diff options
| author | natsuoto <[email protected]> | 2026-07-11 16:08:45 +0530 |
|---|---|---|
| committer | natsuoto <[email protected]> | 2026-07-11 16:08:45 +0530 |
| commit | a0792e59e05b8f8bf3ea5040317f90a66fedd5d8 (patch) | |
| tree | e7fcd28f2ea033c4a431facca4f1bfc5de0059d8 | |
| parent | afd3c93d23e83fb47d3e9f3c900dbe4ab3f563b5 (diff) | |
| download | edify-a0792e59e05b8f8bf3ea5040317f90a66fedd5d8.tar.xz edify-a0792e59e05b8f8bf3ea5040317f90a66fedd5d8.zip | |
chore: ruff format + lint fixes (en-dash → hyphen, line-length, script.py noqa)
186 files changed, 1308 insertions, 317 deletions
diff --git a/docs/upgrading/0.3-to-1.0.rst b/docs/upgrading/0.3-to-1.0.rst new file mode 100644 index 0000000..900fc25 --- /dev/null +++ b/docs/upgrading/0.3-to-1.0.rst @@ -0,0 +1,65 @@ +.. _upgrading-0-3-to-1-0: + +Upgrading from 0.3 to 1.0 +========================== + +.. _validators-callable: + +Validators are callable ``Pattern`` instances +--------------------------------------------- + +In 0.3 the built-in validators under ``edify.library`` were plain functions. +In 1.0 every validator exposes itself as a :class:`edify.Pattern` instance +that is *callable* — ``email(value)`` still returns a ``bool``, and the +underlying pattern is available via ``email.match(value)``, +``email.to_regex_string()``, and every other :class:`Pattern` method: + +.. code-block:: python + + import inspect + from edify import Pattern + from edify.library import email + + inspect.isfunction(email) # False (was True in 0.3) + isinstance(email, Pattern) # True (was False in 0.3) + email("[email protected]") # True (call form unchanged) + email.match("[email protected]") # <re.Match object> + +The library is also reorganized into 22 category folders (``identifier/``, +``address/``, ``contact/``, ``auth/``, ``financial/``, ``temporal/``, +``geo/``, ``numeric/``, ``text/``, ``color/``, ``media/``, ``software/``, +``transport/``, ``publishing/``, ``product/``, ``medical/``, ``api/``, +``data/``, ``document/``, ``security/``, ``grammar/``, ``web/``). Every +validator is importable both from its category submodule and from the +flat top-level ``edify.library`` namespace: + +.. code-block:: python + + from edify.library import uuid # flat top-level + from edify.library.identifier import uuid # category submodule + +The library grew from 14 validators to **200 exported validators** across +these categories. + +Renamed and merged validators +----------------------------- + +Several 0.3 names have been merged into more general patterns in 1.0: + ++---------------------------------+-------------------------------+ +| 0.3 name | 1.0 replacement | ++=================================+===============================+ +| ``iso_date`` | ``date`` | ++---------------------------------+-------------------------------+ +| ``email_rfc_5322`` | ``email`` | ++---------------------------------+-------------------------------+ +| ``ipv4``, ``ipv6`` | ``ip`` | ++---------------------------------+-------------------------------+ +| ``phone_number`` | ``phone`` | ++---------------------------------+-------------------------------+ +| ``zip`` | ``postal`` | ++---------------------------------+-------------------------------+ + +The new names accept any recognised form of their concept, and the old +name-plus-``form`` variants continue to work via each validator's +``form`` / ``strict`` / ``version`` keyword arguments where applicable. diff --git a/edify/library/__init__.py b/edify/library/__init__.py index 3dbf416..a115b55 100644 --- a/edify/library/__init__.py +++ b/edify/library/__init__.py @@ -4,95 +4,420 @@ Users can import any pattern directly (``from edify.library import uuid``); category submodules (``edify.library.identifier.uuid``) remain the canonical location for the individual patterns. """ + from __future__ import annotations + from edify.library.address import ( - cidr, domain, hostname, ip, path, port, ptr, socket, subdomain, subnet, - tld, uri, url, + cidr, + domain, + hostname, + ip, + path, + port, + ptr, + socket, + subdomain, + subnet, + tld, + uri, + url, ) from edify.library.api import ( - atom, graphql, hal, jsonapi, oauth, openapi, openid, rss, saml, soap, - swagger, webhook, + atom, + graphql, + hal, + jsonapi, + oauth, + openapi, + openid, + rss, + saml, + soap, + swagger, + webhook, ) from edify.library.auth import ( - apikey, bearer, challenge, csrf, hmac, jwt, mfa, mnemonic, otp, passkey, - password, pin, refresh, secret, session, signing, sso, token, webauthn, + apikey, + bearer, + challenge, + csrf, + hmac, + jwt, + mfa, + mnemonic, + otp, + passkey, + password, + pin, + refresh, + secret, + session, + signing, + sso, + token, + webauthn, ) from edify.library.color import color, filter, gradient, palette, swatch from edify.library.contact import ( - address, email, fax, pager, phone, username, + address, + email, + fax, + pager, + phone, + username, ) from edify.library.data import ( - avro, csv, hdf5, html, ini, json, msgpack, protobuf, toml, tsv, xml, yaml, + avro, + csv, + hdf5, + html, + ini, + json, + msgpack, + protobuf, + toml, + tsv, + xml, + yaml, ) from edify.library.document import ( - docx, epub, mobi, odt, pdf, pptx, readme, svg, xlsx, + docx, + epub, + mobi, + odt, + pdf, + pptx, + readme, + svg, + xlsx, ) from edify.library.financial import card, crypto, currency, wallet from edify.library.geo import ( - altitude, coordinate, geohash, place, plus, postal, + altitude, + coordinate, + geohash, + place, + plus, + postal, ) from edify.library.grammar import abnf, bnf, ebnf, peg, pest from edify.library.identifier import ( - arn, asin, bic, cusip, did, ein, guid, iata, iban, iccid, icao, imei, - imo, isin, itin, lei, mac, meid, mmsi, orcid, sedol, sku, ssn, tin, - uuid, vin, + arn, + asin, + bic, + cusip, + did, + ein, + guid, + iata, + iban, + icao, + iccid, + imei, + imo, + isin, + itin, + lei, + mac, + meid, + mmsi, + orcid, + sedol, + sku, + ssn, + tin, + uuid, + vin, ) -from edify.library.medical import medical from edify.library.media import ( - charset, codec, encoding, extension, favicon, filename, glob, locale, - mimetype, regex, shebang, + charset, + codec, + encoding, + extension, + favicon, + filename, + glob, + locale, + mimetype, + regex, + shebang, ) +from edify.library.medical import medical from edify.library.numeric import ( - fraction, hash, integer, number, ordinal, percentage, ratio, roman, + fraction, + hash, + integer, + number, + ordinal, + percentage, + ratio, + roman, scientific, ) from edify.library.product import barcode, gtin, mpn from edify.library.publishing import arxiv, doi, isbn, issn, pmc, pmid from edify.library.security import ( - age, certificate, csr, der, keyring, pem, pgp, ssh, x509, + age, + certificate, + csr, + der, + keyring, + pem, + pgp, + ssh, + x509, ) from edify.library.software import ( - cargo, checksum, component, digest, docker, git, image, makefile, - package, ref, semver, version, + cargo, + checksum, + component, + digest, + docker, + git, + image, + makefile, + package, + ref, + semver, + version, ) from edify.library.temporal import ( - cron, date, datetime, duration, epoch, interval, offset, time, timestamp, - timezone, year, + cron, + date, + datetime, + duration, + epoch, + interval, + offset, + time, + timestamp, + timezone, + year, ) from edify.library.text import ( - alpha, alphanumeric, ascii, base, emoji, numeric, printable, script, - slug, unicode, word, + alpha, + alphanumeric, + ascii, + base, + emoji, + numeric, + printable, + script, + slug, + unicode, + word, ) from edify.library.transport import aircraft, vehicle from edify.library.web import ( - apache, captcha, htaccess, humans, manifest, nginx, robots, sitemap, + apache, + captcha, + htaccess, + humans, + manifest, + nginx, + robots, + sitemap, ) __all__ = [ - "abnf", "address", "age", "aircraft", "alpha", "alphanumeric", "altitude", - "apache", "apikey", "arn", "arxiv", "ascii", "asin", "atom", "avro", - "barcode", "base", "bearer", "bic", "bnf", "captcha", "card", "cargo", - "certificate", "challenge", "charset", "checksum", "cidr", "codec", "color", - "component", "coordinate", "cron", "crypto", "csr", "csrf", "csv", - "currency", "cusip", "date", "datetime", "der", "did", "digest", "docker", - "docx", "doi", "domain", "duration", "ebnf", "ein", "email", "emoji", - "encoding", "epoch", "epub", "extension", "favicon", "fax", "filename", - "filter", "fraction", "geohash", "git", "glob", "gradient", "graphql", - "gtin", "guid", "hal", "hash", "hdf5", "hmac", "hostname", "htaccess", - "html", "humans", "iata", "iban", "icao", "iccid", "image", "imei", "imo", - "ini", "integer", "interval", "ip", "isbn", "isin", "issn", "itin", "json", - "jsonapi", "jwt", "keyring", "lei", "locale", "mac", "makefile", "manifest", - "medical", "meid", "mfa", "mimetype", "mmsi", "mnemonic", "mobi", "mpn", - "msgpack", "nginx", "number", "numeric", "oauth", "odt", "offset", - "openapi", "openid", "orcid", "ordinal", "otp", "package", "pager", - "palette", "passkey", "password", "path", "pdf", "peg", "pem", "percentage", - "pest", "pgp", "phone", "pin", "place", "plus", "pmc", "pmid", "port", - "postal", "pptx", "printable", "protobuf", "ptr", "ratio", "readme", "ref", - "refresh", "regex", "robots", "roman", "rss", "saml", "scientific", - "script", "secret", "sedol", "semver", "session", "shebang", "signing", - "sitemap", "sku", "slug", "soap", "socket", "ssh", "ssn", "sso", - "subdomain", "subnet", "svg", "swagger", "swatch", "time", "timestamp", - "timezone", "tin", "tld", "token", "toml", "tsv", "unicode", "uri", "url", - "username", "uuid", "vehicle", "version", "vin", "wallet", "webauthn", - "webhook", "word", "x509", "xlsx", "xml", "yaml", "year", + "abnf", + "address", + "age", + "aircraft", + "alpha", + "alphanumeric", + "altitude", + "apache", + "apikey", + "arn", + "arxiv", + "ascii", + "asin", + "atom", + "avro", + "barcode", + "base", + "bearer", + "bic", + "bnf", + "captcha", + "card", + "cargo", + "certificate", + "challenge", + "charset", + "checksum", + "cidr", + "codec", + "color", + "component", + "coordinate", + "cron", + "crypto", + "csr", + "csrf", + "csv", + "currency", + "cusip", + "date", + "datetime", + "der", + "did", + "digest", + "docker", + "docx", + "doi", + "domain", + "duration", + "ebnf", + "ein", + "email", + "emoji", + "encoding", + "epoch", + "epub", + "extension", + "favicon", + "fax", + "filename", + "filter", + "fraction", + "geohash", + "git", + "glob", + "gradient", + "graphql", + "gtin", + "guid", + "hal", + "hash", + "hdf5", + "hmac", + "hostname", + "htaccess", + "html", + "humans", + "iata", + "iban", + "icao", + "iccid", + "image", + "imei", + "imo", + "ini", + "integer", + "interval", + "ip", + "isbn", + "isin", + "issn", + "itin", + "json", + "jsonapi", + "jwt", + "keyring", + "lei", + "locale", + "mac", + "makefile", + "manifest", + "medical", + "meid", + "mfa", + "mimetype", + "mmsi", + "mnemonic", + "mobi", + "mpn", + "msgpack", + "nginx", + "number", + "numeric", + "oauth", + "odt", + "offset", + "openapi", + "openid", + "orcid", + "ordinal", + "otp", + "package", + "pager", + "palette", + "passkey", + "password", + "path", + "pdf", + "peg", + "pem", + "percentage", + "pest", + "pgp", + "phone", + "pin", + "place", + "plus", + "pmc", + "pmid", + "port", + "postal", + "pptx", + "printable", + "protobuf", + "ptr", + "ratio", + "readme", + "ref", + "refresh", + "regex", + "robots", + "roman", + "rss", + "saml", + "scientific", + "script", + "secret", + "sedol", + "semver", + "session", + "shebang", + "signing", + "sitemap", + "sku", + "slug", + "soap", + "socket", + "ssh", + "ssn", + "sso", + "subdomain", + "subnet", + "svg", + "swagger", + "swatch", + "time", + "timestamp", + "timezone", + "tin", + "tld", + "token", + "toml", + "tsv", + "unicode", + "uri", + "url", + "username", + "uuid", + "vehicle", + "version", + "vin", + "wallet", + "webauthn", + "webhook", + "word", + "x509", + "xlsx", + "xml", + "yaml", + "year", ] diff --git a/edify/library/_support/atoms.py b/edify/library/_support/atoms.py index f05dcca..922e4f9 100644 --- a/edify/library/_support/atoms.py +++ b/edify/library/_support/atoms.py @@ -10,7 +10,6 @@ from __future__ import annotations from edify import Pattern, any_of - hex_lower = Pattern().any_of().range("0", "9").range("a", "f").end() """A single lowercase hex nibble: ``[0-9a-f]``.""" @@ -30,4 +29,4 @@ octet = any_of( Pattern().range("1", "9").digit(), Pattern().digit(), ) -"""An IPv4 octet in ``0``-``255``."""
\ No newline at end of file +"""An IPv4 octet in ``0``-``255``.""" diff --git a/edify/library/address/cidr.py b/edify/library/address/cidr.py index d361396..5894952 100644 --- a/edify/library/address/cidr.py +++ b/edify/library/address/cidr.py @@ -13,6 +13,6 @@ cidr = RegexBackedPattern( r"/(?:12[0-8]|1[01]\d|[1-9]?\d)" r")$" ) -"""Callable :class:`Pattern` for CIDR notation: IPv4 address + ``/0``–``/32`` -or IPv6 address + ``/0``–``/128``. +"""Callable :class:`Pattern` for CIDR notation: IPv4 address + ``/0``-``/32`` +or IPv6 address + ``/0``-``/128``. """ diff --git a/edify/library/address/domain.py b/edify/library/address/domain.py index 673eca9..ef8d310 100644 --- a/edify/library/address/domain.py +++ b/edify/library/address/domain.py @@ -9,5 +9,5 @@ domain = RegexBackedPattern( r"[a-zA-Z]{2,63}$" ) """Callable :class:`Pattern` for the DNS domain name shape: -at least one label followed by a TLD of 2–63 letters. +at least one label followed by a TLD of 2-63 letters. """ diff --git a/edify/library/address/port.py b/edify/library/address/port.py index baa9ddc..297787b 100644 --- a/edify/library/address/port.py +++ b/edify/library/address/port.py @@ -1,4 +1,4 @@ -"""``port`` — TCP/UDP port number 0–65535.""" +"""``port`` — TCP/UDP port number 0-65535.""" from __future__ import annotations @@ -13,4 +13,4 @@ port = any_of( Pattern().start_of_input().range("1", "9").between(0, 3).digit().end_of_input(), Pattern().start_of_input().char("0").end_of_input(), ) -"""Callable :class:`Pattern` for a TCP/UDP port number 0–65535.""" +"""Callable :class:`Pattern` for a TCP/UDP port number 0-65535.""" diff --git a/edify/library/address/subdomain.py b/edify/library/address/subdomain.py index 8c480f8..5318707 100644 --- a/edify/library/address/subdomain.py +++ b/edify/library/address/subdomain.py @@ -7,11 +7,25 @@ from edify import Pattern subdomain = ( Pattern() .start_of_input() - .any_of().range("a", "z").range("A", "Z").range("0", "9").end() - .between(0, 61).any_of().range("a", "z").range("A", "Z").range("0", "9").char("-").end() - .any_of().range("a", "z").range("A", "Z").range("0", "9").end() + .any_of() + .range("a", "z") + .range("A", "Z") + .range("0", "9") + .end() + .between(0, 61) + .any_of() + .range("a", "z") + .range("A", "Z") + .range("0", "9") + .char("-") + .end() + .any_of() + .range("a", "z") + .range("A", "Z") + .range("0", "9") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for a single DNS subdomain label (1–63 chars, +"""Callable :class:`Pattern` for a single DNS subdomain label (1-63 chars, alphanumeric with optional interior hyphens). """ diff --git a/edify/library/address/tld.py b/edify/library/address/tld.py index 5c405fb..5ef029b 100644 --- a/edify/library/address/tld.py +++ b/edify/library/address/tld.py @@ -1,4 +1,4 @@ -"""``tld`` — top-level domain shape (2–63 alpha).""" +"""``tld`` — top-level domain shape (2-63 alpha).""" from __future__ import annotations @@ -7,7 +7,11 @@ from edify import Pattern tld = ( Pattern() .start_of_input() - .between(2, 63).any_of().range("a", "z").range("A", "Z").end() + .between(2, 63) + .any_of() + .range("a", "z") + .range("A", "Z") + .end() .end_of_input() ) """Callable :class:`Pattern` for the TLD shape: 2 to 63 letters.""" diff --git a/edify/library/address/uri.py b/edify/library/address/uri.py index b8033fe..cb417be 100644 --- a/edify/library/address/uri.py +++ b/edify/library/address/uri.py @@ -4,9 +4,7 @@ from __future__ import annotations from edify.library._support.regex import RegexBackedPattern -uri = RegexBackedPattern( - r"^[a-zA-Z][a-zA-Z0-9+.\-]*:[^\s]+$" -) +uri = RegexBackedPattern(r"^[a-zA-Z][a-zA-Z0-9+.\-]*:[^\s]+$") """Callable :class:`Pattern` for the generic URI shape: ``scheme:opaque-or-path`` where scheme starts with a letter. """ diff --git a/edify/library/api/__init__.py b/edify/library/api/__init__.py index 0326739..38507b4 100644 --- a/edify/library/api/__init__.py +++ b/edify/library/api/__init__.py @@ -10,7 +10,18 @@ from edify.library.api.saml import saml from edify.library.api.soap import soap from edify.library.api.swagger import swagger from edify.library.api.webhook import webhook + __all__ = [ - "atom", "graphql", "hal", "jsonapi", "oauth", "openapi", "openid", - "rss", "saml", "soap", "swagger", "webhook", + "atom", + "graphql", + "hal", + "jsonapi", + "oauth", + "openapi", + "openid", + "rss", + "saml", + "soap", + "swagger", + "webhook", ] diff --git a/edify/library/api/atom.py b/edify/library/api/atom.py index 62d1875..e2f1b88 100644 --- a/edify/library/api/atom.py +++ b/edify/library/api/atom.py @@ -1,5 +1,8 @@ """``atom`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + atom = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive atom-related identifier.""" diff --git a/edify/library/api/graphql.py b/edify/library/api/graphql.py index 6898eaf..d4e7527 100644 --- a/edify/library/api/graphql.py +++ b/edify/library/api/graphql.py @@ -1,5 +1,8 @@ """``graphql`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + graphql = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive graphql-related identifier.""" diff --git a/edify/library/api/hal.py b/edify/library/api/hal.py index e2e0d38..d2aef10 100644 --- a/edify/library/api/hal.py +++ b/edify/library/api/hal.py @@ -1,5 +1,8 @@ """``hal`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + hal = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive hal-related identifier.""" diff --git a/edify/library/api/jsonapi.py b/edify/library/api/jsonapi.py index 46f10d7..367c112 100644 --- a/edify/library/api/jsonapi.py +++ b/edify/library/api/jsonapi.py @@ -1,5 +1,8 @@ """``jsonapi`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + jsonapi = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive jsonapi-related identifier.""" diff --git a/edify/library/api/oauth.py b/edify/library/api/oauth.py index 8d4acf4..4dd0c1f 100644 --- a/edify/library/api/oauth.py +++ b/edify/library/api/oauth.py @@ -1,5 +1,8 @@ """``oauth`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + oauth = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive oauth-related identifier.""" diff --git a/edify/library/api/openapi.py b/edify/library/api/openapi.py index d541763..0d6cd51 100644 --- a/edify/library/api/openapi.py +++ b/edify/library/api/openapi.py @@ -1,5 +1,8 @@ """``openapi`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + openapi = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive openapi-related identifier.""" diff --git a/edify/library/api/openid.py b/edify/library/api/openid.py index 186abeb..20f309e 100644 --- a/edify/library/api/openid.py +++ b/edify/library/api/openid.py @@ -1,5 +1,8 @@ """``openid`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + openid = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive openid-related identifier.""" diff --git a/edify/library/api/rss.py b/edify/library/api/rss.py index b2e8eba..d5dc323 100644 --- a/edify/library/api/rss.py +++ b/edify/library/api/rss.py @@ -1,5 +1,8 @@ """``rss`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + rss = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive rss-related identifier.""" diff --git a/edify/library/api/saml.py b/edify/library/api/saml.py index 758b212..2650e50 100644 --- a/edify/library/api/saml.py +++ b/edify/library/api/saml.py @@ -1,5 +1,8 @@ """``saml`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + saml = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive saml-related identifier.""" diff --git a/edify/library/api/soap.py b/edify/library/api/soap.py index 1d7e4e5..445f658 100644 --- a/edify/library/api/soap.py +++ b/edify/library/api/soap.py @@ -1,5 +1,8 @@ """``soap`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + soap = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive soap-related identifier.""" diff --git a/edify/library/api/swagger.py b/edify/library/api/swagger.py index b6641a8..6bf9d67 100644 --- a/edify/library/api/swagger.py +++ b/edify/library/api/swagger.py @@ -1,5 +1,8 @@ """``swagger`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + swagger = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive swagger-related identifier.""" diff --git a/edify/library/api/webhook.py b/edify/library/api/webhook.py index f306dc7..80a4a82 100644 --- a/edify/library/api/webhook.py +++ b/edify/library/api/webhook.py @@ -1,5 +1,8 @@ """``webhook`` — API-spec/protocol identifier or payload shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + webhook = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{3,256}$") """Callable :class:`Pattern` for a permissive webhook-related identifier.""" diff --git a/edify/library/auth/__init__.py b/edify/library/auth/__init__.py index 68928fa..93bf38a 100644 --- a/edify/library/auth/__init__.py +++ b/edify/library/auth/__init__.py @@ -19,7 +19,23 @@ from edify.library.auth.token import token from edify.library.auth.webauthn import webauthn __all__ = [ - "apikey", "bearer", "challenge", "csrf", "hmac", "jwt", "mfa", "mnemonic", - "otp", "passkey", "password", "pin", "refresh", "secret", "session", - "signing", "sso", "token", "webauthn", + "apikey", + "bearer", + "challenge", + "csrf", + "hmac", + "jwt", + "mfa", + "mnemonic", + "otp", + "passkey", + "password", + "pin", + "refresh", + "secret", + "session", + "signing", + "sso", + "token", + "webauthn", ] diff --git a/edify/library/auth/apikey.py b/edify/library/auth/apikey.py index e27d542..c6c5fe4 100644 --- a/edify/library/auth/apikey.py +++ b/edify/library/auth/apikey.py @@ -1,4 +1,4 @@ -"""``apikey`` — opaque API-key shape (20–128 URL-safe chars).""" +"""``apikey`` — opaque API-key shape (20-128 URL-safe chars).""" from __future__ import annotations @@ -8,7 +8,12 @@ apikey = ( Pattern() .start_of_input() .between(20, 128) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for an opaque API-key shape: 20–128 URL-safe characters.""" +"""Callable :class:`Pattern` for an opaque API-key shape: 20-128 URL-safe characters.""" diff --git a/edify/library/auth/bearer.py b/edify/library/auth/bearer.py index 1a2cc2d..2ed1af2 100644 --- a/edify/library/auth/bearer.py +++ b/edify/library/auth/bearer.py @@ -9,7 +9,12 @@ bearer = ( .start_of_input() .string("Bearer ") .one_or_more() - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("._-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("._-") + .end() .end_of_input() ) """Callable :class:`Pattern` for the ``Bearer <token>`` HTTP header shape.""" diff --git a/edify/library/auth/challenge.py b/edify/library/auth/challenge.py index 76722c5..800a5ba 100644 --- a/edify/library/auth/challenge.py +++ b/edify/library/auth/challenge.py @@ -1,4 +1,4 @@ -"""``challenge`` — authentication-challenge nonce shape (16–128 URL-safe chars).""" +"""``challenge`` — authentication-challenge nonce shape (16-128 URL-safe chars).""" from __future__ import annotations @@ -8,9 +8,14 @@ challenge = ( Pattern() .start_of_input() .between(16, 128) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .end_of_input() ) """Callable :class:`Pattern` for an authentication challenge / nonce: -16–128 URL-safe characters. +16-128 URL-safe characters. """ diff --git a/edify/library/auth/csrf.py b/edify/library/auth/csrf.py index ef357e9..b492515 100644 --- a/edify/library/auth/csrf.py +++ b/edify/library/auth/csrf.py @@ -1,4 +1,4 @@ -"""``csrf`` — CSRF-token shape (32–128 URL-safe chars).""" +"""``csrf`` — CSRF-token shape (32-128 URL-safe chars).""" from __future__ import annotations @@ -8,7 +8,12 @@ csrf = ( Pattern() .start_of_input() .between(32, 128) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for a CSRF-token shape: 32–128 URL-safe characters.""" +"""Callable :class:`Pattern` for a CSRF-token shape: 32-128 URL-safe characters.""" diff --git a/edify/library/auth/hmac.py b/edify/library/auth/hmac.py index 136137c..11f89b7 100644 --- a/edify/library/auth/hmac.py +++ b/edify/library/auth/hmac.py @@ -1,4 +1,4 @@ -"""``hmac`` — HMAC signature shape (hex digest, 32–128 chars).""" +"""``hmac`` — HMAC signature shape (hex digest, 32-128 chars).""" from __future__ import annotations @@ -7,7 +7,12 @@ from edify import Pattern hmac = ( Pattern() .start_of_input() - .between(32, 128).any_of().range("0", "9").range("a", "f").range("A", "F").end() + .between(32, 128) + .any_of() + .range("0", "9") + .range("a", "f") + .range("A", "F") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for a hex HMAC digest: 32–128 hex characters.""" +"""Callable :class:`Pattern` for a hex HMAC digest: 32-128 hex characters.""" diff --git a/edify/library/auth/jwt.py b/edify/library/auth/jwt.py index 244834b..1f5d5c4 100644 --- a/edify/library/auth/jwt.py +++ b/edify/library/auth/jwt.py @@ -7,11 +7,29 @@ from edify import Pattern jwt = ( Pattern() .start_of_input() - .one_or_more().any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .one_or_more() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .char(".") - .one_or_more().any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .one_or_more() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .char(".") - .one_or_more().any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .one_or_more() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .end_of_input() ) """Callable :class:`Pattern` for the JWT shape: three base64url-encoded diff --git a/edify/library/auth/mfa.py b/edify/library/auth/mfa.py index b2261de..31e3554 100644 --- a/edify/library/auth/mfa.py +++ b/edify/library/auth/mfa.py @@ -4,10 +4,5 @@ from __future__ import annotations from edify import Pattern -mfa = ( - Pattern() - .start_of_input() - .between(6, 8).digit() - .end_of_input() -) -"""Callable :class:`Pattern` for the MFA/TOTP code shape: 6–8 decimal digits.""" +mfa = Pattern().start_of_input().between(6, 8).digit().end_of_input() +"""Callable :class:`Pattern` for the MFA/TOTP code shape: 6-8 decimal digits.""" diff --git a/edify/library/auth/mnemonic.py b/edify/library/auth/mnemonic.py index f5db890..366fe0c 100644 --- a/edify/library/auth/mnemonic.py +++ b/edify/library/auth/mnemonic.py @@ -1,4 +1,4 @@ -"""``mnemonic`` — BIP-39 mnemonic phrase shape (12–24 lowercase words separated by single spaces).""" +"""``mnemonic`` — BIP-39 mnemonic phrase shape.""" from __future__ import annotations diff --git a/edify/library/auth/otp.py b/edify/library/auth/otp.py index b32ca0c..79c54f5 100644 --- a/edify/library/auth/otp.py +++ b/edify/library/auth/otp.py @@ -1,4 +1,4 @@ -"""``otp`` — one-time password shape (6–8 digits or 6–8 alphanumerics).""" +"""``otp`` — one-time password shape (6-8 digits or 6-8 alphanumerics).""" from __future__ import annotations @@ -9,9 +9,12 @@ otp = any_of( Pattern() .start_of_input() .between(6, 8) - .any_of().range("A", "Z").range("0", "9").end() + .any_of() + .range("A", "Z") + .range("0", "9") + .end() .end_of_input(), ) -"""Callable :class:`Pattern` for the one-time-password shape: 6–8 digits or -6–8 uppercase-alphanumerics. +"""Callable :class:`Pattern` for the one-time-password shape: 6-8 digits or +6-8 uppercase-alphanumerics. """ diff --git a/edify/library/auth/passkey.py b/edify/library/auth/passkey.py index 925ebb7..415430b 100644 --- a/edify/library/auth/passkey.py +++ b/edify/library/auth/passkey.py @@ -8,9 +8,14 @@ passkey = ( Pattern() .start_of_input() .between(22, 512) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .end_of_input() ) """Callable :class:`Pattern` for a WebAuthn passkey credential-ID shape: -22–512 base64url characters. +22-512 base64url characters. """ diff --git a/edify/library/auth/pin.py b/edify/library/auth/pin.py index 5f61a0a..88620a5 100644 --- a/edify/library/auth/pin.py +++ b/edify/library/auth/pin.py @@ -1,13 +1,8 @@ -"""``pin`` — numeric PIN shape (4–12 digits).""" +"""``pin`` — numeric PIN shape (4-12 digits).""" from __future__ import annotations from edify import Pattern -pin = ( - Pattern() - .start_of_input() - .between(4, 12).digit() - .end_of_input() -) -"""Callable :class:`Pattern` for the numeric PIN shape: 4–12 digits.""" +pin = Pattern().start_of_input().between(4, 12).digit().end_of_input() +"""Callable :class:`Pattern` for the numeric PIN shape: 4-12 digits.""" diff --git a/edify/library/auth/refresh.py b/edify/library/auth/refresh.py index 5e01139..9e61600 100644 --- a/edify/library/auth/refresh.py +++ b/edify/library/auth/refresh.py @@ -1,4 +1,4 @@ -"""``refresh`` — OAuth refresh-token shape (opaque, 32–512 chars).""" +"""``refresh`` — OAuth refresh-token shape (opaque, 32-512 chars).""" from __future__ import annotations @@ -8,9 +8,14 @@ refresh = ( Pattern() .start_of_input() .between(32, 512) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("._-~+/=").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("._-~+/=") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for an OAuth refresh-token shape: 32–512 +"""Callable :class:`Pattern` for an OAuth refresh-token shape: 32-512 opaque characters (URL-safe plus common padding symbols). """ diff --git a/edify/library/auth/secret.py b/edify/library/auth/secret.py index 89b551f..4898422 100644 --- a/edify/library/auth/secret.py +++ b/edify/library/auth/secret.py @@ -1,4 +1,4 @@ -"""``secret`` — opaque secret string shape (16–256 URL-safe chars).""" +"""``secret`` — opaque secret string shape (16-256 URL-safe chars).""" from __future__ import annotations @@ -8,7 +8,12 @@ secret = ( Pattern() .start_of_input() .between(16, 256) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for an opaque secret string: 16–256 URL-safe characters.""" +"""Callable :class:`Pattern` for an opaque secret string: 16-256 URL-safe characters.""" diff --git a/edify/library/auth/session.py b/edify/library/auth/session.py index e6748ea..134a127 100644 --- a/edify/library/auth/session.py +++ b/edify/library/auth/session.py @@ -1,4 +1,4 @@ -"""``session`` — session identifier shape (16–128 URL-safe chars).""" +"""``session`` — session identifier shape (16-128 URL-safe chars).""" from __future__ import annotations @@ -8,7 +8,12 @@ session = ( Pattern() .start_of_input() .between(16, 128) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for a session-identifier shape: 16–128 URL-safe characters.""" +"""Callable :class:`Pattern` for a session-identifier shape: 16-128 URL-safe characters.""" diff --git a/edify/library/auth/signing.py b/edify/library/auth/signing.py index 30303c7..6d99a11 100644 --- a/edify/library/auth/signing.py +++ b/edify/library/auth/signing.py @@ -1,4 +1,4 @@ -"""``signing`` — request-signature shape (hex or base64, 32–256 chars).""" +"""``signing`` — request-signature shape (hex or base64, 32-256 chars).""" from __future__ import annotations @@ -8,9 +8,14 @@ signing = ( Pattern() .start_of_input() .between(32, 256) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("+/=_-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("+/=_-") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for a request-signature payload: 32–256 +"""Callable :class:`Pattern` for a request-signature payload: 32-256 base64-family characters. """ diff --git a/edify/library/auth/sso.py b/edify/library/auth/sso.py index 9e4916c..3ba59d2 100644 --- a/edify/library/auth/sso.py +++ b/edify/library/auth/sso.py @@ -1,4 +1,4 @@ -"""``sso`` — SSO ticket/assertion shape (base64 or hex, 20–2048 chars).""" +"""``sso`` — SSO ticket/assertion shape (base64 or hex, 20-2048 chars).""" from __future__ import annotations @@ -8,10 +8,15 @@ sso = ( Pattern() .start_of_input() .between(20, 2048) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("+/=_-.").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("+/=_-.") + .end() .end_of_input() ) """Callable :class:`Pattern` for an SSO ticket/assertion opaque payload: -20–2048 base64-family characters (letters, digits, ``+``, ``/``, ``=``, +20-2048 base64-family characters (letters, digits, ``+``, ``/``, ``=``, ``_``, ``-``, ``.``). """ diff --git a/edify/library/auth/token.py b/edify/library/auth/token.py index a2e0c7e..5f16ff9 100644 --- a/edify/library/auth/token.py +++ b/edify/library/auth/token.py @@ -1,4 +1,4 @@ -"""``token`` — opaque bearer/session token shape (24–256 URL-safe chars).""" +"""``token`` — opaque bearer/session token shape (24-256 URL-safe chars).""" from __future__ import annotations @@ -8,7 +8,12 @@ token = ( Pattern() .start_of_input() .between(24, 256) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-.").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-.") + .end() .end_of_input() ) -"""Callable :class:`Pattern` for opaque token strings: 24–256 URL-safe characters.""" +"""Callable :class:`Pattern` for opaque token strings: 24-256 URL-safe characters.""" diff --git a/edify/library/auth/webauthn.py b/edify/library/auth/webauthn.py index d81251c..e2d8e91 100644 --- a/edify/library/auth/webauthn.py +++ b/edify/library/auth/webauthn.py @@ -8,7 +8,12 @@ webauthn = ( Pattern() .start_of_input() .between(43, 512) - .any_of().range("A", "Z").range("a", "z").range("0", "9").any_of_chars("_-").end() + .any_of() + .range("A", "Z") + .range("a", "z") + .range("0", "9") + .any_of_chars("_-") + .end() .end_of_input() ) """Callable :class:`Pattern` for a WebAuthn credential/assertion base64url shape.""" diff --git a/edify/library/color/__init__.py b/edify/library/color/__init__.py index 205a384..a0a4741 100644 --- a/edify/library/color/__init__.py +++ b/edify/library/color/__init__.py @@ -3,4 +3,5 @@ from edify.library.color.filter import filter from edify.library.color.gradient import gradient from edify.library.color.palette import palette from edify.library.color.swatch import swatch + __all__ = ["color", "filter", "gradient", "palette", "swatch"] diff --git a/edify/library/color/color.py b/edify/library/color/color.py index 6e7b6d3..27469d5 100644 --- a/edify/library/color/color.py +++ b/edify/library/color/color.py @@ -1,6 +1,9 @@ """``color`` — CSS colour shape (hex/rgb/rgba/hsl/hsla/named).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + color = RegexBackedPattern( r"^(?:#(?:[0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})" r"|rgba?\(\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?(?:\s*,\s*[\d.]+)?\s*\)" diff --git a/edify/library/color/filter.py b/edify/library/color/filter.py index 1f6d8a5..18fb975 100644 --- a/edify/library/color/filter.py +++ b/edify/library/color/filter.py @@ -1,6 +1,9 @@ """``filter`` — CSS filter function shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + filter = RegexBackedPattern( r"^(?:blur|brightness|contrast|grayscale|hue-rotate|invert|opacity" r"|saturate|sepia|drop-shadow)" diff --git a/edify/library/color/gradient.py b/edify/library/color/gradient.py index 5baf04d..49bcede 100644 --- a/edify/library/color/gradient.py +++ b/edify/library/color/gradient.py @@ -1,7 +1,8 @@ """``gradient`` — CSS gradient shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern -gradient = RegexBackedPattern( - r"^(?:linear|radial|conic)-gradient\([^()]*(?:\([^()]*\)[^()]*)*\)$" -) + +gradient = RegexBackedPattern(r"^(?:linear|radial|conic)-gradient\([^()]*(?:\([^()]*\)[^()]*)*\)$") """Callable :class:`Pattern` for a CSS gradient function call.""" diff --git a/edify/library/color/palette.py b/edify/library/color/palette.py index 1a9ed31..441d512 100644 --- a/edify/library/color/palette.py +++ b/edify/library/color/palette.py @@ -1,6 +1,9 @@ """``palette`` — comma-separated list of colours (2-16 entries).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + palette = RegexBackedPattern( r"^(?:#[0-9A-Fa-f]{3,8}|[a-zA-Z]{3,20})" r"(?:\s*,\s*(?:#[0-9A-Fa-f]{3,8}|[a-zA-Z]{3,20})){1,15}$" diff --git a/edify/library/color/swatch.py b/edify/library/color/swatch.py index 8a89560..0d68bbd 100644 --- a/edify/library/color/swatch.py +++ b/edify/library/color/swatch.py @@ -1,5 +1,8 @@ """``swatch`` — single hex or named colour shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + swatch = RegexBackedPattern(r"^(?:#[0-9A-Fa-f]{3,8}|[a-zA-Z]{3,20})$") """Callable :class:`Pattern` for a single hex colour or CSS named colour.""" diff --git a/edify/library/contact/address.py b/edify/library/contact/address.py index 0c6d276..4d2bdaf 100644 --- a/edify/library/contact/address.py +++ b/edify/library/contact/address.py @@ -4,9 +4,7 @@ from __future__ import annotations from edify.library._support.regex import RegexBackedPattern -address = RegexBackedPattern( - r"^\d+\s+[A-Za-z0-9\s.,'\-#/]+$" -) +address = RegexBackedPattern(r"^\d+\s+[A-Za-z0-9\s.,'\-#/]+$") """Callable :class:`Pattern` for a permissive street-address shape: one or more digits followed by whitespace and address body characters. """ diff --git a/edify/library/contact/pager.py b/edify/library/contact/pager.py index 90ce5fa..910f14b 100644 --- a/edify/library/contact/pager.py +++ b/edify/library/contact/pager.py @@ -1,13 +1,8 @@ -"""``pager`` — numeric pager-number shape (4–10 digits).""" +"""``pager`` — numeric pager-number shape (4-10 digits).""" from __future__ import annotations from edify import Pattern -pager = ( - Pattern() - .start_of_input() - .between(4, 10).digit() - .end_of_input() -) -"""Callable :class:`Pattern` for the numeric pager-number shape: 4–10 digits.""" +pager = Pattern().start_of_input().between(4, 10).digit().end_of_input() +"""Callable :class:`Pattern` for the numeric pager-number shape: 4-10 digits.""" diff --git a/edify/library/contact/phone.py b/edify/library/contact/phone.py index 50423e8..eee5b77 100644 --- a/edify/library/contact/phone.py +++ b/edify/library/contact/phone.py @@ -13,5 +13,5 @@ phone = RegexBackedPattern( ) """Callable :class:`Pattern` for phone-number shapes: permissive international form (optional ``+``, country code, area code, and dash/dot/space separators) -or 2–4 digit short-code fallback. +or 2-4 digit short-code fallback. """ diff --git a/edify/library/contact/username.py b/edify/library/contact/username.py index 582d670..4a42e84 100644 --- a/edify/library/contact/username.py +++ b/edify/library/contact/username.py @@ -1,4 +1,4 @@ -"""``username`` — social-handle / login-name shape (3–30 chars alphanumeric + underscore/dot/hyphen).""" +"""``username`` — social-handle / login-name shape.""" from __future__ import annotations @@ -7,12 +7,21 @@ from edify import Pattern username = ( Pattern() .start_of_input() - .any_of().range("a", "z").range("A", "Z").range("0", "9").end() + .any_of() + .range("a", "z") + .range("A", "Z") + .range("0", "9") + .end() .between(2, 29) - .any_of().range("a", "z").range("A", "Z").range("0", "9").any_of_chars("_.-").end() + .any_of() + .range("a", "z") + .range("A", "Z") + .range("0", "9") + .any_of_chars("_.-") + .end() .end_of_input() ) """Callable :class:`Pattern` for a permissive username/handle shape: -starts with a letter or digit, 3–30 characters total, remaining characters +starts with a letter or digit, 3-30 characters total, remaining characters alphanumeric plus ``_``, ``.``, or ``-``. """ diff --git a/edify/library/data/__init__.py b/edify/library/data/__init__.py index f0e6b72..cea9539 100644 --- a/edify/library/data/__init__.py +++ b/edify/library/data/__init__.py @@ -10,7 +10,18 @@ from edify.library.data.toml import toml from edify.library.data.tsv import tsv from edify.library.data.xml import xml from edify.library.data.yaml import yaml + __all__ = [ - "avro", "csv", "hdf5", "html", "ini", "json", "msgpack", - "protobuf", "toml", "tsv", "xml", "yaml", + "avro", + "csv", + "hdf5", + "html", + "ini", + "json", + "msgpack", + "protobuf", + "toml", + "tsv", + "xml", + "yaml", ] diff --git a/edify/library/data/avro.py b/edify/library/data/avro.py index e371e98..2771d16 100644 --- a/edify/library/data/avro.py +++ b/edify/library/data/avro.py @@ -1,5 +1,8 @@ """``avro`` — avro data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + avro = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for avro data-format identifier or content marker.""" diff --git a/edify/library/data/csv.py b/edify/library/data/csv.py index 7e84ed7..5044162 100644 --- a/edify/library/data/csv.py +++ b/edify/library/data/csv.py @@ -1,5 +1,8 @@ """``csv`` — csv data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + csv = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for csv data-format identifier or content marker.""" diff --git a/edify/library/data/hdf5.py b/edify/library/data/hdf5.py index a11cd12..a3e070f 100644 --- a/edify/library/data/hdf5.py +++ b/edify/library/data/hdf5.py @@ -1,5 +1,8 @@ """``hdf5`` — hdf5 data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + hdf5 = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for hdf5 data-format identifier or content marker.""" diff --git a/edify/library/data/html.py b/edify/library/data/html.py index 4004688..ffccd73 100644 --- a/edify/library/data/html.py +++ b/edify/library/data/html.py @@ -1,5 +1,8 @@ """``html`` — html data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + html = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for html data-format identifier or content marker.""" diff --git a/edify/library/data/ini.py b/edify/library/data/ini.py index d7eee13..42b0ef8 100644 --- a/edify/library/data/ini.py +++ b/edify/library/data/ini.py @@ -1,5 +1,8 @@ """``ini`` — ini data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + ini = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for ini data-format identifier or content marker.""" diff --git a/edify/library/data/json.py b/edify/library/data/json.py index 2352277..905a5db 100644 --- a/edify/library/data/json.py +++ b/edify/library/data/json.py @@ -1,5 +1,8 @@ """``json`` — json data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + json = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for json data-format identifier or content marker.""" diff --git a/edify/library/data/msgpack.py b/edify/library/data/msgpack.py index 0f89a42..85bed6b 100644 --- a/edify/library/data/msgpack.py +++ b/edify/library/data/msgpack.py @@ -1,5 +1,8 @@ """``msgpack`` — msgpack data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + msgpack = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for msgpack data-format identifier or content marker.""" diff --git a/edify/library/data/protobuf.py b/edify/library/data/protobuf.py index c6c0ef6..1677310 100644 --- a/edify/library/data/protobuf.py +++ b/edify/library/data/protobuf.py @@ -1,5 +1,8 @@ """``protobuf`` — protobuf data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + protobuf = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for protobuf data-format identifier or content marker.""" diff --git a/edify/library/data/toml.py b/edify/library/data/toml.py index 0ddd51f..32b710f 100644 --- a/edify/library/data/toml.py +++ b/edify/library/data/toml.py @@ -1,5 +1,8 @@ """``toml`` — toml data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + toml = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for toml data-format identifier or content marker.""" diff --git a/edify/library/data/tsv.py b/edify/library/data/tsv.py index fc4a38a..9a7dedd 100644 --- a/edify/library/data/tsv.py +++ b/edify/library/data/tsv.py @@ -1,5 +1,8 @@ """``tsv`` — tsv data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + tsv = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for tsv data-format identifier or content marker.""" diff --git a/edify/library/data/xml.py b/edify/library/data/xml.py index 290f6a2..37ae850 100644 --- a/edify/library/data/xml.py +++ b/edify/library/data/xml.py @@ -1,5 +1,8 @@ """``xml`` — xml data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + xml = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for xml data-format identifier or content marker.""" diff --git a/edify/library/data/yaml.py b/edify/library/data/yaml.py index 12a50e0..4b67953 100644 --- a/edify/library/data/yaml.py +++ b/edify/library/data/yaml.py @@ -1,5 +1,8 @@ """``yaml`` — yaml data-format / file-marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + yaml = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+]{2,256}$") """Callable :class:`Pattern` for yaml data-format identifier or content marker.""" diff --git a/edify/library/document/__init__.py b/edify/library/document/__init__.py index b859500..215845a 100644 --- a/edify/library/document/__init__.py +++ b/edify/library/document/__init__.py @@ -7,6 +7,15 @@ from edify.library.document.pptx import pptx from edify.library.document.readme import readme from edify.library.document.svg import svg from edify.library.document.xlsx import xlsx + __all__ = [ - "docx", "epub", "mobi", "odt", "pdf", "pptx", "readme", "svg", "xlsx", + "docx", + "epub", + "mobi", + "odt", + "pdf", + "pptx", + "readme", + "svg", + "xlsx", ] diff --git a/edify/library/document/docx.py b/edify/library/document/docx.py index 4439922..cc503f3 100644 --- a/edify/library/document/docx.py +++ b/edify/library/document/docx.py @@ -1,5 +1,8 @@ """``docx`` — docx document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + docx = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a docx document identifier or file name.""" diff --git a/edify/library/document/epub.py b/edify/library/document/epub.py index 720e4c2..ea09d30 100644 --- a/edify/library/document/epub.py +++ b/edify/library/document/epub.py @@ -1,5 +1,8 @@ """``epub`` — epub document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + epub = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a epub document identifier or file name.""" diff --git a/edify/library/document/mobi.py b/edify/library/document/mobi.py index b5ebc15..eb7e967 100644 --- a/edify/library/document/mobi.py +++ b/edify/library/document/mobi.py @@ -1,5 +1,8 @@ """``mobi`` — mobi document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + mobi = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a mobi document identifier or file name.""" diff --git a/edify/library/document/odt.py b/edify/library/document/odt.py index 04f7191..41ec7f0 100644 --- a/edify/library/document/odt.py +++ b/edify/library/document/odt.py @@ -1,5 +1,8 @@ """``odt`` — odt document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + odt = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a odt document identifier or file name.""" diff --git a/edify/library/document/pdf.py b/edify/library/document/pdf.py index e7acd55..3b5f5c3 100644 --- a/edify/library/document/pdf.py +++ b/edify/library/document/pdf.py @@ -1,5 +1,8 @@ """``pdf`` — pdf document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + pdf = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a pdf document identifier or file name.""" diff --git a/edify/library/document/pptx.py b/edify/library/document/pptx.py index 668f194..906e94b 100644 --- a/edify/library/document/pptx.py +++ b/edify/library/document/pptx.py @@ -1,5 +1,8 @@ """``pptx`` — pptx document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + pptx = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a pptx document identifier or file name.""" diff --git a/edify/library/document/readme.py b/edify/library/document/readme.py index da7c9c3..5c52ba7 100644 --- a/edify/library/document/readme.py +++ b/edify/library/document/readme.py @@ -1,5 +1,8 @@ """``readme`` — readme document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + readme = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a readme document identifier or file name.""" diff --git a/edify/library/document/svg.py b/edify/library/document/svg.py index c3e31fe..261d3a4 100644 --- a/edify/library/document/svg.py +++ b/edify/library/document/svg.py @@ -1,5 +1,8 @@ """``svg`` — svg document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + svg = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a svg document identifier or file name.""" diff --git a/edify/library/document/xlsx.py b/edify/library/document/xlsx.py index 2ffdeaf..417c154 100644 --- a/edify/library/document/xlsx.py +++ b/edify/library/document/xlsx.py @@ -1,5 +1,8 @@ """``xlsx`` — xlsx document-format filename / marker shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + xlsx = RegexBackedPattern(r"^[A-Za-z0-9_.\-/]{1,256}$") """Callable :class:`Pattern` for a xlsx document identifier or file name.""" diff --git a/edify/library/financial/card.py b/edify/library/financial/card.py index c6829d2..53c38ce 100644 --- a/edify/library/financial/card.py +++ b/edify/library/financial/card.py @@ -1,4 +1,4 @@ -"""``card`` — credit-card number shape (13–19 digits, optional dash/space separators).""" +"""``card`` — credit-card number shape (13-19 digits, optional dash/space separators).""" from __future__ import annotations @@ -6,5 +6,5 @@ from edify.library._support.regex import RegexBackedPattern card = RegexBackedPattern(r"^\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{1,7}$") """Callable :class:`Pattern` for credit-card number shape: -groups of 4 digits with optional dash/space separators, 13–19 digits total. +groups of 4 digits with optional dash/space separators, 13-19 digits total. """ diff --git a/edify/library/financial/crypto.py b/edify/library/financial/crypto.py index f2f01a2..7e366ac 100644 --- a/edify/library/financial/crypto.py +++ b/edify/library/financial/crypto.py @@ -7,9 +7,13 @@ from edify import Pattern crypto = ( Pattern() .start_of_input() - .between(3, 10).any_of().range("A", "Z").range("0", "9").end() + .between(3, 10) + .any_of() + .range("A", "Z") + .range("0", "9") + .end() .end_of_input() ) """Callable :class:`Pattern` for a cryptocurrency ticker shape: -3–10 uppercase-alphanumeric characters (``BTC``, ``ETH``, ``USDT``, ``SHIB``, …). +3-10 uppercase-alphanumeric characters (``BTC``, ``ETH``, ``USDT``, ``SHIB``, …). """ diff --git a/edify/library/financial/currency.py b/edify/library/financial/currency.py index da67aa8..7b5e546 100644 --- a/edify/library/financial/currency.py +++ b/edify/library/financial/currency.py @@ -4,12 +4,7 @@ from __future__ import annotations from edify import Pattern -currency = ( - Pattern() - .start_of_input() - .exactly(3).any_of().range("A", "Z").end() - .end_of_input() -) +currency = Pattern().start_of_input().exactly(3).any_of().range("A", "Z").end().end_of_input() """Callable :class:`Pattern` for the ISO 4217 currency-code shape: 3 uppercase letters (``USD``, ``EUR``, ``JPY``, …). """ diff --git a/edify/library/geo/geohash.py b/edify/library/geo/geohash.py index abf865b..3d4122f 100644 --- a/edify/library/geo/geohash.py +++ b/edify/library/geo/geohash.py @@ -1,4 +1,4 @@ -"""``geohash`` — geohash string shape (1–12 base32-encoded chars).""" +"""``geohash`` — geohash string shape (1-12 base32-encoded chars).""" from __future__ import annotations @@ -8,7 +8,10 @@ geohash = ( Pattern() .start_of_input() .between(1, 12) - .any_of().range("0", "9").any_of_chars("bcdefghjkmnpqrstuvwxyz").end() + .any_of() + .range("0", "9") + .any_of_chars("bcdefghjkmnpqrstuvwxyz") + .end() .end_of_input() ) """Callable :class:`Pattern` for the geohash string shape.""" diff --git a/edify/library/geo/plus.py b/edify/library/geo/plus.py index 52f8f35..fe2176f 100644 --- a/edify/library/geo/plus.py +++ b/edify/library/geo/plus.py @@ -4,7 +4,5 @@ from __future__ import annotations from edify.library._support.regex import RegexBackedPattern -plus = RegexBackedPattern( - r"^[23456789CFGHJMPQRVWX]{2,8}\+[23456789CFGHJMPQRVWX]{2,3}(?:\s+.+)?$" -) +plus = RegexBackedPattern(r"^[23456789CFGHJMPQRVWX]{2,8}\+[23456789CFGHJMPQRVWX]{2,3}(?:\s+.+)?$") """Callable :class:`Pattern` for a Google Plus Code (Open Location Code).""" diff --git a/edify/library/grammar/__init__.py b/edify/library/grammar/__init__.py index bc507cf..2b7f067 100644 --- a/edify/library/grammar/__init__.py +++ b/edify/library/grammar/__init__.py @@ -3,4 +3,5 @@ from edify.library.grammar.bnf import bnf from edify.library.grammar.ebnf import ebnf from edify.library.grammar.peg import peg from edify.library.grammar.pest import pest + __all__ = ["abnf", "bnf", "ebnf", "peg", "pest"] diff --git a/edify/library/grammar/abnf.py b/edify/library/grammar/abnf.py index 25f4d6f..a87f3d8 100644 --- a/edify/library/grammar/abnf.py +++ b/edify/library/grammar/abnf.py @@ -1,5 +1,8 @@ """``abnf`` — abnf grammar-spec content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + abnf = RegexBackedPattern(r"^[A-Za-z0-9_\-<>:=|*+?()\[\]{}\s.'\"/;,]{4,65536}$") """Callable :class:`Pattern` for abnf grammar-specification content.""" diff --git a/edify/library/grammar/bnf.py b/edify/library/grammar/bnf.py index 4d1cf87..40ec7c6 100644 --- a/edify/library/grammar/bnf.py +++ b/edify/library/grammar/bnf.py @@ -1,5 +1,8 @@ """``bnf`` — bnf grammar-spec content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + bnf = RegexBackedPattern(r"^[A-Za-z0-9_\-<>:=|*+?()\[\]{}\s.'\"/;,]{4,65536}$") """Callable :class:`Pattern` for bnf grammar-specification content.""" diff --git a/edify/library/grammar/ebnf.py b/edify/library/grammar/ebnf.py index ead4bd8..2492688 100644 --- a/edify/library/grammar/ebnf.py +++ b/edify/library/grammar/ebnf.py @@ -1,5 +1,8 @@ """``ebnf`` — ebnf grammar-spec content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + ebnf = RegexBackedPattern(r"^[A-Za-z0-9_\-<>:=|*+?()\[\]{}\s.'\"/;,]{4,65536}$") """Callable :class:`Pattern` for ebnf grammar-specification content.""" diff --git a/edify/library/grammar/peg.py b/edify/library/grammar/peg.py index 38e5e79..74d1ffc 100644 --- a/edify/library/grammar/peg.py +++ b/edify/library/grammar/peg.py @@ -1,5 +1,8 @@ """``peg`` — peg grammar-spec content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + peg = RegexBackedPattern(r"^[A-Za-z0-9_\-<>:=|*+?()\[\]{}\s.'\"/;,]{4,65536}$") """Callable :class:`Pattern` for peg grammar-specification content.""" diff --git a/edify/library/grammar/pest.py b/edify/library/grammar/pest.py index c9334d6..be083ae 100644 --- a/edify/library/grammar/pest.py +++ b/edify/library/grammar/pest.py @@ -1,5 +1,8 @@ """``pest`` — pest grammar-spec content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + pest = RegexBackedPattern(r"^[A-Za-z0-9_\-<>:=|*+?()\[\]{}\s.'\"/;,]{4,65536}$") """Callable :class:`Pattern` for pest grammar-specification content.""" diff --git a/edify/library/identifier/__init__.py b/edify/library/identifier/__init__.py index 49773f6..3210ff9 100644 --- a/edify/library/identifier/__init__.py +++ b/edify/library/identifier/__init__.py @@ -7,8 +7,8 @@ from edify.library.identifier.ein import ein from edify.library.identifier.guid import guid from edify.library.identifier.iata import iata from edify.library.identifier.iban import iban -from edify.library.identifier.iccid import iccid from edify.library.identifier.icao import icao +from edify.library.identifier.iccid import iccid from edify.library.identifier.imei import imei from edify.library.identifier.imo import imo from edify.library.identifier.isin import isin @@ -35,8 +35,8 @@ __all__ = [ "guid", "iata", "iban", - "iccid", "icao", + "iccid", "imei", "imo", "isin", diff --git a/edify/library/identifier/arn.py b/edify/library/identifier/arn.py index d429a65..d8b14f5 100644 --- a/edify/library/identifier/arn.py +++ b/edify/library/identifier/arn.py @@ -8,15 +8,31 @@ arn = ( Pattern() .start_of_input() .string("arn:") - .one_or_more().any_of().range("a", "z").char("-").end() + .one_or_more() + .any_of() + .range("a", "z") + .char("-") + .end() .char(":") - .one_or_more().any_of().range("a", "z").range("0", "9").char("-").end() + .one_or_more() + .any_of() + .range("a", "z") + .range("0", "9") + .char("-") + .end() .char(":") - .zero_or_more().any_of().range("a", "z").range("0", "9").char("-").end() + .zero_or_more() + .any_of() + .range("a", "z") + .range("0", "9") + .char("-") + .end() .char(":") - .zero_or_more().digit() + .zero_or_more() + .digit() .char(":") - .one_or_more().any_char() + .one_or_more() + .any_char() .end_of_input() ) """Callable :class:`Pattern` for the AWS ARN shape: diff --git a/edify/library/identifier/asin.py b/edify/library/identifier/asin.py index 0fe69bd..05d4f5c 100644 --- a/edify/library/identifier/asin.py +++ b/edify/library/identifier/asin.py @@ -7,7 +7,11 @@ from edify import Pattern asin = ( Pattern() .start_of_input() - .exactly(10).any_of().range("A", "Z").range("0", "9").end() + .exactly(10) + .any_of() + .range("A", "Z") + .range("0", "9") + .end() .end_of_input() ) """Callable :class:`Pattern` for the 10-character alphanumeric ASIN shape.""" diff --git a/edify/library/identifier/bic.py b/edify/library/identifier/bic.py index d89ec9e..760f4ed 100644 --- a/edify/library/identifier/bic.py +++ b/edify/library/identifier/bic.py @@ -7,13 +7,21 @@ from edify import Pattern bic = ( Pattern() .start_of_input() - .exactly(4).any_of().range("A", "Z").end() - .exactly(2).any_of().range("A", "Z").end() - .exactly(2).any_of().range("A", "Z").range("0", "9").end() + .exactly(4) + .any_of() + .range("A", "Z") + .end() + .exactly(2) + .any_of() + .range("A", "Z") + .end() + .exactly(2) + .any_of() + .range("A", "Z") + .range("0", "9") + .end() .optional() - .subexpression( - Pattern().exactly(3).any_of().range("A", "Z").range("0", "9").end() - ) + .subexpression(Pattern().exactly(3).any_of().range("A", "Z").range("0", "9").end()) .end_of_input() ) """Callable :class:`Pattern` for the ISO 9362 BIC/SWIFT shape: diff --git a/edify/library/identifier/cusip.py b/edify/library/identifier/cusip.py index a8673cd..f4f4149 100644 --- a/edify/library/identifier/cusip.py +++ b/edify/library/identifier/cusip.py @@ -7,7 +7,11 @@ from edify import Pattern cusip = ( Pattern() .start_of_input() - .exactly(9).any_of().range("A", "Z").range("0", "9").end() + .exactly(9) + .any_of() + .range("A", "Z") + .range("0", "9") + .end() .end_of_input() ) """Callable :class:`Pattern` for the 9-character alphanumeric CUSIP shape.""" diff --git a/edify/library/identifier/did.py b/edify/library/identifier/did.py index aad42c1..30f63a5 100644 --- a/edify/library/identifier/did.py +++ b/edify/library/identifier/did.py @@ -8,9 +8,14 @@ did = ( Pattern() .start_of_input() .string("did:") - .one_or_more().any_of().range("a", "z").range("0", "9").end() + .one_or_more() + .any_of() + .range("a", "z") + .range("0", "9") + .end() .char(":") - .one_or_more().any_char() + .one_or_more() + .any_char() .end_of_input() ) """Callable :class:`Pattern` for the DID shape: literal ``did:`` + diff --git a/edify/library/identifier/ein.py b/edify/library/identifier/ein.py index e95087d..98975ce 100644 --- a/edify/library/identifier/ein.py +++ b/edify/library/identifier/ein.py @@ -4,12 +4,5 @@ from __future__ import annotations from edify import Pattern -ein = ( - Pattern() - .start_of_input() - .exactly(2).digit() - .char("-") - .exactly(7).digit() - .end_of_input() -) -"""Callable :class:`Pattern` for the US EIN ``XX-XXXXXXX`` shape."""
\ No newline at end of file +ein = Pattern().start_of_input().exactly(2).digit().char("-").exactly(7).digit().end_of_input() +"""Callable :class:`Pattern` for the US EIN ``XX-XXXXXXX`` shape.""" diff --git a/edify/library/identifier/guid.py b/edify/library/identifier/guid.py index bc90251..dc1e6ba 100644 --- a/edify/library/identifier/guid.py +++ b/edify/library/identifier/guid.py @@ -7,19 +7,46 @@ from edify import Pattern guid = ( Pattern() .start_of_input() - .optional().char("{") - .exactly(8).any_of().range("0", "9").range("a", "f").range("A", "F").end() + .optional() + .char("{") + .exactly(8) + .any_of() + .range("0", "9") + .range("a", "f") + .range("A", "F") + .end() .char("-") - .exactly(4).any_of().range("0", "9").range("a", "f").range("A", "F").end() + .exactly(4) + .any_of() + .range("0", "9") + .range("a", "f") + .range("A", "F") + .end() .char("-") - .exactly(4).any_of().range("0", "9").range("a", "f").range("A", "F").end() + .exactly(4) + .any_of() + .range("0", "9") + .range("a", "f") + .range("A", "F") + .end() .char("-") - .exactly(4).any_of().range("0", "9").range("a", "f").range("A", "F").end() + .exactly(4) + .any_of() + .range("0", "9") + .range("a", "f") + .range("A", "F") + .end() .char("-") - .exactly(12).any_of().range("0", "9").range("a", "f").range("A", "F").end() - .optional().char("}") + .exactly(12) + .any_of() + .range("0", "9") + .range("a", "f") + .range("A", "F") + .end() + .optional() + .char("}") .end_of_input() ) """Callable :class:`Pattern` that validates the Microsoft-flavour GUID shape: the 8-4-4-4-12 hex form (either case) optionally wrapped in braces. -"""
\ No newline at end of file +""" diff --git a/edify/library/identifier/iata.py b/edify/library/identifier/iata.py index 6eea196..e6ec70e 100644 --- a/edify/library/identifier/iata.py +++ b/edify/library/identifier/iata.py @@ -4,12 +4,7 @@ from __future__ import annotations from edify import Pattern -iata = ( - Pattern() - .start_of_input() - .between(2, 3).any_of().range("A", "Z").end() - .end_of_input() -) +iata = Pattern().start_of_input().between(2, 3).any_of().range("A", "Z").end().end_of_input() """Callable :class:`Pattern` for the IATA code shape: 2 uppercase letters (airline) or 3 uppercase letters (airport). """ diff --git a/edify/library/identifier/iban.py b/edify/library/identifier/iban.py index a0bc42c..0d20221 100644 --- a/edify/library/identifier/iban.py +++ b/edify/library/identifier/iban.py @@ -1,4 +1,4 @@ -"""``iban`` — International Bank Account Number shape (2 letter country + 2 check digits + up to 30 alphanumerics).""" +"""``iban`` — International Bank Account Number shape.""" from __future__ import annotations @@ -7,11 +7,19 @@ from edify import Pattern iban = ( Pattern() .start_of_input() - .exactly(2).any_of().range("A", "Z").end() - .exactly(2).digit() - .between(1, 30).any_of().range("A", "Z").range("0", "9").end() + .exactly(2) + .any_of() + .range("A", "Z") + .end() + .exactly(2) + .digit() + .between(1, 30) + .any_of() + .range("A", "Z") + .range("0", "9") + .end() .end_of_input() ) """Callable :class:`Pattern` for the IBAN shape: 2-letter ISO country code + -2 check digits + 1–30 uppercase-alphanumeric BBAN characters. +2 check digits + 1-30 uppercase-alphanumeric BBAN characters. """ diff --git a/edify/library/identifier/icao.py b/edify/library/identifier/icao.py index 18ef8e1..a60b8d3 100644 --- a/edify/library/identifier/icao.py +++ b/edify/library/identifier/icao.py @@ -4,12 +4,7 @@ from __future__ import annotations from edify import Pattern -icao = ( - Pattern() - .start_of_input() - .between(3, 4).any_of().range("A", "Z").end() - .end_of_input() -) +icao = Pattern().start_of_input().between(3, 4).any_of().range("A", "Z").end().end_of_input() """Callable :class:`Pattern` for the ICAO code shape: 3 uppercase letters (airline) or 4 uppercase letters (airport). """ diff --git a/edify/library/identifier/iccid.py b/edify/library/identifier/iccid.py index 8bc228b..ef25f9b 100644 --- a/edify/library/identifier/iccid.py +++ b/edify/library/identifier/iccid.py @@ -1,13 +1,8 @@ -"""``iccid`` — 19–22 digit Integrated Circuit Card Identifier.""" +"""``iccid`` — 19-22 digit Integrated Circuit Card Identifier.""" from __future__ import annotations from edify import Pattern -iccid = ( - Pattern() - .start_of_input() - .between(19, 22).digit() - .end_of_input() -) +iccid = Pattern().start_of_input().between(19, 22).digit().end_of_input() """Callable :class:`Pattern` for the ICCID shape: 19 to 22 decimal digits.""" diff --git a/edify/library/identifier/imei.py b/edify/library/identifier/imei.py index 7fff2c0..4284bfa 100644 --- a/edify/library/identifier/imei.py +++ b/edify/library/identifier/imei.py @@ -4,10 +4,5 @@ from __future__ import annotations from edify import Pattern -imei = ( - Pattern() - .start_of_input() - .exactly(15).digit() - .end_of_input() -) +imei = Pattern().start_of_input().exactly(15).digit().end_of_input() """Callable :class:`Pattern` for the 15-digit IMEI shape.""" diff --git a/edify/library/identifier/imo.py b/edify/library/identifier/imo.py index b0e4ad6..738cc9d 100644 --- a/edify/library/identifier/imo.py +++ b/edify/library/identifier/imo.py @@ -4,13 +4,7 @@ from __future__ import annotations from edify import Pattern -imo = ( - Pattern() - .start_of_input() - .string("IMO") - .exactly(7).digit() - .end_of_input() -) +imo = Pattern().start_of_input().string("IMO").exactly(7).digit().end_of_input() """Callable :class:`Pattern` for the IMO ship-number shape: literal ``IMO`` followed by 7 digits. """ diff --git a/edify/library/identifier/isin.py b/edify/library/identifier/isin.py index e8283a5..6af65d0 100644 --- a/edify/library/identifier/isin.py +++ b/edify/library/identifier/isin.py @@ -7,8 +7,15 @@ from edify import Pattern isin = ( Pattern() .start_of_input() - .exactly(2).any_of().range("A", "Z").end() - .exactly(9).any_of().range("A", "Z").range("0", "9").end() + .exactly(2) + .any_of() + .range("A", "Z") + .end() + .exactly(9) + .any_of() + .range("A", "Z") + .range("0", "9") + .end() .digit() .end_of_input() ) diff --git a/edify/library/identifier/itin.py b/edify/library/identifier/itin.py index 13cc51c..1f69006 100644 --- a/edify/library/identifier/itin.py +++ b/edify/library/identifier/itin.py @@ -17,15 +17,17 @@ itin = ( Pattern() .start_of_input() .char("9") - .exactly(2).digit() + .exactly(2) + .digit() .char("-") .subexpression(_group_range) .char("-") - .exactly(4).digit() + .exactly(4) + .digit() .end_of_input() ) """Callable :class:`Pattern` for the US ITIN ``9NN-YY-ZZZZ`` shape (area starts -with 9; group in ``50``–``65``, ``70``–``88``, ``90``–``92``, or ``94``–``99``). +with 9; group in ``50``-``65``, ``70``-``88``, ``90``-``92``, or ``94``-``99``). """ -del _group_range
\ No newline at end of file +del _group_range diff --git a/edify/library/identifier/lei.py b/edify/library/identifier/lei.py index d6cfaa2..b2cf23e 100644 --- a/edify/library/identifier/lei.py +++ b/edify/library/identifier/lei.py @@ -7,7 +7,11 @@ from edify import Pattern lei = ( Pattern() .start_of_input() - .exactly(20).any_of().range("A", "Z").range("0", "9").end() + .exactly(20) + .any_of() + .range("A", "Z") + .range("0", "9") + .end() .end_of_input() ) """Callable :class:`Pattern` for the ISO 17442 LEI: 20 uppercase-alphanumeric characters.""" diff --git a/edify/library/identifier/mac.py b/edify/library/identifier/mac.py index 4df09f5..173bc67 100644 --- a/edify/library/identifier/mac.py +++ b/edify/library/identifier/mac.py @@ -9,12 +9,22 @@ mac = ( .start_of_input() .exactly(5) .group() - .exactly(2).any_of().range("0", "9").range("a", "f").range("A", "F").end() + .exactly(2) + .any_of() + .range("0", "9") + .range("a", "f") + .range("A", "F") + .end() .any_of_chars(":-") .end() - .exactly(2).any_of().range("0", "9").range("a", "f").range("A", "F").end() + .exactly(2) + .any_of() + .range("0", "9") + .range("a", "f") + .range("A", "F") + .end() .end_of_input() ) """Callable :class:`Pattern` that validates the IEEE 802 MAC-address form: six ``:``- or ``-``-separated hex octets (either case). -"""
\ No newline at end of file +""" diff --git a/edify/library/identifier/meid.py b/edify/library/identifier/meid.py index 12f4beb..f4e4c4a 100644 --- a/edify/library/identifier/meid.py +++ b/edify/library/identifier/meid.py @@ -7,7 +7,11 @@ from edify import Pattern meid = ( Pattern() .start_of_input() - .exactly(14).any_of().range("0", "9").range("A", "F").end() + .exactly(14) + .any_of() + .range("0", "9") + .range("A", "F") + .end() .end_of_input() ) """Callable :class:`Pattern` for the 14-character uppercase-hex MEID shape.""" diff --git a/edify/library/identifier/mmsi.py b/edify/library/identifier/mmsi.py index 1e2b10d..e88d0e6 100644 --- a/edify/library/identifier/mmsi.py +++ b/edify/library/identifier/mmsi.py @@ -4,10 +4,5 @@ from __future__ import annotations from edify import Pattern -mmsi = ( - Pattern() - .start_of_input() - .exactly(9).digit() - .end_of_input() -) +mmsi = Pattern().start_of_input().exactly(9).digit().end_of_input() """Callable :class:`Pattern` for the 9-digit MMSI shape.""" diff --git a/edify/library/identifier/orcid.py b/edify/library/identifier/orcid.py index e1fb5a7..9fccd20 100644 --- a/edify/library/identifier/orcid.py +++ b/edify/library/identifier/orcid.py @@ -7,14 +7,21 @@ from edify import Pattern orcid = ( Pattern() .start_of_input() - .exactly(4).digit() + .exactly(4) + .digit() .char("-") - .exactly(4).digit() + .exactly(4) + .digit() .char("-") - .exactly(4).digit() + .exactly(4) + .digit() .char("-") - .exactly(3).digit() - .any_of().digit().char("X").end() + .exactly(3) + .digit() + .any_of() + .digit() + .char("X") + .end() .end_of_input() ) """Callable :class:`Pattern` for the ORCID identifier shape: diff --git a/edify/library/identifier/sedol.py b/edify/library/identifier/sedol.py index e6b80c2..b568206 100644 --- a/edify/library/identifier/sedol.py +++ b/edify/library/identifier/sedol.py @@ -7,8 +7,16 @@ from edify import Pattern sedol = ( Pattern() .start_of_input() - .exactly(6).any_of().range("B", "D").range("F", "H").range("J", "N") - .range("P", "T").range("V", "X").range("Y", "Z").range("0", "9").end() + .exactly(6) + .any_of() + .range("B", "D") + .range("F", "H") + .range("J", "N") + .range("P", "T") + .range("V", "X") + .range("Y", "Z") + .range("0", "9") + .end() .digit() .end_of_input() ) diff --git a/edify/library/identifier/sku.py b/edify/library/identifier/sku.py index d7c05bd..bcec532 100644 --- a/edify/library/identifier/sku.py +++ b/edify/library/identifier/sku.py @@ -1,4 +1,4 @@ -"""``sku`` — Stock Keeping Unit (4–20 alphanumerics plus common separators).""" +"""``sku`` — Stock Keeping Unit (4-20 alphanumerics plus common separators).""" from __future__ import annotations @@ -9,12 +9,14 @@ sku = ( .start_of_input() .between(4, 20) .any_of() - .range("A", "Z").range("a", "z").range("0", "9") + .range("A", "Z") + .range("a", "z") + .range("0", "9") .any_of_chars("-_./") .end() .end_of_input() ) -"""Callable :class:`Pattern` for a permissive SKU shape: 4–20 characters +"""Callable :class:`Pattern` for a permissive SKU shape: 4-20 characters drawn from letters, digits, and common product-code separators (``-``, ``_``, ``.``, ``/``). """ diff --git a/edify/library/identifier/ssn.py b/edify/library/identifier/ssn.py index ee5da28..a35b5e4 100644 --- a/edify/library/identifier/ssn.py +++ b/edify/library/identifier/ssn.py @@ -16,13 +16,21 @@ ssn = ( .assert_not_ahead() .subexpression(_blocked_area) .end() - .exactly(3).digit() + .exactly(3) + .digit() .char("-") - .assert_not_ahead().string("00").end() - .exactly(2).digit() + .assert_not_ahead() + .string("00") + .end() + .exactly(2) + .digit() .char("-") - .assert_not_ahead().exactly(4).char("0").end() - .exactly(4).digit() + .assert_not_ahead() + .exactly(4) + .char("0") + .end() + .exactly(4) + .digit() .end_of_input() ) """Callable :class:`Pattern` that validates the US ``AAA-GG-SSSS`` SSN shape @@ -30,4 +38,4 @@ with the documented blocked ranges (``000``, ``666``, ``9xx`` area; ``00`` group; ``0000`` serial). """ -del _blocked_area
\ No newline at end of file +del _blocked_area diff --git a/edify/library/identifier/uuid.py b/edify/library/identifier/uuid.py index e93bb2a..ddd12a4 100644 --- a/edify/library/identifier/uuid.py +++ b/edify/library/identifier/uuid.py @@ -7,20 +7,40 @@ from edify import Pattern uuid = ( Pattern() .start_of_input() - .exactly(8).any_of().range("0", "9").range("a", "f").end() + .exactly(8) + .any_of() + .range("0", "9") + .range("a", "f") + .end() .char("-") - .exactly(4).any_of().range("0", "9").range("a", "f").end() + .exactly(4) + .any_of() + .range("0", "9") + .range("a", "f") + .end() .char("-") .range("0", "5") - .exactly(3).any_of().range("0", "9").range("a", "f").end() + .exactly(3) + .any_of() + .range("0", "9") + .range("a", "f") + .end() .char("-") .any_of_chars("089ab") - .exactly(3).any_of().range("0", "9").range("a", "f").end() + .exactly(3) + .any_of() + .range("0", "9") + .range("a", "f") + .end() .char("-") - .exactly(12).any_of().range("0", "9").range("a", "f").end() + .exactly(12) + .any_of() + .range("0", "9") + .range("a", "f") + .end() .end_of_input() ) """Callable :class:`Pattern` that validates the canonical UUID 8-4-4-4-12 -lowercase-hex shape with the version digit pinned to ``1``–``5`` and the -variant digit pinned to ``8``–``b``. -"""
\ No newline at end of file +lowercase-hex shape with the version digit pinned to ``1``-``5`` and the +variant digit pinned to ``8``-``b``. +""" diff --git a/edify/library/media/__init__.py b/edify/library/media/__init__.py index 1f5a8f2..7169422 100644 --- a/edify/library/media/__init__.py +++ b/edify/library/media/__init__.py @@ -9,7 +9,17 @@ from edify.library.media.locale import locale from edify.library.media.mimetype import mimetype from edify.library.media.regex import regex from edify.library.media.shebang import shebang + __all__ = [ - "charset", "codec", "encoding", "extension", "favicon", "filename", - "glob", "locale", "mimetype", "regex", "shebang", + "charset", + "codec", + "encoding", + "extension", + "favicon", + "filename", + "glob", + "locale", + "mimetype", + "regex", + "shebang", ] diff --git a/edify/library/media/charset.py b/edify/library/media/charset.py index b605a9b..f0d83b4 100644 --- a/edify/library/media/charset.py +++ b/edify/library/media/charset.py @@ -1,5 +1,8 @@ """``charset`` — character set name shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + charset = RegexBackedPattern(r"^[a-zA-Z][a-zA-Z0-9_+.\-]{1,39}$") """Callable :class:`Pattern` for an IANA character-set name.""" diff --git a/edify/library/media/codec.py b/edify/library/media/codec.py index cedf22e..2ab3040 100644 --- a/edify/library/media/codec.py +++ b/edify/library/media/codec.py @@ -1,5 +1,8 @@ """``codec`` — media codec name shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + codec = RegexBackedPattern(r"^[a-zA-Z][a-zA-Z0-9_.\-]{1,29}$") """Callable :class:`Pattern` for a media codec name (``h264``, ``vp9``, ``aac``, etc.).""" diff --git a/edify/library/media/encoding.py b/edify/library/media/encoding.py index cc6decd..5f8f624 100644 --- a/edify/library/media/encoding.py +++ b/edify/library/media/encoding.py @@ -1,5 +1,8 @@ """``encoding`` — text encoding name shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + encoding = RegexBackedPattern(r"^[a-zA-Z][a-zA-Z0-9_+.\-]{1,39}$") """Callable :class:`Pattern` for a text-encoding name (utf-8, latin-1, etc.).""" diff --git a/edify/library/media/extension.py b/edify/library/media/extension.py index 00a74b2..5ecd564 100644 --- a/edify/library/media/extension.py +++ b/edify/library/media/extension.py @@ -1,5 +1,8 @@ """``extension`` — file extension shape (``.ext``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + extension = RegexBackedPattern(r"^\.[a-zA-Z0-9]{1,10}$") """Callable :class:`Pattern` for a file extension: dot + 1-10 alphanumeric.""" diff --git a/edify/library/media/favicon.py b/edify/library/media/favicon.py index 1a9a308..f032398 100644 --- a/edify/library/media/favicon.py +++ b/edify/library/media/favicon.py @@ -1,5 +1,8 @@ """``favicon`` — favicon filename/URL shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + favicon = RegexBackedPattern(r"^(?:[^\x00-\x1f/\\]+/)*favicon\.(?:ico|png|svg|gif)$") """Callable :class:`Pattern` for a favicon file name or URL path.""" diff --git a/edify/library/media/filename.py b/edify/library/media/filename.py index ccf230b..3fdff61 100644 --- a/edify/library/media/filename.py +++ b/edify/library/media/filename.py @@ -1,5 +1,8 @@ """``filename`` — file name shape (basename with extension).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + filename = RegexBackedPattern(r"^[^\x00-\x1f/\\:*?\"<>|]+\.[a-zA-Z0-9]{1,10}$") """Callable :class:`Pattern` for a valid file name with extension.""" diff --git a/edify/library/media/glob.py b/edify/library/media/glob.py index ea7304b..2bbfae9 100644 --- a/edify/library/media/glob.py +++ b/edify/library/media/glob.py @@ -1,5 +1,8 @@ """``glob`` — Unix glob-pattern shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + glob = RegexBackedPattern(r"^[^\x00-\x1f]*[*?[\]][^\x00-\x1f]*$") """Callable :class:`Pattern` for a Unix glob (must contain at least one wildcard).""" diff --git a/edify/library/media/locale.py b/edify/library/media/locale.py index 280fb0b..8f5e401 100644 --- a/edify/library/media/locale.py +++ b/edify/library/media/locale.py @@ -1,5 +1,8 @@ """``locale`` — POSIX/BCP-47 locale-tag shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + locale = RegexBackedPattern(r"^[a-z]{2,3}(?:[_-][A-Z]{2})?(?:\.[a-zA-Z0-9-]+)?(?:@[a-zA-Z0-9]+)?$") """Callable :class:`Pattern` for a POSIX/BCP-47 locale tag (``en``, ``en_US``, ``en-US.UTF-8``).""" diff --git a/edify/library/media/mimetype.py b/edify/library/media/mimetype.py index daa6ca5..65c54e6 100644 --- a/edify/library/media/mimetype.py +++ b/edify/library/media/mimetype.py @@ -1,5 +1,8 @@ """``mimetype`` — RFC 6838 MIME type shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + mimetype = RegexBackedPattern(r"^[a-zA-Z][a-zA-Z0-9!#$&\-^_.+]*/[a-zA-Z][a-zA-Z0-9!#$&\-^_.+]*$") """Callable :class:`Pattern` for the ``type/subtype`` MIME shape.""" diff --git a/edify/library/media/regex.py b/edify/library/media/regex.py index 7282f06..25f5d75 100644 --- a/edify/library/media/regex.py +++ b/edify/library/media/regex.py @@ -1,8 +1,12 @@ """``regex`` — pattern that itself compiles as a valid regex.""" + from __future__ import annotations + import re + from edify.pattern.composition import Pattern + class _RegexPattern(Pattern): def __call__(self, value: str) -> bool: # type: ignore[override] if not isinstance(value, str): @@ -13,6 +17,7 @@ class _RegexPattern(Pattern): return False return True + regex = _RegexPattern() """Callable :class:`Pattern` that returns True iff ``value`` compiles as a valid Python regular expression. diff --git a/edify/library/media/shebang.py b/edify/library/media/shebang.py index 2bc31bd..83f6ce9 100644 --- a/edify/library/media/shebang.py +++ b/edify/library/media/shebang.py @@ -1,5 +1,8 @@ """``shebang`` — script shebang line shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + shebang = RegexBackedPattern(r"^#!/(?:usr/)?(?:bin|sbin|local)/(?:env\s+)?[a-zA-Z0-9._+/-]+$") """Callable :class:`Pattern` for a shebang line at the top of a script.""" diff --git a/edify/library/medical/__init__.py b/edify/library/medical/__init__.py index 914507f..55f816e 100644 --- a/edify/library/medical/__init__.py +++ b/edify/library/medical/__init__.py @@ -1,2 +1,3 @@ from edify.library.medical.medical import medical + __all__ = ["medical"] diff --git a/edify/library/medical/medical.py b/edify/library/medical/medical.py index 67840f1..ef5407f 100644 --- a/edify/library/medical/medical.py +++ b/edify/library/medical/medical.py @@ -1,6 +1,9 @@ """``medical`` — medical-coding-system code shape (SNOMED, ICD, NPI, RxNorm, LOINC).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + medical = RegexBackedPattern( r"^(?:" r"\d{6,18}" diff --git a/edify/library/numeric/__init__.py b/edify/library/numeric/__init__.py index 8a98ba1..1a327ba 100644 --- a/edify/library/numeric/__init__.py +++ b/edify/library/numeric/__init__.py @@ -9,6 +9,13 @@ from edify.library.numeric.roman import roman from edify.library.numeric.scientific import scientific __all__ = [ - "fraction", "hash", "integer", "number", "ordinal", "percentage", - "ratio", "roman", "scientific", + "fraction", + "hash", + "integer", + "number", + "ordinal", + "percentage", + "ratio", + "roman", + "scientific", ] diff --git a/edify/library/numeric/hash.py b/edify/library/numeric/hash.py index 8c9fb04..1acfcd7 100644 --- a/edify/library/numeric/hash.py +++ b/edify/library/numeric/hash.py @@ -5,6 +5,6 @@ from __future__ import annotations from edify.library._support.regex import RegexBackedPattern hash = RegexBackedPattern(r"^[a-fA-F0-9]{8,128}$") -"""Callable :class:`Pattern` for a hex-hash digest (8–128 hex characters, +"""Callable :class:`Pattern` for a hex-hash digest (8-128 hex characters, covering CRC-32 through SHA-512). """ diff --git a/edify/library/numeric/number.py b/edify/library/numeric/number.py index 98f88a8..03c6a45 100644 --- a/edify/library/numeric/number.py +++ b/edify/library/numeric/number.py @@ -1,4 +1,4 @@ -"""``number`` — number in any base or form (integer, decimal, hex, binary, octal, scientific, complex).""" +"""``number`` — number in any base or common form.""" from __future__ import annotations diff --git a/edify/library/numeric/roman.py b/edify/library/numeric/roman.py index bbce5c5..2abad73 100644 --- a/edify/library/numeric/roman.py +++ b/edify/library/numeric/roman.py @@ -1,10 +1,8 @@ -"""``roman`` — Roman-numeral shape (1–3999).""" +"""``roman`` — Roman-numeral shape (1-3999).""" from __future__ import annotations from edify.library._support.regex import RegexBackedPattern -roman = RegexBackedPattern( - r"^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$" -) -"""Callable :class:`Pattern` for a Roman-numeral value 1–3999.""" +roman = RegexBackedPattern(r"^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$") +"""Callable :class:`Pattern` for a Roman-numeral value 1-3999.""" diff --git a/edify/library/product/__init__.py b/edify/library/product/__init__.py index 79bcdce..b708ac7 100644 --- a/edify/library/product/__init__.py +++ b/edify/library/product/__init__.py @@ -1,4 +1,5 @@ from edify.library.product.barcode import barcode from edify.library.product.gtin import gtin from edify.library.product.mpn import mpn + __all__ = ["barcode", "gtin", "mpn"] diff --git a/edify/library/product/barcode.py b/edify/library/product/barcode.py index 9526075..5502943 100644 --- a/edify/library/product/barcode.py +++ b/edify/library/product/barcode.py @@ -1,5 +1,8 @@ """``barcode`` — generic barcode value shape (numeric or alphanumeric).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + barcode = RegexBackedPattern(r"^[A-Z0-9]{6,48}$") """Callable :class:`Pattern` for a generic barcode value shape.""" diff --git a/edify/library/product/gtin.py b/edify/library/product/gtin.py index 9551330..deceb6a 100644 --- a/edify/library/product/gtin.py +++ b/edify/library/product/gtin.py @@ -1,5 +1,8 @@ """``gtin`` — GTIN barcode number (8/12/13/14 digits, includes UPC and EAN).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + gtin = RegexBackedPattern(r"^\d{8}$|^\d{12}$|^\d{13}$|^\d{14}$") """Callable :class:`Pattern` for the GTIN family: 8-, 12-, 13-, or 14-digit barcode number.""" diff --git a/edify/library/product/mpn.py b/edify/library/product/mpn.py index e6ec73a..cfe42ac 100644 --- a/edify/library/product/mpn.py +++ b/edify/library/product/mpn.py @@ -1,5 +1,8 @@ """``mpn`` — Manufacturer Part Number (permissive alphanumeric).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + mpn = RegexBackedPattern(r"^[A-Z0-9][A-Z0-9\-_.]{1,63}$") """Callable :class:`Pattern` for a permissive Manufacturer Part Number.""" diff --git a/edify/library/publishing/__init__.py b/edify/library/publishing/__init__.py index 2a72746..18bfa10 100644 --- a/edify/library/publishing/__init__.py +++ b/edify/library/publishing/__init__.py @@ -4,4 +4,5 @@ from edify.library.publishing.isbn import isbn from edify.library.publishing.issn import issn from edify.library.publishing.pmc import pmc from edify.library.publishing.pmid import pmid + __all__ = ["arxiv", "doi", "isbn", "issn", "pmc", "pmid"] diff --git a/edify/library/publishing/arxiv.py b/edify/library/publishing/arxiv.py index 53bd772..481479a 100644 --- a/edify/library/publishing/arxiv.py +++ b/edify/library/publishing/arxiv.py @@ -1,6 +1,9 @@ """``arxiv`` — arXiv identifier shape (new format ``YYMM.NNNNN`` or legacy ``category/YYMMNNN``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + arxiv = RegexBackedPattern( r"^(?:\d{4}\.\d{4,5}(?:v\d+)?|[a-z]{2,10}(?:\.[A-Z]{2})?/\d{7}(?:v\d+)?)$" ) diff --git a/edify/library/publishing/doi.py b/edify/library/publishing/doi.py index a35f1d7..ce7c34e 100644 --- a/edify/library/publishing/doi.py +++ b/edify/library/publishing/doi.py @@ -1,5 +1,8 @@ """``doi`` — DOI shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + doi = RegexBackedPattern(r"^10\.\d{4,9}/[-._;()/:A-Za-z0-9]+$") """Callable :class:`Pattern` for the DOI shape.""" diff --git a/edify/library/publishing/isbn.py b/edify/library/publishing/isbn.py index aa15470..379c9a8 100644 --- a/edify/library/publishing/isbn.py +++ b/edify/library/publishing/isbn.py @@ -1,5 +1,8 @@ """``isbn`` — ISBN-10 or ISBN-13 shape (with or without dashes).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + isbn = RegexBackedPattern(r"^(?:\d[- ]?){9}[\dXx]$|^(?:\d[- ]?){12}\d$") -"""Callable :class:`Pattern` for ISBN-10 or ISBN-13 shape (with or without dash/space separators).""" +"""Callable :class:`Pattern` for ISBN-10 or ISBN-13 shape.""" diff --git a/edify/library/publishing/issn.py b/edify/library/publishing/issn.py index 72b22f1..53216d7 100644 --- a/edify/library/publishing/issn.py +++ b/edify/library/publishing/issn.py @@ -1,5 +1,8 @@ """``issn`` — ISSN shape (``NNNN-NNNC``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + issn = RegexBackedPattern(r"^\d{4}-\d{3}[\dXx]$") """Callable :class:`Pattern` for the ISSN shape.""" diff --git a/edify/library/publishing/pmc.py b/edify/library/publishing/pmc.py index c8e0d30..dc97b0b 100644 --- a/edify/library/publishing/pmc.py +++ b/edify/library/publishing/pmc.py @@ -1,5 +1,8 @@ """``pmc`` — PMC identifier shape (``PMCnnnnn...``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + pmc = RegexBackedPattern(r"^PMC\d{1,9}$") """Callable :class:`Pattern` for a PubMed Central identifier.""" diff --git a/edify/library/publishing/pmid.py b/edify/library/publishing/pmid.py index 229f2f0..968ad9a 100644 --- a/edify/library/publishing/pmid.py +++ b/edify/library/publishing/pmid.py @@ -1,5 +1,8 @@ """``pmid`` — PubMed identifier shape (1-8 digits).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + pmid = RegexBackedPattern(r"^\d{1,8}$") """Callable :class:`Pattern` for a PubMed identifier (1-8 digits).""" diff --git a/edify/library/security/__init__.py b/edify/library/security/__init__.py index 9fea6a0..f0334f2 100644 --- a/edify/library/security/__init__.py +++ b/edify/library/security/__init__.py @@ -7,6 +7,15 @@ from edify.library.security.pem import pem from edify.library.security.pgp import pgp from edify.library.security.ssh import ssh from edify.library.security.x509 import x509 + __all__ = [ - "age", "certificate", "csr", "der", "keyring", "pem", "pgp", "ssh", "x509", + "age", + "certificate", + "csr", + "der", + "keyring", + "pem", + "pgp", + "ssh", + "x509", ] diff --git a/edify/library/security/age.py b/edify/library/security/age.py index 9945e9a..39ec2ea 100644 --- a/edify/library/security/age.py +++ b/edify/library/security/age.py @@ -1,5 +1,8 @@ """``age`` — age cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + age = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for age cryptographic-artifact identifier or payload.""" diff --git a/edify/library/security/certificate.py b/edify/library/security/certificate.py index c37aa3d..171cf40 100644 --- a/edify/library/security/certificate.py +++ b/edify/library/security/certificate.py @@ -1,5 +1,8 @@ """``certificate`` — certificate cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + certificate = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for certificate cryptographic-artifact identifier or payload.""" diff --git a/edify/library/security/csr.py b/edify/library/security/csr.py index 055a461..6bacb42 100644 --- a/edify/library/security/csr.py +++ b/edify/library/security/csr.py @@ -1,5 +1,8 @@ """``csr`` — csr cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + csr = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for csr cryptographic-artifact identifier or payload.""" diff --git a/edify/library/security/der.py b/edify/library/security/der.py index 97c727a..3cd2e3e 100644 --- a/edify/library/security/der.py +++ b/edify/library/security/der.py @@ -1,5 +1,8 @@ """``der`` — der cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + der = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for der cryptographic-artifact identifier or payload.""" diff --git a/edify/library/security/keyring.py b/edify/library/security/keyring.py index fd58b13..2442189 100644 --- a/edify/library/security/keyring.py +++ b/edify/library/security/keyring.py @@ -1,5 +1,8 @@ """``keyring`` — keyring cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + keyring = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for keyring cryptographic-artifact identifier or payload.""" diff --git a/edify/library/security/pem.py b/edify/library/security/pem.py index b387d6d..fd63352 100644 --- a/edify/library/security/pem.py +++ b/edify/library/security/pem.py @@ -1,5 +1,8 @@ """``pem`` — pem cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + pem = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for pem cryptographic-artifact identifier or payload.""" diff --git a/edify/library/security/pgp.py b/edify/library/security/pgp.py index eb28dd5..bc6dadd 100644 --- a/edify/library/security/pgp.py +++ b/edify/library/security/pgp.py @@ -1,5 +1,8 @@ """``pgp`` — pgp cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + pgp = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for pgp cryptographic-artifact identifier or payload.""" diff --git a/edify/library/security/ssh.py b/edify/library/security/ssh.py index 10697dc..be3c415 100644 --- a/edify/library/security/ssh.py +++ b/edify/library/security/ssh.py @@ -1,5 +1,8 @@ """``ssh`` — ssh cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + ssh = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for ssh cryptographic-artifact identifier or payload.""" diff --git a/edify/library/security/x509.py b/edify/library/security/x509.py index 5533734..e7aac16 100644 --- a/edify/library/security/x509.py +++ b/edify/library/security/x509.py @@ -1,5 +1,8 @@ """``x509`` — x509 cryptography artifact shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + x509 = RegexBackedPattern(r"^[A-Za-z0-9+/=_\-.:\s]{16,4096}$") """Callable :class:`Pattern` for x509 cryptographic-artifact identifier or payload.""" diff --git a/edify/library/software/__init__.py b/edify/library/software/__init__.py index 7369092..aea11f3 100644 --- a/edify/library/software/__init__.py +++ b/edify/library/software/__init__.py @@ -10,7 +10,18 @@ from edify.library.software.package import package from edify.library.software.ref import ref from edify.library.software.semver import semver from edify.library.software.version import version + __all__ = [ - "cargo", "checksum", "component", "digest", "docker", "git", - "image", "makefile", "package", "ref", "semver", "version", + "cargo", + "checksum", + "component", + "digest", + "docker", + "git", + "image", + "makefile", + "package", + "ref", + "semver", + "version", ] diff --git a/edify/library/software/cargo.py b/edify/library/software/cargo.py index d3e3bb6..ebaa269 100644 --- a/edify/library/software/cargo.py +++ b/edify/library/software/cargo.py @@ -1,5 +1,10 @@ """``cargo`` — Rust Cargo crate identifier shape (``name`` or ``name@version``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern -cargo = RegexBackedPattern(r"^[a-zA-Z][a-zA-Z0-9_-]{0,63}(?:@\d+(?:\.\d+){0,3}(?:[-.+][a-zA-Z0-9.\-]+)?)?$") + +cargo = RegexBackedPattern( + r"^[a-zA-Z][a-zA-Z0-9_-]{0,63}(?:@\d+(?:\.\d+){0,3}(?:[-.+][a-zA-Z0-9.\-]+)?)?$" +) """Callable :class:`Pattern` for a Cargo crate identifier.""" diff --git a/edify/library/software/checksum.py b/edify/library/software/checksum.py index f6d7de1..ed0cfad 100644 --- a/edify/library/software/checksum.py +++ b/edify/library/software/checksum.py @@ -1,5 +1,8 @@ """``checksum`` — hex checksum shape (CRC through SHA).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + checksum = RegexBackedPattern(r"^[a-fA-F0-9]{8,128}$") """Callable :class:`Pattern` for a hex checksum (any common hash width).""" diff --git a/edify/library/software/component.py b/edify/library/software/component.py index c7e9f2d..e1227b9 100644 --- a/edify/library/software/component.py +++ b/edify/library/software/component.py @@ -1,6 +1,9 @@ """``component`` — versioned software-component identifier (``name@version``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + component = RegexBackedPattern( r"^(?:@[a-z0-9][a-z0-9-]*/)?[a-z0-9][a-z0-9._-]{0,213}" r"@\d+(?:\.\d+){0,3}(?:[-.+][a-zA-Z0-9.\-]+)?$" diff --git a/edify/library/software/digest.py b/edify/library/software/digest.py index 069b062..66c895f 100644 --- a/edify/library/software/digest.py +++ b/edify/library/software/digest.py @@ -1,5 +1,8 @@ """``digest`` — content-addressable digest shape (``algorithm:hex``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + digest = RegexBackedPattern(r"^(?:sha256|sha512|sha1|md5|blake2[bs]?)(?::|-)[a-fA-F0-9]{32,128}$") """Callable :class:`Pattern` for a content-addressable digest.""" diff --git a/edify/library/software/docker.py b/edify/library/software/docker.py index b5fb17d..2b9d6f3 100644 --- a/edify/library/software/docker.py +++ b/edify/library/software/docker.py @@ -1,6 +1,9 @@ """``docker`` — Docker image reference shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + docker = RegexBackedPattern( r"^(?:(?:[a-z0-9.\-]+(?::\d+)?/)?[a-z0-9]+(?:[._\-][a-z0-9]+)*)" r"(?:/[a-z0-9]+(?:[._\-][a-z0-9]+)*)*" diff --git a/edify/library/software/git.py b/edify/library/software/git.py index ca48e12..17d75d3 100644 --- a/edify/library/software/git.py +++ b/edify/library/software/git.py @@ -1,5 +1,8 @@ """``git`` — 40-character git SHA-1 hash shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + git = RegexBackedPattern(r"^[a-f0-9]{7,40}$") """Callable :class:`Pattern` for a git commit SHA (7-40 hex characters).""" diff --git a/edify/library/software/image.py b/edify/library/software/image.py index 66b139e..7708774 100644 --- a/edify/library/software/image.py +++ b/edify/library/software/image.py @@ -1,6 +1,9 @@ """``image`` — container-image reference (alias-friendly wrapper around docker).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + image = RegexBackedPattern( r"^(?:(?:[a-z0-9.\-]+(?::\d+)?/)?[a-z0-9]+(?:[._\-][a-z0-9]+)*)" r"(?:/[a-z0-9]+(?:[._\-][a-z0-9]+)*)*" diff --git a/edify/library/software/makefile.py b/edify/library/software/makefile.py index 61d39f4..20e8e06 100644 --- a/edify/library/software/makefile.py +++ b/edify/library/software/makefile.py @@ -1,5 +1,8 @@ """``makefile`` — Makefile-target line shape (``target: [deps]``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + makefile = RegexBackedPattern(r"^\.?[a-zA-Z][a-zA-Z0-9._-]*(?:\s+[a-zA-Z][a-zA-Z0-9._-]*)*\s*:.*$") """Callable :class:`Pattern` for a Makefile-target declaration line.""" diff --git a/edify/library/software/package.py b/edify/library/software/package.py index 3ce0f5a..002688a 100644 --- a/edify/library/software/package.py +++ b/edify/library/software/package.py @@ -1,7 +1,8 @@ """``package`` — package identifier shape (``@scope/name`` or ``name``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern -package = RegexBackedPattern( - r"^(?:@[a-z0-9][a-z0-9-]*/)?[a-z0-9][a-z0-9._-]{0,213}$" -) + +package = RegexBackedPattern(r"^(?:@[a-z0-9][a-z0-9-]*/)?[a-z0-9][a-z0-9._-]{0,213}$") """Callable :class:`Pattern` for an npm/pypi-style package identifier.""" diff --git a/edify/library/software/ref.py b/edify/library/software/ref.py index 64d4e6a..7a78148 100644 --- a/edify/library/software/ref.py +++ b/edify/library/software/ref.py @@ -1,6 +1,9 @@ """``ref`` — git ref shape (branch, tag, or SHA).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + ref = RegexBackedPattern( r"^(?:" r"[a-f0-9]{7,40}" diff --git a/edify/library/software/semver.py b/edify/library/software/semver.py index f8c9e6f..560c984 100644 --- a/edify/library/software/semver.py +++ b/edify/library/software/semver.py @@ -1,6 +1,9 @@ """``semver`` — SemVer 2.0.0 version shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + semver = RegexBackedPattern( r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)" r"(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)" diff --git a/edify/library/software/version.py b/edify/library/software/version.py index 4a9cc95..59ac6be 100644 --- a/edify/library/software/version.py +++ b/edify/library/software/version.py @@ -1,5 +1,8 @@ """``version`` — permissive version-string shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + version = RegexBackedPattern(r"^v?\d+(?:\.\d+){0,3}(?:[-.+][a-zA-Z0-9.\-]+)?$") """Callable :class:`Pattern` for a permissive dotted version string.""" diff --git a/edify/library/temporal/__init__.py b/edify/library/temporal/__init__.py index f054dc7..6fb6c54 100644 --- a/edify/library/temporal/__init__.py +++ b/edify/library/temporal/__init__.py @@ -11,6 +11,15 @@ from edify.library.temporal.timezone import timezone from edify.library.temporal.year import year __all__ = [ - "cron", "date", "datetime", "duration", "epoch", "interval", "offset", - "time", "timestamp", "timezone", "year", + "cron", + "date", + "datetime", + "duration", + "epoch", + "interval", + "offset", + "time", + "timestamp", + "timezone", + "year", ] diff --git a/edify/library/temporal/epoch.py b/edify/library/temporal/epoch.py index c113f59..859dc01 100644 --- a/edify/library/temporal/epoch.py +++ b/edify/library/temporal/epoch.py @@ -6,5 +6,5 @@ from edify.library._support.regex import RegexBackedPattern epoch = RegexBackedPattern(r"^-?\d{1,10}$") """Callable :class:`Pattern` for a Unix epoch-seconds value: optional sign -followed by 1–10 digits (fits in a 32-bit signed integer). +followed by 1-10 digits (fits in a 32-bit signed integer). """ diff --git a/edify/library/temporal/timestamp.py b/edify/library/temporal/timestamp.py index 3a21c26..8be8d7a 100644 --- a/edify/library/temporal/timestamp.py +++ b/edify/library/temporal/timestamp.py @@ -6,5 +6,5 @@ from edify.library._support.regex import RegexBackedPattern timestamp = RegexBackedPattern(r"^-?\d{10,13}$") """Callable :class:`Pattern` for a Unix epoch timestamp in seconds or -milliseconds: optional sign followed by 10–13 digits. +milliseconds: optional sign followed by 10-13 digits. """ diff --git a/edify/library/temporal/year.py b/edify/library/temporal/year.py index f73b240..7beb2e2 100644 --- a/edify/library/temporal/year.py +++ b/edify/library/temporal/year.py @@ -4,10 +4,5 @@ from __future__ import annotations from edify import Pattern -year = ( - Pattern() - .start_of_input() - .exactly(4).digit() - .end_of_input() -) +year = Pattern().start_of_input().exactly(4).digit().end_of_input() """Callable :class:`Pattern` for the 4-digit calendar-year shape.""" diff --git a/edify/library/text/__init__.py b/edify/library/text/__init__.py index aeb116b..fdd1ac3 100644 --- a/edify/library/text/__init__.py +++ b/edify/library/text/__init__.py @@ -11,6 +11,15 @@ from edify.library.text.unicode import unicode from edify.library.text.word import word __all__ = [ - "alpha", "alphanumeric", "ascii", "base", "emoji", "numeric", - "printable", "script", "slug", "unicode", "word", + "alpha", + "alphanumeric", + "ascii", + "base", + "emoji", + "numeric", + "printable", + "script", + "slug", + "unicode", + "word", ] diff --git a/edify/library/text/ascii.py b/edify/library/text/ascii.py index da92912..700963d 100644 --- a/edify/library/text/ascii.py +++ b/edify/library/text/ascii.py @@ -6,5 +6,5 @@ from edify.library._support.regex import RegexBackedPattern ascii = RegexBackedPattern(r"^[\x20-\x7E]+$") """Callable :class:`Pattern` for a printable-ASCII-only string -(characters ``0x20``–``0x7E``). +(characters ``0x20``-``0x7E``). """ diff --git a/edify/library/text/emoji.py b/edify/library/text/emoji.py index a076cc8..7f55330 100644 --- a/edify/library/text/emoji.py +++ b/edify/library/text/emoji.py @@ -4,7 +4,5 @@ from __future__ import annotations from edify.library._support.regex import RegexBackedPattern -emoji = RegexBackedPattern( - r"^[\U0001F300-\U0001FAFF☀-➿]+$" -) +emoji = RegexBackedPattern(r"^[\U0001F300-\U0001FAFF☀-➿]+$") """Callable :class:`Pattern` for a run of one or more emoji characters.""" diff --git a/edify/library/text/script.py b/edify/library/text/script.py index 0c720e2..0a5e1fd 100644 --- a/edify/library/text/script.py +++ b/edify/library/text/script.py @@ -1,4 +1,4 @@ -"""``script`` — text in a specific Unicode script (Latin/Cyrillic/Greek/CJK/etc.).""" +"""``script`` — text in a specific Unicode script.""" from __future__ import annotations @@ -9,7 +9,7 @@ script = RegexBackedPattern( r"[A-Za-zÀ-ɏ]+" r"|[Ѐ-ӿ]+" r"|[Ͱ-Ͽ]+" - r"|[一-鿿-ゟ゠-ヿ가-]+" + r"|[一-鿿-ゟ゠-ヿ가-]+" # noqa: RUF001 r"|[-ۿ]+" r"|[-]+" r"|[ऀ-ॿ]+" diff --git a/edify/library/transport/__init__.py b/edify/library/transport/__init__.py index 5786e46..0cbd39e 100644 --- a/edify/library/transport/__init__.py +++ b/edify/library/transport/__init__.py @@ -1,3 +1,4 @@ from edify.library.transport.aircraft import aircraft from edify.library.transport.vehicle import vehicle + __all__ = ["aircraft", "vehicle"] diff --git a/edify/library/transport/aircraft.py b/edify/library/transport/aircraft.py index 93247bb..86ff2cd 100644 --- a/edify/library/transport/aircraft.py +++ b/edify/library/transport/aircraft.py @@ -1,5 +1,8 @@ """``aircraft`` — aircraft-registration shape (e.g. ``N123AB``, ``G-ABCD``).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + aircraft = RegexBackedPattern(r"^[A-Z]{1,2}-?[A-Z0-9]{1,5}$") """Callable :class:`Pattern` for an aircraft-registration mark.""" diff --git a/edify/library/transport/vehicle.py b/edify/library/transport/vehicle.py index bce70bd..7fc3c0c 100644 --- a/edify/library/transport/vehicle.py +++ b/edify/library/transport/vehicle.py @@ -1,5 +1,8 @@ """``vehicle`` — vehicle/vessel/container identifier shape (permissive alphanumeric).""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + vehicle = RegexBackedPattern(r"^[A-Z0-9][A-Z0-9\- ]{3,17}$") """Callable :class:`Pattern` for a permissive transport-vehicle identifier.""" diff --git a/edify/library/web/__init__.py b/edify/library/web/__init__.py index c274a81..32e29a2 100644 --- a/edify/library/web/__init__.py +++ b/edify/library/web/__init__.py @@ -6,7 +6,14 @@ from edify.library.web.manifest import manifest from edify.library.web.nginx import nginx from edify.library.web.robots import robots from edify.library.web.sitemap import sitemap + __all__ = [ - "apache", "captcha", "htaccess", "humans", "manifest", "nginx", - "robots", "sitemap", + "apache", + "captcha", + "htaccess", + "humans", + "manifest", + "nginx", + "robots", + "sitemap", ] diff --git a/edify/library/web/apache.py b/edify/library/web/apache.py index 3dc3120..3521fc4 100644 --- a/edify/library/web/apache.py +++ b/edify/library/web/apache.py @@ -1,5 +1,8 @@ """``apache`` — apache web-artifact identifier/URL/content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + apache = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+=?&#:%~]{2,4096}$") """Callable :class:`Pattern` for apache web-artifact identifier or content marker.""" diff --git a/edify/library/web/captcha.py b/edify/library/web/captcha.py index d62cf64..92e6300 100644 --- a/edify/library/web/captcha.py +++ b/edify/library/web/captcha.py @@ -1,5 +1,8 @@ """``captcha`` — captcha web-artifact identifier/URL/content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + captcha = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+=?&#:%~]{2,4096}$") """Callable :class:`Pattern` for captcha web-artifact identifier or content marker.""" diff --git a/edify/library/web/htaccess.py b/edify/library/web/htaccess.py index a7411bb..7630236 100644 --- a/edify/library/web/htaccess.py +++ b/edify/library/web/htaccess.py @@ -1,5 +1,8 @@ """``htaccess`` — htaccess web-artifact identifier/URL/content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + htaccess = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+=?&#:%~]{2,4096}$") """Callable :class:`Pattern` for htaccess web-artifact identifier or content marker.""" diff --git a/edify/library/web/humans.py b/edify/library/web/humans.py index 8e11817..5cb305f 100644 --- a/edify/library/web/humans.py +++ b/edify/library/web/humans.py @@ -1,5 +1,8 @@ """``humans`` — humans web-artifact identifier/URL/content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + humans = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+=?&#:%~]{2,4096}$") """Callable :class:`Pattern` for humans web-artifact identifier or content marker.""" diff --git a/edify/library/web/manifest.py b/edify/library/web/manifest.py index 441671b..f48be61 100644 --- a/edify/library/web/manifest.py +++ b/edify/library/web/manifest.py @@ -1,5 +1,8 @@ """``manifest`` — manifest web-artifact identifier/URL/content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + manifest = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+=?&#:%~]{2,4096}$") """Callable :class:`Pattern` for manifest web-artifact identifier or content marker.""" diff --git a/edify/library/web/nginx.py b/edify/library/web/nginx.py index b36df40..d22420d 100644 --- a/edify/library/web/nginx.py +++ b/edify/library/web/nginx.py @@ -1,5 +1,8 @@ """``nginx`` — nginx web-artifact identifier/URL/content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + nginx = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+=?&#:%~]{2,4096}$") """Callable :class:`Pattern` for nginx web-artifact identifier or content marker.""" diff --git a/edify/library/web/robots.py b/edify/library/web/robots.py index b6081d0..322b05e 100644 --- a/edify/library/web/robots.py +++ b/edify/library/web/robots.py @@ -1,5 +1,8 @@ """``robots`` — robots web-artifact identifier/URL/content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + robots = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+=?&#:%~]{2,4096}$") """Callable :class:`Pattern` for robots web-artifact identifier or content marker.""" diff --git a/edify/library/web/sitemap.py b/edify/library/web/sitemap.py index d5fa78b..cbc5335 100644 --- a/edify/library/web/sitemap.py +++ b/edify/library/web/sitemap.py @@ -1,5 +1,8 @@ """``sitemap`` — sitemap web-artifact identifier/URL/content shape.""" + from __future__ import annotations + from edify.library._support.regex import RegexBackedPattern + sitemap = RegexBackedPattern(r"^[A-Za-z0-9_.\-/+=?&#:%~]{2,4096}$") """Callable :class:`Pattern` for sitemap web-artifact identifier or content marker.""" diff --git a/tests/library/ip.test.py b/tests/library/ip.test.py index b288004..2028024 100644 --- a/tests/library/ip.test.py +++ b/tests/library/ip.test.py @@ -1,10 +1,13 @@ from edify.library import ip + def test_valid_ipv4(): assert ip("192.168.1.1") + def test_valid_ipv6(): assert ip("2001:db8::1") + def test_bad_ip(): assert not ip("999.999.999.999") diff --git a/tests/library/phone.test.py b/tests/library/phone.test.py index 53167c0..0076065 100644 --- a/tests/library/phone.test.py +++ b/tests/library/phone.test.py @@ -1,10 +1,13 @@ from edify.library import phone + def test_valid_phone(): assert phone("+1-555-1234") + def test_short_phone(): assert phone("911") + def test_bad_phone(): assert not phone("!!!") diff --git a/tests/library/postal.test.py b/tests/library/postal.test.py index 5527ac6..f4b3dc3 100644 --- a/tests/library/postal.test.py +++ b/tests/library/postal.test.py @@ -1,7 +1,9 @@ from edify.library import postal + def test_valid_postal(): assert postal("12345") + def test_bad_postal(): assert not postal("nope-!!!") diff --git a/tests/library/url.test.py b/tests/library/url.test.py index 50bad29..d4b2eeb 100644 --- a/tests/library/url.test.py +++ b/tests/library/url.test.py @@ -1,10 +1,13 @@ from edify.library import url + def test_valid_http_url(): assert url("http://example.com") + def test_valid_https_url(): assert url("https://example.com/path") + def test_bad_url(): assert not url("nope !!!") |
