-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ammend script to work with cache dir
- Loading branch information
Showing
5 changed files
with
52 additions
and
40 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
|
||
VESUVIO_CONFIG_PATH = os.path.join(os.path.expanduser("~"), '.mvesuvio') | ||
VESUVIO_CONFIG_FILE = "vesuvio.user.properties" | ||
|
||
|
||
def set_config_vars(var_dict): | ||
file_path = f'{VESUVIO_CONFIG_PATH}/{VESUVIO_CONFIG_FILE}' | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
|
||
updated_lines = [] | ||
for line in lines: | ||
match = False | ||
for var in var_dict: | ||
if line.startswith(var): | ||
updated_lines.append(f'{var}={var_dict[var]}') | ||
match = True | ||
break | ||
if not match: | ||
updated_lines.append(line) | ||
|
||
with open(file_path, 'w') as file: | ||
file.writelines(updated_lines) | ||
|
||
|
||
def read_config_var(var): | ||
file_path = f'{VESUVIO_CONFIG_PATH}/{VESUVIO_CONFIG_FILE}' | ||
with open(file_path, 'r') as file: | ||
lines = file.readlines() | ||
|
||
result = "" | ||
for line in lines: | ||
if line.startswith(var): | ||
result = line.split("=", 2)[1].strip('\n') | ||
break | ||
if not result: | ||
raise ValueError(f'{var} was not found in the vesuvio config') | ||
return result |
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