|
5 | 5 | import re
|
6 | 6 |
|
7 | 7 | _sub_regexes = {
|
8 |
| - "tag": "([a-zA-Z][a-zA-Z0-9]{0,10}|\*)", |
9 |
| - "attribute": "[.a-zA-Z_:][-\w:.]*(\(\))?)", |
10 |
| - "value": "\s*[\w/:][-/\w\s,:;.]*" |
| 8 | + "tag": r"([a-zA-Z][a-zA-Z0-9]{0,10}|\*)", |
| 9 | + "attribute": r"[.a-zA-Z_:][-\w:.]*(\(\))?)", |
| 10 | + "value": r"\s*[\w/:][-/\w\s,:;.]*" |
11 | 11 | }
|
12 | 12 |
|
13 | 13 | _validation_re = (
|
14 |
| - "(?P<node>" |
15 |
| - "(" |
16 |
| - "^id\([\"\']?(?P<idvalue>%(value)s)[\"\']?\)" |
17 |
| - "|" |
18 |
| - "(?P<nav>//?)(?P<tag>%(tag)s)" |
19 |
| - "(\[(" |
20 |
| - "(?P<matched>(?P<mattr>@?%(attribute)s=[\"\']" |
21 |
| - "(?P<mvalue>%(value)s))[\"\']" |
22 |
| - "|" |
23 |
| - "(?P<contained>contains\((?P<cattr>@?%(attribute)s,\s*[\"\']" |
24 |
| - "(?P<cvalue>%(value)s)[\"\']\))" |
25 |
| - ")\])?" |
26 |
| - "(\[(?P<nth>\d)\])?" |
27 |
| - ")" |
28 |
| - ")" % _sub_regexes |
| 14 | + r"(?P<node>" |
| 15 | + r"(" |
| 16 | + r"^id\([\"\']?(?P<idvalue>%(value)s)[\"\']?\)" |
| 17 | + r"|" |
| 18 | + r"(?P<nav>//?)(?P<tag>%(tag)s)" |
| 19 | + r"(\[(" |
| 20 | + r"(?P<matched>(?P<mattr>@?%(attribute)s=[\"\']" |
| 21 | + r"(?P<mvalue>%(value)s))[\"\']" |
| 22 | + r"|" |
| 23 | + r"(?P<contained>contains\((?P<cattr>@?%(attribute)s,\s*[\"\']" |
| 24 | + r"(?P<cvalue>%(value)s)[\"\']\))" |
| 25 | + r")\])?" |
| 26 | + r"(\[(?P<nth>\d)\])?" |
| 27 | + r")" |
| 28 | + r")" % _sub_regexes |
29 | 29 | )
|
30 | 30 |
|
31 | 31 | prog = re.compile(_validation_re)
|
@@ -136,7 +136,7 @@ def convert_xpath_to_css(xpath):
|
136 | 136 |
|
137 | 137 | css = _get_raw_css_from_xpath(xpath)
|
138 | 138 |
|
139 |
| - attribute_defs = re.findall('(\[\w+\=\S+\])', css) |
| 139 | + attribute_defs = re.findall(r'(\[\w+\=\S+\])', css) |
140 | 140 | for attr_def in attribute_defs:
|
141 | 141 | if (attr_def.count('[') == 1 and attr_def.count(']') == 1 and
|
142 | 142 | attr_def.count('=') == 1 and attr_def.count('"') == 0 and
|
|
0 commit comments