From: Tobias Brunner Date: Tue, 15 Oct 2024 10:44:02 +0000 (+0200) Subject: Revert "conf: Add support for escaping dots in section/option names" X-Git-Tag: 6.0.0rc1~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=faf40b8d746c4daed148c573443d7fb10fbea7c7;p=thirdparty%2Fstrongswan.git Revert "conf: Add support for escaping dots in section/option names" This reverts commit 84a3077e780e7b25bf536da42a583bdc18448362. Support for dots in names of settings was removed quite a while ago and now the \. sequence caused `SyntaxWarning: invalid escape sequence`. --- diff --git a/conf/format-options.py b/conf/format-options.py index b36e28671c..e0fa180552 100755 --- a/conf/format-options.py +++ b/conf/format-options.py @@ -55,14 +55,6 @@ man pages) the following format can be used: full.section.name.include files/to/include Description of this include statement - -Dots in section/option names may be escaped with a backslash. For instance, -with the following section description - -charon.filelog./var/log/daemon\.log {} - Section to define logging into /var/log/daemon.log - -/var/log/daemon.log will be the name of the last section. """ import sys @@ -74,10 +66,10 @@ from functools import cmp_to_key, total_ordering @total_ordering class ConfigOption: """Representing a configuration option or described section in strongswan.conf""" - def __init__(self, path, default = None, section = False, commented = False, include = False): - self.path = path - self.name = path[-1] - self.fullname = '.'.join(path) + def __init__(self, fullname, default = None, section = False, commented = False, include = False): + self.path = fullname.split('.') + self.name = self.path[-1] + self.fullname = fullname self.default = default self.section = section self.commented = commented @@ -141,8 +133,7 @@ class Parser: if m: if self.__current: self.__add_option(self.__current) - path = self.__split_name(m.group('name')) - self.__current = ConfigOption(path, m.group('default'), + self.__current = ConfigOption(m.group('name'), m.group('default'), commented = not m.group('assign')) return # section definition @@ -150,8 +141,7 @@ class Parser: if m: if self.__current: self.__add_option(self.__current) - path = self.__split_name(m.group('name')) - self.__current = ConfigOption(path, section = True, + self.__current = ConfigOption(m.group('name'), section = True, commented = m.group('comment')) return # include definition @@ -159,8 +149,7 @@ class Parser: if m: if self.__current: self.__add_option(self.__current) - path = self.__split_name(m.group('name')) - self.__current = ConfigOption(path, m.group('pattern'), include = True) + self.__current = ConfigOption(m.group('name'), m.group('pattern'), include = True) return # paragraph separator m = re.match(r'^\s*$', line) @@ -171,10 +160,6 @@ class Parser: if m and self.__current: self.__current.add(m.group('text')) - def __split_name(self, name): - """Split the given full name in a list of section/option names""" - return [x.replace('\.', '.') for x in re.split(r'(?