source: TI02-CSML/branches/CSML2/API/ops_Dataset.py @ 1902

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

beginning to refactor API module

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