From 2f448db88484e03e2cbf64cea48191367687e454 Mon Sep 17 00:00:00 2001 From: Dan Goldsmith Date: Sun, 5 Jul 2020 22:44:12 +0100 Subject: [PATCH] Code tidy before merge --- .pylintrc | 4 +++- CHANGELOG.md | 17 +++++++++++------ remarkable/controller.py | 24 ++---------------------- remarkable/parser.py | 10 ++-------- remarkable/renderer.py | 10 +--------- remarkable/scripts/runDMC.py | 4 ++-- remarkable/section.py | 7 +------ setup.py | 2 +- 8 files changed, 23 insertions(+), 55 deletions(-) diff --git a/.pylintrc b/.pylintrc index 18fa089..85d38f8 100644 --- a/.pylintrc +++ b/.pylintrc @@ -3,4 +3,6 @@ output-format=json [MESSAGES CONTROL] disable=C0103, - W1202 \ No newline at end of file + W1202, + C0413, + C0115 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f1faccf..6db0fc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,14 @@ -# Current - - - Add a Generic template that does its best to build a sensible report from a file - - Keep track of Section order in the parser - - Calculate Marks - - "Personalsation" of the report via header. +# 0.3.1 + + - Software + - Add a Generic template that does its best to build a sensible report from a file + - Keep track of Section order in the parser + - Calculate Marks + - "Customisation" of the report via header. + - Documentation + - Draft Documentation added + - Install + - Walk-through of Generic Template # 0.3 diff --git a/remarkable/controller.py b/remarkable/controller.py index c8188d7..001a69b 100644 --- a/remarkable/controller.py +++ b/remarkable/controller.py @@ -16,25 +16,6 @@ along with this program. If not, see . """ - -""" -Use Markdown to generate various uni documents - -Controller code to get the workflows working. - -Two use cases at the moment: - - 1. Called with all parts specifid - - Template - - Input File - 1. Called with just an input file. Which contains the template. - -Things to think about: - - 1. Batch conversion, point him at a directory - 1. PDF conversion, use something (QT?) to render the HTML to PDF. -""" - import logging import pathlib @@ -44,16 +25,15 @@ import remarkable.renderer as renderer class RenderError(Exception): """Exception raised for errors in the input. - - @message: explanation of the error """ def __init__(self, message): + super().__init__() self.message = message #env.list_templates() - + def convertFile(inputFile, templateFile=None, templateDir=None, outputFile=None): """ Given a set of options convert a file from markdown diff --git a/remarkable/parser.py b/remarkable/parser.py index 4382437..b609bb3 100644 --- a/remarkable/parser.py +++ b/remarkable/parser.py @@ -16,12 +16,6 @@ along with this program. If not, see . """ - -""" -File to read Markdown files and generate -whatever AST we need to generate -""" - import logging import re @@ -75,7 +69,7 @@ class MarkdownParser(): marks = int(marks) if maxMarks: maxMarks = int(maxMarks) - + #And delete the marks part cleanLine = marksRe.sub("", cleanLine) cleanLine = cleanLine.strip() @@ -186,7 +180,7 @@ class MarkdownParser(): theSection = section.Section(out, marks=currentMarks, header=headerText, - maxMarks = maxMarks) + maxMarks=maxMarks) sections[currentSection] = theSection self.sectionOrder.append(currentSection) diff --git a/remarkable/renderer.py b/remarkable/renderer.py index 3368c77..2dcbd0f 100644 --- a/remarkable/renderer.py +++ b/remarkable/renderer.py @@ -16,14 +16,6 @@ along with this program. If not, see . """ - -"""And a Class for Rendering Files - - -I cant see this going much beyond HTML, but lets keep it here for -completeness. -""" - import logging import jinja2 @@ -142,7 +134,7 @@ class HTMLRenderer(Renderer): calcs = {"marksAwarded": totalAwarded, "marksPossible": totalPossible} - + out = self.template.render({"content":sections, "header": header, "order": theParser.sectionOrder, diff --git a/remarkable/scripts/runDMC.py b/remarkable/scripts/runDMC.py index 6249a13..317c19a 100644 --- a/remarkable/scripts/runDMC.py +++ b/remarkable/scripts/runDMC.py @@ -54,8 +54,8 @@ def main(): parser.add_argument("filename", - help = "File to Convert") - + help="File to Convert") + parser.add_argument("-t", "--template", help="Template file to use for rendering") diff --git a/remarkable/section.py b/remarkable/section.py index 6c1a4fb..9facdfe 100644 --- a/remarkable/section.py +++ b/remarkable/section.py @@ -17,11 +17,6 @@ """ -""" -possibly a little overkill, but I may want -to do per section stuff. Saves Refactoring down the line -""" - import remarkable.renderer as renderer class Section(): @@ -88,7 +83,7 @@ class Section(): """ Render the marks - Either show the awarded marks, + Either show the awarded marks, or the Awarded Marks as part of a total diff --git a/setup.py b/setup.py index 7f06c99..1205627 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( name="remarkable", author="Dan Goldsmith", author_email="djgoldsmith@googlemail.com", - version="0.3.0", + version="0.3.1", #Dependencies install_requires=requires, tests_require=testRequires,