24 lines
636 B
Python
24 lines
636 B
Python
from pathlib import Path
|
|
from string import Template
|
|
from typing import Annotated
|
|
|
|
from injectable import injectable, autowired, Autowired
|
|
|
|
from app.services import Passwords
|
|
|
|
|
|
@injectable
|
|
class Mo:
|
|
@autowired
|
|
def __init__(self, passwords: Annotated[Passwords, Autowired]):
|
|
self._passwords = passwords
|
|
|
|
def process(self, mo_file: Path):
|
|
raw = ''
|
|
with open(mo_file, "r") as mo:
|
|
raw = mo.read()
|
|
tpl = Template(raw)
|
|
rendered = tpl.substitute(self._passwords.get_values(tpl.get_identifiers()))
|
|
de_mo_ified = str(mo_file).replace(".mo", "")
|
|
with open(de_mo_ified, "w") as mo:
|
|
mo.write(rendered)
|