Exemplo n.º 1
0
 def get_excep(key, val, classinfo, cls, msg):
     classinfo = ' or '.join(get_cls_name(cls) for cls in classinfo)
     msg = ': ' + msg if msg else ''
     return TypeError('Key "{key}" is an instance of {actual_cls}, but should be instance of {classinfo}{msg}. Help: {help}'.format(
                 key=key,
                 actual_cls=get_cls_name(type(val)),
                 classinfo=classinfo,
                 msg=msg,
                 help=self.help,
             ), key)
Exemplo n.º 2
0
Arquivo: conf.py Projeto: wisen/lisa
 def _get_rst_param_doc(cls):
     return '\n'.join(
         ':param {param}: {help}\n:type {param}: {type}\n'.format(
             param=param,
             help=key_desc.help,
             type=' or '.join(get_cls_name(t) for t in key_desc.classinfo),
         ) for param, key_desc in cls._get_param_key_desc_map().items())
Exemplo n.º 3
0
 def get_help(self, style=None):
     prefix = '*' if style == 'rst' else '|-'
     if self.help:
         joiner = '\n{} '.format(' ' * len(prefix))
         wrapped_lines = textwrap.wrap(self.help, width=60)
         # If more than one line, output a paragraph on its own starting on
         # a new line
         if len(wrapped_lines) > 1:
             wrapped_lines.insert(0, '')
         help_ = ': ' + joiner.join(wrapped_lines)
     else:
         help_ = ''
     return '{prefix} {key} ({classinfo}){help}.'.format(
         prefix=prefix,
         key=self.name,
         classinfo=' or '.join(
             get_cls_name(key_cls, style=style)
             for key_cls in self.classinfo),
         help=help_,
     )