Skip to content

Commit 16b576d

Browse files
committed
d
1 parent 07e20cf commit 16b576d

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

amazon/ionbenchmark/ion_benchmark_cli.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,18 @@ def reset_for_each_execution(each_option):
344344
return api, format_option
345345

346346

347+
def generate_ion_file_with_format(file, binary):
348+
cf = open("converted_file", "wb")
349+
with open(file, "br") as fp:
350+
ion.dump(ion.load(fp, single_value=False), cf, binary=binary)
351+
return cf.name
352+
353+
347354
def convert_file_to_desired_format(f, file):
348355
if f == Format.ION_BINARY.value:
349-
cf = open("converted_file", "wb")
350-
with open(file, "br") as fp:
351-
ion.dump(ion.load(fp, single_value=False), cf, binary=True)
352-
return cf.name
356+
return generate_ion_file_with_format(file, True)
353357
elif f == Format.ION_TEXT.value:
354-
cf = open("converted_file", "wb")
355-
with open(file, "br") as fp:
356-
ion.dump(ion.load(fp, single_value=False), cf, binary=False)
357-
return cf.name
358+
return generate_ion_file_with_format(file, False)
358359
else:
359360
raise Exception('Failed to convert file due to unknown format.')
360361

0 commit comments

Comments
 (0)