summaryrefslogtreecommitdiff
path: root/ishtar_common/utils.py
diff options
context:
space:
mode:
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
commit3b5fed22ed65b818caa65a0ee3e7eeed599ec045 (patch)
treef3c8e0b9b92e1a609e22f2569dc9f5a962ae914e /ishtar_common/utils.py
parent02e0a4a47ef22ff40aca85ea9ccd07c37628d234 (diff)
downloadIshtar-3b5fed22ed65b818caa65a0ee3e7eeed599ec045.tar.bz2
Ishtar-3b5fed22ed65b818caa65a0ee3e7eeed599ec045.zip
Clean media: fix unicode error
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r--ishtar_common/utils.py16
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