class ProcessGroupDict(DataDict): item_cls = ProcessGroup key = "id" def __init__(self): self.id_gen = IncrID() def q_add (self, specs, callback=None, cargs={}): for spec in specs: if spec.get("id", "*") != "*": raise DataCreationError("cannot specify an id") spec['id'] = self.id_gen.next() return DataDict.q_add(self, specs)
class JobDict (DataDict): item_cls = Job key = "id" def __init__(self): self.id_gen = IncrID() def q_add (self, specs, callback=None, cargs={}): for spec in specs: if "id" not in spec or spec['id'] == "*": spec['id'] = self.id_gen.next() return DataDict.q_add(self, specs)
class ProcessGroupDict(DataDict): item_cls = ProcessGroup key = "id" def __init__(self): self.id_gen = IncrID() def q_add(self, specs, callback=None, cargs={}): for spec in specs: if spec.get("id", "*") != "*": raise DataCreationError("cannot specify an id") spec['id'] = self.id_gen.next() return DataDict.q_add(self, specs)
class ProcessGroupDict(DataDict): """A container for holding process groups, keyed by id""" item_cls = ProcessGroup key = "id" def __init__(self): DataDict.__init__(self) self.id_gen = IncrID() def q_add(self, specs, callback=None, cargs={}): """Add a process group to the container""" for spec in specs: if spec.get("id", "*") != "*": raise DataCreationError("cannot specify an id") spec["id"] = self.id_gen.next() return DataDict.q_add(self, specs, callback, cargs)
def test_next(self, max=100): generator = IncrID() for count in itertools.count(1): assert generator.next() == count if count >= max: break
def test_next (self, max=100): generator = IncrID() for count in itertools.count(1): assert generator.next() == count if count >= max: break