1 | ''' ops_Dataset contains operations for root Dataset class''' |
---|
2 | |
---|
3 | import codecs |
---|
4 | import csml.csmllibs.xmlEncoding |
---|
5 | import csml.parser_extra |
---|
6 | |
---|
7 | def testmethod(self): |
---|
8 | print 'testmethod for dataset' |
---|
9 | return 'testmethod dataset' |
---|
10 | |
---|
11 | def 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 | |
---|
23 | def 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 | |
---|
38 | def getFeatureList(self): |
---|
39 | #returns a list of feature ids for the dataset |
---|
40 | self.featureList = [] |
---|
41 | for member in self.featureCollection.featureMembers: |
---|
42 | self.featureList.append(member.id) |
---|
43 | return self.featureList |
---|
44 | |
---|
45 | def getFeature(self, featureID): |
---|
46 | """ returns a single feature object """ |
---|
47 | for member in self.featureCollection.featureMembers: |
---|
48 | if member.id == featureID: |
---|
49 | return member |
---|
50 | |
---|
51 | def getFileExtract(self,extractID): |
---|
52 | for extract in self.dataset.arrayDescriptors: |
---|
53 | if extract.id==extractID: |
---|
54 | return extract |
---|