Exemple #1
0
def itemFromUrl(url: QtCore.QUrl) -> Union[Tuple[str, str, str], None]:
    """
		Parses a URL constructed by urlForItem.
		Returns a tuple (module, id, name ) if parsing is successfull, None otherwise.
		@param url: Url which should be parsed.
		@type url: QUrl or String
		@returns: Tuple (module, id, name ) or None
	"""
    if isinstance(url, QtCore.QUrl):
        url = url.toString()
    # Strip host and query-string
    url = url[url.find("/", 7):]
    if "?" in url:
        url = url[:url.find("?")]
    parts = [x for x in url.split("/") if x]
    if len(parts) < 3:
        return None
    if parts[1].lower() != "view":
        return None
    modul = parts[0]
    if modul not in conf.serverConfig["modules"]:  # Unknown module
        return None
    if len(parts) > 3:
        return modul, parts[2], parts[3]
    else:
        return modul, parts[2], ""