Fixed compatibility with Python 3.
This commit is contained in:
parent
00c0218896
commit
b1dfade98d
3
blame.py
3
blame.py
|
@ -20,6 +20,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from outputable import Outputable
|
from outputable import Outputable
|
||||||
from changes import FileDiff
|
from changes import FileDiff
|
||||||
|
import codecs
|
||||||
import comment
|
import comment
|
||||||
import filtering
|
import filtering
|
||||||
import format
|
import format
|
||||||
|
@ -91,7 +92,7 @@ class Blame:
|
||||||
|
|
||||||
for i, row in enumerate(lines):
|
for i, row in enumerate(lines):
|
||||||
row = row.decode("utf-8", "replace").strip().strip("\"").strip("'")
|
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 FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
|
||||||
if not missing.add(row.strip()):
|
if not missing.add(row.strip()):
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from outputable import Outputable
|
from outputable import Outputable
|
||||||
|
import codecs
|
||||||
import extensions
|
import extensions
|
||||||
import filtering
|
import filtering
|
||||||
import interval
|
import interval
|
||||||
|
@ -45,13 +46,13 @@ class FileDiff:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_extension(string):
|
def get_extension(string):
|
||||||
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
|
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:]
|
return os.path.splitext(string)[1][1:]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_filename(string):
|
def get_filename(string):
|
||||||
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
|
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
|
||||||
return string.decode("string_escape").strip()
|
return codecs.getdecoder('unicode_escape')(string.strip())[0]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_valid_extension(string):
|
def is_valid_extension(string):
|
||||||
|
|
|
@ -52,7 +52,7 @@ def __get_zip_file_content__(name):
|
||||||
zip_file = zipfile.ZipFile(basedir.get_basedir() + "/html/flot.zip", "r")
|
zip_file = zipfile.ZipFile(basedir.get_basedir() + "/html/flot.zip", "r")
|
||||||
content = zip_file.read(name)
|
content = zip_file.read(name)
|
||||||
zip_file.close()
|
zip_file.close()
|
||||||
return content
|
return content.decode("utf-8", "replace")
|
||||||
|
|
||||||
def output_header():
|
def output_header():
|
||||||
if __selected_format__ == "html":
|
if __selected_format__ == "html":
|
||||||
|
@ -67,7 +67,7 @@ def output_header():
|
||||||
logo_file.close()
|
logo_file.close()
|
||||||
logo = base64.b64encode(logo)
|
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":
|
elif __selected_format__ == "xml":
|
||||||
print("<gitinspector>")
|
print("<gitinspector>")
|
||||||
print("\t<version>" + version.__version__ + "</version>")
|
print("\t<version>" + version.__version__ + "</version>")
|
||||||
|
|
Loading…
Reference in New Issue