Skip to content

Commit c92860b

Browse files
authored
Fix docstrings (#239)
1 parent 0a712f8 commit c92860b

File tree

5 files changed

+59
-58
lines changed

5 files changed

+59
-58
lines changed

lib/inputstreamhelper/__init__.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
''' Implements the main InputStream Helper class '''
2+
"""Implements the main InputStream Helper class"""
33
from __future__ import absolute_import, division, unicode_literals
44
import os
55
from inputstreamhelper import config
@@ -13,11 +13,11 @@
1313

1414

1515
class InputStreamException(Exception):
16-
''' Stub Exception '''
16+
"""Stub Exception"""
1717

1818

1919
def system_os():
20-
''' Get system platform, and remember this information '''
20+
"""Get system platform, and remember this information"""
2121

2222
# If it wasn't stored before, get the correct value
2323
if not hasattr(system_os, 'name'):
@@ -33,10 +33,10 @@ def system_os():
3333

3434

3535
class Helper:
36-
''' The main InputStream Helper class '''
36+
"""The main InputStream Helper class"""
3737

3838
def __init__(self, protocol, drm=None):
39-
''' Initialize InputStream Helper class '''
39+
"""Initialize InputStream Helper class"""
4040
self._download_path = None
4141
self._loop_dev = None
4242
self._modprobe_loop = False
@@ -69,7 +69,7 @@ def __init__(self, protocol, drm=None):
6969
install_opener(build_opener(ProxyHandler(proxies)))
7070

7171
def __repr__(self):
72-
''' String representation of Helper class '''
72+
"""String representation of Helper class"""
7373
return 'Helper({protocol}, drm={drm})'.format(protocol=self.protocol, drm=self.drm)
7474

7575
@classmethod
@@ -80,7 +80,7 @@ def _diskspace(cls):
8080

8181
@classmethod
8282
def _temp_path(cls):
83-
''' Return temporary path, usually ~/.kodi/userdata/addon_data/script.module.inputstreamhelper/temp '''
83+
"""Return temporary path, usually ~/.kodi/userdata/addon_data/script.module.inputstreamhelper/temp"""
8484
from xbmcvfs import exists, mkdirs
8585
temp_path = translate_path(os.path.join(get_setting('temp_path', 'special://masterprofile/addon_data/script.module.inputstreamhelper'), 'temp'))
8686
if not exists(temp_path):
@@ -90,7 +90,7 @@ def _temp_path(cls):
9090

9191
@classmethod
9292
def _mnt_path(cls):
93-
''' Return mount path, usually ~/.kodi/userdata/addon_data/script.module.inputstreamhelper/temp/mnt '''
93+
"""Return mount path, usually ~/.kodi/userdata/addon_data/script.module.inputstreamhelper/temp/mnt"""
9494
from xbmcvfs import exists, mkdir
9595
mnt_path = os.path.join(cls._temp_path(), 'mnt')
9696
if not exists(mnt_path):
@@ -100,7 +100,7 @@ def _mnt_path(cls):
100100

101101
@classmethod
102102
def _ia_cdm_path(cls):
103-
''' Return the specified CDM path for inputstream.adaptive, usually ~/.kodi/cdm '''
103+
"""Return the specified CDM path for inputstream.adaptive, usually ~/.kodi/cdm"""
104104
from xbmcaddon import Addon
105105
try:
106106
addon = Addon('inputstream.adaptive')
@@ -116,7 +116,7 @@ def _ia_cdm_path(cls):
116116

117117
@classmethod
118118
def _backup_path(cls):
119-
''' Return the path to the cdm backups '''
119+
"""Return the path to the cdm backups"""
120120
from xbmcvfs import exists, mkdir
121121
path = os.path.join(addon_profile(), 'backup')
122122
if not exists(path):
@@ -125,36 +125,37 @@ def _backup_path(cls):
125125

126126
@classmethod
127127
def _widevine_config_path(cls):
128-
''' Return the full path to the widevine or recovery config file '''
128+
"""Return the full path to the widevine or recovery config file"""
129129
if 'x86' in cls._arch():
130130
return os.path.join(cls._ia_cdm_path(), config.WIDEVINE_CONFIG_NAME)
131131
return os.path.join(cls._ia_cdm_path(), os.path.basename(config.CHROMEOS_RECOVERY_URL) + '.json')
132132

133133
@classmethod
134134
def _load_widevine_config(cls):
135-
''' Load the widevine or recovery config in JSON format '''
135+
"""Load the widevine or recovery config in JSON format"""
136136
from json import loads
137137
with open(cls._widevine_config_path(), 'r') as config_file:
138138
return loads(config_file.read())
139139

140140
@classmethod
141141
def _widevine_path(cls):
142-
''' Get full widevine path '''
142+
"""Get full widevine path"""
143143
widevine_cdm_filename = config.WIDEVINE_CDM_FILENAME[system_os()]
144144
if widevine_cdm_filename is None:
145145
return False
146146

147147
if cls._ia_cdm_path():
148148
widevine_path = os.path.join(cls._ia_cdm_path(), widevine_cdm_filename)
149149
from xbmcvfs import exists
150+
150151
if exists(widevine_path):
151152
return widevine_path
152153

153154
return False
154155

155156
@classmethod
156157
def _kodi_version(cls):
157-
''' Return the current Kodi version '''
158+
"""Return the current Kodi version"""
158159
from xbmc import getInfoLabel
159160
version = getInfoLabel('System.BuildVersion')
160161
return version.split(' ')[0]
@@ -224,18 +225,18 @@ def _helper_disabled(self):
224225

225226
@staticmethod
226227
def disable():
227-
''' Disable plugin '''
228+
"""Disable plugin"""
228229
if get_setting('disabled', 'false') == 'false':
229230
set_setting('disabled', 'true')
230231

231232
@staticmethod
232233
def enable():
233-
''' Enable plugin '''
234+
"""Enable plugin"""
234235
if get_setting('disabled', 'false') == 'true':
235236
set_setting('disabled', 'false')
236237

237238
def _inputstream_version(self):
238-
''' Return the requested inputstream version '''
239+
"""Return the requested inputstream version"""
239240
from xbmcaddon import Addon
240241
try:
241242
addon = Addon(self.inputstream_addon)
@@ -277,7 +278,7 @@ def _chromeos_offset(self, bin_path):
277278
return '0'
278279

279280
def _run_cmd(self, cmd, sudo=False, shell=False):
280-
''' Run subprocess command and return if it succeeds as a bool '''
281+
"""Run subprocess command and return if it succeeds as a bool"""
281282
from .unicodehelper import to_unicode
282283
import subprocess
283284
env = os.environ.copy()
@@ -364,7 +365,7 @@ def _has_widevine(self):
364365

365366
@staticmethod
366367
def _http_request(url):
367-
''' Perform an HTTP request and return request '''
368+
"""Perform an HTTP request and return request"""
368369

369370
try: # Python 3
370371
from urllib.error import HTTPError
@@ -386,7 +387,7 @@ def _http_request(url):
386387
return req
387388

388389
def _http_get(self, url):
389-
''' Perform an HTTP GET request and return content '''
390+
"""Perform an HTTP GET request and return content"""
390391
req = self._http_request(url)
391392
if req is None:
392393
return None
@@ -552,7 +553,7 @@ def _latest_widevine_version(self, eula=False):
552553
return arm_device['version']
553554

554555
def _chromeos_config(self):
555-
''' Parse the Chrome OS recovery configuration and put it in a dictionary '''
556+
"""Parse the Chrome OS recovery configuration and put it in a dictionary"""
556557
url = config.CHROMEOS_RECOVERY_URL
557558
conf = [line for line in self._http_get(url).split('\n\n') if 'hwidmatch=' in line]
558559

@@ -759,7 +760,7 @@ def _install_widevine_arm(self): # pylint: disable=too-many-statements
759760
return False
760761

761762
def install_widevine(self):
762-
''' Wrapper function that calls Widevine installer method depending on architecture '''
763+
"""Wrapper function that calls Widevine installer method depending on architecture"""
763764
if not self._supports_widevine():
764765
return False
765766

@@ -849,7 +850,7 @@ def _widevine_eula(self):
849850
return yesno_dialog(localize(30026), eula, nolabel=localize(30028), yeslabel=localize(30027)) # Widevine CDM EULA
850851

851852
def _extract_widevine_from_img(self, backup_path):
852-
''' Extract the Widevine CDM binary from the mounted Chrome OS image '''
853+
"""Extract the Widevine CDM binary from the mounted Chrome OS image"""
853854
from shutil import copyfile
854855
from xbmcvfs import exists, mkdir
855856

@@ -930,7 +931,7 @@ def _check_widevine(self):
930931
return True
931932

932933
def _unzip(self, unzip_dir, file_to_unzip=None, result=[]): # pylint: disable=dangerous-default-value
933-
''' Unzip files to specified path '''
934+
"""Unzip files to specified path"""
934935
from xbmcvfs import exists, mkdirs
935936

936937
if not exists(unzip_dir):
@@ -954,15 +955,15 @@ def _unzip(self, unzip_dir, file_to_unzip=None, result=[]): # pylint: disable=d
954955
return bool(result)
955956

956957
def _unmount(self):
957-
''' Unmount mountpoint if mounted '''
958+
"""Unmount mountpoint if mounted"""
958959
while os.path.ismount(self._mnt_path()):
959960
log('Unmount {mountpoint}', mountpoint=self._mnt_path())
960961
umount_output = self._run_cmd(['umount', self._mnt_path()], sudo=True)
961962
if not umount_output['success']:
962963
break
963964

964965
def _cleanup(self):
965-
''' Clean up function after Widevine CDM installation '''
966+
"""Clean up function after Widevine CDM installation"""
966967
from shutil import rmtree
967968
self._unmount()
968969
if self._attached_loop_dev:

lib/inputstreamhelper/api.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# -*- coding: utf-8 -*-
2-
''' This is the actual InputStream Helper API script '''
2+
"""This is the actual InputStream Helper API script"""
33

44
from __future__ import absolute_import, division, unicode_literals
55
from inputstreamhelper import Helper
66
from .kodiutils import ADDON, log
77

88

99
def run(params):
10-
''' Route to API method '''
10+
"""Route to API method"""
1111
if 2 <= len(params) <= 4:
1212
if params[1] == 'widevine_install':
1313
widevine_install()
@@ -30,25 +30,25 @@ def run(params):
3030

3131

3232
def check_inputstream(protocol, drm=None):
33-
''' The API interface to check inputstream '''
33+
"""The API interface to check inputstream"""
3434
Helper(protocol, drm=drm).check_inputstream()
3535

3636

3737
def widevine_install():
38-
''' The API interface to install Widevine CDM '''
38+
"""The API interface to install Widevine CDM"""
3939
Helper('mpd', drm='widevine').install_widevine()
4040

4141

4242
def widevine_remove():
43-
''' The API interface to remove Widevine CDMs '''
43+
"""The API interface to remove Widevine CDMs"""
4444
Helper('mpd', drm='widevine').remove_widevine()
4545

4646

4747
def info_dialog():
48-
''' The API interface to show an info Dialog '''
48+
"""The API interface to show an info Dialog"""
4949
Helper('mpd', drm='widevine').info_dialog()
5050

5151

5252
def rollback():
53-
''' The API interface to rollback Widevine CDM '''
53+
"""The API interface to rollback Widevine CDM"""
5454
Helper('mpd', drm='widevine').rollback_libwv()

lib/inputstreamhelper/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
''' Configuration variables for inpustreamhelper '''
2+
"""Configuration variables for inpustreamhelper"""
33
from __future__ import absolute_import, division, unicode_literals
44

55

0 commit comments

Comments
 (0)