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

53 lines
1.9 KiB
Python
Raw Normal View History

2025-02-17 09:38:58 +01:00
"""
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
2025-06-18 06:38:45 +02:00
from rougail.convert.object_model import JinjaCalculation
2025-02-17 09:38:58 +01:00
from .i18n import _
class Annotator(Walk):
"""Annotate for bitwarden"""
2025-03-19 10:14:39 +01:00
level = 90
2025-02-17 09:38:58 +01:00
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():
2025-03-19 10:14:39 +01:00
if not variable.secret_manager:
2025-02-17 09:38:58 +01:00
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)
2025-02-17 15:39:39 +01:00
if 'force_default_on_freeze' in self.objectspace.properties.get(path):
self.objectspace.properties.remove(path, 'force_default_on_freeze')
2025-03-19 10:14:39 +01:00
variable.default = variable.secret_manager