1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fix for topdown issue in postprocessTV

This commit is contained in:
echel0n 2014-05-14 09:18:54 -07:00
parent e0558ea4cd
commit 0657589be0

View File

@ -30,15 +30,17 @@ def fixStupidEncodings(x, silent=False):
try:
return x.decode(sickbeard.SYS_ENCODING)
except UnicodeDecodeError:
logger.log(u"Unable to decode value: "+repr(x), logger.ERROR)
logger.log(u"Unable to decode value: " + repr(x), logger.ERROR)
return None
elif type(x) == unicode:
return x
else:
logger.log(u"Unknown value passed in, ignoring it: "+str(type(x))+" ("+repr(x)+":"+repr(type(x))+")", logger.DEBUG if silent else logger.ERROR)
logger.log(
u"Unknown value passed in, ignoring it: " + str(type(x)) + " (" + repr(x) + ":" + repr(type(x)) + ")",
logger.DEBUG if silent else logger.ERROR)
return None
return None
def fixListEncodings(x):
if type(x) != list and type(x) != tuple:
@ -46,24 +48,28 @@ def fixListEncodings(x):
else:
return filter(lambda x: x != None, map(fixStupidEncodings, x))
def callPeopleStupid(x):
try:
return x.encode(sickbeard.SYS_ENCODING)
except UnicodeEncodeError:
logger.log(u"YOUR COMPUTER SUCKS! Your data is being corrupted by a bad locale/encoding setting. Report this error on the forums or IRC please: "+repr(x)+", "+sickbeard.SYS_ENCODING, logger.ERROR)
logger.log(
u"YOUR COMPUTER SUCKS! Your data is being corrupted by a bad locale/encoding setting. Report this error on the forums or IRC please: " + repr(
x) + ", " + sickbeard.SYS_ENCODING, logger.ERROR)
return x.encode(sickbeard.SYS_ENCODING, 'ignore')
def ek(func, *args):
def ek(func, *args, **kwargs):
result = None
if os.name == 'nt':
result = func(*args)
result = func(*args, **kwargs)
else:
result = func(*[callPeopleStupid(x) if type(x) in (str, unicode) else x for x in args])
result = func(*[callPeopleStupid(x) if type(x) in (str, unicode) else x for x in args], **kwargs)
if type(result) in (list, tuple):
return fixListEncodings(result)
elif type(result) == str:
return fixStupidEncodings(result)
else:
return result
return result