19 from robot.utils import MultiMatcher, console_encode
30 return command.lower()
in [
'list',
'show',
'version']
34 if not cls.
handleshandles(command):
35 raise DataError(
"Unknown command '%s'." % command)
36 if command.lower() ==
'version' and args:
37 raise DataError(
"Command 'version' does not take arguments.")
39 def view(self, command, *args):
41 getattr(self, command.lower())(*args)
44 for kw
in self.
_keywords_keywords.search(
'*%s*' % p
for p
in patterns):
48 if MultiMatcher(names, match_if_no_patterns=
True).match(
'intro'):
52 for kw
in self.
_keywords_keywords.search(names):
62 self.
_header_header(lib.name, underline=
'=')
63 self.
_data_data([(
'Version', lib.version),
64 (
'Scope', lib.scope
if lib.type ==
'LIBRARY' else None)])
65 self.
_doc_doc(lib.doc)
68 self.
_header_header(
'Importing', underline=
'-')
69 for init
in lib.inits:
74 self.
_header_header(kw.name, underline=
'-')
75 self.
_data_data([(
'Arguments',
'[%s]' % str(kw.args))])
79 self.
_console_console(
'%s\n%s' % (name, underline * len(name)))
82 ljust = max(len(name)
for name, _
in items) + 3
83 for name, value
in items:
85 text =
'%s%s' % ((name+
':').ljust(ljust), value)
86 self.
_console_console(self.
_wrap_wrap(text, subsequent_indent=
' '*ljust))
90 for line
in doc.splitlines():
95 def _wrap(self, text, width=78, **config):
96 return '\n'.join(textwrap.wrap(text, width=width, **config))
105 matcher = MultiMatcher(patterns, match_if_no_patterns=
True)
107 if matcher.match(kw.name):
def __init__(self, libdoc)
def list(self, *patterns)
def _show_inits(self, lib)
def _show_keyword(self, kw, show_name=True)
def view(self, command, *args)
def validate_command(cls, command, args)
def _wrap(self, text, width=78, **config)
def handles(cls, command)
def _show_intro(self, lib)
def _header(self, name, underline)
def __init__(self, libdoc)
def search(self, patterns)
def console_encode(string, encoding=None, errors='replace', stream=sys.__stdout__, force=False)
Encodes the given string so that it can be used in the console.