imip-agent

Change of imiptools/profile.py

791:7cbf127b2711
imiptools/profile.py
     1.1 --- a/imiptools/profile.py	Tue Sep 29 14:04:57 2015 +0200
     1.2 +++ b/imiptools/profile.py	Tue Sep 29 19:02:01 2015 +0200
     1.3 @@ -44,6 +44,30 @@
     1.4          except KeyError:
     1.5              return default
     1.6  
     1.7 +    def get_all(self, names):
     1.8 +
     1.9 +        """
    1.10 +        Return a dictionary containing values for entries having the given
    1.11 +        'names'. Absent entries for names are omitted without error.
    1.12 +        """
    1.13 +
    1.14 +        d = {}
    1.15 +        for name in names:
    1.16 +            value = self.get(name)
    1.17 +            if value is not None:
    1.18 +                d[name] = value
    1.19 +        return d
    1.20 +
    1.21 +    def has_key(self, name):
    1.22 +
    1.23 +        "Return whether an entry exists for 'name'."
    1.24 +
    1.25 +        try:
    1.26 +            self[name]
    1.27 +            return True
    1.28 +        except KeyError:
    1.29 +            return False
    1.30 +
    1.31      def __getitem__(self, name):
    1.32  
    1.33          "Return the value for 'name', raising a KeyError if absent."