コード例 #1
0
ファイル: main.py プロジェクト: Pipeliner/calibre
def get_library_path(parent=None):
    library_path = prefs['library_path']
    if library_path is None:  # Need to migrate to new database layout
        base = os.path.expanduser('~')
        if iswindows:
            base = winutil.special_folder_path(winutil.CSIDL_PERSONAL)
            if not base or not os.path.exists(base):
                from PyQt4.Qt import QDir
                base = unicode(QDir.homePath()).replace('/', os.sep)
        candidate = choose_dir(None, 'choose calibre library',
                _('Choose a location for your calibre e-book library'),
                default_dir=base)
        if not candidate:
            candidate = os.path.join(base, 'Calibre Library')
        library_path = os.path.abspath(candidate)
    if not os.path.exists(library_path):
        try:
            os.makedirs(library_path)
        except:
            error_dialog(parent, _('Failed to create library'),
                    _('Failed to create calibre library at: %r.')%library_path,
                    det_msg=traceback.format_exc(), show=True)
            library_path = choose_dir(parent, 'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
    return library_path
コード例 #2
0
 def choose_loc(self, *args):
     base = get_portable_base()
     if base is None:
         loc = choose_dir(self, "choose library location", _("Choose location for calibre library"))
     else:
         name = force_unicode("choose library loc at" + base, filesystem_encoding)
         loc = choose_dir(self, name, _("Choose location for calibre library"), default_dir=base, no_save_dir=True)
     if loc is not None:
         self.location.setText(loc)
コード例 #3
0
ファイル: main.py プロジェクト: suimong/calibre
    def initialize_db_stage2(self, db, tb):
        from calibre.db.legacy import LibraryDatabase

        if db is None and tb is not None:
            # DB Repair failed
            error_dialog(self.splash_screen, _('Repairing failed'),
                    _('The database repair failed. Starting with '
                        'a new empty library.'),
                    det_msg=tb, show=True)
        if db is None:
            candidate = choose_dir(self.splash_screen, 'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
            if not candidate:
                self.initialization_failed()

            try:
                self.library_path = candidate
                db = LibraryDatabase(candidate)
            except:
                error_dialog(self.splash_screen, _('Bad database location'),
                    _('Bad database location %r. calibre will now quit.'
                     )%self.library_path,
                    det_msg=traceback.format_exc(), show=True)
                self.initialization_failed()

        try:
            self.start_gui(db)
        except Exception:
            error_dialog(self.main, _('Startup error'),
                         _('There was an error during {0} startup.'
                           ' Parts of {0} may not function. Click Show details to learn more.').format(__appname__),
                         det_msg=traceback.format_exc(), show=True)
コード例 #4
0
ファイル: main.py プロジェクト: Jellby/PrincePDF
    def save_pdf(self, pdf_file, pdf_base_file):
        '''
        Save the PDF file in the final location
        :param pdf_file: The path to the PDF file
        :param pdf_base_file: The desired file name and relative path
        '''
        from os import rename, makedirs
        from os.path import basename, dirname, join, exists
        from calibre.constants import DEBUG
        from calibre.gui2 import choose_dir
        from calibre.gui2.dialogs.message_box import MessageBox
        from calibre.gui2 import error_dialog

        path = choose_dir(self.gui, 'save to disk dialog', _('Choose destination directory'))
        if not path:
            return
        save_file = join(path, pdf_base_file)
        base_dir = dirname(save_file)
        try:
            makedirs(base_dir)
        except BaseException:
            if not exists(base_dir): raise
        try:
            rename(pdf_file, save_file)
        except:
            error_dialog(self.gui, _('Could not save PDF'), _("Error writing the PDF file:\n%s" % save_file), show=True)
            return
        if DEBUG: print(save_file)
        MessageBox(MessageBox.INFO, _('File saved'), _("PDF file saved in:\n%s") % save_file).exec_()
コード例 #5
0
 def getDirectory(self):
     c = choose_dir(self, _(PLUGIN_NAME + 'dir_chooser'),
             _('Select Default Directory To Unpack Kindle Book/Mobi To'))
     if c:
         self.directory_txtBox.setReadOnly(False)
         self.directory_txtBox.setText(c)
         self.directory_txtBox.setReadOnly(True)
コード例 #6
0
ファイル: file_list.py プロジェクト: jelly/calibre
 def export_selected(self):
     names = self.selected_names
     if not names:
         return
     path = choose_dir(self, 'tweak_book_export_selected', _('Choose location'))
     if path:
         self.export_requested.emit(names, path)
コード例 #7
0
ファイル: catalog.py プロジェクト: Eksmo/calibre
    def catalog_generated(self, job):
        if job.result:
            # Problems during catalog generation
            # jobs.results is a list - the first entry is the intended title for the dialog
            # Subsequent strings are error messages
            dialog_title = job.result.pop(0)
            if re.match('warning:', job.result[0].lower()):
                msg = _("Catalog generation complete, with warnings.")
                warning_dialog(self.gui, dialog_title, msg, det_msg='\n'.join(job.result), show=True)
            else:
                job.result.append("Catalog generation terminated.")
                error_dialog(self.gui, dialog_title,'\n'.join(job.result),show=True)
                return

        if job.failed:
            return self.gui.job_exception(job)
        id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
        self.gui.library_view.model().reset()
        if job.catalog_sync:
            sync = dynamic.get('catalogs_to_be_synced', set([]))
            sync.add(id)
            dynamic.set('catalogs_to_be_synced', sync)
        self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
        self.gui.sync_catalogs()
        if job.fmt not in ['EPUB','MOBI']:
            export_dir = choose_dir(self.gui, _('Export Catalog Directory'),
                    _('Select destination for %(title)s.%(fmt)s') % dict(
                        title=job.catalog_title, fmt=job.fmt.lower()))
            if export_dir:
                destination = os.path.join(export_dir, '%s.%s' % (
                    sanitize_file_name_unicode(job.catalog_title), job.fmt.lower()))
                shutil.copyfile(job.catalog_file_path, destination)
コード例 #8
0
ファイル: main.py プロジェクト: Pipeliner/calibre
    def initialize_db_stage2(self, db, tb):

        if db is None and tb is not None:
            # DB Repair failed
            error_dialog(self.splash_screen, _('Repairing failed'),
                    _('The database repair failed. Starting with '
                        'a new empty library.'),
                    det_msg=tb, show=True)
        if db is None:
            candidate = choose_dir(self.splash_screen, 'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
            if not candidate:
                self.initialization_failed()

            try:
                self.library_path = candidate
                db = self.db_class(candidate)
            except:
                error_dialog(self.splash_screen, _('Bad database location'),
                    _('Bad database location %r. calibre will now quit.'
                     )%self.library_path,
                    det_msg=traceback.format_exc(), show=True)
                self.initialization_failed()

        self.start_gui(db)
コード例 #9
0
ファイル: __init__.py プロジェクト: 089git/calibre
 def choose_root_folder(self, *args):
     x = self.get_root_folder()
     if x is None:
         x = '~'
     x = choose_dir(self, 'add wizard choose root folder',
             _('Choose root folder'), default_dir=x)
     if x is not None:
         self.opt_root_folder.setText(os.path.abspath(x))
コード例 #10
0
ファイル: main.py プロジェクト: MinghuiGao/calibre
 def choose_dir(self, initial_dir):
     self.hide_splash_screen()
     return choose_dir(
         None,
         "choose calibre library",
         _("Choose a location for your new calibre e-book library"),
         default_dir=initial_dir,
     )
コード例 #11
0
 def directoryChooser(self):
     '''
     Select a folder, or use the one specified in the config widget.
     '''
     if cfg.plugin_prefs['Always_Use_Unpack_Folder']:
         return cfg.plugin_prefs['Unpack_Folder']
     else:
         return choose_dir(self.gui, _(PLUGIN_NAME + 'dir_chooser'),
             _('Select Directory To Unpack Kindle/Mobi Book To'))
コード例 #12
0
ファイル: add.py プロジェクト: fredchu/calibre
 def add_recursive(self, single):
     root = choose_dir(self.gui, 'recursive book import root dir dialog',
                       _('Select root folder'))
     if not root:
         return
     lp = os.path.normcase(os.path.abspath(self.gui.current_db.library_path))
     if lp.startswith(os.path.normcase(os.path.abspath(root)) + os.pathsep):
         return error_dialog(self.gui, _('Cannot add'), _(
             'Cannot add books from the folder: %s as it contains the currently opened calibre library') % root, show=True)
     self.do_add_recursive(root, single)
コード例 #13
0
ファイル: exim.py プロジェクト: AEliu/calibre
 def validate_export(self):
     path = choose_dir(self, 'export-calibre-dir', _('Choose a directory to export to'))
     if not path:
         return False
     if os.listdir(path):
         error_dialog(self, _('Export dir not empty'), _(
             'The directory you choose to export the data to must be empty.'), show=True)
         return False
     self.export_dir = path
     return True
コード例 #14
0
ファイル: add.py プロジェクト: yeyanchao/calibre
 def add_recursive(self, single):
     root = choose_dir(self.gui, 'recursive book import root dir dialog',
                       'Select root folder')
     if not root:
         return
     from calibre.gui2.add import Adder
     self._adder = Adder(self.gui,
             self.gui.library_view.model().db,
             self.Dispatcher(self._files_added), spare_server=self.gui.spare_server)
     self.gui.tags_view.disable_recounting = True
     self._adder.add_recursive(root, single)
コード例 #15
0
ファイル: exim.py プロジェクト: AEliu/calibre
 def select_import_folder(self):
     path = choose_dir(self, 'choose-export-folder-for-import', _('Select folder with exported data'))
     if path is None:
         return
     try:
         self.importer = Importer(path)
     except Exception as e:
         import traceback
         return error_dialog(self, _('Not valid'), _(
             'The folder {0} is not valid: {1}').format(path, as_unicode(e)), det_msg=traceback.format_exc(), show=True)
     self.setup_select_libraries_panel()
     self.import_panel.stack.setCurrentIndex(1)
コード例 #16
0
ファイル: add.py プロジェクト: yunfile123/calibre
 def add_recursive(self, single):
     root = choose_dir(self.gui, 'recursive book import root dir dialog',
                       _('Select root folder'))
     if not root:
         return
     lp = os.path.normcase(os.path.abspath(
         self.gui.current_db.library_path))
     if lp.startswith(os.path.normcase(os.path.abspath(root)) + os.pathsep):
         return error_dialog(
             self.gui,
             _('Cannot add'),
             _('Cannot add books from the folder: %s as it contains the currently opened calibre library'
               ) % root,
             show=True)
     self.do_add_recursive(root, single)
コード例 #17
0
ファイル: exim.py プロジェクト: qykth-git/calibre
 def validate_export(self):
     path = choose_dir(self, 'export-calibre-dir',
                       _('Choose a folder to export to'))
     if not path:
         return False
     if os.listdir(path):
         error_dialog(
             self,
             _('Export folder not empty'),
             _('The folder you choose to export the data to must be empty.'
               ),
             show=True)
         return False
     self.export_dir = path
     return True
コード例 #18
0
ファイル: save_to_disk.py プロジェクト: john-peterson/calibre
    def save_to_disk(self, checked, single_dir=False, single_format=None,
            rows=None, write_opf=None, save_cover=None):
        if rows is None:
            rows = self.gui.current_view().selectionModel().selectedRows()
        if not rows or len(rows) == 0:
            return error_dialog(self.gui, _('Cannot save to disk'),
                    _('No books selected'), show=True)
        path = choose_dir(self.gui, 'save to disk dialog',
                _('Choose destination directory'))
        if not path:
            return
        dpath = os.path.abspath(path).replace('/', os.sep)+os.sep
        lpath = self.gui.library_view.model().db.library_path.replace('/',
                os.sep)+os.sep
        if dpath.startswith(lpath):
            return error_dialog(self.gui, _('Not allowed'),
                    _('You are trying to save files into the calibre '
                      'library. This can cause corruption of your '
                      'library. Save to disk is meant to export '
                      'files from your calibre library elsewhere.'), show=True)

        if self.gui.current_view() is self.gui.library_view:
            from calibre.gui2.add import Saver
            from calibre.library.save_to_disk import config
            opts = config().parse()
            if single_format is not None:
                opts.formats = single_format
                # Special case for Kindle annotation files
                if single_format.lower() in ['mbp','pdr','tan']:
                    opts.to_lowercase = False
                    opts.save_cover = False
                    opts.write_opf = False
                    opts.template = opts.send_template
            opts.single_dir = single_dir
            if write_opf is not None:
                opts.write_opf = write_opf
            if save_cover is not None:
                opts.save_cover = save_cover
            self._saver = Saver(self.gui, self.gui.library_view.model().db,
                    Dispatcher(self._books_saved), rows, path, opts,
                    spare_server=self.gui.spare_server)

        else:
            paths = self.gui.current_view().model().paths(rows)
            self.gui.device_manager.save_books(
                    Dispatcher(self.books_saved), paths, path)
コード例 #19
0
 def select_import_folder(self):
     path = choose_dir(self, 'choose-export-folder-for-import',
                       _('Select folder with exported data'))
     if path is None:
         return
     try:
         self.importer = Importer(path)
     except Exception as e:
         import traceback
         return error_dialog(self,
                             _('Not valid'),
                             _('The folder {0} is not valid: {1}').format(
                                 path, as_unicode(e)),
                             det_msg=traceback.format_exc(),
                             show=True)
     self.setup_select_libraries_panel()
     self.import_panel.stack.setCurrentIndex(1)
コード例 #20
0
def create_theme(folder=None, parent=None):
    if folder is None:
        folder = choose_dir(parent, 'create-icon-theme-folder', _(
            'Choose a folder from which to read the icons'))
        if not folder:
            return
    report = read_theme_from_folder(folder)
    d = ThemeCreateDialog(parent, report)
    if d.exec_() != d.Accepted:
        return
    d.save_metadata()
    raw = create_themeball(d.report)
    dest = choose_save_file(parent, 'create-icon-theme-dest', _(
        'Choose destination for icon theme'),
        [(_('ZIP files'), ['zip'])], initial_filename='my-calibre-icon-theme.zip')
    if dest:
        with open(dest, 'wb') as f:
            f.write(raw)
コード例 #21
0
ファイル: icon_theme.py プロジェクト: Cyber-Ronin/calibre
def create_theme(folder=None, parent=None):
    if folder is None:
        folder = choose_dir(parent, 'create-icon-theme-folder', _(
            'Choose a folder from which to read the icons'))
        if not folder:
            return
    report = read_theme_from_folder(folder)
    d = ThemeCreateDialog(parent, report)
    if d.exec_() != d.Accepted:
        return
    d.save_metadata()
    raw, prefix = create_themeball(d.report)
    dest = choose_save_file(parent, 'create-icon-theme-dest', _(
        'Choose destination for icon theme'),
        [(_('ZIP files'), ['zip'])], initial_filename=prefix + '.zip')
    if dest:
        with open(dest, 'wb') as f:
            f.write(raw)
コード例 #22
0
ファイル: exim.py プロジェクト: zyhong/calibre
 def select_import_folder(self):
     path = choose_dir(self, 'choose-export-folder-for-import', _('Select folder with exported data'))
     if path is None:
         return
     if not question_dialog(self, _('Are you sure?'), _(
         'Importing calibre data means all libraries, settings, plugins, etc will be imported. This is'
         ' a security risk, only proceed if the data you are importing was previously generated by you, using the calibre'
         ' export functionality.'
         )):
         return
     try:
         self.importer = Importer(path)
     except Exception as e:
         import traceback
         return error_dialog(self, _('Not valid'), _(
             'The folder {0} is not valid: {1}').format(path, as_unicode(e)), det_msg=traceback.format_exc(), show=True)
     self.setup_select_libraries_panel()
     self.import_panel.stack.setCurrentIndex(1)
コード例 #23
0
    def initialize_db_stage2(self, db, tb):
        from calibre.db.legacy import LibraryDatabase

        if db is None and tb is not None:
            # DB Repair failed
            error_dialog(self.splash_screen,
                         _('Repairing failed'),
                         _('The database repair failed. Starting with '
                           'a new empty library.'),
                         det_msg=tb,
                         show=True)
        if db is None:
            candidate = choose_dir(
                self.splash_screen,
                'choose calibre library',
                _('Choose a location for your new calibre e-book library'),
                default_dir=get_default_library_path())
            if not candidate:
                self.initialization_failed()

            try:
                self.library_path = candidate
                db = LibraryDatabase(candidate)
            except:
                error_dialog(
                    self.splash_screen,
                    _('Bad database location'),
                    _('Bad database location %r. calibre will now quit.') %
                    self.library_path,
                    det_msg=traceback.format_exc(),
                    show=True)
                self.initialization_failed()

        try:
            self.start_gui(db)
        except Exception:
            error_dialog(
                self.main,
                _('Startup error'),
                _('There was an error during {0} startup.'
                  ' Parts of {0} may not function. Click Show details to learn more.'
                  ).format(__appname__),
                det_msg=traceback.format_exc(),
                show=True)
コード例 #24
0
    def save_to_disk(self, checked, single_dir=False, single_format=None,
            rows=None, write_opf=None, save_cover=None):
        if rows is None:
            rows = self.gui.current_view().selectionModel().selectedRows()
        if not rows or len(rows) == 0:
            return error_dialog(self.gui, _('Cannot save to disk'),
                    _('No books selected'), show=True)
        path = choose_dir(self.gui, 'save to disk dialog',
                _('Choose destination directory'))
        if not path:
            return
        dpath = os.path.abspath(path).replace('/', os.sep)+os.sep
        lpath = self.gui.library_view.model().db.library_path.replace('/',
                os.sep)+os.sep
        if dpath.startswith(lpath):
            return error_dialog(self.gui, _('Not allowed'),
                    _('You are trying to save files into the calibre '
                      'library. This can cause corruption of your '
                      'library. Save to disk is meant to export '
                      'files from your calibre library elsewhere.'), show=True)

        if self.gui.current_view() is self.gui.library_view:
            from calibre.gui2.save import Saver
            from calibre.library.save_to_disk import config
            opts = config().parse()
            if single_format is not None:
                opts.formats = single_format
                # Special case for Kindle annotation files
                if single_format.lower() in ['mbp','pdr','tan']:
                    opts.to_lowercase = False
                    opts.save_cover = False
                    opts.write_opf = False
                    opts.template = opts.send_template
            opts.single_dir = single_dir
            if write_opf is not None:
                opts.write_opf = write_opf
            if save_cover is not None:
                opts.save_cover = save_cover
            book_ids = set(map(self.gui.library_view.model().id, rows))
            Saver(book_ids, self.gui.current_db, opts, path, parent=self.gui, pool=self.gui.spare_pool())
        else:
            paths = self.gui.current_view().model().paths(rows)
            self.gui.device_manager.save_books(
                    Dispatcher(self.books_saved), paths, path)
コード例 #25
0
ファイル: catalog.py プロジェクト: JimmXinu/calibre
    def catalog_generated(self, job):
        if job.result:
            # Problems during catalog generation
            # jobs.results is a list - the first entry is the intended title for the dialog
            # Subsequent strings are error messages
            dialog_title = job.result.pop(0)
            if re.search('warning', job.result[0].lower()):
                msg = _("Catalog generation complete, with warnings.")
                warning_dialog(self.gui, dialog_title, msg, det_msg='\n'.join(job.result), show=True)
            else:
                job.result.append("Catalog generation terminated.")
                error_dialog(self.gui, dialog_title,'\n'.join(job.result),show=True)
                return

        if job.failed:
            return self.gui.job_exception(job)
        if dynamic.get('catalog_add_to_library', True):
            id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
            self.gui.library_view.model().beginResetModel(), self.gui.library_view.model().endResetModel()
            if job.catalog_sync:
                sync = dynamic.get('catalogs_to_be_synced', set([]))
                sync.add(id)
                dynamic.set('catalogs_to_be_synced', sync)
        self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
        self.gui.sync_catalogs()
        if not dynamic.get('catalog_add_to_library', True) or job.fmt not in {'EPUB','MOBI', 'AZW3'}:
            export_dir = choose_dir(self.gui, _('Export Catalog Directory'),
                    _('Select destination for %(title)s.%(fmt)s') % dict(
                        title=job.catalog_title, fmt=job.fmt.lower()))
            if export_dir:
                destination = os.path.join(export_dir, '%s.%s' % (
                    sanitize_file_name(job.catalog_title), job.fmt.lower()))
                try:
                    shutil.copyfile(job.catalog_file_path, destination)
                except EnvironmentError as err:
                    if getattr(err, 'errno', None) == errno.EACCES:  # Permission denied
                        import traceback
                        error_dialog(self.gui, _('Permission denied'),
                                _('Could not open %s. Is it being used by another'
                                ' program?')%destination, det_msg=traceback.format_exc(),
                                show=True)
                        return
                    raise
コード例 #26
0
    def catalog_generated(self, job):
        if job.result:
            # Problems during catalog generation
            # jobs.results is a list - the first entry is the intended title for the dialog
            # Subsequent strings are error messages
            dialog_title = job.result.pop(0)
            if re.search('warning', job.result[0].lower()):
                msg = _("Catalog generation complete, with warnings.")
                warning_dialog(self.gui, dialog_title, msg, det_msg='\n'.join(job.result), show=True)
            else:
                job.result.append("Catalog generation terminated.")
                error_dialog(self.gui, dialog_title,'\n'.join(job.result),show=True)
                return

        if job.failed:
            return self.gui.job_exception(job)
        if dynamic.get('catalog_add_to_library', True):
            id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
            self.gui.library_view.model().beginResetModel(), self.gui.library_view.model().endResetModel()
            if job.catalog_sync:
                sync = dynamic.get('catalogs_to_be_synced', set())
                sync.add(id)
                dynamic.set('catalogs_to_be_synced', sync)
        self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
        self.gui.sync_catalogs()
        if not dynamic.get('catalog_add_to_library', True) or job.fmt not in {'EPUB','MOBI', 'AZW3'}:
            export_dir = choose_dir(self.gui, _('Export Catalog Directory'),
                    _('Select destination for %(title)s.%(fmt)s') % dict(
                        title=job.catalog_title, fmt=job.fmt.lower()))
            if export_dir:
                destination = os.path.join(export_dir, '%s.%s' % (
                    sanitize_file_name(job.catalog_title), job.fmt.lower()))
                try:
                    shutil.copyfile(job.catalog_file_path, destination)
                except EnvironmentError as err:
                    if getattr(err, 'errno', None) == errno.EACCES:  # Permission denied
                        import traceback
                        error_dialog(self.gui, _('Permission denied'),
                                _('Could not open %s. Is it being used by another'
                                ' program?')%destination, det_msg=traceback.format_exc(),
                                show=True)
                        return
                    raise
コード例 #27
0
    def catalog_generated(self, job):
        if job.result:
            # Problems during catalog generation
            # jobs.results is a list - the first entry is the intended title for the dialog
            # Subsequent strings are error messages
            dialog_title = job.result.pop(0)
            if re.match('warning:', job.result[0].lower()):
                msg = _("Catalog generation complete, with warnings.")
                warning_dialog(self.gui,
                               dialog_title,
                               msg,
                               det_msg='\n'.join(job.result),
                               show=True)
            else:
                job.result.append("Catalog generation terminated.")
                error_dialog(self.gui,
                             dialog_title,
                             '\n'.join(job.result),
                             show=True)
                return

        if job.failed:
            return self.gui.job_exception(job)
        id = self.gui.library_view.model().add_catalog(job.catalog_file_path,
                                                       job.catalog_title)
        self.gui.library_view.model().reset()
        if job.catalog_sync:
            sync = dynamic.get('catalogs_to_be_synced', set([]))
            sync.add(id)
            dynamic.set('catalogs_to_be_synced', sync)
        self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
        self.gui.sync_catalogs()
        if job.fmt not in ['EPUB', 'MOBI']:
            export_dir = choose_dir(
                self.gui, _('Export Catalog Directory'),
                _('Select destination for %(title)s.%(fmt)s') %
                dict(title=job.catalog_title, fmt=job.fmt.lower()))
            if export_dir:
                destination = os.path.join(
                    export_dir, '%s.%s' % (sanitize_file_name_unicode(
                        job.catalog_title), job.fmt.lower()))
                shutil.copyfile(job.catalog_file_path, destination)
コード例 #28
0
ファイル: __init__.py プロジェクト: aimylios/calibre
    def change(self):
        from calibre.db.legacy import LibraryDatabase
        x = choose_dir(self, 'database location dialog',
                         _('Select location for books'))
        if x:
            if (iswindows and len(x) > LibraryDatabase.WINDOWS_LIBRARY_PATH_LIMIT):
                return error_dialog(self, _('Too long'),
                    _('Path to library too long. Must be less than'
                    ' %d characters.')%(LibraryDatabase.WINDOWS_LIBRARY_PATH_LIMIT),
                    show=True)
            if not os.path.exists(x):
                try:
                    os.makedirs(x)
                except:
                    return error_dialog(self, _('Bad location'),
                            _('Failed to create a folder at %s')%x,
                            det_msg=traceback.format_exc(), show=True)

            if self.is_library_dir_suitable(x):
                self.location.setText(x)
            else:
                self.show_library_dir_error(x)
コード例 #29
0
ファイル: icon_theme.py プロジェクト: yunfile123/calibre
def create_theme(folder=None, parent=None):
    if folder is None:
        folder = choose_dir(parent, 'create-icon-theme-folder', _(
            'Choose a folder from which to read the icons'))
        if not folder:
            return
    report = read_theme_from_folder(folder)
    d = ThemeCreateDialog(parent, report)
    if d.exec_() != d.Accepted:
        return
    d.save_metadata()
    d = Compress(d.report, parent=parent)
    d.exec_()
    if d.wasCanceled() or d.raw is None:
        return
    raw, prefix = d.raw, d.prefix
    dest = choose_save_file(parent, 'create-icon-theme-dest', _(
        'Choose destination for icon theme'),
        [(_('ZIP files'), ['zip'])], initial_filename=prefix + '.zip')
    if dest:
        with lopen(dest, 'wb') as f:
            f.write(raw)
コード例 #30
0
    def change(self):
        from calibre.db.legacy import LibraryDatabase
        x = choose_dir(self, 'database location dialog',
                         _('Select location for books'))
        if x:
            if (iswindows and len(x) > LibraryDatabase.WINDOWS_LIBRARY_PATH_LIMIT):
                return error_dialog(self, _('Too long'),
                    _('Path to library too long. Must be less than'
                    ' %d characters.')%(LibraryDatabase.WINDOWS_LIBRARY_PATH_LIMIT),
                    show=True)
            if not os.path.exists(x):
                try:
                    os.makedirs(x)
                except:
                    return error_dialog(self, _('Bad location'),
                            _('Failed to create a folder at %s')%x,
                            det_msg=traceback.format_exc(), show=True)

            if self.is_library_dir_suitable(x):
                self.location.setText(x)
            else:
                self.show_library_dir_error(x)
コード例 #31
0
ファイル: adding.py プロジェクト: HaraldGustafsson/calibre
 def choose_aa_path(self):
     path = choose_dir(self, 'auto add path choose',
             _('Choose a folder'))
     if path:
         self.opt_auto_add_path.setText(path)
コード例 #32
0
ファイル: debug.py プロジェクト: 089git/calibre
 def set_debug_dir(self):
     x = choose_dir(self, 'conversion debug dir', _('Choose debug folder'))
     if x:
         self.opt_debug_pipeline.setText(x)
コード例 #33
0
 def browse(self):
     d = choose_dir(self, "choose_library_for_copy", _("Choose Library"))
     if d:
         self.le.setText(d)
コード例 #34
0
 def choose_dir(self, initial_dir):
     self.hide_splash_screen()
     return choose_dir(None, 'choose calibre library',
             _('Choose a location for your new calibre e-book library'),
             default_dir=initial_dir)
コード例 #35
0
ファイル: copy_to_library.py プロジェクト: pselle/calibre
 def browse(self):
     d = choose_dir(self, 'choose_library_for_copy',
                    _('Choose Library'))
     if d:
         self.le.setText(d)
コード例 #36
0
 def choose_loc(self, *args):
     loc = choose_dir(self, 'choose library location',
             _('Choose location for calibre library'))
     if loc is not None:
         self.location.setText(loc)
コード例 #37
0
 def set_debug_dir(self):
     x = choose_dir(self, 'conversion debug dir', _('Choose debug folder'))
     if x:
         self.opt_debug_pipeline.setText(x)
コード例 #38
0
ファイル: choose_library.py プロジェクト: AtulKumar2/calibre
 def choose_dir(self):
     d = choose_dir(self, 'library moved choose new loc',
             _('New library location'), default_dir=self.oldloc)
     if d is not None:
         self.loc.setText(d)
コード例 #39
0
 def add_recursive(self, single):
     root = choose_dir(self.gui, 'recursive book import root dir dialog',
                       _('Select root folder'))
     if not root:
         return
     self.do_add_recursive(root, single)
コード例 #40
0
 def choose_dir(self):
     d = choose_dir(self, 'library moved choose new loc',
             _('New library location'), default_dir=self.oldloc)
     if d is not None:
         self.loc.setText(d)
コード例 #41
0
ファイル: add.py プロジェクト: Hainish/calibre
 def add_recursive(self, single):
     root = choose_dir(self.gui, 'recursive book import root dir dialog',
                       _('Select root folder'))
     if not root:
         return
     self.do_add_recursive(root, single)
コード例 #42
0
ファイル: exim.py プロジェクト: AEliu/calibre
 def select_folder(self):
     path = choose_dir(self, 'select-folder-for-imported-library', _('Choose a folder for this library'))
     if path is not None:
         self.le.setText(path)
コード例 #43
0
ファイル: config.py プロジェクト: auspex/sonyutilities
 def _get_dest_directory_name(self):
     path = choose_dir(self, 'backup annotations destination dialog','Choose destination directory')
     if path:
         self.dest_directory_edit.setText(path)
コード例 #44
0
ファイル: adding.py プロジェクト: botmtl/calibre
 def choose_aa_path(self):
     path = choose_dir(self, "auto add path choose", _("Choose a folder"))
     if path:
         self.opt_auto_add_path.setText(path)
コード例 #45
0
ファイル: adding.py プロジェクト: wynick27/calibre
 def choose_aa_path(self):
     path = choose_dir(self, 'auto add path choose', _('Choose a folder'))
     if path:
         self.opt_auto_add_path.setText(path)
コード例 #46
0
 def browse(self):
     d = choose_dir(self, 'choose_library_for_copy', _('Choose Library'))
     if d:
         self.le.setText(d)
コード例 #47
0
ファイル: main.py プロジェクト: artbycrunk/calibre
 def choose_dir(self, initial_dir):
     self.hide_splash_screen()
     return choose_dir(self.splash_screen, 'choose calibre library',
             _('Choose a location for your new calibre e-book library'),
             default_dir=initial_dir)
コード例 #48
0
 def select_folder(self):
     path = choose_dir(self, 'select-folder-for-imported-library',
                       _('Choose a folder for this library'))
     if path is not None:
         self.le.setText(path)