1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 11:32:20 -05:00

Taught it to be nice ;)

This commit is contained in:
echel0n 2014-05-14 02:55:53 -07:00
parent 5645eecd9c
commit 1a3a733654

View File

@ -30,17 +30,15 @@ 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:
@ -48,24 +46,20 @@ 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, **kwargs):
def ek(func, *args):
result = None
if os.name == 'nt':
result = func(*args, **kwargs)
result = func(*args)
else:
result = func(*[callPeopleStupid(x) if type(x) in (str, unicode) else x for x in args], **kwargs)
result = func(*[callPeopleStupid(x) if type(x) in (str, unicode) else x for x in args])
if type(result) in (list, tuple):
return fixListEncodings(result)