KCC: use python 2.6 compatible dictonary comprehensions
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 10 Jun 2015 23:11:06 +0000 (11:11 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 12 Jun 2015 07:46:13 +0000 (09:46 +0200)
The `{k: v for k, v in whatever}` syntax is "new" in Python 2.7.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Jun 12 09:46:13 CEST 2015 on sn-devel-104

python/samba/kcc/__init__.py
python/samba/kcc/kcc_utils.py

index 8f8627ece1980303d6d32d118a6f3b45c4e861cb..46a25cef56457311bc8a985a23f31fc6cef76993 100644 (file)
@@ -1285,7 +1285,7 @@ class KCC(object):
         """
         rbhs_all = self.get_all_bridgeheads(rsite, part, transport,
                                             partial_ok, False)
-        rbh_table = {x.dsa_dnstr: x for x in rbhs_all}
+        rbh_table = dict((x.dsa_dnstr, x) for x in rbhs_all)
 
         debug.DEBUG_GREY("rbhs_all: %s %s" % (len(rbhs_all),
                                               [x.dsa_dnstr for x in rbhs_all]))
@@ -2521,18 +2521,18 @@ class KCC(object):
 
             if forget_local_links:
                 for dsa in self.my_site.dsa_table.values():
-                    dsa.connect_table = {k: v for k, v in
-                                         dsa.connect_table.items()
-                                         if v.is_rodc_topology()}
+                    dsa.connect_table = dict((k, v) for k, v in
+                                             dsa.connect_table.items()
+                                             if v.is_rodc_topology())
                 self.plot_all_connections('dsa_forgotten_local')
 
             if forget_intersite_links:
                 for site in self.site_table.values():
                     for dsa in site.dsa_table.values():
-                        dsa.connect_table = {k: v for k, v in
-                                             dsa.connect_table.items()
-                                             if site is self.my_site and
-                                             v.is_rodc_topology()}
+                        dsa.connect_table = dict((k, v) for k, v in
+                                                 dsa.connect_table.items()
+                                                 if site is self.my_site and
+                                                 v.is_rodc_topology())
 
                 self.plot_all_connections('dsa_forgotten_all')
 
index ef328bd47296a5e2e36bc7123980aed9822f9d0d..3b5b0cce55d70dc1380446753bcb3c97b600e263 100644 (file)
@@ -41,7 +41,7 @@ class NCType(object):
     (unknown, schema, domain, config, application) = range(0, 5)
 
 # map the NCType enum to strings for debugging
-nctype_lut = {v: k for k, v in NCType.__dict__.items() if k[:2] != '__'}
+nctype_lut = dict((v, k) for k, v in NCType.__dict__.items() if k[:2] != '__')
 
 
 class NamingContext(object):