def read_info(fname): all = bindery.parse(fname.read()).vector info = [v for v in all.xml_children if v.xml_type == "element"] def setImplements(fcns): for fcn in fcns: fcn.name = str(fcn.nameStr) fcn.impl = getattr(fcn, "implName", None) fcn.impl = (str(fcn.impl) if fcn.impl else fcn.impl) fcn.line_idx = int(str(fcn.lineNum)) - 1 fcn.is_generator = str(fcn.isGenerator) == "true" for fcn in fcns: fcn.is_toplevel = getattr(fcn, "is_toplevel", False) or bool( fcn.impl) if fcn.impl: try: get_singleton(v for v in fcns if v.name == fcn.impl).is_toplevel = True except GetSingletonEmptyException: global couldntfindexception couldntfindexception = True print("couldn't find function %s for file %s" % (fcn.impl, fcn.srcFile)) return fcns return dict(list(info).equiv_classes( lambda a: Path(str(a.srcFile)))).map_values(setImplements)
def main(): from jinja2 import Environment, FileSystemLoader import jinja2.ext mvnfile = Path("pom.xml") assert mvnfile.exists(), "please run in project root (with ./pom.xml)" version = "1.6.4" paths = list(modpath.walk_files(["jinja2"])) dirs = frozenset(v.parent() for v in paths).union((includepath,)) env = Environment(loader=FileSystemLoader(list(dirs)), trim_blocks=True, extensions=[jinja2.ext.do]) env.globals.update({"version": version}) for fname in Path("scripts").walk_files(["jinja2"]): output = env.get_template(fname.basename()).render() outname = fname.parent().subpath("final", fname.basename().strip(".jinja2")) Path(outname).write_if_different(output) if "launchers" in fname: Path(outname).chmod(0755)
def main(): from jinja2 import Environment, FileSystemLoader import jinja2.ext mvnfile = Path("pom.xml") assert mvnfile.exists(), "please run in project root (with ./pom.xml)" version = "1.6.4" paths = list(modpath.walk_files(["jinja2"])) dirs = frozenset(v.parent() for v in paths).union((includepath, )) env = Environment(loader=FileSystemLoader(list(dirs)), trim_blocks=True, extensions=[jinja2.ext.do]) env.globals.update({"version": version}) for fname in Path("scripts").walk_files(["jinja2"]): output = env.get_template(fname.basename()).render() outname = fname.parent().subpath("final", fname.basename().strip(".jinja2")) Path(outname).write_if_different(output) if "launchers" in fname: Path(outname).chmod(0755)
def run_osc_commit(name, tmppath, commit_msg): repopath = Path("home:gatoatigrado1/%s" % (name)) skip = False if Path("home:gatoatigrado1").exists(): with ExecuteIn(Path("home:gatoatigrado1")): skip = list(SubProc(["osc", "status"]).exec_lines()) == [] if not skip: try: SubProc(["osc", "co", "home:gatoatigrado1", name]).start_wait() except OSError: print("\n\n\nosc not found in path; install with 'sudo zypper -n in osc'", file=sys.stderr) else: print("skipping already checked out source.") [v.copy(repopath.subpath(v.basename())) for v in tmppath.files()] with ExecuteIn(repopath): SubProc(["osc", "add"] + [v for v in Path(".").listdir() if v != ".osc"]).start_wait() SubProc(["osc", "commit"] + (["-m", commit_msg] if commit_msg else [])).start_wait()
def run_osc_commit(name, tmppath, commit_msg): repopath = Path("home:gatoatigrado1/%s" % (name)) skip = False if Path("home:gatoatigrado1").exists(): with ExecuteIn(Path("home:gatoatigrado1")): skip = list(SubProc(["osc", "status"]).exec_lines()) == [] if not skip: try: SubProc(["osc", "co", "home:gatoatigrado1", name]).start_wait() except OSError: print( "\n\n\nosc not found in path; install with 'sudo zypper -n in osc'", file=sys.stderr) else: print("skipping already checked out source.") [v.copy(repopath.subpath(v.basename())) for v in tmppath.files()] with ExecuteIn(repopath): SubProc(["osc", "add"] + [v for v in Path(".").listdir() if v != ".osc"]).start_wait() SubProc(["osc", "commit"] + (["-m", commit_msg] if commit_msg else [])).start_wait()
def read_info(fname): all = bindery.parse(fname.read()).vector info = [v for v in all.xml_children if v.xml_type == "element"] def setImplements(fcns): for fcn in fcns: fcn.name = str(fcn.nameStr) fcn.impl = getattr(fcn, "implName", None) fcn.impl = (str(fcn.impl) if fcn.impl else fcn.impl) fcn.line_idx = int(str(fcn.lineNum)) - 1 fcn.is_generator = str(fcn.isGenerator) == "true" for fcn in fcns: fcn.is_toplevel = getattr(fcn, "is_toplevel", False) or bool(fcn.impl) if fcn.impl: try: get_singleton(v for v in fcns if v.name == fcn.impl).is_toplevel = True except GetSingletonEmptyException: global couldntfindexception couldntfindexception = True print("couldn't find function %s for file %s" %(fcn.impl, fcn.srcFile)) return fcns return dict(list(info).equiv_classes(lambda a: Path(str(a.srcFile)))).map_values(setImplements)