def create_service_from_json(task_handle, data, srv, event_id, service_ids=None):
 if (service_ids is None):
  service_ids = {}
 global CUR_ID
 data.sort(key=(lambda k: k['id']))
 ids = {}
 ct = 0
 total = len(data)
 for obj in data:
  ct += 1
  update_state(task_handle, ('Importing %s (%d/%d)' % (srv[0], ct, total)))
  (old_id, obj) = _trim_id(obj)
  CUR_ID = old_id
  obj = _delete_fields(srv, obj)
  obj = _fix_related_fields(srv, obj, service_ids)
  new_obj = srv[1].create(event_id, obj, 'dont')[0]
  ids[old_id] = new_obj.id
  _upload_media_queue(srv, new_obj)
 return ids

def create_service_from_json ( task_handle , data , srv , event_id , service_ids = None ) : if ( service_ids is None ) : service_ids = { } global CUR_ID data . sort ( key = ( lambda k : k [ 'id' ] ) ) ids = { } ct = 0 total = len ( data ) for obj in data : ct += 1 update_state ( task_handle , ( 'Importing %s (%d/%d)' % ( srv [ 0 ] , ct , total ) ) ) ( old_id , obj ) = _trim_id ( obj ) CUR_ID = old_id obj = _delete_fields ( srv , obj ) obj = _fix_related_fields ( srv , obj , service_ids ) new_obj = srv [ 1 ] . create ( event_id , obj , 'dont' ) [ 0 ] ids [ old_id ] = new_obj . id _upload_media_queue ( srv , new_obj ) return ids
given :data as json .