use add_arguments

This commit is contained in:
j 2018-06-19 20:36:22 +02:00
parent dbf740e55e
commit ebd23c9e52

View file

@ -20,14 +20,19 @@ class Command(BaseCommand):
""" """
help = 'import annotations from srt or vtt' help = 'import annotations from srt or vtt'
args = 'username item layername filename.srt' args = 'username item layername filename.srt'
option_list = BaseCommand.option_list + (
) def add_arguments(self, parser):
parser.add_argument('username', help='username')
parser.add_argument('item', help='item')
parser.add_argument('layername', help='layer')
parser.add_argument('filename', help='filename.srt')
def handle(self, *args, **options): def handle(self, *args, **options):
if len(args) != 4: username = options['username']
print(self.usage('import_srt')) public_id = options['item']
return layer_id = options['layer']
username, public_id, layer_id, filename = args filename = options['filename']
user = User.objects.get(username=username) user = User.objects.get(username=username)
item = Item.objects.get(public_id=public_id) item = Item.objects.get(public_id=public_id)
layer = list(filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers']))[0] layer = list(filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers']))[0]