コード例 #1
0
 def get_variables(self):
     variables = []
     for file in listdir(self.view_db):
         data = get_data_from_json(path.join(self.view_db, file))
         if self.is_variable_file(data):
             variables.append(self.get_resource_or_variable_import(data))
     return variables
 def get_variables(self):
     variables = []
     for file in listdir(self.view_db):
         data = get_data_from_json(path.join(self.view_db, file))
         if self.is_variable_file(data):
             variables.append(self.get_resource_or_variable_import(data))
     return variables
    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)
コード例 #4
0
    def return_file_and_patter(self, object_name, keyword):
        """Returns regex and filename patter to find keyword from the source

        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.

        Searches the file path where the keyword is located and forms the
        regex patter which can be used to search the keyword from the file.
        Can be used to get the keyword from the robot data or from the
        Python libraries.
        """
        regex = None
        file_path = None
        table_name = self.get_doc.get_table_name_from_index(object_name,
                                                            keyword)
        if not table_name:
            return regex, file_path
        table_path = path.join(self.table_dir, table_name)
        data = get_data_from_json(table_path)
        if DBJsonSetting.file_path in data:
            file_path_table = data[DBJsonSetting.file_path]
        else:
            file_path_table = None
        if self.rf_data(file_path_table):
            regex = self.get_regex_resource(keyword)
            file_path = file_path_table
            return regex, file_path
        else:
            return self.get_lib_keyword(
                table_path,
                object_name,
                keyword
            )
コード例 #5
0
    def return_file_and_patter(self, object_name, keyword):
        """Returns regex and filename patter to find keyword from the source

        ``keyword``     -- Keyword documentation to search from database.
        ``object_name`` -- Library or resource object name.

        Searches the file path where the keyword is located and forms the
        regex patter which can be used to search the keyword from the file.
        Can be used to get the keyword from the robot data or from the
        Python libraries.
        """
        regex = None
        file_path = None
        kw_details = self.get_doc.get_table_name_from_index(
            object_name, keyword)
        if not kw_details.table_name:
            return regex, file_path
        table_path = path.join(self.table_dir, kw_details.table_name)
        data = get_data_from_json(table_path)
        if DBJsonSetting.file_path in data:
            file_path_table = data[DBJsonSetting.file_path]
        else:
            file_path_table = None
        if self.rf_data(file_path_table):
            regex = self.get_regex_resource(kw_details.kw)
            file_path = file_path_table
            return regex, file_path
        else:
            return self.get_lib_keyword(table_path, kw_details.kw_object_name,
                                        kw_details.kw)
コード例 #6
0
 def get_libraries(self):
     libraries = []
     for file in listdir(self.view_db):
         data = get_data_from_json(path.join(self.view_db, file))
         if self.is_library(data):
             if 'BuiltIn' not in data[DBJsonSetting.library_module]:
                 libraries.append(self.get_library_import(data))
     return libraries
 def get_libraries(self):
     libraries = []
     for file in listdir(self.view_db):
         data = get_data_from_json(path.join(self.view_db, file))
         if self.is_library(data):
             if "BuiltIn" not in data[DBJsonSetting.library_module]:
                 libraries.append(self.get_library_import(data))
     return libraries
コード例 #8
0
 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]
コード例 #9
0
 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]
コード例 #10
0
    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]
コード例 #11
0
    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]
コード例 #12
0
 def get_library_path(self, imported_lib, open_tab, db_dir):
     lib_path = ''
     if imported_lib.endswith('.py'):
         lib_path = self.get_path_resource_path(imported_file=imported_lib,
                                                open_tab=open_tab)
     else:
         file_name = lib_table_name(imported_lib)
         file_name = str(file_name)
         file_path = os.path.join(db_dir, file_name)
         data = get_data_from_json(file_path)
         keywords = data.get('keywords')
         first_kw = keywords[list(keywords.keys())[0]]
         lib_path = first_kw['keyword_file']
     return lib_path
コード例 #13
0
 def get_library_path(self, imported_lib, open_tab, db_dir):
     lib_path = ''
     if imported_lib.endswith('.py'):
         lib_path = self.get_path_resource_path(
             imported_file=imported_lib, open_tab=open_tab
         )
     else:
         imported_lib_utf8 = imported_lib.encode('utf-8')
         file_name = lib_table_name(imported_lib_utf8)
         file_name = str(file_name)
         file_path = os.path.join(db_dir, file_name)
         data = get_data_from_json(file_path)
         keywords = data.get('keywords')
         first_kw = keywords[list(keywords.keys())[0]]
         lib_path = first_kw['keyword_file']
     return lib_path
コード例 #14
0
    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
        )
コード例 #15
0
    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]
            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
コード例 #17
0
    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