Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a function to add backslash before a space #541

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions arc/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ", "\ ")
11 changes: 11 additions & 0 deletions arc/common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
2 changes: 2 additions & 0 deletions arc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
ARC_PATH,
check_ess_settings,
delete_check_files,
fill_in_the_blanks,
get_logger,
globalize_path,
initialize_job_types,
Expand Down Expand Up @@ -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
Expand Down
Loading