diff options
| author | Jelmer Vernooij <jelmer@samba.org> | 2010-06-10 23:12:53 +0200 |
|---|---|---|
| committer | Jelmer Vernooij <jelmer@samba.org> | 2010-06-11 01:47:55 +0200 |
| commit | c446fbc3bfa345c8bc748a162dedb24857272aab (patch) | |
| tree | 4abfb08ff2c994045de37896f2d2666adedf4ef3 /source4/scripting/python/samba/__init__.py | |
| parent | a53ca944163f5366493b4c36ed94fd9f92e86238 (diff) | |
| download | samba-c446fbc3bfa345c8bc748a162dedb24857272aab.tar.gz samba-c446fbc3bfa345c8bc748a162dedb24857272aab.tar.bz2 samba-c446fbc3bfa345c8bc748a162dedb24857272aab.zip | |
s4-python: Fix formatting.
Diffstat (limited to 'source4/scripting/python/samba/__init__.py')
| -rw-r--r-- | source4/scripting/python/samba/__init__.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py index dcb80a7e5d1..d870879a1ea 100644 --- a/source4/scripting/python/samba/__init__.py +++ b/source4/scripting/python/samba/__init__.py @@ -154,7 +154,11 @@ class Ldb(_Ldb): raise def erase_except_schema_controlled(self): - """Erase this ldb, removing all records, except those that are controlled by Samba4's schema.""" + """Erase this ldb. + + :note: Removes all records, except those that are controlled by + Samba4's schema. + """ basedn = "" @@ -173,8 +177,7 @@ class Ldb(_Ldb): raise res = self.search(basedn, ldb.SCOPE_SUBTREE, - "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", - [], controls=["show_deleted:0"]) + "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", [], controls=["show_deleted:0"]) assert len(res) == 0 # delete the specials @@ -297,20 +300,20 @@ class Ldb(_Ldb): dsdb.dsdb_set_ntds_invocation_id(self, invocation_id) def get_invocation_id(self): - "Get the invocation_id id" + """Get the invocation_id id""" return dsdb.samdb_ntds_invocation_id(self) def get_ntds_GUID(self): - "Get the NTDS objectGUID" + """Get the NTDS objectGUID""" return dsdb.samdb_ntds_objectGUID(self) def server_site_name(self): - "Get the server site name" + """Get the server site name""" return dsdb.samdb_server_site_name(self) def substitute_var(text, values): - """substitute strings of the form ${NAME} in str, replacing + """Substitute strings of the form ${NAME} in str, replacing with substitutions from subobj. :param text: Text in which to subsitute. @@ -360,13 +363,15 @@ def setup_file(template, fname, subst_vars=None): :param fname: Path of the file to create. :param subst_vars: Substitution variables. """ - f = fname - - if os.path.exists(f): - os.unlink(f) + if os.path.exists(fname): + os.unlink(fname) data = read_and_sub_file(template, subst_vars) - open(f, 'w').write(data) + f = open(fname, 'w') + try: + f.write(data) + finally: + f.close() def valid_netbios_name(name): |
