From b837926c11e70b0db76888b3d0162f327e06482d Mon Sep 17 00:00:00 2001 From: Benjamin Dweck Date: Fri, 29 Jan 2021 11:07:58 +0200 Subject: [PATCH] refactorings --- syncthing_monitor/config_xml.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/syncthing_monitor/config_xml.py b/syncthing_monitor/config_xml.py index 4ddbd6c..5987226 100644 --- a/syncthing_monitor/config_xml.py +++ b/syncthing_monitor/config_xml.py @@ -1,7 +1,9 @@ from xml.etree import ElementTree as elementTree +DEFAULT_CONFIG_XML_PATH = '/config/config.xml' -def parse_api_key(xml_path='/config/config.xml'): + +def parse_api_key(xml_path=DEFAULT_CONFIG_XML_PATH): root = elementTree.parse(xml_path).getroot() api_key = '' for gui in root.findall('gui'): @@ -10,11 +12,11 @@ def parse_api_key(xml_path='/config/config.xml'): return api_key -def set_listen_ip_to_any(in_xml_path='/config/config.xml', out_xml_path='/config/config.xml', gui_port='8384'): +def set_listen_ip_to_any(in_xml_path=DEFAULT_CONFIG_XML_PATH, out_xml_path=DEFAULT_CONFIG_XML_PATH, gui_port='8384'): with open(in_xml_path, 'r') as file: xml = file.read() - xml = xml.replace("127.0.0.1:8384", "0.0.0.0:"+gui_port) + xml = xml.replace("127.0.0.1:8384", "0.0.0.0:{0}".format(gui_port)) with open(out_xml_path, 'w') as file: file.write(xml)