Esempio n. 1
0
 def _get_all_handler_names(self):
     """Return a list of `(library_name, handler_name)` tuples."""
     handlers = [('', printable_name(handler.name, True))
                 for handler in self.user_keywords.handlers]
     for library in chain(self.libraries.values(), self.resources.values()):
         if library.name != 'Reserved':
             handlers.extend(
                 ((library.name
                   or '', printable_name(handler.name, code_style=True))
                  for handler in library.handlers))
     return sorted(handlers)
Esempio n. 2
0
 def _get_all_handler_names(self):
     """Return a list of `(library_name, handler_name)` tuples."""
     handlers = [('', printable_name(handler.name, True))
                 for handler in self.user_keywords.handlers]
     for library in chain(self.libraries.values(), self.resources.values()):
         if library.name != 'Reserved':
             handlers.extend(
                 ((library.name or '',
                   printable_name(handler.name, code_style=True))
                  for handler in library.handlers))
     # sort handlers to ensure consistent ordering between Jython and Python
     return sorted(handlers)
Esempio n. 3
0
 def _get_all_handler_names(self):
     """Return a list of `(library_name, handler_name)` tuples."""
     handlers = [('', printable_name(handler.name, True))
                 for handler in self.user_keywords.handlers]
     for library in chain(self.libraries.values(), self.resources.values()):
         if library.name != 'Reserved':
             handlers.extend(
                 ((library.name
                   or '', printable_name(handler.name, code_style=True))
                  for handler in library.handlers))
     # TODO: is this still needed?
     # sort handlers to ensure consistent ordering between Jython and Python
     return sorted(handlers)
Esempio n. 4
0
 def _keyword_doc(self, elements, method):
     doc, tags = split_tags_from_doc(self._get_doc(elements, method))
     return KeywordDoc(name=printable_name(
         method.getSimpleName().toString(), code_style=True),
                       args=self._get_keyword_arguments(method),
                       doc=doc,
                       tags=tags)
 def _deprecate(cls, func, use_instead_library):
     def deprecated(self, *args):
         return func(*args)
     use_instead_keyword = printable_name(func.__name__, code_style=True)
     deprecated.__doc__ = ("*DEPRECATED!* Use '%s.%s' instead."
                           % (use_instead_library, use_instead_keyword))
     return deprecated
Esempio n. 6
0
 def _get_name(self, handler_name, handler_method):
     robot_name = getattr(handler_method, 'robot_name', None)
     name = robot_name or utils.printable_name(handler_name,
                                               code_style=True)
     if not name:
         raise DataError('Keyword name cannot be empty.')
     return name
Esempio n. 7
0
 def _keyword_doc(self, method):
     doc, tags = utils.split_tags_from_doc(self._get_doc(method))
     return KeywordDoc(name=utils.printable_name(method.name(),
                                                 code_style=True),
                       args=self._get_keyword_arguments(method),
                       doc=doc,
                       tags=tags)
Esempio n. 8
0
 def test_printable_name_with_code_style(self):
     for inp, exp in [('simple', 'Simple'),
                      ('ALLCAPS', 'ALLCAPS'),
                      ('name with spaces', 'Name With Spaces'),
                      ('    more   spaces    ', 'More Spaces'),
                      ('under_score_name', 'Under Score Name'),
                      ('under__score and spaces', 'Under Score And Spaces'),
                      ('__leading and trailing_ __', 'Leading And Trailing'),
                      ('__12number34__', '12 Number 34'),
                      ('miXed_CAPS_nAMe', 'MiXed CAPS NAMe'),
                      ('with 89_numbers', 'With 89 Numbers'),
                      ('camelCaseName', 'Camel Case Name'),
                      ('mixedCAPSCamelName', 'Mixed CAPS Camel Name'),
                      ('camelCaseWithDigit1', 'Camel Case With Digit 1'),
                      ('teamX', 'Team X'),
                      ('name42WithNumbers666', 'Name 42 With Numbers 666'),
                      ('name42WITHNumbers666', 'Name 42 WITH Numbers 666'),
                      ('12more34numbers', '12 More 34 Numbers'),
                      ('2KW', '2 KW'),
                      ('KW2', 'KW 2'),
                      ('xKW', 'X KW'),
                      ('KWx', 'K Wx'),
                      (':KW', ':KW'),
                      ('KW:', 'KW:'),
                      ('foo-bar', 'Foo-bar'),
                      ('Foo-b:a;r!', 'Foo-b:a;r!'),
                      ('Foo-B:A;R!', 'Foo-B:A;R!'),
                      ('', '')]:
         assert_equal(printable_name(inp, code_style=True), exp)
Esempio n. 9
0
 def _deprecate(cls, func, use_instead_library):
     def deprecated(self, *args):
         return func(*args)
     use_instead_keyword = printable_name(func.__name__, code_style=True)
     deprecated.__doc__ = ("*DEPRECATED!* Use '%s.%s' instead."
                           % (use_instead_library, use_instead_keyword))
     return deprecated
Esempio n. 10
0
 def test_printable_name_with_code_style(self):
     for inp, exp in [('simple', 'Simple'),
                      ('ALLCAPS', 'ALLCAPS'),
                      ('name with spaces', 'Name With Spaces'),
                      ('    more   spaces    ', 'More Spaces'),
                      ('under_score_name', 'Under Score Name'),
                      ('under__score and spaces', 'Under Score And Spaces'),
                      ('__leading and trailing_ __', 'Leading And Trailing'),
                      ('__12number34__', '12 Number 34'),
                      ('miXed_CAPS_nAMe', 'MiXed CAPS NAMe'),
                      ('with 89_numbers', 'With 89 Numbers'),
                      ('camelCaseName', 'Camel Case Name'),
                      ('mixedCAPSCamelName', 'Mixed CAPS Camel Name'),
                      ('camelCaseWithDigit1', 'Camel Case With Digit 1'),
                      ('teamX', 'Team X'),
                      ('name42WithNumbers666', 'Name 42 With Numbers 666'),
                      ('name42WITHNumbers666', 'Name 42 WITH Numbers 666'),
                      ('12more34numbers', '12 More 34 Numbers'),
                      ('2KW', '2 KW'),
                      ('KW2', 'KW 2'),
                      ('xKW', 'X KW'),
                      ('KWx', 'K Wx'),
                      (':KW', ':KW'),
                      ('KW:', 'KW:'),
                      ('foo-bar', 'Foo-bar'),
                      ('Foo-b:a;r!', 'Foo-b:a;r!'),
                      ('Foo-B:A;R!', 'Foo-B:A;R!'),
                      ('', '')]:
         assert_equal(printable_name(inp, code_style=True), exp)
Esempio n. 11
0
 def __init__(self, library, handler_name, handler_method):
     self.library = library
     self.name = utils.printable_name(handler_name, code_style=True)
     self.arguments = self._parse_arguments(handler_method)
     self.pre_run_messages = None
     self._handler_name = handler_name
     self._method = self._get_initial_handler(library, handler_name, handler_method)
     self._argument_resolver = self._get_argument_resolver(self.arguments)
 def __init__(self, library, handler_name, handler_method):
     self.library = library
     self.name = utils.printable_name(handler_name, code_style=True)
     self.arguments = self._parse_arguments(handler_method)
     self._handler_name = handler_name
     self._method = self._get_initial_handler(library, handler_name,
                                              handler_method)
     self._argument_resolver = self._get_argument_resolver(self.arguments)
Esempio n. 13
0
 def _keyword_doc(self, method):
     doc, tags = utils.split_tags_from_doc(self._get_doc(method))
     return KeywordDoc(
         name=utils.printable_name(method.name(), code_style=True),
         args=self._get_keyword_arguments(method),
         doc=doc,
         tags=tags
     )
 def _keyword_doc(self, elements, method):
     doc, tags = split_tags_from_doc(self._get_doc(elements, method))
     return KeywordDoc(
         name=printable_name(method.getSimpleName().toString(),
                             code_style=True),
         args=self._get_keyword_arguments(method),
         doc=doc,
         tags=tags
     )
Esempio n. 15
0
 def __init__(self, library, handler_name, handler_method):
     self.library = library
     name = getattr(handler_method, 'robot_name', None) or handler_name
     self.name = utils.printable_name(name, code_style=True)
     self.arguments = self._parse_arguments(handler_method)
     self.pre_run_messages = None
     self._handler_name = handler_name
     self._method = self._get_initial_handler(library, handler_name,
                                              handler_method)
     self._argument_resolver = self._get_argument_resolver(self.arguments)
Esempio n. 16
0
    def _get_all_handler_names(self):
        """Return a list of (library name, handler name) tuples.

        For user keywords, library name == None.

        Excludes DeprecatedBuiltIn, DeprecatedOperatingSystem,
        and Reserved libraries.
        """
        excluded = ['DeprecatedBuiltIn', 'DeprecatedOperatingSystem',
                    'Reserved']
        handlers = [(None, utils.printable_name(handler_name, True))
                    for handler_name in self.user_keywords.handlers.keys()]
        for library in (self.libraries.values() + self.resources.values()):
            if library.name not in excluded:
                handlers.extend(
                    ((library.name,
                      utils.printable_name(handler_name, code_style=True))
                     for handler_name in library.handlers))
        # sort handlers to ensure consistent ordering between Jython and Python
        return sorted(handlers)
Esempio n. 17
0
 def _get_names(self, paths):
     paths = [os.path.splitext(os.path.abspath(p))[0] for p in paths]
     path_tokens = [p.replace('\\', '/').split('/') for p in paths]
     min_tokens = min([len(t) for t in path_tokens])
     index = -1
     while self._tokens_are_same_at_index(path_tokens, index):
         index -= 1
         if abs(index) > min_tokens:
             index = -1
             break
     names = [tokens[index] for tokens in path_tokens]
     return [utils.printable_name(n, code_style=True) for n in names]
Esempio n. 18
0
 def _get_names(self, paths):
     paths = [os.path.splitext(os.path.abspath(p))[0] for p in paths]
     path_tokens = [p.replace('\\', '/').split('/') for p in paths]
     min_tokens = min(len(t) for t in path_tokens)
     index = -1
     while self._tokens_are_same_at_index(path_tokens, index):
         index -= 1
         if abs(index) > min_tokens:
             index = -1
             break
     names = [tokens[index] for tokens in path_tokens]
     return [utils.printable_name(n, code_style=True) for n in names]
Esempio n. 19
0
 def __init__(self, library, handler_name, handler_method, doc=''):
     self.library = library
     name = getattr(handler_method, 'robot_name', None) or handler_name
     self.name = utils.printable_name(name, code_style=True)
     self.arguments = self._parse_arguments(handler_method)
     self.pre_run_messages = None
     self._handler_name = handler_name
     self._method = self._get_initial_handler(library, handler_name,
                                              handler_method)
     self._argument_resolver = self._get_argument_resolver(self.arguments)
     doc, tags = utils.split_tags_from_doc(doc)
     self._doc = doc
     self.tags = self._get_tags_from_attribute(handler_method) + tags
Esempio n. 20
0
 def test_printable_name(self):
     for inp, exp in [('simple', 'Simple'), ('ALLCAPS', 'ALLCAPS'),
                      ('name with spaces', 'Name With Spaces'),
                      ('more   spaces', 'More Spaces'),
                      ('  leading and trailing  ', 'Leading And Trailing'),
                      ('  12number34  ', '12number34'),
                      ('Cases AND spaces', 'Cases AND Spaces'),
                      ('under_Score_name', 'Under_Score_name'),
                      ('camelCaseName', 'CamelCaseName'),
                      ('with89numbers', 'With89numbers'),
                      ('with 89 numbers', 'With 89 Numbers'),
                      ('with 89_numbers', 'With 89_numbers'), ('', '')]:
         assert_equal(printable_name(inp), exp)
Esempio n. 21
0
 def __init__(self, library, handler_name, handler_method, doc=''):
     self.library = library
     name = getattr(handler_method, 'robot_name', None) or handler_name
     self.name = utils.printable_name(name, code_style=True)
     self.arguments = self._parse_arguments(handler_method)
     self.pre_run_messages = None
     self._handler_name = handler_name
     self._method = self._get_initial_handler(library, handler_name,
                                              handler_method)
     self._argument_resolver = self._get_argument_resolver(self.arguments)
     doc, tags = utils.split_tags_from_doc(doc)
     self._doc = doc
     self.tags = self._get_tags_from_attribute(handler_method) + tags
Esempio n. 22
0
 def test_printable_name(self):
     for inp, exp in [('simple', 'Simple'),
                      ('ALLCAPS', 'ALLCAPS'),
                      ('name with spaces', 'Name With Spaces'),
                      ('more   spaces', 'More Spaces'),
                      ('  leading and trailing  ', 'Leading And Trailing'),
                      ('  12number34  ', '12number34'),
                      ('Cases AND spaces', 'Cases AND Spaces'),
                      ('under_Score_name', 'Under_Score_name'),
                      ('camelCaseName', 'CamelCaseName'),
                      ('with89numbers', 'With89numbers'),
                      ('with 89 numbers', 'With 89 Numbers'),
                      ('with 89_numbers', 'With 89_numbers'),
                      ('', '')]:
         assert_equal(printable_name(inp), exp)
Esempio n. 23
0
 def _get_name(self, handler_name, handler_method):
     robot_name = getattr(handler_method, 'robot_name', None)
     return robot_name or utils.printable_name(handler_name, code_style=True)
Esempio n. 24
0
def name_from_class(item, drop=None):
    cls = inspect.isclass(item) and item or item.__class__
    name = cls.__name__
    if drop and name.endswith(drop):
        name = name[:-len(drop)]
    return printable_name(name, code_style=True)
Esempio n. 25
0
 def _get_message(self):
     from robot.utils import printable_name
     return ("Invalid '%s' usage."
             % printable_name(type(self).__name__, code_style=True))
Esempio n. 26
0
 def __init__(self, method, library):
     _BaseKeywordDoc.__init__(self, library)
     self.name = utils.printable_name(method.name(), True)
     self.args = [param.name() for param in method.parameters()]
     self.doc = self._process_doc(method.getRawCommentText())
     self.shortdoc = self.doc and self.doc.splitlines()[0] or ''
Esempio n. 27
0
 def __init__(self, library, handler_name, handler_method):
     self.library = library
     self.name = utils.printable_name(handler_name, code_style=True)
     self.arguments = self._parse_arguments(handler_method)
Esempio n. 28
0
 def _keyword_doc(self, method):
     return KeywordDoc(name=utils.printable_name(method.name(),
                                                 code_style=True),
                       args=[param.name() for param in method.parameters()],
                       doc=self._get_doc(method))
Esempio n. 29
0
 def _get_name(self, handler_name, handler_method):
     robot_name = getattr(handler_method, 'robot_name', None)
     name = robot_name or printable_name(handler_name, code_style=True)
     if not name:
         raise DataError('Keyword name cannot be empty.')
     return name
Esempio n. 30
0
 def _get_message(self):
     from robot.utils import printable_name
     return ("Invalid '%s' usage."
             % printable_name(type(self).__name__, code_style=True))
Esempio n. 31
0
 def _keyword_doc(self, method):
     return KeywordDoc(
         name=utils.printable_name(method.name(), code_style=True),
         args=list(self._yield_keyword_arguments(method)),
         doc=self._get_doc(method)
     )
Esempio n. 32
0
 def _get_message(self):
     from robot.utils import printable_name
     return "Invalid '%s' usage." \
            % printable_name(self.__class__.__name__, code_style=True)
 def __init__(self, method, library):
     _BaseKeywordDoc.__init__(self, library)
     self.name = utils.printable_name(method.name(), True)
     self.args = [ param.name() for param in method.parameters() ]
     self.doc = self._process_doc(method.getRawCommentText())
     self.shortdoc = self.doc and self.doc.splitlines()[0] or ''
Esempio n. 34
0
 def _get_message(self):
     from robot.utils import printable_name
     return "Invalid '%s' usage." \
            % printable_name(self.__class__.__name__, code_style=True)
Esempio n. 35
0
def name_from_class(item, drop=None):
    cls = inspect.isclass(item) and item or item.__class__
    name = cls.__name__
    if drop and name.endswith(drop):
        name = name[:-len(drop)]
    return printable_name(name, code_style=True)
Esempio n. 36
0
 def __init__(self, library, handler_name, handler_method):
     self.library = library
     self.name = utils.printable_name(handler_name, code_style=True)
     self.arguments = self._parse_arguments(handler_method)
Esempio n. 37
0
 def _get_name(self, handler_name, handler_method):
     robot_name = getattr(handler_method, 'robot_name', None)
     return robot_name or utils.printable_name(handler_name, code_style=True)
 def _keyword_doc(self, method):
     return KeywordDoc(
         name=utils.printable_name(method.name(), code_style=True),
         args=list(self._yield_keyword_arguments(method)),
         doc=self._get_doc(method)
     )
Esempio n. 39
0
 def _keyword_doc(self, method):
     return KeywordDoc(
         name=utils.printable_name(method.name(), code_style=True),
         args=[param.name() for param in method.parameters()],
         doc=self._get_doc(method)
     )