Example #1
0
 def parse(self):
     list = []
     lines = self.data.splitlines()
     for line in lines:
         info = LibraryInfo()
         info.manager = Requirements.MANAGER_NAME
         has_version = False
         for operator in Requirements.VERSION_OPERATORS:
             if operator not in line:
                 continue
             else:
                 info.name = str(line.split(operator)[0])
                 info.version = operator + str(line.split(operator)[1])
                 has_version = True
         if not has_version:
             info.name = line
         if Manager.needIndex():
             pipy = Pypi()
             index_info = pipy.get_library_info(info.name)
             if Manager.needLicense():
                 info.license = index_info.get('license')
             if Manager.needAuthor():
                 info.author = index_info.get('author')
             if Manager.needHpUrl():
                 info.homepage_url = index_info.get('homepage_url')
             if Manager.needCodeUrl():
                 info.code_url = index_info.get('code_url')
         list.append(info)
     return list
Example #2
0
 def parse(self):
     list = []
     package = json.loads(self.data)
     for kinds in Package.PACKAGE_KINDS:
         if kinds not in package.keys():
             continue
         for lib in package[kinds]:
             info = LibraryInfo()
             info.manager = Package.MANAGER_NAME
             info.name = lib
             info.version = package[kinds][lib]
             if Manager.needIndex():
                 npmjs = Npmjs()
                 index_info = npmjs.get_library_info(info.name)
                 if Manager.needLicense():
                     info.license = index_info.get('license')
                 if Manager.needAuthor():
                     info.author = index_info.get('author')
                 if Manager.needHpUrl():
                     info.homepage_url = index_info.get('homepage_url')
                 if Manager.needCodeUrl():
                     info.code_url = index_info.get('code_url')
             list.append(info)
     return list