diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2016-09-11 20:30:08 (GMT) |
---|---|---|
committer | Ethan Furman <ethan@stoneleaf.us> | 2016-09-11 20:30:08 (GMT) |
commit | f93395bc5125c99539597bf134ca8bcf9707655b (patch) | |
tree | 8d582dd293e52f1e8e8ef9616f3db8a8e0bb71d5 /Lib/re.py | |
parent | 06339e7493bc696b7b9213437ce0182048b37bab (diff) | |
download | cpython-f93395bc5125c99539597bf134ca8bcf9707655b.zip cpython-f93395bc5125c99539597bf134ca8bcf9707655b.tar.gz cpython-f93395bc5125c99539597bf134ca8bcf9707655b.tar.bz2 |
issue28082: use IntFlag for re constants
Diffstat (limited to 'Lib/re.py')
-rw-r--r-- | Lib/re.py | 33 |
1 files changed, 21 insertions, 12 deletions
@@ -119,6 +119,7 @@ This module also defines an exception 'error'. """ +import enum import sre_compile import sre_parse try: @@ -137,18 +138,26 @@ __all__ = [ __version__ = "2.2.1" -# flags -A = ASCII = sre_compile.SRE_FLAG_ASCII # assume ascii "locale" -I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case -L = LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale -U = UNICODE = sre_compile.SRE_FLAG_UNICODE # assume unicode "locale" -M = MULTILINE = sre_compile.SRE_FLAG_MULTILINE # make anchors look for newline -S = DOTALL = sre_compile.SRE_FLAG_DOTALL # make dot match newline -X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE # ignore whitespace and comments - -# sre extensions (experimental, don't rely on these) -T = TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE # disable backtracking -DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation +class Flag(enum.IntFlag): + ASCII = sre_compile.SRE_FLAG_ASCII # assume ascii "locale" + IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case + LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale + UNICODE = sre_compile.SRE_FLAG_UNICODE # assume unicode "locale" + MULTILINE = sre_compile.SRE_FLAG_MULTILINE # make anchors look for newline + DOTALL = sre_compile.SRE_FLAG_DOTALL # make dot match newline + VERBOSE = sre_compile.SRE_FLAG_VERBOSE # ignore whitespace and comments + A = ASCII + I = IGNORECASE + L = LOCALE + U = UNICODE + M = MULTILINE + S = DOTALL + X = VERBOSE + # sre extensions (experimental, don't rely on these) + TEMPLATE = sre_compile.SRE_FLAG_TEMPLATE # disable backtracking + T = TEMPLATE + DEBUG = sre_compile.SRE_FLAG_DEBUG # dump pattern after compilation +globals().update(Flag.__members__) # sre exception error = sre_compile.error |