This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
The following commit(s) were added to refs/heads/sbp by this push:
new b5222e27 Detect source archives by stem suffix
b5222e27 is described below
commit b5222e27a133302b3054008ef230061517f31e63
Author: Sean B. Palmer <[email protected]>
AuthorDate: Sun Mar 8 20:12:01 2026 +0000
Detect source archives by stem suffix
---
atr/classify.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/atr/classify.py b/atr/classify.py
index efb6e6db..0f73100f 100644
--- a/atr/classify.py
+++ b/atr/classify.py
@@ -19,9 +19,12 @@ import enum
import pathlib
import re
from collections.abc import Callable
+from typing import Final
import atr.analysis as analysis
+_SOURCE_STEM: Final[re.Pattern[str]] =
re.compile(r"[-_](source-release|sources|source|src)$")
+
class FileType(enum.Enum):
BINARY = "binary"
@@ -47,8 +50,12 @@ def classify(
if any(path_str.endswith(s) for s in
analysis.STANDALONE_METADATA_SUFFIXES):
return FileType.METADATA
- if search and search.group("artifact") and (source_matcher is not None)
and (base_path is not None):
- if source_matcher(str(base_path / path)):
+ if search and search.group("artifact"):
+ stem = path_str[: search.start()]
+ if _SOURCE_STEM.search(stem):
return FileType.SOURCE
+ if (source_matcher is not None) and (base_path is not None):
+ if source_matcher(str(base_path / path)):
+ return FileType.SOURCE
return FileType.BINARY
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]