From e20e6cd02ef89316657db4314d646a9c0c0feab0 Mon Sep 17 00:00:00 2001 From: Karl Voit Date: Sun, 31 May 2020 19:17:25 +0200 Subject: [PATCH] filenametimestamps: fixed check_datestamp_correctness; fixed #97 --- memacs/filenametimestamps.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/memacs/filenametimestamps.py b/memacs/filenametimestamps.py index a64057c..a0fcb55 100755 --- a/memacs/filenametimestamps.py +++ b/memacs/filenametimestamps.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Time-stamp: <2019-11-06 15:48:47 vk> +# Time-stamp: <2020-05-31 19:15:55 vk> import os from memacs.lib.memacs import Memacs @@ -159,6 +159,10 @@ def __check_datestamp_correctness(self, datestamp): logging.debug('__check_datestamp_correctness(' + str(datestamp) + ') NEGATIVE') return False else: + try: + orgdate = OrgFormat.strdate(datestamp) + except ValueError: + return False return True def __check_timestamp_correctness(self, timestamp): @@ -335,6 +339,7 @@ def __handle_file(self, file, rootdir): # omit optional second day if first has an issue: has_2ymd = False has_2ymdhm = False + orgdate = False elif has_1ymd: # missing time-stamp for day1 if self.__check_datestamp_correctness(day1): if not self._args.skip_filetime_extraction: @@ -352,6 +357,9 @@ def __handle_file(self, file, rootdir): # we've got only a day and determining mtime # is not planned, so use the day as date-stamp orgdate = OrgFormat.strdate(day1, inactive=self._args.inactive_timestamps) + else: + logging.warning('File "' + file + '" has an invalid datestamp (' + str(day1) + ').') + orgdate = False else: logging.warning('File "' + file + '" has an invalid datestamp (' + str(day1) + '). Skipping this faulty date.') # omit optional second day if first has an issue: