예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #5
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
예제 #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
예제 #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)
예제 #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)
예제 #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
예제 #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)
예제 #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)
예제 #12
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._handler_name = handler_name
     self._method = self._get_initial_handler(library, handler_name,
                                              handler_method)
     self._argument_resolver = self._get_argument_resolver(self.arguments)
예제 #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
     )
예제 #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)
예제 #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)
예제 #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]
예제 #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]
예제 #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
예제 #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)
예제 #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
예제 #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)
예제 #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)
예제 #24
0
파일: __init__.py 프로젝트: IlfirinPL/RIDE
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)
예제 #25
0
 def _get_message(self):
     from robot.utils import printable_name
     return ("Invalid '%s' usage."
             % printable_name(type(self).__name__, code_style=True))
예제 #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 ''
예제 #27
0
파일: handlers.py 프로젝트: IlfirinPL/RIDE
 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)
예제 #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))
예제 #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
예제 #30
0
 def _get_message(self):
     from robot.utils import printable_name
     return ("Invalid '%s' usage."
             % printable_name(type(self).__name__, code_style=True))
예제 #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)
     )
예제 #32
0
 def _get_message(self):
     from robot.utils import printable_name
     return "Invalid '%s' usage." \
            % printable_name(self.__class__.__name__, code_style=True)
예제 #33
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 ''
예제 #34
0
 def _get_message(self):
     from robot.utils import printable_name
     return "Invalid '%s' usage." \
            % printable_name(self.__class__.__name__, code_style=True)
예제 #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)
예제 #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)
예제 #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)
     )
예제 #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)
     )