Skip to content

Commit 5a2bd1f

Browse files
committed
Fix filesystem example.
1 parent e8b05b2 commit 5a2bd1f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

examples/0005_filesystem.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33

44
print("Subexample 1")
55
result = judge0.run(source_code="print('hello, world')")
6-
fs = Filesystem(result.post_execution_filesystem)
6+
fs = Filesystem(content=result.post_execution_filesystem)
77
for f in fs:
88
print(f.name)
99
print(f)
1010
print()
1111

1212

1313
print("Subexample 2")
14-
fs = Filesystem(File("my_file.txt", "hello, world"))
14+
fs = Filesystem(content=File(name="my_file.txt", content="hello, world"))
1515
result = judge0.run(
1616
source_code="print(open('my_file.txt').read())", additional_files=fs
1717
)
1818
print(result.stdout)
19-
for f in Filesystem(result.post_execution_filesystem):
19+
for f in Filesystem(content=result.post_execution_filesystem):
2020
print(f.name)
2121
print(f)
2222
print()
2323

2424

2525
print("Subexample 3")
26-
fs = Filesystem(File("my_file.txt", "hello, world"))
26+
fs = Filesystem(content=File(name="my_file.txt", content="hello, world"))
2727
result = judge0.run(
2828
source_code="print(open('my_file.txt').read())", additional_files=fs
2929
)
@@ -35,14 +35,14 @@
3535

3636
print("Subexample 4")
3737
fs = Filesystem(
38-
[
39-
File("my_file.txt", "hello, world"),
40-
File("./dir1/dir2/dir3/my_file2.txt", "hello, world2"),
38+
content=[
39+
File(name="my_file.txt", content="hello, world"),
40+
File(name="./dir1/dir2/dir3/my_file2.txt", content="hello, world2"),
4141
]
4242
)
4343
result = judge0.run(source_code="find .", additional_files=fs, language=46)
4444
print(result.stdout)
45-
for f in Filesystem(result.post_execution_filesystem):
45+
for f in Filesystem(content=result.post_execution_filesystem):
4646
print(f.name)
4747
print(f)
4848
print()

src/judge0/submission.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Submission(BaseModel):
131131
default=LanguageAlias.PYTHON,
132132
repr=True,
133133
)
134-
additional_files: Optional[str] = Field(default=None, repr=True)
134+
additional_files: Optional[Union[str, Filesystem]] = Field(default=None, repr=True)
135135
compiler_options: Optional[str] = Field(default=None, repr=True)
136136
command_line_arguments: Optional[str] = Field(default=None, repr=True)
137137
stdin: Optional[str] = Field(default=None, repr=True)

0 commit comments

Comments
 (0)