|
3 | 3 | import subprocess
|
4 | 4 | import sys
|
5 | 5 | from importlib import import_module
|
6 |
| -from typing import List, Set |
| 6 | +from typing import List, Set, Union |
7 | 7 |
|
8 | 8 |
|
9 | 9 | def return_attribute(value: str, attr: str) -> ast.Attribute:
|
@@ -155,6 +155,25 @@ def main(
|
155 | 155 | )
|
156 | 156 | abstract_methods.append(indented_code)
|
157 | 157 |
|
| 158 | + type_module = import_module(f"viam.{resource_type}s.{resource_type}_base") |
| 159 | + with open(type_module.__file__, "r") as f: |
| 160 | + tree = ast.parse(f.read()) |
| 161 | + for stmt in tree.body: |
| 162 | + if isinstance(stmt, ast.ClassDef): |
| 163 | + for cstmt in stmt.body: |
| 164 | + if isinstance(cstmt, ast.AsyncFunctionDef): |
| 165 | + replace_async_func("", cstmt, []) |
| 166 | + indented_code = '\n'.join( |
| 167 | + [' ' + line for line in ast.unparse(cstmt).splitlines()] |
| 168 | + ) |
| 169 | + abstract_methods.append(indented_code) |
| 170 | + if cstmt.name == "do_command": |
| 171 | + imports.append("from typing import Optional") |
| 172 | + imports.append("from viam.utils import ValueTypes") |
| 173 | + elif cstmt.name == "get_geometries": |
| 174 | + imports.append("from typing import List, Optional") |
| 175 | + imports.append("from viam.proto.common import Geometry") |
| 176 | + |
158 | 177 | model_name_pascal = "".join(
|
159 | 178 | [word.capitalize() for word in slugify(model_name).split("-")]
|
160 | 179 | )
|
|
0 commit comments