-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_verniquet_records.py
74 lines (70 loc) · 4.32 KB
/
update_verniquet_records.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
import logging
from soduco_geonetwork.api_wrapper import (
config,
dataset,
geonetwork,
)
import pandas
def main():
logging.basicConfig(level="INFO")
logging.info("START")
#version = "bnf"
version = "stanford"
version_start = 1
list = pandas.read_csv(f"../geonetwork-resources/verniquet_{version}/yaml_list.csv")
session = geonetwork.log_in(
config.config["GEONETWORK_USER"], config.config["GEONETWORK_PASSWORD"]
)
for index, row in list.iterrows():
uuid = row["geonetwork_uuid"]
if (index > version_start):
sheet = index -version_start
wms = f"verniquet_{version}_{sheet}"
logging.info(f"Row {index} = Sheet{sheet} => {uuid} => {wms}")
#xpath = "./mdb:MD_Metadata/mdb:identificationInfo/mri:MD_DataIdentification/mri:citation/cit:CI_Citation"
#value = f"<gn_add><cit:identifier xmlns:cit=\"http://standards.iso.org/iso/19115/-3/cit/2.0\"><mcc:MD_Identifier xmlns:mcc=\"http://standards.iso.org/iso/19115/-3/mcc/1.0\"><mcc:code><gco:CharacterString xmlns:gco=\"http://standards.iso.org/iso/19115/-3/gco/1.0\">{wms}</gco:CharacterString></mcc:code><mcc:codeSpace><gco:CharacterString xmlns:gco=\"http://standards.iso.org/iso/19115/-3/gco/1.0\">wms_id</gco:CharacterString></mcc:codeSpace></mcc:MD_Identifier></cit:identifier></gn_add>"
#xpath = "./mdb:MD_Metadata/mdb:identificationInfo/mri:MD_DataIdentification/mri:citation/cit:CI_Citation/cit:identifier"
#value = "<gn_delete></gn_delete>"
#xpath = "./mdb:MD_Metadata/mdb:distributionInfo/mrd:MD_Distribution/mrd:transferOptions/mrd:MD_DigitalTransferOptions"
# value = f"<gn_add>\
# <mrd:onLine xmlns:mrd=\"http://standards.iso.org/iso/19115/-3/mrd/1.0\">\
# <cit:CI_OnlineResource xmlns:cit=\"http://standards.iso.org/iso/19115/-3/cit/2.0\">\
# <cit:linkage>\
# <gco:CharacterString xmlns:gco=\"http://standards.iso.org/iso/19115/-3/gco/1.0\">\
# https://map.geohistoricaldata.org/mapproxy/service=WMS?REQUEST=GetCapabilities\
# </gco:CharacterString>\
# </cit:linkage>\
# <cit:protocol xmlns:cit=\"http://standards.iso.org/iso/19115/-3/cit/2.0\">\
# <gco:CharacterString xmlns:gco=\"http://standards.iso.org/iso/19115/-3/gco/1.0\">OGC:WMS</gco:CharacterString>\
# </cit:protocol>\
# <cit:name xmlns:cit=\"http://standards.iso.org/iso/19115/-3/cit/2.0\">\
# <gco:CharacterString xmlns:gco=\"http://standards.iso.org/iso/19115/-3/gco/1.0\">{wms}</gco:CharacterString>\
# </cit:name>\
# <cit:description xmlns:cit=\"http://standards.iso.org/iso/19115/-3/cit/2.0\">\
# <gco:CharacterString xmlns:gco=\"http://standards.iso.org/iso/19115/-3/gco/1.0\">Visualisation</gco:CharacterString>\
# </cit:description>\
# <cit:function xmlns:cit=\"http://standards.iso.org/iso/19115/-3/cit/2.0\">\
# <cit:CI_OnLineFunctionCode codeList=\"http://standards.iso.org/iso/19115/resources/Codelists/cat/codelists.xml#CI_OnLineFunctionCode\" codeListValue=\"browsing\"/>\
# </cit:function>\
# </cit:CI_OnlineResource>\
# </mrd:onLine>\
# </gn_add>"
#xpath = "./mdb:MD_Metadata/mdb:distributionInfo/mrd:MD_Distribution/mrd:transferOptions/mrd:MD_DigitalTransferOptions/mrd:onLine/cit:CI_OnlineResource[starts-with(cit:linkage/gco:CharacterString,'https://www.davidrumsey') or starts-with(cit:linkage/gco:CharacterString,'https://dataverse') or starts-with(cit:linkage/gco:CharacterString,'https://gallica.bnf.fr')]/cit:protocol/gco:CharacterString"
#value = "<gn_replace>WWW:DOWNLOAD-1.0-http--download</gn_replace>"
xpath = ".//cit:CI_Organisation[cit:name/gco:CharacterString='The SoDUCo project' or cit:name/gco:CharacterString='The SoDUCo Project']"
value = "<gn_add>\
<cit:logo xmlns:cit=\"http://standards.iso.org/iso/19115/-3/cit/2.0\">\
<mcc:MD_BrowseGraphic xmlns:mcc=\"http://standards.iso.org/iso/19115/-3/mcc/1.0\">\
<mcc:fileName xmlns:mcc=\"http://standards.iso.org/iso/19115/-3/mcc/1.0\">\
<gco:CharacterString xmlns:gco=\"http://standards.iso.org/iso/19115/-3/gco/1.0\">https://catalog.geohistoricaldata.org/geonetwork/images/harvesting/soduco.png</gco:CharacterString>\
</mcc:fileName>\
</mcc:MD_BrowseGraphic>\
</cit:logo>\
<gn_add>"
logging.info(value)
response = dataset.update([uuid], xpath, value, session)
logging.info(response)
logging.info("END")
if __name__ == "__main__":
main()