2018-01-26 17:02:47 +01:00
|
|
|
#!/usr/bin/env python
|
2024-01-17 13:13:14 +01:00
|
|
|
|
|
|
|
from __future__ import annotations
|
2018-01-26 17:02:47 +01:00
|
|
|
|
|
|
|
try:
|
2020-01-23 10:27:40 +01:00
|
|
|
from pymispgalaxies import Clusters # type: ignore
|
2018-01-26 17:02:47 +01:00
|
|
|
has_pymispgalaxies = True
|
|
|
|
except ImportError:
|
|
|
|
has_pymispgalaxies = False
|
|
|
|
|
|
|
|
try:
|
2020-01-23 10:27:40 +01:00
|
|
|
from pytaxonomies import Taxonomies # type: ignore
|
2018-01-26 17:02:47 +01:00
|
|
|
has_pymispgalaxies = True
|
|
|
|
except ImportError:
|
|
|
|
has_pymispgalaxies = False
|
|
|
|
|
|
|
|
|
2024-02-01 14:40:12 +01:00
|
|
|
def revert_tag_from_galaxies(tag: str) -> list[str]:
|
2018-01-26 17:02:47 +01:00
|
|
|
clusters = Clusters()
|
|
|
|
try:
|
|
|
|
return clusters.revert_machinetag(tag)
|
|
|
|
except Exception:
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
2024-02-01 14:40:12 +01:00
|
|
|
def revert_tag_from_taxonomies(tag: str) -> list[str]:
|
2018-01-26 17:02:47 +01:00
|
|
|
taxonomies = Taxonomies()
|
|
|
|
try:
|
|
|
|
return taxonomies.revert_machinetag(tag)
|
|
|
|
except Exception:
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
2024-02-01 14:40:12 +01:00
|
|
|
def search_taxonomies(query: str) -> list[str]:
|
2018-01-26 17:02:47 +01:00
|
|
|
taxonomies = Taxonomies()
|
|
|
|
found = taxonomies.search(query)
|
|
|
|
if not found:
|
|
|
|
found = taxonomies.search(query, expanded=True)
|
|
|
|
return found
|
|
|
|
|
|
|
|
|
2024-02-01 14:40:12 +01:00
|
|
|
def search_galaxies(query: str) -> list[str]:
|
2018-01-26 17:02:47 +01:00
|
|
|
clusters = Clusters()
|
|
|
|
return clusters.search(query)
|