def get_insert_pos(self, src): mo = packageLine.search(src) pos = 0 if mo is not None: pos = mo.end(0) return pos
def insert_import( self, edit, view, src) : cname = "".join(self.cname) clow = cname.lower() last = None for imp in importLine.finditer(src): if clow < imp.group(2).lower(): ins = "{0}import {1};\n".format(imp.group(1), cname) view.insert(edit, self.get_indent(src, imp.start(0)), ins) return last = imp if not last is None: ins = ";\n{0}import {1}".format(last.group(1), cname) view.insert(edit, last.end(2), ins) else: pkg = packageLine.search(src) if not pkg is None: ins = "\n\nimport {0};".format(cname) view.insert(edit, pkg.end(0), ins) else: ins = "import {0};\n\n".format(cname) view.insert(edit, 0, ins)
def get_cur_package(src): mo = packageLine.search(src) if mo is not None: return mo.group(1) return ''