From: "Slava Bacherikov" <slava@bacherikov.org.ua>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/, gpackages/libs/package_info/generic_metadata/
Date: Tue, 26 Jun 2012 18:48:49 +0000 (UTC) [thread overview]
Message-ID: <1340712724.12352ec6c35112360dbf3567f823a852ac576f61.bacher09@gentoo> (raw)
commit: 12352ec6c35112360dbf3567f823a852ac576f61
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jun 26 12:12:04 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jun 26 12:12:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=12352ec6
Check layman repo by location.
---
.../package_info/generic_metadata/repo_info.py | 32 +++++++++++++++----
gpackages/libs/package_info/mixins.py | 2 +-
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/gpackages/libs/package_info/generic_metadata/repo_info.py b/gpackages/libs/package_info/generic_metadata/repo_info.py
index d9ba513..9bcb22d 100644
--- a/gpackages/libs/package_info/generic_metadata/repo_info.py
+++ b/gpackages/libs/package_info/generic_metadata/repo_info.py
@@ -1,5 +1,6 @@
from __future__ import absolute_import
from functools import total_ordering
+import os.path
# Layman API
from layman.api import LaymanAPI
layman_api = LaymanAPI()
@@ -33,7 +34,7 @@ class Enum(object):
self.num_dict = dct2
def get_as_tuple(self):
- "Return tuple to use as choices in django model"
+ "Return tuple to use as choices in django model"
return tuple([(num, item) for num, item in enumerate(self.list)])
REPO_TYPE = ( 'git',
@@ -96,12 +97,16 @@ class TreeMetadata(ToStrMixin):
statuses = {'official': 0, 'unofficial': 1}
qualities = {'stable': 0 , 'testing': 1, 'experimental': 2}
- def __init__(self, repo_name, dct = None):
+ storage_path = os.path.join(layman_api.config['storage'], '')
+ installed = frozenset(layman_api.get_installed())
+ available = frozenset(layman_api.get_available())
+
+ def __init__(self, repo_name, repo_location = None, dct = None):
"""Args:
repo_name -- repository name
dct -- dict of params, could be None that it will be calculated
"""
- repo_name = self._find_real_repo_name(repo_name)
+ repo_name = self._find_real_repo_name(repo_name, repo_location)
self.repo_name = repo_name
if dct is None:
@@ -109,17 +114,30 @@ class TreeMetadata(ToStrMixin):
self._dct = dct
- def _find_real_repo_name(self, repo_name):
+ def _find_name_by_path(self, repo_name, repo_location):
+ try_name = repo_location.replace(self.storage_path, '')
+ if try_name in self.installed:
+ return try_name
+ else:
+ return None
+
+ def _find_real_repo_name(self, repo_name, repo_location = None):
gen_str = 'gentoo-'
+ try_name = None
+ if repo_location is not None:
+ try_name = self._find_name_by_path(repo_name, repo_location)
+
if repo_name == 'gentoo':
return repo_name
- elif layman_api.is_repo(repo_name):
+ elif try_name is not None:
+ return try_name
+ elif repo_name in self.available:
return repo_name
- elif layman_api.is_repo(gen_str + repo_name):
+ elif (gen_str + repo_name) in self.available:
return gen_str + repo_name
elif repo_name.startswith(gen_str) and \
- layman_api.is_repo(repo_name[len(gen_str):]):
+ (repo_name[len(gen_str):]) in self.available:
return repo_name[len(gen_str):]
diff --git a/gpackages/libs/package_info/mixins.py b/gpackages/libs/package_info/mixins.py
index 610e89e..77972ba 100644
--- a/gpackages/libs/package_info/mixins.py
+++ b/gpackages/libs/package_info/mixins.py
@@ -103,7 +103,7 @@ class PortTreeBaseMixin(ToStrMixin):
@cached_property
def metadata(self):
- return TreeMetadata(self.name)
+ return TreeMetadata(self.name, repo_location = self.porttree_path)
@cached_property
def use_desc(self):
next reply other threads:[~2012-06-26 18:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-26 18:48 Slava Bacherikov [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-07-06 23:09 [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/libs/package_info/, gpackages/libs/package_info/generic_metadata/ Slava Bacherikov
2012-07-05 23:27 Slava Bacherikov
2012-07-03 21:08 Slava Bacherikov
2012-06-24 23:21 Slava Bacherikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340712724.12352ec6c35112360dbf3567f823a852ac576f61.bacher09@gentoo \
--to=slava@bacherikov.org.ua \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox