cardinal_pythonlib.source_reformatting
tools/reformat_source.py
Original code copyright (C) 2009-2022 Rudolf Cardinal (rudolf@pobox.com).
This file is part of cardinal_pythonlib.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Clean up source code.
- class cardinal_pythonlib.source_reformatting.PythonProcessor(full_path: str, top_dir: str, correct_copyright_lines: List[str])[source]
Class to read a Python source file and reformat its shebang/docstring etc.
- Parameters:
- cardinal_pythonlib.source_reformatting.reformat_python_docstrings(top_dirs: List[str], correct_copyright_lines: List[str], show_only: bool = True, rewrite: bool = False, process_only_filenum: int | None = None) None [source]
Walk a directory, finding Python files and rewriting them.
- Parameters:
top_dirs¶ – list of directories to descend into
correct_copyright_lines¶ – list of lines (without newlines) representing the copyright docstring block, including the transition lines of equals symbols
show_only¶ – show results (to stdout) only; don’t rewrite
rewrite¶ – write the changes
process_only_filenum¶ – only process this file number (1-based index); for debugging only