|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +import os |
| 4 | + |
| 5 | +_USE_RUST = os.environ.get("BIKESHED_USE_RUST", "").lower() in ("1", "true") |
| 6 | + |
| 7 | +if _USE_RUST: |
| 8 | + try: |
| 9 | + import bikeshed_rust |
| 10 | + from . import preds as _preds |
| 11 | + |
| 12 | + isASCII = bikeshed_rust.is_ascii |
| 13 | + isASCIIAlpha = bikeshed_rust.is_ascii_alpha |
| 14 | + isASCIIAlphanum = bikeshed_rust.is_ascii_alphanum |
| 15 | + isASCIILowerAlpha = bikeshed_rust.is_ascii_lower_alpha |
| 16 | + isASCIIUpperAlpha = bikeshed_rust.is_ascii_upper_alpha |
| 17 | + isAttrNameChar = bikeshed_rust.is_attr_name_char |
| 18 | + isControl = bikeshed_rust.is_control |
| 19 | + isDigit = bikeshed_rust.is_digit |
| 20 | + isHexDigit = bikeshed_rust.is_hex_digit |
| 21 | + isNoncharacter = bikeshed_rust.is_noncharacter |
| 22 | + isTagnameChar = bikeshed_rust.is_tagname_char |
| 23 | + isWhitespace = bikeshed_rust.is_whitespace |
| 24 | + |
| 25 | + charRefs = _preds.charRefs |
| 26 | + xmlishTagnames = _preds.xmlishTagnames |
| 27 | + isXMLishTagname = _preds.isXMLishTagname |
| 28 | + except ImportError: |
| 29 | + from . import preds as _preds |
| 30 | + |
| 31 | + charRefs = _preds.charRefs |
| 32 | + xmlishTagnames = _preds.xmlishTagnames |
| 33 | + isASCII = _preds.isASCII |
| 34 | + isASCIIAlpha = _preds.isASCIIAlpha |
| 35 | + isASCIIAlphanum = _preds.isASCIIAlphanum |
| 36 | + isASCIILowerAlpha = _preds.isASCIILowerAlpha |
| 37 | + isASCIIUpperAlpha = _preds.isASCIIUpperAlpha |
| 38 | + isAttrNameChar = _preds.isAttrNameChar |
| 39 | + isControl = _preds.isControl |
| 40 | + isDigit = _preds.isDigit |
| 41 | + isHexDigit = _preds.isHexDigit |
| 42 | + isNoncharacter = _preds.isNoncharacter |
| 43 | + isTagnameChar = _preds.isTagnameChar |
| 44 | + isWhitespace = _preds.isWhitespace |
| 45 | + isXMLishTagname = _preds.isXMLishTagname |
| 46 | + |
| 47 | +else: |
| 48 | + from . import preds as _preds |
| 49 | + |
| 50 | + charRefs = _preds.charRefs |
| 51 | + xmlishTagnames = _preds.xmlishTagnames |
| 52 | + isASCII = _preds.isASCII |
| 53 | + isASCIIAlpha = _preds.isASCIIAlpha |
| 54 | + isASCIIAlphanum = _preds.isASCIIAlphanum |
| 55 | + isASCIILowerAlpha = _preds.isASCIILowerAlpha |
| 56 | + isASCIIUpperAlpha = _preds.isASCIIUpperAlpha |
| 57 | + isAttrNameChar = _preds.isAttrNameChar |
| 58 | + isControl = _preds.isControl |
| 59 | + isDigit = _preds.isDigit |
| 60 | + isHexDigit = _preds.isHexDigit |
| 61 | + isNoncharacter = _preds.isNoncharacter |
| 62 | + isTagnameChar = _preds.isTagnameChar |
| 63 | + isWhitespace = _preds.isWhitespace |
| 64 | + isXMLishTagname = _preds.isXMLishTagname |
| 65 | + |
| 66 | +__all__ = [ |
| 67 | + "charRefs", |
| 68 | + "xmlishTagnames", |
| 69 | + "isASCII", |
| 70 | + "isASCIIAlpha", |
| 71 | + "isASCIIAlphanum", |
| 72 | + "isASCIILowerAlpha", |
| 73 | + "isASCIIUpperAlpha", |
| 74 | + "isAttrNameChar", |
| 75 | + "isControl", |
| 76 | + "isDigit", |
| 77 | + "isHexDigit", |
| 78 | + "isNoncharacter", |
| 79 | + "isTagnameChar", |
| 80 | + "isWhitespace", |
| 81 | + "isXMLishTagname", |
| 82 | +] |
0 commit comments