euscan: handlers now use a Package object instead of cpv
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
parent
fd12bf1cb4
commit
8e08b6a33b
@ -14,22 +14,22 @@ handlers = sorted(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def find_best_handler(cpv, url):
|
def find_best_handler(pkg, url):
|
||||||
for handler in handlers:
|
for handler in handlers:
|
||||||
if handler.can_handle(cpv, url):
|
if handler.can_handle(pkg, url):
|
||||||
return handler
|
return handler
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def scan(cpv, url):
|
def scan(pkg, url):
|
||||||
handler = find_best_handler(cpv, url)
|
handler = find_best_handler(pkg, url)
|
||||||
if handler:
|
if handler:
|
||||||
return handler.scan(cpv, url)
|
return handler.scan(pkg, url)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def brute_force(cpv, url):
|
def brute_force(pkg, url):
|
||||||
handler = find_best_handler(cpv, url)
|
handler = find_best_handler(pkg, url)
|
||||||
if handler:
|
if handler:
|
||||||
return handler.brute_force(cpv, url)
|
return handler.brute_force(pkg, url)
|
||||||
return []
|
return []
|
||||||
|
@ -12,7 +12,7 @@ PRIORITY = 100
|
|||||||
_cpan_package_name_re = re.compile("mirror://cpan/authors/.*/([^/.]*).*")
|
_cpan_package_name_re = re.compile("mirror://cpan/authors/.*/([^/.]*).*")
|
||||||
|
|
||||||
|
|
||||||
def can_handle(cpv, url):
|
def can_handle(pkg, url):
|
||||||
return url.startswith('mirror://cpan/')
|
return url.startswith('mirror://cpan/')
|
||||||
|
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ def cpan_vercmp(cp, a, b):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
def scan(cpv, url):
|
def scan(pkg, url):
|
||||||
cp, ver, rev = portage.pkgsplit(cpv)
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
||||||
pkg = guess_package(cp, url)
|
pkg = guess_package(cp, url)
|
||||||
|
|
||||||
orig_url = url
|
orig_url = url
|
||||||
@ -133,5 +133,5 @@ def scan(cpv, url):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def brute_force(cpv, url):
|
def brute_force(pkg, url):
|
||||||
return []
|
return []
|
||||||
|
@ -104,7 +104,7 @@ def scan_directory_recursive(cp, ver, rev, url, steps, orig_url):
|
|||||||
return versions
|
return versions
|
||||||
|
|
||||||
|
|
||||||
def scan(cpv, url):
|
def scan(pkg, url):
|
||||||
for bu in SCANDIR_BLACKLIST_URLS:
|
for bu in SCANDIR_BLACKLIST_URLS:
|
||||||
if re.match(bu, url):
|
if re.match(bu, url):
|
||||||
output.einfo("%s is blacklisted by rule %s" % (url, bu))
|
output.einfo("%s is blacklisted by rule %s" % (url, bu))
|
||||||
@ -114,7 +114,7 @@ def scan(cpv, url):
|
|||||||
if not resolved_url:
|
if not resolved_url:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
cp, ver, rev = portage.pkgsplit(cpv)
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
||||||
|
|
||||||
# 'Hack' for _beta/_rc versions where _ is used instead of -
|
# 'Hack' for _beta/_rc versions where _ is used instead of -
|
||||||
if ver not in resolved_url:
|
if ver not in resolved_url:
|
||||||
@ -141,8 +141,8 @@ def scan(cpv, url):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def brute_force(cpv, url):
|
def brute_force(pkg, url):
|
||||||
cp, ver, rev = portage.pkgsplit(cpv)
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
||||||
|
|
||||||
url = helpers.parse_mirror(url)
|
url = helpers.parse_mirror(url)
|
||||||
if not url:
|
if not url:
|
||||||
@ -226,5 +226,5 @@ def brute_force(cpv, url):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def can_handle(cpv, url):
|
def can_handle(pkg, url):
|
||||||
return True
|
return True
|
||||||
|
@ -11,7 +11,7 @@ CONFIDENCE = 100.0
|
|||||||
PRIORITY = 100
|
PRIORITY = 100
|
||||||
|
|
||||||
|
|
||||||
def can_handle(cpv, url):
|
def can_handle(pkg, url):
|
||||||
return url.startswith('mirror://github/')
|
return url.startswith('mirror://github/')
|
||||||
|
|
||||||
|
|
||||||
@ -22,13 +22,13 @@ def guess_package(cp, url):
|
|||||||
return (match.group(1), match.group(2), match.group(3))
|
return (match.group(1), match.group(2), match.group(3))
|
||||||
|
|
||||||
|
|
||||||
def scan(cpv, url):
|
def scan(pkg, url):
|
||||||
'http://developer.github.com/v3/repos/downloads/'
|
'http://developer.github.com/v3/repos/downloads/'
|
||||||
|
|
||||||
user, project, filename = guess_package(cpv, url)
|
user, project, filename = guess_package(pkg.cpv, url)
|
||||||
|
|
||||||
# find out where version is expected to be found
|
# find out where version is expected to be found
|
||||||
cp, ver, rev = portage.pkgsplit(cpv)
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
||||||
if ver not in filename:
|
if ver not in filename:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -54,5 +54,5 @@ def scan(cpv, url):
|
|||||||
yield (dl['html_url'], pv, HANDLER_NAME, CONFIDENCE)
|
yield (dl['html_url'], pv, HANDLER_NAME, CONFIDENCE)
|
||||||
|
|
||||||
|
|
||||||
def brute_force(cpv, url):
|
def brute_force(pkg, url):
|
||||||
return []
|
return []
|
||||||
|
@ -5,7 +5,7 @@ PRIORITY = 100
|
|||||||
HANDLER_NAME = "kde"
|
HANDLER_NAME = "kde"
|
||||||
|
|
||||||
|
|
||||||
def can_handle(cpv, url):
|
def can_handle(pkg, url):
|
||||||
if url.startswith('mirror://kde/'):
|
if url.startswith('mirror://kde/'):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -22,21 +22,21 @@ def clean_results(results):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def scan(cpv, url):
|
def scan(pkg, url):
|
||||||
results = generic.scan(cpv, url)
|
results = generic.scan(pkg.cpv, url)
|
||||||
|
|
||||||
if url.startswith('mirror://kde/unstable/'):
|
if url.startswith('mirror://kde/unstable/'):
|
||||||
url = url.replace('mirror://kde/unstable/', 'mirror://kde/stable/')
|
url = url.replace('mirror://kde/unstable/', 'mirror://kde/stable/')
|
||||||
results += generic.scan(cpv, url)
|
results += generic.scan(pkg.cpv, url)
|
||||||
|
|
||||||
return clean_results(results)
|
return clean_results(results)
|
||||||
|
|
||||||
|
|
||||||
def brute_force(cpv, url):
|
def brute_force(pkg, url):
|
||||||
results = generic.brute_force(cpv, url)
|
results = generic.brute_force(pkg.cpv, url)
|
||||||
|
|
||||||
if url.startswith('mirror://kde/unstable/'):
|
if url.startswith('mirror://kde/unstable/'):
|
||||||
url = url.replace('mirror://kde/unstable/', 'mirror://kde/stable/')
|
url = url.replace('mirror://kde/unstable/', 'mirror://kde/stable/')
|
||||||
results += generic.brute_force(cpv, url)
|
results += generic.brute_force(pkg.cpv, url)
|
||||||
|
|
||||||
return clean_results(results)
|
return clean_results(results)
|
||||||
|
@ -10,7 +10,7 @@ CONFIDENCE = 100.0
|
|||||||
PRIORITY = 100
|
PRIORITY = 100
|
||||||
|
|
||||||
|
|
||||||
def can_handle(cpv, url):
|
def can_handle(pkg, url):
|
||||||
if url.startswith('http://pear.php.net/get/'):
|
if url.startswith('http://pear.php.net/get/'):
|
||||||
return True
|
return True
|
||||||
if url.startswith('http://pecl.php.net/get/'):
|
if url.startswith('http://pecl.php.net/get/'):
|
||||||
@ -30,12 +30,12 @@ def guess_package_and_channel(cp, url):
|
|||||||
return pkg, host
|
return pkg, host
|
||||||
|
|
||||||
|
|
||||||
def scan(cpv, url):
|
def scan(pkg, url):
|
||||||
cp, ver, rev = portage.pkgsplit(cpv)
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
||||||
pkg, channel = guess_package_and_channel(cp, url)
|
package, channel = guess_package_and_channel(cp, url)
|
||||||
|
|
||||||
orig_url = url
|
orig_url = url
|
||||||
url = 'http://%s/rest/r/%s/allreleases.xml' % (channel, pkg.lower())
|
url = 'http://%s/rest/r/%s/allreleases.xml' % (channel, package.lower())
|
||||||
|
|
||||||
output.einfo("Using: " + url)
|
output.einfo("Using: " + url)
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ def scan(cpv, url):
|
|||||||
if helpers.version_filtered(cp, ver, pv):
|
if helpers.version_filtered(cp, ver, pv):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
url = 'http://%s/get/%s-%s.tgz' % (channel, pkg, up_pv)
|
url = 'http://%s/get/%s-%s.tgz' % (channel, package, up_pv)
|
||||||
|
|
||||||
if url == orig_url:
|
if url == orig_url:
|
||||||
continue
|
continue
|
||||||
@ -72,5 +72,5 @@ def scan(cpv, url):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def brute_force(cpv, url):
|
def brute_force(pkg, url):
|
||||||
return []
|
return []
|
||||||
|
@ -10,7 +10,7 @@ CONFIDENCE = 100.0
|
|||||||
PRIORITY = 100
|
PRIORITY = 100
|
||||||
|
|
||||||
|
|
||||||
def can_handle(cpv, url):
|
def can_handle(pkg, url):
|
||||||
return url.startswith('mirror://pypi/')
|
return url.startswith('mirror://pypi/')
|
||||||
|
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ def guess_package(cp, url):
|
|||||||
return pkg
|
return pkg
|
||||||
|
|
||||||
|
|
||||||
def scan(cpv, url):
|
def scan(pkg, url):
|
||||||
'http://wiki.python.org/moin/PyPiXmlRpc'
|
'http://wiki.python.org/moin/PyPiXmlRpc'
|
||||||
|
|
||||||
package = guess_package(cpv, url)
|
package = guess_package(pkg.cpv, url)
|
||||||
|
|
||||||
output.einfo("Using PyPi XMLRPC: " + package)
|
output.einfo("Using PyPi XMLRPC: " + package)
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ def scan(cpv, url):
|
|||||||
|
|
||||||
versions.reverse()
|
versions.reverse()
|
||||||
|
|
||||||
cp, ver, rev = portage.pkgsplit(cpv)
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
@ -54,5 +54,5 @@ def scan(cpv, url):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def brute_force(cpv, url):
|
def brute_force(pkg, url):
|
||||||
return []
|
return []
|
||||||
|
@ -10,7 +10,7 @@ CONFIDENCE = 100.0
|
|||||||
PRIORITY = 100
|
PRIORITY = 100
|
||||||
|
|
||||||
|
|
||||||
def can_handle(cpv, url):
|
def can_handle(pkg, url):
|
||||||
return url.startswith('mirror://rubygems/')
|
return url.startswith('mirror://rubygems/')
|
||||||
|
|
||||||
|
|
||||||
@ -29,13 +29,13 @@ def guess_gem(cpv, url):
|
|||||||
return pkg
|
return pkg
|
||||||
|
|
||||||
|
|
||||||
def scan(cpv, url):
|
def scan(pkg, url):
|
||||||
'http://guides.rubygems.org/rubygems-org-api/#gemversion'
|
'http://guides.rubygems.org/rubygems-org-api/#gemversion'
|
||||||
|
|
||||||
gem = guess_gem(cpv, url)
|
gem = guess_gem(pkg.cpv, url)
|
||||||
if not gem:
|
if not gem:
|
||||||
output.eerror("Can't guess gem name using %s and %s" % \
|
output.eerror("Can't guess gem name using %s and %s" % \
|
||||||
(cpv, url))
|
(pkg.cpv, url))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
url = 'http://rubygems.org/api/v1/versions/%s.json' % gem
|
url = 'http://rubygems.org/api/v1/versions/%s.json' % gem
|
||||||
@ -58,7 +58,7 @@ def scan(cpv, url):
|
|||||||
if not versions:
|
if not versions:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
cp, ver, rev = portage.pkgsplit(cpv)
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
@ -73,5 +73,5 @@ def scan(cpv, url):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def brute_force(cpv, url):
|
def brute_force(pkg, url):
|
||||||
return []
|
return []
|
||||||
|
@ -44,7 +44,7 @@ def filter_versions(cp, versions):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def scan_upstream_urls(cpv, urls, on_progress):
|
def scan_upstream_urls(pkg, urls, on_progress):
|
||||||
versions = []
|
versions = []
|
||||||
|
|
||||||
if on_progress:
|
if on_progress:
|
||||||
@ -73,7 +73,7 @@ def scan_upstream_urls(cpv, urls, on_progress):
|
|||||||
# Try normal scan
|
# Try normal scan
|
||||||
if CONFIG["scan-dir"]:
|
if CONFIG["scan-dir"]:
|
||||||
try:
|
try:
|
||||||
versions.extend(handlers.scan(cpv, url))
|
versions.extend(handlers.scan(pkg, url))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
output.ewarn("Handler failed: [%s] %s"
|
output.ewarn("Handler failed: [%s] %s"
|
||||||
% (e.__class__.__name__, e.message))
|
% (e.__class__.__name__, e.message))
|
||||||
@ -83,12 +83,12 @@ def scan_upstream_urls(cpv, urls, on_progress):
|
|||||||
|
|
||||||
# Brute Force
|
# Brute Force
|
||||||
if CONFIG["brute-force"] > 0:
|
if CONFIG["brute-force"] > 0:
|
||||||
versions.extend(handlers.brute_force(cpv, url))
|
versions.extend(handlers.brute_force(pkg, url))
|
||||||
|
|
||||||
if versions and CONFIG['oneshot']:
|
if versions and CONFIG['oneshot']:
|
||||||
break
|
break
|
||||||
|
|
||||||
cp, ver, rev = portage.pkgsplit(cpv)
|
cp, ver, rev = portage.pkgsplit(pkg.cpv)
|
||||||
|
|
||||||
result = filter_versions(cp, versions)
|
result = filter_versions(cp, versions)
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ def scan_upstream(query, on_progress=None):
|
|||||||
scan_time = (datetime.now() - start_time).total_seconds()
|
scan_time = (datetime.now() - start_time).total_seconds()
|
||||||
output.metadata("scan_time", scan_time, show=False)
|
output.metadata("scan_time", scan_time, show=False)
|
||||||
|
|
||||||
result = scan_upstream_urls(pkg.cpv, urls, on_progress)
|
result = scan_upstream_urls(pkg, urls, on_progress)
|
||||||
|
|
||||||
if on_progress:
|
if on_progress:
|
||||||
on_progress(increment=10)
|
on_progress(increment=10)
|
||||||
|
Loading…
Reference in New Issue
Block a user