Skip to content

Commit

Permalink
V0.1.5 Adding initial document rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
John Hawkins authored and John Hawkins committed Apr 27, 2021
1 parent cf4b368 commit 1d47045
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CLEAN.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

rm -r projit.egg-info
rm -r .pytest_cache
rm -r projit/__pycache__/
rm -r tests/__pycache__/

2 changes: 1 addition & 1 deletion projit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.4"
__version__ = "0.1.5"

from .utils import locate_projit_config
from .projit import projit_load
Expand Down
11 changes: 8 additions & 3 deletions projit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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):
Expand Down
20 changes: 20 additions & 0 deletions projit/pdf.py
Original file line number Diff line number Diff line change
@@ -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)


10 changes: 10 additions & 0 deletions projit/projit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .config import config_folder
from .template import load_template
from .utils import locate_projit_config
from .pdf import PDF

##########################################################################################

Expand Down Expand Up @@ -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):
"""
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
pyYaml
numpy
pyyaml
pandas
fpdf
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
},
Expand Down

0 comments on commit 1d47045

Please sign in to comment.