diff options
Diffstat (limited to 'tatt/tool.py')
-rw-r--r-- | tatt/tool.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tatt/tool.py b/tatt/tool.py index 450ed6a..1322315 100644 --- a/tatt/tool.py +++ b/tatt/tool.py @@ -1,3 +1,5 @@ +import os + """ Helper functions used in tatt""" ## Getting unique elements of a list ## @@ -17,3 +19,21 @@ def unique(seq, idfun=None): seen[marker] = 1 result.append(item) return result + +def get_repo_dir(repodir): + # Prefer the repo dir in the config + if repodir: + if os.path.isdir(repodir): + return repodir + else: + raise ValueError("Repo dir does not seem to be a directory") + + # No path given in config + if os.path.isdir("/var/db/repos/gentoo/"): + print("Using /var/db/repos/gentoo/ as fallback") + return "/var/db/repos/gentoo" + elif os.path.isdir("/usr/portage/"): + print("Using /usr/portage/ as fallback") + return "/usr/portage/" + + raise ValueError("Repo dir not given and fallbacks failed") |