diff options
-rw-r--r-- | diff2HtmlCompare.py | 16 |
1 files 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)
|