def _import_abq_mesh(fle, param): """ Records mesh data from abaqus input file """ # read abaqus file lines = _read_text(fle) lines = _remove_spaces(lines) lines = _remove_eol_r(lines) # check for pre-existing materials if '\n*Material' in lines: print('Warning: Input file: ' + fle + ' already has materials defined') print(' Beware duplicate material definition') # determine how many parts parts = _find_part_names(lines) # store data for each part part_data = [0] * len(parts) for p in parts: if 'ignore' in param.keys(): if p in param['ignore']: part_data[parts.index(p)] = _get_part_data(lines, p, True) else: part_data[parts.index(p)] = _get_part_data(lines, p) else: part_data[parts.index(p)] = _get_part_data(lines, p) return part_data
def import_parameters(fle): """ Imports parameter data """ # read parameters file lines = _read_text(fle) + '\n' lines = _remove_spaces(lines) lines = _remove_eol_r(lines) # identify and record data param = _get_param(lines) # check all necessary parameters have been defined _checkParamInformation(param) return param
def test_will_import_boolean_from_param_file(self): self.assertEqual(_get_param(_remove_spaces(self.text6)), {'bla': True}, "Error importing boolean from param file")
def test_will_import_text_from_param_file(self): self.assertEqual(_get_param(_remove_spaces(self.text7)), {'bla': 'Calibration'}, "Error importing text from param file")
def test_will_not_import_data_after_hash(self): self.assertFalse('bla2' in _get_param(_remove_spaces(self.text4)).keys(), "Error parameter 'bla2' after hash has been imported")
def test_can_import_param_data(self): self.assertTrue('bla' in _get_param(_remove_spaces(self.text3)).keys(), "Error parameter 'bla' not imported correctly")
def test_can_import_param_file_no_data(self): self.assertTrue(len(_get_param(_remove_spaces(self.text2))) == 0, "Error processing parameters file no data")
def test_can_process_blank_param_file(self): self.assertTrue(len(_get_param(_remove_spaces(self.text1))) == 0, "Error processing blank parameters file")
def setUp(self): self.text1 = _remove_spaces("This is a test\n") self.text2 = _remove_spaces("") self.text3 = _remove_spaces(" ")