@@ -194,23 +194,35 @@ def get_schema_paths(root_path: str) -> list[str]:
194
194
return schema_paths
195
195
196
196
197
- def get_binary_tuples (binaries_path : str , schema_paths : list [str ]) -> list [tuple [str , str ]]:
197
+ def get_binary_tuples (binary_paths : list [ str ] , schema_paths : list [str ]) -> list [tuple [str , str ]]:
198
198
"""
199
199
Получение списка кортежей из двух элементов: (путь к бинарному файлу, путь к соответствующему ему файлу схемы)
200
- :param binaries_path : Список путей к бинарным файлам.
200
+ :param binary_paths : Список путей к бинарным файлам или директориям с ними .
201
201
:param schema_paths: Список путей к файлам схем.
202
202
:return: Кортеж из двух строковых элементов.
203
203
"""
204
204
binary_tuples = []
205
- for subdir , _ , files in os . walk ( binaries_path ):
206
- for file in files :
207
- file_path = os .path .abspath (os . path . join ( subdir , file ) )
205
+ for _ , binary_path in enumerate ( binary_paths ):
206
+ if os . path . isfile ( binary_path ) :
207
+ file_path = os .path .abspath (binary_path )
208
208
for schema_path in schema_paths :
209
209
schema_ext = os .path .splitext (os .path .basename (schema_path ))[0 ]
210
- file_ext = os .path .splitext (file )[1 ][1 :]
210
+ file_ext = os .path .splitext (file_path )[1 ][1 :]
211
211
if schema_ext .casefold () == file_ext .casefold ():
212
212
binary_tuples .append ((file_path , schema_path ))
213
213
break
214
+ continue
215
+ if not os .path .isdir (binary_path ):
216
+ continue
217
+ for subdir , _ , files in os .walk (binary_path ):
218
+ for file in files :
219
+ file_path = os .path .abspath (os .path .join (subdir , file ))
220
+ for schema_path in schema_paths :
221
+ schema_ext = os .path .splitext (os .path .basename (schema_path ))[0 ]
222
+ file_ext = os .path .splitext (file_path )[1 ][1 :]
223
+ if schema_ext .casefold () == file_ext .casefold ():
224
+ binary_tuples .append ((file_path , schema_path ))
225
+ break
214
226
return binary_tuples
215
227
216
228
@@ -252,7 +264,7 @@ def execute_deserialize_batch(flatc_path: str, schemas_path: str, binaries_path:
252
264
if len (schema_paths ) < 1 :
253
265
logging .info (i18n .t ("main.no_schema_files_found" ), binaries_path )
254
266
return os .EX_OK
255
- binary_tuples = get_binary_tuples (binaries_path , schema_paths )
267
+ binary_tuples = get_binary_tuples ([ binaries_path ] , schema_paths )
256
268
with logging_redirect_tqdm ():
257
269
pbar = tqdm (total = len (binary_tuples ), desc = i18n .t ("main.files" ))
258
270
with ThreadPoolExecutor () as executor :
0 commit comments