Skip to content

Commit

Permalink
filenametimestamps: fixed check_datestamp_correctness; fixed #97
Browse files Browse the repository at this point in the history
  • Loading branch information
novoid committed May 31, 2020
1 parent 6144e84 commit e20e6cd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion memacs/filenametimestamps.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit e20e6cd

Please sign in to comment.