Fix issue with save config

This commit is contained in:
bmaltais 2023-02-20 07:56:24 -05:00
parent 758bfe85dc
commit dfc9a8dd40
4 changed files with 30 additions and 6 deletions

View File

@ -122,6 +122,13 @@ def save_configuration(
]
}
# Extract the destination directory from the file path
destination_directory = os.path.dirname(file_path)
# Create the destination directory if it doesn't exist
if not os.path.exists(destination_directory):
os.makedirs(destination_directory)
# Save the data to the selected file
with open(file_path, 'w') as file:
json.dump(variables, file, indent=2)

View File

@ -104,8 +104,8 @@ def save_configuration(
# print(file_path)
if file_path == None:
return original_file_path
if file_path == None or file_path == '':
return original_file_path # In case a file_path was provided and the user decide to cancel the open action
# Return the values of the variables as a dictionary
variables = {
@ -118,6 +118,13 @@ def save_configuration(
]
}
# Extract the destination directory from the file path
destination_directory = os.path.dirname(file_path)
# Create the destination directory if it doesn't exist
if not os.path.exists(destination_directory):
os.makedirs(destination_directory)
# Save the data to the selected file
with open(file_path, 'w') as file:
json.dump(variables, file, indent=2)

View File

@ -133,6 +133,13 @@ def save_configuration(
]
}
# Extract the destination directory from the file path
destination_directory = os.path.dirname(file_path)
# Create the destination directory if it doesn't exist
if not os.path.exists(destination_directory):
os.makedirs(destination_directory)
# Save the data to the selected file
with open(file_path, 'w') as file:
json.dump(variables, file, indent=2)

View File

@ -117,10 +117,6 @@ def save_configuration(
if file_path == None or file_path == '':
return original_file_path # In case a file_path was provided and the user decide to cancel the open action
directory = os.path.dirname(file_path)
if not os.path.exists(directory):
os.makedirs(directory)
# Return the values of the variables as a dictionary
variables = {
name: value
@ -132,6 +128,13 @@ def save_configuration(
]
}
# Extract the destination directory from the file path
destination_directory = os.path.dirname(file_path)
# Create the destination directory if it doesn't exist
if not os.path.exists(destination_directory):
os.makedirs(destination_directory)
# Save the data to the selected file
with open(file_path, 'w') as file:
json.dump(variables, file, indent=2)