misc: fix pep8 error in migrate command
This commit is contained in:
parent
6b6053cce5
commit
b71d066bdb
|
@ -1,13 +1,12 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import csv
|
||||
import json
|
||||
import ldif
|
||||
import logging
|
||||
from optparse import make_option
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import IntegrityError
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
@ -33,7 +32,7 @@ class Command(BaseCommand):
|
|||
args = '<filename>'
|
||||
help = 'Migrate users from ldif file or csv file'
|
||||
|
||||
option_list = BaseCommand.option_list +(
|
||||
option_list = BaseCommand.option_list + (
|
||||
make_option(
|
||||
'--ldap',
|
||||
action='store_true',
|
||||
|
@ -60,9 +59,9 @@ class Command(BaseCommand):
|
|||
else:
|
||||
for filename in args:
|
||||
data = self.get_ldif_data(filename)
|
||||
data = [ d[1] for d in data]
|
||||
data = [d[1] for d in data]
|
||||
data = [
|
||||
{ k : ''.join(v) for k,v in d.items()} for d in data
|
||||
{k: ''.join(v) for k, v in d.items()} for d in data
|
||||
]
|
||||
self.migrate(data)
|
||||
|
||||
|
@ -76,7 +75,6 @@ class Command(BaseCommand):
|
|||
reader = csv.DictReader(fd, delimiter=';', quotechar='|', fieldnames=fieldnames)
|
||||
return list(reader)
|
||||
|
||||
|
||||
def migrate(self, parsed_data):
|
||||
issuer = get_issuer()
|
||||
|
||||
|
@ -85,8 +83,8 @@ class Command(BaseCommand):
|
|||
name_id = data.get('idpUniqueID')
|
||||
credentials = json.loads(data.get('spPostValues'))
|
||||
|
||||
user, created = User.objects.get_or_create(username=name_id,
|
||||
last_name=data.get('spLogin', ''))
|
||||
user, created = User.objects.get_or_create(
|
||||
username=name_id, last_name=data.get('spLogin', ''))
|
||||
|
||||
uc = UserCredentials(user=user, locators=credentials)
|
||||
uc.save()
|
||||
|
|
Reference in New Issue