Skip to content

Commit

Permalink
Print config filename in double verbose mode (#182)
Browse files Browse the repository at this point in the history
This lets the user see which config applies to which file to aid them in
debugging filename pattern matches.
  • Loading branch information
calcmogul authored Jul 9, 2021
1 parent 0fe9940 commit 3808e0e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions wpiformat/wpiformat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def proc_pipeline(name):
with print_lock:
print("Processing", name)
if verbose2:
print(" with config " + config_file.file_name)
for subtask in task_pipeline:
if subtask.should_process_file(config_file, name):
print(" with " + type(subtask).__name__)
Expand Down
9 changes: 6 additions & 3 deletions wpiformat/wpiformat/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ def read_file(directory, file_name):
directory -- current directory from which to start search
file_name -- file name string
Returns list containing file contents or triggers program exit.
Returns tuple of file name and list containing file contents or triggers
program exit.
"""
file_found = False
while not file_found:
try:
with open(directory + os.sep + file_name, "r") as file_contents:
file_found = True
return file_contents.read().splitlines()
return os.path.join(
directory,
file_name), file_contents.read().splitlines()
except OSError:
# .git files are ignored, which are created within submodules
if os.path.isdir(directory + os.sep + ".git"):
Expand Down Expand Up @@ -175,7 +178,7 @@ def __parse_config_file(self, directory, file_name):
group_name = ""
group_elements = []

lines = self.read_file(directory, file_name)
self.file_name, lines = self.read_file(directory, file_name)
if not lines:
return None

Expand Down
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/licenseupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def __try_string_search(self, lines, last_year, license_template):
def run_pipeline(self, config_file, name, lines):
linesep = super().get_linesep(lines)

license_template = Config.read_file(
_, license_template = Config.read_file(
os.path.dirname(os.path.abspath(name)), ".styleguide-license")

# Get year when file was most recently modified in Git history
Expand Down

0 comments on commit 3808e0e

Please sign in to comment.