149149_gridfs_dest_base = "./gridfs/synchronous/"
150150_test_dest_base = "./test/"
151151
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 ))
152156
153157async_files = [
154158 _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:
170174 if (Path (_test_base ) / f ).is_file () and not async_only_test (f )
171175]
172176
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-
185177# Add each asynchronized test here as part of the converting PR
186178converted_tests = [
187179 "__init__.py" ,
@@ -223,15 +215,10 @@ def async_only_test(f: str) -> bool:
223215 "unified_format.py" ,
224216]
225217
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-
233218
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 :
235222 for file in files :
236223 if "__init__" not in file or "__init__" and "test" in file :
237224 with open (file , "r+" ) as f :
@@ -374,7 +361,27 @@ def main() -> None:
374361 unasync_directory (async_files , _pymongo_base , _pymongo_dest_base , replacements )
375362 unasync_directory (gridfs_files , _gridfs_base , _gridfs_dest_base , replacements )
376363 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+ )
378385
379386
380387if __name__ == "__main__" :
0 commit comments