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

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

Helping csml work in python 2.5 (finding celementtree :-)

Line 
1''' __init__.py  '''
2
3
4#import element tree and the parser api
5try: #python 2.5
6    from xml.etree.cElementTree import *
7except ImportError:
8    try:
9        # if you've installed it yourself it comes this way
10        from cElementTree import *
11    except ImportError:
12        # if you've egged it this is the way it comes
13        from elementtree.cElementTree import *
14
15import csml.parser
16import ops_Dataset
17import ops_FileExtract
18import ops_RawFileExtract
19import ops_ArrayGenerator
20import ops_AbstractFeature
21import ops_PointFeature
22import ops_PointSeriesFeature
23import ops_ProfileFeature
24import ops_ProfileSeriesFeature
25import ops_GridFeature
26import ops_GridSeriesFeature
27import ops_TrajectoryFeature
28import csmlContainer
29import types
30
31def getFuncsInModule(mod): 
32    fs = []
33    for key, item in mod.__dict__.items():
34        if type(item) is types.FunctionType:
35            fs.append(item)
36    return fs
37
38
39def appendMethods(obj, mod):
40    for func in getFuncsInModule(mod):
41        setattr(obj, func.__name__, func)
42
43
44operationsMap={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,csml.parser.ProfileSeriesFeature:ops_ProfileSeriesFeature}
45
46
47for parserItem in operationsMap:
48    appendMethods(parserItem, operationsMap[parserItem])
49
Note: See TracBrowser for help on using the repository browser.