Ejemplo n.º 1
0
    def _print_entity_lookup(self, packages):
        self.ctx.writeln('ENTITY_LOOKUP = {')
        self.ctx.lvl_inc()
        for p in packages:
            ns = p.stmt.search_one('namespace')
            for e in p.owned_elements:
                if all((hasattr(e, 'stmt'), e.stmt is not None, e.stmt.keyword
                        in ('container', 'list'))):
                    if self.one_class_per_module:
                        pkg_name = e.get_package().name
                        prop_name = get_property_name(e, e.iskeyword)
                        self.ctx.writeln('("{}", "{}"): "{}.{}.{}.{}",'.format(
                            ns.arg, e.stmt.arg, pkg_name, prop_name, prop_name,
                            e.name))
                        self.ctx.writeln('("{}", "{}"): "{}.{}.{}.{}",'.format(
                            p.stmt.arg, e.stmt.arg, pkg_name, prop_name,
                            prop_name, e.name))
                    else:
                        self.ctx.writeln('("{}", "{}"): "{}",'.format(
                            ns.arg, e.stmt.arg, e.fqn()))
                        self.ctx.writeln('("{}", "{}"): "{}",'.format(
                            p.stmt.arg, e.stmt.arg, e.fqn()))

        self.ctx.lvl_dec()
        self.ctx.writeln('}')
        self.ctx.bline()
Ejemplo n.º 2
0
 def _print_python_modules(self, element, index, path, size, sub):
     for c in [
             clazz for clazz in element.owned_elements
             if isinstance(clazz, Class)
     ]:
         if not c.is_identity():
             self._print_python_module(
                 c, index,
                 os.path.join(path, get_property_name(c, c.iskeyword)),
                 size, sub)
Ejemplo n.º 3
0
def get_pmodule_name_for_one_class_per_module(pmodule_name, property_type):
    p = pmodule_name.replace("'", '')
    if isinstance(property_type, Class):
        pmodule_name = "'%s.%s'" % (p, p.split('.')[-1])
    elif isinstance(property_type, Enum):
        if isinstance(property_type.owner, Package):
            pmodule_name = "'%s.%s'" % (p, p.split('.')[-1])
        else:
            c = property_type.owner
            while (not isinstance(c.owner, Package)):
                c = c.owner
            c = get_property_name(c, c.iskeyword)
            pmodule_name = "'%s.%s.%s'" % (p, c, c)
    return pmodule_name
Ejemplo n.º 4
0
def get_pmodule_name_for_one_class_per_module(pmodule_name, property_type):
    p = pmodule_name.replace("'", '')
    if isinstance(property_type, Class):
        pmodule_name = "'%s.%s'" % (p, p.split('.')[-1])
    elif isinstance(property_type, Enum):
        if isinstance(property_type.owner, Package):
            pmodule_name = "'%s.%s'" % (p, p.split('.')[-1])
        else:
            c = property_type.owner
            while (not isinstance(c.owner, Package)):
                c = c.owner
            c = get_property_name(c, c.iskeyword)
            pmodule_name = "'%s.%s.%s'" % (p, c, c)
    return pmodule_name
Ejemplo n.º 5
0
    def _print_entity_lookup(self, packages):
        self.ctx.writeln('ENTITY_LOOKUP = {')
        self.ctx.lvl_inc()
        for p in packages:
            ns = p.stmt.search_one('namespace')
            for e in p.owned_elements:
                if all((hasattr(e, 'stmt'), e.stmt is not None,
                        e.stmt.keyword in ('container', 'list'))):
                    if self.one_class_per_module:
                        pkg_name = e.get_package().name
                        prop_name = get_property_name(e, e.iskeyword)
                        self.ctx.writeln('("{}", "{}"): "{}.{}.{}.{}",'
                                         .format(ns.arg, e.stmt.arg, pkg_name, prop_name, prop_name, e.name))
                        self.ctx.writeln('("{}", "{}"): "{}.{}.{}.{}",'
                                         .format(p.stmt.arg, e.stmt.arg, pkg_name, prop_name, prop_name, e.name))
                    else:
                        self.ctx.writeln('("{}", "{}"): "{}",'
                                         .format(ns.arg, e.stmt.arg, e.fqn()))
                        self.ctx.writeln('("{}", "{}"): "{}",'
                                         .format(p.stmt.arg, e.stmt.arg, e.fqn()))

        self.ctx.lvl_dec()
        self.ctx.writeln('}')
        self.ctx.bline()
Ejemplo n.º 6
0
def get_python_module_file_name(path, package):
    if isinstance(package, Package):
        return '%s/%s.py' % (path, package.name)
    else:
        return '%s/%s.py' % (path, get_property_name(package, package.iskeyword))
Ejemplo n.º 7
0
def get_python_module_file_name(path, package):
    if isinstance(package, Package):
        return '%s/%s.py' % (path, package.name)
    else:
        return '%s/%s.py' % (path, get_property_name(package, package.iskeyword))
Ejemplo n.º 8
0
 def _print_python_modules(self, element, index, path, size, sub):
     for c in [clazz for clazz in element.owned_elements if isinstance(clazz, Class)]:
         if not c.is_identity():
             self._print_python_module(c, index, os.path.join(path, get_property_name(c, c.iskeyword)), size, sub)