diff options
author | Joe Guo <joeg@catalyst.net.nz> | 2018-04-12 16:07:24 +1200 |
---|---|---|
committer | Douglas Bagnall <dbagnall@samba.org> | 2018-04-13 07:27:12 +0200 |
commit | 2892293182f282336f08ed17315ae744aa72bddc (patch) | |
tree | 229c3e6479beb4d0e8d263a52d5d164238afa5cc /python/samba/samba3 | |
parent | f3b52875388da6e064567621a53e9ccb508dc6d5 (diff) | |
download | samba-2892293182f282336f08ed17315ae744aa72bddc.tar.gz |
python: bulk port tdb iterkeys for py3
In py3, `dict.iterkeys()` is removed, we need to use `keys()` instead.
This is compatible with py2 since `dict.keys()` exists for py2.
tdb pretents to be a dict, however, not completely.
It provides `iterkeys()` for py2 only, and `keys()` for py3 only,
which means replace `iterkeys()` to `keys()` will break py2.
In python, iter a dict will implicitly iter on keys.
Use this feature to work around.
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'python/samba/samba3')
-rw-r--r-- | python/samba/samba3/__init__.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/python/samba/samba3/__init__.py b/python/samba/samba3/__init__.py index f7927836c98..b145e432c97 100644 --- a/python/samba/samba3/__init__.py +++ b/python/samba/samba3/__init__.py @@ -142,7 +142,7 @@ class IdmapDatabase(DbDatabase): def ids(self): """Retrieve a list of all ids in this database.""" - for k in self.db.iterkeys(): + for k in self.db: if k.startswith(IDMAP_USER_PREFIX): yield k.rstrip(b"\0").split(b" ") if k.startswith(IDMAP_GROUP_PREFIX): @@ -213,7 +213,7 @@ class SecretsDatabase(DbDatabase): return self.db.get("SECRETS/DOMGUID/%s" % host) def ldap_dns(self): - for k in self.db.iterkeys(): + for k in self.db: if k.startswith("SECRETS/LDAP_BIND_PW/"): yield k[len("SECRETS/LDAP_BIND_PW/"):].rstrip("\0") @@ -222,7 +222,7 @@ class SecretsDatabase(DbDatabase): :return: Iterator over the names of domains in this database. """ - for k in self.db.iterkeys(): + for k in self.db: if k.startswith("SECRETS/SID/"): yield k[len("SECRETS/SID/"):].rstrip("\0") @@ -248,7 +248,7 @@ class SecretsDatabase(DbDatabase): return self.db.get("SECRETS/$DOMTRUST.ACC/%s" % host) def trusted_domains(self): - for k in self.db.iterkeys(): + for k in self.db: if k.startswith("SECRETS/$DOMTRUST.ACC/"): yield k[len("SECRETS/$DOMTRUST.ACC/"):].rstrip("\0") |