summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/scripting/python/samba/getopt.py15
-rw-r--r--source4/scripting/python/samba/samba3.py3
2 files changed, 18 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py
index 7ec684a9d6..9ecb66e21c 100644
--- a/source4/scripting/python/samba/getopt.py
+++ b/source4/scripting/python/samba/getopt.py
@@ -17,10 +17,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+"""Support for parsing Samba-related command-line options."""
+
import optparse
from credentials import Credentials, AUTO_USE_KERBEROS, DONT_USE_KERBEROS, MUST_USE_KERBEROS
+__docformat__ = "restructuredText"
+
class SambaOptions(optparse.OptionGroup):
+ """General Samba-related command line options."""
def __init__(self, parser):
optparse.OptionGroup.__init__(self, parser, "Samba Common Options")
self.add_option("-s", "--configfile", action="callback",
@@ -29,12 +34,14 @@ class SambaOptions(optparse.OptionGroup):
self._configfile = None
def get_loadparm_path(self):
+ """Return the path to the smb.conf file specified on the command line. """
return self._configfile
def _load_configfile(self, option, opt_str, arg, parser):
self._configfile = arg
def get_loadparm(self):
+ """Return a loadparm object with data specified on the command line. """
import os, param
lp = param.LoadParm()
if self._configfile is not None:
@@ -45,12 +52,15 @@ class SambaOptions(optparse.OptionGroup):
lp.load_default()
return lp
+
class VersionOptions(optparse.OptionGroup):
+ """Command line option for printing Samba version."""
def __init__(self, parser):
optparse.OptionGroup.__init__(self, parser, "Version Options")
class CredentialsOptions(optparse.OptionGroup):
+ """Command line options for specifying credentials."""
def __init__(self, parser):
self.no_pass = False
optparse.OptionGroup.__init__(self, parser, "Credentials Options")
@@ -91,6 +101,11 @@ class CredentialsOptions(optparse.OptionGroup):
self.creds.set_bind_dn(arg)
def get_credentials(self, lp):
+ """Obtain the credentials set on the command-line.
+
+ :param lp: Loadparm object to use.
+ :return: Credentials object
+ """
self.creds.guess(lp)
if not self.no_pass:
self.creds.set_cmdline_callbacks()
diff --git a/source4/scripting/python/samba/samba3.py b/source4/scripting/python/samba/samba3.py
index 9e802fa093..c1340b7760 100644
--- a/source4/scripting/python/samba/samba3.py
+++ b/source4/scripting/python/samba/samba3.py
@@ -309,6 +309,7 @@ class ShareInfoDatabase(TdbDatabase):
class Shares:
+ """Container for share objects."""
def __init__(self, lp, shareinfo):
self.lp = lp
self.shareinfo = shareinfo
@@ -494,6 +495,7 @@ class TdbSam(TdbDatabase):
assert self.version in (0, 1, 2)
def usernames(self):
+ """Iterate over the usernames in this Tdb database."""
for k in self.tdb.keys():
if k.startswith(TDBSAM_USER_PREFIX):
yield k[len(TDBSAM_USER_PREFIX):].rstrip("\0")
@@ -635,6 +637,7 @@ class WinsDatabase:
return iter(self.entries)
def items(self):
+ """Return the entries in this WINS database."""
return self.entries.items()
def close(self): # for consistency