Esempio n. 1
0
 def to_wl(self, *args, **opts):
     return wl.Failure(
         self.failure_tag(),
         wl.Association(
             *(wl.RuleDelayed(key, value) for key, value in self.failure_meta().items())
         ),
     )
    def test_export(self):

        for value in (
                1,
                2,
                "aaaa",
                2.0,
            {
                1: 2
            },
            [1, 2, 3],
            ["hello", decimal.Decimal("1.23")],
                wl.Foo,
                wl.Foo(2, wl.Context.Internal),
        ):
            self.serialize_compare(value, export(value, target_format="wxf"))

        self.assertEqual(
            export(Association(enumerate("abc")), target_format="wxf"),
            export(
                wl.Association(*(wl.Rule(i, v) for i, v in enumerate("abc"))),
                target_format="wxf",
            ),
        )

        self.assertEqual(
            export(wlexpr("2+2"), target_format="wxf"),
            export(wl.ToExpression("2+2"), target_format="wxf"),
        )

        self.assertEqual(
            export(wl.Foo(wlexpr("2+2"), 1, 2), target_format="wxf"),
            export(wl.Foo(wl.ToExpression("2+2"), 1, 2), target_format="wxf"),
        )
Esempio n. 3
0
 def _(blk):
     blk.AllIDs = wl.Keys(serv.existingAccounts)
     blk.id = wl.ToString(
         If(
             wl.Not(wl.SameQ(wl.Length(blk.AllIDs), 0)),
             wl.Plus(wl.Max(wl.Map(wlexpr('ToExpression'), blk.AllIDs)),
                     1), 1))
     blk.existingAccounts[blk.id] = blk.dataUser
     blk.save_json(blk.coID, blk.existingAccounts)
     blk.accountData[blk.id] = wl.Association()
     blk.save_json(blk.coDATA, blk.accountData)