Skip to content

Commit

Permalink
switched to precompiling alphanumerical regex
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan MacLeod <[email protected]>
  • Loading branch information
npmacl committed Mar 22, 2024
1 parent 152f662 commit ca0fac5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/deadline/job_attachments/asset_manifests/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .manifest_model import ManifestModelRegistry
from .versions import ManifestVersion

alphanum_regex = re.compile("[a-zA-Z0-9]+")

def _get_schema(version) -> dict[str, Any]:
schema_filename = Path(__file__).parent.joinpath("schemas", version + ".json").resolve()
Expand Down Expand Up @@ -73,7 +74,7 @@ def decode_manifest(manifest: str) -> BaseAssetManifest:

# Validate hashes are alphanumeric
for path in decoded_manifest.paths:
if re.fullmatch("[a-zA-Z0-9]+", path.hash) is None:
if alphanum_regex.fullmatch(path.hash) is None:
raise ManifestDecodeValidationError(
f"The hash {path.hash} for path {path.path} is not alphanumeric"
)
Expand Down

0 comments on commit ca0fac5

Please sign in to comment.