From 029ba9ab2d0e5369f6e2f4798a5206fd228a40f1 Mon Sep 17 00:00:00 2001 From: Luciana Fujii Pontello Date: Thu, 27 Oct 2016 09:23:48 -0700 Subject: Add requirements.txt --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..459d6d5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +mistune +pygments -- cgit From 79ae1028fec26e6d73a48818b2ce97b5773e8885 Mon Sep 17 00:00:00 2001 From: Luciana Fujii Pontello Date: Thu, 27 Oct 2016 11:21:14 -0700 Subject: CodeDiff: Remove unused file variables Some files are not used, they can be omitted. --- diff2HtmlCompare.py | 8 +------- templates/diff_template.html | 4 +--- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/diff2HtmlCompare.py b/diff2HtmlCompare.py index 9efc859..b3bd42f 100644 --- a/diff2HtmlCompare.py +++ b/diff2HtmlCompare.py @@ -173,10 +173,7 @@ class CodeDiff(object): diffCssFile="./deps/diff.css" diffJsFile="./deps/diff.js" resetCssFile="./deps/reset.css" - semanticCssFile="./deps/semantic.min.css" - semanticJsFile="./deps/semantic.min.js" jqueryJsFile="./deps/jquery.min.js" - commentJsFile="./deps/comment.js" def __init__(self, fromfile, tofile, fromtxt=None, totxt=None, name=None): @@ -259,17 +256,14 @@ class CodeDiff(object): answers = { "html_title": self.filename, - "reset_css": self.resetCssFile, + "reset_css": self.resetCssFile, "pygments_css": self.pygmentsCssFile, "diff_css": self.diffCssFile, - "semantic_css": self.semanticCssFile, "page_title": self.filename, "original_code": codeContents[0], "modified_code": codeContents[1], "jquery_js": self.jqueryJsFile, - "semantic_js": self.semanticJsFile, "diff_js": self.diffJsFile, - "comment_js": self.commentJsFile, } self.htmlContents = diffTemplate % answers diff --git a/templates/diff_template.html b/templates/diff_template.html index 2f8f90b..df86e70 100644 --- a/templates/diff_template.html +++ b/templates/diff_template.html @@ -11,7 +11,6 @@ modified_code: full html contents of modified file jquery_js: path to jquery.min.js diff_js: path to diff.js - comment_js: path to comment.js --> @@ -74,6 +73,5 @@ </div> <script src="%(jquery_js)s" type="text/javascript"></script> <script src="%(diff_js)s" type="text/javascript"></script> -<!--<script src="%(comment_js)s"></script>--> </body> -</html> \ No newline at end of file +</html> -- cgit From 7608485200f83787b6958278c5cbfe9faccb1d76 Mon Sep 17 00:00:00 2001 From: Luciana Fujii Pontello <fujii@cadence.com> Date: Thu, 27 Oct 2016 11:26:46 -0700 Subject: Add Copyright notice to diff2HtmlCompare code --- diff2HtmlCompare.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/diff2HtmlCompare.py b/diff2HtmlCompare.py index b3bd42f..266606a 100644 --- a/diff2HtmlCompare.py +++ b/diff2HtmlCompare.py @@ -1,3 +1,26 @@ +# MIT License +# +# Copyright (c) 2016 Alex Goodman +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + import sys import difflib import argparse -- cgit From bc3237abd0742138b22b0d9e45719e6ca089302b Mon Sep 17 00:00:00 2001 From: Luciana Fujii Pontello <fujii@cadence.com> Date: Thu, 27 Oct 2016 11:58:45 -0700 Subject: Handle exceptions when opening files and close them --- diff2HtmlCompare.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/diff2HtmlCompare.py b/diff2HtmlCompare.py index 266606a..63aa39b 100644 --- a/diff2HtmlCompare.py +++ b/diff2HtmlCompare.py @@ -204,14 +204,26 @@ class CodeDiff(object): self.filename = name self.fromfile = fromfile if fromtxt == None: - self.fromlines = open(fromfile, 'U').readlines() + try: + with open(fromfile) as f: + self.fromlines = f.readlines() + except Exception as e: + print "Problem reading file %s" % fromfile + print e + sys.exit(1) else: self.fromlines = [n + "\n" for n in fromtxt.split("\n")] self.leftcode = "".join(self.fromlines) self.tofile = tofile if totxt == None: - self.tolines = open(tofile, 'U').readlines() + try: + with open(tofile) as f: + self.tolines = f.readlines() + except Exception as e: + print "Problem reading file %s" % tofile + print e + sys.exit(1) else: self.tolines = [n + "\n" for n in totxt.split("\n")] self.rightcode = "".join(self.tolines) -- cgit