add missing docstrings to commands
This commit is contained in:
parent
8d29aa8a6d
commit
9fe4faa6bb
3 changed files with 22 additions and 7 deletions
|
|
@ -91,6 +91,12 @@ class Comparoob(ReplApplication):
|
|||
CAPS = ICapPriceComparison
|
||||
|
||||
def do_prices(self, pattern):
|
||||
"""
|
||||
prices [PATTERN]
|
||||
|
||||
Display prices for a product. If a pattern is supplied, do not prompt
|
||||
what product to compare.
|
||||
"""
|
||||
products = []
|
||||
for backend, product in self.do('search_products', pattern):
|
||||
double = False
|
||||
|
|
@ -135,6 +141,11 @@ class Comparoob(ReplApplication):
|
|||
return self._complete_object()
|
||||
|
||||
def do_info(self, _id):
|
||||
"""
|
||||
info ID
|
||||
|
||||
Get information about a product.
|
||||
"""
|
||||
if not _id:
|
||||
print >>sys.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
|
||||
return 2
|
||||
|
|
|
|||
|
|
@ -148,6 +148,11 @@ class Parceloob(ReplApplication):
|
|||
self.cached_format(p)
|
||||
|
||||
def do_info(self, id):
|
||||
"""
|
||||
info ID
|
||||
|
||||
Get information about a parcel.
|
||||
"""
|
||||
parcel = self.get_object(id, 'get_parcel_tracking', [])
|
||||
if not parcel:
|
||||
print >>sys.stderr, 'Error: parcel not found'
|
||||
|
|
|
|||
|
|
@ -486,11 +486,12 @@ class ReplApplication(Cmd, ConsoleApplication):
|
|||
|
||||
def get_command_help(self, command, short=False):
|
||||
try:
|
||||
doc = getattr(self, 'do_' + command).__doc__
|
||||
func = getattr(self, 'do_' + command)
|
||||
except AttributeError:
|
||||
return None
|
||||
if not doc:
|
||||
return '%s' % command
|
||||
|
||||
doc = func.__doc__
|
||||
assert doc is not None, "A command must have a docstring"
|
||||
|
||||
lines = [line.strip() for line in doc.strip().split('\n')]
|
||||
if not lines[0].startswith(command):
|
||||
|
|
@ -511,10 +512,8 @@ class ReplApplication(Cmd, ConsoleApplication):
|
|||
cmd = name[3:]
|
||||
if cmd in self.hidden_commands.union(self.weboob_commands).union(['help']):
|
||||
continue
|
||||
elif getattr(self, name).__doc__:
|
||||
d[appname].append(self.get_command_help(cmd, short=True))
|
||||
else:
|
||||
d[appname].append(cmd)
|
||||
|
||||
d[appname].append(self.get_command_help(cmd, short=True))
|
||||
if not self.DISABLE_REPL:
|
||||
for cmd in self.weboob_commands:
|
||||
d['Weboob'].append(self.get_command_help(cmd, short=True))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue