Esempio n. 1
0
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))
Esempio n. 2
0
 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")
Esempio n. 3
0
    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
Esempio n. 4
0
 def testMake(self):
     with self.assertRaises(das.ValidationError):
         das.make("validation.SomeType", value_pairs={"weight": 1.0})
Esempio n. 5
0
 def testDict(self):
     v = das.make("mix.dict", key1="value1", key2="value2")
     v.niceEcho()
Esempio n. 6
0
 def testSet(self):
     v = das.make("mix.set", "basket", "fruit")
     v.niceEcho()
Esempio n. 7
0
 def testSequence(self):
     v = das.make("mix.sequence", "hello", "world")
     v.niceEcho()
Esempio n. 8
0
 def testTuple(self):
     v = das.make("mix.tuple", "C", "D", "E")
     v.niceEcho()