Пример #1
0
def main():
    global VERSION
    print("\nIPlug Project Duplicator v" + VERSION +
          " by Oli Larkin ------------------------------\n")

    numargs = len(sys.argv) - 1

    if not (numargs == 3 or numargs == 4):
        print(
            "Usage: duplicate.py inputprojectname outputprojectname manufacturername (outputprojectpath)"
        )
        sys.exit(1)
    else:
        inputprojectname = sys.argv[1]
        outputprojectname = sys.argv[2]
        manufacturer = sys.argv[3]

    if numargs == 4:
        outputbasepath = os.path.abspath(sys.argv[4])
    else:
        outputbasepath = os.getcwd()

    if not (os.path.isdir(outputbasepath)):
        print("error: Output path does not exist")
        sys.exit(1)

    outputpath = os.path.join(outputbasepath, outputprojectname)

    if ' ' in inputprojectname:
        print("error: input project name has spaces")
        sys.exit(1)

    if inputprojectname not in os.listdir(os.curdir):
        print("error: input project " + inputprojectname +
              " doesn't exist, check spelling/case?")
        sys.exit(1)

    if ' ' in outputprojectname:
        print("error: output project name has spaces")
        sys.exit(1)

    if ' ' in manufacturer:
        print("error: manufacturer name has spaces")
        sys.exit(1)

    # remove a trailing slash if it exists
    if inputprojectname[-1:] == "/":
        inputprojectname = inputprojectname[0:-1]

    if outputprojectname[-1:] == "/":
        outputprojectname = outputprojectname[0:-1]

    #check that the folders are OK
    if os.path.isdir(inputprojectname) == False:
        print("error: input project not found")
        sys.exit(1)

    if os.path.isdir(outputpath):
        print("error: output project allready exists")
        sys.exit(1)
    # rmtree(output)

    print("copying " + inputprojectname + " folder to " + outputpath)
    copytree(inputprojectname, outputpath, ignore=ignore_patterns(*DONT_COPY))

    oldroot = ""
    newroot = ""

    if numargs == 4:
        configpath = os.path.join(inputprojectname, "config")
        xcconfig = parse_xcconfig(configpath + "/" + inputprojectname +
                                  "-mac.xcconfig")
        oldroot = xcconfig["IPLUG2_ROOT"]
        iplug2folder = os.path.abspath(os.path.join(configpath, oldroot))
        newroot = os.path.relpath(iplug2folder,
                                  os.path.join(outputpath, "config"))
    else:
        newroot = ""

    #replace manufacturer name strings
    for dir in dirwalk(outputpath, inputprojectname, outputprojectname,
                       "AcmeInc", manufacturer, oldroot, newroot):
        pass

    print("\ncopying gitignore template into project folder\n")

    copy('gitignore_template', outputpath + "/.gitignore")

    config = parse_config(outputpath)

    config["PLUG_UNIQUE_ID"] = randomFourChar()

    set_uniqueid(outputpath, config["PLUG_UNIQUE_ID"])

    pp = pprint.PrettyPrinter(indent=4)
    pp.pprint(config)

    print("\ndone - don't forget to change PLUG_MFR_UID in config.h")
Пример #2
0
def main():
    global VERSION
    print("\nIPlug Project Duplicator v" + VERSION +
          " by Oli Larkin ------------------------------\n")

    if len(sys.argv) != 4:
        print(
            "Usage: duplicate.py inputprojectname outputprojectname manufacturername"
        )
        sys.exit(1)
    else:
        input = sys.argv[1]
        output = sys.argv[2]
        manufacturer = sys.argv[3]

        if ' ' in input:
            print("error: input project name has spaces")
            sys.exit(1)

        if ' ' in output:
            print("error: output project name has spaces")
            sys.exit(1)

        if ' ' in manufacturer:
            print("error: manufacturer name has spaces")
            sys.exit(1)

        # remove a trailing slash if it exists
        if input[-1:] == "/":
            input = input[0:-1]

        if output[-1:] == "/":
            output = output[0:-1]

        #check that the folders are OK
        if os.path.isdir(input) == False:
            print("error: input project not found")
            sys.exit(1)

        if os.path.isdir(output):
            print("error: output folder allready exists")
            sys.exit(1)
        # rmtree(output)

        print("copying " + input + " folder to " + output)
        copytree(input, output, ignore=ignore_patterns(*DONT_COPY))
        cpath = os.path.join(os.getcwd(), output)

        #replace manufacturer name strings
        for dir in dirwalk(cpath, input, output, "AcmeInc", manufacturer):
            pass

        print("\ncopying gitignore template into project folder\n")

        copy('gitignore_template', output + "/.gitignore")

        config = parse_config(output)

        config["PLUG_UNIQUE_ID"] = randomFourChar()

        set_uniqueid(output, config["PLUG_UNIQUE_ID"])

        pp = pprint.PrettyPrinter(indent=4)
        pp.pprint(config)

        print("\ndone - don't forget to change MFR_UID in config.h")