Fixed a long standing bug related to international characters.

This bug occurred because whenever the "git blame" command detects
international character it outputs a string escaped character string in
the form "\ddd\ddd". Gitinspector didn't properly handle this. Python
offers a way to decode this using the decode function together with the
"string_escape" encoding.
This commit is contained in:
Adam Waldenberg 2013-04-16 14:58:33 +02:00
parent 66915b7737
commit 0fc69ff19c
2 changed files with 7 additions and 4 deletions

View File

@ -88,7 +88,8 @@ class Blame:
lines = ls_tree_r.readlines()
for i, row in enumerate(lines):
row = row.decode("utf-8", "replace")
row = row.decode("utf-8", "replace").strip().strip("\"").strip("'")
row = row.decode("string_escape").strip()
if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
if not missing.add(row.strip()):
blame_string = "git blame -w {0} \"".format("-C -C -M" if hard else "") + row.strip() + "\""

View File

@ -26,6 +26,7 @@ import os
import subprocess
import terminal
import textwrap
import sys
class FileDiff:
def __init__(self, string):
@ -43,13 +44,14 @@ class FileDiff:
@staticmethod
def get_extension(string):
string = string.split("|")[0].strip().strip("{}")
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
string = string.decode("string_escape").strip()
return os.path.splitext(string)[1][1:]
@staticmethod
def get_filename(string):
string = string.split("|")[0].strip().strip("{}")
return string.strip()
string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'")
return string.decode("string_escape").strip()
@staticmethod
def is_valid_extension(string):