8000 gh-104683: Add --exclude option to Argument Clinic CLI by erlend-aasland · Pull Request #107770 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104683: Add --exclude option to Argument Clinic CLI #107770

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-104683: Add --exclude option to Argument Clinic CLI
Explicitly exclude Lib/test/clinic.test.c when running make clinic.
  • Loading branch information
erlend-aasland committed Aug 8, 2023
commit bb701b73236be0da633bbfa0bad4f33dbf9843b9
5 changes: 5 additions & 0 deletions Doc/howto/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ The CLI supports the following options:

The directory tree to walk in :option:`--make` mode.

.. option:: --exclude FILES

Comma-separated list of files to exclude in :option:`--make` mode.
This option has no effect unless :option:`--make` is also given.

.. option:: FILE ...

The list of files to process.
Expand Down
2 changes: 1 addition & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ coverage-report: regen-token regen-frozen
# Run "Argument Clinic" over all source files
.PHONY: clinic
clinic: check-clean-src $(srcdir)/Modules/_blake2/blake2s_impl.c
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py --make --exclude Lib/test/clinic.test.c --srcdir $(srcdir)
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_global_objects.py

# Build the interpreter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``--exclude`` option to Argument Clinic CLI.
5 changes: 5 additions & 0 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5832,6 +5832,8 @@ def create_cli() -> argparse.ArgumentParser:
help="walk --srcdir to run over all relevant files")
cmdline.add_argument("--srcdir", type=str, default=os.curdir,
help="the directory tree to walk in --make mode")
cmdline.add_argument("--exclude", type=str,
help="a list of files to exclude --make mode")
cmdline.add_argument("filename", metavar="FILE", type=str, nargs="*",
help="the list of files to process")
return cmdline
Expand Down Expand Up @@ -5903,6 +5905,7 @@ def run_clinic(parser: argparse.ArgumentParser, ns: argparse.Namespace) -> None:
parser.error("can't use -o or filenames with --make")
if not ns.srcdir:
parser.error("--srcdir must not be empty with --make")
excludes = [os.path.join(ns.srcdir, f) for f in ns.exclude.split(",")]
for root, dirs, files in os.walk(ns.srcdir):
for rcs_dir in ('.svn', '.git', '.hg', 'build', 'externals'):
if rcs_dir in dirs:
Expand All @@ -5912,6 +5915,8 @@ def run_clinic(parser: argparse.ArgumentParser, ns: argparse.Namespace) -> None:
if not filename.endswith(('.c', '.cpp', '.h')):
continue
path = os.path.join(root, filename)
if path in excludes:
continue
if ns.verbose:
print(path)
parse_file(path, verify=not ns.force)
Expand Down
0