From b432fd7b6a22667c54a690fdc4e487c23e500f45 Mon Sep 17 00:00:00 2001
From: "Mayr, Hannes" <hannes.mayr@stud.tu-darmstadt.de>
Date: Tue, 23 Aug 2022 15:24:20 +0200
Subject: [PATCH] Allow publishing data to a directory with trailing slash.

---
 plotid/example.py | 2 +-
 plotid/publish.py | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/plotid/example.py b/plotid/example.py
index 7e41ff8..344f310 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 79a926b..2b7f2d1 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.
-- 
GitLab