-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
11 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import os, json | ||
|
||
|
||
class Configurator: | ||
def __init__(self, config_path): | ||
self.config_path = config_path | ||
|
||
def create_file_if_not_exist(self): | ||
def _create_file_if_not_exist(self): | ||
if not os.path.exists(self.config_path): | ||
with open(self.config_path, "w"): pass | ||
|
||
def read_config(self) -> dict: | ||
self.create_file_if_not_exist() | ||
self._create_file_if_not_exist() | ||
with open(self.config_path) as config_json: | ||
config_data = json.load(config_json) | ||
|
||
return config_data | ||
|
||
def write_config(self, config_json): | ||
self.create_file_if_not_exist() | ||
self._create_file_if_not_exist() | ||
with open(self.config_path, "w") as outfile: | ||
json.dump(config_json, outfile, indent=4) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters