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

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

handling standard name in phenomenon

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 ops_RaggedSectionFeature
29import ops_Phenomenon
30import csmlContainer
31import types
32
33def getFuncsInModule(mod): 
34    fs = []
35    for key, item in mod.__dict__.items():
36        if type(item) is types.FunctionType:
37            fs.append(item)
38    return fs
39
40
41def appendMethods(obj, mod):
42    for func in getFuncsInModule(mod):
43        setattr(obj, func.__name__, func)
44
45
46operationsMap={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.ProfileSeriesFeature:ops_ProfileSeriesFeature,csml.parser.TrajectoryFeature:ops_TrajectoryFeature, csml.parser.RaggedSectionFeature:ops_RaggedSectionFeature, csml.parser.Phenomenon:ops_Phenomenon}
47
48
49for parserItem in operationsMap:
50    appendMethods(parserItem, operationsMap[parserItem])
51
Note: See TracBrowser for help on using the repository browser.