149
149
_gridfs_dest_base = "./gridfs/synchronous/"
150
150
_test_dest_base = "./test/"
151
151
152
+ if not Path .exists (Path (_pymongo_dest_base )):
153
+ Path .mkdir (Path (_pymongo_dest_base ))
154
+ if not Path .exists (Path (_gridfs_dest_base )):
155
+ Path .mkdir (Path (_gridfs_dest_base ))
152
156
153
157
async_files = [
154
158
_pymongo_base + f for f in listdir (_pymongo_base ) if (Path (_pymongo_base ) / f ).is_file ()
@@ -170,18 +174,6 @@ def async_only_test(f: str) -> bool:
170
174
if (Path (_test_base ) / f ).is_file () and not async_only_test (f )
171
175
]
172
176
173
- sync_files = [
174
- _pymongo_dest_base + f
175
- for f in listdir (_pymongo_dest_base )
176
- if (Path (_pymongo_dest_base ) / f ).is_file ()
177
- ]
178
-
179
- sync_gridfs_files = [
180
- _gridfs_dest_base + f
181
- for f in listdir (_gridfs_dest_base )
182
- if (Path (_gridfs_dest_base ) / f ).is_file ()
183
- ]
184
-
185
177
# Add each asynchronized test here as part of the converting PR
186
178
converted_tests = [
187
179
"__init__.py" ,
@@ -223,15 +215,10 @@ def async_only_test(f: str) -> bool:
223
215
"unified_format.py" ,
224
216
]
225
217
226
- sync_test_files = [
227
- _test_dest_base + f for f in converted_tests if (Path (_test_dest_base ) / f ).is_file ()
228
- ]
229
-
230
-
231
- docstring_translate_files = sync_files + sync_gridfs_files + sync_test_files
232
-
233
218
234
- def process_files (files : list [str ]) -> None :
219
+ def process_files (
220
+ files : list [str ], docstring_translate_files : list [str ], sync_test_files : list [str ]
221
+ ) -> None :
235
222
for file in files :
236
223
if "__init__" not in file or "__init__" and "test" in file :
237
224
with open (file , "r+" ) as f :
@@ -374,7 +361,27 @@ def main() -> None:
374
361
unasync_directory (async_files , _pymongo_base , _pymongo_dest_base , replacements )
375
362
unasync_directory (gridfs_files , _gridfs_base , _gridfs_dest_base , replacements )
376
363
unasync_directory (test_files , _test_base , _test_dest_base , replacements )
377
- process_files (sync_files + sync_gridfs_files + sync_test_files )
364
+
365
+ sync_files = [
366
+ _pymongo_dest_base + f
367
+ for f in listdir (_pymongo_dest_base )
368
+ if (Path (_pymongo_dest_base ) / f ).is_file ()
369
+ ]
370
+
371
+ sync_gridfs_files = [
372
+ _gridfs_dest_base + f
373
+ for f in listdir (_gridfs_dest_base )
374
+ if (Path (_gridfs_dest_base ) / f ).is_file ()
375
+ ]
376
+ sync_test_files = [
377
+ _test_dest_base + f for f in converted_tests if (Path (_test_dest_base ) / f ).is_file ()
378
+ ]
379
+
380
+ docstring_translate_files = sync_files + sync_gridfs_files + sync_test_files
381
+
382
+ process_files (
383
+ sync_files + sync_gridfs_files + sync_test_files , docstring_translate_files , sync_test_files
384
+ )
378
385
379
386
380
387
if __name__ == "__main__" :
0 commit comments