Skip to content

Commit

Permalink
update function
Browse files Browse the repository at this point in the history
  • Loading branch information
axenteoctavian committed Jan 28, 2025
1 parent a171435 commit 4c17ba5
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions scripts/testnet/sovereignBridge/pyScripts/update_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@ def update_subscribed_addresses(lines, section, identifier, main_chain_address)
return updated_lines


def update_key_in_section(lines, section, key, value):
updated_lines = []
section_found = False

for line in lines:
if line.startswith("[" + section + "]"):
section_found = True
if section_found and key in line:
line = re.sub(rf'({re.escape(key)}\s*=\s*)".*?"', r'\1"{}"'.format(value), line)
section_found = False
updated_lines.append(line)

return updated_lines


def update_key(lines, key, value) -> []:
updated_lines = []

Expand Down Expand Up @@ -83,11 +68,26 @@ def update_node_configs(config_path, esdt_prefix, sovereign_chain_address):
update_transfer_and_execute_address(config_path + "/config.toml", sovereign_chain_address)


def update_main_chain_elastic_url(lines, section, key, value):
updated_lines = []
section_found = False

for line in lines:
if line.startswith("[" + section + "]"):
section_found = True
if section_found and key in line:
line = re.sub(rf'({re.escape(key)}\s*=\s*)".*?"', rf'\1"{value}"', line)
section_found = False
updated_lines.append(line)

return updated_lines


def update_external_config(file_path, main_chain_elastic):
with open(file_path, 'r') as file:
lines = file.readlines()

updated_lines = update_key_in_section(lines, "MainChainElasticSearchConnector", "URL", main_chain_elastic)
updated_lines = update_main_chain_elastic_url(lines, "MainChainElasticSearchConnector", "URL", main_chain_elastic)

with open(file_path, 'w') as file:
file.writelines(updated_lines)
Expand Down

0 comments on commit 4c17ba5

Please sign in to comment.