From: Roland Häder Date: Tue, 2 Jan 2024 19:45:51 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3714bf0e96deb6fea4f02445a4faec1c8ca0c633;p=fba.git Continued: - need to remove prefix "re:" before cleaning up software, else all software is called "re" - added alias "lovers" for "misskey" --- diff --git a/fba/helpers/software.py b/fba/helpers/software.py index dbb4ccc..5c0f6bb 100644 --- a/fba/helpers/software.py +++ b/fba/helpers/software.py @@ -61,7 +61,8 @@ _misskey_aliases = [ "catodon", "lycheebridge", "goblin", - "miraiskey" + "miraiskey", + "lovers" ] @lru_cache @@ -72,100 +73,101 @@ def alias(software: str) -> str: raise ValueError(f"software[]='{type(software)}' is not type 'str'") elif software == "": raise ValueError("Parameter 'software' is empty") - - key = software + elif software.startswith("re:"): + logger.debug("Cutting prefix 're:' from software='%s' ...", software) + software = software.split(":")[1] logger.debug("software='%s'- BEFORE!", software) - software = tidyup.domain(software) - logger.debug("software='%s'- AFTER!", software) - - if software in ["akkoma", "rebased", "akkounfucked", "ched", "incestoma", "revolver"]: - logger.debug("Setting pleroma: software='%s'", software) - software = "pleroma" - elif "radiant" in software: - logger.debug("Setting radiant: software='%s'", software) - software = "radiant" - elif software in ["hometown", "ecko", "fedibird", "glitchcafe"] or "되는 마스토돈" in software or "mastodon" in software: - logger.debug("Setting mastodon: software='%s'", software) - software = "mastodon" - elif software in _misskey_aliases or "shumihub" in software or "мисскей" in software or "milkey" in software or "misskey" in software: - logger.debug("Setting misskey: software='%s'", software) - software = "misskey" - elif software in ["runtube.re", "islameye"]: - logger.debug("Setting peertube: software='%s'", software) - software = "peertube" - elif software in ["nextcloud social", "nextcloudpi", "storage share", "nube"] or "nextcloud" in software: - logger.debug("Setting nextcloud: software='%s'", software) - software = "nextcloud" - elif "discourse" in software: - logger.debug("Setting discourse: software='%s'", software) - software = "discourse" - elif software == "activity-relay": - logger.debug("Setting activityrelay: software='%s'", software) - software = "activityrelay" - elif "owncast" in software: - logger.debug("Setting owncast: software='%s'", software) - software = "owncast" - elif software in ["streams-hubzilla-social", "streams13"]: - logger.debug("Setting streams: software='%s'", software) - software = "streams" - elif software == "roadhouse": - logger.debug("Setting hubzilla: software='%s'", software) - software = "hubzilla" - elif software == "takahē": - logger.debug("Setting takahe: software='%s'", software) - software = "takahe" - elif software == "diaspora* social network": - logger.debug("Setting diaspora: software='%s'", software) - software = "diaspora" - elif software == "tkz relay": - logger.debug("Setting aoderelay: software='%s'", software) - software = "aoderelay" - elif software == "gitdab": - logger.debug("Setting forgejo: software='%s'", software) - software = "forgejo" - elif software == "mbin": - logger.debug("Setting kbin: software='%s'", software) - software = "kbin" - elif software == "write.as": - logger.debug("Setting writefreely: software='%s'", software) - software = "writefreely" - elif "gnu social" in software: - logger.debug("Setting gnusocial: software='%s'", software) - software = "gnusocial" - elif software.find("/") > 0: - logger.warning("Spliting of slash: software='%s'", software) - software = software.split("/")[-1] - elif software.find("|") > 0: - logger.warning("Spliting of pipe: software='%s'", software) - software = software.split("|")[0] - elif "powered by" in software: - logger.debug("software='%s' has 'powered by' in it", software) - software = strip_powered_by(software) - elif software.endswith(" experimental"): - logger.debug("software='%s' ends with 'experimental", software) - software = strip_until(software, "experimental") - - if isinstance(software, str) and " by " in software: - logger.debug("software='%s' has ' by ' in it", software) - software = strip_until(software, " by ") - elif isinstance(software, str) and " - " in software: - logger.debug("software='%s' has ' - ' in it", software) - software = strip_until(software, " - ") - elif isinstance(software, str) and " see " in software: - logger.debug("software='%s' has ' see ' in it", software) - software = strip_until(software, " see ") - - logger.debug("software['%s']='%s'", type(software), software) - if software == "": - logger.warning("tidyup.domain() left no software name behind: software='%s'", software) - software = None + cleared = tidyup.domain(software) + logger.debug("cleared='%s'- AFTER!", cleared) + + if cleared in ["akkoma", "rebased", "akkounfucked", "ched", "incestoma", "revolver"]: + logger.debug("Setting pleroma: cleared='%s'", cleared) + cleared = "pleroma" + elif "radiant" in cleared: + logger.debug("Setting radiant: cleared='%s'", cleared) + cleared = "radiant" + elif cleared in ["hometown", "ecko", "fedibird", "glitchcafe"] or "되는 마스토돈" in cleared or "mastodon" in cleared: + logger.debug("Setting mastodon: cleared='%s'", cleared) + cleared = "mastodon" + elif cleared in _misskey_aliases or "shumihub" in cleared or "мисскей" in cleared or "milkey" in cleared or "misskey" in cleared: + logger.debug("Setting misskey: cleared='%s'", cleared) + cleared = "misskey" + elif cleared in ["runtube.re", "islameye"]: + logger.debug("Setting peertube: cleared='%s'", cleared) + cleared = "peertube" + elif cleared in ["nextcloud social", "nextcloudpi", "storage share", "nube"] or "nextcloud" in cleared: + logger.debug("Setting nextcloud: cleared='%s'", cleared) + cleared = "nextcloud" + elif "discourse" in cleared: + logger.debug("Setting discourse: cleared='%s'", cleared) + cleared = "discourse" + elif cleared == "activity-relay": + logger.debug("Setting activityrelay: cleared='%s'", cleared) + cleared = "activityrelay" + elif "owncast" in cleared: + logger.debug("Setting owncast: cleared='%s'", cleared) + cleared = "owncast" + elif cleared in ["streams-hubzilla-social", "streams13"]: + logger.debug("Setting streams: cleared='%s'", cleared) + cleared = "streams" + elif cleared == "roadhouse": + logger.debug("Setting hubzilla: cleared='%s'", cleared) + cleared = "hubzilla" + elif cleared == "takahē": + logger.debug("Setting takahe: cleared='%s'", cleared) + cleared = "takahe" + elif cleared == "diaspora* social network": + logger.debug("Setting diaspora: cleared='%s'", cleared) + cleared = "diaspora" + elif cleared == "tkz relay": + logger.debug("Setting aoderelay: cleared='%s'", cleared) + cleared = "aoderelay" + elif cleared == "gitdab": + logger.debug("Setting forgejo: cleared='%s'", cleared) + cleared = "forgejo" + elif cleared == "mbin": + logger.debug("Setting kbin: cleared='%s'", cleared) + cleared = "kbin" + elif cleared == "write.as": + logger.debug("Setting writefreely: cleared='%s'", cleared) + cleared = "writefreely" + elif "gnu social" in cleared: + logger.debug("Setting gnusocial: cleared='%s'", cleared) + cleared = "gnusocial" + elif cleared.find("/") > 0: + logger.warning("Spliting of slash: cleared='%s'", cleared) + cleared = cleared.split("/")[-1] + elif cleared.find("|") > 0: + logger.warning("Spliting of pipe: cleared='%s'", cleared) + cleared = cleared.split("|")[0] + elif "powered by" in cleared: + logger.debug("cleared='%s' has 'powered by' in it", cleared) + cleared = strip_powered_by(cleared) + elif cleared.endswith(" experimental"): + logger.debug("cleared='%s' ends with 'experimental", cleared) + cleared = strip_until(cleared, "experimental") + + if isinstance(cleared, str) and " by " in cleared: + logger.debug("cleared='%s' has ' by ' in it", cleared) + cleared = strip_until(cleared, " by ") + elif isinstance(cleared, str) and " - " in cleared: + logger.debug("cleared='%s' has ' - ' in it", cleared) + cleared = strip_until(cleared, " - ") + elif isinstance(cleared, str) and " see " in cleared: + logger.debug("cleared='%s' has ' see ' in it", cleared) + cleared = strip_until(cleared, " see ") + + logger.debug("cleared['%s']='%s'", type(cleared), cleared) + if cleared == "": + logger.warning("tidyup.domain() left no cleared name behind: cleared='%s'", cleared) + cleared = None else: - logger.debug("software='%s' is being cleaned up further ...") - software = software.rstrip("!").strip() + logger.debug("cleared='%s' is being cleaned up further ...", cleared) + cleared = cleared.rstrip("!").strip() - logger.debug("software[%s]='%s' - EXIT!", type(software), software) - return software + logger.debug("cleared[%s]='%s' - EXIT!", type(cleared), cleared) + return cleared def strip_hosted_on(software: str) -> str: logger.debug("software='%s' - CALLED!", software)