diff --git a/arc/common.py b/arc/common.py index b85b676274..924ba45722 100644 --- a/arc/common.py +++ b/arc/common.py @@ -1705,3 +1705,16 @@ def is_xyz_mol_match(mol: 'Molecule', if element not in element_dict_xyz or element_dict_xyz[element] != count: return False return True + + +def fill_in_the_blanks(folder_name: str): + """ + Adding backslashes before spaces in the folder name. + + Args: + folder_name (str): The string directory we want to modify. + + Returns: + str: Modified folder name. + """ + return folder_name.replace(" ", "\ ") diff --git a/arc/common_test.py b/arc/common_test.py index 10f746bb41..3dc9204495 100644 --- a/arc/common_test.py +++ b/arc/common_test.py @@ -1370,6 +1370,17 @@ def test_is_xyz_mol_match(self): self.assertFalse(common.is_xyz_mol_match(mol1, xyz2)) self.assertTrue(common.is_xyz_mol_match(mol2, xyz2)) + def test_fill_in_the_blanks(self): + """Test the fill_in_the_blanks() function""" + ex1 = "michalkfir" + ex2 = "michal kfir" + ex3 = "mich al kfir" + ex4 = "michal kfir" + self.assertEqual(common.fill_in_the_blanks(ex1), "michalkfir") + self.assertEqual(common.fill_in_the_blanks(ex2), "michal\\ kfir") + self.assertEqual(common.fill_in_the_blanks(ex3), "mich\\ al\\ kfir") + self.assertEqual(common.fill_in_the_blanks(ex4), "michal\\ \\ kfir") + @classmethod def tearDownClass(cls): """ diff --git a/arc/main.py b/arc/main.py index 9df94e0738..8016d65081 100644 --- a/arc/main.py +++ b/arc/main.py @@ -27,6 +27,7 @@ ARC_PATH, check_ess_settings, delete_check_files, + fill_in_the_blanks, get_logger, globalize_path, initialize_job_types, @@ -280,6 +281,7 @@ def __init__(self, self.verbose = verbose self.project_directory = project_directory if project_directory is not None \ else os.path.join(ARC_PATH, 'Projects', self.project) + self.project_directory = fill_in_the_blanks(self.project_directory) if not os.path.exists(self.project_directory): os.makedirs(self.project_directory) self.output = output