def do_shopping(): b = das.make_default("shopping.basket") b.items.append(das.make("shopping.item", name="carottes", value=110)) b.items.append(das.make("shopping.item", name="meat", value=320)) das.pprint(b) for c in ["yen", "euro", "dollar"]: print("%f %s(s)" % (b.value_in(c), c))
def test2(self): r0 = das.make("testalias.MyStruct", defaultMargin="both") r1 = das.read(self.OutputFile) self.assertEqual(r0, r1) self.assertEqual(r0.margin, r0.defaultMargin) self.assertEqual(r1.margin, r1.defaultMargin) with self.assertRaises(das.ValidationError): r0.defaultMargin = "any" r0.defaultMargin = "none" self.assertEqual(r0.margin, "none")
def process(self): st = self.input("schemaType").receive() if st.isEOP(): return False if not self.input("fields").isConnected(): fd = {} else: _fd = self.input("fields").receive() if _fd.isEOP(): return False fd = _fd.value() _fd.drop() rv = das.make(st.value(), **fd) st.drop() self.output("outDasObj").send(rv) return True
def testMake(self): with self.assertRaises(das.ValidationError): das.make("validation.SomeType", value_pairs={"weight": 1.0})
def testDict(self): v = das.make("mix.dict", key1="value1", key2="value2") v.niceEcho()
def testSet(self): v = das.make("mix.set", "basket", "fruit") v.niceEcho()
def testSequence(self): v = das.make("mix.sequence", "hello", "world") v.niceEcho()
def testTuple(self): v = das.make("mix.tuple", "C", "D", "E") v.niceEcho()