/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2014-07-25 23:16:04 UTC
  • mto: This revision was merged to the branch mainline in revision 724.
  • Revision ID: teddy@recompile.se-20140725231604-f5c4f82rn2o5ll1k
Use the .items() method instead of .iteritems().

This is strictly not a Python 2.7 change, but Python 2.7 backported
the new .viewitems() from Python 3, and instead of changing .items()
to .viewitems() and later having to change them all into .items()
again in Python 3, I opted to just change all .iteritems() to .items()
so the code will work both now and with Python 3.  The slowdown with
Python 2 is not significant, and with Python 3 it will again be fast.

* mandos (Client.__init__): Use .items() instead of .iteritems().
  (DBusObjectWithProperties.Introspect): - '' -
  (alternate_dbus_interfaces/wrapper): - '' -
  (main): - '' -
* mandos-ctl (main): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
536
536
            server_settings = {}
537
537
        self.server_settings = server_settings
538
538
        # adding all client settings
539
 
        for setting, value in settings.iteritems():
 
539
        for setting, value in settings.items():
540
540
            setattr(self, setting, value)
541
541
        
542
542
        if self.enabled:
1009
1009
                                              (prop,
1010
1010
                                               "_dbus_annotations",
1011
1011
                                               {}))
1012
 
                        for name, value in annots.iteritems():
 
1012
                        for name, value in annots.items():
1013
1013
                            ann_tag = document.createElement(
1014
1014
                                "annotation")
1015
1015
                            ann_tag.setAttribute("name", name)
1018
1018
                # Add interface annotation tags
1019
1019
                for annotation, value in dict(
1020
1020
                    itertools.chain.from_iterable(
1021
 
                        annotations().iteritems()
 
1021
                        annotations().items()
1022
1022
                        for name, annotations in
1023
1023
                        self._get_all_dbus_things("interface")
1024
1024
                        if name == if_tag.getAttribute("name")
1025
 
                        )).iteritems():
 
1025
                        )).items():
1026
1026
                    ann_tag = document.createElement("annotation")
1027
1027
                    ann_tag.setAttribute("name", annotation)
1028
1028
                    ann_tag.setAttribute("value", value)
1084
1084
    """
1085
1085
    def wrapper(cls):
1086
1086
        for orig_interface_name, alt_interface_name in (
1087
 
            alt_interface_names.iteritems()):
 
1087
            alt_interface_names.items()):
1088
1088
            attr = {}
1089
1089
            interface_names = set()
1090
1090
            # Go though all attributes of the class
2594
2594
                           "EOFError:", exc_info=e)
2595
2595
    
2596
2596
    with PGPEngine() as pgp:
2597
 
        for client_name, client in clients_data.iteritems():
 
2597
        for client_name, client in clients_data.items():
2598
2598
            # Skip removed clients
2599
2599
            if client_name not in client_settings:
2600
2600
                continue
2664
2664
        clients_data[client_name] = client_settings[client_name]
2665
2665
    
2666
2666
    # Create all client objects
2667
 
    for client_name, client in clients_data.iteritems():
 
2667
    for client_name, client in clients_data.items():
2668
2668
        tcp_server.clients[client_name] = client_class(
2669
2669
            name = client_name, settings = client,
2670
2670
            server_settings = server_settings)