mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-09 19:56:11 +00:00
Remove six: string coercion
This commit is contained in:
parent
0e5c5e4c07
commit
57ed8bdedd
8 changed files with 17 additions and 34 deletions
|
@ -11,7 +11,6 @@ import sys
|
|||
import re
|
||||
|
||||
from kodi_six import xbmc, xbmcvfs
|
||||
from six import text_type
|
||||
|
||||
from . import jellyfin_db
|
||||
from ..helper import translate, settings, window, dialog
|
||||
|
@ -362,7 +361,7 @@ def save_sync(sync):
|
|||
|
||||
with open(os.path.join(ADDON_DATA, "sync.json"), "wb") as outfile:
|
||||
data = json.dumps(sync, sort_keys=True, indent=4, ensure_ascii=False)
|
||||
if isinstance(data, text_type):
|
||||
if isinstance(data, str):
|
||||
data = data.encode("utf-8")
|
||||
outfile.write(data)
|
||||
|
||||
|
@ -411,7 +410,7 @@ def save_credentials(credentials):
|
|||
try:
|
||||
with open(os.path.join(ADDON_DATA, "data.json"), "wb") as outfile:
|
||||
data = json.dumps(credentials, sort_keys=True, indent=4, ensure_ascii=False)
|
||||
if isinstance(data, text_type):
|
||||
if isinstance(data, str):
|
||||
data = data.encode("utf-8")
|
||||
outfile.write(data)
|
||||
except Exception:
|
||||
|
|
|
@ -6,7 +6,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
import os
|
||||
|
||||
from kodi_six import xbmcgui, xbmcaddon
|
||||
from six import ensure_text
|
||||
|
||||
from ..helper import window, addon_id
|
||||
from ..helper import LazyLogger
|
||||
|
@ -69,7 +68,7 @@ class ContextMenu(xbmcgui.WindowXMLDialog):
|
|||
):
|
||||
|
||||
option = self.list_.getSelectedItem()
|
||||
self.selected_option = ensure_text(option.getLabel())
|
||||
self.selected_option = option.getLabel()
|
||||
LOG.info("option selected: %s", self.selected_option)
|
||||
|
||||
self.close()
|
||||
|
|
|
@ -7,11 +7,10 @@ import os
|
|||
import logging
|
||||
import traceback
|
||||
|
||||
from six import ensure_text
|
||||
from kodi_six import xbmc, xbmcaddon
|
||||
|
||||
from .. import database
|
||||
from . import get_filesystem_encoding, settings, kodi_version
|
||||
from . import settings, kodi_version
|
||||
from .utils import translate_path
|
||||
|
||||
##################################################################################################
|
||||
|
@ -92,9 +91,6 @@ class MyFormatter(logging.Formatter):
|
|||
logging.Formatter.__init__(self, fmt)
|
||||
|
||||
def format(self, record):
|
||||
if record.pathname:
|
||||
record.pathname = ensure_text(record.pathname, get_filesystem_encoding())
|
||||
|
||||
self._gen_rel_path(record)
|
||||
|
||||
# Call the original formatter class to do the grunt work
|
||||
|
@ -107,8 +103,6 @@ class MyFormatter(logging.Formatter):
|
|||
res = []
|
||||
|
||||
for o in traceback.format_exception(*exc_info):
|
||||
o = ensure_text(o, get_filesystem_encoding())
|
||||
|
||||
if o.startswith(' File "'):
|
||||
# If this split can't handle your file names, you should seriously consider renaming your files.
|
||||
fn = o.split(' File "', 2)[1].split('", line ', 1)[0]
|
||||
|
|
|
@ -13,7 +13,6 @@ from uuid import uuid4
|
|||
from urllib.parse import quote_plus
|
||||
|
||||
from dateutil import tz, parser
|
||||
from six import text_type, string_types, ensure_text, ensure_binary
|
||||
|
||||
from kodi_six import xbmc, xbmcaddon, xbmcgui, xbmcvfs
|
||||
|
||||
|
@ -120,7 +119,7 @@ def event(method, data=None, sender=None, hexlify=False):
|
|||
sender = sender or "plugin.video.jellyfin"
|
||||
|
||||
if hexlify:
|
||||
data = ensure_text(binascii.hexlify(ensure_binary(json.dumps(data))))
|
||||
data = str(binascii.hexlify(json.dumps(data).encode()))
|
||||
|
||||
data = '"[%s]"' % json.dumps(data).replace('"', '\\"')
|
||||
|
||||
|
@ -273,7 +272,7 @@ def values(item, keys):
|
|||
return (
|
||||
(
|
||||
item[key.replace("{", "").replace("}", "")]
|
||||
if isinstance(key, text_type) and key.startswith("{")
|
||||
if isinstance(key, str) and key.startswith("{")
|
||||
else key
|
||||
)
|
||||
for key in keys
|
||||
|
@ -423,9 +422,7 @@ def normalize_string(text):
|
|||
text = text.strip()
|
||||
|
||||
text = text.rstrip(".")
|
||||
text = unicodedata.normalize("NFKD", text_type(text, "utf-8")).encode(
|
||||
"ascii", "ignore"
|
||||
)
|
||||
text = unicodedata.normalize("NFKD", str(text, "utf-8")).encode("ascii", "ignore")
|
||||
|
||||
return text
|
||||
|
||||
|
@ -438,7 +435,7 @@ def split_list(itemlist, size):
|
|||
def convert_to_local(date, timezone=tz.tzlocal()):
|
||||
"""Convert the local datetime to local."""
|
||||
try:
|
||||
date = parser.parse(date) if isinstance(date, string_types) else date
|
||||
date = parser.parse(date) if isinstance(date, str) else date
|
||||
date = date.replace(tzinfo=tz.tzutc())
|
||||
date = date.astimezone(timezone)
|
||||
# Bad metadata defaults to date 1-1-1. Catch it and don't throw errors
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
import json
|
||||
|
||||
import requests
|
||||
from six import ensure_str
|
||||
|
||||
from ..helper.exceptions import HTTPException
|
||||
from ..helper.utils import settings
|
||||
|
@ -416,7 +415,7 @@ class API(object):
|
|||
"User-Agent": self.config.data["http.user_agent"]
|
||||
or "%s/%s"
|
||||
% (self.config.data["app.name"], self.config.data["app.version"]),
|
||||
"x-emby-authorization": ensure_str(auth, "utf-8"),
|
||||
"x-emby-authorization": auth,
|
||||
}
|
||||
|
||||
def send_request(
|
||||
|
|
|
@ -6,7 +6,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
import time
|
||||
|
||||
import requests
|
||||
from six import string_types, ensure_str
|
||||
|
||||
from ..helper.utils import JsonDebugPrinter
|
||||
from ..helper import LazyLogger
|
||||
|
@ -218,7 +217,7 @@ class HTTP(object):
|
|||
if isinstance(value, dict):
|
||||
self._process_params(value)
|
||||
|
||||
if isinstance(value, string_types):
|
||||
if isinstance(value, str):
|
||||
params[key] = self._replace_user_info(value)
|
||||
|
||||
def _get_header(self, data):
|
||||
|
@ -257,14 +256,14 @@ class HTTP(object):
|
|||
)
|
||||
auth += "Version=%s" % self.config.data.get("app.version", "0.0.0")
|
||||
|
||||
data["headers"].update({"x-emby-authorization": ensure_str(auth, "utf-8")})
|
||||
data["headers"].update({"x-emby-authorization": auth})
|
||||
|
||||
if self.config.data.get("auth.token") and self.config.data.get("auth.user_id"):
|
||||
|
||||
auth += ", UserId=%s" % self.config.data.get("auth.user_id")
|
||||
data["headers"].update(
|
||||
{
|
||||
"x-emby-authorization": ensure_str(auth, "utf-8"),
|
||||
"x-emby-authorization": auth,
|
||||
"X-MediaBrowser-Token": self.config.data.get("auth.token"),
|
||||
}
|
||||
)
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
from collections import namedtuple
|
||||
from collections.abc import Iterable, Mapping, MutableMapping
|
||||
|
||||
from six import string_types
|
||||
|
||||
|
||||
def clean_none_dict_values(obj):
|
||||
"""
|
||||
Recursively remove keys with a value of None
|
||||
"""
|
||||
if not isinstance(obj, Iterable) or isinstance(obj, string_types):
|
||||
if not isinstance(obj, Iterable) or isinstance(obj, str):
|
||||
return obj
|
||||
|
||||
queue = [obj]
|
||||
|
@ -24,7 +22,7 @@ def clean_none_dict_values(obj):
|
|||
if value is None and mutable:
|
||||
remove.append(key)
|
||||
|
||||
elif isinstance(value, string_types):
|
||||
elif isinstance(value, str):
|
||||
continue
|
||||
|
||||
elif isinstance(value, Iterable):
|
||||
|
@ -37,7 +35,7 @@ def clean_none_dict_values(obj):
|
|||
|
||||
elif isinstance(item, Iterable):
|
||||
for value in item:
|
||||
if value is None or isinstance(value, string_types):
|
||||
if value is None or isinstance(value, str):
|
||||
continue
|
||||
elif isinstance(value, Iterable):
|
||||
queue.append(value)
|
||||
|
|
|
@ -6,9 +6,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
import json
|
||||
import os
|
||||
|
||||
from six import ensure_text
|
||||
|
||||
from ..helper import LazyLogger, get_filesystem_encoding
|
||||
from ..helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -29,7 +27,7 @@ class Objects(object):
|
|||
|
||||
def mapping(self):
|
||||
"""Load objects mapping."""
|
||||
file_dir = os.path.dirname(ensure_text(__file__, get_filesystem_encoding()))
|
||||
file_dir = os.path.dirname(__file__)
|
||||
|
||||
with open(os.path.join(file_dir, "obj_map.json")) as infile:
|
||||
self.objects = json.load(infile)
|
||||
|
|
Loading…
Reference in a new issue