diff options
author | volpino <fox91@anche.no> | 2012-07-24 08:56:00 +0200 |
---|---|---|
committer | volpino <fox91@anche.no> | 2012-07-24 08:56:00 +0200 |
commit | 8e08b6a33bb1c0771fe0534c0e070f46f50d96b8 (patch) | |
tree | e076356e5f536516069e59083a86ef65eeb3992f /pym | |
parent | Merge branch 'master' of https://github.com/iksaif/euscan (diff) | |
download | euscan-8e08b6a33bb1c0771fe0534c0e070f46f50d96b8.tar.gz euscan-8e08b6a33bb1c0771fe0534c0e070f46f50d96b8.tar.bz2 euscan-8e08b6a33bb1c0771fe0534c0e070f46f50d96b8.zip |
euscan: handlers now use a Package object instead of cpv
Signed-off-by: volpino <fox91@anche.no>
Diffstat (limited to 'pym')
-rw-r--r-- | pym/euscan/handlers/__init__.py | 16 | ||||
-rw-r--r-- | pym/euscan/handlers/cpan.py | 8 | ||||
-rw-r--r-- | pym/euscan/handlers/generic.py | 10 | ||||
-rw-r--r-- | pym/euscan/handlers/github.py | 10 | ||||
-rw-r--r-- | pym/euscan/handlers/kde.py | 14 | ||||
-rw-r--r-- | pym/euscan/handlers/php.py | 14 | ||||
-rw-r--r-- | pym/euscan/handlers/pypi.py | 10 | ||||
-rw-r--r-- | pym/euscan/handlers/rubygem.py | 12 | ||||
-rw-r--r-- | pym/euscan/scan.py | 10 |
9 files changed, 52 insertions, 52 deletions
diff --git a/pym/euscan/handlers/__init__.py b/pym/euscan/handlers/__init__.py index bcbd680..495ef7c 100644 --- a/pym/euscan/handlers/__init__.py +++ b/pym/euscan/handlers/__init__.py @@ -14,22 +14,22 @@ handlers = sorted( ) -def find_best_handler(cpv, url): +def find_best_handler(pkg, url): for handler in handlers: - if handler.can_handle(cpv, url): + if handler.can_handle(pkg, url): return handler return None -def scan(cpv, url): - handler = find_best_handler(cpv, url) +def scan(pkg, url): + handler = find_best_handler(pkg, url) if handler: - return handler.scan(cpv, url) + return handler.scan(pkg, url) return [] -def brute_force(cpv, url): - handler = find_best_handler(cpv, url) +def brute_force(pkg, url): + handler = find_best_handler(pkg, url) if handler: - return handler.brute_force(cpv, url) + return handler.brute_force(pkg, url) return [] diff --git a/pym/euscan/handlers/cpan.py b/pym/euscan/handlers/cpan.py index 7115c20..091c64c 100644 --- a/pym/euscan/handlers/cpan.py +++ b/pym/euscan/handlers/cpan.py @@ -12,7 +12,7 @@ PRIORITY = 100 _cpan_package_name_re = re.compile("mirror://cpan/authors/.*/([^/.]*).*") -def can_handle(cpv, url): +def can_handle(pkg, url): return url.startswith('mirror://cpan/') @@ -79,8 +79,8 @@ def cpan_vercmp(cp, a, b): return 1 -def scan(cpv, url): - cp, ver, rev = portage.pkgsplit(cpv) +def scan(pkg, url): + cp, ver, rev = portage.pkgsplit(pkg.cpv) pkg = guess_package(cp, url) orig_url = url @@ -133,5 +133,5 @@ def scan(cpv, url): return ret -def brute_force(cpv, url): +def brute_force(pkg, url): return [] diff --git a/pym/euscan/handlers/generic.py b/pym/euscan/handlers/generic.py index 5c6d467..a9a3048 100644 --- a/pym/euscan/handlers/generic.py +++ b/pym/euscan/handlers/generic.py @@ -104,7 +104,7 @@ def scan_directory_recursive(cp, ver, rev, url, steps, orig_url): return versions -def scan(cpv, url): +def scan(pkg, url): for bu in SCANDIR_BLACKLIST_URLS: if re.match(bu, url): output.einfo("%s is blacklisted by rule %s" % (url, bu)) @@ -114,7 +114,7 @@ def scan(cpv, url): if not resolved_url: return [] - cp, ver, rev = portage.pkgsplit(cpv) + cp, ver, rev = portage.pkgsplit(pkg.cpv) # 'Hack' for _beta/_rc versions where _ is used instead of - if ver not in resolved_url: @@ -141,8 +141,8 @@ def scan(cpv, url): return ret -def brute_force(cpv, url): - cp, ver, rev = portage.pkgsplit(cpv) +def brute_force(pkg, url): + cp, ver, rev = portage.pkgsplit(pkg.cpv) url = helpers.parse_mirror(url) if not url: @@ -226,5 +226,5 @@ def brute_force(cpv, url): return result -def can_handle(cpv, url): +def can_handle(pkg, url): return True diff --git a/pym/euscan/handlers/github.py b/pym/euscan/handlers/github.py index ac5baca..76c50c9 100644 --- a/pym/euscan/handlers/github.py +++ b/pym/euscan/handlers/github.py @@ -11,7 +11,7 @@ CONFIDENCE = 100.0 PRIORITY = 100 -def can_handle(cpv, url): +def can_handle(pkg, url): return url.startswith('mirror://github/') @@ -22,13 +22,13 @@ def guess_package(cp, url): 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/' - user, project, filename = guess_package(cpv, url) + user, project, filename = guess_package(pkg.cpv, url) # 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: return @@ -54,5 +54,5 @@ def scan(cpv, url): yield (dl['html_url'], pv, HANDLER_NAME, CONFIDENCE) -def brute_force(cpv, url): +def brute_force(pkg, url): return [] diff --git a/pym/euscan/handlers/kde.py b/pym/euscan/handlers/kde.py index 406b079..1dcead6 100644 --- a/pym/euscan/handlers/kde.py +++ b/pym/euscan/handlers/kde.py @@ -5,7 +5,7 @@ PRIORITY = 100 HANDLER_NAME = "kde" -def can_handle(cpv, url): +def can_handle(pkg, url): if url.startswith('mirror://kde/'): return True return False @@ -22,21 +22,21 @@ def clean_results(results): return ret -def scan(cpv, url): - results = generic.scan(cpv, url) +def scan(pkg, url): + results = generic.scan(pkg.cpv, url) if url.startswith('mirror://kde/unstable/'): url = url.replace('mirror://kde/unstable/', 'mirror://kde/stable/') - results += generic.scan(cpv, url) + results += generic.scan(pkg.cpv, url) return clean_results(results) -def brute_force(cpv, url): - results = generic.brute_force(cpv, url) +def brute_force(pkg, url): + results = generic.brute_force(pkg.cpv, url) if url.startswith('mirror://kde/unstable/'): 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) diff --git a/pym/euscan/handlers/php.py b/pym/euscan/handlers/php.py index 158280c..36bf3d7 100644 --- a/pym/euscan/handlers/php.py +++ b/pym/euscan/handlers/php.py @@ -10,7 +10,7 @@ CONFIDENCE = 100.0 PRIORITY = 100 -def can_handle(cpv, url): +def can_handle(pkg, url): if url.startswith('http://pear.php.net/get/'): return True if url.startswith('http://pecl.php.net/get/'): @@ -30,12 +30,12 @@ def guess_package_and_channel(cp, url): return pkg, host -def scan(cpv, url): - cp, ver, rev = portage.pkgsplit(cpv) - pkg, channel = guess_package_and_channel(cp, url) +def scan(pkg, url): + cp, ver, rev = portage.pkgsplit(pkg.cpv) + package, channel = guess_package_and_channel(cp, 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) @@ -62,7 +62,7 @@ def scan(cpv, url): if helpers.version_filtered(cp, ver, pv): 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: continue @@ -72,5 +72,5 @@ def scan(cpv, url): return ret -def brute_force(cpv, url): +def brute_force(pkg, url): return [] diff --git a/pym/euscan/handlers/pypi.py b/pym/euscan/handlers/pypi.py index 1dcad99..74aaeb3 100644 --- a/pym/euscan/handlers/pypi.py +++ b/pym/euscan/handlers/pypi.py @@ -10,7 +10,7 @@ CONFIDENCE = 100.0 PRIORITY = 100 -def can_handle(cpv, url): +def can_handle(pkg, url): return url.startswith('mirror://pypi/') @@ -24,10 +24,10 @@ def guess_package(cp, url): return pkg -def scan(cpv, url): +def scan(pkg, url): 'http://wiki.python.org/moin/PyPiXmlRpc' - package = guess_package(cpv, url) + package = guess_package(pkg.cpv, url) output.einfo("Using PyPi XMLRPC: " + package) @@ -39,7 +39,7 @@ def scan(cpv, url): versions.reverse() - cp, ver, rev = portage.pkgsplit(cpv) + cp, ver, rev = portage.pkgsplit(pkg.cpv) ret = [] @@ -54,5 +54,5 @@ def scan(cpv, url): return ret -def brute_force(cpv, url): +def brute_force(pkg, url): return [] diff --git a/pym/euscan/handlers/rubygem.py b/pym/euscan/handlers/rubygem.py index c0f7ade..529e6d4 100644 --- a/pym/euscan/handlers/rubygem.py +++ b/pym/euscan/handlers/rubygem.py @@ -10,7 +10,7 @@ CONFIDENCE = 100.0 PRIORITY = 100 -def can_handle(cpv, url): +def can_handle(pkg, url): return url.startswith('mirror://rubygems/') @@ -29,13 +29,13 @@ def guess_gem(cpv, url): return pkg -def scan(cpv, url): +def scan(pkg, url): 'http://guides.rubygems.org/rubygems-org-api/#gemversion' - gem = guess_gem(cpv, url) + gem = guess_gem(pkg.cpv, url) if not gem: output.eerror("Can't guess gem name using %s and %s" % \ - (cpv, url)) + (pkg.cpv, url)) return [] url = 'http://rubygems.org/api/v1/versions/%s.json' % gem @@ -58,7 +58,7 @@ def scan(cpv, url): if not versions: return [] - cp, ver, rev = portage.pkgsplit(cpv) + cp, ver, rev = portage.pkgsplit(pkg.cpv) ret = [] @@ -73,5 +73,5 @@ def scan(cpv, url): return ret -def brute_force(cpv, url): +def brute_force(pkg, url): return [] diff --git a/pym/euscan/scan.py b/pym/euscan/scan.py index d63488b..114c81e 100644 --- a/pym/euscan/scan.py +++ b/pym/euscan/scan.py @@ -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 = [] if on_progress: @@ -73,7 +73,7 @@ def scan_upstream_urls(cpv, urls, on_progress): # Try normal scan if CONFIG["scan-dir"]: try: - versions.extend(handlers.scan(cpv, url)) + versions.extend(handlers.scan(pkg, url)) except Exception as e: output.ewarn("Handler failed: [%s] %s" % (e.__class__.__name__, e.message)) @@ -83,12 +83,12 @@ def scan_upstream_urls(cpv, urls, on_progress): # Brute Force if CONFIG["brute-force"] > 0: - versions.extend(handlers.brute_force(cpv, url)) + versions.extend(handlers.brute_force(pkg, url)) if versions and CONFIG['oneshot']: break - cp, ver, rev = portage.pkgsplit(cpv) + cp, ver, rev = portage.pkgsplit(pkg.cpv) result = filter_versions(cp, versions) @@ -216,7 +216,7 @@ def scan_upstream(query, on_progress=None): scan_time = (datetime.now() - start_time).total_seconds() 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: on_progress(increment=10) |