Skip to content

Commit

Permalink
fix config file search when stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
jhrmnn authored and danielhollas committed May 27, 2021
1 parent cb25402 commit bc78873
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fprettify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1929,10 +1929,10 @@ def str2bool(str):
else:
return None

def get_config_file_list(filename):
def get_config_file_list(start_dir):
"""helper function to create list of config files found in parent directories"""
config_file_list = []
dir = os.path.dirname(filename)
dir = start_dir
while True:
config_file = os.path.join(dir, '.fprettify.rc')
if os.path.isfile(config_file):
Expand Down Expand Up @@ -2095,7 +2095,8 @@ def build_ws_dict(args):
# reparse arguments using the file's list of config files
filearguments = arguments
if argparse.__name__ == "configargparse":
filearguments['default_config_files'] = ['~/.fprettify.rc'] + get_config_file_list(os.path.abspath(filename) if filename != '-' else os.getcwd())
filearguments['default_config_files'] = ['~/.fprettify.rc'] \
+ get_config_file_list(os.path.dirname(os.path.abspath(filename)) if filename != '-' else os.getcwd())
file_argparser = get_arg_parser(filearguments)
file_args = file_argparser.parse_args(argv[1:])
ws_dict = build_ws_dict(file_args)
Expand Down

0 comments on commit bc78873

Please sign in to comment.