more debug output for smartprepend feature

This commit is contained in:
Karl Voit 2022-01-07 17:03:44 +01:00
parent f423f93e19
commit 4cc3b34ee5

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
PROG_VERSION = u"Time-stamp: <2022-01-04 17:25:15 vk>" PROG_VERSION = u"Time-stamp: <2022-01-07 17:03:35 vk>"
# TODO: # TODO:
# * fix parts marked with «FIXXME» # * fix parts marked with «FIXXME»
@ -288,6 +288,7 @@ def handle_file(filename, text, dryrun):
assert(isinstance(filename, str)) assert(isinstance(filename, str))
num_errors = 0 num_errors = 0
new_filename = ''
if os.path.isdir(filename): if os.path.isdir(filename):
logging.warning("Skipping directory \"%s\" because this tool only processes file names." % filename) logging.warning("Skipping directory \"%s\" because this tool only processes file names." % filename)
@ -309,9 +310,15 @@ def handle_file(filename, text, dryrun):
try: try:
if options.prepend: if options.prepend:
logging.debug('options.prepend is set with |' + str(os.path.dirname(filename)) + '|' +
str(text) + '|' + str(separator()) + '|' + str(old_basename) + '|' + str(tags_with_extension))
new_filename = os.path.join(os.path.dirname(filename), text + separator() + old_basename + tags_with_extension) new_filename = os.path.join(os.path.dirname(filename), text + separator() + old_basename + tags_with_extension)
elif options.smartprepend: elif options.smartprepend:
match = re.match(WITHTIME_AND_SECONDS_PATTERN, filename) match = re.match(WITHTIME_AND_SECONDS_PATTERN, filename)
logging.debug('options.smartprepend is set with |' + str(os.path.dirname(filename)) + '|' +
str(text) + '|' + str(separator()) + '|' + str(old_basename) + '|' + str(tags_with_extension))
logging.debug('options.smartprepend is set with |' + str(type(os.path.dirname(filename))) + '|' +
str(type(text)) + '|' + str(type(separator())) + '|' + str(type(old_basename)) + '|' + str(type(tags_with_extension)))
if not match: if not match:
logging.debug('can\'t find a date/time-stamp, doing a simple prepend') logging.debug('can\'t find a date/time-stamp, doing a simple prepend')
new_filename = os.path.join(os.path.dirname(filename), text + separator() + old_basename + tags_with_extension) new_filename = os.path.join(os.path.dirname(filename), text + separator() + old_basename + tags_with_extension)