def get_library_imports(self, data):
     l = []
     for lib in data[DBJsonSetting.libraries]:
         if lib[DBJsonSetting.library_path]:
             lib_import = lib[DBJsonSetting.library_path]
         else:
             lib_import = lib[DBJsonSetting.library_name]
         lib_args = lib[DBJsonSetting.library_arguments]
         lib_data = None
         try:
             lib_data = self.data_parser.parse_library(
                 lib_import,
                 lib_args
             )
         except ValueError:
             message = ('Unable to parse library "{0}"'
                        ', with args: "{1}"'.format(lib_import, lib_args))
             logging.error(message)
         if lib_data:
             table_name = lib_table_name(
                 lib_data[DBJsonSetting.library_module]
             )
             l.append(table_name)
             self.library_alias.append(
                 (table_name, lib[DBJsonSetting.library_alias])
             )
     return l
 def put_item_to_db(self, item, db_path):
     """Creates the json file to self.db_path"""
     if DBJsonSetting.library_module in item:
         f_name = lib_table_name(item[DBJsonSetting.library_module])
     elif DBJsonSetting.file_path in item:
         f_name = rf_table_name(item[DBJsonSetting.file_path])
     f = open(os.path.join(db_path, f_name), 'w')
     json.dump(item, f)
     f.close()
Example #3
0
 def put_item_to_db(self, item, db_path):
     """Creates the json file to self.db_path"""
     if DBJsonSetting.library_module in item:
         f_name = lib_table_name(item[DBJsonSetting.library_module])
     elif DBJsonSetting.file_path in item:
         f_name = rf_table_name(item[DBJsonSetting.file_path])
     f = open(os.path.join(db_path, f_name), 'w')
     json.dump(item, f)
     f.close()
Example #4
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
 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
Example #6
0
 def add_xml_libraries(self, path_to_xml):
     """Adds the found xml libraries to the queue"""
     for file_ in finder(path_to_xml, 'xml'):
         root = ET.parse(file_).getroot()
         if root.attrib['type'] == DBJsonSetting.library:
             self.queue.add(lib_table_name(root.attrib['name']), None, None)
 def othernamelib_table_name(self):
     return lib_table_name(
         'LibraryNameWhichIsLongerThan100CharactersButItSeemsThatItRequires'
         'QuiteAlotLettersInTheFileNameAndIsNotGoodRealLifeExample')
 def builtin_table_name(self):
     return lib_table_name('BuiltIn')
 def add_xml_libraries(self, path_to_xml):
     """Adds the found xml libraries to the queue"""
     for file_ in finder(path_to_xml, 'xml'):
         root = ET.parse(file_).getroot()
         if root.attrib['type'] == DBJsonSetting.library:
             self.queue.add(lib_table_name(root.attrib['name']), None, None)
 def othernamelib_table_name(self):
     return lib_table_name(
         'LibraryNameWhichIsLongerThan100CharactersButItSeemsThatItRequires'
         'QuiteAlotLettersInTheFileNameAndIsNotGoodRealLifeExample'
     )
 def builtin_table_name(self):
     return lib_table_name('BuiltIn')