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"
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.")
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
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")
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.")
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
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.")
def real_type(self) -> Optional[str]: raise SchemaValueError( f"Schema class `{self.class_name}` unknown real type.")