예제 #1
0
 def testNewer(self):
     r = das.read(self.Newer)
     das.write(r, self.OutputFile)
     self.assertEqual(das.read(self.Newer), das.read(self.OutputFile))
     self.assertNotEqual(
         das.read(self.Newer, schema_type=None, ignore_meta=True),
         das.read(self.OutputFile, schema_type=None, ignore_meta=True))
예제 #2
0
    def testMultiple(self):
        simpsons = das.read(self.SimpsonsInput)
        homer = das.read(self.HomerInput)

        ned = das.make_default("csv.Person")
        ned.name.given = "ned"
        ned.name.family = "flanders"
        rod = das.make_default("csv.Relationship")
        todd = das.make_default("csv.Relationship")
        rod.data.name.given = "rod"
        rod.data.name.family = "flanders"
        todd.data.name.given = "todd"
        todd.data.name.family = "flanders"
        ned.family = [rod, todd]

        das.write_csv([simpsons, homer, ned],
                      self.MultipleOutput,
                      alias={
                          "csv.Person": "p",
                          "csv.Family": "f"
                      })

        read_data = das.read_csv(self.MultipleOutput)
        self.assertEqual(read_data[0], simpsons)
        self.assertEqual(read_data[1], homer)
        self.assertEqual(read_data[2], ned)
        self.assertNotEqual(read_data[2], homer)
        self.assertNotEqual(read_data[1], ned)
예제 #3
0
 def testSimpsons(self):
     simpsons = das.read(self.SimpsonsInput)
     das.write_csv(simpsons, self.SimpsonsOutput)
     from_csv = das.read_csv(self.SimpsonsOutput)[0]
     self.assertEqual(simpsons, from_csv)
     simpsons.father.name.given = "ned"
     self.assertNotEqual(simpsons, from_csv)
예제 #4
0
 def testHomer(self):
     homer = das.read(self.HomerInput)
     das.write_csv(homer, self.HomerOutput)
     from_csv = das.read_csv(self.HomerOutput)[0]
     self.assertEqual(homer, from_csv)
     from_csv.name.family = "flanders"
     self.assertNotEqual(homer, from_csv)
예제 #5
0
    def test3(self):
        r0 = das.make_default("testmultiline.MyStruct")
        r0.comment = u"""昨日
今日
明日"""
        das.write(r0, self.OutputFile)
        r1 = das.read(self.OutputFile)
        self.assertEqual(r0.comment, r1.comment)
예제 #6
0
    def test2(self):
        r0 = das.make_default("testmultiline.MyStruct")
        r0.comment = u"""hello
world.
Be happy!"""
        das.write(r0, self.OutputFile)
        r1 = das.read(self.OutputFile)
        self.assertEqual(r0.comment, r1.comment)
예제 #7
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")
예제 #8
0
def get_ac_freq_pct(inv, freq_ref = 60., das=None):
    try:

        #only use the das (data acquisition system) if it is available
        if das:
            das.read()
            gridFraw = das.ac_freq
        # without the das use the EUT to report the power level
        else:
            inv.inverter.read()
            gridFraw = float(inv.inverter.Hz)

        inv.settings.read()
        Freq_nom = float(freq_ref)

        return (gridFraw/Freq_nom)*100.0

    except Exception, e:
        raise script.ScriptFail('Unable to get ac freq from das or EUT: %s' % str(e))
예제 #9
0
def get_ac_freq_pct(inv, freq_ref=60., das=None):
    try:

        #only use the das (data acquisition system) if it is available
        if das:
            das.read()
            gridFraw = das.ac_freq
        # without the das use the EUT to report the power level
        else:
            inv.inverter.read()
            gridFraw = float(inv.inverter.Hz)

        inv.settings.read()
        Freq_nom = float(freq_ref)

        return (gridFraw / Freq_nom) * 100.0

    except Exception, e:
        raise script.ScriptFail('Unable to get ac freq from das or EUT: %s' %
                                str(e))
예제 #10
0
    def process(self):
        fp = self.input("filepath").receive()
        if fp.isEOP():
            return False

        fv = fp.value()
        fp.drop()

        das_obj = das.read(fv)
        self.output("dasObj").send(das_obj)

        return True
예제 #11
0
파일: __init__.py 프로젝트: gatgui/das
 def testCompare1(self):
    hud1 = das.read(self.InputFile, schema_type="hud.HUD")
    das.write(hud1, self.OutputFile)
    hud2 = das.read(self.OutputFile, schema_type="hud.HUD")
    self.assertEqual(hud1, hud2)
예제 #12
0
파일: __init__.py 프로젝트: gatgui/das
 def testWrite2(self):
    hud = das.read(self.InputFile, schema_type="hud.HUD")
    with self.assertRaises(Exception):
       hud.text.elements[2].align = ("top", "left")
예제 #13
0
파일: __init__.py 프로젝트: gatgui/das
 def testWrite1(self):
    das.write(das.read(self.InputFile, schema_type="hud.HUD"), self.OutputFile)
    self.assertTrue(os.path.isfile(self.OutputFile))
예제 #14
0
 def test3(self):
     r = das.read(self.OutputFile)
     with self.assertRaises(das.ValidationError):
         r.add([1, 2, 3])
예제 #15
0
 def testNewer2(self):
     with self.assertRaises(das.ValidationError):
         das.read(self.Newer2, strict_schema=False)
예제 #16
0
파일: __init__.py 프로젝트: gatgui/das
 def testRead3(self):
    with self.assertRaises(das.ValidationError):
       das.read(self.TestDir + "/error2.asset", schema_type="asset.TokenDict")
예제 #17
0
 def testNotEqual(self):
    das.write(self._makeOne(), self.OutputFile)
    p0 = self._makeOne()
    p1 = das.read(self.OutputFile)
    p1.gender = u"女"
    self.assertFalse(p0 == p1)
예제 #18
0
 def testSaveInvalidValue(self):
     rv = das.read(self.TestDir + "/test1.tl",
                   schema_type="timeline.ClipSource")
     with self.assertRaises(das.ValidationError):
         rv.clipRange = (1, 100, 10)
         das.write(rv, self.OutputFile)
예제 #19
0
 def testSaveValue(self):
     rv = das.read(self.TestDir + "/test1.tl",
                   schema_type="timeline.ClipSource")
     rv.clipRange = [1, 100]
     das.write(rv, self.OutputFile)
     self.assertTrue(os.path.isfile(self.OutputFile))
예제 #20
0
 def testSaveNone2(self):
     rv = das.read(self.TestDir + "/test0.tl",
                   schema_type="timeline.ClipSource")
     with self.assertRaises(das.ValidationError):
         rv.dataRange = None
         das.write(rv, self.OutputFile)
예제 #21
0
 def testWithNone(self):
     rv = das.read(self.TestDir + "/test1.tl",
                   schema_type="timeline.ClipSource")
     self.assertIsNone(rv.clipRange)
예제 #22
0
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")
예제 #23
0
파일: __init__.py 프로젝트: gatgui/das
 def testCompare2(self):
    hud1 = das.read(self.InputFile, schema_type="hud.HUD")
    das.write(hud1, self.OutputFile)
    hud2 = das.read(self.OutputFile, schema_type="hud.HUD")
    hud2.text.elements[2].opacity = 0.5
    self.assertNotEqual(hud1, hud2)
예제 #24
0
파일: __init__.py 프로젝트: gatgui/das
 def testRead1(self):
    _ = das.read(self.TestDir + "/ok.asset", schema_type="asset.TokenDict")
예제 #25
0
 def testNoInf(self):
     with self.assertRaises(das.ValidationError):
         das.read(self.NoInf)
예제 #26
0
 def testTooNew(self):
     with self.assertRaises(das.VersionError):
         das.read(self.TooNew)
예제 #27
0
파일: __init__.py 프로젝트: gatgui/das
 def testOld(self):
     r = das.read(self.InputFile)
     self.assertEqual(r.newField == ["hello", "world"], True)
예제 #28
0
 def testOlder(self):
     das.read(self.Older)
예제 #29
0
파일: __init__.py 프로젝트: gatgui/das
 def testNew(self):
     r = das.read(self.InputFile)
     das.write(r, self.OutputFile)
     with open(self.OutputFile, "r") as f:
         d = eval(f.read())
         self.assertEqual(d["newField"] == ["hello", "world"], True)
예제 #30
0
파일: __init__.py 프로젝트: gatgui/das
 def testRead2(self):
    rv = das.read(self.InputFile, schema_type="hud.HUD")
    self.assertIsInstance(rv, das.types.Struct)
예제 #31
0
 def test2(self):
     r0 = self._makeValue()
     r1 = das.read(self.OutputFile)
     self.assertEqual(r0, r1)
     r0 |= (2, 4, -2.3, "goodbye")
     self.assertNotEqual(r0, r1)