Skip to content

Commit

Permalink
Cleanup previous PR
Browse files Browse the repository at this point in the history
There was a leftover str(id).
  • Loading branch information
kovidgoyal committed Jan 29, 2025
1 parent 8dc6a4e commit ea4aebf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/calibre/library/save_to_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def get_value(self, key, args, kwargs):
return key


def get_component_metadata(template, mi, id_, timefmt='%b %Y'):
def get_component_metadata(template, mi, book_id, timefmt='%b %Y'):
tsorder = tweaks['save_template_title_series_sorting']
format_args = FORMAT_ARGS.copy()
format_args.update(mi.all_non_none_fields())
Expand Down Expand Up @@ -215,7 +215,7 @@ def get_component_metadata(template, mi, id_, timefmt='%b %Y'):
hasattr(mi.last_modified, 'timetuple')):
format_args['last_modified'] = strftime(timefmt, mi.last_modified.timetuple())

format_args['id'] = str(id_)
format_args['id'] = str(book_id)
# Now format the custom fields
custom_metadata = mi.get_all_user_metadata(make_copy=False)
for key in custom_metadata:
Expand All @@ -239,20 +239,20 @@ def get_component_metadata(template, mi, id_, timefmt='%b %Y'):
format_args[key] = ''
return format_args

def get_components(template, mi, id_, timefmt='%b %Y', length=250,

def get_components(template, mi, book_id, timefmt='%b %Y', length=250,
sanitize_func=ascii_filename, replace_whitespace=False,
to_lowercase=False, safe_format=True, last_has_extension=True,
single_dir=False):
format_args = get_component_metadata(template, mi, id_, timefmt)
format_args = get_component_metadata(template, mi, book_id, timefmt)
if safe_format:
components = Formatter().safe_format(template, format_args,
'G_C-EXCEPTION!', mi)
components = Formatter().safe_format(template, format_args, 'G_C-EXCEPTION!', mi)
else:
components = Formatter().unsafe_format(template, format_args, mi)
components = [x.strip() for x in components.split('/')]
components = [sanitize_func(x) for x in components if x]
if not components:
components = [str(id)]
components = [str(book_id)]
if to_lowercase:
components = [x.lower() for x in components]
if replace_whitespace:
Expand Down

0 comments on commit ea4aebf

Please sign in to comment.