1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

gpo.py: avoid inefficient string concatenations

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Björn Jacke 2019-08-25 23:05:31 +02:00 committed by Bjoern Jacke
parent 1825a7f4e2
commit ce56d336f2

View File

@ -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: