Example #1
0
 def iteritems(self):
     for k, v in self.fdf.iteritems():
         try:
             op = Spec.key2spec(k)
         except ValueError:
             op = GetOperation(series_name=k)
         yield op, v
Example #2
0
 def operations(self):
     res = []
     for k in self.fdf.keys():
         try:
             res.append(Spec.key2spec(k))
         except ValueError:
             res.append(GetOperation(k))
     return res
Example #3
0
    def iterkeys(self, raw=False):
        for subdir, _, _ in os.walk(self.path):
            key_fname = os.path.join(subdir, 'key')
            if not os.path.exists(key_fname): continue

            with open(key_fname) as f:
                key = f.read()

            if raw:
                yield subdir, Spec.key2dict(key)
            else:
                try:
                    spec = Spec.key2spec(key)
                except Exception, e:  # there might be a key that is not a valid json
                    if len(e.args) > 0 and isinstance(
                            e.args[0], basestring) and e.args[0].startswith(
                                'Unknown spec type'):
                        raise e
                    traceback.print_exc()
                    warnings.warn('Unable to load spec key: {}'.format(key))
                    continue

                yield spec
Example #4
0
 def test_key(self):
     for spec in self.instances:
         assert spec.to_dict() == Spec.key2spec(spec.key).to_dict()