diff --git a/locale/fr/LC_MESSAGES/rougail_structural_bitwarden.po b/locale/fr/LC_MESSAGES/rougail_structural_bitwarden.po new file mode 100644 index 0000000..21eb9d3 --- /dev/null +++ b/locale/fr/LC_MESSAGES/rougail_structural_bitwarden.po @@ -0,0 +1,56 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: 2025-03-11 12:46+0100\n" +"PO-Revision-Date: 2025-03-11 12:52+0100\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" +"X-Generator: Poedit 3.5\n" + +#: src/rougail/structural_bitwarden/annotator.py:47 +msgid "" +"only \"unix_user\" or \"secret\" variable type can have \"bitwarden\" " +"attribute, but \"{0}\" has type \"{1}\"" +msgstr "" +"seulement une variable du type \"unix_user\" ou \"secret\" peut avoir un " +"attribut \"bitwarden\", mais \"{0}\" a le type \"{1}\"" + +#: src/rougail/structural_bitwarden/annotator.py:50 +msgid "" +"the variable \"{0}\" has attribute \"bitwarden\" but is a multi variable" +msgstr "" +"la variable \"{0}\" a l'attribut \"bitwarden\" mais est une variable " +"multiple" + +#: src/rougail/structural_bitwarden/annotator.py:59 +msgid "" +"the variable \"{0}\" is a follower and leader variable (\"{1}\") is also in " +"Bitwarden so this variable could not have default value" +msgstr "" +"la variable \"{0}\" est une variable suiveuse et la variable meneuse " +"(\"{1}\") est aussi dans Bitwarden donc cette variable ne peut avoir avoir " +"de valeur par défaut" + +#: src/rougail/structural_bitwarden/annotator.py:63 +msgid "the variable \"{0}\" is in Bitwarden so should have default value" +msgstr "" +"la variable \"{0}\" est dans Bitwarden donc cette variable devrait avoir un " +"valeur par défaut" + +#: src/rougail/structural_bitwarden/config.py:31 +msgid "The secret pattern to build item name in Bitwarden" +msgstr "" +"Le patron du secret pour construire le nom de l'élément dans Bitwarden" + +#: src/rougail/structural_bitwarden/config.py:32 +msgid "The pattern is in Jinja format" +msgstr "Le patron est au format Jinja" diff --git a/locale/rougail_structural_bitwarden.pot b/locale/rougail_structural_bitwarden.pot new file mode 100644 index 0000000..9fb5a93 --- /dev/null +++ b/locale/rougail_structural_bitwarden.pot @@ -0,0 +1,41 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR ORGANIZATION +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2025-03-11 12:52+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: pygettext.py 1.5\n" + + +#: src/rougail/structural_bitwarden/annotator.py:47 +msgid "only \"unix_user\" or \"secret\" variable type can have \"bitwarden\" attribute, but \"{0}\" has type \"{1}\"" +msgstr "" + +#: src/rougail/structural_bitwarden/annotator.py:50 +msgid "the variable \"{0}\" has attribute \"bitwarden\" but is a multi variable" +msgstr "" + +#: src/rougail/structural_bitwarden/annotator.py:59 +msgid "the variable \"{0}\" is a follower and leader variable (\"{1}\") is also in Bitwarden so this variable could not have default value" +msgstr "" + +#: src/rougail/structural_bitwarden/annotator.py:63 +msgid "the variable \"{0}\" is in Bitwarden so should have default value" +msgstr "" + +#: src/rougail/structural_bitwarden/config.py:31 +msgid "The secret pattern to build item name in Bitwarden" +msgstr "" + +#: src/rougail/structural_bitwarden/config.py:32 +msgid "The pattern is in Jinja format" +msgstr "" + diff --git a/src/rougail/structural_bitwarden/__init__.py b/src/rougail/structural_bitwarden/__init__.py index 38bdbf5..18e1c4b 100644 --- a/src/rougail/structural_bitwarden/__init__.py +++ b/src/rougail/structural_bitwarden/__init__.py @@ -15,7 +15,5 @@ details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . """ -from .object_model import Variable - -__all__ = ("Variable",) +__all__ = tuple() diff --git a/src/rougail/structural_bitwarden/annotator.py b/src/rougail/structural_bitwarden/annotator.py index db77f89..3f0d4b6 100644 --- a/src/rougail/structural_bitwarden/annotator.py +++ b/src/rougail/structural_bitwarden/annotator.py @@ -20,13 +20,14 @@ 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.object_model import JinjaCalculation from .i18n import _ class Annotator(Walk): """Annotate for bitwarden""" - level = 95 + level = 90 def __init__( self, @@ -40,30 +41,12 @@ class Annotator(Walk): def check_variable(self): for variable in self.get_variables(): - if not variable.bitwarden: + if not variable.secret_manager: continue path = variable.path - if variable.type not in ["unix_user", "secret"]: - msg = _('only "unix_user" or "secret" variable type can have "bitwarden" attribute, but "{0}" has type "{1}"') - raise DictConsistencyError(msg.format(path, variable.type), 301, variable.xmlfiles) - if variable.multi and path not in self.objectspace.leaders: - msg = _('the variable "{0}" has attribute "bitwarden" but is a multi variable') - raise DictConsistencyError(msg.format(path), 302, variable.xmlfiles) - check_default_value = True - if path in self.objectspace.followers: - leadership = path.rsplit('.', 1)[0] - leader_path = self.objectspace.parents[leadership][0] - leader = self.objectspace.paths[leader_path] - if leader.bitwarden: - if variable.default: - msg = _('the variable "{0}" is a follower and leader variable ("{1}") is also in Bitwarden so this variable could not have default value') - raise DictConsistencyError(msg.format(path, leader_path), 303, variable.xmlfiles) - check_default_value = False - if check_default_value and not variable.default: - msg = _('the variable "{0}" is in Bitwarden so should have default value') - raise DictConsistencyError(msg.format(path), 304, variable.xmlfiles) 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 diff --git a/src/rougail/structural_bitwarden/i18n.py b/src/rougail/structural_bitwarden/i18n.py new file mode 100644 index 0000000..f5cc88b --- /dev/null +++ b/src/rougail/structural_bitwarden/i18n.py @@ -0,0 +1,26 @@ +""" +Silique (https://www.silique.fr) +Copyright (C) 2025 + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by the +Free Software Foundation, either version 3 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 Lesser General Public License for more +details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +""" + +from gettext import translation +from pathlib import Path + +t = translation( + "rougail_structural_bitwarden", str(Path(__file__).parent / "locale"), fallback=True +) + +_ = t.gettext diff --git a/src/rougail/structural_bitwarden/locale/fr/LC_MESSAGES/rougail_structural_bitwarden.mo b/src/rougail/structural_bitwarden/locale/fr/LC_MESSAGES/rougail_structural_bitwarden.mo new file mode 100644 index 0000000..9756bb6 Binary files /dev/null and b/src/rougail/structural_bitwarden/locale/fr/LC_MESSAGES/rougail_structural_bitwarden.mo differ diff --git a/src/rougail/structural_bitwarden/object_model.py b/src/rougail/structural_bitwarden/object_model.py deleted file mode 100644 index ce7370b..0000000 --- a/src/rougail/structural_bitwarden/object_model.py +++ /dev/null @@ -1,31 +0,0 @@ -""" -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 typing import Optional -from pydantic import BaseModel - - -class Variable(BaseModel): - bitwarden: bool=False - - -__all__ = ('Variable',) - -