Fixed compatibility with Python 3.

This commit is contained in:
Adam Waldenberg 2013-05-08 18:52:08 +02:00
parent 00c0218896
commit b1dfade98d
3 changed files with 7 additions and 5 deletions

View file

@ -20,6 +20,7 @@
from __future__ import print_function
from outputable import Outputable
from changes import FileDiff
import codecs
import comment
import filtering
import format
@ -91,7 +92,7 @@ class Blame:
for i, row in enumerate(lines):
row = row.decode("utf-8", "replace").strip().strip("\"").strip("'")
row = row.decode("string_escape").strip()
row = codecs.getdecoder('unicode_escape')(row.strip())[0]
if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
if not missing.add(row.strip()):

View file

@ -19,6 +19,7 @@
from __future__ import print_function
from outputable import Outputable
import codecs
import extensions
import filtering
import interval
@ -45,13 +46,13 @@ class FileDiff:
@staticmethod
def get_extension(string):
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
string = string.decode("string_escape").strip()
string = codecs.getdecoder('unicode_escape')(string.strip())[0]
return os.path.splitext(string)[1][1:]
@staticmethod
def get_filename(string):
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
return string.decode("string_escape").strip()
return codecs.getdecoder('unicode_escape')(string.strip())[0]
@staticmethod
def is_valid_extension(string):

View file

@ -52,7 +52,7 @@ def __get_zip_file_content__(name):
zip_file = zipfile.ZipFile(basedir.get_basedir() + "/html/flot.zip", "r")
content = zip_file.read(name)
zip_file.close()
return content
return content.decode("utf-8", "replace")
def output_header():
if __selected_format__ == "html":
@ -67,7 +67,7 @@ def output_header():
logo_file.close()
logo = base64.b64encode(logo)
print(html_header.format(version.__version__, jquery_js, flot_js, pie_js, logo))
print(html_header.format(version.__version__, jquery_js, flot_js, pie_js, logo.decode("utf-8", "replace")))
elif __selected_format__ == "xml":
print("<gitinspector>")
print("\t<version>" + version.__version__ + "</version>")