diff --git a/plotid/example.py b/plotid/example.py index 7e41ff8141faee4152dfb48dd15f945518da4fa6..344f3104c96e620d4ee827b1d1f058541cf0b60b 100644 --- a/plotid/example.py +++ b/plotid/example.py @@ -56,5 +56,5 @@ IMGS_AS_LIST = [IMG1, IMG2] # plots or images. publish(['../README.md', '../docs', '../LICENSE'], - '/home/chief/Dokumente/fst/plotid_python/data', + '/home/chief/Dokumente/fst/plotid_python/data/', TAGGED_FIGS, 'Bild') diff --git a/plotid/publish.py b/plotid/publish.py index 79a926bd592b2061d913c2f686d76379a1191db7..2b7f2d12515070a9f4272bb653dcb9fb234b94f8 100644 --- a/plotid/publish.py +++ b/plotid/publish.py @@ -55,6 +55,13 @@ class PublishOptions: self.data_storage = data_storage self.dst_path_head, self.dst_dirname = os.path.split(self.dst_path) + # If the second string after os.path.split is empty, + # a trailing slash was given. + # To get the dir name correctly, split the first string again. + if not self.dst_dirname: + self.dst_path_head, self.dst_dirname = os.path.split( + self.dst_path_head) + def validate_input(self): """ Validate if input for PublishOptions is correct type. diff --git a/tests/test_publish.py b/tests/test_publish.py index 159f2be0c0ab8f57d7e1055d24035f3c663d1a6c..4956734f9da54fbc30de99c55e4c47420b068116 100644 --- a/tests/test_publish.py +++ b/tests/test_publish.py @@ -46,7 +46,7 @@ class TestPublish(unittest.TestCase): 'copied.') def test_publish(self): """ Test publish and check if an exported picture file exists. """ - publish(SRC_DIR, DST_PATH, FIG, PIC_NAME, 'individual') + publish(SRC_DIR, DST_PATH + '/', FIG, PIC_NAME, 'individual') assert os.path.isfile(os.path.join(DST_PATH, PIC_NAME + '.png')) # Skip test if tests are run from command line.