示例#1
0
    def test_ui_scope(self):
        self.assertTrue(f.find_external_object("ceammc/ui.scope~"))
        self.assertTrue(f.find_external_object("ceammc/ui_scope~"))

        self.assertTrue(f.find_external_object("ui.scope~"))
        self.assertTrue(f.find_external_object("ui_scope~"))
        self.assertTrue(f.find_external_object("ui.scope"))
        self.assertTrue(f.find_external_object("ui_scope"))
        f.add_import("ceammc")
        self.assertTrue(f.find_external_object("ui.scope"))
        self.assertTrue(f.find_external_object("ui_scope"))
        self.assertTrue(f.find_external_object("ui.scope~"))
        self.assertTrue(f.find_external_object("ui_scope~"))

        args = dict()
        args['@size'] = '100x200'
        sc = f.make_by_name("ceammc/ui_scope~", **args)
        self.assertTrue(issubclass(sc.__class__, PdObject))
        self.assertEqual(sc.width, 100)
        self.assertEqual(sc.height, 200)

        # default size
        sc = f.make_by_name("ceammc/ui_scope~")
        self.assertTrue(issubclass(sc.__class__, PdObject))
        self.assertEqual(sc.width, 150)
        self.assertEqual(sc.height, 100)
示例#2
0
    def test_ui_scope(self):
        self.assertTrue(f.find_external_object("ceammc/ui.scope~"))
        self.assertTrue(f.find_external_object("ceammc/ui_scope~"))

        self.assertTrue(f.find_external_object("ui.scope~"))
        self.assertTrue(f.find_external_object("ui_scope~"))
        self.assertTrue(f.find_external_object("ui.scope"))
        self.assertTrue(f.find_external_object("ui_scope"))
        f.add_import("ceammc")
        self.assertTrue(f.find_external_object("ui.scope"))
        self.assertTrue(f.find_external_object("ui_scope"))
        self.assertTrue(f.find_external_object("ui.scope~"))
        self.assertTrue(f.find_external_object("ui_scope~"))

        args = dict()
        args['@size'] = '100x200'
        sc = f.make_by_name("ceammc/ui_scope~", **args)
        self.assertTrue(issubclass(sc.__class__, PdObject))
        self.assertEqual(sc.width, 100)
        self.assertEqual(sc.height, 200)

        # default size
        sc = f.make_by_name("ceammc/ui_scope~")
        self.assertTrue(issubclass(sc.__class__, PdObject))
        self.assertEqual(sc.width, 150)
        self.assertEqual(sc.height, 100)
示例#3
0
    def test_ui_display(self):
        kw = dict()
        d = f.make_by_name("ceammc/ui_display", **kw)
        self.assertEqual(d.width, 150)
        self.assertEqual(d.height, 18)

        kw['@size'] = "100x25"
        d = f.make_by_name("ceammc/ui_display", **kw)
        self.assertEqual(d.width, 100)
        self.assertEqual(d.height, 25)
示例#4
0
    def test_ui_keyboard(self):
        kw = dict()
        d = f.make_by_name("ceammc/ui_keyboard", **kw)
        self.assertEqual(d.width, 433)
        self.assertEqual(d.height, 60)

        kw['@size'] = "200x30"
        d = f.make_by_name("ceammc/ui_keyboard", **kw)
        self.assertEqual(d.width, 200)
        self.assertEqual(d.height, 30)
示例#5
0
    def test_ui_display(self):
        kw = dict()
        d = f.make_by_name("ceammc/ui_display", **kw)
        self.assertEqual(d.width, 150)
        self.assertEqual(d.height, 18)

        kw['@size'] = "100x25"
        d = f.make_by_name("ceammc/ui_display", **kw)
        self.assertEqual(d.width, 100)
        self.assertEqual(d.height, 25)
示例#6
0
    def test_ui_keyboard(self):
        kw = dict()
        d = f.make_by_name("ceammc/ui_keyboard", **kw)
        self.assertEqual(d.width, 433)
        self.assertEqual(d.height, 60)

        kw['@size'] = "200x30"
        d = f.make_by_name("ceammc/ui_keyboard", **kw)
        self.assertEqual(d.width, 200)
        self.assertEqual(d.height, 30)
示例#7
0
    def test_ui_knob(self):
        kw = dict()
        d = f.make_by_name("ceammc/ui_knob", **kw)
        self.assertEqual(d.width, 40)
        self.assertEqual(d.height, 40)

        kw['@size'] = "60x60"
        d = f.make_by_name("ceammc/ui_knob", **kw)
        self.assertEqual(d.width, 60)
        self.assertEqual(d.height, 60)
示例#8
0
    def test_ui_link(self):
        kw = dict()
        d = f.make_by_name("ceammc/ui_link", **kw)
        self.assertEqual(d.width, 100)
        self.assertEqual(d.height, 25)
        self.assertEqual(d.text(), "<no-title>")

        kw = {'@url': 'file.pd', '@title': 'FILE'}
        d = f.make_by_name("ceammc/ui_link", **kw)
        self.assertEqual(d.width, 100)
        self.assertEqual(d.height, 25)
        self.assertEqual(d.text(), "FILE")
        self.assertEqual(d.url(), "file.pd")
示例#9
0
    def test_ui_link(self):
        kw = dict()
        d = f.make_by_name("ceammc/ui_link", **kw)
        self.assertEqual(d.width, 100)
        self.assertEqual(d.height, 25)
        self.assertEqual(d.text(), "<no-title>")

        kw = {'@url': 'file.pd', '@title': 'FILE'}
        d = f.make_by_name("ceammc/ui_link", **kw)
        self.assertEqual(d.width, 100)
        self.assertEqual(d.height, 25)
        self.assertEqual(d.text(), "FILE")
        self.assertEqual(d.url(), "file.pd")
示例#10
0
 def test_bg_color(self):
     kw = {'@url': 'http://ya.ru', '@title': 'Yandex'}
     lnk = f.make_by_name("ceammc/ui_link", args=None, **kw)
     lnk.set_bg_color(Color(255, 0, 128))
     self.assertEqual(lnk.to_string(),
                      "ui.link @background_color 1.0 0.0 0.50196 @title Yandex @url http://ya.ru")
     self.assertEqual(lnk.url(), "http://ya.ru")
     self.assertEqual(lnk.text(), "Yandex")
示例#11
0
 def test_bg_color(self):
     kw = {'@url': 'http://ya.ru', '@title': 'Yandex'}
     lnk = f.make_by_name("ceammc/ui_link", args=None, **kw)
     lnk.set_bg_color(Color(255, 0, 128))
     self.assertEqual(lnk.to_string(),
                      "ui.link @background_color 1.0 0.0 0.50196 @title Yandex @url http://ya.ru")
     self.assertEqual(lnk.url(), "http://ya.ru")
     self.assertEqual(lnk.text(), "Yandex")
示例#12
0
    def test_export(self):
        sc = f.make_by_name("ceammc/ui_scope~")

        self.assertEqual(sc.to_string(), "ui.scope~ @size 150 100")
        sc.x = 10
        sc.y = 20

        sc.calc_brect()
        self.assertEqual(sc.brect(), (10, 20, 150, 100))
示例#13
0
    def test_ui_matrix(self):
        d = dict()
        d['@size'] = "200x150"
        m = f.make_by_name("ceammc/ui_matrix", **d)
        self.assertEqual(m.width, 200)
        self.assertEqual(m.height, 150)

        self.assertEqual(m.get_property('@rows'), '4')
        self.assertEqual(m.get_property('@cols'), '8')
示例#14
0
    def test_export(self):
        sc = f.make_by_name("ceammc/ui_scope~")

        self.assertEqual(sc.to_string(), "ui.scope~ @size 150 100")
        sc.x = 10
        sc.y = 20

        sc.calc_brect()
        self.assertEqual(sc.brect(), (10, 20, 150, 100))
示例#15
0
    def test_ui_matrix(self):
        d = dict()
        d['@size'] = "200x150"
        m = f.make_by_name("ceammc/ui_matrix", **d)
        self.assertEqual(m.width, 200)
        self.assertEqual(m.height, 150)

        self.assertEqual(m.get_property('@rows'), '4')
        self.assertEqual(m.get_property('@cols'), '8')
示例#16
0
def main():
    arg_parser = argparse.ArgumentParser(description='PureData object checker')
    arg_parser.add_argument('name',
                            metavar='OBJECT_NAME',
                            help="PureData object name, for ex.: osc~")
    arg_parser.add_argument('args',
                            metavar='OBJECT_ARGS',
                            nargs='*',
                            help="PureData object arguments")
    arg_parser.add_argument('--xlet-db',
                            '-x',
                            metavar='PATH',
                            action='append',
                            help='inlet/outlet database file path',
                            default=[])

    args = vars(arg_parser.parse_args())
    add_xlet_db(args['xlet_db'])

    obj = factory.make_by_name(args['name'], args['args'])

    if type(obj) != PdObject:
        print('core:', obj.name)
        return

    found = False
    db_name = ""

    for db in xcalc.databases:
        if db.has_object(obj.name):
            found = True
            db_name = db.extname
            break

    if found:
        print(db_name + ':', obj.name, obj.args_to_string())
        return 0
    else:
        logging.error(f"ERROR: [%s] not found", obj.name)
        return 1
示例#17
0
 def test_ui_knob(self):
     kw = dict()
     d = f.make_by_name("ceammc/ui_knob", **kw)
示例#18
0
文件: parser.py 项目: uliss/pddoc
    def parse_nodes(self):
        for n in filter(lambda x: x.is_object(), self.nodes):
            if n.type == 'OBJECT':
                m = re.match(r_OBJECT, n.value)
                # filter spaces and #ID values
                atoms = list(filter(lambda a: len(a) > 0 and (not a.startswith('#')), m.group(1).split(' ')))
                assert len(atoms) > 0
                name, args = self.find_alias(atoms)
                kwargs = dict()

                for a in args:
                    pair = a.split('=')
                    if len(pair) == 2:
                        kwargs[pair[0]] = pair[1]

                if CoreGui.is_coregui(name):
                    n.pd_object = factory.make_by_name(name, **kwargs)
                elif name == 'pd':
                    n.pd_object = Canvas.subpatch(args[0])
                elif name == 'X':
                    n.tok.type = 'CONNECTION_MANUAL'
                    str = atoms[1]
                    conn = []

                    for i in map(lambda x: x.split(':'), str.split('->')):
                        if len(i) == 1:
                            i.append(0)

                        assert len(i) == 2

                        obj_id = self.find_node_id_by_hash(i[0])
                        if obj_id is False:
                            logging.error("can't find node with id: {0:s}".format(i[0]))
                            return

                        i[0] = obj_id
                        conn.append(i)

                    n.conn_src_id = conn[0][0]
                    n.conn_src_outlet = int(conn[0][1])
                    n.conn_dest_id = conn[1][0]
                    n.conn_dest_inlet = int(conn[1][1])

                elif name == 'array':
                    if args[0] in ("set", "get", "define", "sum", "size", "random", "min", "max"):
                        n.pd_object = factory.make_by_name(name + " " + args[0], args[1:], **kwargs)
                    else:
                        n.pd_object = Array(args[0], kwargs.get('size', 100), kwargs.get('save', 0))
                        n.pd_object.width = kwargs.get('w', 200)
                        n.pd_object.height = kwargs.get('h', 140)
                        yr = list(map(lambda x: float(x), kwargs.get('yr', "-1..1").split('..')))
                        n.pd_object.set_yrange(yr[0], yr[1])
                else:
                    n.pd_object = factory.make_by_name(name, args, **kwargs)
            elif n.type == 'MESSAGE':
                m = re.match(r_MESSAGE, n.value)
                txt = m.group(1).replace(',', '\,')
                args = list(filter(lambda a: len(a) > 0 and (not a.startswith('#')), txt.split(' ')))
                n.pd_object = Message(0, 0, args)
            elif n.type == 'COMMENT':
                m = re.match(r_COMMENT, n.value)
                txt = m.group(1).replace(';', ' \;').replace(',', ' \,')
                n.pd_object = Comment(0, 0, txt.split(' '))
            else:
                logging.warning("Unknown type {0:s}".format(n.type))