load a file into the store (makes a copy)
(self, path: Path)
| 187 | self.files.append(fw) |
| 188 | |
| 189 | def load_file(self, path: Path) -> FileEntry: |
| 190 | """load a file into the store (makes a copy)""" |
| 191 | # TODO - ideally lazily-link a path to the store (rather than copy it in) |
| 192 | ext = "".join(path.suffixes) |
| 193 | dest_obj = self.fw_klass(ext=ext, dir_path=self.dir_path) |
| 194 | with path.open("rb") as src_obj: |
| 195 | copyfileobj(src_obj, dest_obj.file) |
| 196 | self.add_file(dest_obj) |
| 197 | return dest_obj |
| 198 | |
| 199 | def as_dict(self) -> dict: |
| 200 | """Build a json structure suitable for embedding in a html file, json-rpc response, etc.""" |