aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ionite <[email protected]>2023-03-08 22:12:22 -0500
committerGravatar Ionite <[email protected]>2023-03-08 22:12:22 -0500
commit3fb90e9100ca7bcd4f9996fe5a7450e08d52a4bd (patch)
treed02e921158af4b5a7a699818f3ac41127280988d
parentAdd `config/.ignore` file, parsed to ignore file patterns for upload (diff)
Remove file ignore filter to use -B flag instead
-rw-r--r--config/.ignore4
-rw-r--r--config/snekbox.cfg2
-rw-r--r--snekbox/memfs.py16
-rw-r--r--snekbox/nsjail.py5
4 files changed, 3 insertions, 24 deletions
diff --git a/config/.ignore b/config/.ignore
deleted file mode 100644
index 961321b..0000000
--- a/config/.ignore
+++ /dev/null
@@ -1,4 +0,0 @@
-__pycache__/
-*.py[cod]
-*$py.class
-*.so
diff --git a/config/snekbox.cfg b/config/snekbox.cfg
index b821df3..5dd63da 100644
--- a/config/snekbox.cfg
+++ b/config/snekbox.cfg
@@ -117,5 +117,5 @@ iface_no_lo: true
exec_bin {
path: "/usr/local/bin/python"
- arg: "-Squ"
+ arg: "-BSqu"
}
diff --git a/snekbox/memfs.py b/snekbox/memfs.py
index feba252..f32fed1 100644
--- a/snekbox/memfs.py
+++ b/snekbox/memfs.py
@@ -4,9 +4,8 @@ from __future__ import annotations
import logging
import warnings
import weakref
-from collections.abc import Generator, Sequence
+from collections.abc import Generator
from contextlib import suppress
-from fnmatch import fnmatch
from pathlib import Path
from types import TracebackType
from typing import Type
@@ -125,7 +124,6 @@ class MemFS:
self,
limit: int,
pattern: str = "**/*",
- ignores: Sequence[str] = (),
exclude_files: dict[Path, float] | None = None,
) -> Generator[FileAttachment, None, None]:
"""
@@ -134,20 +132,12 @@ class MemFS:
Args:
limit: The maximum number of files to parse.
pattern: The glob pattern to match files against.
- ignores: A sequence of fnmatch patterns to ignore.
exclude_files: A dict of Paths and last modified times.
Files will be excluded if their last modified time
is equal to the provided value.
"""
count = 0
for file in self.output.rglob(pattern):
- if any(
- fnmatch(str(file.relative_to(self.home)), match_pattern := ignore_pattern)
- for ignore_pattern in ignores
- ):
- log.info(f"Ignoring {file.name!r} as it matches {match_pattern!r}")
- continue
-
if exclude_files and (orig_time := exclude_files.get(file)):
new_time = file.stat().st_mtime
log.info(f"Checking {file.name} ({orig_time=}, {new_time=})")
@@ -168,7 +158,6 @@ class MemFS:
self,
limit: int,
pattern: str,
- ignores: Sequence[str] = (),
exclude_files: dict[Path, float] | None = None,
preload_dict: bool = False,
) -> list[FileAttachment]:
@@ -178,7 +167,6 @@ class MemFS:
Args:
limit: The maximum number of files to parse.
pattern: The glob pattern to match files against.
- ignores: A sequence of fnmatch patterns to ignore.
exclude_files: A dict of Paths and last modified times.
Files will be excluded if their last modified time
is equal to the provided value.
@@ -187,7 +175,7 @@ class MemFS:
List of FileAttachments sorted lexically by path name.
"""
res = sorted(
- self.files(limit=limit, pattern=pattern, ignores=ignores, exclude_files=exclude_files),
+ self.files(limit=limit, pattern=pattern, exclude_files=exclude_files),
key=lambda f: f.path,
)
if preload_dict:
diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py
index 2c691e4..f014850 100644
--- a/snekbox/nsjail.py
+++ b/snekbox/nsjail.py
@@ -58,7 +58,6 @@ class NsJail:
files_limit: int | None = 100,
files_timeout: float | None = 8,
files_pattern: str = "**/[!_]*",
- files_ignore_path: str = "./config/.ignore",
):
"""
Initialize NsJail.
@@ -75,8 +74,6 @@ class NsJail:
files_limit: Maximum number of output files to parse.
files_timeout: Maximum time in seconds to wait for output files to be read.
files_pattern: Pattern to match files to attach within the output directory.
- files_ignore_path: Path to a file containing a gitignore-like list of file
- patterns to ignore for upload.
"""
self.nsjail_path = nsjail_path
self.config_path = config_path
@@ -89,7 +86,6 @@ class NsJail:
self.files_limit = files_limit
self.files_timeout = files_timeout
self.files_pattern = files_pattern
- self.files_ignores = Path(files_ignore_path).read_text().splitlines()
self.config = self._read_config(config_path)
self.cgroup_version = utils.cgroup.init(self.config)
@@ -275,7 +271,6 @@ class NsJail:
MemFS.files_list,
(fs, self.files_limit, self.files_pattern),
{
- "ignores": self.files_ignores,
"preload_dict": True,
"exclude_files": files_written,
},