@@ -65,6 +65,7 @@ def init_csv_and_watch_changes(
65
65
extra_ignored_values : Optional [list [str ]] = None ,
66
66
extra_allowed_values : Optional [list [str ]] = None ,
67
67
allow_unknown_values : bool = False ,
68
+ deprecated : bool = False ,
68
69
default_list_name : Optional [str ] = None ,
69
70
headers : list [str ] = [SPOKEN_FORM_HEADER , CURSORLESS_IDENTIFIER_HEADER ],
70
71
no_update_file : bool = False ,
@@ -123,6 +124,12 @@ def init_csv_and_watch_changes(
123
124
pluralize_lists = []
124
125
125
126
file_path = get_full_path (filename )
127
+ is_file = file_path .is_file ()
128
+
129
+ # Deprecated file that doesn't exist. Do nothing.
130
+ if deprecated and not is_file :
131
+ return lambda : None
132
+
126
133
super_default_values = get_super_values (default_values )
127
134
128
135
file_path .parent .mkdir (parents = True , exist_ok = True )
@@ -151,9 +158,9 @@ def on_watch(path, flags):
151
158
handle_new_values = handle_new_values ,
152
159
)
153
160
154
- fs .watch (str ( file_path .parent ) , on_watch )
161
+ fs .watch (file_path .parent , on_watch )
155
162
156
- if file_path . is_file () :
163
+ if is_file :
157
164
current_values = update_file (
158
165
path = file_path ,
159
166
headers = headers ,
@@ -188,7 +195,7 @@ def on_watch(path, flags):
188
195
)
189
196
190
197
def unsubscribe ():
191
- fs .unwatch (str ( file_path .parent ) , on_watch )
198
+ fs .unwatch (file_path .parent , on_watch )
192
199
193
200
return unsubscribe
194
201
@@ -385,7 +392,7 @@ def csv_error(path: Path, index: int, message: str, value: str):
385
392
index (int): The index into the file (for error reporting)
386
393
text (str): The text of the error message to report if condition is false
387
394
"""
388
- print (f"ERROR: { path } :{ index + 1 } : { message } '{ value } '" )
395
+ print (f"ERROR: { path } :{ index + 1 } : { message } '{ value } '" )
389
396
390
397
391
398
def read_file (
0 commit comments