diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2016-04-19 18:25:37 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2016-04-19 18:25:37 (GMT) |
commit | 3c78c9f3f4af3c52725947f277e37938fd6d4f08 (patch) | |
tree | 304010bbb643602965cfeba5684ab9b41de04b1b /program/management/commands | |
parent | 1d3301368c60efcb62dd4161e9e464c924b8f4d3 (diff) |
fixed pep8/flake8 warnings. again.
Diffstat (limited to 'program/management/commands')
-rw-r--r-- | program/management/commands/addnote.py | 11 | ||||
-rw-r--r-- | program/management/commands/cleanup_defaultshow.py | 5 | ||||
-rw-r--r-- | program/management/commands/createuser.py | 1 | ||||
-rw-r--r-- | program/management/commands/deleteuser.py | 3 | ||||
-rw-r--r-- | program/management/commands/importhosts.py | 1 | ||||
-rw-r--r-- | program/management/commands/importnotes.py | 9 | ||||
-rw-r--r-- | program/management/commands/importprogramslots.py | 8 | ||||
-rw-r--r-- | program/management/commands/importshows.py | 10 |
8 files changed, 29 insertions, 19 deletions
diff --git a/program/management/commands/addnote.py b/program/management/commands/addnote.py index 01d891e..5c0147e 100644 --- a/program/management/commands/addnote.py +++ b/program/management/commands/addnote.py @@ -1,4 +1,3 @@ -from django.contrib.auth.models import User from django.core.management.base import BaseCommand, CommandError from django.core.exceptions import ValidationError @@ -7,6 +6,7 @@ import sys from program.models import Show, TimeSlot, Note + class Command(BaseCommand): help = 'adds a note to a timeslot' args = '<show_id> <start_date> <status> [index]' @@ -40,11 +40,13 @@ class Command(BaseCommand): timeslot = TimeSlot.objects.get(show=show, start__year=year, start__month=month, start__day=day) except TimeSlot.DoesNotExist as dne: raise CommandError(dne) - except TimeSlot.MultipleObjectsReturned as mor: + except TimeSlot.MultipleObjectsReturned: if not index: - raise CommandError('you must provide the show_id, start_date, status index') + raise CommandError('you must provide the show_id, start_date, status index') try: - timeslot = TimeSlot.objects.filter(show=show, start__year=year, start__month=month, start__day=day).order_by('start')[int(index)] + timeslot = \ + TimeSlot.objects.filter(show=show, start__year=year, start__month=month, start__day=day).order_by( + 'start')[int(index)] except IndexError as ie: raise CommandError(ie) @@ -63,4 +65,3 @@ class Command(BaseCommand): else: note.save() print 'added note "%s" to "%s"' % (title, timeslot) - diff --git a/program/management/commands/cleanup_defaultshow.py b/program/management/commands/cleanup_defaultshow.py index 2f6ccca..98d3f98 100644 --- a/program/management/commands/cleanup_defaultshow.py +++ b/program/management/commands/cleanup_defaultshow.py @@ -3,10 +3,12 @@ from django.db import transaction from program.models import Show, TimeSlot, ProgramSlot + class Command(NoArgsCommand): + help = 'removes default shows without note' + @transaction.commit_manually def handle_noargs(self, **options): - help = 'removes default shows without note' default_show = Show.objects.get(pk=1) try: @@ -18,4 +20,3 @@ class Command(NoArgsCommand): transaction.rollback() else: transaction.commit() - diff --git a/program/management/commands/createuser.py b/program/management/commands/createuser.py index a356bb3..a78c101 100644 --- a/program/management/commands/createuser.py +++ b/program/management/commands/createuser.py @@ -3,6 +3,7 @@ from django.core.management.base import BaseCommand, CommandError from optparse import make_option + class Command(BaseCommand): help = 'creates an user' option_list = BaseCommand.option_list + ( diff --git a/program/management/commands/deleteuser.py b/program/management/commands/deleteuser.py index 27ce61e..db2cb60 100644 --- a/program/management/commands/deleteuser.py +++ b/program/management/commands/deleteuser.py @@ -3,6 +3,7 @@ from django.core.management.base import BaseCommand, CommandError from optparse import make_option + class Command(BaseCommand): help = 'deletes an user' option_list = BaseCommand.option_list + ( @@ -19,4 +20,4 @@ class Command(BaseCommand): except User.DoesNotExist: raise 'user does not exist.' else: - print 'user deleted succesfuly.'
\ No newline at end of file + print 'user deleted succesfuly.' diff --git a/program/management/commands/importhosts.py b/program/management/commands/importhosts.py index 1ecabef..31f4a3f 100644 --- a/program/management/commands/importhosts.py +++ b/program/management/commands/importhosts.py @@ -8,6 +8,7 @@ USER = 'helsinki' PASSWD = 'helsinki' DB = 'helsinki' + class Command(NoArgsCommand): help = 'Import hosts from current program' diff --git a/program/management/commands/importnotes.py b/program/management/commands/importnotes.py index 287dcef..0a1ab0f 100644 --- a/program/management/commands/importnotes.py +++ b/program/management/commands/importnotes.py @@ -1,7 +1,6 @@ -from django.contrib.auth.models import User from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, ValidationError from django.core.management.base import NoArgsCommand -from django.utils.html import clean_html, strip_tags +from django.utils.html import strip_tags import MySQLdb @@ -11,6 +10,7 @@ USER = 'helsinki' PASSWD = 'helsinki' DB = 'helsinki' + class Command(NoArgsCommand): help = 'Import notes from current program' @@ -26,7 +26,7 @@ WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_d for ntitel, datum, stitel, notiz in cursor.fetchall(): ntitel = strip_tags(ntitel) if ntitel else strip_tags(stitel) stitel = strip_tags(stitel) - notiz = clean_html(notiz) + notiz = strip_tags(notiz) if stitel.endswith('(Wiederholung)'): stitel = stitel[:-15] @@ -39,7 +39,8 @@ WHERE n.sendung_id in (SELECT id FROM sendungen WHERE letzter_termin > current_d print 'show with name "%s" not found' % stitel else: try: - timeslot = TimeSlot.objects.get(programslot__show=show, start__year=year, start__month=month, start__day=day) + timeslot = TimeSlot.objects.get(programslot__show=show, start__year=year, start__month=month, + start__day=day) except ObjectDoesNotExist: print 'no timeslot found for sendung "%s" and datum "%s"' % (stitel, datum) except MultipleObjectsReturned: diff --git a/program/management/commands/importprogramslots.py b/program/management/commands/importprogramslots.py index ce4f60e..b527f53 100644 --- a/program/management/commands/importprogramslots.py +++ b/program/management/commands/importprogramslots.py @@ -18,6 +18,7 @@ RRULES = { 28: RRule.objects.get(pk=5) } + class Command(NoArgsCommand): help = 'Import programslots from the current program' @@ -49,8 +50,8 @@ WHERE letzter_termin > current_date AND titel NOT LIKE 'Musikprogramm' AND titel except ObjectDoesNotExist: print 'show with name "%s" not found' % titel else: - programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, tstart=tstart, - tend=tend, until=letzter_termin) + programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, + tstart=tstart, tend=tend, until=letzter_termin) try: programslot.save() counter += 1 @@ -81,7 +82,8 @@ WHERE letzter_termin > current_date AND titel LIKE '%%(Wiederholung)'""") except ObjectDoesNotExist: print 'show with name "%s" not found' % titel else: - programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, tstart=tstart, tend=tend, until=letzter_termin, is_repetition=True) + programslot = ProgramSlot(rrule=rrule, byweekday=termin, show=show, dstart=erster_termin, + tstart=tstart, tend=tend, until=letzter_termin, is_repetition=True) try: programslot.save() counter += 1 diff --git a/program/management/commands/importshows.py b/program/management/commands/importshows.py index d5fdee7..f1353b8 100644 --- a/program/management/commands/importshows.py +++ b/program/management/commands/importshows.py @@ -1,7 +1,7 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django.core.management.base import NoArgsCommand from django.template.defaultfilters import slugify -from django.utils.html import clean_html, strip_tags +from django.utils.html import strip_tags import MySQLdb @@ -13,9 +13,10 @@ DB = 'helsinki' TALK = BroadcastFormat.objects.get(pk=1) + class Command(NoArgsCommand): help = 'Import shows from the current program' - + def handle_noargs(self, **options): connection = MySQLdb.connect(user=USER, passwd=PASSWD, db=DB) cursor = connection.cursor() @@ -29,7 +30,7 @@ ORDER BY titel, beginn, ende""") for titel, beschreibung, web, macher in cursor.fetchall(): titel = strip_tags(titel) - beschreibung = clean_html(beschreibung) + beschreibung = strip_tags(beschreibung) slug = slugify(titel) @@ -50,7 +51,8 @@ ORDER BY titel, beginn, ende""") show = Show.objects.get(name=titel) print 'sendung "%s" already imported as show "%s"' % (titel, show) except ObjectDoesNotExist: - show = Show(broadcastformat=TALK, name=titel, slug=slug, short_description='FIXME', description=beschreibung) + show = Show(broadcastformat=TALK, name=titel, slug=slug, short_description='FIXME', + description=beschreibung) try: show.save() counter += 1 |