mirror of
https://github.com/GAM-team/GAM.git
synced 2025-07-09 14:13:35 +00:00
Strip blanks, handle empty entries in gam file and gam csvfile
This commit is contained in:
13
src/gam.py
13
src/gam.py
@ -8664,8 +8664,12 @@ def getUsersToModify(entity_type=None, entity=None, silent=False, return_uids=Fa
|
|||||||
pass
|
pass
|
||||||
elif entity_type == u'file':
|
elif entity_type == u'file':
|
||||||
users = []
|
users = []
|
||||||
filename = entity
|
f = openFile(entity)
|
||||||
users = readFile(filename, u'rb').splitlines()
|
for row in f:
|
||||||
|
user = row.strip()
|
||||||
|
if user:
|
||||||
|
users.append(user)
|
||||||
|
closeFile(f)
|
||||||
elif entity_type == u'csvfile':
|
elif entity_type == u'csvfile':
|
||||||
try:
|
try:
|
||||||
(filename, column) = entity.split(u':')
|
(filename, column) = entity.split(u':')
|
||||||
@ -8679,8 +8683,9 @@ def getUsersToModify(entity_type=None, entity=None, silent=False, return_uids=Fa
|
|||||||
systemErrorExit(2, MESSAGE_HEADER_NOT_FOUND_IN_CSV_HEADERS.format(column, ','.join(input_file.fieldnames)))
|
systemErrorExit(2, MESSAGE_HEADER_NOT_FOUND_IN_CSV_HEADERS.format(column, ','.join(input_file.fieldnames)))
|
||||||
users = []
|
users = []
|
||||||
for row in input_file:
|
for row in input_file:
|
||||||
if column in row:
|
user = row[column].strip()
|
||||||
users.append(row[column])
|
if user:
|
||||||
|
users.append(user)
|
||||||
closeFile(f)
|
closeFile(f)
|
||||||
elif entity_type in [u'courseparticipants', u'teachers', u'students']:
|
elif entity_type in [u'courseparticipants', u'teachers', u'students']:
|
||||||
croom = buildGAPIObject(u'classroom')
|
croom = buildGAPIObject(u'classroom')
|
||||||
|
Reference in New Issue
Block a user