diff options
| author | Ultrabug <ultrabug@gentoo.org> | 2015-01-08 14:36:46 +0100 |
|---|---|---|
| committer | Ultrabug <ultrabug@gentoo.org> | 2015-01-08 14:36:46 +0100 |
| commit | d375c7d8189af5b645992457eb027b96d68f6296 (patch) | |
| tree | 033cdd433c82c8afe1a53cafd8c985d1660bbd27 | |
| parent | 2bba0d713e5ffb6f9e9eeb8475d191aa2c86cc64 (diff) | |
fix i3status.conf parsing when config parameters contains brackets wrt issue #51 thx to @ZeiP
| -rwxr-xr-x | py3status/__init__.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/py3status/__init__.py b/py3status/__init__.py index 2a80e85..2df39a3 100755 --- a/py3status/__init__.py +++ b/py3status/__init__.py @@ -197,19 +197,29 @@ class I3status(Thread): if not in_section: section_name = line.split('{')[0].strip() section_name = self.eval_config_parameter(section_name) - if section_name not in config: - config[section_name] = {} + if not section_name: + continue + else: + in_section = True + if section_name not in config: + config[section_name] = {} if '{' in line: in_section = True if section_name and '=' in line: - line = line.split('}')[0].strip() + section_line = line + + # one liner cases + if line.endswith('}'): + section_line = line.split('}')[0].strip() + if line.startswith(section_name + ' {'): + section_line = line.split(section_name + ' {')[1].strip() - key = line.split('=')[0].strip() + key = section_line.split('=')[0].strip() key = self.eval_config_parameter(key) - value = line.split('=')[1].strip() + value = section_line.split('=')[1].strip() value = self.eval_config_value(value) if section_name == 'order': @@ -251,7 +261,7 @@ class I3status(Thread): if section_name in ['time', 'tztime'] and key == 'format': self.time_format = value - if '}' in line: + if line.endswith('}'): in_section = False section_name = '' |
