Add documentation for two consts and ensure that all sentenses will end with a dot.
Showing the changes to tools/lib/python (1 of 1 file). Show all
Unified · Split
| @@ -16,10 +16,22 @@ from abi.abi_parser import AbiParser · 15 unmodified lines | |||
| 16 | from abi.helpers import AbiDebug | 16 | from abi.helpers import AbiDebug |
| 17 | 17 | ||
| 18 | class AbiRegex(AbiParser): | 18 | class AbiRegex(AbiParser): |
| 19 | """Extends AbiParser to search ABI nodes with regular expressions""" | 19 | """ |
| 20 | Extends AbiParser to search ABI nodes with regular expressions. | ||
| 20 | 21 | ||
| 21 | # Escape only ASCII visible characters | 22 | There some optimizations here to allow a quick symbol search: |
| 23 | instead of trying to place all symbols altogether an doing linear | ||
| 24 | search which is very time consuming, create a tree with one depth, | ||
| 25 | grouping similar symbols altogether. | ||
| 26 | |||
| 27 | Yet, sometimes a full search will be needed, so we have a special branch | ||
| 28 | on such group tree where other symbols are placed. | ||
| 29 | """ | ||
| 30 | |||
| 31 | #: Escape only ASCII visible characters. | ||
| 22 | escape_symbols = r"([\x21-\x29\x2b-\x2d\x3a-\x40\x5c\x60\x7b-\x7e])" | 32 | escape_symbols = r"([\x21-\x29\x2b-\x2d\x3a-\x40\x5c\x60\x7b-\x7e])" |
| 33 | |||
| 34 | #: Special group for other nodes. | ||
| 23 | leave_others = "others" | 35 | leave_others = "others" |
| 24 | 36 | ||
| 25 | # Tuples with regular expressions to be compiled and replacement data | 37 | # Tuples with regular expressions to be compiled and replacement data |
| @@ -88,13 +100,15 @@ class AbiRegex(AbiParser): · 62 unmodified lines | |||
| 88 | # Recover plus characters | 100 | # Recover plus characters |
| 89 | (re.compile(r"\xf7"), "+"), | 101 | (re.compile(r"\xf7"), "+"), |
| 90 | ] | 102 | ] |
| 103 | |||
| 104 | #: Regex to check if the symbol name has a number on it. | ||
| 91 | re_has_num = re.compile(r"\\d") | 105 | re_has_num = re.compile(r"\\d") |
| 92 | 106 | ||
| 93 | # Symbol name after escape_chars that are considered a devnode basename | 107 | #: Symbol name after escape_chars that are considered a devnode basename. |
| 94 | re_symbol_name = re.compile(r"(\w|\\[\.\-\:])+$") | 108 | re_symbol_name = re.compile(r"(\w|\\[\.\-\:])+$") |
| 95 | 109 | ||
| 96 | # List of popular group names to be skipped to minimize regex group size | 110 | #: List of popular group names to be skipped to minimize regex group size |
| 97 | # Use AbiDebug.SUBGROUP_SIZE to detect those | 111 | #: Use AbiDebug.SUBGROUP_SIZE to detect those. |
| 98 | skip_names = set(["devices", "hwmon"]) | 112 | skip_names = set(["devices", "hwmon"]) |
| 99 | 113 | ||
| 100 | def regex_append(self, what, new): | 114 | def regex_append(self, what, new): |
| @@ -148,7 +162,7 @@ class AbiRegex(AbiParser): · 47 unmodified lines | |||
| 148 | def get_regexes(self, what): | 162 | def get_regexes(self, what): |
| 149 | """ | 163 | """ |
| 150 | Given an ABI devnode, return a list of all regular expressions that | 164 | Given an ABI devnode, return a list of all regular expressions that |
| 151 | may match it, based on the sub-groups created by regex_append() | 165 | may match it, based on the sub-groups created by regex_append(). |
| 152 | """ | 166 | """ |
| 153 | 167 | ||
| 154 | re_list = [] | 168 | re_list = [] |