Skip to content

Commit

Permalink
[PyCRAMNEEMInterface] tests are passing except for redo pick action.
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrhmanBassiouny committed Apr 4, 2024
1 parent 37972fe commit 8266166
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/pycram/cache_manager.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import pathlib

Expand Down Expand Up @@ -63,17 +64,27 @@ def generate_description_and_write_to_cache(self, path: str, name: str, extensio
:param object_description: The object description of the file.
"""
description_string = object_description.generate_description_from_file(path, name, extension)
self.write_to_cache(description_string, cache_path)
wrote = self.write_to_cache(description_string, cache_path)
if wrote:
while not pathlib.Path(cache_path).exists():
pass

@staticmethod
def write_to_cache(description_string: str, cache_path: str) -> None:
def write_to_cache(description_string: str, cache_path: str) -> bool:
"""
Writes the description string to the cache directory.
:param description_string: The description string to write to the cache directory.
:param cache_path: The path of the file in the cache directory.
"""
with open(cache_path, "w") as file:
file.write(description_string)
Returns:
- True if the description string was written to the cache directory.
"""
try:
with open(cache_path, "w") as file:
file.write(description_string)
return True
except Exception as e:
logging.warning(f"Could not write to cache: {e}")
return False

def look_for_file_in_data_dir(self, path_object: pathlib.Path) -> str:
"""
Expand Down

0 comments on commit 8266166

Please sign in to comment.