Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 1ae6a0a

Browse files
committed
improve documentation
1 parent 4095eab commit 1ae6a0a

File tree

11 files changed

+24
-108
lines changed

11 files changed

+24
-108
lines changed

docs/api/script.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ Script
44
.. autoclass:: codequick.script.Script
55
:members:
66

7-
.. autoattribute:: codequick.script.Script.DEBUG
8-
.. autoattribute:: codequick.script.Script.INFO
9-
.. autoattribute:: codequick.script.Script.WARNING
10-
.. autoattribute:: codequick.script.Script.ERROR
11-
.. autoattribute:: codequick.script.Script.CRITICAL
12-
.. autoattribute:: codequick.script.Script.NOTIFY_INFO
13-
.. autoattribute:: codequick.script.Script.NOTIFY_ERROR
14-
.. autoattribute:: codequick.script.Script.NOTIFY_WARNING
15-
167
.. autoclass:: codequick.script.Settings
178
:members:
189
:special-members: __getitem__, __setitem__

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
# Latex figure (float) alignment
138138
#
139139
# 'figure_align': 'htbp',
140+
'classoptions': ',openany,oneside',
141+
'babel' : '\\usepackage[polish]{babel}'
140142
}
141143

142144
# Grouping the document tree into LaTeX files. List of tuples

script.module.codequick/lib/codequick/resolver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def _send_to_kodi(self, resolved):
342342
# Fetch the first element of the generator and process the rest in the background
343343
elif inspect.isgenerator(resolved):
344344
listitem = self._create_playlist([next(resolved)])
345-
self.register_metacall(self._process_generator, resolved)
345+
self.register_delayed_callback(self._process_generator, resolved)
346346

347347
# Create playlist if resolved is a dict of {title: url}
348348
elif hasattr(resolved, "items"):

script.module.codequick/lib/codequick/script.py

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
import xbmc
1212

1313
# Package imports
14-
from codequick.utils import CacheProperty, ensure_unicode, ensure_native_str, safe_path
14+
from codequick.utils import ensure_unicode, ensure_native_str, safe_path
1515
from codequick.support import dispatcher, script_data, addon_data, logger_id
16-
import urlquick
1716

1817
__all__ = ["Script", "Settings"]
1918

@@ -37,7 +36,7 @@ def __getitem__(self, key):
3736

3837
def __setitem__(self, key, value):
3938
"""
40-
Set an add-on setting.
39+
Set add-on setting.
4140
4241
:param str key: Id of the setting.
4342
:param value: Value of the setting.
@@ -127,16 +126,22 @@ class Script(object):
127126
is_playable = False
128127
is_folder = False
129128

130-
# Logging Levels
129+
#: Critical logging level, maps to 'xbmc.LOGFATAL'
131130
CRITICAL = 50
131+
#: Critical logging level, maps to 'xbmc.LOGWARNING'
132132
WARNING = 30
133+
#: Critical logging level, maps to 'xbmc.LOGERROR'
133134
ERROR = 40
135+
#: Critical logging level, maps to 'xbmc.LOGDEBUG'
134136
DEBUG = 10
137+
#: Critical logging level, maps to 'xbmc.LOGNOTICE'
135138
INFO = 20
136139

137-
# Notification icon options
140+
#: Kodi notification warning image
138141
NOTIFY_WARNING = 'warning'
142+
#: Kodi notification error image
139143
NOTIFY_ERROR = 'error'
144+
#: Kodi notification info image
140145
NOTIFY_INFO = 'info'
141146

142147
#: Underlining logger object, for advanced use.
@@ -173,17 +178,17 @@ def register(cls, callback):
173178
return dispatcher.register(callback, cls=cls)
174179

175180
@staticmethod
176-
def register_metacall(func, *args, **kwargs):
181+
def register_delayed_callback(func, *args, **kwargs):
177182
"""
178183
Register a function that will be executed after kodi has finished listing all listitems.
179184
Sence the function is called after the listitems have been shown, it will not slow anything down.
180-
Very useful for fetching extra metadata without slowing down the listing of content.
185+
Very useful for fetching extra metadata for later use without slowing down the listing of content.
181186
182187
:param func: Function that will be called after endOfDirectory is called.
183188
:param args: Positional arguments that will be passed to function.
184189
:param kwargs: Keyword arguments that will be passed to function.
185190
"""
186-
dispatcher.register_metacall(func, args, kwargs)
191+
dispatcher.register_delayed(func, args, kwargs)
187192

188193
@staticmethod
189194
def log(msg, args=None, lvl=10):
@@ -200,7 +205,7 @@ def log(msg, args=None, lvl=10):
200205
:param msg: The message format string.
201206
:type args: list or tuple
202207
:param args: List of arguments which are merged into msg using the string formatting operator.
203-
:param lvl: The logging level to use. default => 10(Debug).
208+
:param lvl: The logging level to use. default => 10 (Debug).
204209
205210
.. Note::
206211
When a log level of 50(CRITICAL) is given, then all debug messages that were previously logged
@@ -313,23 +318,3 @@ def get_info(key, addon_id=None):
313318
os.mkdir(path)
314319

315320
return resp
316-
317-
@CacheProperty
318-
def icon(self):
319-
"""The add-on's icon image path."""
320-
return self.get_info("icon")
321-
322-
@CacheProperty
323-
def fanart(self):
324-
"""The add-on's fanart image path."""
325-
return self.get_info("fanart")
326-
327-
@CacheProperty
328-
def profile(self):
329-
"""The add-on's profile data directory path."""
330-
return self.get_info("profile")
331-
332-
@CacheProperty
333-
def path(self):
334-
"""The add-on's directory path."""
335-
return self.get_info("path")

script.module.codequick/lib/codequick/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self):
3131

3232
# Persistent list of currently saved searches
3333
self.search_db = PersistentList(SEARCH_DB)
34-
self.register_metacall(self.close)
34+
self.register_delayed_callback(self.close)
3535

3636
def run(self, remove_entry=None, search=False, first_load=False, **extras):
3737
"""List all saved searches."""

script.module.codequick/lib/codequick/support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def register(self, callback, cls):
291291
callback.test = tester
292292
return callback
293293

294-
def register_metacall(self, func, args, kwargs):
294+
def register_delayed(self, func, args, kwargs):
295295
callback = (func, args, kwargs)
296296
self.metacalls.append(callback)
297297

script.module.codequick/lib/codequick/utils.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,45 +25,10 @@
2525
# Unicode Type object, unicode on python2 or str on python3
2626
unicode_type = type(u"")
2727

28-
__all__ = ["CacheProperty", "keyboard", "parse_qs", "urljoin_partial", "strip_tags",
28+
__all__ = ["keyboard", "parse_qs", "urljoin_partial", "strip_tags",
2929
"safe_path", "ensure_bytes", "ensure_native_str", "ensure_unicode"]
3030

3131

32-
class CacheProperty(object):
33-
"""
34-
Decorator that converts a class method into a class property and caches the response on first access.
35-
36-
When the class property is accessed for the first time, the result is computed and returned.
37-
The property is then replaced with an instance attribute with the computed result.
38-
39-
:example:
40-
>>> import random
41-
>>> class Test(object):
42-
>>> @CacheProperty
43-
>>> def data_id(self):
44-
>>> return random.random()
45-
>>>
46-
>>> obj = Test()
47-
>>> print(obj.data_id)
48-
0.39391705700202373
49-
>>> print(obj.data_id)
50-
0.39391705700202373
51-
"""
52-
53-
def __init__(self, func):
54-
self.__name__ = func.__name__
55-
self.__doc__ = func.__doc__
56-
self._func = func
57-
58-
def __get__(self, instance, owner):
59-
if instance:
60-
attr = self._func(instance)
61-
setattr(instance, self.__name__, attr)
62-
return attr
63-
else:
64-
return self
65-
66-
6732
def keyboard(heading, default="", hidden=False):
6833
"""
6934
Show a keyboard dialog with default text heading and hidden input flag if supplied.

script.module.codequick/lib/codequick/youtube.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class APIControl(Route):
372372
def __init__(self):
373373
super(APIControl, self).__init__()
374374
self.db = Database()
375-
self.register_metacall(self.db.cleanup)
375+
self.register_delayed_callback(self.db.cleanup)
376376
self.api = API()
377377

378378
def valid_playlistid(self, contentid):

tests/test_script.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_register_metacall(self):
120120
def tester():
121121
pass
122122

123-
self.script.register_metacall(tester)
123+
self.script.register_delayed_callback(tester)
124124
for callback, _, _ in script.dispatcher.metacalls:
125125
if callback is tester:
126126
self.assertTrue(True, "")
@@ -205,15 +205,3 @@ def test_get_version(self):
205205

206206
def test_get_name_addon(self):
207207
self.assertEqual(self.script.get_info("name", addon_id="script.module.codequick"), "CodeQuick")
208-
209-
def test_icon(self):
210-
self.assertTrue(self.script.icon.endswith("script.module.codequick/resources/icon.png"))
211-
212-
def test_fanart(self):
213-
self.assertTrue(self.script.fanart.endswith("script.module.codequick/fanart.jpg"))
214-
215-
def test_profile(self):
216-
self.assertTrue(self.script.profile.endswith("userdata/addon_data/script.module.codequick"))
217-
218-
def test_path(self):
219-
self.assertTrue(self.script.path.endswith("script.module.codequick"))

tests/test_support.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def test_register_metacall(self):
138138
def root():
139139
pass
140140

141-
self.dispatcher.register_metacall(root, [], {})
141+
self.dispatcher.register_delayed(root, [], {})
142142
self.assertListEqual(self.dispatcher.metacalls, [(root, [], {})])
143143

144144
def test_metacalls(self):
@@ -149,7 +149,7 @@ def root():
149149
Executed.yes = True
150150
raise RuntimeError("should not be raised")
151151

152-
self.dispatcher.register_metacall(root, [], {})
152+
self.dispatcher.register_delayed(root, [], {})
153153
self.dispatcher.run_metacalls()
154154
self.assertTrue(Executed.yes)
155155

0 commit comments

Comments
 (0)