Files
itc_projects/mpstwm/under_construction.py
2025-10-27 22:35:15 +05:00

49 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'''
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]
islist.append(nameBlock)
print(islist)