From 1795317d9c7ec38606e21fa9a05cbe1dd5ea001b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sun, 11 Oct 2020 17:21:43 +0200 Subject: [PATCH] fix for empty yesterday-file --- workdirfs.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/workdirfs.py b/workdirfs.py index e0ea2ec..b92f9ca 100755 --- a/workdirfs.py +++ b/workdirfs.py @@ -95,14 +95,18 @@ class WorkdirFS(Operations): def _give_me_yesterday(self): if os.path.exists(self.configlast): with open(self.configlast, 'r') as fh: - self.yesterday = datetime.strptime(fh.readline().strip(), "%Y-%m-%d") + yesterday = fh.readline().strip() + if self.yesterday == None: + self.yesterday = self.today + else: + self.yesterday = datetime.strptime(yesterday, "%Y-%m-%d") else: self.yesterday = self.today self._checkdir(self.confdir) if not os.path.isdir(self.confdir): os.mkdir(self.confdir) - with open(self.configlast, 'w') as fh: - fh.write(self.yesterday.date().strftime("%Y-%m-%d")) + with open(self.configlast, 'w') as fh: + fh.write(self.yesterday.date().strftime("%Y-%m-%d")) return self.yesterday def _give_me_archivpath(self, _date=None):