source: TI02-CSML/trunk/csml/API/__init__.py @ 2584

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

exposing getUnits methods etc

Line 
1''' __init__.py  '''
2
3
4#import element tree and the parser api
5from cElementTree import *
6import csml.parser
7import ops_Dataset
8import ops_FileExtract
9import ops_RawFileExtract
10import ops_ArrayGenerator
11import ops_AbstractFeature
12import ops_PointFeature
13import ops_PointSeriesFeature
14import ops_ProfileFeature
15import ops_ProfileSeriesFeature
16import ops_GridFeature
17import ops_GridSeriesFeature
18import ops_TrajectoryFeature
19import csmlContainer
20import types
21
22def getFuncsInModule(mod): 
23    fs = []
24    for key, item in mod.__dict__.items():
25        if type(item) is types.FunctionType:
26            fs.append(item)
27    return fs
28
29
30def appendMethods(obj, mod):
31    for func in getFuncsInModule(mod):
32        setattr(obj, func.__name__, func)
33
34
35operationsMap={csml.parser.Dataset:ops_Dataset, csml.parser.FileExtract:ops_FileExtract, csml.parser.RawFileExtract: ops_RawFileExtract, csml.parser.AbstractFeature:ops_AbstractFeature, csml.parser.GridSeriesFeature:ops_GridSeriesFeature, csml.parser.GridFeature:ops_GridFeature, csml.parser.PointSeriesFeature:ops_PointSeriesFeature, csml.parser.PointSeriesFeature:ops_PointSeriesFeature}
36
37
38for parserItem in operationsMap:
39    appendMethods(parserItem, operationsMap[parserItem])
40
Note: See TracBrowser for help on using the repository browser.