python3 support
This commit is contained in:
parent
3e34e7b53b
commit
4949162dc8
1 changed files with 330 additions and 330 deletions
|
|
@ -24,7 +24,7 @@
|
||||||
import sys
|
import sys
|
||||||
import difflib
|
import difflib
|
||||||
import argparse
|
import argparse
|
||||||
import StringIO
|
import io
|
||||||
import pygments
|
import pygments
|
||||||
from pygments.lexers import guess_lexer_for_filename
|
from pygments.lexers import guess_lexer_for_filename
|
||||||
from pygments.lexer import RegexLexer
|
from pygments.lexer import RegexLexer
|
||||||
|
|
@ -147,7 +147,7 @@ class DiffHtmlFormatter(HtmlFormatter):
|
||||||
|
|
||||||
|
|
||||||
def _wrap_tablelinenos(self, inner):
|
def _wrap_tablelinenos(self, inner):
|
||||||
dummyoutfile = StringIO.StringIO()
|
dummyoutfile = io.StringIO()
|
||||||
lncount = 0
|
lncount = 0
|
||||||
for t, line in inner:
|
for t, line in inner:
|
||||||
if t:
|
if t:
|
||||||
|
|
@ -208,8 +208,8 @@ class CodeDiff(object):
|
||||||
with open(fromfile) as f:
|
with open(fromfile) as f:
|
||||||
self.fromlines = f.readlines()
|
self.fromlines = f.readlines()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "Problem reading file %s" % fromfile
|
print("Problem reading file %s" % fromfile)
|
||||||
print e
|
print(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
self.fromlines = [n + "\n" for n in fromtxt.split("\n")]
|
self.fromlines = [n + "\n" for n in fromtxt.split("\n")]
|
||||||
|
|
@ -221,8 +221,8 @@ class CodeDiff(object):
|
||||||
with open(tofile) as f:
|
with open(tofile) as f:
|
||||||
self.tolines = f.readlines()
|
self.tolines = f.readlines()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print "Problem reading file %s" % tofile
|
print("Problem reading file %s" % tofile)
|
||||||
print e
|
print(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
self.tolines = [n + "\n" for n in totxt.split("\n")]
|
self.tolines = [n + "\n" for n in totxt.split("\n")]
|
||||||
|
|
@ -261,7 +261,7 @@ class CodeDiff(object):
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
for diff in self.diffs:
|
for diff in self.diffs:
|
||||||
print "%-6s %-80s %-80s" % ( diff[2], diff[0], diff[1] )
|
print("%-6s %-80s %-80s" % ( diff[2], diff[0], diff[1] ))
|
||||||
|
|
||||||
fields = ( (self.leftcode, True, self.fromfile) , (self.rightcode, False, self.tofile) )
|
fields = ( (self.leftcode, True, self.fromfile) , (self.rightcode, False, self.tofile) )
|
||||||
|
|
||||||
|
|
@ -279,7 +279,7 @@ class CodeDiff(object):
|
||||||
|
|
||||||
except pygments.util.ClassNotFound:
|
except pygments.util.ClassNotFound:
|
||||||
if verbose:
|
if verbose:
|
||||||
print "No Lexer Found! Using default..."
|
print("No Lexer Found! Using default...")
|
||||||
|
|
||||||
self.lexer = DefaultLexer()
|
self.lexer = DefaultLexer()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue