diff options
| author | Jelmer Vernooij <jelmer@samba.org> | 2007-12-23 19:19:41 -0600 |
|---|---|---|
| committer | Stefan Metzmacher <metze@samba.org> | 2007-12-24 01:51:03 -0600 |
| commit | aa0a06f13c44e0eca0b3f2f0c34f0f7995b87159 (patch) | |
| tree | 92c180a6928f94f64934e2fab842768c134fed63 /source4/scripting/python/samba/__init__.py | |
| parent | 784c22899f211fa42728e784c2f2e6e5701ddcac (diff) | |
| download | samba-aa0a06f13c44e0eca0b3f2f0c34f0f7995b87159.tar.gz samba-aa0a06f13c44e0eca0b3f2f0c34f0f7995b87159.tar.bz2 samba-aa0a06f13c44e0eca0b3f2f0c34f0f7995b87159.zip | |
r26570: - Trim size of the swig-generated Python bindings by removing a bunch of {}'s.
- Start working on Python equivalents for various EJS tests.
- Fix regression in argument order for reg_diff_apply() in EJS bindings.
(This used to be commit c550c03372cb260b78f6a6c132e70571bc4cb852)
Diffstat (limited to 'source4/scripting/python/samba/__init__.py')
| -rw-r--r-- | source4/scripting/python/samba/__init__.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index c7353613530..5b345341330 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -91,7 +91,14 @@ class Ldb(ldb.Ldb): def searchone(self, basedn, attribute, expression=None, scope=ldb.SCOPE_BASE): - """Search for one attribute as a string.""" + """Search for one attribute as a string. + + :param basedn: BaseDN for the search. + :param attribute: Name of the attribute + :param expression: Optional search expression. + :param scope: Search scope (defaults to base). + :return: Value of attribute as a string or None if it wasn't found. + """ res = self.search(basedn, scope, expression, [attribute]) if len(res) != 1 or res[0][attribute] is None: return None @@ -100,7 +107,7 @@ class Ldb(ldb.Ldb): return values.pop() def erase(self): - """Erase an ldb, removing all records.""" + """Erase this ldb, removing all records.""" # delete the specials for attr in ["@INDEXLIST", "@ATTRIBUTES", "@SUBCLASSES", "@MODULES", "@OPTIONS", "@PARTITION", "@KLUDGEACL"]: @@ -149,13 +156,18 @@ class Ldb(ldb.Ldb): :param ldif_path: Path to LDIF file. """ - self.load_ldif_add(open(ldif_path, 'r').read()) + self.add_ldif(open(ldif_path, 'r').read()) - def load_ldif_add(self, ldif): + def add_ldif(self, ldif): for changetype, msg in self.parse_ldif(ldif): assert changetype == ldb.CHANGETYPE_NONE self.add(msg) + def modify_ldif(self, ldif): + for (changetype, msg) in ldb.parse_ldif(data): + assert changetype == CHANGETYPE_MODIFY + ldb.modify(msg) + def substitute_var(text, values): """substitute strings of the form ${NAME} in str, replacing |
