1
1
#!/usr/bin/env python3
2
2
3
3
import argparse
4
+ import contextlib
4
5
from pathlib import Path
5
- from typing import TYPE_CHECKING , Callable , MutableMapping , Optional
6
+ from typing import TYPE_CHECKING , Callable , Dict , MutableMapping , Optional
6
7
7
8
import yaml
8
- from element_tracking import ElementsInProgress
9
+ from element_tracking import ElementsCache , ElementsInProgress
9
10
from import_backends import FakeTracBackend , GitHubBackend , RealTracBackend
10
11
from ticket_type import Ticket
11
12
@@ -123,6 +124,12 @@ def parse_args() -> argparse.Namespace:
123
124
'year' ,
124
125
help = "SR year to generate for (specify as just the number part)" ,
125
126
)
127
+ parser .add_argument (
128
+ '--cache' ,
129
+ help = "Path to a JSON file in which to load/store mapping from existing tasks." ,
130
+ type = Path ,
131
+ default = None ,
132
+ )
126
133
127
134
backends_group = parser .add_mutually_exclusive_group ()
128
135
backends_group .add_argument (
@@ -147,7 +154,15 @@ def main(arguments: argparse.Namespace) -> None:
147
154
else :
148
155
backend = FakeTracBackend ()
149
156
150
- add (arguments .base , backend , arguments .year )
157
+ with contextlib .ExitStack () as stack :
158
+ if arguments .cache :
159
+ elements : Optional [Dict [str , int ]] = stack .enter_context (
160
+ ElementsCache (arguments .cache ),
161
+ )
162
+ else :
163
+ elements = None
164
+
165
+ add (arguments .base , backend , arguments .year , known_elements = elements )
151
166
152
167
153
168
if __name__ == '__main__' :
0 commit comments