Exemple #1
0
    def real_name(self) -> str:
        if self.namespace is None:
            raise SchemaValueError("Wildcards namespace can't be None.")

        namespace = (self.namespace[2:]
                     if self.namespace.startswith("##") else self.namespace)
        return f"{namespace}_element"
Exemple #2
0
    def real_name(self) -> str:
        name = getattr(self, "name", None) or getattr(self, "ref", None)
        if name:
            return name

        raise SchemaValueError(
            f"Schema class `{self.class_name}` unknown real name.")
Exemple #3
0
    def module(self) -> str:
        origin = self.location or self.target_namespace
        if not origin:
            raise SchemaValueError("Unknown schema module.")

        module = origin.split("/")[-1]
        return module[:-4] if module.endswith(".xsd") else module
Exemple #4
0
    def module(self) -> str:
        if self.location:
            return self.location.name

        if self.target_namespace:
            return Path(self.target_namespace).stem

        raise SchemaValueError("Unknown schema module")
Exemple #5
0
    def real_type(self) -> str:
        """
        Return the real type for this element.

        :raises SchemaValueError: when attribute instance is missing implementation.
        """
        raise SchemaValueError(
            f"Schema class `{self.class_name}` unknown real type.")
Exemple #6
0
    def module(self) -> str:
        """Return a valid module name based on the instance location uri."""
        location = getattr(self, "location", None)
        if not location:
            raise SchemaValueError(
                f"{self.__class__.__name__} empty location.")

        module = location.split("/")[-1]
        name, extension = os.path.splitext(module)
        return name if extension in (".xsd", ".wsdl") else module
Exemple #7
0
    def real_name(self) -> str:
        """
        Return the real name for this element by looking by looking either to
        the name or ref attribute value.

        :raises SchemaValueError: when instance has no name/ref attribute.
        """
        name = getattr(self, "name", None) or getattr(self, "ref", None)
        if name:
            return text.suffix(name)

        raise SchemaValueError(
            f"Schema class `{self.class_name}` unknown real name.")
Exemple #8
0
 def real_type(self) -> Optional[str]:
     raise SchemaValueError(
         f"Schema class `{self.class_name}` unknown real type.")