def addDependencies(self, mod):
        attrs = PyObject.attributes
        PyObject.attributes = {}
        #print '  attrs', attrs.keys()

        for name, (value, module) in mod.imports.items():
            #print '  depends', name
            if module.package:
                m = ImportName.lookupName(module.package + '.' + name)
                if m is None:
                    m = ImportName.lookupName(name)
            else:
                m = ImportName.lookupName(name)
            self.addDependency(m, attrs, mod, value)            

        if self.deep:
            for filename, name in self.depends.items():
                #self.write('%s requires %s' % (mod.name, name))
                if name in self.skip:
                    self.write('  %s skipping %s' % (mod.name, name))
                self.compilefile(filename, name)
Exemplo n.º 2
0
    def addDependencies(self, mod):
        attrs = PyObject.attributes
        PyObject.attributes = {}
        #print '  attrs', attrs.keys()

        for name, (value, module) in mod.imports.items():
            #print '  depends', name
            if module.package:
                m = ImportName.lookupName(module.package + '.' + name)
                if m is None:
                    m = ImportName.lookupName(name)
            else:
                m = ImportName.lookupName(name)
            self.addDependency(m, attrs, mod, value)

        if self.deep:
            for filename, name in self.depends.items():
                #self.write('%s requires %s' % (mod.name, name))
                if name in self.skip:
                    self.write('  %s skipping %s' % (mod.name, name))
                self.compilefile(filename, name)
Exemplo n.º 3
0
def doCompile(opts):
    global mainclass
    global basepath

    skiplist = opts.skip.split(',')
    optpkgs = opts.addpackages.split(',')
    addpackages = [
        'org.python.modules',
        'org.apache.oro.text.regex',
    ] + optpkgs

    comp = Compiler(javapackage=opts.package,
                    deep=opts.deep,
                    include=addpackages,
                    skip=skiplist,
                    options=opts)

    for target in opts.args:
        if target.endswith('.py'):
            classname = os.path.splitext(os.path.basename(target))[0]
            filename = target
            if basepath is None:
                basepath = os.path.split(target)[0]
                sys.path.insert(0, basepath)
        else:
            classname = target
            import ImportName
            m = ImportName.lookupName(classname)
            if not m:
                print 'Could not find class:', classname
                sys.exit(1)
            filename = m.file
        if mainclass is None:
            mainclass = classname
            if opts.package is not None:
                mainclass = opts.package + '.' + mainclass
        comp.compilefile(filename, classname)

    comp.dump(opts.workdir)
    return comp
Exemplo n.º 4
0
def doCompile(opts):
    global mainclass
    global basepath

    skiplist = opts.skip.split(',')
    optpkgs = opts.addpackages.split(',')
    addpackages = ['org.python.modules',
                   'org.apache.oro.text.regex',
                   ] + optpkgs

    comp = Compiler(javapackage=opts.package,
                    deep=opts.deep,
                    include=addpackages,
                    skip=skiplist,
                    options=opts)

    print opts.args
    for target in opts.args:
        if target.endswith('.py'):
            classname = os.path.splitext(os.path.basename(target))[0]
            filename = target
            if basepath is None:
                basepath = os.path.split(target)[0]
                sys.path.insert(0, basepath)
        else:
            classname = target
            import ImportName
            m = ImportName.lookupName(classname)
            if not m:
                print 'Could not find class:', classname
                sys.exit(1)
            filename = m.file
        if mainclass is None:
            mainclass = classname
            if opts.package is not None:
                mainclass = opts.package+'.'+mainclass
        comp.compilefile(filename, classname)

    comp.dump(opts.workdir)
    return comp
Exemplo n.º 5
0
 def _getnames(self, module):
     #print module.value, module.value.__class__
     mod = ImportName.lookupName(module.value.name)
     if mod:
         return dir(mod.mod)
     return []
Exemplo n.º 6
0
 def _getnames(self, module):
     #print module.value, module.value.__class__
     mod = ImportName.lookupName(module.value.name)
     if mod:
         return dir(mod.mod)
     return []