* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-27 22:48 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-27 22:48 UTC (permalink / raw
To: gentoo-commits
commit: 3469cbea1cb9b0c17fc656b6925be562dd019b5d
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun May 27 22:25:04 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun May 27 22:25:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=3469cbea
Add simple admin.
---
gpackages/apps/packages/admin.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
new file mode 100644
index 0000000..11a804e
--- /dev/null
+++ b/gpackages/apps/packages/admin.py
@@ -0,0 +1,4 @@
+from django.contrib import admin
+from models import EbuildModel
+
+admin.site.register(EbuildModel)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-28 10:39 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-28 10:39 UTC (permalink / raw
To: gentoo-commits
commit: 38db588b16d5baddc79b9c6472132b4afc069dc7
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon May 28 10:23:13 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon May 28 10:23:13 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=38db588b
changes in packages models
---
gpackages/apps/packages/models.py | 59 ++++++++++++++++++++++++++++---------
1 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 491fb85..5278709 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -3,47 +3,78 @@ from django.db import models
class ArchesModel(models.Model):
name = models.CharField(max_length = 12)
-class Repository(models.Model):
+class RepositoryModel(models.Model):
name = models.CharField(max_length = 60)
- description = models.TextField()
+ description = models.TextField(blank = True, null = True)
# And other fields
class CategoryModel(models.Model):
- category = models.CharField(max_length = 70)
+ category = models.CharField(unique = True, max_length = 70)
+
+ def __unicode__(self):
+ return self.category
+
+ @classmethod
+ def create_by_category(cls, category):
+ category_model = cls.objects.get_or_create(category = category.category)
+ return category_model
class PackageModel(models.Model):
- name = models.CharField(unique = True, max_length = 254)
- category = models.ForeignKey(CategoryModel)
- # Different versions can have different licenses, or homepages.
+ name = models.CharField(unique = True, max_length = 254)
+ category = models.ForeignKey(CategoryModel)
+ changelog = models.TextField(blank = True)
+ changelog_hash = models.CharField(max_length = 128)
+ manifest_hash = models.CharField(max_length = 128)
+ # Different versions can have different licenses, or homepages.
+ def __unicode__(self):
+ return '%s/%s' % (self.category, self.name)
+
+ #@classmethod
+ #def create_by_pakcage(cls, package):
+ #category_object = CategoryModel.create_by_category(package.category)
+ #package_model = c
class UseFlagModel(models.Model):
name = models.CharField(unique = True, max_length = 28)
- description = models.TextField()
+ description = models.TextField(blank = True)
class LicensModel(models.Model):
name = models.CharField(max_length = 40)
#description = TextField()
+
+ def __unicode__(self):
+ return self.name
class MetaDataModel(models.Model):
homepage = models.URLField()
- description = models.TextField()
- changelog = models.TextField()
- changelog_hash = models.CharField(max_length = 128)
- manifest_hash = models.CharField(max_length = 128)
+ description = models.TextField(blank = True, null = True)
# Some other info
class EbuildModel(models.Model):
package = models.ForeignKey(PackageModel)
- repository = models.ForeignKey(Repository)
- version = models.CharField(max_length = 24)
+ repository = models.ForeignKey(RepositoryModel)
+ version = models.CharField(max_length = 16)
+ revision = models.CharField(max_length = 6)
metadata = models.ForeignKey(MetaDataModel)
use_flags = models.ManyToManyField(UseFlagModel)
licenses = models.ManyToManyField(LicensModel)
+ license = models.CharField(max_length = 254, blank = True )
ebuild_hash = models.CharField(max_length = 128)
ebuld_datetime = models.DateTimeField(auto_now = True)
is_deleted = models.BooleanField(default = False)
+ is_masked = models.BooleanField(default = False)
+
+ def __unicode__(self):
+ return '%s-%s' % (self.package, self.version)
+
+ #@classmethod
+ #def create_by_ebuild(cls, ebuild):
+ #ebuild_model = cls()
+ #ebuild_model.is_masked = ebuild.is_masked
+ #ebuild_model.version = ebuild.version
+ #ebuild_model.revision = ebuild.revision
class Keyword(models.Model):
ebuild = models.ForeignKey(EbuildModel)
arch = models.ForeignKey(ArchesModel)
- status = models.SmallIntegerField() # Stable or not, masked
+ is_stable = models.BooleanField()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-28 10:39 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-28 10:39 UTC (permalink / raw
To: gentoo-commits
commit: 988cf938917e73db1c4a680283fe399e8e7ed81d
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon May 28 10:22:48 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon May 28 10:22:48 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=988cf938
Add more models to admin.
---
gpackages/apps/packages/admin.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index 11a804e..e61e613 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -1,4 +1,11 @@
from django.contrib import admin
-from models import EbuildModel
+from models import EbuildModel, PackageModel, LicensModel, CategoryModel, \
+ UseFlagModel, MetaDataModel, RepositoryModel
admin.site.register(EbuildModel)
+admin.site.register(PackageModel)
+admin.site.register(LicensModel)
+admin.site.register(CategoryModel)
+admin.site.register(UseFlagModel)
+admin.site.register(RepositoryModel)
+admin.site.register(MetaDataModel)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-28 17:00 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-28 17:00 UTC (permalink / raw
To: gentoo-commits
commit: 5982c7ecb766ab0c9ebfda896bfb1a8e77806074
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon May 28 16:08:04 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon May 28 16:08:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=5982c7ec
Changes in packages model
---
gpackages/apps/packages/models.py | 37 +++++++++++++++++++++++++++++++------
1 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index b620dcb..a60f6ce 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -1,6 +1,6 @@
from django.db import models
-from porttree import Category
+from porttree import Category, Package
class ArchesModel(models.Model):
name = models.CharField(max_length = 12)
@@ -34,7 +34,23 @@ class CategoryModel(models.Model):
class PackageModel(models.Model):
- name = models.CharField(unique = True, max_length = 254)
+ def __init__(self, *args, **kwargs):
+ # TODO: Bad code, maybe use some library to overload method
+ if len(args)>=1:
+ package_object = args[0]
+
+ if 'package' in kwargs:
+ package_object = kwargs['package']
+
+ if isinstance(package_object, Package):
+ super(PackageModel, self).__init__()
+ self.init_by_package(package_object)
+ else:
+ super(PackageModel, self).__init__(*args, **kwargs)
+
+
+
+ name = models.CharField(max_length = 254)
category = models.ForeignKey(CategoryModel)
changelog = models.TextField(blank = True)
changelog_hash = models.CharField(max_length = 128)
@@ -43,10 +59,17 @@ class PackageModel(models.Model):
def __unicode__(self):
return '%s/%s' % (self.category, self.name)
- #@classmethod
- #def create_by_pakcage(cls, package):
- #category_object = CategoryModel.create_by_category(package.category)
- #package_model = c
+ def init_by_package(self, package):
+ self.name = package.name
+ self.update_info(package)
+ self.category, created = CategoryModel.objects.get_or_create(category = package.category)
+
+ def update_info(self, package):
+ self.changelog_hash = package.changelog_sha1
+ self.manifest_hash = package.manifest_sha1
+
+ class Meta:
+ unique_together = ('name', 'category')
class UseFlagModel(models.Model):
name = models.CharField(unique = True, max_length = 28)
@@ -92,3 +115,5 @@ class Keyword(models.Model):
ebuild = models.ForeignKey(EbuildModel)
arch = models.ForeignKey(ArchesModel)
is_stable = models.BooleanField()
+ class Meta:
+ unique_together = ('ebuild', 'arch')
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-28 17:00 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-28 17:00 UTC (permalink / raw
To: gentoo-commits
commit: f0421b0de870645a8a509a841821fc0c98fa14cb
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon May 28 11:19:18 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon May 28 11:19:18 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=f0421b0d
Change CategoryModel __nit__
---
gpackages/apps/packages/models.py | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 5278709..ce05e2c 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -1,5 +1,7 @@
from django.db import models
+from porttree import Category
+
class ArchesModel(models.Model):
name = models.CharField(max_length = 12)
@@ -9,15 +11,25 @@ class RepositoryModel(models.Model):
# And other fields
class CategoryModel(models.Model):
+ def __init__(self, *args, **kwargs):
+ category_object = None
+
+ if len(args)>=1:
+ category_object = args[0]
+ if 'category_object' in kwargs:
+ category_object = kwargs['category_object']
+
+ if isinstance(category_object, Category):
+ return super(CategoryModel, self).__init__(category = category_object.category)
+ else:
+ return super(CategoryModel, self).__init__(*args, **kwargs)
+
+
category = models.CharField(unique = True, max_length = 70)
def __unicode__(self):
return self.category
- @classmethod
- def create_by_category(cls, category):
- category_model = cls.objects.get_or_create(category = category.category)
- return category_model
class PackageModel(models.Model):
name = models.CharField(unique = True, max_length = 254)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-28 17:00 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-28 17:00 UTC (permalink / raw
To: gentoo-commits
commit: 1b0de88d6aff6c96dfa1e818bf3037a5dda07531
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon May 28 17:00:43 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon May 28 17:00:43 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=1b0de88d
Add get_or_create to manager of PackageModel
---
gpackages/apps/packages/managers.py | 28 ++++++++++++++++++++++++++++
gpackages/apps/packages/models.py | 5 +++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
new file mode 100644
index 0000000..f44ee34
--- /dev/null
+++ b/gpackages/apps/packages/managers.py
@@ -0,0 +1,28 @@
+from django.db import models
+from porttree import Category, Package
+import packages.models
+
+
+class PackageMixin(object):
+ def get_or_create(self, **kwargs):
+ if 'package' in kwargs:
+ po = kwargs['package']
+ if isinstance(po, Package):
+ del kwargs['package']
+ if 'category' not in kwargs:
+ co, created = packages.models.CategoryModel. \
+ objects.get_or_create(category = po.category)
+ kwargs.update({'category': co})
+
+ kwargs.update({'name': po.name})
+ else:
+ raise ValueError("Bad package object")
+
+ return super(PackageMixin, self).get_or_create(**kwargs)
+
+class PackageQuerySet(PackageMixin, models.query.QuerySet):
+ pass
+
+class PackageManager(PackageMixin, models.Manager):
+ def get_query_set(self):
+ return PackageQuerySet(self.model, using=self._db)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index a60f6ce..e51f62f 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -1,6 +1,7 @@
from django.db import models
from porttree import Category, Package
+import managers
class ArchesModel(models.Model):
name = models.CharField(max_length = 12)
@@ -36,6 +37,7 @@ class CategoryModel(models.Model):
class PackageModel(models.Model):
def __init__(self, *args, **kwargs):
# TODO: Bad code, maybe use some library to overload method
+ package_object = None
if len(args)>=1:
package_object = args[0]
@@ -56,6 +58,9 @@ class PackageModel(models.Model):
changelog_hash = models.CharField(max_length = 128)
manifest_hash = models.CharField(max_length = 128)
# Different versions can have different licenses, or homepages.
+
+ objects = managers.PackageManager()
+
def __unicode__(self):
return '%s/%s' % (self.category, self.name)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-28 20:32 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-28 20:32 UTC (permalink / raw
To: gentoo-commits
commit: 3e640062498819c97b9bef24e8dbbc04f847177c
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon May 28 19:09:53 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon May 28 19:09:53 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=3e640062
Add init_by_ebuild method to EbuildModel
---
gpackages/apps/packages/admin.py | 3 +-
gpackages/apps/packages/models.py | 49 +++++++++++++++++++++++++++----------
2 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index e61e613..9f76014 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
from models import EbuildModel, PackageModel, LicensModel, CategoryModel, \
- UseFlagModel, MetaDataModel, RepositoryModel
+ UseFlagModel, RepositoryModel
admin.site.register(EbuildModel)
admin.site.register(PackageModel)
@@ -8,4 +8,3 @@ admin.site.register(LicensModel)
admin.site.register(CategoryModel)
admin.site.register(UseFlagModel)
admin.site.register(RepositoryModel)
-admin.site.register(MetaDataModel)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index e51f62f..8e50eea 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -81,23 +81,18 @@ class UseFlagModel(models.Model):
description = models.TextField(blank = True)
class LicensModel(models.Model):
- name = models.CharField(max_length = 40)
+ name = models.CharField(unique = True, max_length = 40)
#description = TextField()
def __unicode__(self):
return self.name
-class MetaDataModel(models.Model):
- homepage = models.URLField()
- description = models.TextField(blank = True, null = True)
- # Some other info
class EbuildModel(models.Model):
package = models.ForeignKey(PackageModel)
- repository = models.ForeignKey(RepositoryModel)
+ #repository = models.ForeignKey(RepositoryModel)
version = models.CharField(max_length = 16)
revision = models.CharField(max_length = 6)
- metadata = models.ForeignKey(MetaDataModel)
use_flags = models.ManyToManyField(UseFlagModel)
licenses = models.ManyToManyField(LicensModel)
license = models.CharField(max_length = 254, blank = True )
@@ -105,16 +100,44 @@ class EbuildModel(models.Model):
ebuld_datetime = models.DateTimeField(auto_now = True)
is_deleted = models.BooleanField(default = False)
is_masked = models.BooleanField(default = False)
+
+ homepage = models.URLField()
+ description = models.TextField(blank = True, null = True)
def __unicode__(self):
return '%s-%s' % (self.package, self.version)
- #@classmethod
- #def create_by_ebuild(cls, ebuild):
- #ebuild_model = cls()
- #ebuild_model.is_masked = ebuild.is_masked
- #ebuild_model.version = ebuild.version
- #ebuild_model.revision = ebuild.revision
+ def init_by_ebuild(self, ebuild):
+ self.is_masked = ebuild.is_masked
+ self.version = ebuild.version
+ self.revision = ebuild.revision
+ self.license = ebuild.license
+ self.ebuild_hash = ebuild.sha1
+ self.homepage = ebuild.homepage
+ self.description = ebuild.description
+ self.package = PackageModel.objects.get_or_create(package = ebuild.package)[0]
+ self.save()
+ l = []
+ for license in ebuild.licenses:
+ k, created = LicensModel.objects.get_or_create(name = license)
+ if created:
+ k.save()
+ l.append(k)
+
+ self.licenses.add(*l)
+ l = []
+ # TODO: Bad code
+ for use in ebuild.iter_uses():
+ k, created = UseFlagModel.objects.get_or_create(name = use)
+ if created:
+ k.save()
+ l.append(k)
+ self.use_flags.add(*l)
+
+ class Meta:
+ unique_together = ('package', 'version', 'revision')
+
+
class Keyword(models.Model):
ebuild = models.ForeignKey(EbuildModel)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-29 12:24 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-29 12:24 UTC (permalink / raw
To: gentoo-commits
commit: 14341591e6b6bc0d6699ba81ddea8cf26df45384
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue May 29 07:03:48 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue May 29 07:03:48 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=14341591
Add get_or_create for EbuildModel
---
gpackages/apps/packages/managers.py | 50 +++++++++++++++++++++++++----------
gpackages/apps/packages/models.py | 12 ++++++++
2 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index ec3a55b..2d01508 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -4,21 +4,20 @@ import packages.models
class PackageMixin(object):
- def get_or_create(self, **kwargs):
- if 'package' in kwargs:
- po = kwargs['package']
- if isinstance(po, Package):
- del kwargs['package']
- if 'category' not in kwargs:
- co, created = packages.models.CategoryModel. \
- objects.get_or_create(category = po.category)
- kwargs.update({'category': co})
-
- kwargs.update({'name': po.name})
+ def get(self, package = None, *args, **kwargs):
+ if package is not None and isinstance(package, Package):
+ try:
+ category = packages.models.CategoryModel.objects.get(category = package.category)
+ except packages.models.CategoryModel.DoesNotExist:
+ raise self.model.DoesNotExist
+ name = package.name
+ if len(args)>=1:
+ args[0] = name
+ if len(args)>=2:
+ args[1] = category
else:
- raise ValueError("Bad package object")
-
- return super(PackageMixin, self).get_or_create(**kwargs)
+ kwargs.update({'name': name, 'category': category})
+ return super(PackageMixin, self).get(*args, **kwargs)
class PackageQuerySet(PackageMixin, models.query.QuerySet):
pass
@@ -45,3 +44,26 @@ class KeywordQuerySet(KeywordMixin, models.query.QuerySet):
class KeywordManager(KeywordMixin, models.Manager):
def get_query_set(self):
return KeywordQuerySet(self.model, using=self._db)
+
+
+class EbuildMixin(object):
+ def get(self, ebuild=None, *args, **kwargs):
+ if ebuild is not None and isinstance(ebuild, Ebuild):
+ try:
+ package = packages.models.PackageModel.objects.get(package = ebuild.package)
+ except packages.models.PackageModel.DoesNotExist:
+ raise self.model.DoesNotExist
+ version = ebuild.version
+ revision = ebuild.revision
+ kwargs.update({ 'version': version,
+ 'revision': revision,
+ 'package': package })
+ return super(EbuildMixin, self).get(*args, **kwargs)
+
+
+class EbuildQuerySet(EbuildMixin, models.query.QuerySet):
+ pass
+
+class EbuildManager(EbuildMixin, models.Manager):
+ def get_query_set(self):
+ return EbuildQuerySet(self.model, using=self._db)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index e64fcc1..313e77c 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -106,6 +106,18 @@ class EbuildModel(models.Model):
homepage = models.URLField()
description = models.TextField(blank = True, null = True)
+
+ objects = managers.EbuildManager()
+
+ def __init__(self, *args, **kwargs ):
+ # TODO: Bug fix
+ ebuild = None
+ if 'ebuild' in kwargs:
+ ebuild = kwargs['ebuild']
+ del kwargs['ebuild']
+ super(EbuildModel, self).__init__(*args, **kwargs)
+ if ebuild is not None and isinstance(ebuild, Ebuild):
+ self.init_with_keywords(ebuild)
def __unicode__(self):
return '%s-%s' % (self.package, self.version)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-29 12:24 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-29 12:24 UTC (permalink / raw
To: gentoo-commits
commit: fbe0aa4edb0816db1a72fb45b0f581f9a84e9261
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue May 29 07:03:05 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue May 29 07:03:05 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=fbe0aa4e
Litle fixest in model
---
gpackages/apps/packages/models.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 2cf377c..e64fcc1 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -100,7 +100,7 @@ class EbuildModel(models.Model):
licenses = models.ManyToManyField(LicensModel)
license = models.CharField(max_length = 254, blank = True )
ebuild_hash = models.CharField(max_length = 128)
- ebuld_datetime = models.DateTimeField(auto_now = True)
+ ebuild_datetime = models.DateTimeField(auto_now = True)
is_deleted = models.BooleanField(default = False)
is_masked = models.BooleanField(default = False)
@@ -160,7 +160,7 @@ class Keyword(models.Model):
objects = managers.KeywordManager()
def __unicode__(self):
- return ('' if self.is_stable else '~' ) + self.arch
+ return ('' if self.is_stable else '~' ) + str(self.arch)
def init_by_keyword(self, keyword, ebuild):
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-29 12:24 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-29 12:24 UTC (permalink / raw
To: gentoo-commits
commit: c8c247a88f4def5b7203da619cb5247204000f4a
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue May 29 12:24:00 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue May 29 12:24:00 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=c8c247a8
Rewrite managers.
---
gpackages/apps/packages/managers.py | 35 ++++++++++++++++-------------------
1 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index 2d01508..dd9c2cb 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -3,6 +3,13 @@ from porttree import Category, Package, Ebuild, Keyword
import packages.models
+def _gen_query_and_manager(MixinClass, QueryClassName, ManagerClassName):
+ QueryClass = type(QueryClassName, (MixinClass, models.query.QuerySet), {})
+ ManagerClass = type(ManagerClassName, (MixinClass, models.Manager),{
+ 'get_query_set': lambda self: QueryClass(self.model, using=self._db)
+ })
+ return QueryClass, ManagerClass
+
class PackageMixin(object):
def get(self, package = None, *args, **kwargs):
if package is not None and isinstance(package, Package):
@@ -19,13 +26,9 @@ class PackageMixin(object):
kwargs.update({'name': name, 'category': category})
return super(PackageMixin, self).get(*args, **kwargs)
-class PackageQuerySet(PackageMixin, models.query.QuerySet):
- pass
-
-class PackageManager(PackageMixin, models.Manager):
- def get_query_set(self):
- return PackageQuerySet(self.model, using=self._db)
-
+PackageQuerySet, PackageManager = _gen_query_and_manager(PackageMixin,
+ 'PackageQuerySet',
+ 'PackageManager')
class KeywordMixin(object):
def get_or_create(self, keyword=None, **kwargs):
@@ -38,13 +41,9 @@ class KeywordMixin(object):
return super(KeywordMixin, self).get_or_create(**kwargs)
-class KeywordQuerySet(KeywordMixin, models.query.QuerySet):
- pass
-
-class KeywordManager(KeywordMixin, models.Manager):
- def get_query_set(self):
- return KeywordQuerySet(self.model, using=self._db)
-
+KeywordQuerySet, KeywordManager = _gen_query_and_manager(KeywordMixin,
+ 'KeywordQuerySet',
+ 'KeywordManager')
class EbuildMixin(object):
def get(self, ebuild=None, *args, **kwargs):
@@ -61,9 +60,7 @@ class EbuildMixin(object):
return super(EbuildMixin, self).get(*args, **kwargs)
-class EbuildQuerySet(EbuildMixin, models.query.QuerySet):
- pass
-class EbuildManager(EbuildMixin, models.Manager):
- def get_query_set(self):
- return EbuildQuerySet(self.model, using=self._db)
+EbuildQuerySet, EbuildManager = _gen_query_and_manager(EbuildMixin,
+ 'EbuildQuerySet',
+ 'EbuildManager')
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-29 13:38 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-29 13:38 UTC (permalink / raw
To: gentoo-commits
commit: ad99f68732cca8ee6a530a006896d90e91f6c33c
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue May 29 13:06:24 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue May 29 13:06:24 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=ad99f687
Change limits for long arches like sparc64-solaris
---
gpackages/apps/packages/models.py | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 313e77c..1d2fbe7 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -4,7 +4,7 @@ from porttree import Category, Package, Ebuild
import managers
class ArchesModel(models.Model):
- name = models.CharField(unique = True, max_length = 12)
+ name = models.CharField(unique = True, max_length = 22)
def __unicode__(self):
return self.name
@@ -80,8 +80,11 @@ class PackageModel(models.Model):
unique_together = ('name', 'category')
class UseFlagModel(models.Model):
- name = models.CharField(unique = True, max_length = 28)
+ name = models.CharField(unique = True, max_length = 32)
description = models.TextField(blank = True)
+
+ def __unicode__(self):
+ return self.name
class LicensModel(models.Model):
name = models.CharField(unique = True, max_length = 40)
@@ -104,7 +107,7 @@ class EbuildModel(models.Model):
is_deleted = models.BooleanField(default = False)
is_masked = models.BooleanField(default = False)
- homepage = models.URLField()
+ homepage = models.URLField(blank = True, null = True)
description = models.TextField(blank = True, null = True)
objects = managers.EbuildManager()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-29 21:34 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-29 21:34 UTC (permalink / raw
To: gentoo-commits
commit: b19a891069ed4b9bfa909e00501c47443e3710ff
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue May 29 17:37:48 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue May 29 17:37:48 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=b19a8910
Extend manager.
---
gpackages/apps/packages/managers.py | 40 ++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index a9b514b..6e69007 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -1,4 +1,4 @@
-from django.db import models
+from django.db import models, connections, router, transaction, IntegrityError
from porttree import Category, Package, Ebuild, Keyword
import packages.models
@@ -46,6 +46,44 @@ KeywordQuerySet, KeywordManager = _gen_query_and_manager(KeywordMixin,
'KeywordManager')
class EbuildMixin(object):
+ def create(self, **kwargs):
+ if 'ebuild' in kwargs:
+ obj = self.model(**kwargs)
+ else:
+ obj = super(EbuildMixin, self).create(**kwargs)
+ return obj
+
+ def get_or_create(self, **kwargs):
+ assert kwargs, \
+ 'get_or_create() must be passed at least one keyword argument'
+ defaults = kwargs.pop('defaults', {})
+ lookup = kwargs.copy()
+ for f in self.model._meta.fields:
+ if f.attname in lookup:
+ lookup[f.name] = lookup.pop(f.attname)
+ try:
+ self._for_write = True
+ return self.get(**lookup), False
+ except self.model.DoesNotExist:
+ try:
+ params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
+ params.update(defaults)
+ obj = self.model(**params)
+ if 'ebuild' not in kwargs:
+ obj.save(force_insert=True, using=self.db)
+ sid = transaction.savepoint(using=self.db)
+ transaction.savepoint_commit(sid, using=self.db)
+ return obj, True
+ except IntegrityError as e:
+ transaction.savepoint_rollback(sid, using=self.db)
+ exc_info = sys.exc_info()
+ try:
+ return self.get(**lookup), False
+ except self.model.DoesNotExist:
+ # Re-raise the IntegrityError with its original traceback.
+ raise exc_info[1], None, exc_info[2]
+
+
def get(self, ebuild=None, *args, **kwargs):
if ebuild is not None and isinstance(ebuild, Ebuild):
try:
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-05-31 13:34 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-05-31 13:34 UTC (permalink / raw
To: gentoo-commits
commit: cd6f1e10b426ab50ae4d0d9040adf3e07f6747b1
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed May 30 12:08:29 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed May 30 12:08:29 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=cd6f1e10
Optimize getting by object.
---
gpackages/apps/packages/managers.py | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index 6e69007..464b6ce 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -13,17 +13,15 @@ def _gen_query_and_manager(MixinClass, QueryClassName, ManagerClassName):
class PackageMixin(object):
def get(self, package = None, *args, **kwargs):
if package is not None and isinstance(package, Package):
- try:
- category = packages.models.CategoryModel.objects.get(category = package.category)
- except packages.models.CategoryModel.DoesNotExist:
- raise self.model.DoesNotExist
+ if 'category' not in kwargs:
+ kwargs.update({'category__category' : package.category})
name = package.name
if len(args)>=1:
args[0] = name
if len(args)>=2:
args[1] = category
else:
- kwargs.update({'name': name, 'category': category})
+ kwargs.update({'name': name})
return super(PackageMixin, self).get(*args, **kwargs)
PackageQuerySet, PackageManager = _gen_query_and_manager(PackageMixin,
@@ -68,10 +66,10 @@ class EbuildMixin(object):
try:
params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
params.update(defaults)
+ sid = transaction.savepoint(using=self.db)
obj = self.model(**params)
if 'ebuild' not in kwargs:
obj.save(force_insert=True, using=self.db)
- sid = transaction.savepoint(using=self.db)
transaction.savepoint_commit(sid, using=self.db)
return obj, True
except IntegrityError as e:
@@ -84,17 +82,18 @@ class EbuildMixin(object):
raise exc_info[1], None, exc_info[2]
- def get(self, ebuild=None, *args, **kwargs):
+ def get(self, ebuild=None,package = None, *args, **kwargs):
if ebuild is not None and isinstance(ebuild, Ebuild):
- try:
- package = packages.models.PackageModel.objects.get(package = ebuild.package)
- except packages.models.PackageModel.DoesNotExist:
- raise self.model.DoesNotExist
+ if package is None:
+ kwargs.update({
+ 'package__category__category': ebuild.package.category,
+ 'package__name': ebuild.package.name })
+ else:
+ kwargs.update({'package': package})
version = ebuild.version
revision = ebuild.revision
kwargs.update({ 'version': version,
- 'revision': revision,
- 'package': package })
+ 'revision': revision })
return super(EbuildMixin, self).get(*args, **kwargs)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-03 13:19 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-03 13:19 UTC (permalink / raw
To: gentoo-commits
commit: 0d92c5b317de7af064dea7b14c0cce0b4b926430
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jun 3 12:47:16 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jun 3 12:47:16 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=0d92c5b3
Changes in models HerdsModel and MaintainerModel
---
gpackages/apps/packages/managers.py | 24 +++++++++++++++++++
gpackages/apps/packages/models.py | 44 +++++++++++++++++++++++++++++++++-
2 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index 464b6ce..f613df2 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -101,3 +101,27 @@ class EbuildMixin(object):
EbuildQuerySet, EbuildManager = _gen_query_and_manager(EbuildMixin,
'EbuildQuerySet',
'EbuildManager')
+
+class HerdsMixin(object):
+ def filter(self, *args, **kwargs):
+ if 'herd__in' in kwargs:
+ herds = kwargs['herd__in']
+ del kwargs['herd__in']
+ kwargs['name__in'] = herds
+ return super(HerdsMixin, self).filter(*args, **kwargs)
+
+HerdsQuerySet, HerdsManager = _gen_query_and_manager(HerdsMixin,
+ 'HerdsQuerySet',
+ 'HerdsManager')
+
+class MaintainerMixin(object):
+ def filter(self, *args, **kwargs):
+ if 'maintainer__in' in kwargs:
+ maintars = kwargs['maintainer__in']
+ del kwargs['maintainer__in']
+ kwargs['email__in'] = maintars
+ return super(MaintainerMixin, self).filter(*args, **kwargs)
+
+MaintainerQuerySet, MaintainerManager = _gen_query_and_manager(MaintainerMixin,
+ 'MaintainerQuerySet',
+ 'MaintainerManager')
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index e315c6b..2ad8faa 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -221,13 +221,53 @@ class Keyword(models.Model):
class MaintainerModel(models.Model):
- name = models.CharField( unique = True, max_length = 255)
- email = models.EmailField()
+
+ def __init__(self, *args, **kwargs):
+ #TODO: Bad code, maybe use some libraries for overload methods
+ maintainer = None
+ if 'maintainer' in kwargs:
+ maintainer = kwargs['maintainer']
+ del kwargs['maintainer']
+ super(MaintainerModel, self).__init__(*args, **kwargs)
+ if maintainer is not None:
+ self.init_by_maintainer(maintainer)
+
+ name = models.CharField(max_length = 255, blank = True, null = True)
+ email = models.EmailField(unique = True)
role = models.TextField(blank = True, null = True)
+ objects = managers.MaintainerManager()
+
+ def init_by_maintainer(self, maintainer):
+ self.name = maintainer.name
+ self.email = maintainer.email
+ self.role = maintainer.role
+
+ def __unicode__(self):
+ return ':'.join((unicode(self.name), self.email))
+
class HerdsModel(models.Model):
+
+ def __init__(self, *args, **kwargs):
+ herd = None
+ if 'herd' in kwargs:
+ herd = kwargs['herd']
+ del kwargs['herd']
+ super(HerdsModel, self).__init__(*args, **kwargs)
+ if herd is not None:
+ self.init_by_herd(herd)
+
name = models.CharField(unique = True, max_length = 150)
email = models.EmailField()
description = models.TextField(blank = True, null = True)
maintainers = models.ManyToManyField(MaintainerModel, blank = True)
+ objects = managers.HerdsManager()
+
+ def init_by_herd(self, herd):
+ self.name = herd.name
+ self.email = herd.email
+ self.description = herd.description
+
+ def __unicode__(self):
+ return self.name
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-03 16:19 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-03 16:19 UTC (permalink / raw
To: gentoo-commits
commit: 4f431675ab386384e49b5187a6a81b373aa8f255
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jun 3 14:55:02 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jun 3 14:55:02 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=4f431675
Refactoring in managers.
---
gpackages/apps/packages/managers.py | 53 +++++++++++++++++------------------
1 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index f613df2..d7caaf1 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -10,7 +10,19 @@ def _gen_query_and_manager(MixinClass, QueryClassName, ManagerClassName):
})
return QueryClass, ManagerClass
-class PackageMixin(object):
+def _gen_all_query_and_manager(mixin_name, name_for_query, name_for_manager, *args):
+ for arg in args:
+ basename = arg.__name__
+ if basename.endswith(mixin_name):
+ end_index = len(basename) - len(mixin_name)
+ basename = basename[ : end_index]
+ q_name = basename + name_for_query
+ m_name = basename + name_for_manager
+ q, m = _gen_query_and_manager(arg, q_name, m_name)
+ globals()[q_name], globals()[m_name] = q, m
+
+
+class PackageMixin(object):#{{{
def get(self, package = None, *args, **kwargs):
if package is not None and isinstance(package, Package):
if 'category' not in kwargs:
@@ -22,13 +34,10 @@ class PackageMixin(object):
args[1] = category
else:
kwargs.update({'name': name})
- return super(PackageMixin, self).get(*args, **kwargs)
+ return super(PackageMixin, self).get(*args, **kwargs)#}}}
-PackageQuerySet, PackageManager = _gen_query_and_manager(PackageMixin,
- 'PackageQuerySet',
- 'PackageManager')
-class KeywordMixin(object):
+class KeywordMixin(object):#{{{
def get_or_create(self, keyword=None, **kwargs):
if keyword is not None:
if isinstance(keyword, Keyword):
@@ -37,13 +46,10 @@ class KeywordMixin(object):
else:
raise ValueError("Bad keyword object")
- return super(KeywordMixin, self).get_or_create(**kwargs)
+ return super(KeywordMixin, self).get_or_create(**kwargs)#}}}
-KeywordQuerySet, KeywordManager = _gen_query_and_manager(KeywordMixin,
- 'KeywordQuerySet',
- 'KeywordManager')
-class EbuildMixin(object):
+class EbuildMixin(object):#{{{
def create(self, **kwargs):
if 'ebuild' in kwargs:
obj = self.model(**kwargs)
@@ -94,34 +100,27 @@ class EbuildMixin(object):
revision = ebuild.revision
kwargs.update({ 'version': version,
'revision': revision })
- return super(EbuildMixin, self).get(*args, **kwargs)
-
-
+ return super(EbuildMixin, self).get(*args, **kwargs)#}}}
-EbuildQuerySet, EbuildManager = _gen_query_and_manager(EbuildMixin,
- 'EbuildQuerySet',
- 'EbuildManager')
-class HerdsMixin(object):
+class HerdsMixin(object):#{{{
def filter(self, *args, **kwargs):
if 'herd__in' in kwargs:
herds = kwargs['herd__in']
del kwargs['herd__in']
kwargs['name__in'] = herds
- return super(HerdsMixin, self).filter(*args, **kwargs)
+ return super(HerdsMixin, self).filter(*args, **kwargs)#}}}
-HerdsQuerySet, HerdsManager = _gen_query_and_manager(HerdsMixin,
- 'HerdsQuerySet',
- 'HerdsManager')
-class MaintainerMixin(object):
+class MaintainerMixin(object):#{{{
def filter(self, *args, **kwargs):
if 'maintainer__in' in kwargs:
maintars = kwargs['maintainer__in']
del kwargs['maintainer__in']
kwargs['email__in'] = maintars
- return super(MaintainerMixin, self).filter(*args, **kwargs)
+ return super(MaintainerMixin, self).filter(*args, **kwargs)#}}}
+
-MaintainerQuerySet, MaintainerManager = _gen_query_and_manager(MaintainerMixin,
- 'MaintainerQuerySet',
- 'MaintainerManager')
+_gen_all_query_and_manager('Mixin', 'QuerySet', 'Manager',
+ PackageMixin, KeywordMixin, EbuildMixin, HerdsMixin,
+ MaintainerMixin)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-05 15:49 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-05 15:49 UTC (permalink / raw
To: gentoo-commits
commit: 2c2f169eb9bc4f8b4af246f647aa14ee0845e402
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jun 5 12:27:57 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jun 5 12:27:57 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=2c2f169e
Add metadata_hash field to PackageModel
---
gpackages/apps/packages/models.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index fbf2e15..4326a89 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -132,6 +132,7 @@ class PackageModel(models.Model):
changelog = models.TextField(blank = True)
changelog_hash = models.CharField(max_length = 128)
manifest_hash = models.CharField(max_length = 128)
+ metadata_hash = models.CharField(max_length = 128)
changelog_mtime = models.DateTimeField(blank = True, null = True)
manifest_mtime = models.DateTimeField(blank = True, null = True)
mtime = models.DateTimeField(blank = True, null = True)
@@ -160,8 +161,15 @@ class PackageModel(models.Model):
def check_or_need_update(self, package):
# Need add metadata check to
return not( self.changelog_hash == package.changelog_sha1 and \
+ self.metadata_hash == package.metadata_sha1 and \
self.manifest_hash == package.manifest_sha1)
+ def need_update_metadata(self, package):
+ return self.metadata_hash != package.metadata_sha1
+
+ def need_update_ebuilds(self, package):
+ return self.manifest_hash != package.manifest_sha1
+
def update_info(self, package):
self.mtime = package.mtime
self.changelog_mtime = package.changelog_mtime
@@ -169,6 +177,7 @@ class PackageModel(models.Model):
self.changelog_hash = package.changelog_sha1
self.manifest_mtime = package.manifest_mtime
self.manifest_hash = package.manifest_sha1
+ self.metadata_hash = package.metadata_sha1
class Meta:
unique_together = ('name', 'category')
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-05 15:49 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-05 15:49 UTC (permalink / raw
To: gentoo-commits
commit: bd97f3271c9287902bf8d3c2a2e5c39d310aad20
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jun 5 15:49:29 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jun 5 15:49:29 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=bd97f327
Change in updating info
---
gpackages/apps/packages/managers.py | 72 +++++++++++++++---------------
gpackages/apps/packages/models.py | 12 +++---
gpackages/apps/packages/scan.py | 82 ++++++++++++++++++++++++++--------
3 files changed, 104 insertions(+), 62 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index 27136f8..cfde91e 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -53,42 +53,42 @@ class KeywordMixin(object):#{{{
class EbuildMixin(object):#{{{
- def create(self, **kwargs):
- if 'ebuild' in kwargs:
- obj = self.model(**kwargs)
- else:
- obj = super(EbuildMixin, self).create(**kwargs)
- return obj
-
- def get_or_create(self, **kwargs):
- assert kwargs, \
- 'get_or_create() must be passed at least one keyword argument'
- defaults = kwargs.pop('defaults', {})
- lookup = kwargs.copy()
- for f in self.model._meta.fields:
- if f.attname in lookup:
- lookup[f.name] = lookup.pop(f.attname)
- try:
- self._for_write = True
- return self.get(**lookup), False
- except self.model.DoesNotExist:
- try:
- params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
- params.update(defaults)
- sid = transaction.savepoint(using=self.db)
- obj = self.model(**params)
- if 'ebuild' not in kwargs:
- obj.save(force_insert=True, using=self.db)
- transaction.savepoint_commit(sid, using=self.db)
- return obj, True
- except IntegrityError as e:
- transaction.savepoint_rollback(sid, using=self.db)
- exc_info = sys.exc_info()
- try:
- return self.get(**lookup), False
- except self.model.DoesNotExist:
- # Re-raise the IntegrityError with its original traceback.
- raise exc_info[1], None, exc_info[2]
+ #def create(self, **kwargs):
+ #if 'ebuild' in kwargs:
+ #obj = self.model(**kwargs)
+ #else:
+ #obj = super(EbuildMixin, self).create(**kwargs)
+ #return obj
+
+ #def get_or_create(self, **kwargs):
+ #assert kwargs, \
+ #'get_or_create() must be passed at least one keyword argument'
+ #defaults = kwargs.pop('defaults', {})
+ #lookup = kwargs.copy()
+ #for f in self.model._meta.fields:
+ #if f.attname in lookup:
+ #lookup[f.name] = lookup.pop(f.attname)
+ #try:
+ #self._for_write = True
+ #return self.get(**lookup), False
+ #except self.model.DoesNotExist:
+ #try:
+ #params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
+ #params.update(defaults)
+ #sid = transaction.savepoint(using=self.db)
+ #obj = self.model(**params)
+ #if 'ebuild' not in kwargs:
+ #obj.save(force_insert=True, using=self.db)
+ #transaction.savepoint_commit(sid, using=self.db)
+ #return obj, True
+ #except IntegrityError as e:
+ #transaction.savepoint_rollback(sid, using=self.db)
+ #exc_info = sys.exc_info()
+ #try:
+ #return self.get(**lookup), False
+ #except self.model.DoesNotExist:
+ ## Re-raise the IntegrityError with its original traceback.
+ #raise exc_info[1], None, exc_info[2]
def get(self, ebuild=None,package = None, *args, **kwargs):
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 4326a89..8a52b5d 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -160,9 +160,7 @@ class PackageModel(models.Model):
def check_or_need_update(self, package):
# Need add metadata check to
- return not( self.changelog_hash == package.changelog_sha1 and \
- self.metadata_hash == package.metadata_sha1 and \
- self.manifest_hash == package.manifest_sha1)
+ return self.manifest_hash != package.manifest_sha1
def need_update_metadata(self, package):
return self.metadata_hash != package.metadata_sha1
@@ -243,23 +241,25 @@ class EbuildModel(models.Model):
del kwargs['ebuild']
super(EbuildModel, self).__init__(*args, **kwargs)
if ebuild is not None and isinstance(ebuild, Ebuild):
- self.init_with_keywords(ebuild)
+ self.init_by_ebuild(ebuild)
def __unicode__(self):
return self.cpv
def init_by_ebuild(self, ebuild):
+ self.update_by_ebuild(ebuild)
+
+ def update_by_ebuild(self, ebuild):
self.is_masked = ebuild.is_masked
self.version = ebuild.version
self.revision = ebuild.revision
self.license = ebuild.license
self.ebuild_mtime = ebuild.mtime
self.ebuild_hash = ebuild.sha1
- #self.homepage = ebuild.homepage
self.description = ebuild.description
def check_or_need_update(self, ebuild):
- return not(self.ebuild_hash == ebuild.sha1)
+ return self.ebuild_hash != ebuild.sha1
def init_related(self, ebuild, package = None):
self.init_by_ebuild(ebuild)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index 8deb289..994adbf 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -257,39 +257,81 @@ def scanpackages():
herds_objects.append(herds_cache[herd])
return herds_objects
+
+ def add_related_to_ebuild(ebuild, ebuild_object):
+ # Add licenses
+ ebuild_object.licenses.add(*get_licenses_objects(ebuild))
+ ebuild_object.use_flags.add(*get_uses_objects(ebuild))
+ ebuild_object.homepages.add(*get_homepages_objects(ebuild))
+ get_keywords_objects(ebuild, ebuild_object)
+
+ def clear_related_to_ebuild(ebuild_object):
+ ebuild_object.licenses.clear()
+ ebuild_object.use_flags.clear()
+ ebuild_object.homepages.clear()
+ models.Keyword.objects.filter(ebuild = ebuild_object).delete()
+
+ def update_related_to_ebuild(ebuild, ebuild_object):
+ clear_related_to_ebuild(ebuild_object)
+ add_related_to_ebuild(ebuild, ebuild_object)
+
+ def create_ebuilds(package, package_object):
+ for ebuild in package.iter_ebuilds():
+ ebuild_object = models.EbuildModel()
+ ebuild_object.init_by_ebuild(ebuild)
+ ebuild_object.package = package_object
+ # To Add some related objects it should have pk
+ ebuild_object.save(force_insert=True)
+ add_related_to_ebuild(ebuild, ebuild_object)
+
+ def update_ebuilds(package, package_object, delete = True):
+ not_del = []
+ for ebuild in package.iter_ebuilds():
+ ebuild_object, ebuild_created = models.EbuildModel.objects.get_or_create(ebuild = ebuild, package = package_object)
+ not_del.append(ebuild_object.pk)
+ if ebuild_created:
+ add_related_to_ebuild(ebuild, ebuild_object)
+ continue
+ if ebuild_object.check_or_need_update(ebuild):
+ ebuild_object.update_by_ebuild(ebuild)
+ update_related_to_ebuild(ebuild, ebuild_object)
+ ebuild_object.save(force_update = True)
+ if delete:
+ models.EbuildModel.objects.exclude(pk__in = not_del).delete()
+
# Load homepages to cache
#for homepage in models.HomepageModel.objects.all():
#homepages_cache[homepage.url] = homepage
-
+ existend_categorys = []
+ existend_packages = []
for category in porttree.iter_categories():
category_object, category_created = models.CategoryModel.objects.get_or_create(category = category)
+ existend_categorys.append(category_object.pk)
for package in category.iter_packages():
- print package
+ #print package
package_object, package_created = models.PackageModel.objects.get_or_create(package = package, category = category_object)
+ existend_packages.append(package_object.pk)
if not package_created:
if package_object.check_or_need_update(package):
+ print package
# need update
- pass
+ if package_object.need_update_metadata(package):
+ package_object.herds.clear()
+ package_object.maintainers.clear()
+
+ if package_object.need_update_ebuilds(package):
+ update_ebuilds(package, package_object)
+
+ package_object.update_info(package)
+ package_object.save(force_update = True)
else:
+ # not need to update, ebuilds too
continue
package_object.herds.add(*get_herds_objects(package))
package_object.maintainers.add(*get_maintainers_objects(package))
- for ebuild in package.iter_ebuilds():
- ebuild_object = models.EbuildModel()
- ebuild_object.init_by_ebuild(ebuild)
- ebuild_object.package = package_object
- # To Add some related objects it should have pk
- ebuild_object.save(force_insert=True)
- # Add licenses
- ebuild_object.licenses.add(*get_licenses_objects(ebuild))
- ebuild_object.use_flags.add(*get_uses_objects(ebuild))
- ebuild_object.homepages.add(*get_homepages_objects(ebuild))
- get_keywords_objects(ebuild, ebuild_object)
- #homepages_list = []
- #for homepage in ebuild.homepages:
- #homepage_object = models.HomepageModel(url = homepage,
- #ebuild = ebuild_object)
- #homepages_list.append(homepage_object)
- #models.HomepageModel.objects.bulk_create(homepages_list)
+ if package_created:
+ create_ebuilds(package, package_object)
+ # del
+ #models.CategoryModel.objects.exclude(pk__in = existend_categorys).delete()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-05 20:48 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-05 20:48 UTC (permalink / raw
To: gentoo-commits
commit: 8246af3caeb234f9b739683a37ea175d81eb12a2
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jun 5 17:32:48 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jun 5 17:32:48 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=8246af3c
Changes in ebuild deletetion
---
gpackages/apps/packages/scan.py | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index 994adbf..f739c69 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -196,7 +196,7 @@ def scan_uses_description():
use_desc_obj.save(force_update = True)
models.UseFlagDescriptionModel.objects.bulk_create(to_create)
-def scanpackages():
+def scanpackages(delete = True, force_update = False):
licenses_cache = {}
def get_licenses_objects(ebuild):
licenses = ebuild.licenses
@@ -297,33 +297,36 @@ def scanpackages():
update_related_to_ebuild(ebuild, ebuild_object)
ebuild_object.save(force_update = True)
if delete:
- models.EbuildModel.objects.exclude(pk__in = not_del).delete()
+ models.EbuildModel.objects.filter(package = package_object).exclude(pk__in = not_del).delete()
+
+ def update_package(package, package_object, force_update = False):
+ if package_object.need_update_metadata(package) or force_update:
+ package_object.herds.clear()
+ package_object.maintainers.clear()
+
+ if package_object.need_update_ebuilds(package) or force_update:
+ update_ebuilds(package, package_object)
+
+ package_object.update_info(package)
+ package_object.save(force_update = True)
# Load homepages to cache
#for homepage in models.HomepageModel.objects.all():
#homepages_cache[homepage.url] = homepage
existend_categorys = []
- existend_packages = []
for category in porttree.iter_categories():
+ existend_packages = []
category_object, category_created = models.CategoryModel.objects.get_or_create(category = category)
existend_categorys.append(category_object.pk)
for package in category.iter_packages():
- #print package
+ print package
package_object, package_created = models.PackageModel.objects.get_or_create(package = package, category = category_object)
existend_packages.append(package_object.pk)
if not package_created:
- if package_object.check_or_need_update(package):
+ if package_object.check_or_need_update(package) or force_update:
print package
# need update
- if package_object.need_update_metadata(package):
- package_object.herds.clear()
- package_object.maintainers.clear()
-
- if package_object.need_update_ebuilds(package):
- update_ebuilds(package, package_object)
-
- package_object.update_info(package)
- package_object.save(force_update = True)
+ update_package(package, package_object)
else:
# not need to update, ebuilds too
continue
@@ -331,6 +334,9 @@ def scanpackages():
package_object.maintainers.add(*get_maintainers_objects(package))
if package_created:
create_ebuilds(package, package_object)
+
+ if delete:
+ models.PackageModel.objects.filter(category = category_object).exclude(pk__in = existend_packages).delete()
# del
#models.CategoryModel.objects.exclude(pk__in = existend_categorys).delete()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-05 20:48 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-05 20:48 UTC (permalink / raw
To: gentoo-commits
commit: 54b17e3390263909535dc1edd697931f96635e1f
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jun 5 17:21:41 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jun 5 17:21:41 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=54b17e33
Add abstract class for created and updated datetime.
---
gpackages/apps/packages/models.py | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 8a52b5d..fd36098 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -3,6 +3,13 @@ from django.db import models
from porttree import Category, Package, Ebuild
import managers
+class AbstractDateTimeModel(models.Model):
+ created_datetime = models.DateTimeField(auto_now_add = True)
+ updated_datetime = models.DateTimeField(auto_now = True)
+
+ class Meta:
+ abstract = True
+
class HomepageModel(models.Model):
url = models.URLField(max_length=255, unique = True)
@@ -42,7 +49,7 @@ class CategoryModel(models.Model):
def __unicode__(self):
return self.category
-class MaintainerModel(models.Model):
+class MaintainerModel(AbstractDateTimeModel):
def __init__(self, *args, **kwargs):
#TODO: Bad code, maybe use some libraries for overload methods
@@ -75,7 +82,7 @@ class MaintainerModel(models.Model):
def __unicode__(self):
return ':'.join((unicode(self.name), self.email))
-class HerdsModel(models.Model):
+class HerdsModel(AbstractDateTimeModel):
def __init__(self, *args, **kwargs):
herd = None
@@ -109,7 +116,7 @@ class HerdsModel(models.Model):
def __unicode__(self):
return self.name
-class PackageModel(models.Model):
+class PackageModel(AbstractDateTimeModel):
def __init__(self, *args, **kwargs):
# TODO: Bad code, maybe use some library to overload method
package_object = None
@@ -209,7 +216,7 @@ class LicensModel(models.Model):
return self.name
-class EbuildModel(models.Model):
+class EbuildModel(AbstractDateTimeModel):
package = models.ForeignKey(PackageModel)
#repository = models.ForeignKey(RepositoryModel)
version = models.CharField(max_length = 26)
@@ -219,7 +226,6 @@ class EbuildModel(models.Model):
license = models.CharField(max_length = 254, blank = True )
ebuild_hash = models.CharField(max_length = 128)
ebuild_mtime = models.DateTimeField(blank = True, null = True)
- ebuild_datetime = models.DateTimeField(auto_now = True)
is_deleted = models.BooleanField(default = False)
is_masked = models.BooleanField(default = False)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-05 20:48 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-05 20:48 UTC (permalink / raw
To: gentoo-commits
commit: 38a340cdefa85a3a5ef62d2767ae0c38f37981d7
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jun 5 20:38:40 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jun 5 20:38:40 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=38a340cd
Update admin for packages
---
gpackages/apps/packages/admin.py | 86 +++++++++++++++++++++++++++++++++++---
1 files changed, 80 insertions(+), 6 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index 08df2c5..b7fe67e 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -1,11 +1,85 @@
from django.contrib import admin
+from django.db.models import Count
from models import EbuildModel, PackageModel, LicensModel, CategoryModel, \
- UseFlagModel, RepositoryModel, HomepageModel, HerdsModel, MaintainerModel
+ UseFlagModel, RepositoryModel, HomepageModel, HerdsModel, \
+ MaintainerModel, Keyword, ArchesModel, UseFlagDescriptionModel
-admin.site.register(EbuildModel)
-admin.site.register(PackageModel)
-admin.site.register(LicensModel)
+class EbuildAdmin(admin.ModelAdmin):
+ list_display = ('__unicode__', 'is_masked', )
+ list_filter = ('created_datetime','updated_datetime', 'licenses', 'is_masked')
+ filter_horizontal = ('licenses', 'use_flags', 'homepages')
+ date_hierarchy = 'updated_datetime'
+ list_select_related = True
+
+
+class PackageAdmin(admin.ModelAdmin):
+ list_display = ('__unicode__', 'ebuilds_count')
+ list_filter = ('created_datetime', 'updated_datetime', 'herds')
+ list_select_related = True
+
+ def queryset(self, request):
+ return super(PackageAdmin, self).queryset(request).annotate(ebuilds_count = Count('ebuildmodel'))
+
+ def ebuilds_count(self, obj):
+ return obj.ebuilds_count
+
+
+class HerdsAdmin(admin.ModelAdmin):
+ list_display = ('name', 'email', 'description', 'packages_count')
+ search_fields = ('name', 'email')
+
+ def queryset(self, request):
+ return super(HerdsAdmin, self).queryset(request).annotate(packages_count = Count('packagemodel'))
+
+ def packages_count(self, obj):
+ return obj.packages_count
+
+class MaintainerAdmin(admin.ModelAdmin):
+ list_display = ('name', 'email', 'packages_count')
+ search_fields = ('name', 'email')
+
+ def queryset(self, request):
+ return super(MaintainerAdmin, self).queryset(request).annotate(packages_count = Count('packagemodel'))
+
+ def packages_count(self, obj):
+ return obj.packages_count
+
+
+class UseFlagAdmin(admin.ModelAdmin):
+ list_display = ('name', 'description', 'ebuilds_count')
+ search_fields = ('name', 'description')
+
+ def queryset(self, request):
+ return super(UseFlagAdmin, self).queryset(request).annotate(ebuilds_count = Count('ebuildmodel'))
+
+ def ebuilds_count(self, obj):
+ return obj.ebuilds_count
+
+class UseFlagDescriptionAdmin(admin.ModelAdmin):
+ list_display = ('use_flag', 'package', 'description')
+ list_select_related = True
+
+class HomepageAdmin(admin.ModelAdmin):
+ list_display = ('url',)
+ search_fields = ('url',)
+
+class LicensAdmin(admin.ModelAdmin):
+ list_display = ('name', 'licenses_count')
+ search_fields = ('name',)
+
+ def queryset(self, request):
+ return super(LicensAdmin, self).queryset(request).annotate(licenses_count = Count('ebuildmodel'))
+
+ def licenses_count(self, obj):
+ return obj.licenses_count
+
+admin.site.register(EbuildModel, EbuildAdmin)
+admin.site.register(PackageModel, PackageAdmin)
+admin.site.register(LicensModel, LicensAdmin)
admin.site.register(CategoryModel)
-admin.site.register(UseFlagModel)
+admin.site.register(UseFlagModel, UseFlagAdmin)
+admin.site.register(UseFlagDescriptionModel, UseFlagDescriptionAdmin)
admin.site.register(RepositoryModel)
-admin.site.register(HomepageModel)
+admin.site.register(HomepageModel, HomepageAdmin)
+admin.site.register(HerdsModel, HerdsAdmin)
+admin.site.register(MaintainerModel, MaintainerAdmin)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-06 22:48 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-06 22:48 UTC (permalink / raw
To: gentoo-commits
commit: d3f396a3f7553bf9d1007f532d67e7bddc4f72cc
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jun 6 22:48:45 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jun 6 22:48:45 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=d3f396a3
Add caching in dbm
---
gpackages/apps/packages/scan.py | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index f316900..9c5c193 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -6,6 +6,8 @@ import porttree
import herds
import use_info
+import anydbm
+
portage = porttree.Portage()
def _get_from_cache(cache, what):
@@ -207,7 +209,10 @@ arches_cache = {}
homepages_cache = {}
herds_cache = {}
maintainers_cache = {}
-def scanpackages(porttree, porttree_obj, delete = True, force_update = False):
+
+cache_dict = None
+def scanpackages(porttree, porttree_obj, delete = True, force_update = False,
+ update_cache = True, use_cache = True):
def get_licenses_objects(ebuild):
licenses = ebuild.licenses
return _get_items(licenses, models.LicensModel, 'name', licenses_cache)
@@ -325,8 +330,19 @@ def scanpackages(porttree, porttree_obj, delete = True, force_update = False):
category_object, category_created = models.CategoryModel.objects.get_or_create(category = category)
existend_categorys.append(category_object.pk)
for package in category.iter_packages():
+ if use_cache:
+ key = str(porttree.name)+'/'+str(package)
+ val = None
+ if key in cache_dict:
+ val = cache_dict[key]
+ if val is not None and val == package.manifest_sha1:
+ continue
print('%s [%s]' % (package, porttree))
package_object, package_created = models.PackageModel.objects.get_or_create(package = package, category = category_object, repository = porttree_obj)
+ if update_cache:
+ key = str(porttree.name)+'/'+str(package)
+ cache_dict[key] = package.manifest_sha1
+
existend_packages.append(package_object.pk)
if not package_created:
if package_object.check_or_need_update(package) or force_update:
@@ -347,7 +363,10 @@ def scanpackages(porttree, porttree_obj, delete = True, force_update = False):
def scan_all_repos():
+ global cache_dict
+ cache_dict = anydbm.open('cache.db','c')
herds_cache, maintainers_cache = scan_herds()
for repo in portage.iter_trees():
repo_obj, repo_created = models.RepositoryModel.objects.get_or_create(name = repo.name)
scanpackages(repo, repo_obj)
+ cache_dict.close()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-07 11:27 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-07 11:27 UTC (permalink / raw
To: gentoo-commits
commit: 54d392ff2ead7a3f4af92805cdf6e6578869d8b2
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jun 7 11:27:08 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jun 7 11:27:08 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=54d392ff
Fix bug in delete.
---
gpackages/apps/packages/scan.py | 31 ++++++++++++++++---------------
1 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index 9c5c193..5bd9b0b 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -330,18 +330,19 @@ def scanpackages(porttree, porttree_obj, delete = True, force_update = False,
category_object, category_created = models.CategoryModel.objects.get_or_create(category = category)
existend_categorys.append(category_object.pk)
for package in category.iter_packages():
- if use_cache:
- key = str(porttree.name)+'/'+str(package)
- val = None
- if key in cache_dict:
- val = cache_dict[key]
- if val is not None and val == package.manifest_sha1:
- continue
+ #if use_cache:
+ #key = str(porttree.name)+'/'+str(package)
+ #val = None
+ #if key in cache_dict:
+ #val = cache_dict[key]
+ #if val is not None and val == package.manifest_sha1:
+ #continue
print('%s [%s]' % (package, porttree))
- package_object, package_created = models.PackageModel.objects.get_or_create(package = package, category = category_object, repository = porttree_obj)
- if update_cache:
- key = str(porttree.name)+'/'+str(package)
- cache_dict[key] = package.manifest_sha1
+ package_object, package_created = models.PackageModel.objects.only('changelog_hash', 'manifest_hash', 'metadata_hash') \
+ .get_or_create(package = package, category = category_object, repository = porttree_obj)
+ #if update_cache:
+ #key = str(porttree.name)+'/'+str(package)
+ #cache_dict[key] = package.manifest_sha1
existend_packages.append(package_object.pk)
if not package_created:
@@ -357,16 +358,16 @@ def scanpackages(porttree, porttree_obj, delete = True, force_update = False,
create_ebuilds(package, package_object)
if delete:
- models.PackageModel.objects.filter(category = category_object).exclude(pk__in = existend_packages).delete()
+ models.PackageModel.objects.filter(category = category_object, repository = porttree_obj).exclude(pk__in = existend_packages).delete()
# del
#models.CategoryModel.objects.exclude(pk__in = existend_categorys).delete()
def scan_all_repos():
- global cache_dict
- cache_dict = anydbm.open('cache.db','c')
+ #global cache_dict
+ #cache_dict = anydbm.open('cache.db','c')
herds_cache, maintainers_cache = scan_herds()
for repo in portage.iter_trees():
repo_obj, repo_created = models.RepositoryModel.objects.get_or_create(name = repo.name)
scanpackages(repo, repo_obj)
- cache_dict.close()
+ #cache_dict.close()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-07 18:37 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-07 18:37 UTC (permalink / raw
To: gentoo-commits
commit: 7be3203e948de4fa4ea78554cf5107b79e5fddbd
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jun 7 14:05:27 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jun 7 14:05:27 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=7be3203e
Del unused code in managers.
---
gpackages/apps/packages/managers.py | 40 +---------------------------------
1 files changed, 2 insertions(+), 38 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index cfde91e..c4ab013 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -44,7 +44,8 @@ class KeywordMixin(object):#{{{
def get_or_create(self, keyword=None, **kwargs):
if keyword is not None:
if isinstance(keyword, Keyword):
- arch, created = packages.models.ArchesModel.objects.get_or_create(name = keyword.name)
+ arch, created = packages.models.ArchesModel.objects \
+ .get_or_create(name = keyword.name)
kwargs.update({'arch': arch, 'status': keyword.status})
else:
raise ValueError("Bad keyword object")
@@ -53,43 +54,6 @@ class KeywordMixin(object):#{{{
class EbuildMixin(object):#{{{
- #def create(self, **kwargs):
- #if 'ebuild' in kwargs:
- #obj = self.model(**kwargs)
- #else:
- #obj = super(EbuildMixin, self).create(**kwargs)
- #return obj
-
- #def get_or_create(self, **kwargs):
- #assert kwargs, \
- #'get_or_create() must be passed at least one keyword argument'
- #defaults = kwargs.pop('defaults', {})
- #lookup = kwargs.copy()
- #for f in self.model._meta.fields:
- #if f.attname in lookup:
- #lookup[f.name] = lookup.pop(f.attname)
- #try:
- #self._for_write = True
- #return self.get(**lookup), False
- #except self.model.DoesNotExist:
- #try:
- #params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
- #params.update(defaults)
- #sid = transaction.savepoint(using=self.db)
- #obj = self.model(**params)
- #if 'ebuild' not in kwargs:
- #obj.save(force_insert=True, using=self.db)
- #transaction.savepoint_commit(sid, using=self.db)
- #return obj, True
- #except IntegrityError as e:
- #transaction.savepoint_rollback(sid, using=self.db)
- #exc_info = sys.exc_info()
- #try:
- #return self.get(**lookup), False
- #except self.model.DoesNotExist:
- ## Re-raise the IntegrityError with its original traceback.
- #raise exc_info[1], None, exc_info[2]
-
def get(self, ebuild=None,package = None, *args, **kwargs):
if ebuild is not None and isinstance(ebuild, Ebuild):
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-07 18:37 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-07 18:37 UTC (permalink / raw
To: gentoo-commits
commit: 2fea5d7405abf9549e7a281019e66077adc1c763
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jun 7 14:26:31 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jun 7 14:26:31 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=2fea5d74
Code clean-up in models
---
gpackages/apps/packages/models.py | 15 ---------------
1 files changed, 0 insertions(+), 15 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 80e4103..3b30d6f 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -31,21 +31,6 @@ class RepositoryModel(models.Model):
return self.name
class CategoryModel(models.Model):
- def __init__(self, *args, **kwargs):
- category_object = None
-
- if len(args)>=1:
- category_object = args[0]
- if 'category_object' in kwargs:
- category_object = kwargs['category_object']
- elif 'category' in kwargs:
- category_object = kwargs['category']
-
- if isinstance(category_object, Category):
- return super(CategoryModel, self).__init__(category = category_object.category)
- else:
- return super(CategoryModel, self).__init__(*args, **kwargs)
-
category = models.CharField(unique = True, max_length = 70)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-07 18:37 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-07 18:37 UTC (permalink / raw
To: gentoo-commits
commit: 54a9e0228a598e86a7d19651016c708881c90dc1
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jun 7 15:27:45 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jun 7 15:27:45 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=54a9e022
Fix bug in herds.
---
gpackages/apps/packages/scan.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index 5bd9b0b..d437e42 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -364,6 +364,7 @@ def scanpackages(porttree, porttree_obj, delete = True, force_update = False,
def scan_all_repos():
+ global herds_cache, maintainers_cache
#global cache_dict
#cache_dict = anydbm.open('cache.db','c')
herds_cache, maintainers_cache = scan_herds()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-07 18:37 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-07 18:37 UTC (permalink / raw
To: gentoo-commits
commit: 0ea02f6f29cbcea12e249f882f6f7b723920738b
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jun 7 15:27:26 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jun 7 15:27:26 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=0ea02f6f
Code clean-up in admin
---
gpackages/apps/packages/admin.py | 63 +++++++++++++++-----------------------
1 files changed, 25 insertions(+), 38 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index b7fe67e..b403a45 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -4,6 +4,25 @@ from models import EbuildModel, PackageModel, LicensModel, CategoryModel, \
UseFlagModel, RepositoryModel, HomepageModel, HerdsModel, \
MaintainerModel, Keyword, ArchesModel, UseFlagDescriptionModel
+class AbstractAnnotateAdmin(object):
+ annotate_dict = {}
+
+ def queryset(self, request):
+ return super(AbstractAnnotateAdmin, self).queryset(request) \
+ .annotate(**self.annotate_dict)
+
+class EbuildsCountAdmin(AbstractAnnotateAdmin):
+ annotate_dict = {'ebuilds_count': Count('ebuildmodel')}
+
+ def ebuilds_count(self, obj):
+ return obj.ebuilds_count
+
+class PackagesCountAdmin(AbstractAnnotateAdmin):
+ annotate_dict = {'packages_count': Count('packagemodel')}
+
+ def packages_count(self, obj):
+ return obj.packages_count
+
class EbuildAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'is_masked', )
list_filter = ('created_datetime','updated_datetime', 'licenses', 'is_masked')
@@ -11,50 +30,23 @@ class EbuildAdmin(admin.ModelAdmin):
date_hierarchy = 'updated_datetime'
list_select_related = True
-
-class PackageAdmin(admin.ModelAdmin):
+class PackageAdmin(EbuildsCountAdmin, admin.ModelAdmin):
list_display = ('__unicode__', 'ebuilds_count')
list_filter = ('created_datetime', 'updated_datetime', 'herds')
list_select_related = True
- def queryset(self, request):
- return super(PackageAdmin, self).queryset(request).annotate(ebuilds_count = Count('ebuildmodel'))
-
- def ebuilds_count(self, obj):
- return obj.ebuilds_count
-
-
-class HerdsAdmin(admin.ModelAdmin):
+class HerdsAdmin(PackagesCountAdmin, admin.ModelAdmin):
list_display = ('name', 'email', 'description', 'packages_count')
search_fields = ('name', 'email')
- def queryset(self, request):
- return super(HerdsAdmin, self).queryset(request).annotate(packages_count = Count('packagemodel'))
-
- def packages_count(self, obj):
- return obj.packages_count
-
-class MaintainerAdmin(admin.ModelAdmin):
+class MaintainerAdmin(PackagesCountAdmin, admin.ModelAdmin):
list_display = ('name', 'email', 'packages_count')
search_fields = ('name', 'email')
- def queryset(self, request):
- return super(MaintainerAdmin, self).queryset(request).annotate(packages_count = Count('packagemodel'))
-
- def packages_count(self, obj):
- return obj.packages_count
-
-
-class UseFlagAdmin(admin.ModelAdmin):
+class UseFlagAdmin(EbuildsCountAdmin, admin.ModelAdmin):
list_display = ('name', 'description', 'ebuilds_count')
search_fields = ('name', 'description')
- def queryset(self, request):
- return super(UseFlagAdmin, self).queryset(request).annotate(ebuilds_count = Count('ebuildmodel'))
-
- def ebuilds_count(self, obj):
- return obj.ebuilds_count
-
class UseFlagDescriptionAdmin(admin.ModelAdmin):
list_display = ('use_flag', 'package', 'description')
list_select_related = True
@@ -63,15 +55,10 @@ class HomepageAdmin(admin.ModelAdmin):
list_display = ('url',)
search_fields = ('url',)
-class LicensAdmin(admin.ModelAdmin):
- list_display = ('name', 'licenses_count')
+class LicensAdmin(EbuildsCountAdmin, admin.ModelAdmin):
+ list_display = ('name', 'ebuilds_count')
search_fields = ('name',)
- def queryset(self, request):
- return super(LicensAdmin, self).queryset(request).annotate(licenses_count = Count('ebuildmodel'))
-
- def licenses_count(self, obj):
- return obj.licenses_count
admin.site.register(EbuildModel, EbuildAdmin)
admin.site.register(PackageModel, PackageAdmin)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-07 22:48 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-07 22:48 UTC (permalink / raw
To: gentoo-commits
commit: 0589a3ae5f667330ba55f8a3992fd4d0407be51f
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jun 7 21:30:20 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jun 7 21:30:20 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=0589a3ae
Code clean-up in managers
---
gpackages/apps/packages/managers.py | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index ed5018c..7ebde50 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -36,6 +36,7 @@ class PackageMixin(object):#{{{
else:
kwargs.update({'name': name})
elif package is not None:
+ # Bad code !!
category, name = package.split('/')
kwargs.update({'name': name, 'category__category': category})
return super(PackageMixin, self).get(*args, **kwargs)#}}}
@@ -64,10 +65,8 @@ class EbuildMixin(object):#{{{
'package__name': ebuild.package.name })
else:
kwargs.update({'package': package})
- version = ebuild.version
- revision = ebuild.revision
- kwargs.update({ 'version': version,
- 'revision': revision })
+ kwargs.update({ 'version': ebuild.version,
+ 'revision': ebuild.revision })
return super(EbuildMixin, self).get(*args, **kwargs)#}}}
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-09 18:19 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-09 18:19 UTC (permalink / raw
To: gentoo-commits
commit: 5af34c978bd73991caede9e577c75b49934cb4e2
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sat Jun 9 10:45:34 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sat Jun 9 10:45:34 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=5af34c97
Changes in scan.py
---
gpackages/apps/packages/scan.py | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index d437e42..c9645fc 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -310,10 +310,23 @@ def scanpackages(porttree, porttree_obj, delete = True, force_update = False,
if delete:
models.EbuildModel.objects.filter(package = package_object).exclude(pk__in = not_del).delete()
+ def clear_related_to_package(package_object):
+ package_object.herds.clear()
+ package_object.maintainers.clear()
+
+
+ def add_related_to_package(package, package_object):
+ package_object.herds.add(*get_herds_objects(package))
+ package_object.maintainers.add(*get_maintainers_objects(package))
+
+ def update_related_to_package(package, package_object):
+ clear_related_to_package(package_object)
+ add_related_to_package(package, package_object)
+
def update_package(package, package_object, force_update = False):
if package_object.need_update_metadata(package) or force_update:
- package_object.herds.clear()
- package_object.maintainers.clear()
+ #Updating related objects to package
+ update_related_to_package(package, package_object)
if package_object.need_update_ebuilds(package) or force_update:
update_ebuilds(package, package_object)
@@ -337,7 +350,7 @@ def scanpackages(porttree, porttree_obj, delete = True, force_update = False,
#val = cache_dict[key]
#if val is not None and val == package.manifest_sha1:
#continue
- print('%s [%s]' % (package, porttree))
+ print('%s [%s]' % (str(package).ljust(44), porttree))
package_object, package_created = models.PackageModel.objects.only('changelog_hash', 'manifest_hash', 'metadata_hash') \
.get_or_create(package = package, category = category_object, repository = porttree_obj)
#if update_cache:
@@ -349,18 +362,14 @@ def scanpackages(porttree, porttree_obj, delete = True, force_update = False,
if package_object.check_or_need_update(package) or force_update:
# need update
update_package(package, package_object)
- else:
- # not need to update, ebuilds too
- continue
- package_object.herds.add(*get_herds_objects(package))
- package_object.maintainers.add(*get_maintainers_objects(package))
+
+ continue
+ add_related_to_package(package, package_object)
if package_created:
create_ebuilds(package, package_object)
if delete:
models.PackageModel.objects.filter(category = category_object, repository = porttree_obj).exclude(pk__in = existend_packages).delete()
- # del
- #models.CategoryModel.objects.exclude(pk__in = existend_categorys).delete()
def scan_all_repos():
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-09 18:19 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-09 18:19 UTC (permalink / raw
To: gentoo-commits
commit: 842ed7b061795f548f76b13c3161839d032bdd19
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sat Jun 9 16:18:03 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sat Jun 9 16:18:03 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=842ed7b0
More refactoring in scan.py
---
gpackages/apps/packages/models.py | 1 -
gpackages/apps/packages/scan.py | 147 ++++++++++++++++++-------------------
2 files changed, 73 insertions(+), 75 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index dc2147c..713cb70 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -48,7 +48,6 @@ class MaintainerModel(AbstractDateTimeModel):
name = models.CharField(max_length = 255, blank = True, null = True)
email = models.EmailField(unique = True)
- role = models.TextField(blank = True, null = True)
objects = managers.MaintainerManager()
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index db9c0e6..d0f476e 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -66,7 +66,8 @@ def _get_items(items_list, Model, field_name, cache_var):
# Getting from cache
items_objects, geted_items = _get_from_cache(cache_var, items_set)
# Getting from database
- queryset, geted = _get_from_database_and_update_cache(Model, field_name, items_set - geted_items, cache_var)
+ queryset, geted = _get_from_database_and_update_cache(Model, field_name,
+ items_set - geted_items, cache_var)
if queryset is None:
return items_objects
geted_items = geted_items | geted
@@ -75,7 +76,8 @@ def _get_items(items_list, Model, field_name, cache_var):
items_objects.extend(queryset)
# Create not existend items fast using bulk_create, works only in django 1.4 or gt
need_create = list(items_set - geted_items)
- created, geted = _create_objects_and_update_cache(Model, field_name, need_create, cache_var)
+ created, geted = _create_objects_and_update_cache(Model, field_name,
+ need_create, cache_var)
if created is None:
return items_objects
items_objects.extend(created)
@@ -281,76 +283,73 @@ class Scanner(object):
def clean_keywords_object(self, ebuild_object):
models.Keyword.objects.filter(ebuild = ebuild_object).delete()
- def scanpackages(self, porttree, porttree_obj, delete = True,
- force_update = False, update_cache = True, use_cache = True):
-
-
-
-
- def add_related_to_ebuild(ebuild, ebuild_object):
- # Add licenses
- ebuild_object.licenses.add(*self.get_licenses_objects(ebuild))
- ebuild_object.use_flags.add(*self.get_uses_objects(ebuild))
- ebuild_object.homepages.add(*self.get_homepages_objects(ebuild))
- self.create_keywords_objects(ebuild, ebuild_object)
-
- def clear_related_to_ebuild(ebuild_object):
- ebuild_object.licenses.clear()
- ebuild_object.use_flags.clear()
- ebuild_object.homepages.clear()
- self.clean_keywords_object(ebuild_object)
-
- def update_related_to_ebuild(ebuild, ebuild_object):
- clear_related_to_ebuild(ebuild_object)
- add_related_to_ebuild(ebuild, ebuild_object)
-
- def create_ebuilds(package, package_object):
- for ebuild in package.iter_ebuilds():
- ebuild_object = models.EbuildModel()
- ebuild_object.init_by_ebuild(ebuild)
- ebuild_object.package = package_object
- # To Add some related objects it should have pk
- ebuild_object.save(force_insert=True)
- add_related_to_ebuild(ebuild, ebuild_object)
-
- def update_ebuilds(package, package_object, delete = True):
- not_del = []
- for ebuild in package.iter_ebuilds():
- ebuild_object, ebuild_created = models.EbuildModel.objects.get_or_create(ebuild = ebuild, package = package_object)
- not_del.append(ebuild_object.pk)
- if ebuild_created:
- add_related_to_ebuild(ebuild, ebuild_object)
- continue
- if ebuild_object.check_or_need_update(ebuild):
- ebuild_object.update_by_ebuild(ebuild)
- update_related_to_ebuild(ebuild, ebuild_object)
- ebuild_object.save(force_update = True)
- if delete:
- models.EbuildModel.objects.filter(package = package_object).exclude(pk__in = not_del).delete()
-
- def clear_related_to_package(package_object):
- package_object.herds.clear()
- package_object.maintainers.clear()
-
-
- def add_related_to_package(package, package_object):
- package_object.herds.add(*self.get_herds_objects(package))
- package_object.maintainers.add(*self.get_maintainers_objects(package))
-
- def update_related_to_package(package, package_object):
- clear_related_to_package(package_object)
- add_related_to_package(package, package_object)
-
- def update_package(package, package_object, force_update = False):
- if package_object.need_update_metadata(package) or force_update:
- #Updating related objects to package
- update_related_to_package(package, package_object)
+ def add_related_to_ebuild(self, ebuild, ebuild_object):
+ # Add licenses
+ ebuild_object.licenses.add(*self.get_licenses_objects(ebuild))
+ ebuild_object.use_flags.add(*self.get_uses_objects(ebuild))
+ ebuild_object.homepages.add(*self.get_homepages_objects(ebuild))
+ self.create_keywords_objects(ebuild, ebuild_object)
+
+ def clear_related_to_ebuild(self, ebuild_object):
+ ebuild_object.licenses.clear()
+ ebuild_object.use_flags.clear()
+ ebuild_object.homepages.clear()
+ self.clean_keywords_object(ebuild_object)
+
+ def update_related_to_ebuild(self, ebuild, ebuild_object):
+ self.clear_related_to_ebuild(ebuild_object)
+ self.add_related_to_ebuild(ebuild, ebuild_object)
+
+ def create_ebuilds(self, package, package_object):
+ for ebuild in package.iter_ebuilds():
+ ebuild_object = models.EbuildModel()
+ ebuild_object.init_by_ebuild(ebuild)
+ ebuild_object.package = package_object
+ # To Add some related objects it should have pk
+ ebuild_object.save(force_insert=True)
+ self.add_related_to_ebuild(ebuild, ebuild_object)
+
+ def clear_related_to_package(self, package_object):
+ package_object.herds.clear()
+ package_object.maintainers.clear()
+
- if package_object.need_update_ebuilds(package) or force_update:
- update_ebuilds(package, package_object)
+ def add_related_to_package(self, package, package_object):
+ package_object.herds.add(*self.get_herds_objects(package))
+ package_object.maintainers.add(*self.get_maintainers_objects(package))
+
+ def update_related_to_package(self, package, package_object):
+ self.clear_related_to_package(package_object)
+ self.add_related_to_package(package, package_object)
+
+ def update_ebuilds(self, package, package_object, delete = True):
+ not_del = []
+ for ebuild in package.iter_ebuilds():
+ ebuild_object, ebuild_created = models.EbuildModel.objects.get_or_create(ebuild = ebuild, package = package_object)
+ not_del.append(ebuild_object.pk)
+ if ebuild_created:
+ self.add_related_to_ebuild(ebuild, ebuild_object)
+ continue
+ if ebuild_object.check_or_need_update(ebuild):
+ ebuild_object.update_by_ebuild(ebuild)
+ self.update_related_to_ebuild(ebuild, ebuild_object)
+ ebuild_object.save(force_update = True)
+ if delete:
+ models.EbuildModel.objects.filter(package = package_object).exclude(pk__in = not_del).delete()
+
+ def update_package(package, package_object, force_update = False):
+ if package_object.need_update_metadata(package) or force_update:
+ #Updating related objects to package
+ self.update_related_to_package(package, package_object)
+
+ if package_object.need_update_ebuilds(package) or force_update:
+ self.update_ebuilds(package, package_object)
+
+ package_object.update_info(package)
+ package_object.save(force_update = True)
- package_object.update_info(package)
- package_object.save(force_update = True)
+ def scanpackages(self, porttree, porttree_obj, delete = True,
+ force_update = False, update_cache = True, use_cache = True):
# Load homepages to cache
#for homepage in models.HomepageModel.objects.all():
@@ -368,7 +367,7 @@ class Scanner(object):
#val = cache_dict[key]
#if val is not None and val == package.manifest_sha1:
#continue
- print('%s [%s]' % (str(package).ljust(44), porttree))
+ print('%-44s [%s]' % (package, porttree))
package_object, package_created = models.PackageModel.objects.only('changelog_hash', 'manifest_hash', 'metadata_hash') \
.get_or_create(package = package, category = category_object, repository = porttree_obj)
#if update_cache:
@@ -379,12 +378,12 @@ class Scanner(object):
if not package_created:
if package_object.check_or_need_update(package) or force_update:
# need update
- update_package(package, package_object)
+ self.update_package(package, package_object)
continue
# if package_created:
- add_related_to_package(package, package_object)
- create_ebuilds(package, package_object)
+ self.add_related_to_package(package, package_object)
+ self.create_ebuilds(package, package_object)
if delete:
models.PackageModel.objects.filter(category = category_object, repository = porttree_obj).exclude(pk__in = existend_packages).delete()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-10 17:51 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-10 17:51 UTC (permalink / raw
To: gentoo-commits
commit: de5ae2fa059a0d463283be466396a4f7093288ec
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jun 10 14:15:08 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jun 10 14:15:08 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=de5ae2fa
Fix bug in update_package
---
gpackages/apps/packages/scan.py | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index a7a77b9..37ba159 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -247,7 +247,9 @@ class Scanner(object):
for repo in portage.iter_trees():
self.output("Scaning repository '%s'\n", repo.name, 3)
- repo_obj, repo_created = models.RepositoryModel.objects.get_or_create(name = repo.name)
+ repo_obj, repo_created = models.RepositoryModel.objects \
+ .get_or_create(name = repo.name)
+
self.scanpackages(repo, repo_obj)
#cache_dict.close()
@@ -367,9 +369,10 @@ class Scanner(object):
self.output("ebuild updated '%s'\n", ebuild_object, 3)
if delete:
- models.EbuildModel.objects.filter(package = package_object).exclude(pk__in = not_del).delete()
+ models.EbuildModel.objects.filter(package = package_object) \
+ .exclude(pk__in = not_del).delete()
- def update_package(package, package_object, force_update = False):
+ def update_package(self, package, package_object, force_update = False):
if package_object.need_update_metadata(package) or force_update:
#Updating related objects to package
self.update_related_to_package(package, package_object)
@@ -386,7 +389,9 @@ class Scanner(object):
existend_categorys = []
for category in porttree.iter_categories():
existend_packages = []
- category_object, category_created = models.CategoryModel.objects.get_or_create(category = category)
+ category_object, category_created = models.CategoryModel \
+ .objects.get_or_create(category = category)
+
existend_categorys.append(category_object.pk)
for package in category.iter_packages():
#if use_cache:
@@ -397,8 +402,11 @@ class Scanner(object):
#if val is not None and val == package.manifest_sha1:
#continue
self.output('%-44s [%s]\n', (package, porttree))
- package_object, package_created = models.PackageModel.objects.only('changelog_hash', 'manifest_hash', 'metadata_hash') \
- .get_or_create(package = package, category = category_object, repository = porttree_obj)
+ package_object, package_created = models.PackageModel.objects \
+ .only('changelog_hash', 'manifest_hash', 'metadata_hash') \
+ .get_or_create(package = package,
+ category = category_object,
+ repository = porttree_obj)
#if update_cache:
#key = str(porttree.name)+'/'+str(package)
#cache_dict[key] = package.manifest_sha1
@@ -415,7 +423,9 @@ class Scanner(object):
self.create_ebuilds(package, package_object)
if delete:
- models.PackageModel.objects.filter(category = category_object, repository = porttree_obj).exclude(pk__in = existend_packages).delete()
+ models.PackageModel.objects \
+ .filter(category = category_object, repository = porttree_obj) \
+ .exclude(pk__in = existend_packages).delete()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-10 22:56 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-10 22:56 UTC (permalink / raw
To: gentoo-commits
commit: ca060436bc632080921c209d062bce107d6807b3
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jun 10 22:45:31 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jun 10 22:45:31 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=ca060436
Admin tuning
---
gpackages/apps/packages/admin.py | 9 +++++++++
gpackages/apps/packages/models.py | 4 +++-
2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index b403a45..a316c72 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -23,12 +23,20 @@ class PackagesCountAdmin(AbstractAnnotateAdmin):
def packages_count(self, obj):
return obj.packages_count
+class KeywordAdmin(admin.TabularInline):
+ model = Keyword
+
+class ArchesAdmin(admin.ModelAdmin):
+ list_display = ('name',)
+ search_fields = ('name',)
+
class EbuildAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'is_masked', )
list_filter = ('created_datetime','updated_datetime', 'licenses', 'is_masked')
filter_horizontal = ('licenses', 'use_flags', 'homepages')
date_hierarchy = 'updated_datetime'
list_select_related = True
+ inlines = (KeywordAdmin,)
class PackageAdmin(EbuildsCountAdmin, admin.ModelAdmin):
list_display = ('__unicode__', 'ebuilds_count')
@@ -70,3 +78,4 @@ admin.site.register(RepositoryModel)
admin.site.register(HomepageModel, HomepageAdmin)
admin.site.register(HerdsModel, HerdsAdmin)
admin.site.register(MaintainerModel, MaintainerAdmin)
+admin.site.register(ArchesModel, ArchesAdmin)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 3486399..b2170f1 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -136,7 +136,9 @@ class PackageModel(AbstractDateTimeModel):
self.name = package.name
self.update_info(package)
if category is None:
- self.category, created = CategoryModel.objects.get_or_create(category = package.category)
+ self.category, created = CategoryModel \
+ .objects.get_or_create(category = package.category)
+
elif isinstance(category, CategoryModel):
self.category = category
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-12 18:34 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-12 18:34 UTC (permalink / raw
To: gentoo-commits
commit: c6829e89b5652642864f0043a3b075430ada3b29
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jun 11 23:41:36 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jun 11 23:41:36 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=c6829e89
Code check that keywords doesn't repeat
---
gpackages/apps/packages/scan.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index ef28293..82c8a91 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -353,7 +353,7 @@ class Scanner(object):
def create_keywords_objects(self, ebuild, ebuild_object):
keywords_list = []
- for keyword in ebuild.get_keywords():
+ for keyword in ebuild.get_uniq_keywords():
keyword_object = models.Keyword(status = keyword.status,
ebuild = ebuild_object)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-13 22:15 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-13 22:15 UTC (permalink / raw
To: gentoo-commits
commit: 954496f22408b9fd7b3960e691c8eff8e786993a
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jun 13 15:17:12 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jun 13 15:17:12 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=954496f2
Add search by category to VirtualPackageAdmin
---
gpackages/apps/packages/admin.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index 42b854b..f803372 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -41,7 +41,7 @@ class EbuildAdmin(admin.ModelAdmin):
class VirtualPackageAdmin(admin.ModelAdmin):
list_display = ('__unicode__',)
- search_fields = ('name',)
+ search_fields = ('name','category__category')
class PackageAdmin(EbuildsCountAdmin, admin.ModelAdmin):
list_display = ('__unicode__', 'ebuilds_count')
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-20 23:23 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-20 23:23 UTC (permalink / raw
To: gentoo-commits
commit: 770b394d6658ed0c481d027fbe92d65691656049
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jun 20 11:38:04 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jun 20 11:38:04 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=770b394d
Add repository feed and source to admin
---
gpackages/apps/packages/admin.py | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index 9ce400d..5b5c209 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -3,7 +3,8 @@ from django.db.models import Count
from models import EbuildModel, PackageModel, LicenseModel, CategoryModel, \
UseFlagModel, RepositoryModel, HomepageModel, MaintainerModel, \
Keyword, ArchesModel, UseFlagDescriptionModel, HerdsModel, \
- VirtualPackageModel
+ VirtualPackageModel, RepositoryFeedModel, \
+ RepositorySourceModel
class AbstractAnnotateAdmin(object):
annotate_dict = {}
@@ -72,6 +73,24 @@ class LicenseAdmin(EbuildsCountAdmin, admin.ModelAdmin):
list_display = ('name', 'ebuilds_count')
search_fields = ('name',)
+class RepositoryAdmin(admin.ModelAdmin):
+ list_display = ('name', 'updated_datetime', 'official', 'homepage', 'quality')
+ search_fields = ('name', 'description', 'owner_name', 'owner_email')
+ list_filter = ('created_datetime', 'updated_datetime', 'official', 'quality')
+ date_hierarchy = 'updated_datetime'
+
+class RepositoryFeedAdmin(admin.ModelAdmin):
+ list_display = ('repository', 'feed')
+ search_fields = ('repository__name', 'feed')
+ list_filter = ('repository', )
+ list_select_related = True
+
+class RepositorySourceAdmin(admin.ModelAdmin):
+ list_display = ('repository', 'repo_type', 'url', 'subpath')
+ search_fields = ('repository__name', 'url')
+ list_filter = ('repo_type', )
+ list_select_related = True
+
admin.site.register(EbuildModel, EbuildAdmin)
admin.site.register(VirtualPackageModel, VirtualPackageAdmin)
@@ -80,7 +99,9 @@ admin.site.register(LicenseModel, LicenseAdmin)
admin.site.register(CategoryModel)
admin.site.register(UseFlagModel, UseFlagAdmin)
admin.site.register(UseFlagDescriptionModel, UseFlagDescriptionAdmin)
-admin.site.register(RepositoryModel)
+admin.site.register(RepositoryModel, RepositoryAdmin)
+admin.site.register(RepositoryFeedModel, RepositoryFeedAdmin)
+admin.site.register(RepositorySourceModel, RepositorySourceAdmin)
admin.site.register(HomepageModel, HomepageAdmin)
admin.site.register(HerdsModel, HerdsAdmin)
admin.site.register(MaintainerModel, MaintainerAdmin)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-20 23:23 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-20 23:23 UTC (permalink / raw
To: gentoo-commits
commit: bf591ce7f367ac35d6c10e17049a9af45357020b
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jun 19 18:27:13 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jun 19 18:27:13 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=bf591ce7
Little refactor in scan.py
---
gpackages/apps/packages/scan.py | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index 3e5cf81..48f7002 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -119,19 +119,21 @@ class Scanner(object):
self.start_time = datetime.now()
def update_options(self, **kwargs):
+ bool_get = lambda x,y: bool(kwargs.get(x, y))
+
self.verbosity = toint(kwargs.get('verbosity',1),1)
- self.traceback = bool(kwargs.get('traceback',False))
- self.s_all = bool(kwargs.get('scan_all', False))
- self.s_packages = bool(kwargs.get('packages', False))
- self.s_only_repo_info = bool(kwargs.get('only_repo_info', False))
- self.is_show_time = bool(kwargs.get('show_time', True))
- self.is_scan_herds = bool(kwargs.get('scan_herds', True))
- self.force_update = bool(kwargs.get('force_update', False))
- self.update_repo = bool(kwargs.get('update_repo', False))
- self.delete = bool(kwargs.get('delete', True))
+ self.traceback = bool_get('traceback',False)
+ self.s_all = bool_get('scan_all', False)
+ self.s_packages = bool_get('packages', False)
+ self.s_only_repo_info = bool_get('only_repo_info', False)
+ self.is_show_time = bool_get('show_time', True)
+ self.is_scan_herds = bool_get('scan_herds', True)
+ self.force_update = bool_get('force_update', False)
+ self.update_repo = bool_get('update_repo', False)
+ self.delete = bool_get('delete', True)
self.scan_repos_name = tuple(kwargs.get('repos',[]))
- self.scan_global_use_descr = bool(kwargs.get('scan_global_use', False))
- self.scan_local_use_descr = bool(kwargs.get('scan_local_use', False))
+ self.scan_global_use_descr = bool_get('scan_global_use', False)
+ self.scan_local_use_descr = bool_get('scan_local_use', False)
def show_time(self):
end = datetime.now()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-20 23:23 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-20 23:23 UTC (permalink / raw
To: gentoo-commits
commit: 997f0bca9b029d7a5d2c58327a5a3846a254fcd3
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jun 20 11:44:55 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jun 20 11:44:55 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=997f0bca
Select related for virtual packages
---
gpackages/apps/packages/admin.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index 5b5c209..b66ef73 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -43,6 +43,7 @@ class EbuildAdmin(admin.ModelAdmin):
class VirtualPackageAdmin(admin.ModelAdmin):
list_display = ('__unicode__',)
search_fields = ('name','category__category')
+ list_select_related = True
class PackageAdmin(EbuildsCountAdmin, admin.ModelAdmin):
list_display = ('__unicode__', 'ebuilds_count')
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-24 23:21 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-24 23:21 UTC (permalink / raw
To: gentoo-commits
commit: cffe07358db18dcead5bca370b03945ae304349e
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sat Jun 23 17:06:26 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sat Jun 23 17:06:26 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=cffe0735
Add indexes
---
gpackages/apps/packages/models.py | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 614faa0..943b370 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -25,7 +25,7 @@ class HomepageModel(models.Model):
return self.url
class ArchesModel(models.Model):
- name = models.CharField(unique = True, max_length = 22)
+ name = models.CharField(unique = True, max_length = 22, db_index = True)
def __unicode__(self):
return self.name
@@ -43,7 +43,7 @@ class RepositoryModel(AbstractDateTimeModel):
if repo is not None:
self.init_by_repo(repo)
- name = models.CharField(unique = True, max_length = 60)
+ name = models.CharField(unique = True, max_length = 60, db_index = True)
# Additional info
description = models.TextField(blank = True, null = True)
@@ -114,7 +114,7 @@ class RepositoryModel(AbstractDateTimeModel):
return self.name
class RepositoryFeedModel(models.Model):
- repository = models.ForeignKey(RepositoryModel)
+ repository = models.ForeignKey(RepositoryModel, db_index = True)
feed = models.URLField()
def __unicode__(self):
@@ -129,7 +129,7 @@ class RepositorySourceModel(models.Model):
repo_type = models.PositiveSmallIntegerField(choices = REPO_TYPE)
url = models.CharField(max_length = 255)
subpath = models.CharField(max_length = 100, blank = True, null = True)
- repository = models.ForeignKey(RepositoryModel)
+ repository = models.ForeignKey(RepositoryModel, db_index = True)
def __unicode__(self):
return self.url
@@ -149,7 +149,7 @@ class CategoryModel(models.Model):
def check_or_need_update(self, category):
return self.metadata_hash == category.metadata_sha1
- category = models.CharField(unique = True, max_length = 70)
+ category = models.CharField(unique = True, max_length = 70, db_index = True)
description = models.TextField(blank = True, null = True)
metadata_hash = models.CharField(max_length = 128, null = True)
@@ -165,7 +165,7 @@ class MaintainerModel(AbstractDateTimeModel):
self.init_by_maintainer(maintainer)
name = models.CharField(max_length = 255, blank = True, null = True)
- email = models.EmailField(unique = True, validators = [validate_email])
+ email = models.EmailField(unique = True, validators = [validate_email], db_index = True)
objects = managers.MaintainerManager()
@@ -191,7 +191,7 @@ class HerdsModel(AbstractDateTimeModel):
if herd is not None:
self.init_by_herd(herd)
- name = models.CharField(unique = True, max_length = 150)
+ name = models.CharField(unique = True, max_length = 150, db_index = True)
email = models.EmailField(validators = [validate_email])
description = models.TextField(blank = True, null = True)
maintainers = models.ManyToManyField(MaintainerModel, blank = True)
@@ -218,7 +218,7 @@ class HerdsModel(AbstractDateTimeModel):
ordering = ('name',)
class VirtualPackageModel(models.Model):
- name = models.CharField(max_length = 254)
+ name = models.CharField(max_length = 254, db_index = True)
category = models.ForeignKey(CategoryModel)
objects = managers.VirtualPackageManager()
@@ -243,7 +243,7 @@ class PackageModel(AbstractDateTimeModel):
self.init_by_package(package_object, category = category)
- virtual_package = models.ForeignKey(VirtualPackageModel)
+ virtual_package = models.ForeignKey(VirtualPackageModel, db_index = True)
changelog = models.TextField(blank = True, null = True)
changelog_hash = models.CharField(max_length = 128)
manifest_hash = models.CharField(max_length = 128)
@@ -256,7 +256,7 @@ class PackageModel(AbstractDateTimeModel):
maintainers = models.ManyToManyField(MaintainerModel, blank = True)
description = models.TextField(blank = True, null = True)
- repository = models.ForeignKey(RepositoryModel)
+ repository = models.ForeignKey(RepositoryModel, db_index = True)
# Different versions can have different licenses, or homepages.
objects = managers.PackageManager()
@@ -306,14 +306,14 @@ class PackageModel(AbstractDateTimeModel):
unique_together = ('virtual_package', 'repository')
class UseFlagModel(models.Model):
- name = models.CharField(unique = True, max_length = 60)
+ name = models.CharField(unique = True, max_length = 60, db_index = True)
description = models.TextField(blank = True)
def __unicode__(self):
return self.name
class UseFlagDescriptionModel(models.Model):
- use_flag = models.ForeignKey(UseFlagModel)
+ use_flag = models.ForeignKey(UseFlagModel, db_index = True)
package = models.ForeignKey(VirtualPackageModel)
description = models.TextField()
@@ -327,7 +327,7 @@ class UseFlagDescriptionModel(models.Model):
unique_together = ('use_flag', 'package')
class LicenseModel(models.Model):
- name = models.CharField(unique = True, max_length = 60)
+ name = models.CharField(unique = True, max_length = 60, db_index = True)
#description = TextField()
def __unicode__(self):
@@ -335,9 +335,9 @@ class LicenseModel(models.Model):
class EbuildModel(AbstractDateTimeModel):
- package = models.ForeignKey(PackageModel)
- version = models.CharField(max_length = 26)
- revision = models.CharField(max_length = 12)
+ package = models.ForeignKey(PackageModel, db_index = True)
+ version = models.CharField(max_length = 26, db_index = True)
+ revision = models.CharField(max_length = 12, db_index = True)
use_flags = models.ManyToManyField(UseFlagModel)
licenses = models.ManyToManyField(LicenseModel)
license = models.CharField(max_length = 254, blank = True )
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-25 22:23 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-25 22:23 UTC (permalink / raw
To: gentoo-commits
commit: ac2250f01a4656a5f703c58ae16defb501396885
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jun 25 22:23:31 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jun 25 22:23:31 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=ac2250f0
Add docstrings to scan.py file
---
gpackages/apps/packages/scan.py | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index b19958d..52f9a12 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -93,6 +93,7 @@ def toint(val, defval):
class Scanner(object):
+ "General class for scan and collect data from portage"
def __init__(self, **kwargs):
# maintainers_cache: maintainer.email as key, and maintainer object as
# value
@@ -136,11 +137,14 @@ class Scanner(object):
self.is_scan_license_groups = bool_get('scan_license_groups', False)
def show_time(self):
+ "Prints scan time"
end = datetime.now()
t_time = end - self.start_time
self.output("Scanning time is: %s secconds.\n", t_time.total_seconds())
def scan(self):
+ """General method for scan and collect data
+ It check object properties and scan only what property require"""
if self.is_scan_herds:
self.scan_herds()
@@ -171,10 +175,23 @@ class Scanner(object):
self.show_time()
def write(self, what, verbosity = 1):
+ """If object vervosity level are greate or equal to
+ method property verbosity prints param what
+ Args:
+ what -- string to print
+ vervosity -- level of verbosity that require for print string
+ """
if verbosity <= self.verbosity:
sys.stdout.write(what)
def output(self, format_str, whats, verbosity = 1):
+ """If object vervosity level are greate or equal to
+ method property verbosity prints param whats formated by param format_str
+ Args:
+ format_str -- formating string
+ what -- vals to print
+ vervosity -- level of verbosity that require for print string
+ """
# Maybe implement lazy format string ?
if verbosity <= self.verbosity:
sys.stdout.write(format_str % whats)
@@ -238,6 +255,7 @@ class Scanner(object):
self.maitainers_cache_loaded = True
def scan_license_groups(self):
+ "Scan license groups"
self.write('Scaning license groups\n', 3)
for group, licenses in portage.license_groups.groups_dict.iteritems():
licenses_obj = self.get_licenses_objects(licenses)
@@ -250,6 +268,7 @@ class Scanner(object):
self.output("update license group '%s'\n", group, 2)
def scan_herds(self):
+ "Scan herds and maintainers in herds.xml"
self.write('Scaning herds\n', 3)
existent_herds = self.get_existent_herds()
herds_dict = self.herds_object.get_herds_indict()
@@ -313,6 +332,7 @@ class Scanner(object):
return self.maintainers_cache
def scan_all_repos(self, **kwargs):
+ "Scan packages in all available trees"
#cache_dict = anydbm.open('cache.db','c')
for repo in portage.iter_trees():
@@ -336,6 +356,10 @@ class Scanner(object):
return repo
def scan_repo_by_name(self, repo_name, **kwargs):
+ """Scan repository by name, available repository names could be se
+ with manage.py listrepos command
+ Args:
+ repo_name -- repository name"""
repo = self.get_repo_by_name(repo_name)
if repo is not None:
@@ -357,6 +381,10 @@ class Scanner(object):
return repo_obj
def scan_all_repo_info(self, delete = False):
+ """Scan all info (metada) of all available repositories
+ Args:
+ delete -- if this true that repository will delete
+ if portage would be not available"""
ex_pk = []
for repo in portage.iter_trees():
repo_obj = self.get_repo_obj(repo, update_repo = True)
@@ -514,6 +542,13 @@ class Scanner(object):
def scanpackages(self, porttree, porttree_obj, delete = True,
force_update = False, update_cache = True, use_cache = True):
+ """Scan packages (and ebuilds) in porttree
+ Args:
+ porttree -- `PortTree` object from packages_info
+ porttree_obj -- `RepositoryModel` object
+ delete -- if True will delete unavailable packages and ebuilds
+ force_update -- update packages and ebuilds even if manifest not changed
+ """
existend_categorys = []
for category in porttree.iter_categories():
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-27 22:52 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-27 22:52 UTC (permalink / raw
To: gentoo-commits
commit: 6edf337fdb3ccd680c4109e6e684c36547aaad60
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jun 27 17:15:55 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jun 27 17:15:55 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=6edf337f
Set default ordering
---
gpackages/apps/packages/models.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 2b59deb..290516c 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -183,6 +183,9 @@ class MaintainerModel(AbstractDateTimeModel):
def __unicode__(self):
return ':'.join((unicode(self.name), self.email))
+ class Meta:
+ ordering = ('name',)
+
class HerdsModel(AbstractDateTimeModel):
def __init__(self, *args, **kwargs):
@@ -304,6 +307,7 @@ class PackageModel(AbstractDateTimeModel):
class Meta:
unique_together = ('virtual_package', 'repository')
+ ordering = ('-updated_datetime',)
class UseFlagModel(models.Model):
name = models.CharField(unique = True, max_length = 60, db_index = True)
@@ -436,6 +440,9 @@ class EbuildModel(AbstractDateTimeModel):
class Meta:
unique_together = ('package', 'version', 'revision')
+ ordering = ('-updated_datetime',)
+ #ordering = ('-updated_datetime', 'package__virtual_package__name',
+ #'-version', '-revision')
class Keyword(models.Model):
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-28 23:59 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-28 23:59 UTC (permalink / raw
To: gentoo-commits
commit: 3c76d3040d63aaaa34905be0c486c8e28ae455e1
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jun 28 15:34:34 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jun 28 15:34:34 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=3c76d304
Add prefetch keywords for packages manager
---
gpackages/apps/packages/managers.py | 48 ++++++++++++++++++++++++++++------
gpackages/apps/packages/models.py | 9 +++++-
gpackages/apps/packages/views.py | 4 +-
3 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index 012b40d..cfe0166 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -4,6 +4,8 @@ from package_info.abstract import AbstarctPackage, AbstractEbuild, \
import packages.models
from package_info.generic import get_from_kwargs_and_del
from collections import defaultdict
+from prefetch import PrefetchManagerMixin, PrefetchManager, PrefetchQuerySet, \
+ Prefetcher, P
def _gen_query_and_manager(MixinClass, QueryClassName, ManagerClassName):
QueryClass = type(QueryClassName, (MixinClass, models.query.QuerySet), {})
@@ -23,6 +25,19 @@ def _gen_all_query_and_manager(mixin_name, name_for_query, name_for_manager, *ar
q, m = _gen_query_and_manager(arg, q_name, m_name)
globals()[q_name], globals()[m_name] = q, m
+class EbuildsWithKeywrods(Prefetcher):
+ def __init__(self, keywords):
+ self.keywords = keywords
+
+ def filter(self, ids):
+ return packages.models.EbuildModel.objects.filter(package__in = ids).order_by('-version', '-revision').prefetch_with_keywords(self.keywords)
+
+ def reverse_mapper(self, ebuild):
+ return [ebuild.package_id]
+
+ def decorator(self, package, ebuilds = ()):
+ setattr(package, 'ebuilds', ebuilds)
+
class PackageMixin(object):
def get(self, package = None, *args, **kwargs):
@@ -54,6 +69,16 @@ class PackageMixin(object):
return super(PackageMixin, self).filter(**kwargs)
+class PackageQuerySet(PackageMixin, PrefetchQuerySet):
+ def prefetch_keywords(self, arch_list):
+ return self.prefetch(P('ebuilds', keywords = arch_list))
+
+class PackageManager(PackageMixin, PrefetchManagerMixin):
+ @classmethod
+ def get_query_set_class(cls):
+ return PackageQuerySet
+
+ prefetch_definitions = {'ebuilds': EbuildsWithKeywrods}
class KeywordMixin(object):#{{{
def get_or_create(self, keyword=None, **kwargs):
@@ -68,7 +93,7 @@ class KeywordMixin(object):#{{{
return super(KeywordMixin, self).get_or_create(**kwargs)#}}}
-class EbuildMixin(object):#{{{
+class EbuildMixin(object):
def get(self, ebuild=None, package = None, *args, **kwargs):
if ebuild is not None and isinstance(ebuild, AbstractEbuild):
@@ -80,13 +105,15 @@ class EbuildMixin(object):#{{{
kwargs.update({'package': package})
kwargs.update({ 'version': ebuild.version,
'revision': ebuild.revision })
- return super(EbuildMixin, self).get(*args, **kwargs)#}}}
+ return super(EbuildMixin, self).get(*args, **kwargs)
def all_by_numbers(self):
return super(EbuildMixin, self).order_by('version', 'revision')
+class EbuildQuerySet(EbuildMixin, models.query.QuerySet):
+
def __init__(self, *args, **kwargs):
- super(EbuildMixin, self).__init__(*args, **kwargs)
+ super(EbuildQuerySet, self).__init__(*args, **kwargs)
self._arches_set = None
self._cache_keywords = None
@@ -98,18 +125,19 @@ class EbuildMixin(object):#{{{
return self
def __old_iter__(self):
- return super(EbuildMixin, self).__iter__()
+ return super(EbuildQuerySet, self).__iter__()
def _clone(self, *args, **kwargs):
- c = super(EbuildMixin, self)._clone(*args, **kwargs)
+ c = super(EbuildQuerySet, self)._clone(*args, **kwargs)
c._arches_set = self._arches_set
return c
def _prefetch_keywords(self):
arch_set = self._arches_set
pk_keys = [ebuild.pk for ebuild in self.__old_iter__()]
- query = packages.models.Keyword.objects.filter(ebuild__in = pk_keys,
- arch__name__in = arch_set).select_related('arch')
+ query = packages.models.Keyword.objects.\
+ filter(ebuild__in = pk_keys, arch__name__in = arch_set). \
+ select_related('arch')
cache_query = defaultdict(list)
for keyword in query:
@@ -132,7 +160,9 @@ class EbuildMixin(object):#{{{
ebuild._prefetched_keywords = cache_query[ebuild.pk]
yield ebuild
-
+class EbuildManager(EbuildMixin, models.Manager):
+ def get_query_set(self):
+ return EbuildQuerySet(self.model, using = self._db)
class HerdsMixin(object):#{{{
def filter(self, *args, **kwargs):
@@ -174,6 +204,6 @@ class RepositoryMixin(object):
_gen_all_query_and_manager('Mixin', 'QuerySet', 'Manager',
- PackageMixin, KeywordMixin, EbuildMixin, HerdsMixin,
+ KeywordMixin, HerdsMixin,
MaintainerMixin, VirtualPackageMixin,
RepositoryMixin)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index caa7156..aa7bd65 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -12,6 +12,7 @@ from django.core.exceptions import ValidationError
validate_url = URLValidator()
+
class AbstractDateTimeModel(models.Model):
created_datetime = models.DateTimeField(auto_now_add = True)
updated_datetime = models.DateTimeField(auto_now = True)
@@ -308,8 +309,12 @@ class PackageModel(AbstractDateTimeModel):
def get_ebuilds_and_keywords(self, arch_list):
l = []
- for ebuild in self.ebuildmodel_set.order_by('-version', '-revision'):
- l.extend(ebuild.get_ebuilds_and_keywords(arch_list))
+ if not hasattr(self, 'ebuilds'):
+ for ebuild in self.ebuildmodel_set.order_by('-version', '-revision'):
+ l.extend(ebuild.get_ebuilds_and_keywords(arch_list))
+ else:
+ for ebuild in self.ebuilds:
+ l.extend(ebuild.get_ebuilds_and_keywords(arch_list))
return l
class Meta:
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index 16c74e2..21fa07c 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -52,5 +52,5 @@ class PackagesListsView(ContextListView):
template_name = 'packages.html'
context_object_name = 'packages'
queryset = PackageModel.objects.all(). \
- select_related('virtual_package', 'virtual_package__category')
- #prefetch_related('ebuildmodel_set')
+ select_related('virtual_package', 'virtual_package__category'). \
+ prefetch_keywords(arches)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-28 23:59 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-28 23:59 UTC (permalink / raw
To: gentoo-commits
commit: ecd1dd1c2c3cc2a556bd7dd7d1367eab669bd993
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jun 28 20:20:03 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jun 28 20:45:15 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=ecd1dd1c
Use prefetcher for keywords prefetch in ebuilds
---
gpackages/apps/packages/managers.py | 81 ++++++++++++-----------------------
gpackages/apps/packages/views.py | 2 +-
2 files changed, 29 insertions(+), 54 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index cfe0166..c1fd5e9 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -30,7 +30,9 @@ class EbuildsWithKeywrods(Prefetcher):
self.keywords = keywords
def filter(self, ids):
- return packages.models.EbuildModel.objects.filter(package__in = ids).order_by('-version', '-revision').prefetch_with_keywords(self.keywords)
+ return packages.models.EbuildModel.objects. \
+ filter(package__in = ids).order_by('-version', '-revision'). \
+ prefetch_keywords(self.keywords)
def reverse_mapper(self, ebuild):
return [ebuild.package_id]
@@ -38,6 +40,21 @@ class EbuildsWithKeywrods(Prefetcher):
def decorator(self, package, ebuilds = ()):
setattr(package, 'ebuilds', ebuilds)
+class KeywordsPrefetch(Prefetcher):
+ def __init__(self, arches):
+ self.arches = arches
+
+ def filter(self, ids):
+ return packages.models.Keyword.objects. \
+ filter(ebuild__in = ids, arch__name__in = self.arches). \
+ select_related('arch')
+
+ def reverse_mapper(self, keyword):
+ return [keyword.ebuild_id]
+
+ def decorator(self, ebuild, keywords = ()):
+ setattr(ebuild, '_prefetched_keywords', keywords)
+
class PackageMixin(object):
def get(self, package = None, *args, **kwargs):
@@ -110,59 +127,17 @@ class EbuildMixin(object):
def all_by_numbers(self):
return super(EbuildMixin, self).order_by('version', 'revision')
-class EbuildQuerySet(EbuildMixin, models.query.QuerySet):
-
- def __init__(self, *args, **kwargs):
- super(EbuildQuerySet, self).__init__(*args, **kwargs)
- self._arches_set = None
- self._cache_keywords = None
-
- # Maybe use https://github.com/ionelmc/django-prefetch ?
- def prefetch_with_keywords(self, arch_list):
- arch_set = set(arch_list)
- arch_set.add('*')
- self._arches_set = arch_set
- return self
-
- def __old_iter__(self):
- return super(EbuildQuerySet, self).__iter__()
-
- def _clone(self, *args, **kwargs):
- c = super(EbuildQuerySet, self)._clone(*args, **kwargs)
- c._arches_set = self._arches_set
- return c
-
- def _prefetch_keywords(self):
- arch_set = self._arches_set
- pk_keys = [ebuild.pk for ebuild in self.__old_iter__()]
- query = packages.models.Keyword.objects.\
- filter(ebuild__in = pk_keys, arch__name__in = arch_set). \
- select_related('arch')
+class EbuildQuerySet(EbuildMixin, PrefetchQuerySet):
+
+ def prefetch_keywords(self, arch_list):
+ return self.prefetch(P('keywords', arches = arch_list))
- cache_query = defaultdict(list)
- for keyword in query:
- cache_query[keyword.ebuild_id].append(keyword)
-
- self._cache_keywords = cache_query
-
- def __iter__(self):
- arch_set = self._arches_set
- if arch_set is None:
- for ebuild in self.__old_iter__():
- yield ebuild
- else:
- if self._cache_keywords is None:
- self._prefetch_keywords()
-
- cache_query = self._cache_keywords
-
- for ebuild in self.__old_iter__():
- ebuild._prefetched_keywords = cache_query[ebuild.pk]
- yield ebuild
-
-class EbuildManager(EbuildMixin, models.Manager):
- def get_query_set(self):
- return EbuildQuerySet(self.model, using = self._db)
+class EbuildManager(EbuildMixin, PrefetchManagerMixin):
+ prefetch_definitions = {'keywords': KeywordsPrefetch}
+
+ @classmethod
+ def get_query_set_class(cls):
+ return EbuildQuerySet
class HerdsMixin(object):#{{{
def filter(self, *args, **kwargs):
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index 21fa07c..4639555 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -43,7 +43,7 @@ class EbuildsListView(ContextListView):
queryset = EbuildModel.objects.all(). \
select_related('package',
'package__virtual_package',
- 'package__virtual_package__category').prefetch_with_keywords(arches)
+ 'package__virtual_package__category').prefetch_keywords(arches)
class PackagesListsView(ContextListView):
arches = ['alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64', 'sparc', 'x86']
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-29 17:29 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-29 17:29 UTC (permalink / raw
To: gentoo-commits
commit: 1534ff4c1ae792366ecdf5a426c55e32130a7722
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Fri Jun 29 00:28:28 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Fri Jun 29 00:28:28 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=1534ff4c
Litle optimize queries
---
gpackages/apps/packages/views.py | 22 ++++------------------
1 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index 98672d4..3b4cd23 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -56,15 +56,8 @@ class PackagesListsView(ContextListView):
context_object_name = 'packages'
queryset = PackageModel.objects.all(). \
select_related('virtual_package',
- 'virtual_package__category',
- 'repository'). \
- defer('repository__description',
- 'repository__owner_name',
- 'repository__owner_email',
- 'repository__homepage',
- 'repository__official',
- 'repository__quality',
- 'changelog'). \
+ 'virtual_package__category'). \
+ prefetch_related('repository'). \
prefetch_keywords(arches)
class PackageDetailView(ContextView, DetailView):
@@ -74,15 +67,8 @@ class PackageDetailView(ContextView, DetailView):
context_object_name = 'package'
queryset = PackageModel.objects.all(). \
select_related('virtual_package',
- 'virtual_package__category',
- 'repository'). \
- defer('repository__description',
- 'repository__owner_name',
- 'repository__owner_email',
- 'repository__homepage',
- 'repository__official',
- 'repository__quality',
- 'changelog'). \
+ 'virtual_package__category'). \
+ prefetch_related('repository'). \
prefetch_keywords(arches)
def get_object(self, queryset = None):
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-06-29 17:29 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-06-29 17:29 UTC (permalink / raw
To: gentoo-commits
commit: f6a01a82001fed88cfa5b767d40b824e9abd45b2
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Fri Jun 29 16:54:38 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Fri Jun 29 16:56:11 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=f6a01a82
Change urls
---
gpackages/apps/packages/urls.py | 3 ++-
gpackages/apps/packages/views.py | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/urls.py b/gpackages/apps/packages/urls.py
index 3744802..ffb16ca 100644
--- a/gpackages/apps/packages/urls.py
+++ b/gpackages/apps/packages/urls.py
@@ -15,5 +15,6 @@ urlpatterns = patterns('',
# In Future I will write my onw URL Resolver !!!
#url(r'^package/(?:(?P<pk>\d+)|(?P<category>[^/]+)/(?P<name>[^/]+))/$', PackageDetailView.as_view(), name = 'package'),
url(r'^package/(?P<pk>\d+)/$', PackageDetailView.as_view(), name = 'package'),
- url(r'^package/(?P<category>[^/]+)/(?P<name>[^/:]+)(::(?P<repository>[^/]+))?/$', PackageDetailView.as_view(), name = 'package'),
+ url(r'^package/(?P<category>[^/]+)/(?P<name>[^/:]+)/$', PackageDetailView.as_view(), name = 'package'),
+ url(r'^package/(?P<category>[^/]+)/(?P<name>[^/:]+)::(?P<repository>[^/]+)/$', PackageDetailView.as_view(), name = 'package'),
)
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index 3b4cd23..2ec2758 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -54,6 +54,14 @@ class PackagesListsView(ContextListView):
extra_context = {'page_name': 'Packages', 'arches': arches}
template_name = 'packages.html'
context_object_name = 'packages'
+ # Faster query !!
+ #SELECT t.id, t.virtual_package_id, t.description, t.repository_id, vp.id
+ #as virtual_package__name FROM
+ #(SELECT * FROM packages_packagemodel
+ #ORDER BY updated_datetime DESC LIMIT 3 ) as t
+ #INNER JOIN packages_virtualpackagemodel vp
+ #ON( `vp`.id = t.virtual_package_id) INNER JOIN `packages_categorymodel` cp
+ #ON (vp.category_id = cp.id);
queryset = PackageModel.objects.all(). \
select_related('virtual_package',
'virtual_package__category'). \
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-02 22:25 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-02 22:25 UTC (permalink / raw
To: gentoo-commits
commit: 2dd360558109f4ab0f201d10cd497c3d5b0cd447
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jul 2 18:13:41 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jul 2 18:13:41 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=2dd36055
Fix not effective query
---
gpackages/apps/packages/managers.py | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index c1fd5e9..d3f7b21 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -39,6 +39,8 @@ class EbuildsWithKeywrods(Prefetcher):
def decorator(self, package, ebuilds = ()):
setattr(package, 'ebuilds', ebuilds)
+ for ebuild in ebuilds:
+ ebuild.package = package
class KeywordsPrefetch(Prefetcher):
def __init__(self, arches):
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-03 21:08 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-03 21:08 UTC (permalink / raw
To: gentoo-commits
commit: 358b177ec765d8dfae6cde6c43add6ae08979e52
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jul 3 10:27:01 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jul 3 10:30:02 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=358b177e
Show hardmask in keywords table
---
gpackages/apps/packages/admin.py | 2 +-
gpackages/apps/packages/keywords.py | 13 ++++++++++---
gpackages/apps/packages/models.py | 2 +-
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index 04a269e..cfeeb80 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -34,7 +34,7 @@ class ArchesAdmin(admin.ModelAdmin):
class EbuildAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'is_hard_masked', )
- list_filter = ('created_datetime','updated_datetime', 'licenses', 'is_hard_masked')
+ list_filter = ('created_datetime','updated_datetime', 'is_hard_masked', 'licenses')
filter_horizontal = ('licenses', 'use_flags', 'homepages')
date_hierarchy = 'updated_datetime'
list_select_related = True
diff --git a/gpackages/apps/packages/keywords.py b/gpackages/apps/packages/keywords.py
index 0ab1e87..8b71f77 100644
--- a/gpackages/apps/packages/keywords.py
+++ b/gpackages/apps/packages/keywords.py
@@ -3,21 +3,28 @@ from package_info.generic import ToStrMixin
class KeywordRepr(ToStrMixin):
- __slots__ = ('status', 'arch')
+ __slots__ = ('status', 'arch', 'hardmask')
status_repr_list = ('', '+', '~','-')
status_class_list = ('blank', 'stable', 'unstable', 'hardmask')
- def __init__(self, arch, status):
+ def __init__(self, arch, status, hardmask = False):
self.arch = arch
self.status = status
+ self.hardmask = hardmask
@property
def status_repr(self):
- return self.status_repr_list[self.status + 1]
+ st = self.status_repr_list[self.status + 1]
+ if self.hardmask and st:
+ st = 'M' + st
+ return st
@property
def status_class(self):
+ # Maybe set hardmask class only for status > 0
+ if self.hardmask:
+ return self.status_class_list[3]
return self.status_class_list[self.status + 1]
def __unicode__(self):
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 5ce8919..98abc79 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -498,7 +498,7 @@ class EbuildModel(AbstractDateTimeModel):
def get_keywords(self, arch_list):
keywords_dict = self.get_keywords_dict(arch_list)
- return (KeywordRepr(arch, keywords_dict[arch]) for arch in arch_list)
+ return (KeywordRepr(arch, keywords_dict[arch], self.is_hard_masked) for arch in arch_list)
def get_keywords_dict(self, arch_list):
arch_set = set(arch_list)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-04 22:13 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-04 22:13 UTC (permalink / raw
To: gentoo-commits
commit: 451a2a0a19ba23afb625b52c404f6f3e1cc1fef6
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 4 13:26:32 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 4 13:26:32 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=451a2a0a
Update maintainer name if it find
---
gpackages/apps/packages/scan.py | 25 ++++++++++++++++++-------
1 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index 85ceb76..0fdf488 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -2,6 +2,7 @@ from datetime import datetime
from packages import models
import sys
from django.db import IntegrityError
+from django.utils.encoding import smart_unicode
from collections import defaultdict
from package_info.generic import StrThatIgnoreCase, toint
from package_info.porttree import porttree
@@ -415,18 +416,26 @@ class Scanner(object):
homepages = ebuild.homepages
return _get_items(homepages, models.HomepageModel, 'url', self.homepages_cache)
- def get_maintainers_objects(self, maintainers):
+ def get_maintainers_objects(self, maintainers, update_maintainer = False):
objects = []
#for maintainer in package.metadata.maintainers():
for maintainer in maintainers:
if maintainer.email in self.maintainers_cache:
- objects.append(self.maintainers_cache[maintainer.email])
+ m_obj = self.maintainers_cache[maintainer.email]
else:
- maintainer_object, created = models.MaintainerModel \
+ m_obj, created = models.MaintainerModel \
.objects.get_or_create(maintainer = maintainer)
- objects.append(maintainer_object)
# Add to cache
- self.maintainers_cache[maintainer_object.email] = maintainer_object
+ self.maintainers_cache[m_obj.email] = m_obj
+
+ #If we find maintainer name
+ if (update_maintainer or m_obj.name is None) and \
+ smart_unicode(m_obj.name) != smart_unicode(maintainer.name):
+
+ m_obj.name = maintainer.name
+ m_obj.save(force_update = True)
+
+ objects.append(m_obj)
return objects
def get_herds_objects(self, package):
@@ -669,9 +678,11 @@ class Scanner(object):
self.scan_news_item(news)
def add_related_to_news(self, news, news_obj):
- authors_obj = self.get_maintainers_objects(news.authors)
+ authors_obj = self.get_maintainers_objects(news.authors,
+ update_maintainer = True)
news_obj.authors.add(*authors_obj)
- translators_obj = self.get_maintainers_objects(news.translators)
+ translators_obj = self.get_maintainers_objects(news.translators,
+ update_maintainer = True)
news_obj.translators.add(*translators_obj)
def update_related_to_news(self, news, news_obj):
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-05 23:27 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-05 23:27 UTC (permalink / raw
To: gentoo-commits
commit: 8124e7c496ed6ae98915aab023d8cc1075191570
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jul 5 22:33:00 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jul 5 22:33:00 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=8124e7c4
Change admin for stats.
---
gpackages/apps/packages/admin.py | 46 ++++++++++++++-----------------------
1 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/gpackages/apps/packages/admin.py b/gpackages/apps/packages/admin.py
index 6143cd2..9cfb4ad 100644
--- a/gpackages/apps/packages/admin.py
+++ b/gpackages/apps/packages/admin.py
@@ -6,25 +6,6 @@ from models import EbuildModel, PackageModel, LicenseModel, CategoryModel, \
VirtualPackageModel, RepositoryFeedModel, \
RepositorySourceModel, LicenseGroupModel, PortageNewsModel
-class AbstractAnnotateAdmin(object):
- annotate_dict = {}
-
- def queryset(self, request):
- return super(AbstractAnnotateAdmin, self).queryset(request) \
- .annotate(**self.annotate_dict)
-
-class EbuildsCountAdmin(AbstractAnnotateAdmin):
- annotate_dict = {'ebuilds_count': Count('ebuildmodel')}
-
- def ebuilds_count(self, obj):
- return obj.ebuilds_count
-
-class PackagesCountAdmin(AbstractAnnotateAdmin):
- annotate_dict = {'packages_count': Count('packagemodel')}
-
- def packages_count(self, obj):
- return obj.packages_count
-
class KeywordAdmin(admin.TabularInline):
model = Keyword
@@ -45,20 +26,23 @@ class VirtualPackageAdmin(admin.ModelAdmin):
search_fields = ('name','category__category')
list_select_related = True
-class PackageAdmin(EbuildsCountAdmin, admin.ModelAdmin):
+class PackageAdmin(admin.ModelAdmin):
list_display = ('__unicode__', 'ebuilds_count')
list_filter = ('created_datetime', 'updated_datetime', 'herds')
list_select_related = True
-class HerdsAdmin(PackagesCountAdmin, admin.ModelAdmin):
- list_display = ('name', 'email', 'description', 'packages_count')
+class HerdsAdmin(admin.ModelAdmin):
+ list_display = ('name', 'email', 'description', 'packages_count',
+ 'ebuilds_count', 'maintainers_count',)
+ # 'repositories_count')
search_fields = ('name', 'email')
-class MaintainerAdmin(PackagesCountAdmin, admin.ModelAdmin):
- list_display = ('name', 'email', 'packages_count')
+class MaintainerAdmin(admin.ModelAdmin):
+ list_display = ('name', 'email', 'packages_count', 'ebuilds_count',
+ 'herds_count')
search_fields = ('name', 'email')
-class UseFlagAdmin(EbuildsCountAdmin, admin.ModelAdmin):
+class UseFlagAdmin(admin.ModelAdmin):
list_display = ('name', 'description', 'ebuilds_count')
search_fields = ('name', 'description')
@@ -70,12 +54,13 @@ class HomepageAdmin(admin.ModelAdmin):
list_display = ('url',)
search_fields = ('url',)
-class LicenseAdmin(EbuildsCountAdmin, admin.ModelAdmin):
+class LicenseAdmin(admin.ModelAdmin):
list_display = ('name', 'ebuilds_count')
search_fields = ('name',)
class RepositoryAdmin(admin.ModelAdmin):
- list_display = ('name', 'updated_datetime', 'official', 'homepage', 'quality')
+ list_display = ('name', 'updated_datetime', 'official', 'homepage',
+ 'quality', 'packages_count', 'ebuilds_count')
search_fields = ('name', 'description', 'owner_name', 'owner_email')
list_filter = ('created_datetime', 'updated_datetime', 'official', 'quality')
date_hierarchy = 'updated_datetime'
@@ -98,13 +83,18 @@ class PortageNewsAdmin(admin.ModelAdmin):
search_fields = ('name', 'title', 'message')
date_hierarchy = 'date'
+class CategoryAdmin(admin.ModelAdmin):
+ list_display = ('category', 'virtual_packages_count', 'packages_count',
+ 'ebuilds_count', 'repositories_count')
+ search_fields = ('category', 'description')
+
admin.site.register(EbuildModel, EbuildAdmin)
admin.site.register(VirtualPackageModel, VirtualPackageAdmin)
admin.site.register(PackageModel, PackageAdmin)
admin.site.register(LicenseModel, LicenseAdmin)
admin.site.register(LicenseGroupModel)
-admin.site.register(CategoryModel)
+admin.site.register(CategoryModel, CategoryAdmin)
admin.site.register(UseFlagModel, UseFlagAdmin)
admin.site.register(UseFlagDescriptionModel, UseFlagDescriptionAdmin)
admin.site.register(RepositoryModel, RepositoryAdmin)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-08 19:54 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-08 19:54 UTC (permalink / raw
To: gentoo-commits
commit: 510273d8195d12002e8e37fa5b98f5ecf307f22c
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 8 17:53:31 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 8 17:53:31 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=510273d8
Show keywords in alphabetical order
---
gpackages/apps/packages/views.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index e359bd1..32b4e7d 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -214,7 +214,7 @@ class ArchChoiceView(ContextView, ArchesViewMixin, FormView):
return {'arches': arches }
def form_valid(self, form):
- arches = form.cleaned_data['arches']
+ arches = sorted(form.cleaned_data['arches'])
# Maybe save it to cookies ?
# arches_str = ','.join(arches)
self.request.session['arches'] = arches
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-12 22:16 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-12 22:16 UTC (permalink / raw
To: gentoo-commits
commit: f694b485748519118602387dc674439b9dfa8051
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 11 11:31:43 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 11 11:31:43 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=f694b485
Add link properties to PackageModel
---
gpackages/apps/packages/models.py | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 67b59f6..b90049f 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -330,8 +330,18 @@ class VirtualPackageModel(models.Model):
objects = managers.VirtualPackageManager()
- #forum_template = /
- #"http://forums.gentoo.org/search.php?search_terms=all&show_results=topics&search_keywords=%s&mode=results"
+ forum_template = "http://forums.gentoo.org/search.php" \
+ "?search_terms=all&show_results=topics&search_keywords=%s&mode=results"
+
+ bugs_template = "https://bugs.gentoo.org/buglist.cgi" \
+ "?bug_status=UNCONFIRMED&bug_status=IN_PROGRESS&bug_status=CONFIRMED" \
+ "&query_format=&short_desc_type=allwords&short_desc=%s"
+
+ wiki_template = "http://en.gentoo-wiki.com/w/index.php" \
+ "?title=Special%%3ASearch&search=%s"
+
+ maillist_template = "http://www.mail-archive.com/search" \
+ "?q=%s&l=gentoo-user%%40lists.gentoo.org"
@property
def cp(self):
@@ -341,6 +351,18 @@ class VirtualPackageModel(models.Model):
def forum_link(self):
return self.forum_template % self.name
+ @property
+ def bugs_link(self):
+ return self.bugs_template % self.name
+
+ @property
+ def wiki_link(self):
+ return self.wiki_template % self.name
+
+ @property
+ def maillist_link(self):
+ return self.maillist_template % self.name
+
def __unicode__(self):
return unicode(self.cp)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-15 23:08 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-15 23:08 UTC (permalink / raw
To: gentoo-commits
commit: 6f5c6c5241b733b9629035a76374e354e48aeb82
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 15 18:12:33 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 15 18:12:33 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=6f5c6c52
Cache choices in filter form
---
gpackages/apps/packages/forms.py | 53 +++++++++++++++++++++++++------------
1 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/gpackages/apps/packages/forms.py b/gpackages/apps/packages/forms.py
index 974eb63..4784e23 100644
--- a/gpackages/apps/packages/forms.py
+++ b/gpackages/apps/packages/forms.py
@@ -2,6 +2,7 @@ from django import forms
from .models import ArchesModel, RepositoryModel, CategoryModel, HerdsModel, \
UseFlagModel, MaintainerModel, LicenseModel
from .widgets import DivCheckboxSelectMultiple
+from django.core.cache import cache
# Need rerun if database are empty
arches = ArchesModel.objects.exclude(name = '*').order_by('name').values_list('name', 'name')
@@ -13,29 +14,47 @@ class ArchChoiceForm(forms.Form):
#widget = forms.CheckboxSelectMultiple(attrs = {'class': 'inline checkbox'}),
choices = arches)
-class FilteringForm(forms.Form):
- def __init__(self, *args, **kwargs):
- super(FilteringForm, self).__init__(*args, **kwargs)
- repos = RepositoryModel.objects.all().order_by('name'). \
- values_list('name', 'name')
+def get_all_choices():
+ repos = RepositoryModel.objects.all().order_by('name'). \
+ values_list('name', 'name')
- categories = CategoryModel.objects.all().order_by('category'). \
- values_list('category', 'category')
+ categories = CategoryModel.objects.all().order_by('category'). \
+ values_list('category', 'category')
- herds = HerdsModel.objects.all().order_by('name'). \
- values_list('name','name')
+ herds = HerdsModel.objects.all().order_by('name'). \
+ values_list('name','name')
- uses = UseFlagModel.objects.all().order_by('name'). \
- values_list('name', 'name')
+ uses = UseFlagModel.objects.all().order_by('name'). \
+ values_list('name', 'name')
- #maintainers = MaintainerModel.all().order_by('email'). \
- # values_list('pk', 'email')
+ #maintainers = MaintainerModel.all().order_by('email'). \
+ # values_list('pk', 'email')
- licenses = LicenseModel.objects.all().order_by('name'). \
- values_list('name', 'name')
-
+ licenses = LicenseModel.objects.all().order_by('name'). \
+ values_list('name', 'name')
+
+ values = (repos, categories, herds, uses, licenses)
+ return values
+
+class FilteringForm(forms.Form):
+ def __init__(self, *args, **kwargs):
+ super(FilteringForm, self).__init__(*args, **kwargs)
names = ['repos', 'categories', 'herds', 'uses', 'licenses']
- values = [repos, categories, herds, uses, licenses]
+ names_cache = map(lambda x: x+'_f_list', names)
+ cache_vals = cache.get_many(names_cache)
+ f = False
+ values = []
+ for item in names_cache:
+ v = cache_vals.get(item, None)
+ if v is None:
+ f = True
+ break
+ values.append(v)
+
+ if f:
+ values = get_all_choices()
+ cache.set_many(dict(zip(names_cache, values)))
+
for k, v in zip(names, values):
self.fields[k].choices = v
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-15 23:08 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-15 23:08 UTC (permalink / raw
To: gentoo-commits
commit: 9f0e46c154cb578f3659f563a3701f5550edc371
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 15 17:34:17 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 15 17:34:17 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=9f0e46c1
Add base transactions support
---
gpackages/apps/packages/scan.py | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index e0cc09c..9135021 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -2,6 +2,7 @@ from datetime import datetime
from packages import models
import sys
from django.db import IntegrityError
+from django.db import transaction
from django.utils.encoding import smart_unicode
from collections import defaultdict
from package_info.generic import StrThatIgnoreCase, toint
@@ -255,6 +256,7 @@ class Scanner(object):
self.maintainers_cache = mo_dict
self.maitainers_cache_loaded = True
+ @transaction.commit_on_success
def scan_license_groups(self):
"Scan license groups"
self.write('Scaning license groups\n', 3)
@@ -268,6 +270,7 @@ class Scanner(object):
self.output("update license group '%s'\n", group, 2)
+ @transaction.commit_on_success
def scan_herds(self):
"Scan herds and maintainers in herds.xml"
self.write('Scaning herds\n', 3)
@@ -366,6 +369,7 @@ class Scanner(object):
if repo is not None:
self.scan_repo(repo, **kwargs)
+ @transaction.commit_on_success
def get_repo_obj(self, repo, update_repo = False):
repo_obj, repo_created = models.RepositoryModel \
.objects.get_or_create(repo = repo)
@@ -693,6 +697,7 @@ class Scanner(object):
news_obj.clear_related()
self.add_related_to_news(news, news_obj)
+ @transaction.commit_on_success
def scan_news_item(self, news_item):
for n in news_item.news.itervalues():
n_obj, created = models.PortageNewsModel.objects. \
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-18 23:20 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-18 23:20 UTC (permalink / raw
To: gentoo-commits
commit: bba55bafc9d076b29a8248fdd7c0516ab6c36f0e
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 18 23:19:41 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 18 23:19:41 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=bba55baf
Add short_description property to PackageModel
---
gpackages/apps/packages/models.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index bb8a67f..6eaaa1d 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -441,6 +441,10 @@ class PackageModel(StatsModel, AbstractDateTimeModel):
else:
return self.cpr
+ @property
+ def short_description(self):
+ return self.latest_ebuild.description
+
def init_by_package(self, package, category = None, virtual_package = None):
#self.name = package.name
self.update_info(package)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-18 23:20 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-18 23:20 UTC (permalink / raw
To: gentoo-commits
commit: 8e03f8abe96416287bb360fcb80764dfd392ca40
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 18 23:20:15 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 18 23:20:15 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=8e03f8ab
Prefetch latest_ebuild with all package ebuilds
---
gpackages/apps/packages/managers.py | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index 82ba10a..0d586e4 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -41,6 +41,8 @@ class EbuildsWithKeywrods(Prefetcher):
setattr(package, 'ebuilds', ebuilds)
for ebuild in ebuilds:
ebuild.package = package
+ if ebuild.pk == package.latest_ebuild_id:
+ package.latest_ebuild = ebuild
class KeywordsPrefetch(Prefetcher):
def __init__(self, arches):
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-19 23:50 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-19 23:50 UTC (permalink / raw
To: gentoo-commits
commit: c450f479c85fcdbe8d10fce6feae22a2a3fc0586
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jul 19 14:59:56 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jul 19 14:59:56 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=c450f479
More smart sort ebuilds by version
---
gpackages/apps/packages/managers.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index 0d586e4..b0ff424 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -30,9 +30,9 @@ class EbuildsWithKeywrods(Prefetcher):
self.keywords = keywords
def filter(self, ids):
- return packages.models.EbuildModel.objects. \
- filter(package__in = ids).order_by('-version', '-revision'). \
- prefetch_keywords(self.keywords)
+ ebuilds = packages.models.EbuildModel.objects. \
+ filter(package__in = ids).prefetch_keywords(self.keywords)
+ return sorted(ebuilds, key = lambda x: x.version_cmp, reverse = True)
def reverse_mapper(self, ebuild):
return [ebuild.package_id]
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-19 23:50 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-19 23:50 UTC (permalink / raw
To: gentoo-commits
commit: 167dcb0a229edc3239a680f2cfa6ac278a36d46b
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jul 19 19:17:58 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jul 19 19:17:58 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=167dcb0a
Fix bug with updating category description
---
gpackages/apps/packages/models.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 6eaaa1d..aabf5e2 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -233,7 +233,7 @@ class CategoryModel(StatsModel):
self.metadata_hash = category.metadata_sha1
def check_or_need_update(self, category):
- return self.metadata_hash == category.metadata_sha1
+ return self.metadata_hash != category.metadata_sha1
category = models.CharField(unique = True, max_length = 70, db_index = True)
description = models.TextField(blank = True, null = True)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-22 23:46 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-22 23:46 UTC (permalink / raw
To: gentoo-commits
commit: f7b03554777bb8d71636edaa2f82286b5d5060b3
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Jul 22 23:37:18 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Jul 22 23:37:27 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=f7b03554
Fix bug when delete latest ebuild
---
gpackages/apps/packages/models.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index aabf5e2..4dc1432 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -420,7 +420,8 @@ class PackageModel(StatsModel, AbstractDateTimeModel):
# ebuilds_count = models.PositiveIntegerField(default = 0)
# latest ebuild info
- latest_ebuild = models.ForeignKey('EbuildModel', blank = True, null = True)
+ latest_ebuild = models.ForeignKey('EbuildModel', blank = True, null = True,
+ on_delete = models.SET_NULL)
objects = managers.PackageManager()
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-25 22:47 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-25 22:47 UTC (permalink / raw
To: gentoo-commits
commit: e936666996220adfc8b14c555ca4075170a7a029
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jul 24 09:04:38 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jul 24 09:04:38 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=e9366669
Optimize searching latest ebuild in package
---
gpackages/apps/packages/scan.py | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index a02975b..6b32418 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -8,8 +8,9 @@ from collections import defaultdict
from package_info.generic import StrThatIgnoreCase, toint
from package_info.porttree import porttree
from django.core.cache import cache as cache_backend
-
+import logging
import anydbm
+logger = logging.getLogger(__name__)
portage = porttree
@@ -730,12 +731,15 @@ class Scanner(object):
@staticmethod
def set_latest_ebuilds_to_package():
- for package in models.PackageModel.objects.only('pk').iterator():
- # search latest ebuild should done by version and revison
+ for package_id, in models.PackageModel.objects.values_list('pk'):
+ # search latest ebuild should done by version and revision
# and database could not allow smart order by version becaouse
# version are compared as string
- ebuilds = package.ebuildmodel_set.only('version', 'revision').all()
- latest_ebuild = max(ebuilds, key = lambda x: x.version_cmp)
+ ebuilds = models.EbuildModel.objects.filter(package = package_id)
+ try:
+ latest_ebuild = max(ebuilds, key = lambda x: x.version_cmp)
+ except ValueError:
+ logger.exception('Bad package without ebuilds %s' % package_id)
# Hack for not update last modified datetime
- models.PackageModel.objects.filter(pk = package.pk). \
+ models.PackageModel.objects.filter(pk = package_id). \
update(latest_ebuild = latest_ebuild)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-25 22:47 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-25 22:47 UTC (permalink / raw
To: gentoo-commits
commit: dc4adfafdddafea0b3ccd5ce7b41552191c274f8
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Wed Jul 25 22:42:30 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Wed Jul 25 22:42:30 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=dc4adfaf
More right transactions
---
gpackages/apps/packages/scan.py | 71 ++++++++++++++++++++++-----------------
1 files changed, 40 insertions(+), 31 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index c99ed85..d7c2f63 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -580,6 +580,38 @@ class Scanner(object):
package_object.update_info(package)
package_object.save(force_update = True)
+ @transaction.commit_on_success
+ def scanpackage(self, package, porttree, category_object, porttree_obj,
+ force_update = False):
+ #if use_cache:
+ #key = str(porttree.name)+'/'+str(package)
+ #val = None
+ #if key in cache_dict:
+ #val = cache_dict[key]
+ #if val is not None and val == package.manifest_sha1:
+ #continue
+ self.output('%-44s [%s]\n', (package, porttree))
+ package_object, package_created = models.PackageModel.objects \
+ .only('changelog_hash', 'manifest_hash', 'metadata_hash') \
+ .get_or_create(package = package,
+ category = category_object,
+ repository = porttree_obj)
+ #if update_cache:
+ #key = str(porttree.name)+'/'+str(package)
+ #cache_dict[key] = package.manifest_sha1
+
+ if not package_created:
+ if package_object.check_or_need_update(package) or force_update:
+ # need update
+ self.update_package(package, package_object,
+ force_update = force_update)
+
+ return package_object.pk
+ # if package_created:
+ self.add_related_to_package(package, package_object)
+ self.create_ebuilds(package, package_object)
+ return package_object.pk
+
def scanpackages(self, porttree, porttree_obj, delete = True,
force_update = False, update_cache = True, use_cache = True):
"""Scan packages (and ebuilds) in porttree
@@ -604,34 +636,10 @@ class Scanner(object):
existend_categorys.append(category_object.pk)
for package in category.iter_packages():
- #if use_cache:
- #key = str(porttree.name)+'/'+str(package)
- #val = None
- #if key in cache_dict:
- #val = cache_dict[key]
- #if val is not None and val == package.manifest_sha1:
- #continue
- self.output('%-44s [%s]\n', (package, porttree))
- package_object, package_created = models.PackageModel.objects \
- .only('changelog_hash', 'manifest_hash', 'metadata_hash') \
- .get_or_create(package = package,
- category = category_object,
- repository = porttree_obj)
- #if update_cache:
- #key = str(porttree.name)+'/'+str(package)
- #cache_dict[key] = package.manifest_sha1
-
- existend_packages.append(package_object.pk)
- if not package_created:
- if package_object.check_or_need_update(package) or force_update:
- # need update
- self.update_package(package, package_object,
- force_update = force_update)
-
- continue
- # if package_created:
- self.add_related_to_package(package, package_object)
- self.create_ebuilds(package, package_object)
+ pk = self.scanpackage(package, porttree,
+ category_object, porttree_obj,
+ force_update)
+ existend_packages.append(pk)
if delete:
models.PackageModel.objects \
@@ -755,6 +763,7 @@ class Scanner(object):
latest_ebuild = max(ebuilds, key = lambda x: x.version_cmp)
except ValueError:
logger.exception('Bad package without ebuilds %s' % package_id)
- # Hack for not update last modified datetime
- models.PackageModel.objects.filter(pk = package_id). \
- update(latest_ebuild = latest_ebuild)
+ else:
+ # Hack for not update last modified datetime
+ models.PackageModel.objects.filter(pk = package_id). \
+ update(latest_ebuild = latest_ebuild)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-30 12:59 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-30 12:59 UTC (permalink / raw
To: gentoo-commits
commit: 71cdead14c0c426989322b5b0562e312cc3ba30c
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Jul 26 23:40:00 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Jul 26 23:48:16 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=71cdead1
Add simple rss for main page
---
gpackages/apps/packages/urls.py | 4 +++-
gpackages/apps/packages/views.py | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/urls.py b/gpackages/apps/packages/urls.py
index d2071fb..4a04940 100644
--- a/gpackages/apps/packages/urls.py
+++ b/gpackages/apps/packages/urls.py
@@ -4,7 +4,8 @@ from views import CategoriesListView, HerdsListView, MaintainersListView, \
PackagesListsView, PackageDetailView, EbuildDetailView, \
GlobalUseListView, NewsListView, NewsDetailView, \
LicenseDetailView, ArchChoiceView, LicensesListView, \
- LocalUseListView, FilteringView, RepoDetailView
+ LocalUseListView, FilteringView, RepoDetailView, \
+ MainPageFeed
urlpatterns = patterns('',
url(r'^categories/$', CategoriesListView.as_view(), name = 'categories'),
@@ -31,4 +32,5 @@ urlpatterns = patterns('',
url(r'^licenses/$', LicensesListView.as_view(), name = 'licenses'),
url(r'^filter/$', FilteringView.as_view(), name = 'filter'),
url(r'^repository/(?P<slug>[^/]+)/$', RepoDetailView.as_view(), name = 'repository'),
+ url(r'^rss/$', MainPageFeed()),
)
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index b7def3a..5fdde7b 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -10,6 +10,7 @@ from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
from package_info.parse_cp import EbuildParseCPVR, PackageParseCPR
+from django.contrib.syndication.views import Feed
arches = ['alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64', 'sparc', 'x86']
@@ -252,3 +253,20 @@ class RepoDetailView(DetailView):
context_object_name = 'repository'
slug_field = 'name'
queryset = RepositoryModel.objects.all()
+
+class MainPageFeed(Feed):
+ title = 'Feed'
+ link = '/rss/'
+ description = 'Descr'
+
+ def items(self):
+ return EbuildModel.objects.all()[:40]
+
+ def item_title(self, item):
+ return item.cpv_or_cpvr()
+
+ def item_description(self, item):
+ return item.description
+
+ def item_pubdate(self, item):
+ return item.created_datetime
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-30 23:30 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-30 23:30 UTC (permalink / raw
To: gentoo-commits
commit: a43df8385ddabf7d858bb9dbc5fe3ded9a68e2e8
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Jul 30 23:22:14 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Jul 30 23:22:14 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=a43df838
Add prefetching use descr
---
gpackages/apps/packages/managers.py | 27 +++++++++++++++++++++++++++
gpackages/apps/packages/models.py | 13 +++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index b0ff424..8e00278 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -44,6 +44,22 @@ class EbuildsWithKeywrods(Prefetcher):
if ebuild.pk == package.latest_ebuild_id:
package.latest_ebuild = ebuild
+class UseWithLocalDesc(Prefetcher):
+ def __init__(self, package):
+ self.package = package
+
+ def filter(self, ids):
+ return packages.models.UseFlagDescriptionModel.objects. \
+ filter(use_flag__in = ids, package = self.package)
+
+ def reverse_mapper(self, descr):
+ return [descr.use_flag_id]
+
+ def decorator(self, use_flag, descrs = ()):
+ if len(descrs)>0:
+ descr = descrs[0]
+ use_flag.local_descr = descr.description
+
class KeywordsPrefetch(Prefetcher):
def __init__(self, arches):
self.arches = arches
@@ -101,6 +117,17 @@ class PackageManager(PackageMixin, PrefetchManagerMixin):
prefetch_definitions = {'ebuilds': EbuildsWithKeywrods}
+class UseFlagQuerySet(PrefetchQuerySet):
+ def prefetch_package_descr(self, package):
+ return self.prefetch(P('descr', package = package))
+
+class UseFlagManager(PrefetchManagerMixin):
+ @classmethod
+ def get_query_set_class(cls):
+ return UseFlagQuerySet
+
+ prefetch_definitions = {'descr': UseWithLocalDesc}
+
class KeywordMixin(object):#{{{
def get_or_create(self, keyword=None, **kwargs):
if keyword is not None:
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 90c20de..238e864 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -532,12 +532,18 @@ class RemoteId(models.Model):
return u'%s:%s' % (self.get_type_display(), self.remote_id)
class UseFlagModel(StatsModel):
+ def __init__(self, *args, **kwargs):
+ super(UseFlagModel, self).__init__(*args, **kwargs)
+ self.local_descr = None
+
stats_params = (
('ebuilds_count', 'ebuildmodel'),
)
name = models.CharField(unique = True, max_length = 60, db_index = True)
description = models.TextField(blank = True)
+
+ objects = managers.UseFlagManager()
# Autogenerated fields for fast stats
#ebuilds_count = models.PositiveIntegerField(default = 0)
@@ -545,6 +551,13 @@ class UseFlagModel(StatsModel):
def __unicode__(self):
return self.name
+ @property
+ def descr(self):
+ if self.local_descr is not None:
+ return self.local_descr
+ else:
+ return self.description
+
class Meta:
ordering = ('name',)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-07-31 23:20 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-07-31 23:20 UTC (permalink / raw
To: gentoo-commits
commit: 54c5fdee540b786c1bbf74f2fc1a67669687c6d7
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Jul 31 21:44:14 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Jul 31 21:44:14 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=54c5fdee
Fix bug with invalid package atom
---
gpackages/apps/packages/views.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index 0d483f9..b6ddb97 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -11,6 +11,7 @@ from .forms import ArchChoiceForm, FilteringForm
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
+from django.http import Http404
from package_info.parse_cp import EbuildParseCPVR, PackageParseCPR
from django.contrib.sitemaps import Sitemap
@@ -159,6 +160,8 @@ class PackageDetailView(ArchesContexView, DetailView):
cpr = self.kwargs.get('cpr')
po = PackageParseCPR(cpr)
+ if not po.is_valid:
+ raise Http404
category, name = po.category, po.name
repository = po.repository_for_q
obj = get_object_or_404(queryset, name = name,
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-08-07 0:10 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-08-07 0:10 UTC (permalink / raw
To: gentoo-commits
commit: c3d7e3ba0363b814b21dfbe21075ac0a8df6779e
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Aug 6 16:33:55 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Aug 6 16:33:55 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=c3d7e3ba
Save dependences to database
---
gpackages/apps/packages/models.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 0a26aaa..bc592cd 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -666,6 +666,10 @@ class EbuildModel(AbstractDateTimeModel):
self.description = ebuild.description
self.eapi = ebuild.eapi_as_int
self.slot = ebuild.slot_for_q
+ # Depends
+ self.depend = ebuild.depends
+ self.rdepend = ebuild.rdepends
+ self.pdepend = ebuild.pdepends
def check_or_need_update(self, ebuild):
return self.ebuild_hash != ebuild.sha1
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-08-11 22:30 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-08-11 22:30 UTC (permalink / raw
To: gentoo-commits
commit: 3989c5d3aeb690211452bcc2c058689f9ff1be6f
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sat Aug 11 15:36:44 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sat Aug 11 15:36:44 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=3989c5d3
Add mask change methods in scan class
---
gpackages/apps/packages/scan.py | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index e42b7fc..660fcc3 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -772,3 +772,32 @@ class Scanner(object):
# Hack for not update last modified datetime
models.PackageModel.objects.filter(pk = package_id). \
update(latest_ebuild = latest_ebuild)
+
+ def add_mising_ebuilds(self):
+ for ebuild in porttree.iter_ebuilds():
+ try:
+ ebuild_obj = models.EbuildModel.objects.get(ebuild = ebuild)
+ except models.EbuildModel.DoesNotExist:
+ self.output('%-44s [%s]\n', (ebuild,
+ ebuild.package.category.porttree_name))
+ try:
+ package_obj = models.PackageModel.objects. \
+ get(package = ebuild.package)
+
+ except models.PackageModel.DoesNotExist:
+ pass
+ else:
+ self.update_ebuilds(ebuild.package, package_obj)
+
+ def update_ebuild_mask(self):
+ for ebuild in porttree.iter_ebuilds():
+ try:
+ ebuild_obj = models.EbuildModel.objects.get(ebuild = ebuild)
+ except models.EbuildModel.DoesNotExist:
+ continue
+ if ebuild_obj.is_hard_masked != ebuild.is_hard_masked:
+ self.output('%-44s [%s]\n', (ebuild,
+ ebuild.package.category.porttree_name))
+
+ ebuild_obj.is_hard_masked = ebuild.is_hard_masked
+ ebuild_obj.save(force_update = True)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-08-11 22:30 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-08-11 22:30 UTC (permalink / raw
To: gentoo-commits
commit: 3dd9acc0be41ef8c59534806fe715357733c0bef
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sat Aug 11 15:07:59 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sat Aug 11 15:07:59 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=3dd9acc0
Fix managers
---
gpackages/apps/packages/managers.py | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/gpackages/apps/packages/managers.py b/gpackages/apps/packages/managers.py
index 8e00278..0d82615 100644
--- a/gpackages/apps/packages/managers.py
+++ b/gpackages/apps/packages/managers.py
@@ -88,6 +88,8 @@ class PackageMixin(object):
args[1] = category
else:
kwargs.update({'name': name})
+ if 'repository' not in kwargs:
+ kwargs['repository__name'] = package.category.porttree_name
elif package is not None:
# Bad code !!
category, name = package.split('/')
@@ -147,8 +149,9 @@ class EbuildMixin(object):
if ebuild is not None and isinstance(ebuild, AbstractEbuild):
if package is None:
kwargs.update({
- 'package__category__category': ebuild.package.category,
- 'package__name': ebuild.package.name })
+ 'package__virtual_package__category__category': ebuild.package.category,
+ 'package__virtual_package__name': ebuild.package.name,
+ 'package__repository__name' : ebuild.package.category.porttree_name})
else:
kwargs.update({'package': package})
kwargs.update({ 'version': ebuild.version,
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-08-20 13:03 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-08-20 13:03 UTC (permalink / raw
To: gentoo-commits
commit: fbd46c29f259aeca7dc7e5608f30612285805c10
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Mon Aug 13 15:52:15 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Mon Aug 13 15:52:15 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=fbd46c29
Cache views
---
gpackages/apps/packages/views.py | 105 ++++++++++++++++++++++++++++++++-----
1 files changed, 90 insertions(+), 15 deletions(-)
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index 81f30e1..4e27892 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -14,14 +14,75 @@ from django.shortcuts import get_object_or_404
from django.http import Http404
from package_info.parse_cp import EbuildParseCPVR, PackageParseCPR
from django.contrib.sitemaps import Sitemap
+from django.core.cache import cache
+import hashlib
+import logging
+logger = logging.getLogger(__name__)
arches = ['alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64', 'sparc', 'x86']
+class CacheViewMixin(object):
+ cache_time = 30
+
+ def get_cache_keys(self):
+ path = self.request.path
+ lang = self.request.LANGUAGE_CODE
+ tz = self.request.session.get('django_timezone')
+ # self.request.GET
+ return (path, frozenset(self.args), self.kwargs, lang, tz)
+
+ @staticmethod
+ def hash_keys(keys):
+ str_keys = str(keys)
+ return hashlib.md5(str_keys).hexdigest()
+
+ def get_cache_key(self):
+ keys_hash = self.hash_keys(self.get_cache_keys())
+ class_name = type(self).__name__
+ return 'view_cache_%s:%s' % (class_name, keys_hash)
+
+ def get(self, request, *args, **kwargs):
+ key = self.get_cache_key()
+ response = cache.get(key)
+ class_name = type(self).__name__
+ logger.info('CacheView: %s, get from cache %s' % (class_name, key))
+ if response is not None:
+ return response
+ response = super(CacheViewMixin, self).get(request, *args, **kwargs)
+ if hasattr(response, 'render') and callable(response.render):
+ response.render()
+ cache.set(key, response, self.cache_time)
+ logger.info('CacheView: %s, set to cache %s' % (class_name, key))
+ return response
+
class ArchesViewMixin(object):
def get_arches(self):
arches_s = self.request.session.get('arches')
return arches_s or arches
-
+
+class ArchesCacheViewMixin(CacheViewMixin, ArchesViewMixin):
+
+ def get_cache_keys(self):
+ keys = super(ArchesCacheViewMixin, self).get_cache_keys()
+ arches_s = frozenset(self.get_arches())
+ return keys + (arches_s,)
+
+class PagebleCacheViewMixin(ArchesCacheViewMixin):
+
+ def get_cache_keys(self):
+ keys = super(PagebleCacheViewMixin, self).get_cache_keys()
+ page = self.request.GET.get('page')
+ return keys + (page, )
+
+class ArgsCacheViewMixin(ArchesCacheViewMixin):
+
+ def get_cache_keys(self):
+ keys = super(ArgsCacheViewMixin, self).get_cache_keys()
+ args = self.request.GET
+ return keys + (args,)
+
+class CacheFilterListView(ArgsCacheViewMixin, MultipleFilterListViewMixin):
+ pass
class ArchesContexView(ArchesViewMixin, ContextView):
def get_context_data(self, **kwargs):
@@ -36,38 +97,47 @@ class ArchesContexView(ArchesViewMixin, ContextView):
class ContextArchListView(ArchesContexView, ListView):
pass
-class CategoriesListView(ContextListView):
+class CategoriesListView(ArchesCacheViewMixin, ContextListView):
+ cache_time = 420
extra_context = {'page_name': 'Categories',}
template_name = 'categories.html'
queryset = CategoryModel.objects.defer('metadata_hash').all()
context_object_name = 'categories'
-class HerdsListView(ContextListView):
+class HerdsListView(ArchesCacheViewMixin, ContextListView):
+ cache_time = 420
extra_context = {'page_name': 'Herds',}
template_name = 'herds.html'
queryset = HerdsModel.objects.only('name', 'email', 'description').all()
context_object_name = 'herds'
-class MaintainersListView(ContextListView):
+class MaintainersListView(CacheFilterListView, ContextListView):
+ cache_time = 560
+ allowed_filter = { 'dev' : 'is_dev',
+ 'herd' : 'herdsmodel__name'}
+ allowed_order = { None: 'name'}
+ boolean_filters = ('dev',)
paginate_by = 40
extra_context = {'page_name': 'Maintainers',}
template_name = 'maintainers.html'
queryset = MaintainerModel.objects.only('name', 'email' ).all()
context_object_name = 'maintainers'
-class RepositoriesListView(ContextListView):
+class RepositoriesListView(ArchesCacheViewMixin, ContextListView):
extra_context = {'page_name': 'Repsitories',}
template_name = 'repositories.html'
queryset = RepositoryModel.objects.only('name', 'description' ).all()
context_object_name = 'repositories'
-class LicenseGroupsView(ContextListView):
+class LicenseGroupsView(ArchesCacheViewMixin, ContextListView):
+ cache_time = 820
extra_context = {'page_name': 'License Groups',}
queryset = LicenseGroupModel.objects.all().prefetch_related('licenses')
template_name = 'license_groups.html'
context_object_name = 'license_groups'
-class EbuildsListView(ContextArchListView):
+class EbuildsListView(PagebleCacheViewMixin, ContextArchListView):
+ cache_time = 420
paginate_by = 40
extra_context = {'page_name': 'Ebuilds', 'arches' : arches}
template_name = 'ebuilds.html'
@@ -78,7 +148,7 @@ class EbuildsListView(ContextArchListView):
'package__virtual_package__category'). \
prefetch_related('package__repository')
-class AtomDetailViewMixin(ArchesContexView, DetailView):
+class AtomDetailViewMixin(ArchesCacheViewMixin, ArchesContexView, DetailView):
parsing_class = EbuildParseCPVR
table_items = ['changelog', 'use_flags', 'licenses', 'dependences']
@@ -136,7 +206,8 @@ class EbuildDetailView(AtomDetailViewMixin):
revision = revision)
return obj
-class PackagesListsView(MultipleFilterListViewMixin, ContextArchListView):
+class PackagesListsView(CacheFilterListView, ContextArchListView):
+ cache_time = 420
allowed_filter = { 'category':'virtual_package__category__category',
'repo':'repository__name',
'herd':'herds__name',
@@ -201,7 +272,7 @@ class PackageDetailView(AtomDetailViewMixin):
repository__name = repository)
return obj
-class GlobalUseListView(ContextListView):
+class GlobalUseListView(ArchesCacheViewMixin, ContextListView):
extra_context = {'page_name': 'Global Use', }
template_name = 'global_use.html'
context_object_name = 'uses'
@@ -214,7 +285,7 @@ class LocalUseListView(ContextListView):
queryset = UseFlagDescriptionModel.objects.all().\
select_related('use_flag', 'package', 'package__category')
-class NewsListView(ContextListView):
+class NewsListView(PagebleCacheViewMixin, ContextListView):
extra_context = {'page_name': 'News'}
template_name = 'portage_news.html'
context_object_name = 'news'
@@ -222,7 +293,7 @@ class NewsListView(ContextListView):
queryset = PortageNewsModel.objects.filter(lang = 'en'). \
prefetch_related('authors', 'translators')
-class NewsDetailView(ContextView, DetailView):
+class NewsDetailView(ArchesCacheViewMixin, ContextView, DetailView):
extra_context = {'page_name': 'News Item'}
template_name = 'portage_news_item.html'
context_object_name = 'news_item'
@@ -230,14 +301,16 @@ class NewsDetailView(ContextView, DetailView):
queryset = PortageNewsModel.objects.filter(lang = 'en'). \
prefetch_related('authors', 'translators')
-class LicensesListView(ContextListView):
+class LicensesListView(PagebleCacheViewMixin, ContextListView):
+ cache_time = 300
extra_context = {'page_name': 'Licens'}
template_name = 'licenses.html'
context_object_name = 'licenses'
paginate_by = 20
queryset = LicenseModel.objects.all()
-class LicenseDetailView(ContextView, DetailView):
+class LicenseDetailView(ArchesCacheViewMixin, ContextView, DetailView):
+ cache_time = 300
extra_context = {'page_name': 'Licens'}
template_name = 'license.html'
context_object_name = 'license'
@@ -294,7 +367,8 @@ class FilteringView(FormView):
dct[v] = ','.join(vv)
return reverse('packages', kwargs = dct)
-class RepoDetailView(DetailView):
+class RepoDetailView(ArchesCacheViewMixin, DetailView):
+ cache_time = 900
template_name = 'repository.html'
context_object_name = 'repository'
slug_field = 'name'
@@ -343,3 +417,4 @@ def auto_package_or_ebuild(request, atom, *args, **kwargs):
return PackageDetailView.as_view()(request, parsed = p_atom, *args, **kwargs)
else:
raise Http404
+
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-08-20 13:03 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-08-20 13:03 UTC (permalink / raw
To: gentoo-commits
commit: e5baa17bb7d8194dce2afb9a942eb320495d957d
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Thu Aug 16 13:21:00 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Thu Aug 16 13:21:00 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=e5baa17b
Make is_dev field not editable
---
gpackages/apps/packages/models.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/models.py b/gpackages/apps/packages/models.py
index 1e2cac5..43293b0 100644
--- a/gpackages/apps/packages/models.py
+++ b/gpackages/apps/packages/models.py
@@ -271,7 +271,7 @@ class MaintainerModel(StatsModel, AbstractDateTimeModel):
name = models.CharField(max_length = 255, blank = True, null = True)
email = models.EmailField(unique = True, validators = [validate_email], db_index = True)
- is_dev = models.BooleanField(default = False)
+ is_dev = models.BooleanField(default = False, editable = False)
# Autogenerated fields for fast stats
# herds_count packages_count ebuilds_count repositories_count
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-08-26 23:00 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-08-26 23:00 UTC (permalink / raw
To: gentoo-commits
commit: 9dc23c05c47729d2b41c1c52f9fdb1b91924a48b
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sat Aug 25 21:09:52 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sat Aug 25 21:09:52 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=9dc23c05
Fix typos
---
gpackages/apps/packages/views.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gpackages/apps/packages/views.py b/gpackages/apps/packages/views.py
index 4e27892..5167a31 100644
--- a/gpackages/apps/packages/views.py
+++ b/gpackages/apps/packages/views.py
@@ -303,7 +303,7 @@ class NewsDetailView(ArchesCacheViewMixin, ContextView, DetailView):
class LicensesListView(PagebleCacheViewMixin, ContextListView):
cache_time = 300
- extra_context = {'page_name': 'Licens'}
+ extra_context = {'page_name': 'Licenses'}
template_name = 'licenses.html'
context_object_name = 'licenses'
paginate_by = 20
@@ -311,7 +311,7 @@ class LicensesListView(PagebleCacheViewMixin, ContextListView):
class LicenseDetailView(ArchesCacheViewMixin, ContextView, DetailView):
cache_time = 300
- extra_context = {'page_name': 'Licens'}
+ extra_context = {'page_name': 'License'}
template_name = 'license.html'
context_object_name = 'license'
slug_field = 'name'
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-09-13 22:17 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-09-13 22:17 UTC (permalink / raw
To: gentoo-commits
commit: 553233ac4f4168fa2e5b22ef734a9abdaf2c0d12
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Tue Aug 28 11:25:58 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Tue Aug 28 11:25:58 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=553233ac
Change category url conf
---
gpackages/apps/packages/urls.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gpackages/apps/packages/urls.py b/gpackages/apps/packages/urls.py
index c0207e9..64b6f45 100644
--- a/gpackages/apps/packages/urls.py
+++ b/gpackages/apps/packages/urls.py
@@ -35,5 +35,5 @@ urlpatterns = patterns('',
url(r'^rss/$', MainPageFeed()),
url(r'^atom/$', MainPageFeedAtom()),
url(r'^(?P<atom>[^/]+/[^/]+)/(?P<table_item>[^/]+)?$', auto_package_or_ebuild, name = 'auto'),
- url(r'^(?P<category>[^/]+)/$', PackagesListsView.as_view(), name = 'packages'),
+ url(r'^(?P<category>[\w-]+)/$', PackagesListsView.as_view(), name = 'packages'),
)
^ permalink raw reply related [flat|nested] 69+ messages in thread
* [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/
@ 2012-09-23 19:35 Slava Bacherikov
0 siblings, 0 replies; 69+ messages in thread
From: Slava Bacherikov @ 2012-09-23 19:35 UTC (permalink / raw
To: gentoo-commits
commit: 89cbe30b49424e6f454053258cfa10d79f4d37c2
Author: Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sun Sep 23 11:52:21 2012 +0000
Commit: Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sun Sep 23 11:52:21 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=89cbe30b
More pretty output
---
gpackages/apps/packages/scan.py | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index 792853b..a7100f1 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -215,6 +215,17 @@ class Scanner(object):
if verbosity <= self.verbosity:
sys.stdout.write(format_str % whats)
+ def print_aligment_text(self, left, right, verbosity = 1):
+ left, right = unicode(left), unicode(right)
+ # This constant should be changed
+ spaces = ' ' * (80 - (len(left) + len(right)))
+ self.output('%s%s%s\n', (left, spaces, right))
+
+ def print_package(self, left, right, end = '', verbosity = 1):
+ self.print_aligment_text('%s ' % left,
+ '[%s]%s ' % (right, end),
+ verbosity)
+
def get_existent_maintainers(self):
return models.MaintainerModel.objects.all()
@@ -607,7 +618,8 @@ class Scanner(object):
#val = cache_dict[key]
#if val is not None and val == package.manifest_sha1:
#continue
- self.output('%-44s [%s]\n', (package, porttree))
+ #self.output('%-44s [%s]\n', (package, porttree))
+ self.print_package(package, porttree)
package_object, package_created = models.PackageModel.objects \
.only('changelog_hash', 'manifest_hash', 'metadata_hash') \
.get_or_create(package = package,
@@ -800,8 +812,9 @@ class Scanner(object):
else:
# Don't run this for updated packages
if package_obj.manifest_hash == ebuild.package.manifest_sha1:
- self.output('%-44s [%s]M\n', (ebuild,
- ebuild.package.category.porttree_name))
+ self.print_package(ebuild,
+ ebuild.package.category.porttree_name, 'M')
+
self.update_ebuilds(ebuild.package, package_obj)
def add_mising_ebuilds(self):
@@ -821,8 +834,8 @@ class Scanner(object):
continue
if ebuild_obj.is_hard_masked != ebuild.is_hard_masked:
- self.output('%-44s [%s]\n', (ebuild,
- ebuild.package.category.porttree_name))
+ self.print_package(ebuild,
+ ebuild.package.category.porttree_name)
ebuild_obj.is_hard_masked = ebuild.is_hard_masked
ebuild_obj.save(force_update = True)
^ permalink raw reply related [flat|nested] 69+ messages in thread
end of thread, other threads:[~2012-09-23 19:36 UTC | newest]
Thread overview: 69+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-05 20:48 [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/ Slava Bacherikov
-- strict thread matches above, loose matches on Subject: below --
2012-09-23 19:35 Slava Bacherikov
2012-09-13 22:17 Slava Bacherikov
2012-08-26 23:00 Slava Bacherikov
2012-08-20 13:03 Slava Bacherikov
2012-08-20 13:03 Slava Bacherikov
2012-08-11 22:30 Slava Bacherikov
2012-08-11 22:30 Slava Bacherikov
2012-08-07 0:10 Slava Bacherikov
2012-07-31 23:20 Slava Bacherikov
2012-07-30 23:30 Slava Bacherikov
2012-07-30 12:59 Slava Bacherikov
2012-07-25 22:47 Slava Bacherikov
2012-07-25 22:47 Slava Bacherikov
2012-07-22 23:46 Slava Bacherikov
2012-07-19 23:50 Slava Bacherikov
2012-07-19 23:50 Slava Bacherikov
2012-07-18 23:20 Slava Bacherikov
2012-07-18 23:20 Slava Bacherikov
2012-07-15 23:08 Slava Bacherikov
2012-07-15 23:08 Slava Bacherikov
2012-07-12 22:16 Slava Bacherikov
2012-07-08 19:54 Slava Bacherikov
2012-07-05 23:27 Slava Bacherikov
2012-07-04 22:13 Slava Bacherikov
2012-07-03 21:08 Slava Bacherikov
2012-07-02 22:25 Slava Bacherikov
2012-06-29 17:29 Slava Bacherikov
2012-06-29 17:29 Slava Bacherikov
2012-06-28 23:59 Slava Bacherikov
2012-06-28 23:59 Slava Bacherikov
2012-06-27 22:52 Slava Bacherikov
2012-06-25 22:23 Slava Bacherikov
2012-06-24 23:21 Slava Bacherikov
2012-06-20 23:23 Slava Bacherikov
2012-06-20 23:23 Slava Bacherikov
2012-06-20 23:23 Slava Bacherikov
2012-06-13 22:15 Slava Bacherikov
2012-06-12 18:34 Slava Bacherikov
2012-06-10 22:56 Slava Bacherikov
2012-06-10 17:51 Slava Bacherikov
2012-06-09 18:19 Slava Bacherikov
2012-06-09 18:19 Slava Bacherikov
2012-06-07 22:48 Slava Bacherikov
2012-06-07 18:37 Slava Bacherikov
2012-06-07 18:37 Slava Bacherikov
2012-06-07 18:37 Slava Bacherikov
2012-06-07 18:37 Slava Bacherikov
2012-06-07 11:27 Slava Bacherikov
2012-06-06 22:48 Slava Bacherikov
2012-06-05 20:48 Slava Bacherikov
2012-06-05 20:48 Slava Bacherikov
2012-06-05 15:49 Slava Bacherikov
2012-06-05 15:49 Slava Bacherikov
2012-06-03 16:19 Slava Bacherikov
2012-06-03 13:19 Slava Bacherikov
2012-05-31 13:34 Slava Bacherikov
2012-05-29 21:34 Slava Bacherikov
2012-05-29 13:38 Slava Bacherikov
2012-05-29 12:24 Slava Bacherikov
2012-05-29 12:24 Slava Bacherikov
2012-05-29 12:24 Slava Bacherikov
2012-05-28 20:32 Slava Bacherikov
2012-05-28 17:00 Slava Bacherikov
2012-05-28 17:00 Slava Bacherikov
2012-05-28 17:00 Slava Bacherikov
2012-05-28 10:39 Slava Bacherikov
2012-05-28 10:39 Slava Bacherikov
2012-05-27 22:48 Slava Bacherikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox