Skip to content

Commit d22aff0

Browse files
committed
Changing output format in saving to the file methods
1 parent 3bbe4e7 commit d22aff0

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

skillcorner/client.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ def __new__(cls, classname, supers, cls_dict):
302302
if write_output_format_file_format_binding:
303303
if 'df' in write_output_format_file_format_binding.keys():
304304
write_output_format_file_format_binding['csv'] = write_output_format_file_format_binding.pop('df')
305+
if 'python_structured_data' in write_output_format_file_format_binding.keys():
306+
if 'json' in write_output_format_file_format_binding['python_structured_data']:
307+
write_output_format_file_format_binding['json'] = write_output_format_file_format_binding.pop('python_structured_data')
308+
elif 'jsonl' in write_output_format_file_format_binding['python_structured_data']:
309+
write_output_format_file_format_binding['jsonl'] = write_output_format_file_format_binding.pop('python_structured_data')
310+
if 'bytes' in write_output_format_file_format_binding.keys():
311+
write_output_format_file_format_binding.pop('bytes')
312+
write_output_format_file_format_binding['txt'] = ['fifa-data']
313+
write_output_format_file_format_binding['xml'] = ['fifa-xml']
305314
setattr(skcr_client,
306315
get_and_save_method_name,
307316
_freeze_args(skcr_client._get_and_write_data,
@@ -317,8 +326,11 @@ def __new__(cls, classname, supers, cls_dict):
317326
docstring.split(" in the ")[1]
318327
if default_output_format:
319328
get_and_save_docstring = get_and_save_docstring.replace('df', 'csv')
320-
get_and_save_docstring = get_and_save_docstring.replace('python_structured_data', 'json')
321329
get_and_save_docstring = get_and_save_docstring.replace('bytes', 'xml, txt')
330+
if 'jsonl' in write_output_format_file_format_binding.keys():
331+
get_and_save_docstring = get_and_save_docstring.replace('python_structured_data', 'jsonl')
332+
elif 'json' in write_output_format_file_format_binding.keys():
333+
get_and_save_docstring = get_and_save_docstring.replace('python_structured_data', 'json')
322334
cls_dict[get_and_save_method_name.strip("_")].__doc__ = get_and_save_docstring
323335

324336
for key, value in METHOD_URL_ID_BINDING.items():
@@ -370,6 +382,15 @@ def __new__(cls, classname, supers, cls_dict):
370382
if write_output_format_file_format_binding:
371383
if 'df' in write_output_format_file_format_binding.keys():
372384
write_output_format_file_format_binding['csv'] = write_output_format_file_format_binding.pop('df')
385+
if 'python_structured_data' in write_output_format_file_format_binding.keys():
386+
if 'json' in write_output_format_file_format_binding['python_structured_data']:
387+
write_output_format_file_format_binding['json'] = write_output_format_file_format_binding.pop('python_structured_data')
388+
elif 'jsonl' in write_output_format_file_format_binding['python_structured_data']:
389+
write_output_format_file_format_binding['jsonl'] = write_output_format_file_format_binding.pop('python_structured_data')
390+
if 'bytes' in write_output_format_file_format_binding.keys():
391+
write_output_format_file_format_binding.pop('bytes')
392+
write_output_format_file_format_binding['txt'] = ['fifa-data']
393+
write_output_format_file_format_binding['xml'] = ['fifa-xml']
373394
setattr(skcr_client,
374395
get_and_save_method_name,
375396
_freeze_args(skcr_client._get_and_write_data_with_id,
@@ -390,8 +411,11 @@ def __new__(cls, classname, supers, cls_dict):
390411
docstring.split(" in the ")[1]
391412
if default_output_format:
392413
get_and_save_docstring = get_and_save_docstring.replace('df', 'csv')
393-
get_and_save_docstring = get_and_save_docstring.replace('python_structured_data', 'json')
394414
get_and_save_docstring = get_and_save_docstring.replace('bytes', "xml', 'txt")
415+
if 'jsonl' in write_output_format_file_format_binding.keys():
416+
get_and_save_docstring = get_and_save_docstring.replace('python_structured_data', 'jsonl')
417+
elif 'json' in write_output_format_file_format_binding.keys():
418+
get_and_save_docstring = get_and_save_docstring.replace('python_structured_data', 'json')
395419

396420
cls_dict[get_and_save_method_name.strip("_")].__doc__ = get_and_save_docstring
397421

0 commit comments

Comments
 (0)