Skip to content

Commit

Permalink
small fixes and copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 14, 2024
1 parent db7b0e0 commit 5baf131
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
def merge_ini_files(old_file_path, new_file_path):
# Check if files exist
if not os.path.isfile(old_file_path):
logging.error(f"file '{old_file_path}' does not exist.")
logging.error(f"file %s does not exist.", old_file_path)
sys.exit(1)
if not os.path.isfile(new_file_path):
logging.error(f"file '{new_file_path}' does not exist.")
logging.error(f"file %s does not exist.", new_file_path)
sys.exit(1)

# Create a configparser object
Expand All @@ -22,7 +22,7 @@ def merge_ini_files(old_file_path, new_file_path):
config_new.read(new_file_path)

except configparser.Error as e:
logging.error(f"Failed to parse configurations files: {e}")
logging.error(f"Failed to parse configurations files: %s", e)
sys.exit(1)

# Merge configurations
Expand All @@ -36,10 +36,10 @@ def merge_ini_files(old_file_path, new_file_path):
config_old.set(section, option, config_new.get(section, option))

# Write the merged configuration to the old file path
with open(old_file_path, 'w') as configfile:
with open(old_file_path, 'w', encoding="utf-8") as configfile:
config_old.write(configfile)

logging.info(f"Configuration has been merged and saved to {old_file_path}")
logging.info(f"Configuration has been merged and saved to %s", old_file_path)

if __name__ == "__main__":
# Get file paths from command line arguments
Expand Down

0 comments on commit 5baf131

Please sign in to comment.