Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only generate combined image when more than 1 jdx file #131

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion chem_spectra/lib/converter/bagit/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __read(self, target_dir, fname):
list_file_names = []
data_dir_path = os.path.join(target_dir, 'data')
for (dirpath, dirnames, filenames) in os.walk(data_dir_path):
filenames.sort()
list_file_names.extend(filenames)
break
if (len(list_file_names) == 0):
Expand Down Expand Up @@ -70,7 +71,7 @@ def get_base64_data(self):
return list_jcamps

def __combine_images(self, list_composer, list_file_names = None):
if len(list_composer) == 0:
if len(list_composer) <= 1:
return None
if isinstance(list_composer[0].core, JcampMSConverter):
return None
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='chem-spectra-app',
version='0.13.3',
version='0.13.4',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
Expand Down
8 changes: 8 additions & 0 deletions tests/lib/converter/bagit/test_bagit_base_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,11 @@ def test_get_combined_image():
converter = BagItConveter(td)
combined_image = converter.combined_image
assertFileType(combined_image, 'image/png')

def test_bagit_has_one_file_no_combined_image():
with tempfile.TemporaryDirectory() as td:
with zipfile.ZipFile(dls_acf_layout_path, 'r') as z:
z.extractall(td)

converter = BagItConveter(td)
assert converter.combined_image is None
Loading