[1111] | 1 | ''' ops_Dataset contains operations for root Dataset class''' |
---|
[1490] | 2 | |
---|
[1438] | 3 | import codecs |
---|
[1484] | 4 | import csml.csmllibs.xmlEncoding |
---|
[1485] | 5 | import csml.parser_extra |
---|
[1111] | 6 | |
---|
| 7 | def testmethod(self): |
---|
| 8 | print 'testmethod for dataset' |
---|
| 9 | return 'testmethod dataset' |
---|
| 10 | |
---|
| 11 | def parse(self,csmlfile): |
---|
[1438] | 12 | """must be provided with csmlfile parses the csmlfile into self """ |
---|
| 13 | #determine encoding |
---|
| 14 | f = open(csmlfile) |
---|
| 15 | startoffile=f.readline() |
---|
[1484] | 16 | encoding=csml.csmllibs.xmlEncoding.autoDetectXMLEncoding(startoffile) |
---|
[1438] | 17 | f.close() |
---|
| 18 | #parse with correct encoding |
---|
[1485] | 19 | tree = csml.parser_extra.encodingParser(csmlfile,encoding) |
---|
[1438] | 20 | self.fromXML(tree.getroot()) |
---|
[1485] | 21 | self =csml.parser_extra.ParserPostProcessor(self).resolveReferences() |
---|
[1438] | 22 | |
---|
[1170] | 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 | |
---|
[1111] | 38 | def getFeatureList(self): |
---|
| 39 | #returns a list of feature ids for the dataset |
---|
| 40 | self.featureList = [] |
---|
[2061] | 41 | for member in self.featureCollection.featureMembers: |
---|
[1111] | 42 | self.featureList.append(member.id) |
---|
| 43 | return self.featureList |
---|
| 44 | |
---|
| 45 | def getFeature(self, featureID): |
---|
| 46 | """ returns a single feature object """ |
---|
[2061] | 47 | for member in self.featureCollection.featureMembers: |
---|
[1111] | 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 |
---|