diff --git a/CLEAN.sh b/CLEAN.sh new file mode 100755 index 0000000..c4cfbf0 --- /dev/null +++ b/CLEAN.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +rm -r projit.egg-info +rm -r .pytest_cache +rm -r projit/__pycache__/ +rm -r tests/__pycache__/ + diff --git a/projit/__init__.py b/projit/__init__.py index 41e5352..50febaa 100644 --- a/projit/__init__.py +++ b/projit/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.1.4" +__version__ = "0.1.5" from .utils import locate_projit_config from .projit import projit_load diff --git a/projit/cli.py b/projit/cli.py index d7f865b..a383035 100644 --- a/projit/cli.py +++ b/projit/cli.py @@ -36,7 +36,12 @@ def main(): if cmd == "status": project_status(project) if cmd == "render": - render_doc(project) + if len(sys.argv) < 3: + print("ERROR: Rendering a project requires a path for output file.") + exit(1) + else: + path = sys.argv[2] + render_doc(project, path) if cmd == "list": if len(sys.argv) < 3: print("ERROR: MISSING ARGUMENTS") @@ -105,8 +110,8 @@ def project_status(project): print("") ########################################################################################## -def render_doc(project): - print("YOU WANT A DOC RENDERED") +def render_doc(project, path): + project.render(path) ########################################################################################## def list(subcmd, project): diff --git a/projit/pdf.py b/projit/pdf.py new file mode 100644 index 0000000..48109be --- /dev/null +++ b/projit/pdf.py @@ -0,0 +1,20 @@ +from fpdf import FPDF + +class PDF(FPDF): + + def setup(self): + self.add_page() + + def add_title(self, title): + self.set_xy(0.0,0.0) + self.set_font('Arial', 'B', 16) + self.set_text_color(50, 50, 50) + self.cell(w=210.0, h=40.0, align='C', txt=title, border=0) + + def add_description(self, description): + self.set_xy(10.0,40.0) + self.set_text_color(32.0, 32.0, 32.0) + self.set_font('Arial', '', 12) + self.multi_cell(0,10,description) + + diff --git a/projit/projit.py b/projit/projit.py index 65b13ce..5b20082 100644 --- a/projit/projit.py +++ b/projit/projit.py @@ -7,6 +7,7 @@ from .config import config_folder from .template import load_template from .utils import locate_projit_config +from .pdf import PDF ########################################################################################## @@ -154,6 +155,15 @@ def save(self): with open(path_to_json, 'w') as outfile: json.dump(self.__dict__, outfile, indent=0) + def render(self, path): + results = self.get_results() + pdf = PDF() + pdf.setup() + pdf.add_title(self.name) + pdf.add_description(self.desc) + pdf.output(path, 'F') + + ########################################################################################## def load(config_path): """ diff --git a/requirements.txt b/requirements.txt index 9eb7ffb..d1f662f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ -pyYaml +numpy +pyyaml pandas +fpdf diff --git a/setup.py b/setup.py index f7b355b..126301b 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ name = "projit", packages = ["projit"], license = "MIT", - install_requires = ['pyyaml', 'pandas'], + install_requires = ['numpy', 'pyyaml', 'pandas', 'fpdf'], entry_points = { "console_scripts": ['projit = projit.cli:main'] },