"""
Silique (https://www.silique.fr)
Copyright (C) 2026

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.output_doc.i18n import _
try:
    from rougail.output_doc.annotator import Annotator as AnnotatorDoc
except:
    AnnotatorDoc = None


if AnnotatorDoc:
    class Annotator(AnnotatorDoc):
        level = 96

        def __init__(self, *args):
            super().__init__(*args, force_default_value=True, force_display_unknown_optional_variable=True)
#            host_namespace = self.objectspace.rougailconfig["ansible.inventory.host_namespace"]
#            namespaces = self.objectspace.parents["."]
#            if not namespaces:
#                msg = _("no namespace configured")
#                raise DictConsistencyError(msg, 300, [])
#            first_namespace = self.objectspace.paths[namespaces[0]]
#            if first_namespace.name != first_namespace.namespace:
#                msg = _("no namespace configured")
#                raise DictConsistencyError(msg, 301, first_namespace.xmlfiles)
#            if host_namespace not in namespaces:
#                msg = _('cannot find host namespace "{0}"').format(host_namespace)
#                raise DictConsistencyError(msg, 302, first_namespace.xmlfiles)
#            hostnames = f"{host_namespace}.hostnames"
#            if hostnames not in self.objectspace.parents[host_namespace]:
#                hosts = self.objectspace.paths[host_namespace]
#                msg = _('malformated host namespace "{0}", should have the "hostnames" key').format(host_namespace)
#                raise DictConsistencyError(msg, 303, hosts.xmlfiles)
#            for hostname in self.objectspace.parents[hostnames]:
#                hosts = self.objectspace.paths[hostname]
#                if hostname not in self.objectspace.families:
#                    msg = _('malformated host namespace "{0}", "{1}" is not a family').format(host_namespace, hostname)
#                    raise DictConsistencyError(msg, 304, hosts.xmlfiles)
#                hosts_name = f"{hostname}.hosts"
#                if hosts_name in self.objectspace.parents[hostname]:
#                    hosts_obj = self.objectspace.paths[hosts_name]
#                    if hosts_obj.type != "domainname":
#                        msg = _('malformated ansible hosts "{0}", is not a "domainname" variable').format(hosts_name)
#                        raise DictConsistencyError(msg, 305, hosts_obj.xmlfiles)
#                    if hosts_obj.multi is False:
#                        msg = _('malformated ansible hosts "{0}", it must be a multiple variable').format(hosts_name)
#                        raise DictConsistencyError(msg, 306, hosts_obj.xmlfiles)
