|
4 | 4 | from typing import Any, Generator, Iterable, List, Tuple |
5 | 5 |
|
6 | 6 | from aws_doc_sdk_examples_tools.doc_gen import DocGen, Example |
7 | | -from aws_doc_sdk_examples_tools.fs import PathFs |
| 7 | +from aws_doc_sdk_examples_tools.fs import Fs, PathFs |
8 | 8 | from aws_doc_sdk_examples_tools.lliam.domain.model import Prompt |
9 | 9 | from aws_doc_sdk_examples_tools.lliam.shared_constants import BATCH_PREFIX |
10 | 10 |
|
@@ -76,9 +76,9 @@ def _get(self, id: str) -> Prompt: |
76 | 76 |
|
77 | 77 |
|
78 | 78 | class FsPromptRepository(AbstractPromptRepository): |
79 | | - def __init__(self): |
| 79 | + def __init__(self, fs: Fs = PathFs()): |
80 | 80 | super().__init__() |
81 | | - self.fs = PathFs() |
| 81 | + self.fs = fs |
82 | 82 |
|
83 | 83 | def rollback(self): |
84 | 84 | # TODO: This is not what rollback is for. We should be rolling back any |
@@ -120,13 +120,19 @@ def _get_new_prompts(self, doc_gen_root: str) -> List[Prompt]: |
120 | 120 |
|
121 | 121 |
|
122 | 122 | class FsDocGenRepository(AbstractDocGenRepository): |
| 123 | + def __init__(self, fs: Fs = PathFs()): |
| 124 | + super().__init__() |
| 125 | + self.fs = fs |
| 126 | + |
123 | 127 | def rollback(self): |
124 | 128 | # TODO: This is not what rollback is for. We should be rolling back any |
125 | 129 | # file changes |
126 | 130 | self._doc_gen = None |
127 | 131 |
|
128 | 132 | def _get_new_prompts(self, doc_gen_root: str) -> List[Prompt]: |
129 | | - self._doc_gen = DocGen.from_root(Path(doc_gen_root)) |
| 133 | + # Right now this is the only instance of DocGen used in this Repository, |
| 134 | + # but if that changes we need to move it up. |
| 135 | + self._doc_gen = DocGen.from_root(Path(doc_gen_root), fs=self.fs) |
130 | 136 | self._doc_gen.collect_snippets() |
131 | 137 | new_examples = self._get_new_examples() |
132 | 138 | prompts = self._examples_to_prompts(new_examples) |
|
0 commit comments