NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

Changeset 257

Show
Ignore:
Timestamp:
11/24/09 17:46:59
Author:
cbc
Message:

File name and path attributes on MainData?.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sodar/branches/scintec-branch/sodar/scintec/maindata.py

    r256 r257  
    5050    """ 
    5151     
    52     def __init__(self, mnd): 
     52    def __init__(self, mnd, *args): 
    5353        """ 
    5454        Parse main daily Scintec sodar .mnd file. 
    5555         
    56         MainData(mnd) -> <MainData object> 
     56        MainData(mnd[,file_name[,file_path]]) -> <MainData object> 
    5757         
    58         Where mnd is a str object containing the complete contents read from a 
    59         Scintec .mnd daily sodar file including all line endings. 
     58        Where: 
     59          
     60            mnd is a str object containing the complete contents read from a 
     61            Scintec .mnd daily sodar file including all line endings, 
     62             
     63            file_name is an optional string object representing a file name for 
     64            a file which contains the referenced .mnd daily sodar file, 
     65             
     66            file_path is an optional string object representing the path to 
     67            file_name. 
    6068         
    6169        Parse a known good .mnd file: 
    6270         
    6371        >>> main_data = MainData(good_mnd) 
     72        >>> main_data = MainData(good_mnd,good_name) 
     73        >>> main_data.file_name == good_name 
     74        True 
     75        >>> main_data = MainData(good_mnd,good_name,good_path) 
     76        >>> main_data.file_name == good_name 
     77        True 
     78        >>> main_data.file_path == good_path 
     79        True 
    6480        """ 
    6581         
    6682        super(MainData, self).__init__() 
     83         
     84        self.file_name = '' 
     85        self.file_path = '' 
     86         
     87        try: 
     88            self.file_name = str(args[0]) 
     89            self.file_path = str(args[1]) 
     90        except IndexError: 
     91            pass 
     92         
     93        print mnd 
     94         
    6795        self._blocks = [self._block.strip() 
    6896                      for self._block in mnd.split('\n\n') 
  • sodar/branches/scintec-branch/sodar/tests/suite.py

    r255 r257  
    1616    Get data from test file. 
    1717     
    18     setUpData(data_dir,data_file) -> str 
     18    setUpData(data_dir,data_file) -> (data_path, data) 
    1919     
    20     Where data_dir is a str representation of a relative path in tests/data, 
    21     and data_file is a str representation of a data file within data_dir 
     20    Where: 
     21     
     22        data_dir is a str representation of a relative path in tests/data, 
     23         
     24        data_file is a str representation of a data file within data_dir, 
     25         
     26        data_path is a str representation of the absolute path to data_file, 
     27         
     28        data is a str representation of the contents of data_file. 
    2229    """ 
    2330     
    2431    module_dir = os.path.abspath(os.path.dirname(__file__)) 
    25     data_file = os.path.join(module_dir,'data',data_dir,data_file) 
    26     data = open(data_file).read() 
    27     return data 
     32    data_path = os.path.join(module_dir,'data',data_dir,data_file) 
     33    data = open(data_path).read() 
     34    return (data_path, data) 
    2835 
    2936def setUpGoodMndData(): 
     
    3239    """ 
    3340     
    34     return setUpData(os.path.join('scintec','good',),'091117.mnd') 
     41    mnd_dir = os.path.join('scintec','good',) 
     42    mnd_file = '091117.mnd' 
     43    return setUpData(mnd_dir,mnd_file) 
    3544 
    3645def setUpGoodMnd(test): 
     
    3948    """ 
    4049     
    41     mnd = setUpGoodMndData() 
    42     test.globs.update(good_mnd=mnd) 
     50    mnd_path,mnd = setUpGoodMndData() 
     51    mnd_path,mnd_file = os.path.split(mnd_path)  
     52    test.globs.update(good_mnd=mnd, 
     53                      good_name=mnd_file, 
     54                      good_path=mnd_path) 
    4355 
    4456def test_suite():