Skip to content

Commit

Permalink
more WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbull committed Feb 16, 2023
1 parent 0cd2397 commit 5308425
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions cloudpathlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def patch_open():
CloudPath.open,
)
builtins.open = patched
CloudPath.__fspath__ = lambda x: x # turn off `fspath`
return patched


Expand Down
25 changes: 25 additions & 0 deletions test-open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
from cloudpathlib import CloudPath, patch_open, patch_os_functions


def hello(cp):
with open(cp, "a") as f:
f.write(" written")


if __name__ == "__main__":
patch_open()

cp = CloudPath("s3://cloudpathlib-test-bucket/manual/text_file.txt")
cp.write_text("yah")

hello(cp)

print(cp.read_text())
cp.unlink()

patch_os_functions()

print(list(os.walk(".")))
print(list(cp.parent.client._list_dir(cp.parent, recursive=True)))
print(list(os.walk(cp.parent)))

0 comments on commit 5308425

Please sign in to comment.