Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit 3a333f8

Browse files
author
PokestarFan
committed
Add changes
1 parent 96d9ed6 commit 3a333f8

File tree

3 files changed

+46
-13
lines changed

3 files changed

+46
-13
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ source*
109109

110110
#my custom file
111111
setupcommands.bat
112+
113+
#.anything
114+
.*

Diff for: markdowntable/__init__.py

+33-13
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
1-
from __future__ import print_function, unicode_literals
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
23

4+
from __future__ import print_function, unicode_literals
5+
from .exceptions import SupressedError
36

47
class Table():
58
"""docstring for Table.
69
This is the main class. It adds rows and columns, with data
710
"""
8-
def __init__(self, name):
11+
def __init__(self, name, debug = True):
912
super(Table, self).__init__()
13+
self.debug = debug
1014
self.rows = 0
1115
self.columns = 1
1216
self.table = '''|{}|'''.format(str(name))
1317
self.finalized = False
18+
if self.debug:
19+
self.functions = []
1420

1521
def debug(self):
16-
print('''Printing debug information:
17-
Rows: {rows}
18-
Columns: {cols}
19-
Finalized?: {fin}
20-
Table Content: {table}'''.format(rows = str(self.rows),
21-
cols = str(self.columns),
22-
fin = str(self.finalized),
23-
table = self.table))
22+
try:
23+
print('''Printing debug information:
24+
Rows: {rows}
25+
Columns: {cols}
26+
Finalized?: {fin}
27+
Table Content: {table}
28+
Functions: {funcs}'''.format(rows = str(self.rows),
29+
cols = str(self.columns),
30+
fin = str(self.finalized),
31+
table = self.table,
32+
funcs = self.functions))
33+
except(NameError):
34+
pass
35+
except Exception as e:
2436

25-
def add_column(self, name):
37+
def add_column(self, name, all_cols = False):
2638
self.columns += 1
27-
self.table += '''{}|'''.format(name)
39+
self.table += '{}|'.format(str(name))
40+
try:
41+
if all_cols:
42+
return {'function':'add_column', 'data': [str(name)]}
43+
else:
44+
self.functions.append({'function':'add_column', 'data': [str(name)]})
45+
except(NameError):
46+
pass
2847

2948
def all_columns(self, *args):
49+
all_col_data = {'function':'all_columns', 'data': []}
3050
for value in args:
31-
self.add_column(str(value))
51+
all_col_data['data'].append(self.add_column(str(value), all_cols = True))
3252

3353
def finalize_cols(self):
3454
finalizer = '\n|'

Diff for: markdowntable/exceptions.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from __future__ import unicode_literals
2+
3+
class SupressedError(Exception):
4+
"""docstring for SupressedError."""
5+
def __init__(self, error, message):
6+
super(SupressedError, self).__init__()
7+
Exception.__init__(self, '''An error has occured. Printing error. information:
8+
Error Name: {n}
9+
Error Message: {m}'''.format(n = error,
10+
m = message))

0 commit comments

Comments
 (0)