Reduce number of imports
This commit is contained in:
parent
907c542950
commit
6ed00a7b11
1 changed files with 16 additions and 2 deletions
|
@ -2,8 +2,6 @@
|
|||
###############################################################################
|
||||
import logging
|
||||
import xbmc
|
||||
|
||||
from utils import tryEncode
|
||||
###############################################################################
|
||||
LEVELS = {
|
||||
logging.ERROR: xbmc.LOGERROR,
|
||||
|
@ -14,6 +12,22 @@ LEVELS = {
|
|||
###############################################################################
|
||||
|
||||
|
||||
def tryEncode(uniString, encoding='utf-8'):
|
||||
"""
|
||||
Will try to encode uniString (in unicode) to encoding. This possibly
|
||||
fails with e.g. Android TV's Python, which does not accept arguments for
|
||||
string.encode()
|
||||
"""
|
||||
if isinstance(uniString, str):
|
||||
# already encoded
|
||||
return uniString
|
||||
try:
|
||||
uniString = uniString.encode(encoding, "ignore")
|
||||
except TypeError:
|
||||
uniString = uniString.encode()
|
||||
return uniString
|
||||
|
||||
|
||||
def config():
|
||||
logger = logging.getLogger('PLEX')
|
||||
logger.addHandler(LogHandler())
|
||||
|
|
Loading…
Reference in a new issue