Skip to content

Commit

Permalink
Prevented error when no config file exists
Browse files Browse the repository at this point in the history
  • Loading branch information
akenion committed Oct 25, 2023
1 parent 67642d7 commit 1e7708e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions wordfence/cli/configurer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ def read(self) -> List[ConfigValue]:
values = []
self.initialize_parser()
ini_path = self.resolve_ini_path()
with open(ini_path, 'r') as file:
self.read_existing_config(file, ini_path)
for section_name, section_proxy in self.parser.items():
for key, value in section_proxy.items():
values.append(ConfigValue(section_name, key, value))
try:
with open(ini_path, 'r') as file:
self.read_existing_config(file, ini_path)
for section_name, section_proxy in self.parser.items():
for key, value in section_proxy.items():
values.append(ConfigValue(section_name, key, value))
except FileNotFoundError:
log.debug(f'No existing config file found at {ini_path}')
return values

def delete_section(self, section: str) -> None:
Expand Down

0 comments on commit 1e7708e

Please sign in to comment.