~xnox/ubuntu-archive-tools/sru-report-autopkgtest-vomit

« back to all changes in this revision

Viewing changes to component-mismatches

  • Committer: Colin Watson
  • Date: 2012-07-31 11:51:59 UTC
  • Revision ID: cjwatson@canonical.com-20120731115159-a0g2d0dmq3p18rjw
Simplify using collections.defaultdict.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from __future__ import print_function
26
26
 
 
27
from collections import defaultdict
27
28
import copy
28
29
import gzip
29
30
from optparse import OptionParser
42
43
germinate_source = {}
43
44
germinate_binary = {}
44
45
 
45
 
seed_source = {}
46
 
seed_binary = {}
 
46
seed_source = defaultdict(set)
 
47
seed_binary = defaultdict(set)
47
48
 
48
49
 
49
50
def read_current_source(options):
125
126
 
126
127
        for arch in ["i386", "amd64", "powerpc", "armel", "armhf"]:
127
128
            for seed in seeds:
128
 
                if seed != "all":
129
 
                    if seed not in seed_binary:
130
 
                        seed_binary.setdefault(seed, set())
131
 
                    if seed not in seed_source:
132
 
                        seed_source.setdefault(seed, set())
133
129
                filename = "%s/%s_%s_%s_%s" \
134
130
                           % (local_germinate, seed, flavour,
135
131
                              options.suite, arch)
352
348
    # Additions
353
349
 
354
350
    output = ""
355
 
    binary_only = {}
356
 
    both = {}
 
351
    binary_only = defaultdict(dict)
 
352
    both = defaultdict(dict)
357
353
 
358
354
    source_add = copy.copy(orig_source_add)
359
355
    source_remove = copy.copy(orig_source_remove)
361
357
    for pkg in binary_add:
362
358
        (source, why, flavour, arch) = binary_add[pkg]
363
359
        if source not in orig_source_add:
364
 
            binary_only.setdefault(source, {})
365
360
            binary_only[source][pkg] = why
366
361
        else:
367
 
            both.setdefault(source, {})
368
362
            both[source][pkg] = why
369
363
            if source in source_add:
370
364
                source_add.remove(source)
431
425
 
432
426
    # Removals
433
427
 
434
 
    binary_only = {}
435
 
    both = {}
 
428
    binary_only = defaultdict(dict)
 
429
    both = defaultdict(dict)
436
430
    output = ""
437
431
    for pkg in binary_remove:
438
432
        source = get_source(pkg)
439
433
        if source not in orig_source_remove:
440
 
            binary_only.setdefault(source, {})
441
434
            binary_only[source][pkg] = ""
442
435
        else:
443
 
            both.setdefault(source, {})
444
436
            both[source][pkg] = ""
445
437
            if source in source_remove:
446
438
                source_remove.remove(source)
529
521
 
530
522
    Return a map source -> [(id, status, title), ...]
531
523
    '''
532
 
    result = {}
 
524
    result = defaultdict(list)
533
525
    mir_team = options.launchpad.people['ubuntu-mir']
534
526
    for source in sources:
535
527
        tasks = options.distro.getSourcePackage(name=source).searchTasks(
536
528
            bug_subscriber=mir_team)
537
529
        for task in tasks:
538
 
            result.setdefault(source, []).append(
539
 
                (task.bug.id, task.status, task.bug.title))
 
530
            result[source].append((task.bug.id, task.status, task.bug.title))
540
531
 
541
532
    return result
542
533