Skip to content

Commit

Permalink
flake8/pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
emilsvennesson committed Oct 6, 2024
1 parent f229a68 commit 3c52011
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions lib/inputstreamhelper/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""This is the actual InputStream Helper API script"""

from __future__ import absolute_import, division, unicode_literals

from . import Helper
from .kodiutils import ADDON, log

Expand Down
1 change: 0 additions & 1 deletion lib/inputstreamhelper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""Configuration variables for inpustreamhelper"""
from __future__ import absolute_import, division, unicode_literals


INPUTSTREAM_PROTOCOLS = {
'mpd': 'inputstream.adaptive',
'ism': 'inputstream.adaptive',
Expand Down
3 changes: 2 additions & 1 deletion lib/inputstreamhelper/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def addon_version(addon_name=None):
return get_addon_info('version', addon)


def browsesingle(type, heading, shares='', mask='', useThumbs=False, treatAsFolder=False, defaultt=None): # pylint: disable=invalid-name,redefined-builtin
# pylint: disable=invalid-name,redefined-builtin,too-many-positional-arguments
def browsesingle(type, heading, shares='', mask='', useThumbs=False, treatAsFolder=False, defaultt=None):
"""Show a Kodi browseSingle dialog"""
from xbmcgui import Dialog
if not heading:
Expand Down
8 changes: 5 additions & 3 deletions lib/inputstreamhelper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def download_path(url):
def _http_request(url, headers=None, time_out=30):
"""Make a robust HTTP request handling redirections."""
try:
response = urlopen(url, timeout=time_out) # pylint: disable=consider-using-with:w
response = urlopen(url, timeout=time_out) # pylint: disable=consider-using-with:w
if response.status in [301, 302, 303, 307, 308]: # Handle redirections
new_url = response.getheader('Location')
log(1, f"Redirecting to {new_url}")
Expand All @@ -90,17 +90,18 @@ def _http_request(url, headers=None, time_out=30):
log(2, f"HTTP request timed out: {err}")
return None


def http_get(url):
"""Perform an HTTP GET request and return content"""
req = _http_request(url)
if req is None:
return None

content = req.read()
# NOTE: Do not log reponse (as could be large)
# log(0, 'Response: {response}', response=content)
return content.decode("utf-8")


def http_head(url):
"""Perform an HTTP HEAD request and return status code."""
req = Request(url)
Expand All @@ -111,7 +112,8 @@ def http_head(url):
except HTTPError as exc:
return exc.getcode()

def http_download(url, message=None, checksum=None, hash_alg='sha1', dl_size=None, background=False): # pylint: disable=too-many-statements

def http_download(url, message=None, checksum=None, hash_alg='sha1', dl_size=None, background=False): # pylint: disable=too-many-statements
"""Makes HTTP request and displays a progress dialog on download."""
if checksum:
from hashlib import md5, sha1
Expand Down
9 changes: 6 additions & 3 deletions lib/inputstreamhelper/widevine/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"""Implements ARM specific widevine functions"""

from __future__ import absolute_import, division, unicode_literals
import os

import json
import os

from .. import config
from ..kodiutils import browsesingle, localize, log, ok_dialog, open_file, progress_dialog, yesno_dialog
from ..utils import diskspace, http_download, http_get, parse_version, sizeof_fmt, system_os, update_temp_path, userspace64
from ..kodiutils import (browsesingle, localize, log, ok_dialog, open_file,
progress_dialog, yesno_dialog)
from ..utils import (diskspace, http_download, http_get, parse_version,
sizeof_fmt, system_os, update_temp_path, userspace64)
from .arm_chromeos import ChromeOSImage
from .arm_lacros import cdm_from_lacros, install_widevine_arm_lacros

Expand Down
5 changes: 3 additions & 2 deletions lib/inputstreamhelper/widevine/arm_chromeos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
"""Implements a class with methods related to the Chrome OS image"""

from __future__ import absolute_import, division, unicode_literals

import os
from io import UnsupportedOperation
from struct import calcsize, unpack
from zipfile import ZipFile
from io import UnsupportedOperation

from ..kodiutils import exists, localize, log, mkdirs
from .. import config
from ..kodiutils import exists, localize, log, mkdirs
from ..unicodes import compat_path


Expand Down
2 changes: 1 addition & 1 deletion lib/inputstreamhelper/widevine/widevine.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def widevine_eula():
cdm_arch = config.WIDEVINE_ARCH_MAP_REPO[arch()]
else: # Grab the license from the x86 files
log(0, 'Acquiring Widevine EULA from x86 files.')
cdm_version = '4.10.2830.0' # fine to hardcode as it's only used for the EULA
cdm_version = '4.10.2830.0' # fine to hardcode as it's only used for the EULA
cdm_os = 'mac'
cdm_arch = 'x64'

Expand Down
6 changes: 4 additions & 2 deletions tests/xbmcgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""This file implements the Kodi xbmcgui module, either using stubs or alternative functionality"""

# flake8: noqa: FI14; pylint: disable=invalid-name,super-on-old-class,too-few-public-methods,too-many-arguments,unused-argument,useless-super-delegation
# flake8: noqa: FI14; pylint: disable=invalid-name,super-on-old-class,too-few-public-methods,too-many-arguments,unused-argument,useless-super-delegation,too-many-positional-arguments

from __future__ import absolute_import, division, print_function

import sys
from xbmcextra import kodi_to_ansi

from .xbmcextra import kodi_to_ansi


class Control:
Expand Down

0 comments on commit 3c52011

Please sign in to comment.