示例#1
0
    def generate_body_commands(self, body):
        """ Generates gEDA commands for *body* converting all shapes
            into valid gEDA shapes. If the body can be represented as
            a gEDA 'path' command it will generated as such. Pins are
            added after shapes.

            Returns a list of gEDA commands without trailing linebreaks.
        """
        commands = []

        id_param = geda_commands.GEDAExtraParameter('id')
        ## extract paths
        paths = {}
        for shape_ in body.shapes:
            path_id = shape_.styles.get(id_param.name, None)
            paths.setdefault(path_id, []).append(shape_)

        for shape_ in paths.get(None, []):
            method_name = '_convert_%s' % shape_.type
            if hasattr(self, method_name):
                commands += getattr(self, method_name)(shape_)
            else:
                raise GEDAError("invalid shape '%s' in component" %
                                shape_.type)

        for path_id in paths:
            if path_id is not None:
                commands += self._create_path(paths[path_id])

        ## create commands for pins
        for pin_seq, pin in enumerate(body.pins):
            commands += self._create_pin(pin_seq, pin)

        return commands
示例#2
0
    def setUp(self):
        self.command = geda_commands.GEDACommand()
        self.param = geda_commands.GEDAParameter('test')
        self.style_param = geda_commands.GEDAStyleParameter('test')
        self.extra_param = geda_commands.GEDAExtraParameter('test')

        self.command.TYPE = 'X'
        self.command.PARAMETERS = (self.param, self.style_param)
        self.command.EXTRA_PARAMETERS = (self.extra_param, )