コード例 #1
0
ファイル: finddupes.py プロジェクト: yellcorp/dupescan
def get_arg_parser():
    p = argparse.ArgumentParser(
        description="Find files with identical content.",
        epilog="""Arguments that accept byte counts accept an integer with an
                  optional suffix indicating units.  'B' indicates bytes, which
                  is also the default if no suffix is provided.  'K' indicates
                  kibibytes (1024 bytes).  'M' indicates mebibytes.  'G'
                  indicates gibibytes, and 'T' indicates tebibytes.""",
    )

    p.add_argument(
        "paths",
        nargs="*",
        metavar="PATH",
        help="""List of files to consider. Specify --recurse (-r) to also
                consider the contents of directories.""",
    )

    p.add_argument("-s", "--symlinks", action="store_true", help="""Include symlinks.""")

    p.add_argument(
        "-z",
        "--zero",
        action="store_true",
        help="""Include zero-length files. All zero-length files are considered
                to have identical content. This option is equivalent to
                --min-size 0""",
    )

    p.add_argument(
        "-a",
        "--aliases",
        action="store_true",
        help="""Check whether a single file has more than one name, which is
                possible through hardlinks, as well as symlinks if the
                -s/--symlinks option is specified. This check is used to skip
                redundant content comparisons, add extra information to
                reports, and preserve all paths pointing to a selected file
                when the -p/--prefer option is used.""",
    )

    p.add_argument("-r", "--recurse", action="store_true", help="""Recurse into subdirectories.""")

    p.add_argument(
        "-o",
        "--only-mixed-roots",
        action="store_true",
        help="""Only show duplicate files if they arise from recursing into
                different root directories. This can speed operations if the
                only results of interest are whether duplicates exist between
                different filesystem hierarchies, rather than within a single
                one. Note that this only has a useful effect if -r/--recurse
                is specified and two or more paths are provided. If -r/--recurse
                is not specified, this option has no effect. If -r/--recurse
                is specified with only one path, no output will be
                produced.""",
    )

    p.add_argument(
        "-m",
        "--min-size",
        type=units.parse_byte_count,
        default=None,
        metavar="SIZE",
        help="""Ignore files smaller than %(metavar)s. This option accepts a
                byte count. The default is 1.""",
    )

    p.add_argument(
        "-p",
        "--prefer",
        metavar="CRITERIA",
        help="""For each set of duplicate files, automatically select one
                for preservation according to the provided criteria. Other
                duplicates can be deleted by passing the generated report to
                the -x/--execute option.""",
    )

    p.add_argument("--time", action="store_true", help="""Add elasped time to the generated report.""")

    p.add_argument("--help-prefer", action="store_true", help="""Display detailed help on using the --prefer option""")

    p.add_argument("-v", "--verbose", action="store_true", help="""Log detailed information to STDERR.""")

    p.add_argument("--progress", action="store_true", help="""Show progress bars on STDERR.""")

    p.add_argument(
        "-x",
        "--execute",
        metavar="PATH",
        help="""Delete unmarked files in the report at %(metavar)s. Sets where
                no files are marked will be skipped.""",
    )

    p.add_argument(
        "-n",
        "--dry-run",
        action="store_true",
        help="""Used in combination with -x/--execute. List actions that
                --execute would perform without actually doing them.""",
    )

    add_common_cli_args(p)

    return p
コード例 #2
0
def get_arg_parser():
    p = argparse.ArgumentParser(
        description="Compare two directories by content.",
        epilog="""If none of -m/--matches, -r/--removes, -a/--adds is
                  specified, all are reported."""
    )

    p.add_argument("dirs",
        nargs=2,
        metavar="DIR",
        help="""Paths to the directories to be compared."""
    )

    #p.add_argument("-s", "--symlinks",
        #action="store_true",
        #help="""Include symlinks."""
    #)

    p.add_argument("-v", "--verbose",
        action="store_true",
        help="""Log detailed information to STDERR."""
    )

    p.add_argument("-m", "--matches",
        action="store_true",
        help="""List files that appear in both directories."""
    )

    p.add_argument("-r", "--removes",
        action="store_true",
        help="""List files that appear only as a descendant of the first directory."""
    )

    p.add_argument("-a", "--adds",
        action="store_true",
        help="""List files that appear only as a descendant of the second directory."""
    )

    p.add_argument("-c", "--colorize",
        dest="colorize",
        default=None,
        action="store_true",
        help="""Colorize output."""
    )

    p.add_argument("--no-colorize",
        dest="colorize",
        action="store_false",
        help="""Force colorizing off. If neither --colorize or --no-colorize is
                specified, it will be enabled if a compatible terminal is
                detected."""
    )

    p.add_argument("--no-summary",
        action="store_true",
        help="""Suppress the summary."""
    )

    add_common_cli_args(p)

    return p