(cls, path: str)
| 12 | |
| 13 | @classmethod |
| 14 | def from_path(cls, path: str) -> "File": |
| 15 | if not path.startswith("/"): |
| 16 | path = f"./{path}" |
| 17 | with open(path, "rb") as f: |
| 18 | path = path.split("/")[-1] |
| 19 | return cls(name=path, content=f.read()) |
| 20 | |
| 21 | @classmethod |
| 22 | async def afrom_path(cls, path: str) -> "File": |