diff options
author | Björn Jacke <bj@sernet.de> | 2019-08-25 23:05:31 +0200 |
---|---|---|
committer | Bjoern Jacke <bjacke@samba.org> | 2019-09-24 12:22:44 +0000 |
commit | ce56d336f234febfd4cb3da11dd584842c24ce1d (patch) | |
tree | 3852aa3a70f9ad164606d66e996dcaf115dae240 /python | |
parent | 1825a7f4e2a39d03f01da37b68ba4f65dbafd04a (diff) | |
download | samba-ce56d336f234febfd4cb3da11dd584842c24ce1d.tar.gz |
gpo.py: avoid inefficient string concatenations
Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/netcmd/gpo.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 5a0258196c3..047f91951e8 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -110,9 +110,7 @@ def parse_gplink(gplink): def encode_gplink(gplist): '''Encode an array of dn and options into gPLink string''' - ret = '' - for g in gplist: - ret += "[LDAP://%s;%d]" % (g['dn'], g['options']) + ret = "".join("[LDAP://%s;%d]" % (g['dn'], g['options']) for g in gplist) return ret @@ -1079,9 +1077,8 @@ class cmd_backup(GPOCommand): entities = cmd_backup.generalize_xml_entities(self.outf, gpodir, gpodir) import operator - ents = '' - for ent in sorted(entities.items(), key=operator.itemgetter(1)): - ents += '<!ENTITY {} "{}">\n'.format(ent[1].strip('&;'), ent[0]) + ents = "".join('<!ENTITY {} "{}\n">'.format(ent[1].strip('&;'), ent[0]) \ + for ent in sorted(entities.items(), key=operator.itemgetter(1))) if ent_file: with open(ent_file, 'w') as f: |