Skip to content

Commit

Permalink
faulty return files in find_config()
Browse files Browse the repository at this point in the history
  • Loading branch information
Loevenich, Mathis committed Jul 17, 2020
1 parent d3371d6 commit e93773c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion script/htcompact
Original file line number Diff line number Diff line change
Expand Up @@ -1085,25 +1085,31 @@ def find_config():
else:
found_config_file = file
found_default_in_cwd = True

# try to find the config file in the current environment hierarchy
elif os.path.isfile(f"{sys.prefix}/config/{file}") and config.read(f"{sys.prefix}/config/{file}"):
found_config = True
arguments.remove(file)
found_config_file = f"{sys.prefix}/config/{file}" # remember the file

# try to find config file in ~/.config/script_name/
elif os.path.isfile(f"~/.config/{script_name}/{file}") \
and config.read(f"~/.config/{script_name}/{file}"):
found_config = True
arguments.remove(file)
found_config_file = f"~/.config/{script_name}/{file}" # remember the file

# try to find config file in /etc
elif os.path.isfile(f"/etc/{file}") and config.read(f"/etc/{file}"):
found_config = True
arguments.remove(file)
found_config_file = f"/etc/{file}" # remember the file

else:
logging.debug(f"{file} not found or is not a valid config file")

# do not search any longer if found
if found_config:
found_config_file = file # remember the file
break

# File has no readable format for the configparser, probably because it's not a config file
Expand Down

0 comments on commit e93773c

Please sign in to comment.