Allow checking NowPlayingSegment

This commit is contained in:
ZyX 2014-08-06 00:01:35 +04:00
parent 416a0efd84
commit 0255df2f7b
1 changed files with 13 additions and 3 deletions

View File

@ -44,12 +44,22 @@ def getconfigargspec(obj):
else:
obj = obj
argspec = getargspec(obj)
remove_self = False
try:
argspec = getargspec(obj)
except TypeError: # Workaround for now_playing segment
# TODO For NowPlayingSegment for linter: merge in information about
# player-specific arguments
argspec = getargspec(obj.__call__)
remove_self = True
args = []
defaults = []
for i, arg in zip(count(1), reversed(argspec.args)):
if ((arg == 'segment_info' and getattr(obj, 'powerline_requires_segment_info', None)) or
arg == 'pl'):
if (
(arg == 'segment_info' and getattr(obj, 'powerline_requires_segment_info', None))
or arg == 'pl'
or (arg == 'self' and remove_self)
):
continue
if argspec.defaults and len(argspec.defaults) >= i:
default = argspec.defaults[-i]