(filename)
| 296 | |
| 297 | |
| 298 | def findGlobalVar(filename) -> dict: |
| 299 | results = dict() |
| 300 | with open(filename, "r") as file: |
| 301 | pattern = r"\n(pub\s+)?(const\s+)?(static\s+)?(mut\s+)?(?P<name1>\w+)\s*(:\s*(?P<type2>[^=]+))?\s*(=\s*(?P<value3>[^;]+))?;" |
| 302 | for var in re.findall(pattern, re.sub("//.+\n", "", file.read())): # remove comment |
| 303 | if var[0] == "" and var[1] == "" and var[2] == "" and var[3] == "": |
| 304 | continue |
| 305 | # print(var) |
| 306 | name = var[4] |
| 307 | results[name] = { |
| 308 | "value": var[-1].strip(), |
| 309 | "type": var[-3].strip(), |
| 310 | "visibility": "public" if "pub" in var[0] else "private", |
| 311 | } |
| 312 | return results |
| 313 | |
| 314 | |
| 315 | def findStruct(filename, only_near_bindgen=False) -> list: |
no test coverage detected