#NEWLINE# def normalize( sresult , force_id_mask = False ) : #NEWLINE# #INDENT# 'Replace time, updateSequence and version specific values with generic\n    values' #NEWLINE# version = re . search ( b'<!-- (.*) -->' , sresult ) #NEWLINE# updatesequence = re . search ( b'updateSequence="(\\S+)"' , sresult ) #NEWLINE# timestamp = re . search ( b'timestamp="(.*)"' , sresult ) #NEWLINE# timestamp2 = re . search ( b'timeStamp="(.*)"' , sresult ) #NEWLINE# timestamp3 = re . search ( b'<oai:responseDate>(.*)</oai:responseDate>' , sresult ) #NEWLINE# timestamp4 = re . search ( b'<oai:earliestDatestamp>(.*)</oai:earliestDatestamp>' , sresult ) #NEWLINE# zrhost = re . search ( b'<zr:host>(.*)</zr:host>' , sresult ) #NEWLINE# zrport = re . search ( b'<zr:port>(.*)</zr:port>' , sresult ) #NEWLINE# elapsed_time = re . search ( b'elapsedTime="(.*)"' , sresult ) #NEWLINE# expires = re . search ( b'expires="(.*?)"' , sresult ) #NEWLINE# atom_updated = re . findall ( b'<atom:updated>(.*)</atom:updated>' , sresult ) #NEWLINE# if version : #NEWLINE# #INDENT# sresult = sresult . replace ( version . group ( 0 ) , b'<!-- PYCSW_VERSION -->' ) #NEWLINE# #UNINDENT# if updatesequence : #NEWLINE# #INDENT# sresult = sresult . replace ( updatesequence . group ( 0 ) , b'updateSequence="PYCSW_UPDATESEQUENCE"' ) #NEWLINE# #UNINDENT# if timestamp : #NEWLINE# #INDENT# sresult = sresult . replace ( timestamp . group ( 0 ) , b'timestamp="PYCSW_TIMESTAMP"' ) #NEWLINE# #UNINDENT# if timestamp2 : #NEWLINE# #INDENT# sresult = sresult . replace ( timestamp2 . group ( 0 ) , b'timeStamp="PYCSW_TIMESTAMP"' ) #NEWLINE# #UNINDENT# if timestamp3 : #NEWLINE# #INDENT# sresult = sresult . replace ( timestamp3 . group ( 0 ) , b'<oai:responseDate>PYCSW_TIMESTAMP</oai:responseDate>' ) #NEWLINE# #UNINDENT# if timestamp4 : #NEWLINE# #INDENT# sresult = sresult . replace ( timestamp4 . group ( 0 ) , b'<oai:earliestDatestamp>PYCSW_TIMESTAMP</oai:earliestDatestamp>' ) #NEWLINE# #UNINDENT# if zrport : #NEWLINE# #INDENT# sresult = sresult . replace ( zrport . group ( 0 ) , b'<zr:port>PYCSW_PORT</zr:port>' ) #NEWLINE# #UNINDENT# if zrhost : #NEWLINE# #INDENT# sresult = sresult . replace ( zrhost . group ( 0 ) , b'<zr:host>PYCSW_HOST</zr:host>' ) #NEWLINE# #UNINDENT# if elapsed_time : #NEWLINE# #INDENT# sresult = sresult . replace ( elapsed_time . group ( 0 ) , b'elapsedTime="PYCSW_ELAPSED_TIME"' ) #NEWLINE# #UNINDENT# if expires : #NEWLINE# #INDENT# sresult = sresult . replace ( expires . group ( 0 ) , b'expires="PYCSW_EXPIRES"' ) #NEWLINE# #UNINDENT# for au in atom_updated : #NEWLINE# #INDENT# sresult = sresult . replace ( au , b'PYCSW_TIMESTAMP' ) #NEWLINE# #UNINDENT# if ( sresult . find ( b'HarvestResponse' ) != ( - 1 ) ) : #NEWLINE# #INDENT# identifier = re . findall ( b'<dc:identifier>(\\S+)</dc:identifier>' , sresult ) #NEWLINE# for i in identifier : #NEWLINE# #INDENT# sresult = sresult . replace ( i , b'PYCSW_IDENTIFIER' ) #NEWLINE# #UNINDENT# #UNINDENT# timestamp = re . search ( b'"@timestamp": "(.*?)"' , sresult ) #NEWLINE# if timestamp : #NEWLINE# #INDENT# sresult = sresult . replace ( timestamp . group ( 0 ) , b'"@timestamp": "PYCSW_TIMESTAMP"' ) #NEWLINE# #UNINDENT# if force_id_mask : #NEWLINE# #INDENT# dcid = re . findall ( b'<dc:identifier>(urn:uuid.*)</dc:identifier>' , sresult ) #NEWLINE# isoid = re . findall ( b'id="(urn:uuid.*)"' , sresult ) #NEWLINE# isoid2 = re . findall ( b'<gco:CharacterString>(urn:uuid.*)</gco' , sresult ) #NEWLINE# for d in dcid : #NEWLINE# #INDENT# sresult = sresult . replace ( d , b'PYCSW_IDENTIFIER' ) #NEWLINE# #UNINDENT# for i in isoid : #NEWLINE# #INDENT# sresult = sresult . replace ( i , b'PYCSW_IDENTIFIER' ) #NEWLINE# #UNINDENT# for i2 in isoid2 : #NEWLINE# #INDENT# sresult = sresult . replace ( d , b'PYCSW_IDENTIFIER' ) #NEWLINE# #UNINDENT# #UNINDENT# return sresult