Skip to content

Commit

Permalink
fix the progress bars for multiple inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
marph91 committed Jun 21, 2024
1 parent 141655e commit ab5b527
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import requests

import common
import intermediate_format as imf


Expand All @@ -14,13 +13,13 @@
class JoplinImporter:
"""Import notebooks, notes and related data to Joplin."""

def __init__(self, api, stats: common.Stats):
def __init__(self, api, progress_bars):
self.api = api
# Cache created tags to create them only once.
self.tag_map: dict[str, imf.Tag] = {} # original id - joplin id
self.note_id_map: dict[str, str] = {} # original id - joplin id

self.progress_bars = stats.create_progress_bars()
self.progress_bars = progress_bars

def add_tag(self, tag: imf.Tag) -> str:
self.progress_bars["tags"].update(1)
Expand Down
6 changes: 4 additions & 2 deletions src/jimmy.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def jimmy(api, config) -> common.Stats:
api.delete_all_tags()
LOGGER.info("Cleared everything successfully.")

LOGGER.info(f"Importing notes from {' '.join(map(str, config.input))}")
inputs_str = ' '.join(map(str, config.input))
LOGGER.info(f"Importing notes from \"{inputs_str}\"")
LOGGER.info("Start parsing")
root_notebooks = convert_all_inputs(config.input, config.format)
stats = common.get_import_stats(root_notebooks)
Expand All @@ -107,8 +108,9 @@ def jimmy(api, config) -> common.Stats:

if not config.dry_run:
LOGGER.info("Start import to Joplin")
progress_bars = stats.create_progress_bars()
for note_tree in root_notebooks:
joplin_importer = importer.JoplinImporter(api, stats)
joplin_importer = importer.JoplinImporter(api, progress_bars)
joplin_importer.import_notebook(note_tree)
# We need another pass, since at the first pass
# target note IDs are unknown.
Expand Down

0 comments on commit ab5b527

Please sign in to comment.