diff options
author | Dan McGee <dan@archlinux.org> | 2011-11-15 15:04:33 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-11-15 15:04:33 -0600 |
commit | 0344f8ad564644c50203985255fab1d053aed463 (patch) | |
tree | 9029728a3c96cbf1d6d8ce31edd6f1b5967a9b01 /packages/management/commands | |
parent | 84679f90a772e591dae2dea28194730d5453e6cf (diff) |
Add ability to cache users by username on the UserFinder
This is very useful in the signoff message population script where we
are very likely to encounter the same users over and over.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/management/commands')
-rw-r--r-- | packages/management/commands/populate_signoffs.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/packages/management/commands/populate_signoffs.py b/packages/management/commands/populate_signoffs.py index 5b5acbaf..ce5ec734 100644 --- a/packages/management/commands/populate_signoffs.py +++ b/packages/management/commands/populate_signoffs.py @@ -20,6 +20,7 @@ from django.core.management.base import NoArgsCommand from ...models import SignoffSpecification from ...utils import get_signoff_groups +from devel.utils import UserFinder logging.basicConfig( level=logging.INFO, @@ -58,17 +59,13 @@ def svn_log(pkgbase, repo): 'message': xml.findtext('logentry/msg'), } -def create_specification(package, log): +def create_specification(package, log, finder): trimmed_message = log['message'].strip() spec = SignoffSpecification(pkgbase=package.pkgbase, pkgver=package.pkgver, pkgrel=package.pkgrel, epoch=package.epoch, arch=package.arch, repo=package.repo, comments=trimmed_message) - try: - spec.user = User.objects.get(username=log['author']) - except User.DoesNotExist: - pass - + spec.user = finder.find_by_username(log['author']) return spec def add_signoff_comments(): @@ -76,6 +73,8 @@ def add_signoff_comments(): groups = get_signoff_groups() logger.info("%d signoff groups found", len(groups)) + finder = UserFinder() + for group in groups: if not group.default_spec: continue @@ -83,7 +82,7 @@ def add_signoff_comments(): logger.debug("getting SVN log for %s (%s)", group.pkgbase, group.repo) log = svn_log(group.pkgbase, group.repo) logger.info("creating spec with SVN message for %s", group.pkgbase) - spec = create_specification(group.packages[0], log) + spec = create_specification(group.packages[0], log, finder) spec.save() # vim: set ts=4 sw=4 et: |