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

Commit eebc6b3

Browse files
author
PokestarFan
committed
Make setupable
1 parent 9c5fdb9 commit eebc6b3

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

Diff for: MarkdownTable.py

-4
This file was deleted.

Diff for: markdowntable/__init__.py

Whitespace-only changes.

Diff for: markdowntable/markdowntable.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from __future__ import absolute_import
2+
from __future__ import (print_function, unicode_literals)
3+
4+
5+
class Table():
6+
"""docstring for Table.
7+
This is the main class. It adds rows and columns, with data
8+
"""
9+
def __init__(self,name):
10+
super(Table, self).__init__()
11+
self.rows = 0
12+
self.columns = 1
13+
self.table = '''|{}|'''.format(str(name))
14+
15+
def add_column(self, name):
16+
self.columns += 1
17+
self.table += '''{}|'''.format(name)
18+
19+
def finalize_columms(self):
20+
finalizer = '\n|'
21+
for i in range(self.columns):
22+
finalizer += '---|'
23+
self.table += finalizer
24+
25+
26+
def add_row(self, list):
27+
self.rows += 1
28+
row = '|'
29+
try:
30+
assert int(len(list)) == self.columns
31+
except(AssertionError):
32+
raise AssertionError('The list does not have enough values, or has too many values. Make sure only {} values are present.'.format(self.columns))
33+
for i in range(int(len(list))):
34+
row += '{}|'.format(list[i])
35+
self.table += '\n{}'.format(row)
36+
37+
def get_table(self):
38+
return self.table

Diff for: setup.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from setuptools import setup
2+
3+
4+
setup(name='markdowntable',
5+
version='0.1',
6+
description='Easy way to make markdown code for tables',
7+
url='https://github.com/PokestarFan/Python-Markdown-Table',
8+
author='PokestarFan',
9+
author_email='[email protected]',
10+
license='MIT',
11+
packages=['markdowntable'],
12+
zip_safe=True)

0 commit comments

Comments
 (0)