remove 'shorten_path()' and 'shorten_filename()'
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
|
||||
"""Collection of functions that work in strings/text"""
|
||||
|
||||
import sys
|
||||
import re
|
||||
import os.path
|
||||
import html
|
||||
@@ -78,19 +77,6 @@ def clean_path_posix(path):
|
||||
return ""
|
||||
|
||||
|
||||
def shorten_path(path, limit=255, encoding=sys.getfilesystemencoding()):
|
||||
"""Shorten a path segment to at most 'limit' bytes"""
|
||||
return (path.encode(encoding)[:limit]).decode(encoding, "ignore")
|
||||
|
||||
|
||||
def shorten_filename(fname, limit=255, encoding=sys.getfilesystemencoding()):
|
||||
"""Shorten filename to at most 'limit' bytes while preserving extension"""
|
||||
name, extension = os.path.splitext(fname)
|
||||
bext = extension.encode(encoding)
|
||||
bname = name.encode(encoding)[:limit-len(bext)]
|
||||
return bname.decode(encoding, "ignore") + extension
|
||||
|
||||
|
||||
def extract(txt, begin, end, pos=0):
|
||||
"""Extract the text between 'begin' and 'end' from 'txt'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user