Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:
logging.debug("item [%s] not found and thus could not determine mtime" % link)
return orgdate
"""
handles a file (except ending with a tilde)
"""
# don't handle emacs tmp files (file~)
if file[-1:] == '~':
return
link = os.path.join(rootdir, file)
logging.debug(link)
if self._args.force_filedate_extraction:
file_datetime = time.localtime(os.path.getmtime(link))
if self._args.skip_filetime_extraction:
logging.debug('force_filedate_extraction and skip_filetime_extraction: using date')
orgdate = OrgFormat.date(file_datetime)
else:
logging.debug('force_filedate_extraction and not skip_filetime_extraction: using datetime')
orgdate = OrgFormat.datetime(file_datetime)
self.__write_file(file, link, orgdate)
elif DATESTAMP_REGEX.match(file):
logging.debug('DATESTAMP_REGEX matches; trying __parse_filename_iso_timestamp() ...')
try:
# we put this in a try block because:
# if a timestamp is false i.e. 2011-14-19 or false time
# we can handle those not easy with REGEX, therefore we have
# an Exception TimestampParseException, which is thrown,
# when strptime (parse from string to time tupel) fails
orgdate = self.__parse_filename_iso_timestamp(file, link)
self.__write_file(file, link, orgdate)
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:
logging.debug("item [%s] not found and thus could not determine mtime" % link)
return orgdate
def datetimerange(begin, end):
"""
returns a date range string in org format
@param begin,end: has to be a time.struct_time
"""
assert isinstance(begin, time.struct_time)
assert isinstance(end, time.struct_time)
return "%s--%s" % (OrgFormat.date(begin, True),
OrgFormat.date(end, True))