Skip to content

Commit

Permalink
Misc tidy ups
Browse files Browse the repository at this point in the history
- use str.join instead of str.format
  • Loading branch information
MoojMidge committed Aug 3, 2024
1 parent 2b3db17 commit 6785212
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 161 deletions.
9 changes: 5 additions & 4 deletions resources/lib/youtube_plugin/kodion/abstract_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,11 @@ def reroute(self, context, path=None, params=None, uri=None):
if not result:
return False
context.get_ui().set_property(REROUTE_PATH, path)
context.execute('ActivateWindow(Videos, {0}{1})'.format(
context.execute(''.join((
'ActivateWindow(Videos, ',
context.create_uri(path, params),
', return' if window_return else '',
))
', return)' if window_return else ')',
)))
return True

@staticmethod
Expand Down Expand Up @@ -364,7 +365,7 @@ def on_search(provider, context, re_match):
@staticmethod
def on_command(re_match, **_kwargs):
command = re_match.group('command')
return UriItem('command://{0}'.format(command))
return UriItem(''.join(('command://', command)))

def handle_exception(self, context, exception_to_handle):
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def get_ui(self):
def get_system_version():
return current_system_version

def create_uri(self, path=None, params=None):
def create_uri(self, path=None, params=None, run=False):
if isinstance(path, (list, tuple)):
uri = self.create_path(*path, is_uri=True)
elif path:
Expand All @@ -270,7 +270,11 @@ def create_uri(self, path=None, params=None):
if params:
uri = '?'.join((uri, urlencode(params)))

return uri
return ''.join((
'RunPlugin(',
uri,
')'
)) if run else uri

@staticmethod
def create_path(*args, **kwargs):
Expand Down
15 changes: 12 additions & 3 deletions resources/lib/youtube_plugin/kodion/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,24 @@ def wrapper(*args, **kwargs):
class_name = args[0].__name__
else:
class_name = args[0].__class__.__name__
name = '{0}.{1}'.format(class_name, func.__name__)
name = '.'.join((
class_name,
func.__name__,
))

elif (func.__class__
and not isinstance(func.__class__, type)
and func.__class__.__name__ != 'function'):
name = '{0}.{1}'.format(func.__class__.__name__, func.__name__)
name = '.'.join((
func.__class__.__name__,
func.__name__,
))

elif func.__module__:
name = '{0}.{1}'.format(func.__module__, func.__name__)
name = '.'.join((
func.__module__,
func.__name__,
))

else:
name = func.__name__
Expand Down
5 changes: 4 additions & 1 deletion resources/lib/youtube_plugin/kodion/items/base_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ def set_fanart(self, fanart):
def get_fanart(self, default=True):
if self._fanart or not default:
return self._fanart
return '{0}/fanart.jpg'.format(MEDIA_PATH)
return '/'.join((
MEDIA_PATH,
'fanart.jpg',
))

def add_context_menu(self, context_menu, position='end', replace=False):
context_menu = (item for item in context_menu if item)
Expand Down
Loading

0 comments on commit 6785212

Please sign in to comment.