示例#1
0
def _build_arg_parser():
    """Creates an argument parser for the nbshow command."""
    parser = ConfigBackedParser(
        description=_description,
        add_help=True,
        )
    add_generic_args(parser)
    parser.add_argument("notebook", nargs="*", help="notebook filename(s) or - to read from stdin")

    # Things we can choose to show or not
    ignorables = parser.add_argument_group(
        title='ignorables',
        description='Set which parts of the notebook (not) to show.')
    ignorables.add_argument(
        '-s', '--sources',
        action=IgnorableAction,
        help="show/ignore sources.")
    ignorables.add_argument(
        '-o', '--outputs',
        action=IgnorableAction,
        help="show/ignore outputs.")
    ignorables.add_argument(
        '-a', '--attachments',
        action=IgnorableAction,
        help="show/ignore attachments.")
    ignorables.add_argument(
        '-m', '--metadata',
        action=IgnorableAction,
        help="show/ignore metadata.")
    ignorables.add_argument(
        '-d', '--details',
        action=IgnorableAction,
        help="show/ignore details not covered by other options.")

    return parser
示例#2
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = ConfigBackedParser(
        description=_description,
        add_help=True,
        )
    from .args import add_generic_args, add_diff_args, add_merge_args, add_filename_args
    add_generic_args(parser)
    add_diff_args(parser)
    add_merge_args(parser)
    add_filename_args(parser, ["base", "local", "remote"])

    parser.add_argument(
        '--out',
        default=None,
        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
示例#3
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = ConfigBackedParser(
        description=_description,
        )
    add_generic_args(parser)
    add_diff_args(parser)
    add_diff_cli_args(parser)

    parser.add_argument(
        "base", help="the base notebook filename OR base git-revision.",
        nargs='?', default='HEAD',
    )
    parser.add_argument(
        "remote", help="the remote modified notebook filename OR remote git-revision.",
        nargs='?', default=None,
    )
    parser.add_argument(
        "paths", help="filter diffs for git-revisions based on path",
        nargs='*', default=None,
    )

    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
示例#4
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = ConfigBackedParser(
        description=_description,
        )
    add_generic_args(parser)
    add_diff_args(parser)
    add_diff_cli_args(parser)

    parser.add_argument(
        "base", help="the base notebook filename OR base git-revision.",
        nargs='?', default='HEAD',
    )
    parser.add_argument(
        "remote", help="the remote modified notebook filename OR remote git-revision.",
        nargs='?', default=None,
    )
    parser.add_argument(
        "paths", help="filter diffs for git-revisions based on path",
        nargs='*', default=None,
    )

    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
示例#5
0
def test_config_parser(entrypoint_config):
    parser = ConfigBackedParser('test-prog')
    parser.add_argument(
        '--log-level',
        default='INFO',
        choices=('DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'),
        help="Set the log level by name.",
        action=LogLevelAction,
    )

    # Check that log level default is taken from FixtureConfig
    arguments = parser.parse_args([])
    assert arguments.log_level == 'WARN'

    arguments = parser.parse_args(['--log-level', 'ERROR'])
    assert arguments.log_level == 'ERROR'
示例#6
0
def test_config_parser(entrypoint_config):
    parser = ConfigBackedParser('test-prog')
    parser.add_argument(
        '--log-level',
        default='INFO',
        choices=('DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'),
        help="Set the log level by name.",
        action=LogLevelAction,
    )

    # Check that log level default is taken from FixtureConfig
    arguments = parser.parse_args([])
    assert arguments.log_level == 'WARN'

    arguments = parser.parse_args(['--log-level', 'ERROR'])
    assert arguments.log_level == 'ERROR'
示例#7
0
def _build_arg_parser():
    """Creates an argument parser for the nbpatch command."""
    parser = ConfigBackedParser(
        description=_description,
        add_help=True,
        )
    from .args import add_generic_args, add_filename_args
    add_generic_args(parser)
    add_filename_args(parser, ["base", "patch"])
    parser.add_argument(
        '-o', '--output',
        default=None,
        help="if supplied, the patched notebook is written "
             "to this file. Otherwise it is printed to the "
             "terminal.")
    return parser
示例#8
0
def _build_arg_parser():
    """Creates an argument parser for the nbshow command."""
    parser = ConfigBackedParser(
        description=_description,
        add_help=True,
    )
    add_generic_args(parser)
    parser.add_argument("notebook",
                        nargs="*",
                        help="notebook filename(s) or - to read from stdin")

    # Things we can choose to show or not
    ignorables = parser.add_argument_group(
        title='ignorables',
        description='Set which parts of the notebook (not) to show.')
    ignorables.add_argument('-s',
                            '--sources',
                            action=IgnorableAction,
                            help="show/ignore sources.")
    ignorables.add_argument('-o',
                            '--outputs',
                            action=IgnorableAction,
                            help="show/ignore outputs.")
    ignorables.add_argument('-a',
                            '--attachments',
                            action=IgnorableAction,
                            help="show/ignore attachments.")
    ignorables.add_argument('-m',
                            '--metadata',
                            action=IgnorableAction,
                            help="show/ignore metadata.")
    ignorables.add_argument(
        '-d',
        '--details',
        action=IgnorableAction,
        help="show/ignore details not covered by other options.")

    return parser
示例#9
0
def _build_arg_parser():
    """Creates an argument parser for the nbdiff command."""
    parser = ConfigBackedParser(
        description=_description,
        add_help=True,
    )
    from .args import add_generic_args, add_diff_args, add_merge_args, add_filename_args
    add_generic_args(parser)
    add_diff_args(parser)
    add_merge_args(parser)
    add_filename_args(parser, ["base", "local", "remote"])

    parser.add_argument('--out',
                        default=None,
                        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
示例#10
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