def set_metadata(xml):
 try:
  exml = etree.fromstring(xml)
 except Exception as err:
  raise GeoNodeException(('Uploaded XML document is not XML: %s' % str(err)))
 tagname = get_tagname(exml)
 if (tagname == 'GetRecordByIdResponse'):
  LOGGER.info('stripping CSW root element')
  exml = exml.getchildren()[0]
  tagname = get_tagname(exml)
 if (tagname == 'MD_Metadata'):
  (identifier, vals, regions, keywords) = iso2dict(exml)
 elif (tagname == 'metadata'):
  (identifier, vals, regions, keywords) = fgdc2dict(exml)
 elif (tagname == 'Record'):
  (identifier, vals, regions, keywords) = dc2dict(exml)
 else:
  raise RuntimeError('Unsupported metadata format')
 if (not vals.get('date')):
  vals['date'] = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
 return [identifier, vals, regions, keywords]

def set_metadata ( xml ) : try : exml = etree . fromstring ( xml ) except Exception as err : raise GeoNodeException ( ( 'Uploaded XML document is not XML: %s' % str ( err ) ) ) tagname = get_tagname ( exml ) if ( tagname == 'GetRecordByIdResponse' ) : LOGGER . info ( 'stripping CSW root element' ) exml = exml . getchildren ( ) [ 0 ] tagname = get_tagname ( exml ) if ( tagname == 'MD_Metadata' ) : ( identifier , vals , regions , keywords ) = iso2dict ( exml ) elif ( tagname == 'metadata' ) : ( identifier , vals , regions , keywords ) = fgdc2dict ( exml ) elif ( tagname == 'Record' ) : ( identifier , vals , regions , keywords ) = dc2dict ( exml ) else : raise RuntimeError ( 'Unsupported metadata format' ) if ( not vals . get ( 'date' ) ) : vals [ 'date' ] = datetime . datetime . now ( ) . strftime ( '%Y-%m-%dT%H:%M:%S' ) return [ identifier , vals , regions , keywords ]
generate dict of model properties based on xml metadata .