pyblish_maya/vendor/Qt.py
def cli(args):
    """Qt.py command-line interface"""
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument("--convert",
                        help="Path to compiled Python module, e.g. my_ui.py")
    parser.add_argument("--compile",
                        help="Accept raw .ui file and compile with native "
                             "PySide2 compiler.")
    parser.add_argument("--stdout",
                        help="Write to stdout instead of file",
                        action="store_true")
    parser.add_argument("--stdin",
                        help="Read from stdin instead of file",
                        action="store_true")

    args = parser.parse_args(args)

    if args.stdout:
        raise NotImplementedError("--stdout")

    if args.stdin:
        raise NotImplementedError("--stdin")

    if args.compile:
        raise NotImplementedError("--compile")

    if args.convert:
        sys.stdout.write("#\n"
                         "# WARNING: --convert is an ALPHA feature.\n#\n"
                         "# See https://github.com/mottosso/Qt.py/pull/132\n"
                         "# for details.\n"
                         "#\n")

        #
        # ------> Read
        #
        with open(args.convert) as f:
            lines = convert(f.readlines())

        backup = "%s_backup%s" % os.path.splitext(args.convert)
        sys.stdout.write("Creating \"%s\"..\n" % backup)
        shutil.copy(args.convert, backup)

        #
        # <------ Write
        #
        with open(args.convert, "w") as f:
            f.write("".join(lines))

        sys.stdout.write("Successfully converted \"%s\"\n" % args.convert)
def cli(args):
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument("--convert",
                        help="Path to compiled Python module, e.g. my_ui.py")
    parser.add_argument("--compile",
                        help="Accept raw .ui file and compile with native "
                             "PySide2 compiler.")
    parser.add_argument("--stdout",
                        help="Write to stdout instead of file",
                        action="store_true")
    parser.add_argument("--stdin",
                        help="Read from stdin instead of file",
                        action="store_true")

    args = parser.parse_args(args)

    if args.stdout:
        raise NotImplementedError("--stdout")

    if args.stdin:
        raise NotImplementedError("--stdin")

    if args.compile:
        raise NotImplementedError("--compile")

    if args.convert:
        sys.stdout.write("#\n"
                         "# WARNING: --convert is an ALPHA feature.\n#\n"
                         "# See https://github.com/mottosso/Qt.py/pull/132\n"
                         "# for details.\n"
                         "#\n")

        #
        # ------> Read
        #
        with open(args.convert) as f:
            lines = convert(f.readlines())

        backup = "%s_backup%s" % os.path.splitext(args.convert)
        sys.stdout.write("Creating \"%s\"..\n" % backup)
        shutil.copy(args.convert, backup)

        #
        # <------ Write
        #
        with open(args.convert, "w") as f:
            f.write("".join(lines))

        sys.stdout.write("Successfully converted \"%s\"\n" % args.convert)
def cli ( args ) : import argparse parser = argparse . ArgumentParser ( ) parser . add_argument ( "--convert" , help = "Path to compiled Python module, e.g. my_ui.py" ) parser . add_argument ( "--compile" , help = "Accept raw .ui file and compile with native " "PySide2 compiler." ) parser . add_argument ( "--stdout" , help = "Write to stdout instead of file" , action = "store_true" ) parser . add_argument ( "--stdin" , help = "Read from stdin instead of file" , action = "store_true" ) args = parser . parse_args ( args ) if args . stdout : raise NotImplementedError ( "--stdout" ) if args . stdin : raise NotImplementedError ( "--stdin" ) if args . compile : raise NotImplementedError ( "--compile" ) if args . convert : sys . stdout . write ( "#\n" "# WARNING: --convert is an ALPHA feature.\n#\n" "# See https://github.com/mottosso/Qt.py/pull/132\n" "# for details.\n" "#\n" ) # # ------> Read # with open ( args . convert ) as f : lines = convert ( f . readlines ( ) ) backup = "%s_backup%s" % os . path . splitext ( args . convert ) sys . stdout . write ( "Creating \"%s\"..\n" % backup ) shutil . copy ( args . convert , backup ) # # <------ Write # with open ( args . convert , "w" ) as f : f . write ( "" . join ( lines ) ) sys . stdout . write ( "Successfully converted \"%s\"\n" % args . convert )
Qt.py command-line interface
Qt . py command - line interface