|
18 | 18 | import unicodedata |
19 | 19 | from collections import defaultdict |
20 | 20 |
|
21 | | -import regex._regex as _regex |
| 21 | +from regex import _regex |
22 | 22 |
|
23 | 23 | __all__ = ["A", "ASCII", "B", "BESTMATCH", "D", "DEBUG", "E", "ENHANCEMATCH", |
24 | 24 | "F", "FULLCASE", "I", "IGNORECASE", "L", "LOCALE", "M", "MULTILINE", "P", |
@@ -121,7 +121,42 @@ def __repr__(self): |
121 | 121 |
|
122 | 122 | __str__ = object.__str__ |
123 | 123 |
|
124 | | -globals().update(RegexFlag.__members__) |
| 124 | +# Put the flags into the module namespace. Being explicit here helps tools like |
| 125 | +# linters and IDEs understand the code better. |
| 126 | +ASCII = RegexFlag.ASCII |
| 127 | +BESTMATCH = RegexFlag.BESTMATCH |
| 128 | +DEBUG = RegexFlag.DEBUG |
| 129 | +DOTALL = RegexFlag.DOTALL |
| 130 | +ENHANCEMATCH = RegexFlag.ENHANCEMATCH |
| 131 | +FULLCASE = RegexFlag.FULLCASE |
| 132 | +IGNORECASE = RegexFlag.IGNORECASE |
| 133 | +LOCALE = RegexFlag.LOCALE |
| 134 | +MULTILINE = RegexFlag.MULTILINE |
| 135 | +POSIX = RegexFlag.POSIX |
| 136 | +REVERSE = RegexFlag.REVERSE |
| 137 | +TEMPLATE = RegexFlag.TEMPLATE |
| 138 | +UNICODE = RegexFlag.UNICODE |
| 139 | +VERBOSE = RegexFlag.VERBOSE |
| 140 | +VERSION0 = RegexFlag.VERSION0 |
| 141 | +VERSION1 = RegexFlag.VERSION1 |
| 142 | +WORD = RegexFlag.WORD |
| 143 | +A = RegexFlag.A |
| 144 | +B = RegexFlag.B |
| 145 | +D = RegexFlag.D |
| 146 | +E = RegexFlag.E |
| 147 | +F = RegexFlag.F |
| 148 | +I = RegexFlag.I |
| 149 | +L = RegexFlag.L |
| 150 | +M = RegexFlag.M |
| 151 | +P = RegexFlag.P |
| 152 | +R = RegexFlag.R |
| 153 | +S = RegexFlag.S |
| 154 | +U = RegexFlag.U |
| 155 | +V0 = RegexFlag.V0 |
| 156 | +V1 = RegexFlag.V1 |
| 157 | +W = RegexFlag.W |
| 158 | +X = RegexFlag.X |
| 159 | +T = RegexFlag.T |
125 | 160 |
|
126 | 161 | DEFAULT_VERSION = VERSION1 |
127 | 162 |
|
@@ -2488,7 +2523,7 @@ def fix_groups(self, pattern, reverse, fuzzy): |
2488 | 2523 | self._key = self.__class__, self.group |
2489 | 2524 |
|
2490 | 2525 | def remove_captures(self): |
2491 | | - raise error("group reference not allowed", pattern, self.position) |
| 2526 | + raise error("group reference not allowed", self.pattern, self.position) |
2492 | 2527 |
|
2493 | 2528 | def _compile(self, reverse, fuzzy): |
2494 | 2529 | return [(OP.GROUP_CALL, self.call_ref)] |
@@ -3058,7 +3093,7 @@ def _compile(self, reverse, fuzzy): |
3058 | 3093 | def dump(self, indent, reverse): |
3059 | 3094 | group = self.group |
3060 | 3095 | if group < 0: |
3061 | | - group = private_groups[group] |
| 3096 | + group = self.info.private_groups[group] |
3062 | 3097 | print("{}GROUP {}".format(INDENT * indent, group)) |
3063 | 3098 | self.subpattern.dump(indent + 1, reverse) |
3064 | 3099 |
|
@@ -3413,7 +3448,7 @@ def fix_groups(self, pattern, reverse, fuzzy): |
3413 | 3448 | self._key = self.__class__, self.group, self.case_flags |
3414 | 3449 |
|
3415 | 3450 | def remove_captures(self): |
3416 | | - raise error("group reference not allowed", pattern, self.position) |
| 3451 | + raise error("group reference not allowed", self.pattern, self.position) |
3417 | 3452 |
|
3418 | 3453 | def _compile(self, reverse, fuzzy): |
3419 | 3454 | flags = 0 |
|
0 commit comments