launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12492
[Merge] lp:~lifeless/python-oops-datedir-repo/bug-1003627 into lp:python-oops-datedir-repo
Robert Collins has proposed merging lp:~lifeless/python-oops-datedir-repo/bug-1003627 into lp:python-oops-datedir-repo.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~lifeless/python-oops-datedir-repo/bug-1003627/+merge/126392
Implement a feature request around pruning - support pruning multiple projects or project groups at once. The core already handled this mostly, so it was trivial. I haven't reduced test coverage at all.
--
https://code.launchpad.net/~lifeless/python-oops-datedir-repo/bug-1003627/+merge/126392
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/python-oops-datedir-repo/bug-1003627 into lp:python-oops-datedir-repo.
=== modified file 'NEWS'
--- NEWS 2012-09-26 06:35:34 +0000
+++ NEWS 2012-09-26 06:59:20 +0000
@@ -6,6 +6,11 @@
NEXT
----
+* prune now supports passing multiple projects and or project groups
+ in one invocation. For API compatibility, the parameters are type inspected,
+ in a future release passing strings will be deprecated or removed.
+ (Robert Collins, #1003627)
+
* The legacy uniquefileallocator code path has been dropped, fixing
the bugs associated with its flawed design. As a result the
instance_id parameter to DateDirRepo.__init__ has been dropped.
=== modified file 'oops_datedir_repo/prune.py'
--- oops_datedir_repo/prune.py 2012-09-18 07:40:15 +0000
+++ oops_datedir_repo/prune.py 2012-09-26 06:59:20 +0000
@@ -47,12 +47,23 @@
def find_oops_references(self, start_time, end_time, project=None,
projectgroup=None):
+ """Find oops references from start_time to end_time.
+
+ :param project: Either None or a project name, or a list of projects.
+ :param projectgroup: Either None or a project group name or a list
+ of project group names.
+ """
projects = set([])
if project is not None:
- projects.add(project)
+ if type(project) is not list:
+ project = [project]
+ projects.update(project)
if projectgroup is not None:
- [projects.add(lp_proj.name)
- for lp_proj in self.lp.project_groups[projectgroup].projects]
+ if type(projectgroup) is not list:
+ projectgroup = [projectgroup]
+ for group in projectgroup:
+ [projects.add(lp_proj.name)
+ for lp_proj in self.lp.project_groups[group].projects]
result = set()
lp_projects = self.lp.projects
one_week = datetime.timedelta(weeks=1)
@@ -82,7 +93,7 @@
The following options must be supplied:
--repo
- And either
+ And at least one of either
--project
or
--projectgroup
@@ -92,6 +103,8 @@
Will process every member project of launchpad-project.
+ --project and --projectgroup can be supplied multiple times.
+
When run this program will ask Launchpad for OOPS references made since
the last date it pruned up to, with an upper limit of one week from
today. It then looks in the repository for all oopses created during
@@ -103,9 +116,9 @@
"Delete OOPS reports that are not referenced in a bug tracker."
parser = optparse.OptionParser(
description=description, usage=usage)
- parser.add_option('--project',
+ parser.add_option('--project', action="append",
help="Launchpad project to find references in.")
- parser.add_option('--projectgroup',
+ parser.add_option('--projectgroup', action="append",
help="Launchpad project group to find references in.")
parser.add_option('--repo', help="Path to the repository to read from.")
parser.add_option(
@@ -122,9 +135,6 @@
else:
raise ValueError(
'One of options %s must be supplied' % (optnames,))
- elif len(present) != 1:
- raise ValueError(
- 'Only one of options %s can be supplied' % (optnames,))
needed('repo')
needed('project', 'projectgroup')
logging.basicConfig(