def process(self): dp = self.input("inDasObj").receive() if dp.isEOP(): return False dv = das.copy(dp.value()) dp.drop() kp = self.input("key").receive() if kp.isEOP(): return False kv = kp.value() kp.drop() vp = self.input("value").receive() if vp.isEOP(): return False vv = vp.value() vp.drop() das.cli.set(dv, kv, str(vv)) self.output("outDasObj").send(dv) return True
def process(self): dp = self.input("inDasObj").receive() if dp.isEOP(): return False dv = das.copy(dp.value()) dp.drop() ep = self.input("expression").receive() if ep.isEOP(): return False ev = ep.value() ep.drop() res = das.cli.eval(dv, ev) self.output("output").send(res) self.output("outDasObj").send(dv) return True
def value(self): return das.copy(self.__v)
def testNonEqual1(self): v0 = self._makeOne() v1 = das.copy(v0) v1.option = False self.assertNotEqual(v0, v1)
def testEqual1(self): v0 = self._makeOne() v0.option = True v1 = das.copy(v0) self.assertEqual(v0, v1)
def test_mixin1(): print("=== Mixin tests using timeline.ClipSource schema type ===") class Range(das.Mixin): @classmethod def get_schema_type(klass): return "timeline.Range" def __init__(self, *args, **kwargs): super(Range, self).__init__(*args, **kwargs) def expand(self, start, end): cs, ce = self[0], self[1] if start < cs: cs = start if end > ce: ce = end self[0], self[1] = cs, ce class ClipSource(das.Mixin): @classmethod def get_schema_type(klass): return "timeline.ClipSource" def __init__(self, *args, **kwargs): super(ClipSource, self).__init__(*args, **kwargs) def set_media(self, path): _, ext = map(lambda x: x.lower(), os.path.splitext(path)) if ext == ".fbx": print("Get range from FBX file") elif ext == ".abc": print("Get range from Alembic file") elif ext == ".mov": print("Get range from Movie file") self.media = os.path.abspath(path).replace("\\", "/") def set_clip_offsets(self, start, end): data_start, data_end = self.dataRange clip_start = min(data_end, data_start + max(0, start)) clip_end = max(data_start, data_end + min(end, 0)) if clip_start == data_start and clip_end == data_end: self.clipRange = None else: self.clipRange = (clip_start, clip_end) das.register_mixins(Range, ClipSource) print("-- make def (1)") dv = das.make_default("timeline.ClipSource") print("-- write (1)") das.write(dv, "./out.tl") print("-- make def (2)") cs = das.make_default("timeline.ClipSource") print("-- read (1)") cs = das.read("./out.tl") das.pprint(cs) cs.dataRange = (100, 146) cs.dataRange.expand(102, 150) cs.set_media("./source.mov") cs.set_clip_offsets(1, -1) das.pprint(cs) print("-- write (2)") das.write(cs, "./out.tl") c = das.copy(cs) das.pprint(c) for k, v in c.iteritems(): print("%s = %s" % (k, v)) os.remove("./out.tl")
data = das.make_default("timeline.ClipSource") try: data.pprint() except Exception, e: print(str(e)) das.mixin.bind([Fn, Fn2], data) das.mixin.bind(Fn2, data) das.mixin.bind(Fn, data) try: das.mixin.bind(Fn3, data) except Exception, e: print(str(e)) data.pprint() c = data._copy() c = das.copy(data) das.mixin.bind(Fn2, c, reset=True) c.echo() try: c.pprint() except Exception, e: print(str(e)) def name_conflicts(): print("=== Name conflict resolution ===") d = das.make_default("conflicts.DictMethod") das.pprint(d) print("keys = %s" % d.keys) print("_keys() -> %s" % d._keys()) print("values = %s" % d.values)