Fix unicode decoding bug in compatability.py and add_original_name.py (#194)

This commit is contained in:
Jaisen Mathai 2017-01-24 00:25:52 -08:00 committed by GitHub
parent ed1dbc6c9a
commit 56f0b1e170
2 changed files with 6 additions and 7 deletions

View File

@ -1,10 +1,11 @@
import os
import shutil
import sys
from elodie import constants
def _decode(string, encoding='utf8'):
def _decode(string, encoding=sys.getfilesystemencoding()):
"""Return a utf8 encoded unicode string.
Python2 and Python3 differ in how they handle strings.

View File

@ -30,11 +30,10 @@ def main(argv):
if os.path.isdir(path):
for source in filesystem.get_all_files(path, None):
status = add_original_name(source, subclasses)
result.append((source, status))
result.append((_decode(source), status))
else:
status = add_original_name(path, subclasses)
result.append((path, status))
result.append((_decode(path), status))
result.write()
@ -52,7 +51,6 @@ def add_original_name(source, subclasses):
original_name = parse_original_name_from_media(metadata)
return media.set_original_name(original_name)
def parse_original_name_from_media(metadata):
# 2015-07-23_04-31-12-img_9414-test3.jpg
base_name = metadata['base_name']