From 59abf28fd5cf74329e4105cab5ed2c6b238c52c8 Mon Sep 17 00:00:00 2001 From: Jendrik Seipp Date: Fri, 11 Sep 2020 10:01:11 +0200 Subject: [PATCH] Remove duplicate code for argument parsing. --- vulture/core.py | 63 ------------------------------------------------- 1 file changed, 63 deletions(-) diff --git a/vulture/core.py b/vulture/core.py index 8a080c69..854de8ab 100644 --- a/vulture/core.py +++ b/vulture/core.py @@ -1,4 +1,3 @@ -import argparse import ast from fnmatch import fnmatch, fnmatchcase import os.path @@ -676,68 +675,6 @@ def generic_visit(self, node): self.visit(value) -def _parse_args(): - def csv(exclude): - return exclude.split(",") - - usage = "%(prog)s [options] PATH [PATH ...]" - version = f"vulture {__version__}" - glob_help = "Patterns may contain glob wildcards (*, ?, [abc], [!abc])." - parser = argparse.ArgumentParser(prog="vulture", usage=usage) - parser.add_argument( - "paths", - nargs="+", - metavar="PATH", - help="Paths may be Python files or directories. For each directory" - " Vulture analyzes all contained *.py files.", - ) - parser.add_argument( - "--exclude", - metavar="PATTERNS", - type=csv, - help=f"Comma-separated list of paths to ignore (e.g.," - f' "*settings.py,docs/*.py"). {glob_help} A PATTERN without glob' - f" wildcards is treated as *PATTERN*.", - ) - parser.add_argument( - "--ignore-decorators", - metavar="PATTERNS", - type=csv, - help=f"Comma-separated list of decorators. Functions and classes using" - f' these decorators are ignored (e.g., "@app.route,@require_*").' - f" {glob_help}", - ) - parser.add_argument( - "--ignore-names", - metavar="PATTERNS", - type=csv, - default=None, - help=f'Comma-separated list of names to ignore (e.g., "visit_*,do_*").' - f" {glob_help}", - ) - parser.add_argument( - "--make-whitelist", - action="store_true", - help="Report unused code in a format that can be added to a" - " whitelist module.", - ) - parser.add_argument( - "--min-confidence", - type=int, - default=0, - help="Minimum confidence (between 0 and 100) for code to be" - " reported as unused.", - ) - parser.add_argument( - "--sort-by-size", - action="store_true", - help="Sort unused functions and classes by their lines of code.", - ) - parser.add_argument("-v", "--verbose", action="store_true") - parser.add_argument("--version", action="version", version=version) - return parser.parse_args() - - def main(): config = make_config() vulture = Vulture(