def import_user_xml(xml_file='', _user=None):
'''
Import an XML file created by the ShakeCast workbook; Users
Args:
xml_file (string): The filepath to the xml_file that will be uploaded
_user (int): User id of admin making inventory changes
Returns:
dict: a dictionary that contains information about the function run
::
data = {'status': either 'finished' or 'failed',
'message': message to be returned to the UI,
'log': message to be added to ShakeCast log
and should contain info on error}
'''
with open(xml_file, 'r') as xml_str:
user_xml_dict = json.loads(json.dumps(xmltodict.parse(xml_str)))
user_list = user_xml_dict['UserTable']['UserRow']
if isinstance(user_list, list) is False:
user_list = [user_list]
data = import_user_dicts(user_list, _user)
return data
评论列表
文章目录