diff options
author | Dan McGee <dan@archlinux.org> | 2011-04-29 10:16:17 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-04-29 10:16:17 -0500 |
commit | 23cda53f812f1b907def8a9dcac95167b8c7c395 (patch) | |
tree | 9f1d04b3ecd703e5f254dba0bf24a251c6922e9c /releng/management/commands/syncisos.py | |
parent | 87983d141b6b2134b22e7973b598ad7a73de17ce (diff) |
releng: auto-deactivate old ISO names
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'releng/management/commands/syncisos.py')
-rw-r--r-- | releng/management/commands/syncisos.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/releng/management/commands/syncisos.py b/releng/management/commands/syncisos.py index 247b01cd..ba174131 100644 --- a/releng/management/commands/syncisos.py +++ b/releng/management/commands/syncisos.py @@ -19,7 +19,7 @@ class IsoListParser(HTMLParser): for name, value in attrs: if name == "href": if value != '../' and self.url_re.search(value) != None: - self.hyperlinks.append(value[:len(value)-1]) + self.hyperlinks.append(value[:-1]) def parse(self, url): try: @@ -38,11 +38,14 @@ class Command(BaseCommand): def handle(self, *args, **options): parser = IsoListParser() isonames = Iso.objects.values_list('name', flat=True) - new_isos = parser.parse(settings.ISO_LIST_URL) + active_isos = parser.parse(settings.ISO_LIST_URL) - for iso in new_isos: + # create any names that don't already exist + for iso in active_isos: if iso not in isonames: - new = Iso(name=iso) + new = Iso(name=iso, active=True) new.save() + # and then mark all other names as no longer active + Iso.objects.exclude(name__in=active_isos).update(active=False) # vim: set ts=4 sw=4 et: |