Example #1
0
    def _synch_description_str2enum(self, _synch_description_str):
        """Translates synchronization description data structure so it uses
        SynchParam and SynchDomain enums as keys instead of strings.

        .. todo:: At some point remove the backwards compatibility
          for memorized values created with Python 2. In Python 2 IntEnum was
          serialized to "<class>.<attr>" e.g. "SynchDomain.Time" and we were
          using a class method `fromStr` to interpret the enumeration objects.
        """
        synch_description = []
        for group_str in _synch_description_str:
            group = {}
            for param_str, conf_str in group_str.items():
                try:
                    param = SynchParam(int(param_str))
                except ValueError:
                    param = SynchParam.fromStr(param_str)
                if isinstance(conf_str, dict):
                    conf = {}
                    for domain_str, value in conf_str.items():
                        try:
                            domain = SynchDomain(int(domain_str))
                        except ValueError:
                            domain = SynchDomain.fromStr(domain_str)
                        conf[domain] = value
                else:
                    conf = conf_str
                group[param] = conf
            synch_description.append(group)
        return synch_description
Example #2
0
 def _synchronization_str2enum(self, synchronization):
     '''Translates synchronization data structure so it uses SynchDomain
     enums as keys instead of strings.
     '''
     for group in synchronization:
         for param, conf in group.iteritems():
             group.pop(param)
             param = SynchParam.fromStr(param)
             group[param] = conf
             # skip repeats cause its value is just a long number
             if param == SynchParam.Repeats:
                 continue
             for domain, value in conf.iteritems():
                 conf.pop(domain)
                 domain = SynchDomain.fromStr(domain)
                 conf[domain] = value
     return synchronization
Example #3
0
 def read_SoftwareSynchronizerInitialDomain(self, attr):
     domain = self.measurement_group.sw_synch_initial_domain
     d = SynchDomain(domain).name
     attr.set_value(d)