def load_gems(self, analysis_json, containing_image): gems_json = analysis_json.get('package_list', {}).get('pkgs.gems', {}).get('base') if not gems_json: return [] gems = [] for path, gem_str in gems_json.items(): gem_json = json.loads(gem_str) n = ImageGem() n.path_hash = hashlib.sha256(path).hexdigest() n.path = path n.name = gem_json.get('name') n.src_pkg = gem_json.get('src_pkg') n.origins_json = gem_json.get('origins') n.licenses_json = gem_json.get('lics') n.versions_json = gem_json.get('versions') n.latest = gem_json.get('latest') n.image_user_id = containing_image.user_id n.image_id = containing_image.id gems.append(n) return gems
def load_gems(self, analysis_json, containing_image): gems_json = analysis_json.get('package_list', {}).get('pkgs.gems', {}).get('base') if not gems_json: return [] gems = [] image_packages = [] for path, gem_str in list(gems_json.items()): gem_json = json.loads(gem_str) n = ImageGem() n.path_hash = hashlib.sha256(ensure_bytes(path)).hexdigest() n.path = path n.name = gem_json.get('name') n.src_pkg = gem_json.get('src_pkg') n.origins_json = gem_json.get('origins') n.licenses_json = gem_json.get('lics') n.versions_json = gem_json.get('versions') n.latest = gem_json.get('latest') n.image_user_id = containing_image.user_id n.image_id = containing_image.id #gems.append(n) np = ImagePackage() # primary keys np.name = n.name if len(n.versions_json): version = n.versions_json[0] else: version = "N/A" np.version = version np.pkg_type = 'gem' np.arch = 'N/A' np.image_user_id = n.image_user_id np.image_id = n.image_id np.pkg_path = n.path # other np.pkg_path_hash = n.path_hash np.distro_name = 'gem' np.distro_version = 'N/A' np.like_distro = 'gem' np.fullversion = np.version np.license = ' '.join(n.licenses_json) np.origin = ' '.join(n.origins_json) #np.metadata_json = pkg_json.get('metadata') fullname = np.name np.normalized_src_pkg = fullname np.src_pkg = fullname image_packages.append(np) return image_packages