''' MPSTWM Автор: Игорь Рагозин Лицензия: MIT(подробнее в /LICENSE) ''' ''' Своя реализация парсера конфига Hyprland. Примерный алгоритм работы, и концепции на основе идеи рассказал ИИ. Код полностью написан с помощью обычных рук ''' def ParserKeyValue(line): line = line.strip() if '=' in line: key,value=line.split('=', 1) key = key.strip() value = value.strip() return key, value def isBlock(line): line = line.strip() if '{' in line: return True with open("example_hyprland.conf", "r") as file: sections={ 'commentConfig': [], 'air': [], 'variableConfig': [], } file = file.readlines() for index, line in enumerate(file): no_tab = line.strip() if line.strip().startswith('#'): sections['commentConfig'].append({'rawvalue': no_tab, 'line': index}) elif not line.strip(): sections['air'].append({'line': index}) elif line.strip().startswith('$'): value_line = ParserKeyValue(no_tab) key,value = value_line[0],value_line[1] sections['variableConfig'].append({'key': key, 'value': value, 'rawvalue': line, 'line': index}) elif no_tab.strip().endswith(' {'): isBlock = True nameBlock = no_tab.split()[0]