factorize csv list to python list converter
This commit is contained in:
parent
c8ad7a4670
commit
d535e13756
|
@ -64,7 +64,7 @@ Installation on Debian with Apache2/mod_wsgi
|
|||
|
||||
First install some development libraries::
|
||||
|
||||
sudo apt-get install gcc libldap-dev libsasl2-dev python-dev libssl-dev libpq-dev swig
|
||||
sudo apt-get install gcc libldap-dev libsasl2-dev python-dev libssl-dev libpq-dev swig gettext
|
||||
|
||||
Now you can follow the generic installation described before.
|
||||
|
||||
|
@ -106,7 +106,7 @@ Installation on Debian using gunicorn and apache2
|
|||
|
||||
First install some development libraries::
|
||||
|
||||
apt-get install gcc libldap-dev libsasl2-dev python-dev libssl-dev libpq-dev swig
|
||||
apt-get install gcc libldap-dev libsasl2-dev python-dev libssl-dev libpq-dev swig gettext
|
||||
|
||||
Now you can follow the generic installation described before.
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ def unicode_csv_reader(utf8_csv_data, dialect=csv.excel, **kwargs):
|
|||
# decode UTF-8 back to Unicode, cell by cell:
|
||||
yield [unicode(cell, 'utf-8') for cell in row]
|
||||
|
||||
def csv_to_list(s):
|
||||
return filter(None, map(unicode.strip, s.split(u',')))
|
||||
|
||||
# Utilise seulement des majuscules et des chiffres, sauf i,l et 1, O et 0
|
||||
__pwd_alphabet = 'ABCDEFGHJKMNPQRSTUVWXYZ23456789'
|
||||
def create_password(pwd_length=8):
|
||||
|
@ -61,16 +64,16 @@ class Command(BaseCommand):
|
|||
data['username'] = username
|
||||
|
||||
if 'profil' not in data:
|
||||
default_profiles = map(unicode.strip, map(unicode, options.get('profile',[])))
|
||||
default_profiles = csv_to_list(','.join(map(unicode, options.get('profile',[]))))
|
||||
data['profil'] = default_profiles
|
||||
else:
|
||||
data['profil'] = map(unicode.strip, data['profil'].split(u','))
|
||||
data['profil'] = csv_to_list(data['profil'])
|
||||
|
||||
if 'groupe' not in data:
|
||||
default_groups = map(unicode.strip, map(unicode, options.get('group',[])))
|
||||
default_groups = csv_to_list(','.join(map(unicode, options.get('group',[]))))
|
||||
data['groupe'] = default_groups
|
||||
else:
|
||||
data['groupe'] = map(unicode.strip, data['groupe'].split(u','))
|
||||
data['groupe'] = csv_to_list(data['groupe'])
|
||||
|
||||
if not data.get('password'):
|
||||
if options.get('password'):
|
||||
|
|
Loading…
Reference in New Issue