History

docs: python: abi_regex: do some improvements at documentation

Add documentation for two consts and ensure that all sentenses will end with a dot.

Mauro Carvalho Chehab committed 9 months ago

Commit ff916371 parent 66c3bf91 file · +20 −6Browse files

Showing the changes to tools/lib/python (1 of 1 file). Show all

Unified · Split

tools/lib/python/abi/abi_regex.py+20−6
@@ -16,10 +16,22 @@ from abi.abi_parser import AbiParser · 15 unmodified lines
1616 from abi.helpers import AbiDebug
1717
1818 class AbiRegex(AbiParser):
19− """Extends AbiParser to search ABI nodes with regular expressions"""
19+ """
20+ Extends AbiParser to search ABI nodes with regular expressions.
2021
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.
2232 escape_symbols = r"([\x21-\x29\x2b-\x2d\x3a-\x40\x5c\x60\x7b-\x7e])"
33+
34+ #: Special group for other nodes.
2335 leave_others = "others"
2436
2537 # Tuples with regular expressions to be compiled and replacement data
@@ -88,13 +100,15 @@ class AbiRegex(AbiParser): · 62 unmodified lines
88100 # Recover plus characters
89101 (re.compile(r"\xf7"), "+"),
90102 ]
103+
104+ #: Regex to check if the symbol name has a number on it.
91105 re_has_num = re.compile(r"\\d")
92106
93− # Symbol name after escape_chars that are considered a devnode basename
107+ #: Symbol name after escape_chars that are considered a devnode basename.
94108 re_symbol_name = re.compile(r"(\w|\\[\.\-\:])+$")
95109
96− # List of popular group names to be skipped to minimize regex group size
97− # Use AbiDebug.SUBGROUP_SIZE to detect those
110+ #: List of popular group names to be skipped to minimize regex group size
111+ #: Use AbiDebug.SUBGROUP_SIZE to detect those.
98112 skip_names = set(["devices", "hwmon"])
99113
100114 def regex_append(self, what, new):
@@ -148,7 +162,7 @@ class AbiRegex(AbiParser): · 47 unmodified lines
148162 def get_regexes(self, what):
149163 """
150164 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().
152166 """
153167
154168 re_list = []