Skip to content

Fix for windows: os wrapper, check if property exists #353

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

Merged
merged 2 commits into from
Mar 28, 2025
Merged
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions aikido_zen/sinks/os.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@
modified_os = importhook.copy_module(os)
for op in OS_FILE_FUNCTIONS:
# Wrap os. functions
if not hasattr(os, op):
continue # Don't wrap methods that are specific to the OS

Check warning on line 63 in aikido_zen/sinks/os.py

View check run for this annotation

Codecov / codecov/patch

aikido_zen/sinks/os.py#L63

Added line #L63 was not covered by tests
former_func = copy.deepcopy(getattr(os, op))
aikido_new_func = generate_aikido_function(op, former_func)
setattr(os, op, aikido_new_func)
setattr(modified_os, op, aikido_new_func)

for op in OS_PATH_FUNCTIONS:
# Wrap os.path functions
if not hasattr(os.path, op):
continue # Don't wrap methods that are specific to the OS

Check warning on line 72 in aikido_zen/sinks/os.py

View check run for this annotation

Codecov / codecov/patch

aikido_zen/sinks/os.py#L72

Added line #L72 was not covered by tests
former_func = copy.deepcopy(getattr(os.path, op))
aikido_new_func = generate_aikido_function(f"path.{op}", former_func)
setattr(os.path, op, aikido_new_func)
Expand Down
Loading