def main(): default_packname = Path(".").absolute().name readme = Path(".") / "README.md" if readme.exists(): README_REF[0] = readme.open().read() def delegato( *, packname: "python package name. in fact, the package name will be 'dexe-$packname'"=default_packname, exe: "executable path. If $depdir specified, it's a relative path to $depdir." = "", depdir: "dependency directory. if specified shall include $exe" = "", cmdname: "if specified, it's the name that the installed executable seen as" = "" ): """delegato: delegate your executable to existing environment managers. """ assert exe, "executable name/path mustn't be empty!" packname = "dexe_" + packname cmdname = cmdname or Path(exe).with_suffix("").name Path(packname).mkdir(mode=0o777, parents=True, exist_ok=True) if depdir: depdir_path = Path(depdir).absolute() bindir = depdir_path.name copy_tree(str(depdir_path), str(Path(packname).joinpath(bindir))) exe_pack_path = os.path.join(bindir, exe) else: bindir = "bin" exe_pack_path = os.path.join(bindir, Path(exe).name) Path(packname).joinpath("bin").mkdir( mode=0o777, parents=True, exist_ok=True ) with open(exe, 'rb') as f1, Path(packname).joinpath(exe_pack_path).open('wb') as f2: f2.write(f1.read()) with open("setup.py", "w") as f: f.write(mk_setup(packname, bindir, cmdname)) with Path(packname).joinpath("main.py").open("w") as f: f.write(mk_main(exe_pack_path)) with Path(packname).joinpath("__init__.py").open("w") as f: f.write("") wise(delegato)()
def cmd_pspy(): import wisepy2 wisepy2.wise(pspy)()
def cmd_gen_init(): import wisepy2 wisepy2.wise(gen_init)()
def cmd_gen_setup(): import wisepy2 wisepy2.wise(gen_setup)()
def cli_generate(): wise(generate)(sys.argv[1:])
return outDir = o vargs = list(vargs) for i, varg in enumerate(vargs): if varg.endswith(".mlfs"): p = Path(varg) f = str(p.with_suffix('.mlfsf')) mlfsf(varg, f) vargs[i] = f srcFiles = ','.join(map(dumps, vargs)) srcFiles = f"String[{srcFiles}]" sigFiles = ','.join(map(dumps, filter(lambda x: x, sig.split(";")))) sigFiles = f"String[{sigFiles}]" args = [ "julia", "--compile=min", "-e", f"using MLFS;smlfsCompile({srcFiles}, {sigFiles}, {dumps(name)}, {dumps(outDir)})" ] call(args) def entry(): wise(mlfsc)() if __name__ == "__main__": wise(mlfsc)()
def mlscm(): wise(execute)(sys.argv[1:])
'src', '.gitignore', 'manage.py', 'vocab.py', '.vscode', 'localize.py', 'favicon.ico', '.nojekyll', '.', '.git', "build-docs.sh", "requirements.txt" ] def clean(): for each in Path('.').list_dir(): filename = each.relative() if filename in preserved: continue each.delete() def dispatch(build: bool=False, clean: bool=False): g = globals() if clean: g['clean']() if build: g['build']() if __name__ == '__main__': wise(dispatch)()
from wisepy2 import wise def f(a): print(args) wise(f)()
from wisepy2 import wise from string import Template import re subs = {f'FFFFFF{i}': f'${i+1}' for i in range(100)} def fix(filename): with open(filename) as r: src = r.read() src = re.sub("\$(\d)", "$FFFFFF\g<1>", src) print(Template(src).safe_substitute(**subs)) if __name__ == "__main__": import sys wise(fix)()
def entry(): from wisepy2 import wise wise(build)()
def exception_hook(exctype, value, traceback): sys._excepthook(exctype, value, traceback) sys.exit(1) sys.excepthook = exception_hook def nove(proj_path: str): os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1" app = QApplication([]) light(app) app.setAttribute(Qt.AA_EnableHighDpiScaling) rect = app.desktop().screenGeometry() win = Main(proj_path) area = QScrollArea() area.setWidget(win) area.setGeometry(100, 100, int(0.2 * rect.width()), int(0.8 * rect.height())) area.setWidgetResizable(True) modern = ModernWindow(area) modern.show() sys.exit(app.exec_()) if __name__ == '__main__': wisepy2.wise(nove)()
def cli_view_graph(): wise(view_parsing_graph)(sys.argv[1:])
def cli_dump_graph(): wise(dump_graph)(sys.argv[1:])
def cmd_get_binary(): import wisepy2 wisepy2.wise(get_binary)()
token = tokens[i] lineno = token.lineno maxline = max(lineno, maxline) colno = token.colno msgs.append(f"Line {lineno + 1}, column {colno}, {msg}") e = SyntaxError() e.lineno = maxline + 1 e.msg = "\n".join(msgs) e.filename = filename off = token.offset e.offset = off e.text = text[:text.find("\n", off)] raise e def mlfsf(file, o): parser = mk_parser() with open(file) as f: src = f.read() res = parse(src, file) with open(o, "w") as f: f.write(json.dumps(res)) return if "__main__" == __name__: wise(mlfsf)()
def entry(): wise(main)()
def ml2scm(): wise(s2s)(sys.argv[1:])
for _ in range(n): args.append(obj_stack.pop()) args.reverse() if ctor is mk_list: v = args else: v = ctor(*args) obj_stack.append(v) left = left_stack.pop() def main(filename: str, out: str): """ QB to Python Compiler """ with open(filename, newline='\n') as f: io = StringIO() for c in sum(Generate.read_and_gen(f), []): code_list_to_string('', io, c) if out.lower() == 'std': print(io.getvalue()) else: with open(out, 'w') as f: f.write('from rts import RTS as __RTS\n') f.write(io.getvalue()) if __name__ == '__main__': wise(main)()
def main(): wise(build)()
def entry(): from wisepy2 import wise wise(main)()
def entry(): wise(mlfsc)()
def main(): wise(tobnf)()