public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Slava Bacherikov" <slava@bacherikov.org.ua>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/libs/
Date: Mon, 18 Jun 2012 21:26:02 +0000 (UTC)	[thread overview]
Message-ID: <1340037500.280b86959ff7a179802ede7f04b9d23881ab151a.bacher09@gentoo> (raw)

commit:     280b86959ff7a179802ede7f04b9d23881ab151a
Author:     Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jun 18 16:38:20 2012 +0000
Commit:     Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jun 18 16:38:20 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=280b8695

Collect more info about repository

---
 gpackages/apps/packages/managers.py |   10 +++++++++-
 gpackages/apps/packages/models.py   |   33 +++++++++++++++++++++++++++++++++
 gpackages/apps/packages/scan.py     |    2 +-
 gpackages/libs/porttree.py          |    7 +++++++
 4 files changed, 50 insertions(+), 2 deletions(-)

diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index ca1561c..45033d8 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -112,7 +112,15 @@ class VirtualPackageMixin(object):
 
         return super(VirtualPackageMixin, self).filter(*args, **kwargs)
 
+class RepositoryMixin(object):
+    def filter(self, *args, **kwargs):
+        repo = get_from_kwargs_and_del('repo', kwargs)
+        if repo is not None:
+            kwargs['name'] = repo.name
+        return super(RepositoryMixin, self).filter(*args, **kwargs)
+
 
 _gen_all_query_and_manager('Mixin', 'QuerySet', 'Manager',
                            PackageMixin, KeywordMixin, EbuildMixin, HerdsMixin,
-                           MaintainerMixin, VirtualPackageMixin)
+                           MaintainerMixin, VirtualPackageMixin,
+                           RepositoryMixin)

diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index c2b62ac..6d96b42 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -29,8 +29,41 @@ class ArchesModel(models.Model):
         return self.name
 
 class RepositoryModel(AbstractDateTimeModel):
+    QUALITY_CHOICES = ( (0, 'stable'),
+                        (1, 'testing'),
+                        (2, 'experimental'),
+                      )
+
+    def __init__(self, *args, **kwargs):
+        repo = get_from_kwargs_and_del('repo', kwargs)
+        super(RepositoryModel, self).__init__(*args, **kwargs)
+
+        if repo is not None:
+            self.init_by_repo(repo)
+
     name = models.CharField(unique = True, max_length = 60)
+
+    # Additional info
     description = models.TextField(blank = True, null = True)
+    owner_name = models.CharField(max_length = 65 , blank = True, null = True)
+    owner_email = models.EmailField(blank = True, null = True)
+    homepage = models.URLField(blank = True, null = True)
+    official = models.BooleanField(default = False)
+    quality = models.PositiveSmallIntegerField(choices = QUALITY_CHOICES)
+
+    objects = managers.RepositoryManager()
+
+    def init_by_repo(self, repo):
+        self.name = repo.name
+        self.update_metadata(repo)
+
+    def update_metadata(self, repo):
+        self.description = repo.metadata.description
+        self.owner_name = repo.metadata.owner_name
+        self.owner_email = repo.metadata.owner_email
+        self.homepage = repo.metadata.homepage
+        self.official = repo.metadata.official
+        self.quality = repo.metadata.int_quality
 
     def __unicode__(self):
         return self.name

diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index d716380..6d14237 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -310,7 +310,7 @@ class Scanner(object):
         self.output("Scaning repository '%s'\n", repo.name, 3)
 
         repo_obj, repo_created = models.RepositoryModel \
-            .objects.get_or_create(name = repo.name)
+            .objects.get_or_create(repo = repo)
 
         if not repo_created:
             #Update modification time

diff --git a/gpackages/libs/porttree.py b/gpackages/libs/porttree.py
index 995ef91..75812ab 100644
--- a/gpackages/libs/porttree.py
+++ b/gpackages/libs/porttree.py
@@ -20,6 +20,9 @@ from my_etree import etree
 # Validators
 from validators import validate_url, validate_url, ValidationError
 
+# Repo info
+from repo_info import TreeMetadata
+
 __all__ = ('Portage','PortTree', 'Category', 'Package', 'Ebuild')
 
 BINDB = portage.db[portage.root]["bintree"].dbapi
@@ -257,6 +260,10 @@ class PortTree(ToStrMixin):
         return self.porttree
 
     @cached_property
+    def metadata(self):
+        return TreeMetadata(self.name)
+
+    @cached_property
     def use_desc(self):
         return _get_info_by_func(get_uses_info,
                                  self.porttree_path,



             reply	other threads:[~2012-06-18 21:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-18 21:26 Slava Bacherikov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-06-12 18:34 [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/, gpackages/libs/ Slava Bacherikov
2012-06-12 18:34 Slava Bacherikov
2012-06-12 18:34 Slava Bacherikov
2012-06-07 22:48 Slava Bacherikov
2012-06-06 22:48 Slava Bacherikov
2012-06-05 20:48 Slava Bacherikov
2012-06-05 15:49 Slava Bacherikov
2012-06-03 19:34 Slava Bacherikov
2012-05-29 21:34 Slava Bacherikov
2012-05-28 20:32 Slava Bacherikov
2012-05-28 17:00 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=1340037500.280b86959ff7a179802ede7f04b9d23881ab151a.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