Skip to content

Commit 7529545

Browse files
jhrmnndanielhollas
authored andcommitted
fix config file search when stdin
1 parent bea75ad commit 7529545

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fprettify/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,10 +1929,10 @@ def str2bool(str):
19291929
else:
19301930
return None
19311931

1932-
def get_config_file_list(filename):
1932+
def get_config_file_list(start_dir):
19331933
"""helper function to create list of config files found in parent directories"""
19341934
config_file_list = []
1935-
dir = os.path.dirname(filename)
1935+
dir = start_dir
19361936
while True:
19371937
config_file = os.path.join(dir, '.fprettify.rc')
19381938
if os.path.isfile(config_file):
@@ -2096,7 +2096,8 @@ def build_ws_dict(args):
20962096
# reparse arguments using the file's list of config files
20972097
filearguments = arguments
20982098
if argparse.__name__ == "configargparse":
2099-
filearguments['default_config_files'] = ['~/.fprettify.rc'] + get_config_file_list(os.path.abspath(filename) if filename != '-' else os.getcwd())
2099+
filearguments['default_config_files'] = ['~/.fprettify.rc'] \
2100+
+ get_config_file_list(os.path.dirname(os.path.abspath(filename)) if filename != '-' else os.getcwd())
21002101
file_argparser = get_arg_parser(filearguments)
21012102
file_args = file_argparser.parse_args(argv[1:])
21022103

0 commit comments

Comments
 (0)