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 logging
|
||||||
import xbmc
|
import xbmc
|
||||||
|
|
||||||
from utils import tryEncode
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
LEVELS = {
|
LEVELS = {
|
||||||
logging.ERROR: xbmc.LOGERROR,
|
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():
|
def config():
|
||||||
logger = logging.getLogger('PLEX')
|
logger = logging.getLogger('PLEX')
|
||||||
logger.addHandler(LogHandler())
|
logger.addHandler(LogHandler())
|
||||||
|
|
Loading…
Reference in a new issue