Skip to content

Commit ba0ca81

Browse files
committed
one more time
1 parent 706fcc4 commit ba0ca81

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/block_requests.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def my_get(url, **kwargs):
3939

4040
# Kindly provided by our friend WizardLM-30B
4141
def my_open(*args, **kwargs):
42+
"""
43+
Custom open function that modifies the file contents before returning.
44+
"""
4245
filename = str(args[0])
4346
if filename.endswith("index.html"):
4447
with original_open(*args, **kwargs) as f:
@@ -59,11 +62,14 @@ def my_open(*args, **kwargs):
5962
b'\n </head>'
6063
)
6164

62-
return io.BytesIO(file_contents) # return bytes
65+
return io.BytesIO(file_contents.decode()) # return bytes
6366
else:
6467
return original_open(*args, **kwargs)
6568

6669
def my_print(*args, **kwargs):
70+
"""
71+
Custom print function that modifies the output before printing.
72+
"""
6773
if len(args) > 0 and "To create a public link, set `share=True`" in args[0]:
6874
return
6975
else:

0 commit comments

Comments
 (0)