rougail-structural-bitwarden/src/rougail/structural_bitwarden/annotator.py

52 lines
1.9 KiB
Python

"""
Silique (https://www.silique.fr)
Copyright (C) 2025
distribued with GPL-2 or later license
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from rougail.error import DictConsistencyError
from rougail.annotator.variable import Walk
from rougail.convert.object_model import JinjaCalculation
from .i18n import _
class Annotator(Walk):
"""Annotate for bitwarden"""
level = 90
def __init__(
self,
objectspace,
*args, # pylint: disable=unused-argument
) -> None:
if not objectspace.paths:
return
self.objectspace = objectspace
self.check_variable()
def check_variable(self):
for variable in self.get_variables():
if not variable.secret_manager:
continue
path = variable.path
self.objectspace.informations.add(path, "bitwarden", True)
self.objectspace.informations.add(path, "default_value_makes_sense", False)
self.objectspace.properties.add(path, "novalidator", True)
if 'force_default_on_freeze' in self.objectspace.properties.get(path):
self.objectspace.properties.remove(path, 'force_default_on_freeze')
variable.default = variable.secret_manager