source: TI02-CSML/trunk/parser/API/ops_Dataset.py @ 1438

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/parser/API/ops_Dataset.py@1438
Revision 1438, 1.9 KB checked in by domlowe, 13 years ago (diff)

Fix for XML unicode problems (I think). Tests files to see what format they are then passes the correct encoding information to elementtree. Requres further testing

Line 
1''' ops_Dataset  contains operations for root Dataset class'''
2from API import *
3import codecs
4
5def testmethod(self):
6    print 'testmethod for dataset'
7    return 'testmethod dataset'
8
9def parse(self,csmlfile):
10    """must be provided with csmlfile   parses the csmlfile into self """
11    #determine encoding
12    f = open(csmlfile)
13    startoffile=f.readline()
14    encoding=xmlEncoding.autoDetectXMLEncoding(startoffile)
15    f.close()
16    #parse with correct encoding
17    tree = parser_extra.encodingParser(csmlfile,encoding)
18    self.fromXML(tree.getroot())
19    self =parser_extra.ParserPostProcessor(self).resolveReferences()
20   
21def getSecurity(self):
22    """ returns a dictonary containing attributeAuthority: role"""
23    security=[]
24    if hasattr(self, 'accessControlPolicy'):
25        if hasattr(self.accessControlPolicy,'dgSecurityConditions'):
26            for condition in self.accessControlPolicy.dgSecurityConditions:
27                #need to test for these but ok for alpha.
28                cond=[]
29                cond.append(condition.effect)
30                cond.append(condition.simpleCondition.dgAttributeAuthority)
31                cond.append(condition.simpleCondition.attrauthRole)
32                cond.append(condition.conditionExplanationText)
33                security.append(cond)
34    return security
35
36def getFeatureList(self):
37    #returns a list of feature ids for the dataset
38    self.featureList = []
39    for member in self.featureCollection.members:
40            self.featureList.append(member.id)
41    return self.featureList
42   
43def getFeature(self, featureID):
44    """ returns a single feature object """
45    for member in self.featureCollection.members:
46            if member.id == featureID:
47                return member   
48
49def getFileExtract(self,extractID):
50        for extract in self.dataset.arrayDescriptors:
51            if  extract.id==extractID:
52                return extract
Note: See TracBrowser for help on using the repository browser.