Ejemplo n.º 1
0
    def process(self):
        """Main method that process input directory and write
        converted files to output directory.

        Each input file is parsed using `snakes.lang.python` to an AST
        that is then traversed for processing.
        """
        for dirpath, dirnames, filenames in os.walk(self.path):
            for name in sorted(filenames):
                if not name.endswith(".py") or name.startswith("."):
                    continue
                path = os.path.join(dirpath, name)
                if not self.openout(path):
                    continue
                node = parse(open(path).read())
                if ".plugins." in self.module:
                    self.visit_plugin(node)
                else:
                    self.visit_module(node)
Ejemplo n.º 2
0
    def process (self) :
        """Main method that process input directory and write
        converted files to output directory.

        Each input file is parsed using `snakes.lang.python` to an AST
        that is then traversed for processing.
        """
        for dirpath, dirnames, filenames in os.walk(self.path) :
            for name in sorted(filenames) :
                if not name.endswith(".py") or name.startswith(".") :
                    continue
                path = os.path.join(dirpath, name)
                if not self.openout(path) :
                    continue
                node = parse(open(path).read())
                if ".plugins." in self.module :
                    self.visit_plugin(node)
                else :
                    self.visit_module(node)
Ejemplo n.º 3
0
def unlet (expr, *names) :
    if not names :
        names = ["let"]
    drop = DropLet(names)
    new = DropTrue().visit(drop.visit(parse(expr)))
    return unparse(new), drop.calls
Ejemplo n.º 4
0
def unlet(expr, *names):
    if not names:
        names = ["let"]
    drop = DropLet(names)
    new = DropTrue().visit(drop.visit(parse(expr)))
    return unparse(new), drop.calls