Index: sodar/branches/scintec-branch/sodar/scintec/maindata.py =================================================================== --- sodar/branches/scintec-branch/sodar/scintec/maindata.py (revision 256) +++ sodar/branches/scintec-branch/sodar/scintec/maindata.py (revision 257) @@ -50,19 +50,47 @@ """ - def __init__(self, mnd): + def __init__(self, mnd, *args): """ Parse main daily Scintec sodar .mnd file. - MainData(mnd) -> + MainData(mnd[,file_name[,file_path]]) -> - Where mnd is a str object containing the complete contents read from a - Scintec .mnd daily sodar file including all line endings. + Where: + + mnd is a str object containing the complete contents read from a + Scintec .mnd daily sodar file including all line endings, + + file_name is an optional string object representing a file name for + a file which contains the referenced .mnd daily sodar file, + + file_path is an optional string object representing the path to + file_name. Parse a known good .mnd file: >>> main_data = MainData(good_mnd) + >>> main_data = MainData(good_mnd,good_name) + >>> main_data.file_name == good_name + True + >>> main_data = MainData(good_mnd,good_name,good_path) + >>> main_data.file_name == good_name + True + >>> main_data.file_path == good_path + True """ super(MainData, self).__init__() + + self.file_name = '' + self.file_path = '' + + try: + self.file_name = str(args[0]) + self.file_path = str(args[1]) + except IndexError: + pass + + print mnd + self._blocks = [self._block.strip() for self._block in mnd.split('\n\n') Index: sodar/branches/scintec-branch/sodar/tests/suite.py =================================================================== --- sodar/branches/scintec-branch/sodar/tests/suite.py (revision 255) +++ sodar/branches/scintec-branch/sodar/tests/suite.py (revision 257) @@ -16,14 +16,21 @@ Get data from test file. - setUpData(data_dir,data_file) -> str + setUpData(data_dir,data_file) -> (data_path, data) - Where data_dir is a str representation of a relative path in tests/data, - and data_file is a str representation of a data file within data_dir + Where: + + data_dir is a str representation of a relative path in tests/data, + + data_file is a str representation of a data file within data_dir, + + data_path is a str representation of the absolute path to data_file, + + data is a str representation of the contents of data_file. """ module_dir = os.path.abspath(os.path.dirname(__file__)) - data_file = os.path.join(module_dir,'data',data_dir,data_file) - data = open(data_file).read() - return data + data_path = os.path.join(module_dir,'data',data_dir,data_file) + data = open(data_path).read() + return (data_path, data) def setUpGoodMndData(): @@ -32,5 +39,7 @@ """ - return setUpData(os.path.join('scintec','good',),'091117.mnd') + mnd_dir = os.path.join('scintec','good',) + mnd_file = '091117.mnd' + return setUpData(mnd_dir,mnd_file) def setUpGoodMnd(test): @@ -39,6 +48,9 @@ """ - mnd = setUpGoodMndData() - test.globs.update(good_mnd=mnd) + mnd_path,mnd = setUpGoodMndData() + mnd_path,mnd_file = os.path.split(mnd_path) + test.globs.update(good_mnd=mnd, + good_name=mnd_file, + good_path=mnd_path) def test_suite():