Skip to content

Commit 3808e0e

Browse files
authored
Print config filename in double verbose mode (#182)
This lets the user see which config applies to which file to aid them in debugging filename pattern matches.
1 parent 0fe9940 commit 3808e0e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

wpiformat/wpiformat/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def proc_pipeline(name):
8989
with print_lock:
9090
print("Processing", name)
9191
if verbose2:
92+
print(" with config " + config_file.file_name)
9293
for subtask in task_pipeline:
9394
if subtask.should_process_file(config_file, name):
9495
print(" with " + type(subtask).__name__)

wpiformat/wpiformat/config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@ def read_file(directory, file_name):
3232
directory -- current directory from which to start search
3333
file_name -- file name string
3434
35-
Returns list containing file contents or triggers program exit.
35+
Returns tuple of file name and list containing file contents or triggers
36+
program exit.
3637
"""
3738
file_found = False
3839
while not file_found:
3940
try:
4041
with open(directory + os.sep + file_name, "r") as file_contents:
4142
file_found = True
42-
return file_contents.read().splitlines()
43+
return os.path.join(
44+
directory,
45+
file_name), file_contents.read().splitlines()
4346
except OSError:
4447
# .git files are ignored, which are created within submodules
4548
if os.path.isdir(directory + os.sep + ".git"):
@@ -175,7 +178,7 @@ def __parse_config_file(self, directory, file_name):
175178
group_name = ""
176179
group_elements = []
177180

178-
lines = self.read_file(directory, file_name)
181+
self.file_name, lines = self.read_file(directory, file_name)
179182
if not lines:
180183
return None
181184

wpiformat/wpiformat/licenseupdate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __try_string_search(self, lines, last_year, license_template):
128128
def run_pipeline(self, config_file, name, lines):
129129
linesep = super().get_linesep(lines)
130130

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

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

0 commit comments

Comments
 (0)