source: TI02-CSML/trunk/csml/API/ops_Dataset.py @ 1484

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

moving xmlEncodign and NetCDFwriter into csmllibs

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