示例#1
0
文件: diff.py 项目: vidartf/nbdime
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    import argparse
    parser = ConfigBackedParser('hg-nbdiff', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    add_diff_args(parser)
    add_diff_cli_args(parser)
    add_filename_args(parser, ('base', 'remote'))

    opts = parser.parse_args(args)

    # TODO: Filter base/remote: If directories, find all modified notebooks
    # If files that are not notebooks, ensure a decent error is printed.
    if not os.path.isfile(opts.base) or not os.path.isfile(opts.remote):
        base, remote = opts.base, opts.remote
        for a, b in diff_directories(base, remote):
            opts.base, opts.remote = a, b
            ret = nbdiffapp.main_diff(opts)
            if ret != 0:
                return ret
        return ret
    else:
        return nbdiffapp.main_diff(opts)
示例#2
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    import argparse
    parser = ConfigBackedParser(
        'hg-nbdiff',
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    add_diff_args(parser)
    add_diff_cli_args(parser)
    add_prettyprint_args(parser)
    add_filename_args(parser, ('base', 'remote'))

    opts = parser.parse_args(args)

    # TODO: Filter base/remote: If directories, find all modified notebooks
    # If files that are not notebooks, ensure a decent error is printed.
    if not os.path.isfile(opts.base) or not os.path.isfile(opts.remote):
        base, remote = opts.base, opts.remote
        for a, b in diff_directories(base, remote):
            opts.base, opts.remote = a, b
            ret = nbdiffapp.main_diff(opts)
            if ret != 0:
                return ret
        return ret
    else:
        return nbdiffapp.main_diff(opts)
示例#3
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    parser = ConfigBackedParser(
        "git-pjmergedriver",
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    subparsers = parser.add_subparsers(dest="subcommand")

    merge_parser = subparsers.add_parser(
        "merge",
        description=
        "The actual entrypoint for the merge tool. Git will call this.",
    )
    add_generic_args(parser)
    add_diff_args(merge_parser)
    add_merge_args(merge_parser)

    # Argument list, we are given base, local, remote
    add_filename_args(merge_parser, ["base", "local", "remote"])

    # TODO: support git-config-specified conflict markers inside sources
    merge_parser.add_argument("marker")
    merge_parser.add_argument("out", nargs="?")
    # "The merge driver can learn the pathname in which the merged result will
    # be stored via placeholder %P"
    # - NOTE: This is not where the driver should store its output, see below!

    add_git_config_subcommand(
        subparsers,
        enable,
        disable,
        subparser_help=
        "Configure git to use packson for notebooks in `git merge`",
        enable_help="enable packson merge driver via git config",
        disable_help="disable packson merge driver via git config",
    )

    opts = parser.parse_args(args)
    if opts.subcommand == "merge":
        # "The merge driver is expected to leave the result of the merge in the
        # file named with %A by overwriting it, and exit with zero status if it
        # managed to merge them cleanly, or non-zero if there were conflicts."
        opts.out = opts.local
        # mergeapp expects an additional decisions arg:
        opts.decisions = False
        return main_merge(opts)
    elif opts.subcommand == "config":
        opts.config_func(opts.scope)
        return 0
    else:
        parser.print_help()
        return 1
示例#4
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = argparse.ArgumentParser(description=_description, add_help=True)
    add_generic_args(parser)
    add_diff_args(parser)
    add_filename_args(parser, ["base", "remote"])

    parser.add_argument(
        "-o",
        "--output",
        default=None,
        help="if supplied, the diff is written to this file. " "Otherwise it is printed to the terminal.",
    )

    return parser
示例#5
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    parser = ConfigBackedParser('git-nbmergedriver', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )
    subparsers = parser.add_subparsers(dest='subcommand')

    merge_parser = subparsers.add_parser('merge',
        description="The actual entrypoint for the merge tool. Git will call this."
    )
    add_generic_args(parser)
    add_diff_args(merge_parser)
    add_merge_args(merge_parser)

    # Argument list, we are given base, local, remote
    add_filename_args(merge_parser, ["base", "local", "remote"])

    # TODO: support git-config-specified conflict markers inside sources
    merge_parser.add_argument('marker')
    merge_parser.add_argument('out', nargs='?')
    # "The merge driver can learn the pathname in which the merged result will
    # be stored via placeholder %P"
    # - NOTE: This is not where the driver should store its output, see below!


    add_git_config_subcommand(
        subparsers,
        enable, disable,
        subparser_help="Configure git to use nbdime for notebooks in `git merge`",
        enable_help="enable nbdime merge driver via git config",
        disable_help="disable nbdime merge driver via git config")

    opts = parser.parse_args(args)
    if opts.subcommand == 'merge':
        # "The merge driver is expected to leave the result of the merge in the
        # file named with %A by overwriting it, and exit with zero status if it
        # managed to merge them cleanly, or non-zero if there were conflicts."
        opts.out = opts.local
        # mergeapp expects an additional decisions arg:
        opts.decisions = False
        return nbmergeapp.main_merge(opts)
    elif opts.subcommand == 'config':
        opts.config_func(opts.scope)
        return 0
    else:
        parser.print_help()
        return 1
示例#6
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = argparse.ArgumentParser(
        description=_description,
        add_help=True,
    )
    add_generic_args(parser)
    add_diff_args(parser)
    add_filename_args(parser, ["base", "remote"])

    parser.add_argument('--out',
                        default=None,
                        help="if supplied, the diff is written to this file. "
                        "Otherwise it is printed to the terminal.")

    return parser
示例#7
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = ConfigBackedParser(description=_description, add_help=True)
    from nbdime.args import (
        add_generic_args,
        add_diff_args,
        add_merge_args,
        filename_help,
        add_filename_args,
        add_prettyprint_args,
    )

    add_generic_args(parser)
    add_diff_args(parser)
    add_merge_args(parser)
    add_prettyprint_args(parser)

    parser.add_argument(
        "base",
        type=Path,
        help=filename_help["base"],
        nargs="?",
        default=EXPLICIT_MISSING_FILE,
    )
    add_filename_args(parser, ["local", "remote"])

    parser.add_argument(
        "--out",
        default=None,
        type=Path,
        help="if supplied, the merged notebook is written "
        "to this file. Otherwise it is printed to the "
        "terminal.",
    )
    parser.add_argument(
        "--decisions",
        action="store_true",
        help="print a human-readable summary of conflicted "
        "merge decisions instead of merging the notebook.",
    )

    return parser
示例#8
0
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    parser = argparse.ArgumentParser('hg-nbmerge', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    add_generic_args(parser)
    add_diff_args(parser)
    add_merge_args(parser)

    # Argument list, we are given base, local, remote
    add_filename_args(parser, ["base", "local", "remote", "merged"])

    opts = parser.parse_args(args)
    # mergeapp expects an additional decisions arg:
    opts.decisions = False
    opts.out = opts.merged
    del opts.merged
    return nbmergeapp.main_merge(opts)
示例#9
0
文件: merge.py 项目: vidartf/nbdime
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    parser = ConfigBackedParser('hg-nbmerge', description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
    )

    add_generic_args(parser)
    add_diff_args(parser)
    add_merge_args(parser)

    # Argument list, we are given base, local, remote
    add_filename_args(parser, ["base", "local", "remote", "merged"])

    opts = parser.parse_args(args)
    # mergeapp expects an additional decisions arg:
    opts.decisions = False
    opts.out = opts.merged
    del opts.merged
    return nbmergeapp.main_merge(opts)
示例#10
0
def _build_arg_parser():
    """Creates an argument parser for the nbshow command."""
    parser = argparse.ArgumentParser(
        description=_description,
        add_help=True,
    )
    add_generic_args(parser)
    add_filename_args(parser, ["notebook"])

    # Things we can choose to show or not
    parser.add_argument('-s',
                        '--sources',
                        action="store_true",
                        default=False,
                        help="show sources.")
    parser.add_argument('-o',
                        '--outputs',
                        action="store_true",
                        default=False,
                        help="show outputs.")
    parser.add_argument('-a',
                        '--attachments',
                        action="store_true",
                        default=False,
                        help="show attachments.")
    parser.add_argument('-m',
                        '--metadata',
                        action="store_true",
                        default=False,
                        help="show metadata.")
    parser.add_argument('-d',
                        '--details',
                        action="store_true",
                        default=False,
                        help="show details not covered by other options.")

    return parser