parent
b450929553
commit
73358d1c22
|
@ -19,17 +19,29 @@ def fixName(txt, char='_'):
|
||||||
txt = re.sub(r'[\0\/\\:*?"<>|]', char, txt)
|
txt = re.sub(r'[\0\/\\:*?"<>|]', char, txt)
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
|
def fixEndOfData(bString):
|
||||||
|
try:
|
||||||
|
bString.decode()
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
def fixLongName(name):
|
def fixLongName(name):
|
||||||
if pathSep in name:
|
if pathSep in name:
|
||||||
name2 = name.split(pathSep)
|
name2 = name.split(pathSep)
|
||||||
name = ""
|
name = ""
|
||||||
for txt in name2:
|
for txt in name2:
|
||||||
txt = txt[:200]
|
txt = txt.encode('utf-8')[:200]
|
||||||
|
while not fixEndOfData(txt):
|
||||||
|
txt = txt[:-1]
|
||||||
|
txt = txt.decode()
|
||||||
name += txt + pathSep
|
name += txt + pathSep
|
||||||
name = name[:-1]
|
name = name[:-1]
|
||||||
else:
|
else:
|
||||||
name = name[:200]
|
name = name.encode('utf-8')[:200]
|
||||||
|
while not fixEndOfData(name):
|
||||||
|
name = name[:-1]
|
||||||
|
name = name.decode()
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue