diff options
author | 2010-08-12 10:13:08 +0300 | |
---|---|---|
committer | 2010-08-12 10:13:08 +0300 | |
commit | 25c149fd79edb4356200a917c58d79a56ae3e55e (patch) | |
tree | 7100c9845f34798ed51b6cb9ffcf505b5c3e1797 | |
parent | Fix bug in package rename (diff) | |
download | gsoc2010-grumpy-25c149fd79edb4356200a917c58d79a56ae3e55e.tar.gz gsoc2010-grumpy-25c149fd79edb4356200a917c58d79a56ae3e55e.tar.bz2 gsoc2010-grumpy-25c149fd79edb4356200a917c58d79a56ae3e55e.zip |
Implement module lookup for version check modules instead of predefined list
-rw-r--r-- | grumpy/vdb/__init__.py | 5 | ||||
-rw-r--r-- | grumpy/vdb/gnome.py | 2 | ||||
-rw-r--r-- | grumpy/vdb/pypi.py | 2 | ||||
-rw-r--r-- | utils/version_check.py | 21 |
4 files changed, 13 insertions, 17 deletions
diff --git a/grumpy/vdb/__init__.py b/grumpy/vdb/__init__.py index 1a871fa..e69de29 100644 --- a/grumpy/vdb/__init__.py +++ b/grumpy/vdb/__init__.py @@ -1,5 +0,0 @@ -from .pypi import PyPi -from .gnome import GNOME - -# We need some intelligent lookup mechanism ;) -modules = ['PyPi', 'GNOME'] diff --git a/grumpy/vdb/gnome.py b/grumpy/vdb/gnome.py index b7bd799..a4f86cc 100644 --- a/grumpy/vdb/gnome.py +++ b/grumpy/vdb/gnome.py @@ -1,7 +1,7 @@ from lxml.html import fromstring import string, urllib2 -class GNOME(object): +class gnome_checker(object): # TODO: Shall we use some kind of yaml or json based format instead? # Or move this data into DB? pkgs = { diff --git a/grumpy/vdb/pypi.py b/grumpy/vdb/pypi.py index eaee00f..b695e9b 100644 --- a/grumpy/vdb/pypi.py +++ b/grumpy/vdb/pypi.py @@ -1,7 +1,7 @@ from lxml.html import fromstring import urllib -class PyPi(object): +class pypi_checker(object): # TODO: Shall we use some kind of yaml or json based format instead? # Or move this data into DB? pkgs = { diff --git a/utils/version_check.py b/utils/version_check.py index eac7dad..23923f7 100644 --- a/utils/version_check.py +++ b/utils/version_check.py @@ -2,36 +2,37 @@ import os, sys from datetime import datetime from optparse import OptionParser -from werkzeug.utils import import_string +from werkzeug.utils import find_modules, import_string path = os.path.join(os.path.dirname(__file__), os.path.pardir) sys.path.insert(0, path) del path -from grumpy import app, vdb +from grumpy import app from grumpy.models import db, Package, PkgIssue, Setting from grumpy.utils import compare_version PLUGIN_NAME='ver_bumper::' +def print_list(mods): + return "Supported modules are:\n\t%s" % ('\n\t'.join(mods)) if __name__ == '__main__': + # Look up supported modules + modules = [i.rsplit('.', 1)[1] for i in find_modules('grumpy.vdb')] parser = OptionParser(usage="usage: %prog [options] CONFFILE module") (opts, args) = parser.parse_args() if len(args) != 2: parser.error("provide path to configuration file as first argument\n" \ "package module you want to load as second argument.\n\n" \ - "Supported modules are:\n\t%s" % \ - ('\n\t'.join(vdb.modules))) + "%s" % print_list(modules)) sys.exit(1) # Check whether module is supported mod = args[1] - if mod not in vdb.modules: - parser.error("Unknown module: %s\n" \ - "Supported modules are:\n\t%s" % \ - (mod, '\n\t'.join(vdb.modules))) + if mod not in modules: + parser.error("Unknown module: %s\n%s" % (mod, print_list(modules))) sys.exit(1) - # Import our module - m = import_string('grumpy.vdb:%s' % mod, True) + # Import our version checker module + m = import_string('grumpy.vdb.%s.%s_checker' % (mod, mod), True) if not m: print "Unknown error occurred: unable to import module %s" % mod raise RuntimeError |