Amend previous commit

The comment included a typo and, using 'max' as variable name, I was accidentally shadowing Python's builtin 'max' function
This commit is contained in:
JoeLametta
2018-10-23 08:00:00 +00:00
parent 02fd962094
commit fd6611743b

View File

@@ -161,10 +161,10 @@ def truncate_filename(path):
"""
p, f = os.path.split(os.path.normpath(path))
f, e = os.path.splitext(f)
fn_lim = os.pathconf(p, 'PC_NAME_MAX') # max filenmae length in bytes
max = fn_lim - len(e.encode('utf-8'))
fn_lim = os.pathconf(p, 'PC_NAME_MAX') # max.filename length in bytes
f_max = fn_lim - len(e.encode('utf-8'))
f = unicodedata.normalize('NFC', f)
f_trunc = unicode(f.encode('utf-8')[:max], 'utf-8', errors='ignore')
f_trunc = unicode(f.encode('utf-8')[:f_max], 'utf-8', errors='ignore')
return os.path.join(p, f_trunc + e)