This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
PokestarFan
committed
Oct 15, 2017
1 parent
9c5fdb9
commit eebc6b3
Showing
4 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from __future__ import absolute_import | ||
from __future__ import (print_function, unicode_literals) | ||
|
||
|
||
class Table(): | ||
"""docstring for Table. | ||
This is the main class. It adds rows and columns, with data | ||
""" | ||
def __init__(self,name): | ||
super(Table, self).__init__() | ||
self.rows = 0 | ||
self.columns = 1 | ||
self.table = '''|{}|'''.format(str(name)) | ||
|
||
def add_column(self, name): | ||
self.columns += 1 | ||
self.table += '''{}|'''.format(name) | ||
|
||
def finalize_columms(self): | ||
finalizer = '\n|' | ||
for i in range(self.columns): | ||
finalizer += '---|' | ||
self.table += finalizer | ||
|
||
|
||
def add_row(self, list): | ||
self.rows += 1 | ||
row = '|' | ||
try: | ||
assert int(len(list)) == self.columns | ||
except(AssertionError): | ||
raise AssertionError('The list does not have enough values, or has too many values. Make sure only {} values are present.'.format(self.columns)) | ||
for i in range(int(len(list))): | ||
row += '{}|'.format(list[i]) | ||
self.table += '\n{}'.format(row) | ||
|
||
def get_table(self): | ||
return self.table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from setuptools import setup | ||
|
||
|
||
setup(name='markdowntable', | ||
version='0.1', | ||
description='Easy way to make markdown code for tables', | ||
url='https://github.com/PokestarFan/Python-Markdown-Table', | ||
author='PokestarFan', | ||
author_email='pokestarfan@yahoo.com', | ||
license='MIT', | ||
packages=['markdowntable'], | ||
zip_safe=True) |