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)
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
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
def _getnames(self, module): #print module.value, module.value.__class__ mod = ImportName.lookupName(module.value.name) if mod: return dir(mod.mod) return []