mirror of
https://github.com/SickGear/SickGear.git
synced 2024-11-24 13:55:16 +00:00
e56303798c
Initial SickGear for Python 3.
30 lines
788 B
Python
30 lines
788 B
Python
from hachoir.core.error import warning
|
|
|
|
|
|
def fault_tolerant(func, *args):
|
|
def safe_func(*args, **kw):
|
|
try:
|
|
func(*args, **kw)
|
|
except Exception as err:
|
|
warning("Error when calling function %s(): %s" % (
|
|
func.__name__, err))
|
|
return safe_func
|
|
|
|
|
|
def getFieldAttribute(fieldset, key, attrname):
|
|
try:
|
|
field = fieldset[key]
|
|
if field.hasValue():
|
|
return getattr(field, attrname)
|
|
except Exception as err:
|
|
warning("Unable to get %s of field %s/%s: %s" % (
|
|
attrname, fieldset.path, key, err))
|
|
return None
|
|
|
|
|
|
def getValue(fieldset, key):
|
|
return getFieldAttribute(fieldset, key, "value")
|
|
|
|
|
|
def getDisplay(fieldset, key):
|
|
return getFieldAttribute(fieldset, key, "display")
|