source: TI01-discovery/branches/ingestion-MEDIN/ingestAutomation-upgrade/OAIBatch/testISO.py @ 6357

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/branches/ingestion-MEDIN/ingestAutomation-upgrade/OAIBatch/testISO.py@6357
Revision 6357, 2.5 KB checked in by sdonegan, 11 years ago (diff)

Updated so can handle multiple ordered elements - testIso.py updated to show all information

Line 
1from ExtractISO import ExtractISO
2import logging,os,pdb
3
4def accessIsoDataModel(struct,name):
5       
6        for i in struct:
7                if type(i) is dict:
8                        for j in i.keys():             
9                                print name + ": " + j + " = " + str(i[j])
10                if type(i) is list:
11                        for j in i:
12                                print name + ": " + j
13                if len(struct) > 1:
14                        print "-------------------------------"
15
16logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(filename)s:%(lineno)d %(levelname)s %(message)s')
17
18#test dif2stubIso xml file - converted from dif via xquery
19#dif2stubIso_file = 'data/NEODC/stub_iso/neodc.nerc.ac.uk__stubISO__dataent_11658383444211836_DIF_multiDate.xml'
20dif2stubIso_file = 'data/NEODC/stub_iso/neodc.nerc.ac.uk__stubISO__dataent_11658383444211836_DIF_multiCoord.xml'
21#dif2stubIso_file = 'data/NEODC/stub_iso/neodc.nerc.ac.uk__stubISO__dataent_11658383444211836_DIF.xml'
22
23isoData = ExtractISO(dif2stubIso_file,'dif2stubIso')
24
25if isoData.createISOdataStructure() is True:
26        logging.info("ISO extractor worked fine! (here are the variables...)")
27elif isoData.createISOdataStructure() is True:
28        logging.info ("Something wrong with ISO extractor... (ExtractISO returned False: xml access problem?)")
29        sys.exit()
30else:
31        logging.info( "Something SERIOUSELY wrong with extractor (couldnt get at ExtractISO class)")
32        sys.exit()
33
34print "\nTesting for bounding dates (list of dictionaries) ..."
35name = "boundingDates"
36accessIsoDataModel(isoData.boundingDates, name)
37
38print "\nTesting for datasetID (List)..."
39name = "datasetID"
40accessIsoDataModel(isoData.datasetID, name)
41
42print "\nTesting for keywords (List)..."
43name = "keywords"
44accessIsoDataModel(isoData.keywords, name)
45
46print "\nTesting for revision date (List)..."
47name = "revisionDate"
48accessIsoDataModel(isoData.revisionDate, name)
49
50print "\nTesting for creation date (List) ..."
51name = "createDate"
52accessIsoDataModel(isoData.createDate, name)
53       
54print "\nTesting for dataset name (List) ..."
55name = "datasetName"
56accessIsoDataModel(isoData.datasetName, name)
57               
58print "\nTesting for original format (List) ..."
59name = "originalFormat"
60accessIsoDataModel(isoData.originalFormat, name)
61       
62print "\nTesting for authors (List) ..."
63name = "authors"
64accessIsoDataModel(isoData.authors, name)
65               
66print "\nTesting for data centre name (List) ..."
67name = "datacentreName"
68accessIsoDataModel(isoData.datacentreName, name)
69       
70print "\nTesting for parameters (List) ..."
71name = "parameters"
72accessIsoDataModel(isoData.parameters, name)
73       
74print "\nTesting for data centre name (list of dictionaries) ..."
75name = "boundingBoxCoordinates"
76accessIsoDataModel(isoData.boundingBoxCoordinates, name)
Note: See TracBrowser for help on using the repository browser.