aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ionite34 <[email protected]>2022-11-24 11:24:10 +0800
committerGravatar ionite34 <[email protected]>2022-11-24 11:24:10 +0800
commitdd13795004230b4e52782f5fbc15eab9d89316a0 (patch)
tree49d83493badcd055d6a280524873778b9255f69f
parentRefactor output files in `output` dir (diff)
Update docstrings
-rw-r--r--snekbox/memfs.py16
-rw-r--r--snekbox/nsjail.py5
2 files changed, 17 insertions, 4 deletions
diff --git a/snekbox/memfs.py b/snekbox/memfs.py
index a39b690..0c157dc 100644
--- a/snekbox/memfs.py
+++ b/snekbox/memfs.py
@@ -25,6 +25,11 @@ def parse_files(
"""
Parse files in a MemFS.
+ Args:
+ fs: The MemFS to parse.
+ files_limit: The maximum number of files to parse.
+ files_pattern: The glob pattern to match files against.
+
Returns:
List of FileAttachments sorted lexically by path name.
"""
@@ -106,7 +111,16 @@ class MemFS:
def attachments(
self, max_count: int, pattern: str = "**/*"
) -> Generator[FileAttachment, None, None]:
- """Return a list of attachments in the tempdir."""
+ """
+ Generate FileAttachments for files in the MemFS.
+
+ Args:
+ max_count: The maximum number of files to parse.
+ pattern: The glob pattern to match files against.
+
+ Yields:
+ FileAttachments for files in the MemFS.
+ """
count = 0
for file in self.output.rglob(pattern):
if count > max_count:
diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py
index 4538287..ec5c6b1 100644
--- a/snekbox/nsjail.py
+++ b/snekbox/nsjail.py
@@ -243,9 +243,8 @@ class NsJail:
# convert negative exit codes to the `N + 128` form.
returncode = -nsjail.returncode + 128 if nsjail.returncode < 0 else nsjail.returncode
- # Parse attachments
+ # Parse attachments with time limit
try:
- # Sort attachments by name lexically
attachments = timed(
parse_files,
(fs, self.files_limit, self.files_pattern),
@@ -253,7 +252,7 @@ class NsJail:
)
log.info(f"Found {len(attachments)} files.")
except TimeoutError as e:
- log.warning(f"Exceeded time limit while parsing attachments: {e}")
+ log.info(f"Exceeded time limit while parsing attachments: {e}")
return EvalResult(
args, None, "TimeoutError: Exceeded time limit while parsing attachments"
)