Skip to content

Commit d62b456

Browse files
committed
Add dunder repr to FileSystem and Submission. Expose async_run and sync_run as public api functions.
1 parent f8df2bc commit d62b456

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

src/judge0/__init__.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import os
22

3-
from .api import async_execute, execute, get_client, run, sync_execute, wait
3+
from .api import (
4+
async_execute,
5+
async_run,
6+
execute,
7+
get_client,
8+
run,
9+
sync_execute,
10+
sync_run,
11+
wait,
12+
)
413
from .base_types import Flavor, Language, LanguageAlias, Status, TestCase
514
from .clients import (
615
ATD,
@@ -42,6 +51,8 @@
4251
"async_execute",
4352
"execute",
4453
"get_client",
54+
"async_run",
55+
"sync_run",
4556
"run",
4657
"sync_execute",
4758
"wait",

src/judge0/api.py

-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def sync_execute(
258258

259259

260260
execute = sync_execute
261-
262261
run = sync_execute
263262
sync_run = sync_execute
264263
async_run = async_execute

src/judge0/filesystem.py

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def __init__(
4949
elif isinstance(content, Filesystem):
5050
self.files = copy.deepcopy(content.files)
5151

52+
def __repr__(self) -> str:
53+
content_encoded = b64encode(self.encode()).decode()
54+
return f"{self.__class__.__name__}(content={content_encoded!r})"
55+
5256
def encode(self) -> bytes:
5357
zip_buffer = io.BytesIO()
5458
with zipfile.ZipFile(zip_buffer, "w") as zip_file:

src/judge0/submission.py

+10
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,13 @@ def is_done(self) -> bool:
182182

183183
def copy(self) -> "Submission":
184184
return copy.deepcopy(self)
185+
186+
def __repr__(self) -> str:
187+
arguments = ", ".join(f"{field}={getattr(self, field)!r}" for field in FIELDS)
188+
return f"{self.__class__.__name__}({arguments})"
189+
190+
def __iter__(self):
191+
if self.post_execution_filesystem is None:
192+
return iter([])
193+
else:
194+
return iter(self.post_execution_filesystem)

0 commit comments

Comments
 (0)