Skip to content

Commit

Permalink
Fix error when fetching metadata for Ruby gems
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Bijlani <ashish@ossillate.com>
  • Loading branch information
PackjGuard committed Apr 28, 2023
1 parent a6a00dd commit fafe4d4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packj/audit/pm_proxy/rubygems.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def is_ver_yanked(self, pkg_name, pkg_version):

def get_version(self, pkg_name, ver_str=None, pkg_info=None):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"
if not ver_str:
ver_str = pkg_info['version']
Expand All @@ -134,13 +134,13 @@ def get_version(self, pkg_name, ver_str=None, pkg_info=None):

def get_description(self, pkg_name, ver_str=None, pkg_info=None):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"
return pkg_info.get('info', None)

def get_readme(self, pkg_name, ver_str=None, pkg_info=None):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"
return pkg_info.get('documentation_uri')

Expand Down Expand Up @@ -197,19 +197,19 @@ def get_release_history(self, pkg_name, pkg_info=None, max_num=-1):

def get_download_url(self, pkg_name, ver_str=None, pkg_info=None, ver_info=None):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"
return pkg_info.get('gem_uri', None)

def get_repo(self, pkg_name, ver_str=None, pkg_info=None, ver_info=None):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"
return pkg_info.get('source_code_uri', None)

def get_downloads(self, pkg_name, pkg_info):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"
downloads = pkg_info.get('downloads', None)
if downloads:
Expand All @@ -218,7 +218,7 @@ def get_downloads(self, pkg_name, pkg_info):

def get_homepage(self, pkg_name, ver_str=None, pkg_info=None):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"
return pkg_info.get('homepage_uri', None)

Expand Down Expand Up @@ -319,7 +319,7 @@ def __parse_dev_list(self, dev_list:str, dev_type:str, data=None):

def get_maintainers(self, pkg_name, ver_str=None, pkg_info=None, ver_info=None):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"

owners = self.__owners(pkg_name)
Expand All @@ -328,7 +328,7 @@ def get_maintainers(self, pkg_name, ver_str=None, pkg_info=None, ver_info=None):
# use rubygems API to get num gems for this author
def get_author(self, pkg_name, ver_str=None, pkg_info=None, ver_info=None):
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"

authors = pkg_info.get('authors', None)
Expand All @@ -337,7 +337,7 @@ def get_author(self, pkg_name, ver_str=None, pkg_info=None, ver_info=None):
def get_dependencies(self, pkg_name, ver_str=None, pkg_info=None, ver_info=None):
# Alternatively, use gem dependency, but it is regex-based and tricky to parse.
if not pkg_info:
pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
_,pkg_info = self.get_metadata(pkg_name=pkg_name, pkg_version=ver_str)
assert pkg_info and 'version' in pkg_info, "Invalid metadata!"

if 'dependencies' in pkg_info and 'runtime' in pkg_info['dependencies']:
Expand Down

0 comments on commit fafe4d4

Please sign in to comment.