def clean_file_name(fname): # Just in case - control path separators fname = fname.replace(os.sep, '') fname = fname.translate(other_reserved) if version.WINDOWS: # Just in case fname = fname.translate(windows_reserved) # Seriously, not sure very long names are practical anyways # I know that this is Windows only, on newer versions we probably could set "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled 1" and remove this line fname = smart_truncate(fname, max_length=240) return fname
def test_smart_truncate_no_seperator(self): txt = '1,000 reasons you are #1' r = smart_truncate(txt, max_length=100, separator='_') self.assertEqual(r, txt)
def test_smart_truncate_no_max_length(self): txt = '1,000 reasons you are #1' r = smart_truncate(txt) self.assertEqual(r, txt)