Changeset 257
- Timestamp:
- 11/24/09 17:46:59
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sodar/branches/scintec-branch/sodar/scintec/maindata.py
r256 r257 50 50 """ 51 51 52 def __init__(self, mnd ):52 def __init__(self, mnd, *args): 53 53 """ 54 54 Parse main daily Scintec sodar .mnd file. 55 55 56 MainData(mnd ) -> <MainData object>56 MainData(mnd[,file_name[,file_path]]) -> <MainData object> 57 57 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. 60 68 61 69 Parse a known good .mnd file: 62 70 63 71 >>> 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 64 80 """ 65 81 66 82 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 67 95 self._blocks = [self._block.strip() 68 96 for self._block in mnd.split('\n\n') sodar/branches/scintec-branch/sodar/tests/suite.py
r255 r257 16 16 Get data from test file. 17 17 18 setUpData(data_dir,data_file) -> str18 setUpData(data_dir,data_file) -> (data_path, data) 19 19 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. 22 29 """ 23 30 24 31 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 data32 data_path = os.path.join(module_dir,'data',data_dir,data_file) 33 data = open(data_path).read() 34 return (data_path, data) 28 35 29 36 def setUpGoodMndData(): … … 32 39 """ 33 40 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) 35 44 36 45 def setUpGoodMnd(test): … … 39 48 """ 40 49 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) 43 55 44 56 def test_suite():