Introduce path cleaning

A new function sp is introduced. It does the same as ss but also cleans
the path.
This commit is contained in:
mano3m committed 2013-11-02 10:15:50 +01:00
1 parent 9fa62de6dd
commit fa1baa73e8
10 files changed
+51 -47

No files matched your search

+5
View File
@@ -1,6 +1,7 @@
from couchpotato.core.logger import CPLog
from string import ascii_letters, digits
from urllib import quote_plus
import os
import re
import traceback
import unicodedata
@@ -47,6 +48,10 @@ def ss(original, *args):
log.debug('Failed ss encoding char, force UTF8: %s', e)
return u_original.encode('UTF-8')
def sp(path, *args):
# Standardise encoding, normalise case, path and strip trailing '/' or '\'
return os.path.normcase(os.path.normpath(ss(path, *args))).rstrip(os.path.sep)
def ek(original, *args):
if isinstance(original, (str, unicode)):
try: