# Path: crowd_anki/utils/constants.py
# UUID_FIELD_NAME = 'crowdanki_uuid'
# DECK_FILE_NAME = "deck"
# DECK_FILE_EXTENSION = ".json"
# MEDIA_SUBDIRECTORY_NAME = "media"
# IMPORT_CONFIG_NAME = "import_config.yaml"
# ANKI_EXPORT_EXTENSION = "directory"
# USER_FILES_PATH = Path(__file__).parent.parent.joinpath('user_files')


import os
import anki.exporting
import anki.hooks
import anki.utils
import aqt.exporting
import aqt.utils
from aqt import QFileDialog
from aqt.exporting import ExportDialog
from ...utils import constants



# aqt part:


def exporter_changed(self, exporter_id):
    self.exporter = aqt.exporting.exporters(self.col)[exporter_id][1](self.col)
    self.frm.includeMedia.setVisible(hasattr(self.exporter, "includeMedia"))


def get_save_file(parent, title, dir_description, key, ext, fname=None):
    if ext == constants.ANKI_EXPORT_EXTENSION:
        directory = str(QFileDialog.getExistingDirectory(caption="Select Export Directory",
                                                         directory=fname))
        if directory:

# Path: crowd_anki/utils/constants.py
# UUID_FIELD_NAME = 'crowdanki_uuid'
# DECK_FILE_NAME = "deck"
# DECK_FILE_EXTENSION = ".json"
# MEDIA_SUBDIRECTORY_NAME = "media"
# IMPORT_CONFIG_NAME = "import_config.yaml"
# ANKI_EXPORT_EXTENSION = "directory"
# USER_FILES_PATH = Path(__file__).parent.parent.joinpath('user_files')


# Path: crowd_anki/anki/overrides/exporting.py
import os
import anki.exporting
import anki.hooks
import anki.utils
import aqt.exporting
import aqt.utils
from aqt import QFileDialog
from aqt.exporting import ExportDialog
from ...utils import constants




# aqt part:


def exporter_changed(self, exporter_id):
    self.exporter = aqt.exporting.exporters(self.col)[exporter_id][1](self.col)
    self.frm.includeMedia.setVisible(hasattr(self.exporter, "includeMedia"))


def get_save_file(parent, title, dir_description, key, ext, fname=None):
    if ext == constants.ANKI_EXPORT_EXTENSION:
        directory = str(QFileDialog.getExistingDirectory(caption="Select Export Directory",
                                                         directory=fname))
        if directory:

            return os.path.join(directory, str(anki.utils.intTime()))