Ignore:
Timestamp:
13/06/07 13:24:28 (13 years ago)
Author:
domlowe
Message:

exposing getUnits methods etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI02-CSML/trunk/csml/API/__init__.py

    r2562 r2584  
    1818import ops_TrajectoryFeature 
    1919import csmlContainer 
     20import types 
    2021 
    21 def addMethods(obj, meths): 
    22     for meth in meths: 
    23         setattr(obj, meth.__name__, meth) 
     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 
    2428 
    25 #Assign methods to parser classes 
    26 #Dataset methods: 
    27 addMethods(csml.parser.Dataset, [ops_Dataset.parse, ops_Dataset.getSecurity, ops_Dataset.getFeatureList, ops_Dataset.getFeature, ops_Dataset.getFileExtract]) 
    2829 
    29 #AbstractFileExtract methods: 
    30 addMethods(csml.parser.FileExtract, [ops_FileExtract.getData,ops_FileExtract.getDataFromChunks]) 
     30def appendMethods(obj, mod): 
     31    for func in getFuncsInModule(mod): 
     32        setattr(obj, func.__name__, func) 
    3133 
    32 #RawFileExtract methods: 
    33 addMethods(csml.parser.RawFileExtract, [ops_RawFileExtract.getData]) 
    3434 
    35 #ArrayGenerator methods: 
    36 #addMethods(csml.parser.ArrayGenerator, [ops_ArrayGenerator.getGeneratedValues]) 
     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} 
    3736 
    38 ##AbstractFeature methods: 
    39 addMethods(csml.parser.AbstractFeature, [ops_AbstractFeature.testmethod, ops_AbstractFeature.getAllowedSubsettings]) 
    4037 
    41 ##PointFeature methods: 
    42 #addMethods(csml.parser.PointFeature,[ops_PointFeature.testmethod]) 
     38for parserItem in operationsMap: 
     39    appendMethods(parserItem, operationsMap[parserItem]) 
    4340 
    44 ##PointSeriesFeature methods: 
    45 addMethods(csml.parser.PointSeriesFeature, [ops_PointSeriesFeature.testmethod,ops_PointSeriesFeature.getDomain, ops_PointSeriesFeature.subsetToPointSeries,ops_PointSeriesFeature.subsetToPoint,  ops_PointSeriesFeature.getAllowedSubsettings]) 
    46  
    47 ##ProfileFeature methods: 
    48 #addMethods(csml.parser.ProfileFeature,[ops_ProfileFeature.testmethod]) 
    49  
    50 ##ProfileSeriesFeature methods: 
    51 addMethods(csml.parser.ProfileSeriesFeature,[ops_ProfileSeriesFeature.testmethod, ops_ProfileSeriesFeature.getDomain, ops_ProfileSeriesFeature.subsetToProfile,ops_ProfileSeriesFeature.subsetToPointSeries,ops_ProfileSeriesFeature._subsetProfileSeries]) 
    52  
    53 ##GridFeature methods: 
    54 #addMethods(csml.parser.GridFeature,[ops_GridFeature.testmethod]) 
    55  
    56 ##GridSeriesFeature methods: 
    57 addMethods(csml.parser.GridSeriesFeature,[ops_GridSeriesFeature.getAllowedSubsettings,ops_GridSeriesFeature.getDomain,ops_GridSeriesFeature.subsetToGridSeries, ops_GridSeriesFeature.getUom,ops_GridSeriesFeature.getSliceIndices, ops_GridSeriesFeature._subsetGrid,ops_GridSeriesFeature.subsetToProfileSeries, ops_GridSeriesFeature.subsetToProfile,ops_GridSeriesFeature.subsetToPointSeries]) 
    58  
    59 ##TrajectoryFeature methods: 
    60 #addMethods(csml.parser.TrajectoryFeature, [ops_TrajectoryFeature.testmethod]) 
Note: See TracChangeset for help on using the changeset viewer.