Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse_src_github(self, name, url):
p, v = parse_src_name(url, 'HEAD')
if '/' in p: url = 'https://github.com/{0}/archive/{1}.tar.gz'.format(p, v)
else: url = 'https://github.com/{0}/{0}/archive/{1}.tar.gz'.format(p, v)
if name is None: name = p
return PackageSource(name=name, url=url)
def to_fname(self):
if isinstance(self.pkg_src, PackageSource): return self.pkg_src.to_fname()
else: return self.pkg_src
def parse_pkg_src(self, pkg, start=None, no_recipe=False):
if isinstance(pkg, PackageSource): return pkg
if isinstance(pkg, PackageBuild): return self.parse_pkg_src(pkg.pkg_src, start)
name, url = parse_alias(pkg)
self.log('parse_pkg_src:', name, url, pkg)
if '://' not in url:
return self.parse_src_file(name, url, start) or \
(None if no_recipe else self.parse_src_recipe(name, url)) or \
self.parse_src_github(name, url)
return PackageSource(name=name, url=url)
def parse_src_file(self, name, url, start=None):
f = util.actual_path(url, start)
self.log('parse_src_file actual_path:', start, f)
if os.path.exists(f): return PackageSource(name=name, url='file://' + f)
return None
def parse_pkg_src(self, pkg, start=None, no_recipe=False):
if isinstance(pkg, PackageSource): return pkg
if isinstance(pkg, PackageBuild): return self.parse_pkg_src(pkg.pkg_src, start)
name, url = parse_alias(pkg)
self.log('parse_pkg_src:', name, url, pkg)
if '://' not in url:
return self.parse_src_file(name, url, start) or \
(None if no_recipe else self.parse_src_recipe(name, url)) or \
self.parse_src_github(name, url)
return PackageSource(name=name, url=url)
def fname_to_pkg(fname):
if fname.startswith('_url_'): return PackageSource(name=decode_url(fname), fname=fname)
else: return PackageSource(name=fname.replace('__', '/'), fname=fname)