~ubuntu-langpack/langpack-o-matic/main

« back to all changes in this revision

Viewing changes to import

  • Committer: Martin Pitt
  • Date: 2015-10-06 09:13:29 UTC
  • Revision ID: martin.pitt@canonical.com-20151006091329-0cd72ee9mm36mrhc
Fix discarding with custom classes

Don't let a subsequent --class import discard langpacks from a previous run
which was not for this class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
411
411
            pot_priority[i['translation_domain']] = i['priority']
412
412
 
413
413
 
414
 
def discard_languages(langs):
415
 
    '''Remove built packages for given languages'''
 
414
def discard_languages(langs, custom_class=None):
 
415
    '''Remove built packages for given languages
416
416
 
 
417
    When custom_class is given, only remove packages for that.
 
418
    '''
417
419
    if not langs:
418
420
        return
419
421
 
422
424
        for pkg in f:
423
425
            packages.append(pkg.strip())
424
426
    for pkg in list(packages):
 
427
        if custom_class and 'sources-%s/' % custom_class not in pkg:
 
428
            continue
425
429
        for l in langs:
426
430
            if pkg.endswith('-' + l) or '-%s-' % l in pkg:
427
431
                logging.debug('Discarding %s', pkg)
626
630
            else:
627
631
                print('  %s\t%i' % (l, lang_count[l]))
628
632
 
629
 
        discard_languages(discarded)
 
633
        discard_languages(discarded, options.custom_class)
630
634
finally:
631
635
    shutil.rmtree(contentdirbase, True)