Skip to content

Commit

Permalink
style: resole doc issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aalemayhu committed Oct 17, 2024
1 parent 0bd4209 commit 319f88a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions helpers/write_apkg.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""
This module provides functionality to write a new Anki package file (.apkg) using provided deck payloads and media files.
"""

import os
import sys
import re
import tempfile

from genanki import Deck, Package

"""
This module provides functionality to write a new Anki package file (.apkg) using provided deck payloads and media files.
"""

def sanitize_filename(filename):
"""
Sanitize the filename by removing any character that is not alphanumeric, a space, or a hyphen.
Expand Down Expand Up @@ -62,14 +62,14 @@ def _write_new_apkg(deck_payloads, media_files):

try:
package.write_to_file(tmp_file.name)
except OSError as e:
if e.errno == 36: # File name too long
except OSError as error:
if error.errno == 36: # File name too long
tmp_file.name = (
f'{truncated_name[:max_name_length - 10]}-truncated-{first_deck_id}.apkg'
)
package.write_to_file(tmp_file.name)
else:
raise e # Re-raise other exceptions
raise error # Re-raise other exceptions

final_path = os.path.join(os.getcwd(), tmp_file.name)
os.rename(tmp_file.name, final_path)
Expand Down

0 comments on commit 319f88a

Please sign in to comment.