Ejemplo n.º 1
0
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)()
Ejemplo n.º 2
0
def cmd_pspy():
    import wisepy2
    wisepy2.wise(pspy)()
Ejemplo n.º 3
0
def cmd_gen_init():
    import wisepy2
    wisepy2.wise(gen_init)()
Ejemplo n.º 4
0
def cmd_gen_setup():
    import wisepy2
    wisepy2.wise(gen_setup)()
Ejemplo n.º 5
0
def cli_generate():
    wise(generate)(sys.argv[1:])
Ejemplo n.º 6
0
        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)()
Ejemplo n.º 7
0
def mlscm():
    wise(execute)(sys.argv[1:])
Ejemplo n.º 8
0
  '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)()
Ejemplo n.º 9
0
from wisepy2 import wise


def f(a):
    print(args)


wise(f)()
Ejemplo n.º 10
0
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)()
Ejemplo n.º 11
0
def entry():
    from wisepy2 import wise

    wise(build)()
Ejemplo n.º 12
0

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)()
Ejemplo n.º 13
0
def cli_view_graph():
    wise(view_parsing_graph)(sys.argv[1:])
Ejemplo n.º 14
0
def cli_dump_graph():
    wise(dump_graph)(sys.argv[1:])
Ejemplo n.º 15
0
def cmd_get_binary():
    import wisepy2
    wisepy2.wise(get_binary)()
Ejemplo n.º 16
0
        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)()
Ejemplo n.º 17
0
def entry():
    wise(main)()
Ejemplo n.º 18
0
def ml2scm():
    wise(s2s)(sys.argv[1:])
Ejemplo n.º 19
0
            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)()
Ejemplo n.º 20
0
def main():
    wise(build)()
Ejemplo n.º 21
0
def entry():
    from wisepy2 import wise

    wise(main)()
Ejemplo n.º 22
0
def entry():
    wise(mlfsc)()
Ejemplo n.º 23
0
def main():
    wise(tobnf)()