| 8 | |
| 9 | |
| 10 | def find_features(path: str, typ: str, string: str) -> List[Feature]: |
| 11 | features = [] |
| 12 | index = int(string) if typ == "id" else None |
| 13 | for feature in Mwm(path): |
| 14 | found = False |
| 15 | if typ == "n": |
| 16 | for value in feature.names().values(): |
| 17 | if string in value: |
| 18 | found = True |
| 19 | break |
| 20 | elif typ in ("t", "et"): |
| 21 | for t in feature.types(): |
| 22 | readable_type_ = readable_type(t) |
| 23 | if readable_type_ == string: |
| 24 | found = True |
| 25 | break |
| 26 | elif typ == "t" and string in readable_type_: |
| 27 | found = True |
| 28 | break |
| 29 | elif typ == "m": |
| 30 | for f in feature.metadata(): |
| 31 | if string in f.name: |
| 32 | found = True |
| 33 | break |
| 34 | elif typ == "id" and index == feature.index(): |
| 35 | found = True |
| 36 | |
| 37 | if found: |
| 38 | features.append(feature) |
| 39 | |
| 40 | return features |
| 41 | |
| 42 | |
| 43 | def find_and_print_features(path: str, typ: str, string: str): |