diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-28 17:38:55 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-01-28 17:38:55 +0100 |
commit | 20c3109c1a43a60a393286fd34c693ec45d7495e (patch) | |
tree | f3c8e0b9b92e1a609e22f2569dc9f5a962ae914e /ishtar_common/utils.py | |
parent | f13c6223b5a6fe3ee4a138a5263de85b8103de8d (diff) | |
download | Ishtar-20c3109c1a43a60a393286fd34c693ec45d7495e.tar.bz2 Ishtar-20c3109c1a43a60a393286fd34c693ec45d7495e.zip |
Clean media: fix unicode error
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index e6bc38237..3e05ff6eb 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -1001,12 +1001,12 @@ def simplify_name(full_path_name, check_existing=False): name = name_exp[-1] current_name = name[:] ext = "" - if u"." in name: # remove extension if have one - names = name.split(u".") - name = u".".join(names[0:-1]) - ext = u"." + names[-1] + if "." in name: # remove extension if have one + names = name.split(".") + name = ".".join(names[0:-1]) + ext = "." + names[-1] - while u"_" in name and len(name) > 15: + while "_" in name and len(name) > 15: oldname = name[:] for regex in MEDIA_RE: match = None @@ -1214,11 +1214,11 @@ def try_fix_file(filename, make_copy=True): filename, check_existing=False) try: - dirs = list(os.listdir(path)) + dirs = list(sorted(os.listdir(path))) except UnicodeDecodeError: - dirs = list(os.listdir(path.encode('utf-8'))) + dirs = list(sorted(os.listdir(path.encode('utf-8')))) # check existing files in the path - for file in sorted(dirs): + for file in dirs: full_file = os.sep.join([path, file]) if not os.path.isfile(full_file): # must be a file continue |