diff --git a/resources/lib/api.py b/resources/lib/api.py index 78fb7cb6..435ebaaf 100644 --- a/resources/lib/api.py +++ b/resources/lib/api.py @@ -7,17 +7,17 @@ class Api: - ''' Main API class ''' + """Main API class""" _shared_state = {} def __init__(self): - ''' Constructor for Api class ''' + """Constructor for Api class""" self.__dict__ = self._shared_state self.data = {} self.encoding = 'base64' def log(self, msg, level=2): - ''' Log wrapper ''' + """Log wrapper""" ulog(msg, name=self.__class__.__name__, level=level) def has_addon_data(self): diff --git a/resources/lib/monitor.py b/resources/lib/monitor.py index 6570092e..6d87e9fa 100644 --- a/resources/lib/monitor.py +++ b/resources/lib/monitor.py @@ -11,21 +11,21 @@ class UpNextMonitor(Monitor): - ''' Service monitor for Kodi ''' + """Service monitor for Kodi""" def __init__(self): - ''' Constructor for Monitor ''' + """Constructor for Monitor""" self.player = UpNextPlayer() self.api = Api() self.playback_manager = PlaybackManager() Monitor.__init__(self) def log(self, msg, level=1): - ''' Log wrapper ''' + """Log wrapper""" ulog(msg, name=self.__class__.__name__, level=level) def run(self): - ''' Main service loop ''' + """Main service loop""" self.log('Service started', 0) while not self.abortRequested(): @@ -82,7 +82,7 @@ def run(self): self.log('Service stopped', 0) def onNotification(self, sender, method, data): # pylint: disable=invalid-name - ''' Notification event handler for accepting data from add-ons ''' + """Notification event handler for accepting data from add-ons""" if not method.endswith('upnext_data'): # Method looks like Other.upnext_data return diff --git a/resources/lib/player.py b/resources/lib/player.py index 8f92a9dc..145cf020 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -8,7 +8,7 @@ class UpNextPlayer(Player): - ''' Service class for playback monitoring ''' + """Service class for playback monitoring""" last_file = None track = False @@ -30,7 +30,7 @@ def disable_tracking(self): self.state.track = False def onPlayBackStarted(self): # pylint: disable=invalid-name - ''' Will be called when kodi starts playing a file ''' + """Will be called when kodi starts playing a file""" sleep(5000) # Delay for slower devices, should really use onAVStarted for Leia if not getCondVisibility('videoplayer.content(episodes)'): return @@ -43,16 +43,16 @@ def onPlayBackResumed(self): # pylint: disable=invalid-name self.state.pause = False def onPlayBackStopped(self): # pylint: disable=invalid-name - ''' Will be called when user stops playing a file ''' + """Will be called when user stops playing a file""" self.api.reset_addon_data() self.state = State() # Reset state def onPlayBackEnded(self): # pylint: disable=invalid-name - ''' Will be called when Kodi has ended playing a file ''' + """Will be called when Kodi has ended playing a file""" self.api.reset_addon_data() self.state = State() # Reset state def onPlayBackError(self): # pylint: disable=invalid-name - ''' Will be called when when playback stops due to an error ''' + """Will be called when when playback stops due to an error""" self.api.reset_addon_data() self.state = State() # Reset state diff --git a/resources/lib/script.py b/resources/lib/script.py index a786351f..61111b17 100644 --- a/resources/lib/script.py +++ b/resources/lib/script.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # GNU General Public License v2.0 (see COPYING or https://www.gnu.org/licenses/gpl-2.0.txt) -''' This is the actual Up Next API script ''' +"""This is the actual Up Next API script""" from __future__ import absolute_import, division, unicode_literals from datetime import datetime, timedelta @@ -102,7 +102,7 @@ def open_settings(): def run(argv): - ''' Route to API method ''' + """Route to API method""" if len(argv) == 3 and argv[1] == 'test_window': test_popup(argv[2]) else: diff --git a/resources/lib/script_entry.py b/resources/lib/script_entry.py index 517d6ae9..8bb88e41 100644 --- a/resources/lib/script_entry.py +++ b/resources/lib/script_entry.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # GNU General Public License v2.0 (see COPYING or https://www.gnu.org/licenses/gpl-2.0.txt) -''' This is the Up Next script entry point ''' +"""This is the Up Next script entry point""" from __future__ import absolute_import, division, unicode_literals from sys import argv diff --git a/resources/lib/statichelper.py b/resources/lib/statichelper.py index 3eae2c96..c09facf3 100644 --- a/resources/lib/statichelper.py +++ b/resources/lib/statichelper.py @@ -1,19 +1,19 @@ # -*- coding: utf-8 -*- # GNU General Public License v2.0 (see COPYING or https://www.gnu.org/licenses/gpl-2.0.txt) -''' Implements static functions used elsewhere in the add-on ''' +"""Implements static functions used elsewhere in the add-on""" from __future__ import absolute_import, division, unicode_literals def to_unicode(text, encoding='utf-8', errors='strict'): - ''' Force text to unicode ''' + """Force text to unicode""" if isinstance(text, bytes): return text.decode(encoding, errors) return text def from_unicode(text, encoding='utf-8', errors='strict'): - ''' Force unicode to text ''' + """Force unicode to text""" import sys if sys.version_info.major == 2 and isinstance(text, unicode): # noqa: F821; pylint: disable=undefined-variable,useless-suppression return text.encode(encoding, errors) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index b65ab054..59684a56 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -13,37 +13,37 @@ def get_addon_info(key): - ''' Return add-on information ''' + """Return add-on information""" return to_unicode(ADDON.getAddonInfo(key)) def addon_id(): - ''' Return add-on ID ''' + """Return add-on ID""" return get_addon_info('id') def addon_path(): - ''' Return add-on path ''' + """Return add-on path""" return get_addon_info('path') def get_property(key, window_id=10000): - ''' Get a Window property ''' + """Get a Window property""" return to_unicode(Window(window_id).getProperty(key)) def set_property(key, value, window_id=10000): - ''' Set a Window property ''' + """Set a Window property""" return Window(window_id).setProperty(key, from_unicode(str(value))) def clear_property(key, window_id=10000): - ''' Clear a Window property ''' + """Clear a Window property""" return Window(window_id).clearProperty(key) def get_setting(key, default=None): - ''' Get an add-on setting ''' + """Get an add-on setting""" # We use Addon() here to ensure changes in settings are reflected instantly try: value = to_unicode(Addon().getSetting(key)) @@ -55,7 +55,7 @@ def get_setting(key, default=None): def encode_data(data, encoding='base64'): - ''' Encode data for a notification event ''' + """Encode data for a notification event""" json_data = json.dumps(data).encode() if encoding == 'base64': from base64 import b64encode @@ -72,7 +72,7 @@ def encode_data(data, encoding='base64'): def decode_data(encoded): - ''' Decode data coming from a notification event ''' + """Decode data coming from a notification event""" encoding = 'base64' from binascii import Error, unhexlify try: @@ -94,7 +94,7 @@ def decode_json(data): def event(message, data=None, sender=None, encoding='base64'): - ''' Send internal notification event ''' + """Send internal notification event""" data = data or {} sender = sender or addon_id() @@ -110,7 +110,7 @@ def event(message, data=None, sender=None, encoding='base64'): def log(msg, name=None, level=1): - ''' Log information to the Kodi log ''' + """Log information to the Kodi log""" log_level = int(get_setting('logLevel', level)) debug_logging = get_global_setting('debug.showloginfo') set_property('logLevel', log_level) @@ -121,14 +121,14 @@ def log(msg, name=None, level=1): def calculate_progress_steps(period): - ''' Calculate a progress step ''' + """Calculate a progress step""" if int(period) == 0: # Avoid division by zero return 10.0 return (100.0 / int(period)) / 10 def jsonrpc(**kwargs): - ''' Perform JSONRPC calls ''' + """Perform JSONRPC calls""" if 'id' not in kwargs: kwargs.update(id=1) if 'jsonrpc' not in kwargs: @@ -137,13 +137,13 @@ def jsonrpc(**kwargs): def get_global_setting(setting): - ''' Get a Kodi setting ''' + """Get a Kodi setting""" result = jsonrpc(method='Settings.GetSettingValue', params=dict(setting=setting)) return result.get('result', {}).get('value') def localize(string_id): - ''' Return the translated string from the .po language files, optionally translating variables ''' + """Return the translated string from the .po language files, optionally translating variables""" return ADDON.getLocalizedString(string_id)