Files
OldThink/Tools/ss14_ru/fluentastmanager.py
HitPanda 50abbcee11 [Feat] Translates + translate tools (#260)
* autotranslate python script

* 8/52 translated

* autotranslate finished

* updated autotranslate script

* fixes

* updated tool

* once more updated tool

* more translates

* more translates

* fixes
2024-01-20 05:10:24 +03:00

26 lines
975 B
Python
Raw Permalink 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.
from fluent.syntax import ast
from fluentast import FluentAstAbstract
class FluentAstManager:
def __init__(self, sourse_parsed: ast.Resource, target_parsed: ast.Resource):
self.sourse_parsed = sourse_parsed
self.target_parsed = target_parsed
self.source_elements = list(map(lambda e: FluentAstAbstract.create_element(e), sourse_parsed.body))
self.target_elements = list(map(lambda e: FluentAstAbstract.create_element(e), target_parsed.body))
def update_by_index(self, index, update_element: ast.Message):
source_element = None
try:
source_element = self.sourse_parsed.body[index]
except:
raise Exception(f'Нет элемента с индексом {index}')
if not source_element:
raise Exception(f'Элемен с индексом {index} не существует')
self.sourse_parsed.body[index] = update_element
return self.sourse_parsed