Skip to content

Commit

Permalink
refactor: remove transfor v4 options
Browse files Browse the repository at this point in the history
  • Loading branch information
datawhores committed Jan 18, 2025
1 parent ae55bde commit dc2a83e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 220 deletions.
31 changes: 0 additions & 31 deletions cyberdrop_dl/ui/program_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from cyberdrop_dl.ui.prompts.basic_prompts import ask_dir_path, enter_to_continue
from cyberdrop_dl.ui.prompts.defaults import DONE_CHOICE, EXIT_CHOICE
from cyberdrop_dl.utils.cookie_management import clear_cookies
from cyberdrop_dl.utils.transfer.transfer_v4_config import transfer_v4_config
from cyberdrop_dl.utils.transfer.transfer_v4_db import transfer_v4_db
from cyberdrop_dl.utils.utilities import check_latest_pypi, clear_term, open_in_text_editor

if TYPE_CHECKING:
Expand Down Expand Up @@ -102,35 +100,6 @@ def _check_updates(self) -> None:
check_latest_pypi(call_from_ui=True)
enter_to_continue()

@repeat_until_done
def _import_from_v4(self) -> None:
options_map = {
1: self._import_v4_config,
2: self._import_v4_download_history,
}
answer = user_prompts.import_cyberdrop_v4_items_prompt(self.manager)
return self._process_answer(answer, options_map)

def _import_v4_config(self) -> None:
new_config = user_prompts.import_v4_config_prompt(self.manager)
if not new_config:
return
transfer_v4_config(self.manager, *new_config)

def _import_v4_download_history(self) -> None:
import_download_history_path = user_prompts.import_v4_download_history_prompt()
if import_download_history_path.is_file():
transfer_v4_db(import_download_history_path, self.manager.path_manager.history_db)
return

for item in import_download_history_path.glob("**/*.sqlite"):
if str(item) == str(self.manager.path_manager.history_db):
continue
try:
transfer_v4_db(item, self.manager.path_manager.history_db)
except Exception as e:
self.print_error(f"Unable to import {item.name}: {e!s}")

def _change_config(self) -> None:
configs = self.manager.config_manager.get_configs()
selected_config = user_prompts.select_config(configs)
Expand Down
26 changes: 0 additions & 26 deletions cyberdrop_dl/ui/prompts/user_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
from cyberdrop_dl.utils.utilities import clear_term

if TYPE_CHECKING:
from pathlib import Path

from yarl import URL

from cyberdrop_dl.managers.manager import Manager
Expand Down Expand Up @@ -224,30 +222,6 @@ def filter_cache_urls(manager: Manager, domains: list) -> set[URL]:
return urls_to_remove


""" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ V4 IMPORT PROMPTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""


def import_cyberdrop_v4_items_prompt(manager: Manager) -> int:
"""Import Cyberdrop_V4 Items."""
prompt_header(manager)
OPTIONS = [["Import config", "Import download_history.sql"]]
choices = basic_prompts.create_choices(OPTIONS)
console.print("V4 Import Menu")
return basic_prompts.ask_choice(choices)


def import_v4_config_prompt(manager: Manager) -> tuple[str, Path] | None:
"""Asks the user for the name and path of the config to import. Returns `None` if the config name is invalid."""
new_config = create_new_config(manager, title="What should this config be called:")
if not new_config:
return None
return new_config, basic_prompts.ask_file_path("Select the config file to import:")


def import_v4_download_history_prompt() -> Path:
return basic_prompts.ask_file_path("Select the download_history.sql file to import:")


""" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ OTHERS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""


Expand Down
129 changes: 0 additions & 129 deletions cyberdrop_dl/utils/transfer/transfer_v4_config.py

This file was deleted.

34 changes: 0 additions & 34 deletions cyberdrop_dl/utils/transfer/transfer_v4_db.py

This file was deleted.

0 comments on commit dc2a83e

Please sign in to comment.