Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __parse_filename_iso_timestamp(self, file, link):
"""
Parses the date+time and writes entry to outputfile
@param file: filename
@param link: path
"""
if TIMESTAMP_REGEX.match(file):
# if we found a timestamp too,take hours,min
# and optionally seconds from this timestamp
timestamp = TIMESTAMP_REGEX.match(file).group()
orgdate = OrgFormat.strdatetimeiso8601(timestamp)
logging.debug("found timestamp: " + orgdate)
else:
datestamp = DATESTAMP_REGEX.match(file).group()
orgdate = OrgFormat.strdate(datestamp)
orgdate_time_tupel = OrgFormat.datetupeliso8601(datestamp)
if not self._args.skip_filetime_extraction:
if os.path.exists(link):
file_datetime = time.localtime(os.path.getmtime(link))
# check if the file - time information matches year,month,day,
# then update time
if file_datetime.tm_year == orgdate_time_tupel.tm_year and \
file_datetime.tm_mon == orgdate_time_tupel.tm_mon and \
file_datetime.tm_mday == orgdate_time_tupel.tm_mday:
logging.debug("found a time in file.setting %s-->%s",
orgdate, OrgFormat.date(file_datetime, True))
orgdate = OrgFormat.date(file_datetime, True)
else: