diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-23 23:33:36 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-01-23 23:38:57 +0100 |
commit | decdf5954d5e1ae84318d6767317965f544a897f (patch) | |
tree | b2d0d55116726fae8a086511100c341b769e199c /source4/scripting/python | |
parent | 00cb710fbc872cffa2d4d5c54c5ea65ba993da0c (diff) | |
download | samba-decdf5954d5e1ae84318d6767317965f544a897f.tar.gz samba-decdf5954d5e1ae84318d6767317965f544a897f.tar.bz2 samba-decdf5954d5e1ae84318d6767317965f544a897f.zip |
python: Add convenience function for getting command line loadparm context
and default to using system smb.conf.
(This used to be commit b3afde0f00ab5093b577b139a062c233d4db2524)
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/getopt.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py index a087974a69..dfcf2c457e 100644 --- a/source4/scripting/python/samba/getopt.py +++ b/source4/scripting/python/samba/getopt.py @@ -23,9 +23,25 @@ from credentials import Credentials class SambaOptions(optparse.OptionGroup): def __init__(self, parser): optparse.OptionGroup.__init__(self, parser, "Samba Common Options") - self.add_option("-s", "--configfile", type="string", metavar="FILE", - help="Configuration file") + self.add_option("-s", "--configfile", action="callback", + type=str, metavar="FILE", help="Configuration file", + callback=self._load_configfile) + self._configfile = None + def get_loadparm_path(self): + return self._configfile + + def _load_configfile(self, option, opt_str, arg, parser): + self._configfile = arg + + def get_loadparm(self): + import param + lp = param.LoadParm() + if self._configfile is None: + lp.load_default() + else: + lp.load(self._configfile) + return lp class VersionOptions(optparse.OptionGroup): def __init__(self, parser): |