summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2010-02-18 05:12:43 +0100
committerSebastian Pipping <sebastian@pipping.org>2010-02-18 05:24:02 +0100
commit8990dad4eb192d342545589c66555faae88e8301 (patch)
tree54b84012f2e80537434f38328b07a987b68c003a
parentf32f4851f604ff3e96d47f58a2044d3ca71a21b2 (diff)
downloadlayman-8990dad4eb192d342545589c66555faae88e8301.tar.gz
layman-8990dad4eb192d342545589c66555faae88e8301.tar.bz2
layman-8990dad4eb192d342545589c66555faae88e8301.zip
Resolve Actions class, allow custom sys.argv for Config class
-rwxr-xr-xbin/layman11
-rw-r--r--layman/action.py10
-rw-r--r--layman/config.py6
3 files changed, 13 insertions, 14 deletions
diff --git a/bin/layman b/bin/layman
index 3080c05..b85f4fa 100755
--- a/bin/layman
+++ b/bin/layman
@@ -6,10 +6,12 @@
#
# Copyright:
# (c) 2005 Gunnar Wrobel
+# (c) 2009 Sebastian Pipping
# Distributed under the terms of the GNU General Public License v2
#
# Author(s):
# Gunnar Wrobel <wrobel@gentoo.org>
+# Sebastian Pipping <sebastian@pipping.org>
#
__version__ = "$Id$"
@@ -21,7 +23,7 @@ __version__ = "$Id$"
#-------------------------------------------------------------------------------
from layman.config import Config
-from layman.action import Actions
+from layman.action import main
#===============================================================================
#
@@ -29,9 +31,4 @@ from layman.action import Actions
#
#-------------------------------------------------------------------------------
-def main():
-
- Actions(Config())
-
-if __name__ == "__main__":
- main()
+main(Config())
diff --git a/layman/action.py b/layman/action.py
index 0fe023c..b8a9c27 100644
--- a/layman/action.py
+++ b/layman/action.py
@@ -499,11 +499,11 @@ class ListLocal:
#===============================================================================
#
-# Class Actions
+# MAIN
#
#-------------------------------------------------------------------------------
-class Actions:
+def main(config):
'''Dispatches to the actions the user selected. '''
# Given in order of precedence
@@ -516,7 +516,7 @@ class Actions:
('list', List),
('list_local', ListLocal),]
- def __init__(self, config):
+ if True: # A hack to save diff with indentation changes only
# Make fetching the overlay list a default action
if not 'nofetch' in config.keys():
@@ -539,7 +539,7 @@ class Actions:
OUT.die('Failed setting to umask "' + umask + '"!\nError was: '
+ str(error))
- for i in self.actions:
+ for i in actions:
OUT.debug('Checking for action', 7)
@@ -553,7 +553,7 @@ class Actions:
sys.exit(0)
else:
sys.exit(1)
-
+
#===============================================================================
#
# Testing
diff --git a/layman/config.py b/layman/config.py
index bbafba3..0a48c5d 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -47,7 +47,7 @@ layman (-l|-L|-S)"""
class Config(object):
'''Handles the configuration.'''
- def __init__(self):
+ def __init__(self, args=None):
'''
Creates and describes all possible polymeraZe options and creates
a debugging object.
@@ -62,6 +62,8 @@ class Config(object):
>>> sorted(a.keys())
['bzr_command', 'cache', 'config', 'cvs_command', 'darcs_command', 'git_command', 'local_list', 'make_conf', 'mercurial_command', 'nocheck', 'overlays', 'proxy', 'quietness', 'rsync_command', 'storage', 'svn_command', 'tar_command', 'umask', 'width']
'''
+ if args == None:
+ args = sys.argv
self.defaults = {'config' : '/etc/layman/layman.cfg',
'storage' : '/var/lib/layman',
@@ -236,7 +238,7 @@ class Config(object):
# Parse the command line first since we need to get the config
# file option.
- self.options = self.parser.parse_args()[0]
+ self.options = self.parser.parse_args(args)[0]
# handle debugging
OUT.cli_handle(self.options)