aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMykyta Holubakha <hilobakho@gmail.com>2017-06-03 01:30:39 +0300
committerMykyta Holubakha <hilobakho@gmail.com>2017-06-03 01:30:39 +0300
commiteeb64c87fe6e99dd1d9c219a1a96a9718e467f6b (patch)
treebef9e6d027a97156a41e67b12904983c7adf1a35
parentFix name (diff)
downloadpomu-eeb64c87fe6e99dd1d9c219a1a96a9718e467f6b.tar.gz
pomu-eeb64c87fe6e99dd1d9c219a1a96a9718e467f6b.tar.bz2
pomu-eeb64c87fe6e99dd1d9c219a1a96a9718e467f6b.zip
Separate active pomu repo detection
-rw-r--r--pomu/cli.py12
-rw-r--r--pomu/repo/repo.py6
2 files changed, 12 insertions, 6 deletions
diff --git a/pomu/cli.py b/pomu/cli.py
index a34ab21..3e45f7e 100644
--- a/pomu/cli.py
+++ b/pomu/cli.py
@@ -2,7 +2,7 @@
import click
from pomu.repo.init import init_plain_repo, init_portage_repo
-from pomu.repo.repo import portage_repo_path, portage_repos, pomu_status
+from pomu.repo.repo import portage_repo_path, portage_repos, pomu_status, pomu_active_repo
from pomu.util.result import ResultException
#TODO: global --repo option, (env var?)
@@ -63,9 +63,9 @@ def status(globalvars):
return
print('pomu is not initialized')
else:
- for repo in portage_repos():
- if pomu_status(portage_repo_path(repo)):
- print('pomu is initialized for repository', repo, 'at', portage_repo_path(repo))
- return
- print('pomu is not initialized')
+ repo = pomu_active_repo()
+ if repo:
+ print('pomu is initialized for repository', repo, 'at', portage_repo_path(repo))
+ else:
+ print('pomu is not initialized')
diff --git a/pomu/repo/repo.py b/pomu/repo/repo.py
index bfa97fe..e8693ce 100644
--- a/pomu/repo/repo.py
+++ b/pomu/repo/repo.py
@@ -18,3 +18,9 @@ def portage_repo_path(repo):
def pomu_status(repo_path):
"""Check if pomu is enabled for a repository at a given path"""
return path.isdir(path.join(repo_path, 'metadata', 'pomu'))
+
+def pomu_active_repo():
+ for repo in portage_repos():
+ if pomu_status(portage_repo_path(repo)):
+ return repo
+ return None