Skip to content

Commit 5308425

Browse files
committed
more WIP
1 parent 0cd2397 commit 5308425

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

cloudpathlib/patches.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def patch_open():
3232
CloudPath.open,
3333
)
3434
builtins.open = patched
35+
CloudPath.__fspath__ = lambda x: x # turn off `fspath`
3536
return patched
3637

3738

test-open.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
from cloudpathlib import CloudPath, patch_open, patch_os_functions
3+
4+
5+
def hello(cp):
6+
with open(cp, "a") as f:
7+
f.write(" written")
8+
9+
10+
if __name__ == "__main__":
11+
patch_open()
12+
13+
cp = CloudPath("s3://cloudpathlib-test-bucket/manual/text_file.txt")
14+
cp.write_text("yah")
15+
16+
hello(cp)
17+
18+
print(cp.read_text())
19+
cp.unlink()
20+
21+
patch_os_functions()
22+
23+
print(list(os.walk(".")))
24+
print(list(cp.parent.client._list_dir(cp.parent, recursive=True)))
25+
print(list(os.walk(cp.parent)))

0 commit comments

Comments
 (0)