def get_table_name_from_index(self, object_name, keyword):
        """Returns the keyword table name from the index table

        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.
        """
        return_kw = None
        return_table_name = None
        kw_object_name = None
        KwDetails = collections.namedtuple(
            'KwDetails', ['table_name', 'kw', 'kw_object_name'])
        open_tab = normalise_path(self.open_tab)
        index_name = get_index_name(rf_table_name(open_tab))
        index_data = get_data_from_json(path.join(self.index_dir, index_name))
        for keyword_ in index_data[DBJsonSetting.keywords]:
            kw_canditate = keyword_[0]
            kw_object_name_alias = keyword_[4]
            kw_table_name = keyword_[3]
            kw_object_name = keyword_[2]
            if (object_name and object_name == kw_object_name_alias
                    or object_name == kw_object_name):
                # Test kw if object names are equal
                if kw_equals_kw_candite(keyword, kw_canditate):
                    return_kw = kw_canditate
                    return_table_name = kw_table_name
                    break
            elif not object_name:
                if kw_equals_kw_candite(keyword, kw_canditate):
                    return_kw = kw_canditate
                    return_table_name = kw_table_name
                    break
        return KwDetails(table_name=return_table_name,
                         kw=return_kw,
                         kw_object_name=kw_object_name)
예제 #2
0
 def test_embedded_arg_kw(self):
     kw1 = 'Embedding arg To Keyword Name'
     kw2 = 'Embedding ${arg} To Keyword Name'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'EMBEDDING_ARG_TO_KEYWORD_NAME'
     kw2 = 'Embedding ${arg} To Keyword Name'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'embedding_arg_to_keyword_name'
     kw2 = 'Embedding ${arg} To Keyword Name'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
 def test_embedded_arg_kw(self):
     kw1 = 'Embedding arg To Keyword Name'
     kw2 = 'Embedding ${arg} To Keyword Name'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'EMBEDDING_ARG_TO_KEYWORD_NAME'
     kw2 = 'Embedding ${arg} To Keyword Name'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'embedding_arg_to_keyword_name'
     kw2 = 'Embedding ${arg} To Keyword Name'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
 def test_kw_equals_kw_candite(self):
     kw1 = 'My Long Keyword'
     kw2 = '.My Long Keyword'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw2 = 'Not Same'
     self.assertFalse(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'My Long Keyword'
     kw2 = '.my long keyword'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'My Long Keyword'
     kw2 = '.my_LONG_keyword'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'My Long Keyword'
     kw2 = '.myLONGkeyword'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
예제 #5
0
 def test_kw_equals_kw_candite(self):
     kw1 = 'My Long Keyword'
     kw2 = '.My Long Keyword'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw2 = 'Not Same'
     self.assertFalse(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'My Long Keyword'
     kw2 = '.my long keyword'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'My Long Keyword'
     kw2 = '.my_LONG_keyword'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
     kw1 = 'My Long Keyword'
     kw2 = '.myLONGkeyword'
     self.assertTrue(kw_equals_kw_candite(kw1, kw2))
    def separate_keyword_from_object(self, rf_cell):
        """Separates keyword from the object.

        ``rf_cell`` -- cell where the cursor is.

        ``rf_cell`` must be a valid valid keyword. Example
        BuiltIn.Comment or Comment. ``rf_cell`` is separated based
        on the object names and keywords found from the
        current_view.json file. If object and/or keyword can not be
        found from the rf_cell, empty values are returned.
        """
        self._get_data()
        completions = self.data[KW_COMPLETION]
        object_best_match = ''
        keyword_best_match = ''
        for kw_completion in completions:
            object_name = kw_completion[2]
            kw = kw_completion[0]
            if rf_cell.startswith(object_name):
                if len(object_best_match) <= len(object_name):
                    object_canditate = object_name
                    object_re = object_canditate.replace('.', '\\.')
                    object_re = '(?:{0}\\.)(.+)'.format(object_re)
                    match = re.search(object_re, rf_cell)
                    if match:
                        keyword_canditate = match.group(1)
                    else:
                        keyword_canditate = ''
                    if kw_equals_kw_candite(kw, keyword_canditate):
                        object_best_match = object_canditate
                        keyword_best_match = keyword_canditate
        return object_best_match, keyword_best_match
    def separate_keyword_from_object(self, rf_cell):
        """Separates keyword from the object.

        ``rf_cell`` -- cell where the cursor is.

        ``rf_cell`` must be a valid valid keyword. Example
        BuiltIn.Comment or Comment. ``rf_cell`` is separated based
        on the object names and keywords found from the
        current_view.json file. If object and/or keyword can not be
        found from the rf_cell, empty values are returned.
        """
        self._get_data()
        completions = self.data[KW_COMPLETION]
        object_best_match = ''
        keyword_best_match = ''
        for kw_completion in completions:
            object_name = kw_completion[2]
            kw = kw_completion[0]
            if rf_cell.startswith(object_name):
                if len(object_best_match) <= len(object_name):
                    object_canditate = object_name
                    object_re = object_canditate.replace('.', '\\.')
                    object_re = '(?:{0}\\.)(.+)'.format(object_re)
                    match = re.search(object_re, rf_cell)
                    if match:
                        keyword_canditate = match.group(1)
                    else:
                        keyword_canditate = ''
                    if kw_equals_kw_candite(kw, keyword_canditate):
                        object_best_match = object_canditate
                        keyword_best_match = keyword_canditate
        return object_best_match, keyword_best_match
    def separate_keyword_from_object(self, rf_cell):
        """Separates keyword from the object.

        ``rf_cell`` -- cell where the cursor is.

        ``rf_cell`` must be a valid valid keyword. Example
        BuiltIn.Comment or Comment. ``rf_cell`` is separated based
        on the object names and keywords found from the
        current_view.json file. If object and/or keyword can not be
        found from the rf_cell, empty values are returned.
        """
        self._get_data()
        completions = self.data[KW_COMPLETION]
        object_best_match = ''
        keyword_best_match = ''
        for kw_completion in completions:
            # This leaves bug in code if the there class name imported like:
            # com.company.object.robot In this case robot is stripped from
            # class name without actually checking should it be.
            object_name = kw_completion[2].rstrip('.' + self.rf_extension)
            kw = kw_completion[0]
            if rf_cell.startswith(object_name):
                if len(object_best_match) <= len(object_name):
                    object_canditate = object_name
                    object_re = object_canditate.replace('.', '\\.')
                    object_re = '(?:{0}\\.)(.+)'.format(object_re)
                    match = re.search(object_re, rf_cell)
                    if match:
                        keyword_canditate = match.group(1)
                    else:
                        keyword_canditate = ''
                    if kw_equals_kw_candite(kw, keyword_canditate):
                        object_best_match = object_canditate
                        keyword_best_match = keyword_canditate
        return object_best_match, keyword_best_match
    def separate_keyword_from_object(self, rf_cell):
        """Separates keyword from the object.

        ``rf_cell`` -- cell where the cursor is.

        ``rf_cell`` must be a valid valid keyword. Example
        BuiltIn.Comment or Comment. ``rf_cell`` is separated based
        on the object names and keywords found from the
        current_view.json file. If object and/or keyword can not be
        found from the rf_cell, empty values are returned.
        """
        self._get_data()
        completions = self.data[KW_COMPLETION]
        object_best_match = ''
        keyword_best_match = ''
        for kw_completion in completions:
            # This leaves bug in code if the there class name imported like:
            # com.company.object.robot In this case robot is stripped from
            # class name without actually checking should it be.
            object_name = kw_completion[2].rstrip('.' + self.rf_extension)
            kw = kw_completion[0]
            if rf_cell.startswith(object_name):
                if len(object_best_match) <= len(object_name):
                    object_canditate = object_name
                    object_re = object_canditate.replace('.', '\\.')
                    object_re = '(?:{0}\\.)(.+)'.format(object_re)
                    match = re.search(object_re, rf_cell)
                    if match:
                        keyword_canditate = match.group(1)
                    else:
                        keyword_canditate = ''
                    if kw_equals_kw_candite(kw, keyword_canditate):
                        object_best_match = object_canditate
                        keyword_best_match = keyword_canditate
        return object_best_match, keyword_best_match
    def get_table_name_from_index(self, object_name, keyword):
        """Returns the keyword table name from the index table

        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.
        """
        return_kw = None
        return_table_name = None
        kw_object_name = None
        KwDetails = collections.namedtuple(
            'KwDetails',
            [
                'table_name',
                'kw',
                'kw_object_name'
            ]
        )
        open_tab = normalise_path(self.open_tab)
        index_name = get_index_name(rf_table_name(open_tab))
        index_data = get_data_from_json(
            path.join(self.index_dir, index_name)
        )
        for keyword_ in index_data[DBJsonSetting.keywords]:
            kw_canditate = keyword_[0]
            kw_object_name_alias = keyword_[4]
            kw_table_name = keyword_[3]
            kw_object_name = keyword_[2]
            if (object_name and
                    object_name == kw_object_name_alias or
                    object_name == kw_object_name):
                # Test kw if object names are equal
                if kw_equals_kw_candite(keyword, kw_canditate):
                    return_kw = kw_canditate
                    return_table_name = kw_table_name
                    break
            elif not object_name:
                if kw_equals_kw_candite(keyword, kw_canditate):
                    return_kw = kw_canditate
                    return_table_name = kw_table_name
                    break
        return KwDetails(
            table_name=return_table_name,
            kw=return_kw,
            kw_object_name=kw_object_name
        )
 def get_lib_keyword_file(self, table_path, object_name, keyword):
     """Returns file path from db where library keyword is defined"""
     data = get_data_from_json(table_path)
     table_keywords = data[DBJsonSetting.keywords]
     table_kw_object = data[DBJsonSetting.library_module]
     for table_kw_data in table_keywords:
         if kw_equals_kw_candite(keyword, table_kw_data):
             if not object_name or object_name == table_kw_object:
                 return table_keywords[table_kw_data][DBJsonSetting.keyword_file]
 def get_lib_keyword_file(self, table_path, object_name, keyword):
     """Returns file path from db where library keyword is defined"""
     data = get_data_from_json(table_path)
     table_keywords = data[DBJsonSetting.keywords]
     table_kw_object = data[DBJsonSetting.library_module]
     for table_kw_data in table_keywords:
         if kw_equals_kw_candite(keyword, table_kw_data):
             if not object_name or object_name == table_kw_object:
                 return table_keywords[table_kw_data][DBJsonSetting.keyword_file]
    def get_table_name_from_index(self, object_name, keyword):
        """Returns the keyword table name from the index table

        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.
        """
        open_tab = normalise_path(self.open_tab)
        index_name = get_index_name(rf_table_name(open_tab))
        index_data = get_data_from_json(path.join(self.index_dir, index_name))
        for keyword_ in index_data[DBJsonSetting.keyword]:
            kw = keyword_[0]
            kw_object_name = keyword_[2]
            kw_table_name = keyword_[3]
            if object_name and object_name == kw_object_name:
                if kw_equals_kw_candite(keyword, kw):
                    return kw_table_name
            elif not object_name:
                if kw_equals_kw_candite(keyword, kw):
                    return kw_table_name
    def get_keyword_documentation(self, table_path, object_name, keyword):
        """Returns the keyword documentation from the table

        ``table_name``  -- Filename where the documentation is searched.
        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.

        """
        keywords = get_data_from_json(table_path)[DBJsonSetting.keywords]
        for keyword_ in keywords:
            if kw_equals_kw_candite(keyword, keyword_):
                return keywords[keyword_][DBJsonSetting.documentation]
    def get_keyword_documentation(self, table_path, object_name, keyword):
        """Returns the keyword documentation from the table

        ``table_name``  -- Filename where the documentation is searched.
        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.

        """
        keywords = get_data_from_json(table_path)[DBJsonSetting.keywords]
        for keyword_ in keywords:
            if kw_equals_kw_candite(keyword, keyword_):
                return keywords[keyword_][DBJsonSetting.documentation]
    def get_table_name_from_index(self, object_name, keyword):
        """Returns the keyword table name from the index table

        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.
        """
        open_tab = normalise_path(self.open_tab)
        index_name = get_index_name(rf_table_name(open_tab))
        index_data = get_data_from_json(
            path.join(self.index_dir, index_name)
        )
        for keyword_ in index_data[DBJsonSetting.keyword]:
            kw = keyword_[0]
            kw_object_name = keyword_[2]
            kw_table_name = keyword_[3]
            if object_name and object_name == kw_object_name:
                if kw_equals_kw_candite(keyword, kw):
                    return kw_table_name
            elif not object_name:
                if kw_equals_kw_candite(keyword, kw):
                    return kw_table_name
    def get_table_name_from_index(self, object_name, keyword):
        """Returns the keyword table name from the index table

        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.
        """
        open_tab = normalise_path(self.open_tab)
        index_name = get_index_name(rf_table_name(open_tab))
        index_data = get_data_from_json(
            path.join(self.index_dir, index_name)
        )
        for keyword_ in index_data[DBJsonSetting.keyword]:
            kw = keyword_[0]
            # This leaves bug in code if the there class name imported like:
            # com.company.object.robot In this case robot is stripped from
            # class name without actually checking should it be.
            kw_object_name = keyword_[2].rstrip('.' + self.rf_extension)
            kw_table_name = keyword_[3]
            if object_name and object_name == kw_object_name:
                if kw_equals_kw_candite(keyword, kw):
                    return kw_table_name
            elif not object_name:
                if kw_equals_kw_candite(keyword, kw):
                    return kw_table_name
예제 #18
0
 def _separate_worker(self, object_best_match, object_canditate, rf_cell,
                      kw_canditate):
     MatchFound = self.get_MatchFound()
     object_ = ''
     keyword = ''
     if len(object_best_match) <= len(object_canditate):
         object_re = object_canditate.replace('.', '\\.')
         object_re = '(?:{0}\\.)(.+)'.format(object_re)
         match = re.search(object_re, rf_cell)
         if match:
             keyword_from_line = match.group(1)
         else:
             keyword_from_line = ''
         if kw_equals_kw_candite(keyword_from_line, kw_canditate):
             object_ = object_canditate
             keyword = keyword_from_line
     return MatchFound(object=object_, keyword=keyword)
 def _separate_worker(self, object_best_match, object_canditate,
                      rf_cell, kw_canditate):
     MatchFound = self.get_MatchFound()
     object_ = ''
     keyword = ''
     if len(object_best_match) <= len(object_canditate):
         object_re = object_canditate.replace('.', '\\.')
         object_re = '(?:{0}\\.)(.+)'.format(object_re)
         match = re.search(object_re, rf_cell)
         if match:
             keyword_from_line = match.group(1)
         else:
             keyword_from_line = ''
         if kw_equals_kw_candite(keyword_from_line, kw_canditate):
             object_ = object_canditate
             keyword = keyword_from_line
     return MatchFound(object=object_, keyword=keyword)