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

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

now shows element numbers too

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