Пример #1
0
    )

    options, args = parser.parse_args()

    if options.basedir:
        import_renpy(options.basedir)
    else:
        import_renpy()

    # Expand wildcards
    args = map(glob.glob, args)
    # Concatenate lists
    args = list(itertools.chain(*args))

    if len(args) == 0:
        parser.print_help()
        parser.error("No script files given.")

    good = bad = 0
    for filename in args:
        try:
            a = decompile_rpyc(filename, options.clobber)
        except Exception as e:
            print e
            bad += 1
        else:
            if a:
                good += 1
            else:
                bad += 1
    if bad == 0:
Пример #2
0
def main():
    # python27 unrpyc.py [-c] [-b BASEDIR] [-d] [--python-screens|--ast-screens|--no-screens|--single-line-screen-kwargs] file [file ...]
    parser = argparse.ArgumentParser(description="Decompile .rpyc files")

    parser.add_argument('-c', '--clobber', dest='clobber', action='store_true',
                        help="overwrites existing output files")

    parser.add_argument('-b', '--basedir', dest='basedir', action='store',
                        help="specify the game base directory in which the 'renpy' directory is located") 

    parser.add_argument('-d', '--dump', dest='dump', action='store_true',
                        help="instead of decompiling, pretty print the ast to a file")

    configscreen = parser.add_mutually_exclusive_group()

    configscreen.add_argument('--python-screens', dest='pythonscreens', action='store_true',
                        help="only for decompiling, don't decompile screens back to screen language")

    configscreen.add_argument('--ast-screens', dest='astscreens', action='store_true',
                        help="only for dumping, prints the entire screen ast instead of decompiling")

    configscreen.add_argument('--no-screens', dest='noscreens', action='store_true',
                        help="don't extract screens at all")

    configscreen.add_argument('--single-line-screen-kwargs', dest='screenkwargs', action='store_true',
                        help="don't force all keyword arguments from screencode to different lines")

    parser.add_argument('file', type=str, nargs='+', 
                        help="The filenames to decompile")

    args = parser.parse_args()

    # set config according to the passed options
    config = Config()
    if args.pythonscreens:
        config.DECOMPILE_SCREENCODE=False
    elif args.noscreens:
        config.EXTRACT_PYTHON_AST=False
    elif args.astscreens:
        config.DECOMPILE_PYTHON_AST=False
    elif args.screenkwargs:
        config.FORCE_MULTILINE_KWARGS=False

    # try to import renpy
    if args.basedir:
        import_renpy(args.basedir)
    else:
        import_renpy()

    # Expand wildcards
    files = map(glob.glob, args.file)
    # Concatenate lists
    files = list(itertools.chain(*files))

    # Check if we actually have files
    if len(files) == 0:
        parser.print_help();
        parser.error("No script files given.")

    # Check per file if everything went well and report back
    good = bad = 0
    for filename in files:
        try:
            a = decompile_rpyc(filename, args.clobber, args.dump, config=config)
        except Exception as e:
            print e
            bad += 1
        else:
            if a:
                good += 1
            else:
                bad += 1
    if bad == 0:
        print "Decompilation of %d script file%s successful" % (good, 's' if good>1 else '')
    elif good == 0:
        print "Decompilation of %d file%s failed" % (bad, 's' if bad>1 else '')
    else:
        print "Decompilation of %d file%s successful, but decompilation of %d file%s failed" % (good, 's' if good>1 else '', bad, 's' if bad>1 else '')
Пример #3
0
def main():
    # python27 unrpyc.py [-c] [-b BASEDIR] [-d] [--python-screens|--ast-screens|--no-screens|--single-line-screen-kwargs] file [file ...]
    parser = argparse.ArgumentParser(description="Decompile .rpyc files")

    parser.add_argument('-c',
                        '--clobber',
                        dest='clobber',
                        action='store_true',
                        help="overwrites existing output files")

    parser.add_argument(
        '-b',
        '--basedir',
        dest='basedir',
        action='store',
        help=
        "specify the game base directory in which the 'renpy' directory is located"
    )

    parser.add_argument(
        '-d',
        '--dump',
        dest='dump',
        action='store_true',
        help="instead of decompiling, pretty print the ast to a file")

    configscreen = parser.add_mutually_exclusive_group()

    configscreen.add_argument(
        '--python-screens',
        dest='pythonscreens',
        action='store_true',
        help=
        "only for decompiling, don't decompile screens back to screen language"
    )

    configscreen.add_argument(
        '--ast-screens',
        dest='astscreens',
        action='store_true',
        help=
        "only for dumping, prints the entire screen ast instead of decompiling"
    )

    configscreen.add_argument('--no-screens',
                              dest='noscreens',
                              action='store_true',
                              help="don't extract screens at all")

    configscreen.add_argument(
        '--single-line-screen-kwargs',
        dest='screenkwargs',
        action='store_true',
        help=
        "don't force all keyword arguments from screencode to different lines")

    parser.add_argument('file',
                        type=str,
                        nargs='+',
                        help="The filenames to decompile")

    args = parser.parse_args()

    # set config according to the passed options
    config = Config()
    if args.pythonscreens:
        config.DECOMPILE_SCREENCODE = False
    elif args.noscreens:
        config.EXTRACT_PYTHON_AST = False
    elif args.astscreens:
        config.DECOMPILE_PYTHON_AST = False
    elif args.screenkwargs:
        config.FORCE_MULTILINE_KWARGS = False

    # try to import renpy
    if args.basedir:
        import_renpy(args.basedir)
    else:
        import_renpy()

    # Expand wildcards
    files = map(glob.glob, args.file)
    # Concatenate lists
    files = list(itertools.chain(*files))

    # Check if we actually have files
    if len(files) == 0:
        parser.print_help()
        parser.error("No script files given.")

    # Check per file if everything went well and report back
    good = bad = 0
    for filename in files:
        try:
            a = decompile_rpyc(filename,
                               args.clobber,
                               args.dump,
                               config=config)
        except Exception as e:
            print e
            bad += 1
        else:
            if a:
                good += 1
            else:
                bad += 1
    if bad == 0:
        print "Decompilation of %d script file%s successful" % (
            good, 's' if good > 1 else '')
    elif good == 0:
        print "Decompilation of %d file%s failed" % (bad,
                                                     's' if bad > 1 else '')
    else:
        print "Decompilation of %d file%s successful, but decompilation of %d file%s failed" % (
            good, 's' if good > 1 else '', bad, 's' if bad > 1 else '')