From 71e6a449afbad015a25a39eedc808aca0c92db00 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sat, 9 Jan 2010 15:11:00 -0500 Subject: [PATCH] Add getApplication() function to wizard.app. Signed-off-by: Edward Z. Yang --- doc/module/wizard.app.rst | 1 + wizard/app/__init__.py | 3 +++ wizard/command/install.py | 2 +- wizard/command/prepare_pristine.py | 2 +- wizard/command/research.py | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/module/wizard.app.rst b/doc/module/wizard.app.rst index 7747d90..8aebea3 100644 --- a/doc/module/wizard.app.rst +++ b/doc/module/wizard.app.rst @@ -12,6 +12,7 @@ Classes Functions --------- +.. autofunction:: getApplication .. autofunction:: applications .. autofunction:: expand_re .. autofunction:: make_extractors diff --git a/wizard/app/__init__.py b/wizard/app/__init__.py index 1d01966..5f318dc 100644 --- a/wizard/app/__init__.py +++ b/wizard/app/__init__.py @@ -51,6 +51,9 @@ def applications(): _applications = dict([(n,Application.make(n)) for n in _application_list ]) return _applications +def getApplication(appname): + """Retrieves application instance given a name""" + return applications()[appname] class Application(object): """ diff --git a/wizard/command/install.py b/wizard/command/install.py index 6ac1383..fa7299a 100644 --- a/wizard/command/install.py +++ b/wizard/command/install.py @@ -19,7 +19,7 @@ def main(argv, baton): raise DirectoryExistsError appname, _, version = appstr.partition('-') - application = app.applications()[appname] + application = app.getApplication(appname) # get configuration schema = application.install_schema diff --git a/wizard/command/prepare_pristine.py b/wizard/command/prepare_pristine.py index 80517d1..6890676 100644 --- a/wizard/command/prepare_pristine.py +++ b/wizard/command/prepare_pristine.py @@ -9,7 +9,7 @@ def main(argv, baton): check_directory(options) if not os.path.exists(args[0]): appname, _, version = args[0].partition("-") - application = app.applications()[appname] + application = app.getApplication(appname) url = application.download(version) base = os.path.basename(url) with open(base, "w") as outfile: diff --git a/wizard/command/research.py b/wizard/command/research.py index d36a850..b81ec46 100644 --- a/wizard/command/research.py +++ b/wizard/command/research.py @@ -8,7 +8,7 @@ from wizard import app, command, deploy, shell, util def main(argv, baton): options, show = parse_args(argv, baton) appname = show[0] - application = app.applications()[appname] + application = app.getApplication(appname) deploys = deploy.parse_install_lines(show, options.versions_path) stats = {} iffy = 0 -- 2.45.0