Skip to content

Commit

Permalink
Merge pull request #233 from VesnaT/fix_path_subfolder
Browse files Browse the repository at this point in the history
ImportImages: Assure valid path
  • Loading branch information
PrimozGodec committed Sep 12, 2023
2 parents d825d3a + bb122b9 commit 3f67a54
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
6 changes: 3 additions & 3 deletions orangecontrib/imageanalytics/import_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ def create_table(image_meta, categories=None, start_dir=None):
basename = os.path.basename(imgmeta.path)
imgname, _ = os.path.splitext(basename)

path = imgmeta.path[len(start_dir)+1:] if start_dir else imgmeta.path
path = path.replace(os.path.sep, "/")
meta_data.append(
[imgname,
imgmeta.path[len(start_dir)+1:] if start_dir else imgmeta.path,
imgmeta.size, imgmeta.width, imgmeta.height]
[imgname, path, imgmeta.size, imgmeta.width, imgmeta.height]
)
else:
n_skipped += 1
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions orangecontrib/imageanalytics/tests/test_import_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import unittest
from os.path import dirname, join

from pkg_resources import get_distribution

from orangecontrib.imageanalytics.import_images import ImportImages


Expand Down Expand Up @@ -31,8 +29,19 @@ def test_import_various_formats(self):
includes all currently supported formats by QImageReader
"""
table, n_skipped = self.import_images(join(dirname(__file__), "test_images"))
self.assertEqual(16, len(table))
self.assertEqual(18, len(table))
self.assertEqual(0, n_skipped)

def test_import_subfolder(self):
"""
Check if paths are valid for all operating systems.
"""
table, n_skipped = \
self.import_images(join(dirname(__file__), "test_images"))
self.assertEqual(18, len(table))
self.assertEqual(0, n_skipped)
self.assertEqual(table.metas[-2, 1], "img/example_image_a.jpg")
self.assertEqual(table.metas[-1, 1], "img/inner/example_image_b.jpg")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
PACKAGE_DATA = {
'orangecontrib.imageanalytics.widgets': ['icons/*.svg'],
'orangecontrib.imageanalytics.widgets.tests': ['test_images/*'],
'orangecontrib.imageanalytics.tests': ['test_images/*']
'orangecontrib.imageanalytics.tests': ['test_images/*', 'test_images/img/*', 'test_images/img/inner/*'],
}

ENTRY_POINTS = {
Expand Down

0 comments on commit 3f67a54

Please sign in to comment.