truedat101 / gitinspector

Automatically exported from code.google.com/p/gitinspector
GNU General Public License v3.0
0 stars 0 forks source link

Problem with non-ascii filenames #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Repositories with non-ascii filenames from Windows causes problems in Linux 
environment:
Traceback (most recent call last):
  File "/home/legogris/gitinspector/gitinspector.py", line 135, in <module>
    __run__.output()
  File "/home/legogris/gitinspector/gitinspector.py", line 59, in output
    outputable.output(blame.BlameOutput(self.hard))
  File "/home/legogris/gitinspector/outputable.py", line 37, in output
    outputable.output_text()
  File "/home/legogris/gitinspector/blame.py", line 210, in output_text
    get(self.hard)
  File "/home/legogris/gitinspector/blame.py", line 149, in get
    __blame__ = Blame(hard)
  File "/home/legogris/gitinspector/blame.py", line 97, in __init__
    if FileDiff.is_valid_extension(row) and not filtering.set_filtered(FileDiff.get_filename(row)):
  File "/home/legogris/gitinspector/changes.py", line 58, in is_valid_extension
    extension = FileDiff.get_extension(string)
  File "/home/legogris/gitinspector/changes.py", line 48, in get_extension
    string = FileDiff.get_filename(string)
  File "/home/legogris/gitinspector/changes.py", line 54, in get_filename
    return codecs.getdecoder('unicode_escape')(string.strip())[0]
UnicodeEncodeError: 'ascii' codec can't encode characters in position 16-17: 
ordinal not in range(128)

Replacing FileDiff.get_extension and get_filename in change.py with the 
following fixes the issue for me:

@staticmethod
def get_extension(string):
  string = FileDiff.get_filename(string)
  return os.path.splitext(string)[1][1:]

@staticmethod
def get_filename(string):
  string = string.split("|")[0].strip().strip("{}").strip("\"").strip("'").encode('latin-1')                   
  return codecs.getdecoder('unicode_escape')(string.strip())[0]

Original issue reported on code.google.com by robert.e...@gmail.com on 13 May 2013 at 9:58

GoogleCodeExporter commented 9 years ago
Hi Robert.

Your solution would break utf-8 encoded strings. There are also compatibility 
issues between Python 2 and 3. The 2.1 release of gitinspector should work just 
fine with Python 3. In the meantime, this bug should already have been fixed in 
the master branch in revision 35214550f35f.

Try checking out the current master branch and try again. It should hopefully 
fix it.

/Adam Waldenberg

Original comment by gitinspe...@ejwa.se on 13 May 2013 at 11:26

GoogleCodeExporter commented 9 years ago
It seems there are still some issues related to this. I will take a look as 
soon as possible. "unicode-escape" and "string-escape" behave slightly 
different and these problems were introduced with the Python 3 fixes that were 
done previously.

/Adam Waldenberg

Original comment by gitinspe...@ejwa.se on 15 May 2013 at 12:00

GoogleCodeExporter commented 9 years ago
This issue was closed by revision cf40f16119ab.

Original comment by gitinspe...@ejwa.se on 16 May 2013 at 1:07