├── plugin-import-name-mass_search_replace.txt ├── images ├── export.png ├── import.png ├── plugin.png ├── warning.png ├── image_add.png ├── mass_search_replace.xcf ├── find_replace.svg └── saved-search.svg ├── .gitmodules ├── static ├── Mass_Search-Replace-context.png ├── Mass_Search-Replace-config-menu.png ├── Mass_Search-Replace-config-operation.png └── Mass_Search-Replace-operations-list.png ├── .gitignore ├── search_replace ├── text.py └── __init__.py ├── pyproject.toml ├── readme.bbcode ├── __init__.py ├── changelog.md ├── README.md ├── translations ├── default.pot ├── es.po └── fr.po ├── action.py ├── LICENSE └── config.py /plugin-import-name-mass_search_replace.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/images/export.png -------------------------------------------------------------------------------- /images/import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/images/import.png -------------------------------------------------------------------------------- /images/plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/images/plugin.png -------------------------------------------------------------------------------- /images/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/images/warning.png -------------------------------------------------------------------------------- /images/image_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/images/image_add.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "common_utils"] 2 | path = common_utils 3 | url = https://github.com/un-pogaz/common_utils.git 4 | -------------------------------------------------------------------------------- /images/mass_search_replace.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/images/mass_search_replace.xcf -------------------------------------------------------------------------------- /static/Mass_Search-Replace-context.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/static/Mass_Search-Replace-context.png -------------------------------------------------------------------------------- /static/Mass_Search-Replace-config-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/static/Mass_Search-Replace-config-menu.png -------------------------------------------------------------------------------- /static/Mass_Search-Replace-config-operation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/static/Mass_Search-Replace-config-operation.png -------------------------------------------------------------------------------- /static/Mass_Search-Replace-operations-list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/HEAD/static/Mass_Search-Replace-operations-list.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## gitignore 2 | ## https://git-scm.com/docs/gitignore 3 | ## 4 | 5 | __pycache__/ 6 | .ruff_cache/ 7 | .vscode/ 8 | --*/ 9 | zz* 10 | *.lnk 11 | *.url 12 | *.mo 13 | MobileRead_post.bbcode 14 | -------------------------------------------------------------------------------- /search_replace/text.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2020, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | 13 | SEARCH_FIELD = _('You must specify a "Search field"') 14 | 15 | 16 | class FIELD_NAME: 17 | REPLACE_FUNC = _('Case to be applied') 18 | REPLACE_MODE = _('Replace mode') 19 | SEARCH_MODE = _('Search mode') 20 | IDENTIFIER_TYPE = _('Identifier type') 21 | 22 | 23 | S_R_REPLACE = _('Replace field') 24 | REPLACE_REGEX = '(?msi)^.*$' 25 | REPLACE_HEADING = _('In field replacement mode, the specified field is set to the text and all previous values are erased. ' 26 | 'After replacement is finished, the text can be changed to upper-case, lower-case, or title-case.') 27 | 28 | TEMPLATE_BUTTON_ToolTip = _('Open the template editor') 29 | 30 | EXCEPTION_Invalid_identifier = _('Invalid identifier string. It must be a comma-separated list of pairs of strings separated by a colon.') 31 | 32 | 33 | def get_empty_field(field): 34 | return _('The field "{:s}" is not defined').format(field) 35 | 36 | 37 | def get_for_invalid_value(field, value): 38 | return _('The operation field "{:s}" contains a invalid value ({:s}).').format(field, value) 39 | 40 | 41 | def get_for_localized_field(field, value): 42 | return get_for_invalid_value(field, value)+'\n'+_('The value of this field is localized (translated). This can cause problems when using settings shared on internet or when changing the user interface language.') 43 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [project] 2 | name = "Mass Search/Replace" 3 | requires-python = ">=3.8" 4 | 5 | [tool.ruff] 6 | exclude = ["common_utils/"] 7 | line-length = 120 8 | target-version = "py38" 9 | builtins = ['_', 'I', 'P'] 10 | preview = true 11 | 12 | [tool.ruff.lint] 13 | explicit-preview-rules = true 14 | ignore = [ 15 | 'E741', 'E402', 'E722', 'W293', 16 | 'UP012', 'UP030', 'UP032', 'C413', 'C420', 'PIE790', 'ISC003', 17 | 'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF012', 'RUF013', 'RUF015', 'RUF100', 18 | 'F841', # because in preview, unused tuple unpacking variable that not use dummy syntax (prefix '_' underscore) 19 | # raise error 'unused-variable', sigh (https://github.com/astral-sh/ruff/issues/8884) 20 | ] 21 | select = [ 22 | 'E', 'F', 'I', 'W', 'INT', 23 | 'Q', 'UP', 'YTT', 'C4', 'COM818', 'PIE', 'RET501', 'ISC', 24 | 'RUF', # nota: RUF can flag many unsolicited errors 25 | # preview rules 26 | 'RUF051', 'RUF056', # useless dict operation 27 | 'RUF055', # unnecessary regex 28 | 'RUF039', # always use raw-string for regex 29 | 'E302', 'E303', 'E304', 'E305', 'W391', # blank-line standard 30 | 'E111', 'E112', 'E113', 'E117', # code indentation 31 | 'E114', 'E115', 'E116', 'E261', 'E262', 'E265', # comment formating 32 | 'E201', 'E202', 'E211', 'E251', 'E275', # + partial: 'E203', 'E222', 'E241', 'E271', 'E272' # various whitespace 33 | ] 34 | unfixable = ['ISC001'] 35 | 36 | [tool.ruff.lint.per-file-ignores] 37 | "search_replace/*.py" = ['E501'] 38 | 39 | [tool.ruff.format] 40 | quote-style = 'single' 41 | 42 | [tool.ruff.lint.isort] 43 | detect-same-package = true 44 | known-first-party = ["calibre", "calibre_extensions", "calibre_plugins", "polyglot"] 45 | known-third-party = ["qt"] 46 | relative-imports-order = "closest-to-furthest" 47 | split-on-trailing-comma = false 48 | section-order = ["__python__", "future", "standard-library", "third-party", "first-party", "local-folder"] 49 | 50 | [tool.ruff.lint.isort.sections] 51 | "__python__" = ["__python__"] 52 | 53 | [tool.ruff.lint.flake8-comprehensions] 54 | allow-dict-calls-with-keyword-arguments = true 55 | 56 | [tool.ruff.lint.flake8-quotes] 57 | avoid-escape = true 58 | docstring-quotes = 'single' 59 | inline-quotes = 'single' 60 | multiline-quotes = 'single' 61 | -------------------------------------------------------------------------------- /images/find_replace.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 21 | 23 | image/svg+xml 24 | 26 | 27 | 28 | 29 | 30 | 32 | 54 | 61 | 68 | 69 | 73 | 77 | 85 | 86 | -------------------------------------------------------------------------------- /readme.bbcode: -------------------------------------------------------------------------------- 1 | [I]Mass Search/Replace[/I] is a small plugin to facilitate the execution of one or more of your favorite Search and Replace operations to your books metadata. 2 | 3 | Each entry in the context menu will launch a list of Search/Replace operations that you have previously set up. Setting up an operation uses the Calibre Search and Replace module. 4 | 5 | The plugin has the following features: 6 | [LIST] 7 | [*]Editable context menu 8 | [*]Editables operations list 9 | [*]Error Strategy 10 | [*]Quick Search/Replace on various range: Selection, Current Search, Virtual library, Library. 11 | [*]Shared Search/Replace operation: set in once, used where you want, edit them and all reference has edited (compatible with Calibre saved Search/Replace system) 12 | [/LIST] 13 | 14 | Available operation type: 15 | [LIST] 16 | [*]Character match 17 | [*]Regular expression 18 | [*]Replace field 19 | [/LIST] 20 | 21 | To use a "Shared Search/Replace operation", create and save a operation in the Calibre combo box, or select one that already exist. 22 | Important, don't edit any field after having select the "Shared operation" or the link will be broken. To edit a "Shared operation", it will have to be re-registered with the same name in the Calibre saved Search/Replace system. 23 | Once the "Shared operation" corrrectly save, the name of this one will appear in operations list. 24 | 25 | [B]Special Notes:[/B] 26 | [LIST] 27 | [*]Uses the Calibre Search/Replace module. 28 | [*][COLOR="Red"][B]You can destroy your library using this plugin.[/B] Changes are permanent. There is no undo function. You are strongly encouraged to back up your library before proceeding.[/COLOR] 29 | [/LIST] 30 | 31 | [B]Credits:[/B] 32 | [LIST] 33 | [*]The icon dialog and the dynamic menus for chains are based on code from the Open With plugin by kiwidude. 34 | [*]The Calibre Actions is based on code from the Favourites Menu plugin by kiwidude. 35 | [*]The module editor is based on calibre editor function editor by Kovid Goyal. 36 | [*]The Search and Replace Action is based on calibre's search and replace. (chaley and Kovid Goyal) 37 | [*]Thanks to capink and its plugin [URL=https://www.mobileread.com/forums/showthread.php?t=334974]Action Chains[/URL] without which this one wouldn't exist. 38 | [/LIST] 39 | 40 | [B]Installation[/B] 41 | Open [I]Preferences -> Plugins -> Get new plugins[/I] and install the "Mass Search/Replace" plugin. 42 | You may also download the attached zip file and install the plugin manually, then restart calibre as described in the [URL="https://www.mobileread.com/forums/showthread.php?t=118680"]Introduction to plugins thread[/URL] 43 | 44 | The plugin works for Calibre 5 and later. 45 | 46 | Page: [URL=https://github.com/un-pogaz/Mass-Search-Replace]GitHub[/URL] | [URL=https://www.mobileread.com/forums/showthread.php?t=335417]MobileRead[/URL] 47 | 48 | [U]Note for those who wish to provide a translation:[/U] 49 | I am [I]French[/I]! Although for obvious reasons, the default language of the plugin is English, keep in mind that already a translation. 50 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2020, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | # The class that all Interface Action plugin wrappers must inherit from 13 | from calibre.customize import InterfaceActionBase 14 | 15 | 16 | class ActionMassSearchReplace(InterfaceActionBase): 17 | ''' 18 | This class is a simple wrapper that provides information about the actual 19 | plugin class. The actual interface plugin class is called InterfacePlugin 20 | and is defined in the ui.py file, as specified in the actual_plugin field 21 | below. 22 | 23 | The reason for having two classes is that it allows the command line 24 | calibre utilities to run without needing to load the GUI libraries. 25 | ''' 26 | name = 'Mass Search-Replace' 27 | description = _('Easily apply a list of multiple saved Find and Replace operations ' 28 | 'to your books metadata') 29 | supported_platforms = ['windows', 'osx', 'linux'] 30 | author = 'un_pogaz' 31 | version = (1, 8, 5) 32 | minimum_calibre_version = (5, 0, 0) 33 | 34 | # This field defines the GUI plugin class that contains all the code 35 | # that actually does something. Its format is module_path:class_name 36 | # The specified class must be defined in the specified module. 37 | actual_plugin = __name__+'.action:MassSearchReplaceAction' 38 | 39 | def is_customizable(self): 40 | ''' 41 | This method must return True to enable customization via 42 | Preferences->Plugins 43 | ''' 44 | return True 45 | 46 | def config_widget(self): 47 | ''' 48 | Implement this method and :meth:`save_settings` in your plugin to 49 | use a custom configuration dialog. 50 | 51 | This method, if implemented, must return a QWidget. The widget can have 52 | an optional method validate() that takes no arguments and is called 53 | immediately after the user clicks OK. Changes are applied if and only 54 | if the method returns True. 55 | 56 | If for some reason you cannot perform the configuration at this time, 57 | return a tuple of two strings (message, details), these will be 58 | displayed as a warning dialog to the user and the process will be 59 | aborted. 60 | 61 | The base class implementation of this method raises NotImplementedError 62 | so by default no user configuration is possible. 63 | ''' 64 | # It is important to put this import statement here rather than at the 65 | # top of the module as importing the config class will also cause the 66 | # GUI libraries to be loaded, which we do not want when using calibre 67 | # from the command line 68 | if self.actual_plugin_: 69 | from .config import ConfigWidget 70 | return ConfigWidget() 71 | 72 | def save_settings(self, config_widget): 73 | ''' 74 | Save the settings specified by the user with config_widget. 75 | 76 | :param config_widget: The widget returned by :meth:`config_widget`. 77 | ''' 78 | config_widget.save_settings() 79 | if self.actual_plugin_: 80 | self.actual_plugin_.rebuild_menus() 81 | 82 | 83 | # For testing, run from command line with this: 84 | # calibre-debug -e __init__.py 85 | if __name__ == '__main__': 86 | from calibre.gui2 import Application 87 | from calibre.gui2.preferences import test_widget 88 | app = Application([]) 89 | test_widget('Advanced', 'Plugins') 90 | -------------------------------------------------------------------------------- /images/saved-search.svg: -------------------------------------------------------------------------------- 1 | 2 | 20 | 22 | 23 | 25 | image/svg+xml 26 | 28 | 29 | 30 | 31 | 32 | 34 | 37 | 41 | 45 | 46 | 55 | 56 | 78 | 85 | 92 | 93 | 100 | 103 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog - Mass Search/Replace 2 | 3 | ## [1.8.5] - 2025/10/09 4 | 5 | ### Bug fixes 6 | - fix previous patch 7 | 8 | ## [1.8.4] - 2025/10/09 9 | 10 | ### Bug fixes 11 | - fix edge case for malformed comments custom columns 12 | 13 | ## [1.8.3] - 2025/09/29 14 | 15 | ### Bug fixes 16 | - fix fatal freeze on linux 17 | 18 | ## [1.8.2] - 2024/02/19 19 | 20 | ### Bug fixes 21 | - Fix some untranslated string 22 | 23 | ## [1.8.1] - 2024/01/27 24 | 25 | ### Bug fixes 26 | - Fix wrong text display when customizing keyboard shortcut 27 | 28 | ## [1.8.0] - 2023/11/17 29 | 30 | ### Changed 31 | - Drop Python 2 / Calibre 4 compatibility, only Calibre 5 and above 32 | 33 | ## [1.7.5] - 2023/10/07 34 | 35 | ### Bug fixes 36 | - Fix NotImplementedError: set() cannot be used in this context. ProxyMetadata is read only 37 | 38 | ## [1.7.4] - 2023/09/31 39 | 40 | ### Bug fixes 41 | - Don't update the config file when Calibre start 42 | 43 | ## [1.7.3] - 2023/05/31 44 | 45 | ### Bug fixes 46 | - Fix columns list not the same as Calibre 47 | 48 | ## [1.7.2] - 2023/04/12 49 | 50 | ### Bug fixes 51 | - Fix active statue of Shared Search/Replace operation not conserved (always active) 52 | 53 | ## [1.7.1] - 2023/02/03 54 | 55 | ### Bug fixes 56 | - Fix broken compatibility with 6.12 (use a icon instead of a red border to warn about a regex error) 57 | 58 | ## [1.7.0] - 2022/10/19 59 | 60 | ### Changed 61 | - Again, big rework of common_utils (use submodule) 62 | 63 | ## [1.6.1] - 2022/10/17 64 | 65 | ### Bug fixes 66 | - Fix a error when a user categorie exist in the library 67 | 68 | ## [1.6.0] - 2022/10/11 69 | 70 | ### Changed 71 | - Big rework of common_utils.py 72 | 73 | ## [1.5.1] - 2022/09/08 74 | 75 | ### Bug fixes 76 | - Fix a bug where the books are marked, even if an error has occurred in restore books 77 | - Icon not display when a theme colors is used 78 | 79 | ## [1.5.0] - 2022/08/17 80 | 81 | ### Changed 82 | - Rework of the Quick Search/Replace for add alternatives range target (Selection / Current Search / Virtual library / Library) 83 | 84 | ## [1.4.5] - 2022/08/06 85 | 86 | ### Changed 87 | - Improvement of the 'Replace Field' mode 88 | 89 | ## [1.4.4] - 2022/07/20 90 | 91 | ### Changed 92 | - Small incompatibility Calibre6/Qt6 93 | 94 | ## [1.4.3] - 2022/07/11 95 | 96 | ### Changed 97 | - More compatibility Calibre6/Qt6 98 | 99 | ## [1.4.2] - 2022/03/11 100 | 101 | ### Changed 102 | - Small improvement for identifier operation 103 | 104 | ## [1.4.1] - 2022/02/25 105 | 106 | ### Bug fixes 107 | - Calibre Search/Replace operation are not saved if it contains an error 108 | 109 | ## [1.4.0] - 2022/02/25 110 | 111 | ### Added 112 | - Shared Search/Replace operation: set in once, used where you want, edit them and all reference has edited
Uses and compatible with Calibre saved Search/Replace system 113 | 114 | ## [1.3.3] - 2022/02/24 115 | 116 | ### Bug fixes 117 | - Fix the fix of Calibre saved Search/Replace operation 118 | 119 | ## [1.3.2] - 2022/02/23 120 | 121 | ### Bug fixes 122 | - The Calibre saved Search/Replace operation could not be loaded 123 | 124 | ## [1.3.1] - 2022/02/22 125 | 126 | ### Changed 127 | - Various technical improvement 128 | 129 | ## [1.3.0] - 2022/01/04 130 | 131 | ### Changed 132 | - Compatible Calibre6/Qt6 133 | 134 | ## [1.2.2] - 2021/07/01 135 | 136 | ### Bug fixes 137 | - Fix wrong error message when an error occurs during the update of the library 138 | 139 | ## [1.2.1] - 2021/06/08 140 | 141 | ### Bug fixes 142 | - Fix ghost identifier with empty value 143 | 144 | ## [1.2.0] - 2021/05/28 145 | 146 | ### Added 147 | - Add a 'Replace Field' mode that replace any values with the specified string 148 | 149 | ### Bug fixes 150 | - Fix freeze when your config the settings of operations when many books are selected 151 | - Fix the displaying of a error in dialog 152 | 153 | ## [1.1.0] - 2021/05/25 154 | 155 | ### Bug fixes 156 | - Improved handling of errors with invalid identifiers 157 | 158 | ## [1.0.2] - 2021/05/16 159 | 160 | ### Bug fixes 161 | - Fix invalide identifier with colon 162 | 163 | ## [1.0.1] - 2021/02/12 164 | 165 | ### Bug fixes 166 | - Fix error in search mode "Character match" 167 | 168 | ## [1.0.0] - 2021/01/18 169 | 170 | ### Full release 171 | 172 | ### Bug fixes 173 | - Fix regression with case sensitivity 174 | 175 | ## [0.9.3] - 2020/12/08 176 | 177 | ### Added 178 | - Add Spanish translation. Thanks *dunhill* 179 | 180 | ## [0.9.2] - 2020/12/08 181 | 182 | ### Bug fixes 183 | - Fix case for the test result field 184 | - Fix detection of None and inchanged value 185 | 186 | ## [0.9.1] - 2020/12/07 187 | 188 | ### Bug fixes 189 | - Fix library switch 190 | 191 | ## [0.9.0] - 2020/12/06 192 | 193 | ### First release 194 | - Beta public test 195 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mass Search/Replace 2 | [![MobileRead][mobileread-image]][mobileread-url] 3 | [![History][changelog-image]][changelog-url] 4 | [![License][license-image]][license-url] 5 | [![calibre Version][calibre-image]][calibre-url] 6 | [![Status][status-image]][status-image] 7 | 8 | 9 | *Mass Search/Replace* is a small plugin to facilitate the execution of one or more of your favorite Search and Replace operations to your books metadata. 10 | 11 | Each entry in the context menu will launch a list of Search/Replace operations that you have previously set up. Setting up an operation uses the Calibre Search and Replace module. 12 | 13 | The plugin has the following features: 14 | 15 | * Editable context menu 16 | * Editables operations list 17 | * Error Strategy 18 | * Quick Search/Replace on various range: Selection, Current Search, Virtual library, Library. 19 | * Shared Search/Replace operation: set in once, used where you want, edit them and all reference has edited (compatible with Calibre saved Search/Replace system) 20 | 21 | Available operation type: 22 | 23 | * Character match 24 | * Regular expression 25 | * Replace field 26 | 27 | To use a "Shared Search/Replace operation", create and save a operation in the Calibre combo box, or select one that already exist. 28 | Important, don't edit any field after having select the "Shared operation" or the link will be broken. To edit a "Shared operation", it will have to be re-registered with the same name in the Calibre saved Search/Replace system. 29 | Once the "Shared operation" corrrectly save, the name of this one will appear in operations list. 30 | 31 | 32 | **Special Notes:** 33 | 34 | * Uses the Calibre Search/Replace module. 35 | * **You can destroy your library using this plugin.** Changes are permanent. There is no undo function. You are strongly encouraged to back up your library before proceeding. 36 | 37 | 38 | **Credits:** 39 | 40 | * The icon dialog and the dynamic menus for chains are based on code from the Open With plugin by kiwidude. 41 | * The Calibre Actions is based on code from the Favourites Menu plugin by kiwidude. 42 | * The module editor is based on calibre editor function editor by Kovid Goyal. 43 | * The Search and Replace Action is based on calibre's search and replace. (chaley and Kovid Goyal) 44 | * Thanks to capink and its plugin [Action Chains](https://www.mobileread.com/forums/showthread.php?t=334974) without which this one wouldn't exist. 45 | 46 | 47 | **Installation** 48 | 49 | Open *Preferences -> Plugins -> Get new plugins* and install the "Mass Search/Replace" plugin. 50 | You may also download the attached zip file and install the plugin manually, then restart calibre as described in the [Introduction to plugins thread](https://www.mobileread.com/forums/showthread.php?t=118680") 51 | 52 | The plugin works for Calibre 5 and later. 53 | 54 | Page: [GitHub](https://github.com/un-pogaz/Mass-Search-Replace) | [MobileRead](https://www.mobileread.com/forums/showthread.php?t=335417) 55 | 56 | Note for those who wish to provide a translation:
57 | I am *French*! Although for obvious reasons, the default language of the plugin is English, keep in mind that already a translation. 58 | 59 | 60 |

61 | 62 | ![configuration dialog of contextual menu](https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/main/static/Mass_Search-Replace-config-menu.png) 63 | ![button contextual menu](https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/main/static/Mass_Search-Replace-context.png) 64 | ![configuration dialog of a operations-list](https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/main/static/Mass_Search-Replace-operations-list.png) 65 | ![configuration dialog for a Search/Replace operation](https://raw.githubusercontent.com/un-pogaz/Mass-Search-Replace/main/static/Mass_Search-Replace-config-operation.png) 66 | 67 | 68 | [mobileread-url]: https://www.mobileread.com/forums/showthread.php?t=335417 69 | 70 | [changelog-image]: https://img.shields.io/badge/History-CHANGELOG-blue.svg 71 | [changelog-url]: changelog.md 72 | 73 | [license-image]: https://img.shields.io/badge/License-GPL-yellow.svg 74 | [license-url]: LICENSE 75 | 76 | [calibre-image]: https://img.shields.io/badge/calibre-5.00.0_and_above-green?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAllJREFUOMt1kz1MU1EUx3/3fZSP0lJLgVqRNqCDHxApAWcXF9O4oomDcXU06iIuLgxuTi4mrm7GRI2LiYOJ4ldAiBqxqSA2lEc/oNC+d991eI8HRnuGm3tzzv2d/znnXpEb5CHQDoCi8LigruHbrXOTs6Wl6qnkcPTd7SdvTvMfM/I1LgnhHYSgePHm9APheMAbV8e+mZoaR7BCCzMyEehNJXCky0bR2tJcdx7Nc+at0POjiQYokWkJABgcTlGv72AVLXRdQ9d0XKUob4uyF6aGWgE0gO36Jq7dBEBKl6Zt4zgO5bpe8uO6P768HGupACVRrvzHWdwMWbAFwHx96uy9u+UTc68WcmcuTCqljNzMFL80gCNDMfr6O0Eh9gOWq2YZsAFWGyNXYv3h6cLnyph0mllhMBGU8HVxleKKBQIFcKiv1y8HF1gG6NGXqqF2E8cGx3bQYSwA/Mxb1CrbQWYlwDT86iAPMGDMSYDIAcHGagUF4wEgnQ4Tj5t7AFehacLvssgDpPSFMGDH+kKUlssA2aCJ9a0GXV1GADBNA0e6u7g8gC4aaWBxMjc62tbeBpC6/oikBlCtNNmsNQKAbUtPvLf+8DcZJXgfTyYIxyLeCDWyGoAmFNWaDEYgpYNhmP49TwEQ6aT25a85Kx/QHVYkoq6fE1ylgnfhCrkLYDD0YW3/fQFZ7XsVXizAs3ko1Ij0J3pIpw5yOJkk3NHRefJ1egVoABw3nu4Ack8AWWM4yk7wnWHtd2k9Wiytt/kpLGbuuPcnRl27KRsDI/Fj6jxvhcBU8EkoZv8AURDxq1Vav0YAAAAASUVORK5CYII= 77 | [calibre-url]: https://www.calibre-ebook.com/ 78 | 79 | [status-image]: https://img.shields.io/badge/Status-Stable-green 80 | 81 | [mobileread-image]: https://img.shields.io/badge/MobileRead-Plugin%20Thread-blue?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAACJUlEQVQ4EZ3SX0hTYRjH8e+79DQcm5pGba0pQizrJhiMvJDwj3dR2SIoqK68CYouy24sb/TKbsuyC4kwG3gVBpUlqP1hBaUxiMp5aLZyzdn847E6+YQHDkNv+ty88PI8Px6e91XvJ5Nm9MU44t10GjuXplFV5qZIK6SyrARRHdgWAPbvqfT1A6jo8Buz73WcfAf3VnGqMczC4jKJbz9YWDJWzwxiIvkdMf41TQHrKE5P8XxgBP3lI0RraysiFKxAlA4NIRYNz/oBK3qcG7d7EEOrxbFYjFAohOjt7UX4/X5mYk9xlBe7yJf5mZMmcrkcg4ODuN1uLNlslubmZurq6tAcJv+W2DbwjHwNHgNjfo5IJILX68Uioe3t7RjGCq7tAQrYQG19E9UVXoRMMzY2Rk1NDcFgkM7OTq4/GEE42IBrs4adrut0dHSQTCYRiXSWrW4X6oOe0i9Hn/jJU79rpxQgJmcyzBu/sJMnbDtyAAVw/Npdk/9w78IJpVgjHyo385lEIo5Ir3hY/q3wObPYoblR5UEqyko43RhWCpupqwHzz2IO8Uqr5dKdCS6ePUkkME02FsXia+lHq2pQ9iVifHpsNQsOnzlPOBymu+8hpce6FTZLH4exFLBGOUuxM768pauri1QqRaBozpy9dQiLw1mCRWGTud9i2kfVfLvZ5CxmeXoCmc66850bVesGiIVYjzk7ehMjGceucMsO3PuO4mm6orD5CzQt1i+ddfLfAAAAAElFTkSuQmCC 82 | -------------------------------------------------------------------------------- /search_replace/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2020, Ahmed Zaki ; adjustment 2020, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | import copy 13 | from typing import Any, List 14 | 15 | try: 16 | from qt.core import QVBoxLayout 17 | except ImportError: 18 | from PyQt5.Qt import QVBoxLayout 19 | 20 | from calibre.gui2 import question_dialog 21 | from calibre.gui2.widgets2 import Dialog 22 | 23 | from . import text as CalibreText 24 | from .calibre import KEY_QUERY, S_R_FUNCTIONS, S_R_MATCH_MODES, S_R_REPLACE_MODES, MetadataBulkWidget 25 | from ..common_utils import GUI, current_db, debug_print, get_icon 26 | from ..common_utils.columns import get_all_identifiers, get_possible_fields 27 | 28 | 29 | class Operation(dict): 30 | 31 | _default_operation = None 32 | _s_r = None 33 | 34 | def __init__(self, src=None): 35 | dict.__init__(self) 36 | if not src: 37 | if not Operation._s_r or Operation._s_r.db != current_db(): 38 | _s_r = Operation._s_r = SearchReplaceWidget([0]) 39 | if not Operation._default_operation: 40 | Operation._default_operation = _s_r.get_operation() 41 | Operation._default_operation[KEY_QUERY.ACTIVE] = True 42 | 43 | src = copy.copy(Operation._default_operation) 44 | 45 | self.update(src) 46 | 47 | def get_error(self) -> Any: 48 | 49 | if not self: 50 | return TypeError 51 | 52 | if KEY_QUERY.S_R_ERROR in self: 53 | return self[KEY_QUERY.S_R_ERROR] 54 | 55 | difference = set(KEY_QUERY.ALL).difference(self.keys()) 56 | for key in difference: 57 | return OperationError(_('Invalid operation, the "{:s}" key is missing.').format(key)) 58 | 59 | if self[KEY_QUERY.REPLACE_FUNC] not in S_R_FUNCTIONS: 60 | return OperationError(CalibreText.get_for_localized_field(CalibreText.FIELD_NAME.REPLACE_FUNC, self[KEY_QUERY.REPLACE_FUNC])) 61 | 62 | if self[KEY_QUERY.REPLACE_MODE] not in S_R_REPLACE_MODES: 63 | return OperationError(CalibreText.get_for_localized_field(CalibreText.FIELD_NAME.REPLACE_MODE, self[KEY_QUERY.REPLACE_MODE])) 64 | 65 | if self[KEY_QUERY.SEARCH_MODE] not in S_R_MATCH_MODES: 66 | return OperationError(CalibreText.get_for_localized_field(CalibreText.FIELD_NAME.SEARCH_MODE, self[KEY_QUERY.SEARCH_MODE])) 67 | 68 | # Field test 69 | all_fields, writable_fields = get_possible_fields() 70 | 71 | search_field = self[KEY_QUERY.SEARCH_FIELD] 72 | dest_field = self[KEY_QUERY.DESTINATION_FIELD] 73 | 74 | if search_field not in all_fields: 75 | return OperationError(_('Search field "{:s}" is not available for this library').format(search_field)) 76 | 77 | if dest_field and (dest_field not in writable_fields): 78 | return OperationError(_('Destination field "{:s}" is not available for this library').format(dest_field)) 79 | 80 | possible_idents = get_all_identifiers() 81 | 82 | if search_field == 'identifiers': 83 | src_ident = self[KEY_QUERY.S_R_SRC_IDENT] 84 | if src_ident not in possible_idents: 85 | return OperationError(_('Identifier type "{:s}" is not available for this library').format(src_ident)) 86 | 87 | return None 88 | 89 | def test_full_error(self) -> Any: 90 | err = self.get_error() 91 | if err: 92 | return err 93 | Operation() 94 | Operation._s_r.load_operation(self) 95 | return Operation._s_r.get_error() 96 | 97 | def is_full_valid(self) -> bool: 98 | return self.test_full_error() is None 99 | 100 | def get_para_list(self) -> List[str]: 101 | name = self.get(KEY_QUERY.NAME, '') 102 | column = self.get(KEY_QUERY.SEARCH_FIELD, '') 103 | field = self.get(KEY_QUERY.DESTINATION_FIELD, '') 104 | if (field and field != column): 105 | column += ' => '+ field 106 | 107 | search_mode = self.get(KEY_QUERY.SEARCH_MODE, '') 108 | template = self.get(KEY_QUERY.S_R_TEMPLATE, '') 109 | search_for = '' 110 | if search_mode == CalibreText.S_R_REPLACE: 111 | search_for = '*' 112 | else: 113 | search_for = self.get(KEY_QUERY.SEARCH_FOR, '') 114 | replace_with = self.get(KEY_QUERY.REPLACE_WITH, '') 115 | 116 | if column == 'identifiers': 117 | src_ident = self.get(KEY_QUERY.S_R_SRC_IDENT, '') 118 | search_for = src_ident+':'+search_for 119 | 120 | dst_ident = self.get(KEY_QUERY.S_R_DST_IDENT, src_ident) 121 | replace_with = dst_ident+':'+replace_with.strip() 122 | 123 | return [name, column, template, search_mode, search_for, replace_with] 124 | 125 | def string_info(self) -> str: 126 | tbl = self.get_para_list() 127 | if not tbl[2]: 128 | del tbl[2] 129 | 130 | return ('name:"'+tbl[0]+'" => ' if tbl[0] else '') + '"'+ '" | "'.join(tbl[1:])+'"' 131 | 132 | 133 | class OperationError(ValueError): 134 | pass 135 | 136 | 137 | def clean_empty_operation(operation_list) -> List[Operation]: 138 | operation_list = operation_list or [] 139 | default = Operation() 140 | rlst = [] 141 | for operation in operation_list: 142 | for key in KEY_QUERY.ALL: 143 | if operation[key] != default[key]: 144 | rlst.append(Operation(operation)) 145 | break 146 | 147 | return rlst 148 | 149 | 150 | def operation_list_active(operation_list) -> List[Operation]: 151 | rlst = [] 152 | for operation in clean_empty_operation(operation_list): 153 | if operation.get(KEY_QUERY.ACTIVE, True): 154 | rlst.append(operation) 155 | 156 | return rlst 157 | 158 | 159 | class SearchReplaceWidget(MetadataBulkWidget): 160 | def __init__(self, book_ids=[], refresh_books=set()): 161 | self.original_operation = None 162 | MetadataBulkWidget.__init__(self, book_ids, refresh_books) 163 | self.updated_fields = self.set_field_calls 164 | self.load_query = self.load_operation 165 | 166 | def load_operation(self, operation): 167 | self.original_operation = Operation(operation) 168 | MetadataBulkWidget.load_query(self, operation) 169 | 170 | def get_operation(self) -> Operation: 171 | return Operation(self.get_query()) 172 | 173 | def get_error(self) -> Any: 174 | return Operation(self.get_query()).get_error() 175 | 176 | def search_replace(self, book_id, operation=None) -> Any: 177 | if operation: 178 | self.load_operation(operation) 179 | 180 | err = self.get_error() 181 | if not err: 182 | err = self.do_search_replace(book_id) 183 | return err 184 | 185 | 186 | class SearchReplaceDialog(Dialog): 187 | def __init__(self, operation=None, book_ids=[]): 188 | self.operation = operation or Operation() 189 | self.widget = SearchReplaceWidget(book_ids[:10]) 190 | Dialog.__init__(self, 191 | title=_('Configuration of a Search/Replace operation'), 192 | name='plugin.MassSearchReplace:config_query_SearchReplace', 193 | parent=GUI, 194 | ) 195 | 196 | def setup_ui(self): 197 | l = QVBoxLayout() 198 | self.setLayout(l) 199 | l.addWidget(self.widget) 200 | l.addWidget(self.bb) 201 | 202 | if self.operation: 203 | self.widget.load_operation(self.operation) 204 | 205 | def accept(self): 206 | err = self.widget.get_error() 207 | 208 | if err: 209 | if question_dialog(self, _('Invalid operation'), 210 | _('The registering of Find/Replace operation has failed.\n{:s}\n' 211 | 'Do you want discard the changes?').format(str(err)), 212 | default_yes=True, show_copy_button=False, override_icon=get_icon('dialog_warning.png')): 213 | 214 | Dialog.reject(self) 215 | return 216 | else: 217 | return 218 | 219 | new_operation = self.widget.get_operation() 220 | original_operation = self.widget.original_operation 221 | new_operation_name = new_operation.get(KEY_QUERY.NAME, None) 222 | original_operation_name = original_operation.get(KEY_QUERY.NAME, None) 223 | if new_operation_name and new_operation_name == original_operation_name: 224 | different = False 225 | for k in new_operation: 226 | if k in original_operation and new_operation[k] != original_operation[k]: 227 | if k == KEY_QUERY.S_R_SRC_IDENT and not KEY_QUERY.SEARCH_FIELD == 'identifiers': 228 | continue 229 | if k == KEY_QUERY.S_R_DST_IDENT and not KEY_QUERY.DESTINATION_FIELD == 'identifiers': 230 | continue 231 | different = True 232 | break 233 | 234 | if different: 235 | if question_dialog(self, _('Changed operation'), 236 | _('The content of the Find/Replace operation "{:s}" was edited after being loaded into the editor.\n' 237 | 'The operation will be saved has it and not as a shared named operation!\n' 238 | 'Do you want continue?').format(new_operation_name), 239 | default_yes=True, show_copy_button=False, override_icon=get_icon('dialog_warning.png')): 240 | 241 | new_operation[KEY_QUERY.NAME] = '' 242 | else: 243 | return 244 | 245 | self.operation = new_operation 246 | 247 | debug_print('Saved operation >', self.operation.string_info()) 248 | debug_print(self.operation) 249 | Dialog.accept(self) 250 | -------------------------------------------------------------------------------- /translations/default.pot: -------------------------------------------------------------------------------- 1 | #, fuzzy 2 | msgid "" 3 | msgstr "" 4 | "Project-Id-Version: \n" 5 | "POT-Creation-Date: 2023-10-08 13:51+0200\n" 6 | "PO-Revision-Date: 2023-08-08 19:22+0200\n" 7 | "Last-Translator: \n" 8 | "Language-Team: \n" 9 | "Language: en\n" 10 | "MIME-Version: 1.0\n" 11 | "Content-Type: text/plain; charset=UTF-8\n" 12 | "Content-Transfer-Encoding: 8bit\n" 13 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 14 | "X-Generator: Poedit 3.4\n" 15 | "X-Poedit-Basepath: ..\n" 16 | "X-Poedit-SearchPath-0: .\n" 17 | "X-Poedit-SearchPathExcluded-0: search_replace/calibre.py\n" 18 | 19 | #: __init__.py:29 20 | msgid "Easily apply a list of multiple saved Find and Replace operations to your books metadata" 21 | msgstr "" 22 | 23 | #: action.py:46 24 | msgid "Apply a list of multiple saved Find and Replace operations" 25 | msgstr "" 26 | 27 | #: action.py:83 28 | msgid "&Quick Search/Replace…" 29 | msgstr "" 30 | 31 | #: action.py:87 32 | msgid "&Selection" 33 | msgstr "" 34 | 35 | #: action.py:91 36 | msgid "&Current search" 37 | msgstr "" 38 | 39 | #: action.py:95 40 | msgid "&Virtual library" 41 | msgstr "" 42 | 43 | #: action.py:99 44 | msgid "&Library" 45 | msgstr "" 46 | 47 | #: action.py:105 48 | msgid "&Customize plugin…" 49 | msgstr "" 50 | 51 | #: action.py:146 52 | msgid "the selected books" 53 | msgstr "" 54 | 55 | #: action.py:149 56 | msgid "all books in the library {:s}" 57 | msgstr "" 58 | 59 | #: action.py:154 60 | msgid "the virtual library {:s}" 61 | msgstr "" 62 | 63 | #: action.py:159 64 | msgid "the current search" 65 | msgstr "" 66 | 67 | #: action.py:164 68 | msgid "({:d} books)" 69 | msgstr "" 70 | 71 | #: action.py:195 72 | msgid "Invalide menu configuration, the \"{:s}\" key is missing." 73 | msgstr "" 74 | 75 | #: action.py:202 common_utils/dialogs.py:242 76 | #, python-brace-format 77 | msgid "{PLUGIN_NAME} progress" 78 | msgstr "" 79 | 80 | #: action.py:205 81 | msgid "Search/Replace {:d} of {:d}. Book {:d} of {:d}." 82 | msgstr "" 83 | 84 | #: action.py:260 action.py:306 action.py:350 search_replace/__init__.py:215 85 | msgid "Invalid operation" 86 | msgstr "" 87 | 88 | #: action.py:261 89 | msgid "" 90 | "A invalid operations has detected:\n" 91 | "{:s}\n" 92 | "\n" 93 | "Mass Search/Replace was canceled." 94 | msgstr "" 95 | 96 | #: action.py:290 97 | msgid "The library a was restored to its original state." 98 | msgstr "" 99 | 100 | #: action.py:293 101 | msgid "Cannot update the library" 102 | msgstr "" 103 | 104 | #: action.py:299 105 | msgid "Exceptions during the library update" 106 | msgstr "" 107 | 108 | #: action.py:300 109 | msgid "" 110 | "{:d} exceptions have occurred during the library update.\n" 111 | "Some fields may not have been updated." 112 | msgstr "" 113 | 114 | #: action.py:307 115 | msgid "{:d} invalid operations has detected and have been ignored." 116 | msgstr "" 117 | 118 | #: action.py:312 119 | msgid "Update Report" 120 | msgstr "" 121 | 122 | #: action.py:313 123 | msgid "Mass Search/Replace performed for {:d} books with a total of {:d} fields modify." 124 | msgstr "" 125 | 126 | #: action.py:351 127 | msgid "" 128 | "A invalid operations has detected:\n" 129 | "{:s}\n" 130 | "\n" 131 | "Continue the execution of Mass Search/Replace?\n" 132 | "Other errors may exist and will be ignored." 133 | msgstr "" 134 | 135 | #: action.py:411 136 | msgid "Update the library for {:d} books with a total of {:d} fields…" 137 | msgstr "" 138 | 139 | #: common_utils/__init__.py:407 140 | msgid "You cannot configure this plugin before calibre is restarted." 141 | msgstr "" 142 | 143 | #: common_utils/dialogs.py:52 common_utils/dialogs.py:82 144 | msgid "Keyboard shortcuts" 145 | msgstr "" 146 | 147 | #: common_utils/dialogs.py:83 148 | msgid "Edit the keyboard shortcuts associated with this plugin" 149 | msgstr "" 150 | 151 | #: common_utils/dialogs.py:99 152 | msgid "Preferences for:" 153 | msgstr "" 154 | 155 | #: common_utils/dialogs.py:122 156 | msgid "Clear all settings for this plugin" 157 | msgstr "" 158 | 159 | #: common_utils/dialogs.py:164 160 | msgid "The changes cannot be applied." 161 | msgstr "" 162 | 163 | #: common_utils/dialogs.py:168 164 | msgid "Are you sure you want to change your settings in this library for this plugin?" 165 | msgstr "" 166 | 167 | #: common_utils/dialogs.py:169 common_utils/dialogs.py:181 168 | msgid "Any settings in other libraries or stored in a JSON file in your calibre plugins folder will not be touched." 169 | msgstr "" 170 | 171 | #: common_utils/dialogs.py:180 172 | msgid "Are you sure you want to clear your settings in this library for this plugin?" 173 | msgstr "" 174 | 175 | #: common_utils/dialogs.py:201 176 | msgid "View library preferences" 177 | msgstr "" 178 | 179 | #: common_utils/dialogs.py:202 180 | msgid "View data stored in the library database for this plugin" 181 | msgstr "" 182 | 183 | #: common_utils/dialogs.py:232 184 | msgid "Cancel" 185 | msgstr "" 186 | 187 | #: common_utils/dialogs.py:298 188 | msgid "Book {:d} of {:d}" 189 | msgstr "" 190 | 191 | #: common_utils/dialogs.py:333 192 | msgid "Copy to clipboard" 193 | msgstr "" 194 | 195 | #: common_utils/dialogs.py:352 196 | msgid "Add New Image" 197 | msgstr "" 198 | 199 | #: common_utils/dialogs.py:360 200 | msgid "&Select image source" 201 | msgstr "" 202 | 203 | #: common_utils/dialogs.py:363 204 | msgid "From &web domain favicon" 205 | msgstr "" 206 | 207 | #: common_utils/dialogs.py:370 208 | msgid "From .png &file" 209 | msgstr "" 210 | 211 | #: common_utils/dialogs.py:383 212 | msgid "&Save as filename:" 213 | msgstr "" 214 | 215 | #: common_utils/dialogs.py:404 216 | msgid "Select a .png file for the menu icon" 217 | msgstr "" 218 | 219 | #: common_utils/dialogs.py:410 common_utils/dialogs.py:419 220 | #: common_utils/dialogs.py:422 common_utils/dialogs.py:437 221 | #: common_utils/dialogs.py:443 common_utils/dialogs.py:445 222 | #: common_utils/dialogs.py:447 223 | msgid "Cannot import image" 224 | msgstr "" 225 | 226 | #: common_utils/dialogs.py:410 common_utils/dialogs.py:445 227 | msgid "Source image must be a .png file." 228 | msgstr "" 229 | 230 | #: common_utils/dialogs.py:419 231 | msgid "You must specify a filename to save as." 232 | msgstr "" 233 | 234 | #: common_utils/dialogs.py:422 235 | msgid "The save as filename should consist of a filename only." 236 | msgstr "" 237 | 238 | #: common_utils/dialogs.py:427 config.py:515 config.py:979 239 | msgid "Are you sure?" 240 | msgstr "" 241 | 242 | #: common_utils/dialogs.py:427 243 | msgid "An image with this name already exists - overwrite it?" 244 | msgstr "" 245 | 246 | #: common_utils/dialogs.py:437 247 | msgid "You must specify a web domain url" 248 | msgstr "" 249 | 250 | #: common_utils/dialogs.py:443 251 | msgid "You must specify a source file." 252 | msgstr "" 253 | 254 | #: common_utils/dialogs.py:447 255 | msgid "Source image does not exist!" 256 | msgstr "" 257 | 258 | #: common_utils/dialogs.py:477 259 | #, python-brace-format 260 | msgid "The {PLUGIN_NAME} plugin has encounter a unhandled exception." 261 | msgstr "" 262 | 263 | #: common_utils/dialogs.py:486 264 | msgid "Unhandled exception" 265 | msgstr "" 266 | 267 | #: common_utils/dialogs.py:500 268 | msgid "Select a ZIP archive file to import…" 269 | msgstr "" 270 | 271 | #: common_utils/dialogs.py:511 272 | msgid "Save ZIP archive file as…" 273 | msgstr "" 274 | 275 | #: common_utils/dialogs.py:523 276 | msgid "Select a JSON file to import…" 277 | msgstr "" 278 | 279 | #: common_utils/dialogs.py:534 280 | msgid "Save the JSON file as…" 281 | msgstr "" 282 | 283 | #: common_utils/librarys.py:48 284 | msgid "Could not to launch {:s}" 285 | msgstr "" 286 | 287 | #: common_utils/librarys.py:62 288 | msgid "No book selected" 289 | msgstr "" 290 | 291 | #: common_utils/librarys.py:67 292 | msgid "No book in the library" 293 | msgstr "" 294 | 295 | #: common_utils/librarys.py:72 common_utils/librarys.py:78 296 | msgid "No book in the virtual library" 297 | msgstr "" 298 | 299 | #: common_utils/librarys.py:83 300 | msgid "No book in the current search" 301 | msgstr "" 302 | 303 | #: common_utils/templates.py:57 304 | msgid "Unknown" 305 | msgstr "" 306 | 307 | #: common_utils/templates.py:64 308 | msgid "Template Error" 309 | msgstr "" 310 | 311 | #: common_utils/templates.py:65 312 | msgid "Running the template returned an error:" 313 | msgstr "" 314 | 315 | #: common_utils/templates.py:77 316 | msgid "Enter a template to test using data from the selected book" 317 | msgstr "" 318 | 319 | #: common_utils/templates.py:84 320 | msgid "Template editor" 321 | msgstr "" 322 | 323 | #: common_utils/templates.py:105 common_utils/templates.py:106 324 | #: search_replace/text.py:31 325 | msgid "Open the template editor" 326 | msgstr "" 327 | 328 | #: common_utils/widgets.py:66 329 | msgid "Restart required" 330 | msgstr "" 331 | 332 | #: common_utils/widgets.py:67 333 | msgid "Title image not found - you must restart Calibre before using this plugin!" 334 | msgstr "" 335 | 336 | #: common_utils/widgets.py:122 337 | msgid "Undefined" 338 | msgstr "" 339 | 340 | #: common_utils/widgets.py:270 341 | msgid "Subset of values associate to the books" 342 | msgstr "" 343 | 344 | #: common_utils/widgets.py:271 345 | msgid "No books" 346 | msgstr "" 347 | 348 | #: common_utils/widgets.py:272 349 | msgid "{:d} books (no values)" 350 | msgstr "" 351 | 352 | #: common_utils/widgets.py:273 353 | msgid "{:d} books" 354 | msgstr "" 355 | 356 | #: common_utils/widgets.py:396 357 | msgid "No notes" 358 | msgstr "" 359 | 360 | #: common_utils/widgets.py:442 361 | msgid "Add New Image…" 362 | msgstr "" 363 | 364 | #: config.py:86 365 | msgid "Interrupt execution" 366 | msgstr "" 367 | 368 | #: config.py:87 369 | msgid "Stop Mass Search/Replace and display the error normally without further action." 370 | msgstr "" 371 | 372 | #: config.py:90 373 | msgid "Restore the library" 374 | msgstr "" 375 | 376 | #: config.py:91 377 | msgid "Stop Mass Search/Replace and restore the library to its original state." 378 | msgstr "" 379 | 380 | #: config.py:94 381 | msgid "Updates the fields one by one. This operation can be slower than other strategies." 382 | msgstr "" 383 | 384 | #: config.py:97 385 | msgid "Carefully executed (slower)" 386 | msgstr "" 387 | 388 | #: config.py:98 389 | msgid "When a error occurs, stop Mass Search/Replace and display the error normally without further action." 390 | msgstr "" 391 | 392 | #: config.py:101 393 | msgid "Don't stop (slower, not recomanded)" 394 | msgstr "" 395 | 396 | #: config.py:102 397 | msgid "Update the library, no matter how many errors are encountered. The problematics fields will not be updated." 398 | msgstr "" 399 | 400 | #: config.py:116 401 | msgid "Abbort" 402 | msgstr "" 403 | 404 | #: config.py:117 405 | msgid "If an invalid operation is detected, abort the changes." 406 | msgstr "" 407 | 408 | #: config.py:120 409 | msgid "Asked" 410 | msgstr "" 411 | 412 | #: config.py:121 413 | msgid "If an invalid operation is detected, asked whether to continue or abort the changes." 414 | msgstr "" 415 | 416 | #: config.py:124 417 | msgid "Hidden" 418 | msgstr "" 419 | 420 | #: config.py:125 421 | msgid "Ignore all invalid operations." 422 | msgstr "" 423 | 424 | #: config.py:174 425 | msgid "Select and configure the menu items to display:" 426 | msgstr "" 427 | 428 | #: config.py:190 429 | msgid "Move menu item up" 430 | msgstr "" 431 | 432 | #: config.py:197 433 | msgid "Add menu item" 434 | msgstr "" 435 | 436 | #: config.py:204 437 | msgid "Copy menu item" 438 | msgstr "" 439 | 440 | #: config.py:211 441 | msgid "Delete menu item" 442 | msgstr "" 443 | 444 | #: config.py:218 445 | msgid "Move menu item down" 446 | msgstr "" 447 | 448 | #: config.py:235 449 | msgid "Mark the updated books" 450 | msgstr "" 451 | 452 | #: config.py:239 453 | msgid "Display a update report" 454 | msgstr "" 455 | 456 | #: config.py:243 457 | msgid "Error strategy" 458 | msgstr "" 459 | 460 | #: config.py:244 461 | msgid "Define the strategy when a error occurs during the library update" 462 | msgstr "" 463 | 464 | #: config.py:267 config.py:700 465 | msgid "Name" 466 | msgstr "" 467 | 468 | #: config.py:267 469 | msgid "Submenu" 470 | msgstr "" 471 | 472 | #: config.py:267 473 | msgid "Image" 474 | msgstr "" 475 | 476 | #: config.py:267 477 | msgid "Operation" 478 | msgstr "" 479 | 480 | #: config.py:288 481 | msgid "&Add image…" 482 | msgstr "" 483 | 484 | #: config.py:292 485 | msgid "&Open images folder" 486 | msgstr "" 487 | 488 | #: config.py:300 config.py:831 489 | msgid "&Import…" 490 | msgstr "" 491 | 492 | #: config.py:304 config.py:835 493 | msgid "&Export…" 494 | msgstr "" 495 | 496 | #: config.py:327 config.py:346 config.py:850 497 | msgid "Import failed" 498 | msgstr "" 499 | 500 | #: config.py:327 501 | msgid "This is not a valid OWIP export archive" 502 | msgstr "" 503 | 504 | #: config.py:343 config.py:854 505 | msgid "Import completed" 506 | msgstr "" 507 | 508 | #: config.py:343 509 | msgid "{:d} menu items imported" 510 | msgstr "" 511 | 512 | #: config.py:349 513 | msgid "Select a menu file archive to import…" 514 | msgstr "" 515 | 516 | #: config.py:359 config.py:384 config.py:857 config.py:870 config.py:881 517 | msgid "Export failed" 518 | msgstr "" 519 | 520 | #: config.py:359 521 | msgid "No menu items selected to export" 522 | msgstr "" 523 | 524 | #: config.py:381 config.py:878 525 | msgid "Export completed" 526 | msgstr "" 527 | 528 | #: config.py:381 529 | msgid "" 530 | "{:d} menu items exported to\n" 531 | "{:s}" 532 | msgstr "" 533 | 534 | #: config.py:387 535 | msgid "Save menu archive as…" 536 | msgstr "" 537 | 538 | #: config.py:499 539 | msgid "(copy)" 540 | msgstr "" 541 | 542 | #: config.py:512 543 | msgid "Are you sure you want to delete this menu item?" 544 | msgstr "" 545 | 546 | #: config.py:514 547 | msgid "Are you sure you want to delete the selected {:d} menu items?" 548 | msgstr "" 549 | 550 | #: config.py:646 551 | msgid "{:d}/{:d} operations" 552 | msgstr "" 553 | 554 | #: config.py:648 555 | msgid "{:d} operations" 556 | msgstr "" 557 | 558 | #: config.py:664 559 | msgid "This operations list contain a error" 560 | msgstr "" 561 | 562 | #: config.py:667 563 | msgid "Edit the operations list" 564 | msgstr "" 565 | 566 | #: config.py:700 567 | msgid "Columns" 568 | msgstr "" 569 | 570 | #: config.py:700 571 | msgid "Template" 572 | msgstr "" 573 | 574 | #: config.py:700 search_replace/text.py:20 575 | msgid "Search mode" 576 | msgstr "" 577 | 578 | #: config.py:700 579 | msgid "Search" 580 | msgstr "" 581 | 582 | #: config.py:700 583 | msgid "Replace" 584 | msgstr "" 585 | 586 | #: config.py:711 587 | msgid "List of operations for a quick Search/Replaces" 588 | msgstr "" 589 | 590 | #: config.py:716 591 | msgid "List of Search/Replace operations for {:s}" 592 | msgstr "" 593 | 594 | #: config.py:730 595 | msgid "Select and configure the order of execution of the operations of Search/Replace operations:" 596 | msgstr "" 597 | 598 | #: config.py:750 599 | msgid "Move operation up" 600 | msgstr "" 601 | 602 | #: config.py:758 603 | msgid "Add operation" 604 | msgstr "" 605 | 606 | #: config.py:766 607 | msgid "Copy operation" 608 | msgstr "" 609 | 610 | #: config.py:774 611 | msgid "Delete operation" 612 | msgstr "" 613 | 614 | #: config.py:782 615 | msgid "Move operation down" 616 | msgstr "" 617 | 618 | #: config.py:850 619 | msgid "This is not a valid JSON file" 620 | msgstr "" 621 | 622 | #: config.py:854 623 | msgid "{:d} operations imported" 624 | msgstr "{:d} opérations importés" 625 | 626 | #: config.py:870 627 | msgid "No operations selected to export" 628 | msgstr "" 629 | 630 | #: config.py:878 631 | msgid "" 632 | "{:d} operations exported to\n" 633 | "{:s}" 634 | msgstr "" 635 | 636 | #: config.py:884 637 | msgid "Save the operations as…" 638 | msgstr "" 639 | 640 | #: config.py:976 641 | msgid "Are you sure you want to delete this operation?" 642 | msgstr "" 643 | 644 | #: config.py:978 645 | msgid "Are you sure you want to delete the selected {:d} operations?" 646 | msgstr "" 647 | 648 | #: config.py:1141 649 | msgid "Error Strategy" 650 | msgstr "" 651 | 652 | #: config.py:1150 653 | msgid "Set the strategy when an invalid operation has detected:" 654 | msgstr "" 655 | 656 | #: config.py:1161 657 | msgid "Define the strategy when a error occurs during the library update:" 658 | msgstr "" 659 | 660 | #: search_replace/__init__.py:66 661 | msgid "Invalid operation, the \"{:s}\" key is missing." 662 | msgstr "" 663 | 664 | #: search_replace/__init__.py:84 665 | msgid "Search field \"{:s}\" is not available for this library" 666 | msgstr "" 667 | 668 | #: search_replace/__init__.py:87 669 | msgid "Destination field \"{:s}\" is not available for this library" 670 | msgstr "" 671 | 672 | #: search_replace/__init__.py:94 673 | msgid "Identifier type \"{:s}\" is not available for this library" 674 | msgstr "" 675 | 676 | #: search_replace/__init__.py:197 677 | msgid "Configuration of a Search/Replace operation" 678 | msgstr "" 679 | 680 | #: search_replace/__init__.py:216 681 | msgid "" 682 | "The registering of Find/Replace operation has failed.\n" 683 | "{:s}\n" 684 | "Do you want discard the changes?" 685 | msgstr "" 686 | 687 | #: search_replace/__init__.py:241 688 | msgid "Changed operation" 689 | msgstr "" 690 | 691 | #: search_replace/__init__.py:242 692 | msgid "" 693 | "The content of the Find/Replace operation \"{:s}\" was edited after being loaded into the editor.\n" 694 | "The operation will be saved has it and not as a shared named operation!\n" 695 | "Do you want continue?" 696 | msgstr "" 697 | 698 | #: search_replace/text.py:15 699 | msgid "You must specify a \"Search field\"" 700 | msgstr "" 701 | 702 | #: search_replace/text.py:18 703 | msgid "Case to be applied" 704 | msgstr "" 705 | 706 | #: search_replace/text.py:19 707 | msgid "Replace mode" 708 | msgstr "" 709 | 710 | #: search_replace/text.py:21 711 | msgid "Identifier type" 712 | msgstr "" 713 | 714 | #: search_replace/text.py:23 715 | msgid "Replace field" 716 | msgstr "" 717 | 718 | #: search_replace/text.py:26 719 | msgid "In field replacement mode, the specified field is set to the text and all previous values are erased. After replacement is finished, the text can be changed to upper-case, lower-case, or title-case." 720 | msgstr "" 721 | 722 | #: search_replace/text.py:33 723 | msgid "Invalid identifier string. It must be a comma-separated list of pairs of strings separated by a colon." 724 | msgstr "" 725 | 726 | #: search_replace/text.py:36 727 | msgid "The field \"{:s}\" is not defined" 728 | msgstr "" 729 | 730 | #: search_replace/text.py:39 731 | msgid "The operation field \"{:s}\" contains a invalid value ({:s})." 732 | msgstr "" 733 | 734 | #: search_replace/text.py:42 735 | msgid "The value of this field is localized (translated). This can cause problems when using settings shared on internet or when changing the user interface language." 736 | msgstr "" 737 | -------------------------------------------------------------------------------- /action.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2020, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | import time 13 | from collections import defaultdict 14 | from functools import partial 15 | from typing import Union 16 | 17 | try: 18 | from qt.core import QMenu, QToolButton 19 | except ImportError: 20 | from PyQt5.Qt import QMenu, QToolButton 21 | 22 | from calibre.gui2 import info_dialog, question_dialog, warning_dialog 23 | from calibre.gui2.actions import InterfaceAction 24 | 25 | from .common_utils import CALIBRE_VERSION, GUI, debug_print, get_icon 26 | from .common_utils.dialogs import ProgressDialog, custom_exception_dialog 27 | from .common_utils.librarys import ( 28 | get_BookIds_all, 29 | get_BookIds_search, 30 | get_BookIds_selected, 31 | get_BookIds_virtual, 32 | get_curent_virtual, 33 | set_marked, 34 | ) 35 | from .common_utils.menus import create_menu_action_unique, create_menu_item, unregister_menu_actions 36 | from .config import ( 37 | ERROR_OPERATION, 38 | ERROR_UPDATE, 39 | ICON, 40 | KEY_ERROR, 41 | KEY_MENU, 42 | PREFS, 43 | ConfigOperationListDialog, 44 | get_default_menu, 45 | ) 46 | from .search_replace import Operation, SearchReplaceWidget, operation_list_active 47 | from .search_replace import text as CalibreText 48 | 49 | 50 | class MassSearchReplaceAction(InterfaceAction): 51 | 52 | name = 'Mass Search/Replace' 53 | 54 | # Create our top-level menu/toolbar action (text, icon_path, tooltip, keyboard shortcut) 55 | action_spec = (name, None, _('Apply a list of multiple saved Find and Replace operations'), None) 56 | popup_type = QToolButton.InstantPopup 57 | action_type = 'current' 58 | dont_add_to = frozenset(['context-menu-device']) 59 | 60 | def genesis(self): 61 | self.menu = QMenu(GUI) 62 | self.qaction.setMenu(self.menu) 63 | self.qaction.setIcon(get_icon(ICON.PLUGIN)) 64 | 65 | error_operation = PREFS[KEY_ERROR.ERROR][KEY_ERROR.OPERATION] 66 | if error_operation not in ERROR_OPERATION.LIST.keys(): 67 | PREFS[KEY_ERROR.ERROR][KEY_ERROR.OPERATION] = ERROR_OPERATION.DEFAULT 68 | 69 | error_update = PREFS[KEY_ERROR.ERROR][KEY_ERROR.UPDATE] 70 | if error_update not in ERROR_UPDATE.LIST.keys(): 71 | PREFS[KEY_ERROR.ERROR][KEY_ERROR.UPDATE] = ERROR_UPDATE.DEFAULT 72 | 73 | def initialization_complete(self): 74 | self.rebuild_menus() 75 | 76 | def rebuild_menus(self): 77 | self.menu.clear() 78 | sub_menus = {} 79 | 80 | unregister_menu_actions() 81 | 82 | for menu in PREFS[KEY_MENU.MENU]: 83 | if not menu_get_error(menu) and menu[KEY_MENU.ACTIVE]: 84 | self.append_menu_item_ex(self.menu, sub_menus, menu) 85 | 86 | self.menu.addSeparator() 87 | 88 | ac = create_menu_item(self, self.menu, _('&Quick Search/Replace…'), ICON.PLUGIN) 89 | mn_books = QMenu() 90 | ac.setMenu(mn_books) 91 | 92 | create_menu_action_unique(self, mn_books, _('&Selection'), 'highlight_only_on.png', 93 | triggered=self.quick_selected, 94 | unique_name='&Quick Search/Replace in all books>&Selection') 95 | 96 | create_menu_action_unique(self, mn_books, _('&Current search'), 'search.png', 97 | triggered=self.quick_search, 98 | unique_name='&Quick Search/Replace in all books>&Current search') 99 | 100 | create_menu_action_unique(self, mn_books, _('&Virtual library'), 'vl.png', 101 | triggered=self.quick_virtual, 102 | unique_name='&Quick Search/Replace in all books>&Virtual library') 103 | 104 | create_menu_action_unique(self, mn_books, _('&Library'), 'library.png', 105 | triggered=self.quick_library, 106 | unique_name='&Quick Search/Replace in all books>&Library') 107 | 108 | self.menu.addSeparator() 109 | 110 | create_menu_action_unique(self, self.menu, _('&Customize plugin…'), 'config.png', 111 | triggered=self.show_configuration, 112 | unique_name='&Customize plugin', 113 | shortcut=False) 114 | GUI.keyboard.finalize() 115 | 116 | def append_menu_item_ex(self, parent_menu, sub_menus, menu): 117 | 118 | menu_text = menu[KEY_MENU.TEXT] 119 | sub_menu_text = menu[KEY_MENU.SUBMENU] 120 | image_name = menu[KEY_MENU.IMAGE] 121 | 122 | ac = None 123 | if sub_menu_text: 124 | # Create the sub-menu if it does not exist 125 | if sub_menu_text not in sub_menus: 126 | ac = create_menu_item(self, parent_menu, sub_menu_text, image=None, shortcut=None) 127 | sm = QMenu() 128 | ac.setMenu(sm) 129 | sub_menus[sub_menu_text] = sm 130 | # Now set our menu variable so the parent menu item will be the sub-menu 131 | parent_menu = sub_menus[sub_menu_text] 132 | 133 | if not menu_text: 134 | parent_menu.addSeparator() 135 | elif len(menu[KEY_MENU.OPERATIONS])>0: 136 | if sub_menu_text: 137 | unique_name = f'{sub_menu_text} > {menu_text}' 138 | else: 139 | unique_name = f'{menu_text}' 140 | 141 | unique_name = unique_name.replace('&','') 142 | debug_print('Rebuilding menu for:', unique_name) 143 | 144 | create_menu_action_unique(self, parent_menu, menu_text, image_name, 145 | triggered=partial(self.run_SearchReplace, menu, None), 146 | unique_name=unique_name, 147 | ) 148 | 149 | def quick_selected(self): 150 | self.quick_search_replace(get_BookIds_selected(), _('the selected books')) 151 | 152 | def quick_library(self): 153 | self.quick_search_replace( 154 | get_BookIds_all(), 155 | _('all books in the library {:s}').format(GUI.iactions['Choose Library'].library_name()) 156 | ) 157 | 158 | def quick_virtual(self): 159 | vl = get_curent_virtual() 160 | if vl[0]: 161 | self.quick_search_replace(get_BookIds_virtual(), _('the virtual library {:s}').format(vl[0])) 162 | else: 163 | self.quick_library() 164 | 165 | def quick_search(self): 166 | self.quick_search_replace(get_BookIds_search(), _('the current search')) 167 | 168 | def quick_search_replace(self, book_ids, text): 169 | 170 | menu = get_default_menu() 171 | menu[KEY_MENU.TEXT] = text +' '+ _('({:d} books)').format(len(book_ids)) 172 | menu[KEY_MENU.OPERATIONS] = [Operation(o) for o in PREFS[KEY_MENU.QUICK]] 173 | 174 | d = ConfigOperationListDialog(menu=menu, book_ids=book_ids) 175 | 176 | if len(d.operation_list)==0: 177 | d.add_empty_operation() 178 | 179 | if d.exec(): 180 | if len(d.operation_list)>0: 181 | menu[KEY_MENU.OPERATIONS] = d.operation_list 182 | 183 | self.run_SearchReplace(menu, book_ids) 184 | 185 | PREFS[KEY_MENU.QUICK] = d.operation_list 186 | 187 | def run_SearchReplace(self, menu, book_ids): 188 | if book_ids is None: 189 | book_ids = get_BookIds_selected(show_error=True) 190 | 191 | SearchReplacesProgressDialog(book_ids, menu=menu) 192 | 193 | def show_configuration(self): 194 | self.interface_action_base_plugin.do_user_config(GUI) 195 | 196 | 197 | def menu_get_error(menu: QMenu) -> Union[Exception, None]: 198 | 199 | difference = set(KEY_MENU.ALL).difference(menu) 200 | for key in difference: 201 | return Exception(_('Invalide menu configuration, the "{:s}" key is missing.').format(key)) 202 | 203 | return None 204 | 205 | 206 | class SearchReplacesProgressDialog(ProgressDialog): 207 | 208 | title = _('{PLUGIN_NAME} progress').format(PLUGIN_NAME=MassSearchReplaceAction.name) 209 | 210 | def progress_text(self): 211 | return _('Search/Replace {:d} of {:d}. Book {:d} of {:d}.').format( 212 | self.op_num, self.operation_count, self.book_num, self.book_count 213 | ) 214 | 215 | def setup_progress(self, **kvargs): 216 | # Count update 217 | self.books_update = 0 218 | self.fields_update = 0 219 | self.book_num = 0 220 | 221 | # is a quick Search/Replace 222 | self.quick_search_replace = kvargs['menu'][KEY_MENU.TEXT] is None 223 | 224 | # operation list of Search/Replace 225 | self.op_num = 0 226 | self.operation_list = operation_list_active(kvargs['menu'][KEY_MENU.OPERATIONS]) 227 | 228 | # Count of Search/Replace 229 | self.operation_count = len(self.operation_list) 230 | 231 | # Count of Search/Replace 232 | self.total_operation_count = self.book_count*self.operation_count 233 | 234 | # Search/Replace Widget 235 | self.s_r = SearchReplaceWidget(self.book_ids) 236 | 237 | # operation error 238 | self.operationStrategy = PREFS[KEY_ERROR.ERROR][KEY_ERROR.OPERATION] 239 | self.operationErrorList = [] 240 | 241 | # use mark 242 | self.useMark = PREFS[KEY_MENU.USE_MARK] 243 | 244 | # show Update Report 245 | self.showUpdateReport = PREFS[KEY_MENU.UPDATE_REPORT] 246 | 247 | # Exception 248 | self.exceptionStrategy = PREFS[KEY_ERROR.ERROR][KEY_ERROR.UPDATE] 249 | self.exception = [] 250 | self.exception_unhandled = False 251 | self.exception_update = False 252 | self.exception_safely = False 253 | 254 | return self.total_operation_count 255 | 256 | def end_progress(self): 257 | 258 | if self.wasCanceled(): 259 | debug_print('Mass Search/Replace was cancelled. No change.\n') 260 | 261 | elif self.exception_unhandled: 262 | debug_print('Mass Search/Replace was interupted. An exception has occurred:\n'+str(self.exception)) 263 | custom_exception_dialog(self.exception) 264 | 265 | elif self.operationErrorList and self.operationStrategy == ERROR_OPERATION.ABORT: 266 | debug_print( 267 | 'Mass Search/Replace was interupted. An invalid operation has detected:', 268 | str(self.operationErrorList[0][1]), 269 | sep='\n', 270 | ) 271 | warning_dialog(GUI, _('Invalid operation'), 272 | _('A invalid operations has detected:\n{:s}\n\n' 273 | 'Mass Search/Replace was canceled.').format(str(self.operationErrorList[0][1])), 274 | show=True, show_copy_button=False) 275 | 276 | else: 277 | 278 | # info debug 279 | debug_print(f'Search/Replace launched for {self.book_count} books with {self.operation_count} operation.') 280 | 281 | if self.operationErrorList: 282 | debug_print(f'!! {len(self.operationErrorList):d} invalid operation was detected.') 283 | 284 | if self.exception_update: 285 | id, book_info, field, e = self.exception[0] 286 | debug_print( 287 | '!! Mass Search/Replace was interupted. An exception has occurred during the library update:', 288 | str(e), 289 | sep='\n', 290 | ) 291 | elif self.exception_safely: 292 | debug_print(f'!! {len(self.exception):d} exceptions have occurred during the library update.') 293 | 294 | if self.exception_update and self.exceptionStrategy == ERROR_UPDATE.RESTORE: 295 | debug_print('The library a was restored to its original state.') 296 | else: 297 | debug_print( 298 | f'Search/Replace performed for {self.books_update} books' 299 | f'with a total of {self.fields_update} fields modify.' 300 | ) 301 | debug_print(f'Search/Replace execute in {self.time_execut:0.3f} seconds.\n') 302 | 303 | # info dialog 304 | if self.exception_update: 305 | 306 | msg = None 307 | if self.exceptionStrategy == ERROR_UPDATE.RESTORE: 308 | msg = _('The library a was restored to its original state.') 309 | 310 | id, book_info, field, e = self.exception[0] 311 | custom_exception_dialog(e, additional_msg=msg, title=_('Cannot update the library')) 312 | 313 | elif self.exception_safely: 314 | lst = [] 315 | for id, book_info, field, e in self.exception: 316 | lst.append(f'Book {book_info} | {field} > ' + e.__class__.__name__ +': '+ str(e)) 317 | det_msg= '\n'.join(lst) 318 | 319 | warning_dialog(GUI, _('Exceptions during the library update'), 320 | _('{:d} exceptions have occurred during the library update.\n' 321 | 'Some fields may not have been updated.').format(len(self.exception)), 322 | det_msg='-- Mass Search/Replace: Library update exceptions --\n\n'+det_msg, 323 | show=True, show_copy_button=True, 324 | ) 325 | 326 | if self.operationErrorList: 327 | lst = [] 328 | for n, err in self.operationErrorList: 329 | lst.append(f'Operation {n}/{self.operation_count} > {err}') 330 | det_msg= '\n'.join(lst) 331 | 332 | warning_dialog(GUI, _('Invalid operation'), 333 | _('{:d} invalid operations has detected and have been ignored.').format( 334 | len(self.operationErrorList) 335 | ), 336 | det_msg='-- Mass Search/Replace: Invalid operations --\n\n'+det_msg, 337 | show=True, show_copy_button=True, 338 | ) 339 | 340 | if self.showUpdateReport and not (self.exception_update and self.exceptionStrategy == ERROR_UPDATE.RESTORE): 341 | books_update, fields_update = self.books_update, self.fields_update 342 | info_dialog(GUI, _('Update Report'), 343 | _('Mass Search/Replace performed for {:d} books with a total of {:d} fields modify.').format( 344 | books_update, 345 | fields_update, 346 | ), 347 | show=True, show_copy_button=False, 348 | ) 349 | 350 | self.s_r.close() 351 | del self.s_r 352 | 353 | def job_progress(self): 354 | 355 | debug_print(f'Launch Search/Replace for {self.book_count} books with {self.operation_count} operation.\n') 356 | 357 | lst_id = [] 358 | book_id_update = defaultdict(dict) 359 | 360 | alreadyOperationError = False 361 | 362 | try: 363 | 364 | for self.op_num, operation in enumerate(self.operation_list, 1): 365 | 366 | debug_print(f'Operation {self.op_num}/{self.operation_count} >', operation.string_info()) 367 | 368 | err = operation.get_error() 369 | if not err: 370 | self.s_r.load_operation(operation) 371 | err = self.s_r.get_error() 372 | 373 | if err: 374 | debug_print('!! Invalide operation:', err, '\n') 375 | self.operationErrorList.append([self.op_num, str(err)]) 376 | 377 | if len(self.operationErrorList) == 1 and self.operationStrategy == ERROR_OPERATION.ABORT: 378 | return 379 | elif (not alreadyOperationError 380 | and len(self.operationErrorList) == 1 381 | and self.operationStrategy == ERROR_OPERATION.ASK 382 | ): 383 | alreadyOperationError = True 384 | start_dialog = time.time() 385 | rslt = question_dialog(self, _('Invalid operation'), 386 | _('A invalid operations has detected:\n{:s}\n\n' 387 | 'Continue the execution of Mass Search/Replace?\n' 388 | 'Other errors may exist and will be ignored.').format(str(self.operationErrorList[0][1])), 389 | default_yes=True, override_icon=get_icon('dialog_warning.png')) 390 | 391 | self.start = self.start + (time.time() - start_dialog) 392 | 393 | if not rslt: 394 | return 395 | 396 | if not err: 397 | for self.book_num, book_id in enumerate(self.book_ids, 1): 398 | 399 | # update Progress 400 | self.increment() 401 | 402 | miA = self.dbAPI.get_proxy_metadata(book_id) 403 | 404 | # Book book_num/book_count > "title" (author & author) {id: book_id} 405 | book_info = 'Book {book_num}/{book_count} > "{title}" ({authors}) {{id: {book_id}}}'.format( 406 | book_num=self.book_num, 407 | book_count=self.book_count, 408 | title=miA.get('title'), 409 | authors=' & '.join(miA.get('authors')), 410 | book_id=book_id, 411 | ) 412 | 413 | if self.book_num == self.book_count: 414 | nl = '\n' 415 | else: 416 | nl = '' 417 | 418 | debug_print(book_info+nl) 419 | 420 | if self.wasCanceled(): 421 | return 422 | 423 | err = self.s_r.search_replace(book_id) 424 | if err: 425 | if type(err) is Exception: 426 | if str(err) == CalibreText.EXCEPTION_Invalid_identifier: 427 | # title (author & author) 428 | book_info = '"{title}" ({authors})'.format( 429 | title=miA.get('title'), authors=' & '.join(miA.get('authors')), 430 | ) 431 | self.exception.append((book_id, book_info, 'identifier', err)) 432 | else: 433 | raise err 434 | else: 435 | raise Exception(err) 436 | 437 | except Exception as e: 438 | self.exception_unhandled = True 439 | self.exception = e 440 | 441 | else: 442 | 443 | lst_id = [] 444 | for field, book_id_val_map in self.s_r.updated_fields.items(): 445 | lst_id += book_id_val_map.keys() 446 | 447 | self.fields_update = len(lst_id) 448 | lst_id = list(dict.fromkeys(lst_id)) 449 | self.books_update = len(lst_id) 450 | 451 | book_id_update = defaultdict(dict) 452 | 453 | if self.books_update > 0: 454 | books_update, fields_update = self.books_update, self.fields_update 455 | debug_print(f'Update the database for {books_update} books with a total of {fields_update} fields…\n') 456 | self.set_value(-1, 457 | text=_('Update the library for {:d} books with a total of {:d} fields…').format( 458 | books_update, fields_update, 459 | )) 460 | 461 | if self.exceptionStrategy == ERROR_UPDATE.SAFELY or self.exceptionStrategy == ERROR_UPDATE.DONT_STOP: 462 | 463 | dont_stop = self.exceptionStrategy == ERROR_UPDATE.DONT_STOP 464 | 465 | if self.exception: 466 | self.exception_safely = True 467 | 468 | for id in iter(lst_id): 469 | if self.exception and not dont_stop: 470 | break 471 | for field, book_id_val_map in self.s_r.updated_fields.items(): 472 | if self.exception and not dont_stop: 473 | break 474 | if id in book_id_val_map: 475 | try: 476 | val = self.s_r.updated_fields[field][id] 477 | self.dbAPI.set_field(field, {id:val}) 478 | book_id_update[field][id] = '' 479 | except Exception as e: 480 | self.exception_safely = True 481 | 482 | miA = self.dbAPI.get_proxy_metadata(id) 483 | # title (author & author) 484 | book_info = '"{title}" ({authors})'.format( 485 | title=miA.get('title'), authors=' & '.join(miA.get('authors')), 486 | ) 487 | self.exception.append((id, book_info, field, e)) 488 | 489 | else: 490 | try: 491 | 492 | backup_fields = None 493 | is_restore = self.exceptionStrategy == ERROR_UPDATE.RESTORE 494 | if is_restore: 495 | backup_fields = defaultdict(dict) 496 | 497 | if self.exception: 498 | raise Exception('raise') 499 | 500 | for field, book_id_val_map in self.s_r.updated_fields.items(): 501 | if is_restore: 502 | src_field = self.dbAPI.all_field_for(field, book_id_val_map.keys()) 503 | backup_fields[field] = src_field 504 | 505 | self.dbAPI.set_field(field, book_id_val_map) 506 | book_id_update[field] = {id:'' for id in book_id_val_map.keys()} 507 | 508 | except Exception as e: 509 | self.exception_update = True 510 | self.exception.append((None, None, None, e)) 511 | 512 | if is_restore: 513 | for field, book_id_val_map in backup_fields.items(): 514 | self.dbAPI.set_field(field, book_id_val_map) 515 | book_id_update = {} 516 | 517 | GUI.iactions['Edit Metadata'].refresh_gui(lst_id, covers_changed=False) 518 | 519 | finally: 520 | 521 | lst_id = [] 522 | for field, book_id_map in book_id_update.items(): 523 | lst_id += book_id_map.keys() 524 | self.fields_update = len(lst_id) 525 | 526 | lst_id = list(dict.fromkeys(lst_id)) 527 | self.books_update = len(lst_id) 528 | 529 | if CALIBRE_VERSION >= (5,41,0) and self.useMark and self.fields_update: 530 | set_marked('mass_search_replace_updated', lst_id) 531 | -------------------------------------------------------------------------------- /translations/es.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: \n" 4 | "POT-Creation-Date: 2023-10-21 21:56+0200\n" 5 | "PO-Revision-Date: 2023-10-21 21:56+0200\n" 6 | "Last-Translator: \n" 7 | "Language-Team: \n" 8 | "Language: es\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 13 | "X-Generator: Poedit 3.4\n" 14 | "X-Poedit-Basepath: ..\n" 15 | "X-Poedit-SearchPath-0: .\n" 16 | "X-Poedit-SearchPathExcluded-0: search_replace/calibre.py\n" 17 | 18 | #: __init__.py:29 19 | msgid "Easily apply a list of multiple saved Find and Replace operations to your books metadata" 20 | msgstr "Aplica fácilmente una lista de múltiples operaciones de Buscar y Reemplazar guardadas a los metadatos de tus libros" 21 | 22 | #: action.py:46 23 | msgid "Apply a list of multiple saved Find and Replace operations" 24 | msgstr "Aplicar una lista de múltiples operaciones guardadas de Buscar y Reemplazar" 25 | 26 | #: action.py:83 27 | msgid "&Quick Search/Replace…" 28 | msgstr "&Rápido Buscar/Reemplazar…" 29 | 30 | #: action.py:87 31 | msgid "&Selection" 32 | msgstr "&Selección" 33 | 34 | #: action.py:91 35 | msgid "&Current search" 36 | msgstr "Búsqueda &actual" 37 | 38 | #: action.py:95 39 | msgid "&Virtual library" 40 | msgstr "Biblioteca &virtual" 41 | 42 | #: action.py:99 43 | msgid "&Library" 44 | msgstr "&Biblioteca" 45 | 46 | #: action.py:105 47 | msgid "&Customize plugin…" 48 | msgstr "&Personalizar complemento…" 49 | 50 | #: action.py:146 51 | msgid "the selected books" 52 | msgstr "los libros seleccionados" 53 | 54 | #: action.py:149 55 | msgid "all books in the library {:s}" 56 | msgstr "todos los libros de la biblioteca {:s}" 57 | 58 | #: action.py:154 59 | msgid "the virtual library {:s}" 60 | msgstr "la biblioteca virtual {:s}" 61 | 62 | #: action.py:159 63 | msgid "the current search" 64 | msgstr "la búsqueda actual" 65 | 66 | #: action.py:164 67 | msgid "({:d} books)" 68 | msgstr "({:d} libros)" 69 | 70 | #: action.py:195 71 | msgid "Invalide menu configuration, the \"{:s}\" key is missing." 72 | msgstr "Configuración de menú no válida, falta la tecla \"{:s}\"." 73 | 74 | #: action.py:202 common_utils/dialogs.py:242 75 | #, python-brace-format 76 | msgid "{PLUGIN_NAME} progress" 77 | msgstr "{PLUGIN_NAME} progreso" 78 | 79 | #: action.py:205 80 | msgid "Search/Replace {:d} of {:d}. Book {:d} of {:d}." 81 | msgstr "Buscar/Reemplazar {:d} de {:d}. Libro {:d} de {:d}." 82 | 83 | #: action.py:260 action.py:306 action.py:350 search_replace/__init__.py:215 84 | msgid "Invalid operation" 85 | msgstr "Operación no válida" 86 | 87 | #: action.py:261 88 | msgid "" 89 | "A invalid operations has detected:\n" 90 | "{:s}\n" 91 | "\n" 92 | "Mass Search/Replace was canceled." 93 | msgstr "" 94 | "Se ha detectado una operación no válida:\n" 95 | "{:s}\n" 96 | "\n" 97 | "Se canceló Mass Search/Replace." 98 | 99 | #: action.py:290 100 | msgid "The library a was restored to its original state." 101 | msgstr "La biblioteca a fue restaurada a su estado original." 102 | 103 | #: action.py:293 104 | msgid "Cannot update the library" 105 | msgstr "No se puede actualizar la biblioteca" 106 | 107 | #: action.py:299 108 | msgid "Exceptions during the library update" 109 | msgstr "Excepciones durante la actualización de la biblioteca" 110 | 111 | #: action.py:300 112 | msgid "" 113 | "{:d} exceptions have occurred during the library update.\n" 114 | "Some fields may not have been updated." 115 | msgstr "" 116 | "{:d} se han producido excepciones durante la actualización de la biblioteca.\n" 117 | "Es posible que algunos campos no se hayan actualizado." 118 | 119 | #: action.py:307 120 | msgid "{:d} invalid operations has detected and have been ignored." 121 | msgstr "{:d} operaciones no válidas han sido detectadas y han sido ignoradas." 122 | 123 | #: action.py:312 124 | msgid "Update Report" 125 | msgstr "Informe de actualización" 126 | 127 | #: action.py:313 128 | msgid "Mass Search/Replace performed for {:d} books with a total of {:d} fields modify." 129 | msgstr "Mass Search/Replace realizado para {:d} libros con un total de {:d} campos modificados." 130 | 131 | #: action.py:351 132 | msgid "" 133 | "A invalid operations has detected:\n" 134 | "{:s}\n" 135 | "\n" 136 | "Continue the execution of Mass Search/Replace?\n" 137 | "Other errors may exist and will be ignored." 138 | msgstr "" 139 | "Se ha detectado una operación no válida:\n" 140 | "{:s}\n" 141 | "\n" 142 | "¿Continuar la ejecución de Mass Search/Replace?\n" 143 | "Pueden existir otros errores y serán ignorados." 144 | 145 | #: action.py:411 146 | msgid "Update the library for {:d} books with a total of {:d} fields…" 147 | msgstr "Actualizar la biblioteca para {:d} libros con un total de {:d} campos…" 148 | 149 | #: common_utils/__init__.py:407 150 | msgid "You cannot configure this plugin before calibre is restarted." 151 | msgstr "No puede configurar este complemento antes de reiniciar calibre." 152 | 153 | #: common_utils/dialogs.py:52 common_utils/dialogs.py:82 154 | msgid "Keyboard shortcuts" 155 | msgstr "Atajos de teclado" 156 | 157 | #: common_utils/dialogs.py:83 158 | msgid "Edit the keyboard shortcuts associated with this plugin" 159 | msgstr "Editar los atajos de teclado asociados con este complemento" 160 | 161 | #: common_utils/dialogs.py:99 162 | msgid "Preferences for:" 163 | msgstr "Preferencias para:" 164 | 165 | #: common_utils/dialogs.py:122 166 | msgid "Clear all settings for this plugin" 167 | msgstr "Borrar todas las configuraciones para este complemento" 168 | 169 | #: common_utils/dialogs.py:164 170 | msgid "The changes cannot be applied." 171 | msgstr "Los cambios no se pueden aplicar." 172 | 173 | #: common_utils/dialogs.py:168 174 | msgid "Are you sure you want to change your settings in this library for this plugin?" 175 | msgstr "¿Está seguro de que desea cambiar su configuración en esta biblioteca para este complemento?" 176 | 177 | #: common_utils/dialogs.py:169 common_utils/dialogs.py:181 178 | msgid "Any settings in other libraries or stored in a JSON file in your calibre plugins folder will not be touched." 179 | msgstr "Cualquier configuración en otras bibliotecas o almacenada en un archivo JSON en su carpeta de complementos de calibre no se modificará." 180 | 181 | #: common_utils/dialogs.py:180 182 | msgid "Are you sure you want to clear your settings in this library for this plugin?" 183 | msgstr "¿Está seguro de que desea borrar su configuración en esta biblioteca para este complemento?" 184 | 185 | #: common_utils/dialogs.py:201 186 | msgid "View library preferences" 187 | msgstr "Ver preferencias de biblioteca" 188 | 189 | #: common_utils/dialogs.py:202 190 | msgid "View data stored in the library database for this plugin" 191 | msgstr "Ver datos almacenados en la base de datos de la biblioteca para este complemento" 192 | 193 | #: common_utils/dialogs.py:232 194 | msgid "Cancel" 195 | msgstr "Cancelar" 196 | 197 | #: common_utils/dialogs.py:298 198 | msgid "Book {:d} of {:d}" 199 | msgstr "Libro {:d} de {:d}" 200 | 201 | #: common_utils/dialogs.py:333 202 | msgid "Copy to clipboard" 203 | msgstr "Copiar al portapapeles" 204 | 205 | #: common_utils/dialogs.py:352 206 | msgid "Add New Image" 207 | msgstr "Agregar nueva imagen" 208 | 209 | #: common_utils/dialogs.py:360 210 | msgid "&Select image source" 211 | msgstr "&Seleccionar fuente de imagen" 212 | 213 | #: common_utils/dialogs.py:363 214 | msgid "From &web domain favicon" 215 | msgstr "Desde &dominio web favicon" 216 | 217 | #: common_utils/dialogs.py:370 218 | msgid "From .png &file" 219 | msgstr "Desde &archivo .png" 220 | 221 | #: common_utils/dialogs.py:383 222 | msgid "&Save as filename:" 223 | msgstr "&Guardar como nombre de archivo:" 224 | 225 | #: common_utils/dialogs.py:404 226 | msgid "Select a .png file for the menu icon" 227 | msgstr "Seleccione un archivo .png para el icono del menú" 228 | 229 | #: common_utils/dialogs.py:410 common_utils/dialogs.py:419 230 | #: common_utils/dialogs.py:422 common_utils/dialogs.py:437 231 | #: common_utils/dialogs.py:443 common_utils/dialogs.py:445 232 | #: common_utils/dialogs.py:447 233 | msgid "Cannot import image" 234 | msgstr "No se puede importar la imagen" 235 | 236 | #: common_utils/dialogs.py:410 common_utils/dialogs.py:445 237 | msgid "Source image must be a .png file." 238 | msgstr "La imagen de origen debe ser un archivo .png." 239 | 240 | #: common_utils/dialogs.py:419 241 | msgid "You must specify a filename to save as." 242 | msgstr "Debe especificar un nombre de archivo para guardar como." 243 | 244 | #: common_utils/dialogs.py:422 245 | msgid "The save as filename should consist of a filename only." 246 | msgstr "Guardar como nombre de archivo debe consistir solo en un nombre de archivo." 247 | 248 | #: common_utils/dialogs.py:427 config.py:515 config.py:979 249 | msgid "Are you sure?" 250 | msgstr "¿Estás seguro?" 251 | 252 | #: common_utils/dialogs.py:427 253 | msgid "An image with this name already exists - overwrite it?" 254 | msgstr "Ya existe una imagen con este nombre. ¿Sobrescribirla?" 255 | 256 | #: common_utils/dialogs.py:437 257 | msgid "You must specify a web domain url" 258 | msgstr "Debe especificar una URL de dominio web" 259 | 260 | #: common_utils/dialogs.py:443 261 | msgid "You must specify a source file." 262 | msgstr "Debe especificar un archivo fuente." 263 | 264 | #: common_utils/dialogs.py:447 265 | msgid "Source image does not exist!" 266 | msgstr "¡La imagen de origen no existe!" 267 | 268 | #: common_utils/dialogs.py:477 269 | #, python-brace-format 270 | msgid "The {PLUGIN_NAME} plugin has encounter a unhandled exception." 271 | msgstr "El complemento {PLUGIN_NAME} ha encontrado una excepción no controlada." 272 | 273 | #: common_utils/dialogs.py:486 274 | msgid "Unhandled exception" 275 | msgstr "Excepción no controlada" 276 | 277 | #: common_utils/dialogs.py:500 278 | msgid "Select a ZIP archive file to import…" 279 | msgstr "Seleccione un archivo ZIP para importar…" 280 | 281 | #: common_utils/dialogs.py:511 282 | msgid "Save ZIP archive file as…" 283 | msgstr "Guardar archivo ZIP como…" 284 | 285 | #: common_utils/dialogs.py:523 286 | msgid "Select a JSON file to import…" 287 | msgstr "Seleccione un archivo JSON para importar…" 288 | 289 | #: common_utils/dialogs.py:534 290 | msgid "Save the JSON file as…" 291 | msgstr "Guardar un archivo JSON como…" 292 | 293 | #: common_utils/librarys.py:48 294 | msgid "Could not to launch {:s}" 295 | msgstr "No se pudo iniciar {:s}" 296 | 297 | #: common_utils/librarys.py:62 298 | msgid "No book selected" 299 | msgstr "Ningún libro seleccionado" 300 | 301 | #: common_utils/librarys.py:67 302 | msgid "No book in the library" 303 | msgstr "No hay libro en la biblioteca" 304 | 305 | #: common_utils/librarys.py:72 common_utils/librarys.py:78 306 | msgid "No book in the virtual library" 307 | msgstr "No hay libro en la biblioteca virtual" 308 | 309 | #: common_utils/librarys.py:83 310 | msgid "No book in the current search" 311 | msgstr "Ningún libro en la búsqueda actual" 312 | 313 | #: common_utils/templates.py:57 314 | msgid "Unknown" 315 | msgstr "Desconocido" 316 | 317 | #: common_utils/templates.py:64 318 | msgid "Template Error" 319 | msgstr "Error de plantilla" 320 | 321 | #: common_utils/templates.py:65 322 | msgid "Running the template returned an error:" 323 | msgstr "Ejecutar la plantilla devolvió un error:" 324 | 325 | #: common_utils/templates.py:77 326 | msgid "Enter a template to test using data from the selected book" 327 | msgstr "Ingrese una plantilla para probar usando datos del libro seleccionado" 328 | 329 | #: common_utils/templates.py:84 330 | msgid "Template editor" 331 | msgstr "Editor de plantilla" 332 | 333 | #: common_utils/templates.py:105 common_utils/templates.py:106 334 | #: search_replace/text.py:31 335 | msgid "Open the template editor" 336 | msgstr "Abrir el editor de plantillas" 337 | 338 | #: common_utils/widgets.py:66 339 | msgid "Restart required" 340 | msgstr "Reinicio requerido" 341 | 342 | #: common_utils/widgets.py:67 343 | msgid "Title image not found - you must restart Calibre before using this plugin!" 344 | msgstr "No se encontró la imagen del título. ¡Debe reiniciar Calibre antes de usar este complemento!" 345 | 346 | #: common_utils/widgets.py:122 347 | msgid "Undefined" 348 | msgstr "Indefinido" 349 | 350 | #: common_utils/widgets.py:270 351 | msgid "Subset of values associate to the books" 352 | msgstr "Subconjunto de valores asociados a los libros" 353 | 354 | #: common_utils/widgets.py:271 355 | msgid "No books" 356 | msgstr "Sin libros" 357 | 358 | #: common_utils/widgets.py:272 359 | msgid "{:d} books (no values)" 360 | msgstr "{:d} libros (sin valores)" 361 | 362 | #: common_utils/widgets.py:273 363 | msgid "{:d} books" 364 | msgstr "Sin notas" 365 | 366 | #: common_utils/widgets.py:396 367 | msgid "No notes" 368 | msgstr "Agregar nueva imagen…" 369 | 370 | #: common_utils/widgets.py:447 371 | msgid "Add New Image…" 372 | msgstr "Agregar nueva imagen…" 373 | 374 | #: config.py:86 375 | msgid "Interrupt execution" 376 | msgstr "Interrumpir la ejecución" 377 | 378 | #: config.py:87 379 | msgid "Stop Mass Search/Replace and display the error normally without further action." 380 | msgstr "Detener Mass Search/Replace y mostrar el error normalmente sin más acción." 381 | 382 | #: config.py:90 383 | msgid "Restore the library" 384 | msgstr "Restaurar la biblioteca" 385 | 386 | #: config.py:91 387 | msgid "Stop Mass Search/Replace and restore the library to its original state." 388 | msgstr "Detener Mass Search/Replace y restaurar la biblioteca a su estado original." 389 | 390 | #: config.py:94 391 | msgid "Updates the fields one by one. This operation can be slower than other strategies." 392 | msgstr "Actualiza los campos uno por uno. Esta operación puede ser más lenta que otras estrategias." 393 | 394 | #: config.py:97 395 | msgid "Carefully executed (slower)" 396 | msgstr "Cuidadosamente ejecutado (más lento)" 397 | 398 | #: config.py:98 399 | msgid "When a error occurs, stop Mass Search/Replace and display the error normally without further action." 400 | msgstr "Cuando ocurre un error, detenga Mass Search/Replace y muestre el error normalmente sin más acción." 401 | 402 | #: config.py:101 403 | msgid "Don't stop (slower, not recomanded)" 404 | msgstr "No detenerse (más lento, no recomendado)" 405 | 406 | #: config.py:102 407 | msgid "Update the library, no matter how many errors are encountered. The problematics fields will not be updated." 408 | msgstr "Actualice la biblioteca, sin importar cuántos errores se encuentren. Los campos problemáticos no se actualizarán." 409 | 410 | #: config.py:116 411 | msgid "Abbort" 412 | msgstr "Abortar" 413 | 414 | #: config.py:117 415 | msgid "If an invalid operation is detected, abort the changes." 416 | msgstr "Si se detecta una operación no válida, cancele los cambios." 417 | 418 | #: config.py:120 419 | msgid "Asked" 420 | msgstr "Pregunta" 421 | 422 | #: config.py:121 423 | msgid "If an invalid operation is detected, asked whether to continue or abort the changes." 424 | msgstr "Si se detecta una operación inválida, pregunta si continuar o cancelar los cambios." 425 | 426 | #: config.py:124 427 | msgid "Hidden" 428 | msgstr "Oculto" 429 | 430 | #: config.py:125 431 | msgid "Ignore all invalid operations." 432 | msgstr "Ignorar todas las operaciones inválidas." 433 | 434 | #: config.py:174 435 | msgid "Select and configure the menu items to display:" 436 | msgstr "Seleccione y configure los elementos del menú para mostrar:" 437 | 438 | #: config.py:190 439 | msgid "Move menu item up" 440 | msgstr "Mover elemento de menú hacia arriba" 441 | 442 | #: config.py:197 443 | msgid "Add menu item" 444 | msgstr "Agregar elemento de menú" 445 | 446 | #: config.py:204 447 | msgid "Copy menu item" 448 | msgstr "Copiar elemento de menú" 449 | 450 | #: config.py:211 451 | msgid "Delete menu item" 452 | msgstr "Eliminar elemento de menú" 453 | 454 | #: config.py:218 455 | msgid "Move menu item down" 456 | msgstr "Mover elemento de menú hacia abajo" 457 | 458 | #: config.py:235 459 | msgid "Mark the updated books" 460 | msgstr "Marcar los libros actualizados" 461 | 462 | #: config.py:239 463 | msgid "Display a update report" 464 | msgstr "Mostrar un informe de actualización" 465 | 466 | #: config.py:243 467 | msgid "Error strategy" 468 | msgstr "Estrategia de error" 469 | 470 | #: config.py:244 471 | msgid "Define the strategy when a error occurs during the library update" 472 | msgstr "Defina la estrategia cuando ocurra un error durante la actualización de la biblioteca" 473 | 474 | #: config.py:267 config.py:700 475 | msgid "Name" 476 | msgstr "Nombre" 477 | 478 | #: config.py:267 479 | msgid "Submenu" 480 | msgstr "Submenú" 481 | 482 | #: config.py:267 483 | msgid "Image" 484 | msgstr "Imagen" 485 | 486 | #: config.py:267 487 | msgid "Operation" 488 | msgstr "Operación" 489 | 490 | #: config.py:288 491 | msgid "&Add image…" 492 | msgstr "&Agregar imagen…" 493 | 494 | #: config.py:292 495 | msgid "&Open images folder" 496 | msgstr "&Abrir carpeta de imágenes" 497 | 498 | #: config.py:300 config.py:831 499 | msgid "&Import…" 500 | msgstr "&Importar…" 501 | 502 | #: config.py:304 config.py:835 503 | msgid "&Export…" 504 | msgstr "&Exportar…" 505 | 506 | #: config.py:327 config.py:346 config.py:850 507 | msgid "Import failed" 508 | msgstr "Importación fallida" 509 | 510 | #: config.py:327 511 | msgid "This is not a valid OWIP export archive" 512 | msgstr "Este no es un archivo de exportación OWIP válido" 513 | 514 | #: config.py:343 config.py:854 515 | msgid "Import completed" 516 | msgstr "Importación completada" 517 | 518 | #: config.py:343 519 | msgid "{:d} menu items imported" 520 | msgstr "{:d} elementos de menú importados" 521 | 522 | #: config.py:349 523 | msgid "Select a menu file archive to import…" 524 | msgstr "Seleccione un archivo de menú para importar…" 525 | 526 | #: config.py:359 config.py:384 config.py:857 config.py:870 config.py:881 527 | msgid "Export failed" 528 | msgstr "Exportación fallida" 529 | 530 | #: config.py:359 531 | msgid "No menu items selected to export" 532 | msgstr "No hay elementos de menú seleccionados para exportar" 533 | 534 | #: config.py:381 config.py:878 535 | msgid "Export completed" 536 | msgstr "Exportación completada" 537 | 538 | #: config.py:381 539 | msgid "" 540 | "{:d} menu items exported to\n" 541 | "{:s}" 542 | msgstr "" 543 | "{:d} elementos de menú exportados a\n" 544 | "{:s}" 545 | 546 | #: config.py:387 547 | msgid "Save menu archive as…" 548 | msgstr "Guardar archivo de menú como…" 549 | 550 | #: config.py:499 551 | msgid "(copy)" 552 | msgstr "(copiar)" 553 | 554 | #: config.py:512 555 | msgid "Are you sure you want to delete this menu item?" 556 | msgstr "¿Está seguro de que desea eliminar este elemento del menú?" 557 | 558 | #: config.py:514 559 | msgid "Are you sure you want to delete the selected {:d} menu items?" 560 | msgstr "¿Está seguro de que desea eliminar los elementos de menú {:d} seleccionados?" 561 | 562 | #: config.py:646 563 | msgid "{:d}/{:d} operations" 564 | msgstr "{:d}/{:d} operaciones" 565 | 566 | #: config.py:648 567 | msgid "{:d} operations" 568 | msgstr "{:d} operaciones" 569 | 570 | #: config.py:664 571 | msgid "This operations list contain a error" 572 | msgstr "Esta lista de operaciones contiene un error" 573 | 574 | #: config.py:667 575 | msgid "Edit the operations list" 576 | msgstr "Editar la lista de operaciones" 577 | 578 | #: config.py:700 579 | msgid "Columns" 580 | msgstr "Columnas" 581 | 582 | #: config.py:700 583 | msgid "Template" 584 | msgstr "Plantilla" 585 | 586 | #: config.py:700 search_replace/text.py:20 587 | msgid "Search mode" 588 | msgstr "Modo de busqueda" 589 | 590 | #: config.py:700 591 | msgid "Search" 592 | msgstr "Buscar" 593 | 594 | #: config.py:700 595 | msgid "Replace" 596 | msgstr "Reemplazar" 597 | 598 | #: config.py:711 599 | msgid "List of operations for a quick Search/Replaces" 600 | msgstr "Lista de operaciones para una búsqueda/reemplazo rápido" 601 | 602 | #: config.py:716 603 | msgid "List of Search/Replace operations for {:s}" 604 | msgstr "Lista de operaciones de búsqueda/reemplazo para {:s}" 605 | 606 | #: config.py:730 607 | msgid "Select and configure the order of execution of the operations of Search/Replace operations:" 608 | msgstr "Seleccione y configure el orden de ejecución de las operaciones de búsqueda/reemplazo:" 609 | 610 | #: config.py:750 611 | msgid "Move operation up" 612 | msgstr "Mover la operación hacia arriba" 613 | 614 | #: config.py:758 615 | msgid "Add operation" 616 | msgstr "Agregar operación" 617 | 618 | #: config.py:766 619 | msgid "Copy operation" 620 | msgstr "Copiar operación" 621 | 622 | #: config.py:774 623 | msgid "Delete operation" 624 | msgstr "Eliminar operación" 625 | 626 | #: config.py:782 627 | msgid "Move operation down" 628 | msgstr "Mover la operación hacia abajo" 629 | 630 | #: config.py:850 631 | msgid "This is not a valid JSON file" 632 | msgstr "Este no es un archivo JSON válido" 633 | 634 | #: config.py:854 635 | msgid "{:d} operations imported" 636 | msgstr "{:d} operaciones importados" 637 | 638 | #: config.py:870 639 | msgid "No operations selected to export" 640 | msgstr "No se seleccionaron operaciones para exportar" 641 | 642 | #: config.py:878 643 | msgid "" 644 | "{:d} operations exported to\n" 645 | "{:s}" 646 | msgstr "" 647 | "{:d} operaciones exportadas a\n" 648 | "{:s}" 649 | 650 | #: config.py:884 651 | msgid "Save the operations as…" 652 | msgstr "Guardar las operaciones como…" 653 | 654 | #: config.py:976 655 | msgid "Are you sure you want to delete this operation?" 656 | msgstr "¿Está seguro de que desea eliminar esta operación?" 657 | 658 | #: config.py:978 659 | msgid "Are you sure you want to delete the selected {:d} operations?" 660 | msgstr "¿Está seguro de que desea eliminar las operaciones {:d} seleccionadas?" 661 | 662 | #: config.py:1141 663 | msgid "Error Strategy" 664 | msgstr "Estrategia de error" 665 | 666 | #: config.py:1150 667 | msgid "Set the strategy when an invalid operation has detected:" 668 | msgstr "Establecer la estrategia cuando se detecte una operación no válida:" 669 | 670 | #: config.py:1161 671 | msgid "Define the strategy when a error occurs during the library update:" 672 | msgstr "Defina la estrategia cuando ocurra un error durante la actualización de la biblioteca:" 673 | 674 | #: search_replace/__init__.py:66 675 | msgid "Invalid operation, the \"{:s}\" key is missing." 676 | msgstr "Operación no válida, falta la tecla \"{:s}\"." 677 | 678 | #: search_replace/__init__.py:84 679 | msgid "Search field \"{:s}\" is not available for this library" 680 | msgstr "El campo de búsqueda \"{:s}\" no está disponible para esta biblioteca" 681 | 682 | #: search_replace/__init__.py:87 683 | msgid "Destination field \"{:s}\" is not available for this library" 684 | msgstr "El campo de destino \"{:s}\" no está disponible para esta biblioteca" 685 | 686 | #: search_replace/__init__.py:94 687 | msgid "Identifier type \"{:s}\" is not available for this library" 688 | msgstr "El tipo de identificador \"{:s}\" no está disponible para esta biblioteca" 689 | 690 | #: search_replace/__init__.py:197 691 | msgid "Configuration of a Search/Replace operation" 692 | msgstr "Configuración de una operación de Buscar/Reemplazar" 693 | 694 | #: search_replace/__init__.py:216 695 | msgid "" 696 | "The registering of Find/Replace operation has failed.\n" 697 | "{:s}\n" 698 | "Do you want discard the changes?" 699 | msgstr "" 700 | "Ha fallado el registro de la operación Buscar/Reemplazar.\n" 701 | "{:s}\n" 702 | "¿Quieres descartar los cambios?" 703 | 704 | #: search_replace/__init__.py:241 705 | msgid "Changed operation" 706 | msgstr "" 707 | 708 | #: search_replace/__init__.py:242 709 | msgid "" 710 | "The content of the Find/Replace operation \"{:s}\" was edited after being loaded into the editor.\n" 711 | "The operation will be saved has it and not as a shared named operation!\n" 712 | "Do you want continue?" 713 | msgstr "" 714 | 715 | #: search_replace/text.py:15 716 | msgid "You must specify a \"Search field\"" 717 | msgstr "Debes especificar un \"campo de búsqueda\"" 718 | 719 | #: search_replace/text.py:18 720 | msgid "Case to be applied" 721 | msgstr "Aplicar mayúsculas" 722 | 723 | #: search_replace/text.py:19 724 | msgid "Replace mode" 725 | msgstr "Modo de reemplazo" 726 | 727 | #: search_replace/text.py:21 728 | msgid "Identifier type" 729 | msgstr "Tipo de identificador" 730 | 731 | #: search_replace/text.py:23 732 | msgid "Replace field" 733 | msgstr "Reemplazar campo" 734 | 735 | #: search_replace/text.py:26 736 | msgid "In field replacement mode, the specified field is set to the text and all previous values are erased. After replacement is finished, the text can be changed to upper-case, lower-case, or title-case." 737 | msgstr "En el modo de reemplazo de campo, el campo especificado se establece en el texto y todos los valores anteriores se borran. Una vez que finaliza el reemplazo, el texto se puede cambiar a mayúsculas, minúsculas o título." 738 | 739 | #: search_replace/text.py:33 740 | msgid "Invalid identifier string. It must be a comma-separated list of pairs of strings separated by a colon." 741 | msgstr "Cadena de identificador no válida. Debe ser una lista separada por comas de pares de cadenas separadas por dos puntos." 742 | 743 | #: search_replace/text.py:36 744 | msgid "The field \"{:s}\" is not defined" 745 | msgstr "El campo \"{:s}\" no está definido" 746 | 747 | #: search_replace/text.py:39 748 | msgid "The operation field \"{:s}\" contains a invalid value ({:s})." 749 | msgstr "El campo de operación \"{:s}\" contiene un valor no válido ({:s})." 750 | 751 | #: search_replace/text.py:42 752 | msgid "The value of this field is localized (translated). This can cause problems when using settings shared on internet or when changing the user interface language." 753 | msgstr "El valor de este campo está localizado (traducido). Esto puede causar problemas al usar configuraciones compartidas en Internet o al cambiar el idioma de la interfaz de usuario." 754 | -------------------------------------------------------------------------------- /translations/fr.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: \n" 4 | "POT-Creation-Date: 2023-10-08 13:51+0200\n" 5 | "PO-Revision-Date: 2023-10-08 13:51+0200\n" 6 | "Last-Translator: \n" 7 | "Language-Team: \n" 8 | "Language: fr\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=UTF-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 13 | "X-Generator: Poedit 3.4\n" 14 | "X-Poedit-Basepath: ..\n" 15 | "X-Poedit-SearchPath-0: .\n" 16 | "X-Poedit-SearchPathExcluded-0: search_replace/calibre.py\n" 17 | 18 | #: __init__.py:29 19 | msgid "Easily apply a list of multiple saved Find and Replace operations to your books metadata" 20 | msgstr "Appliquer facilement une liste de plusieurs opérations de Rechercher et Remplacer sauvegardées aux métadonnées de vos livres" 21 | 22 | #: action.py:46 23 | msgid "Apply a list of multiple saved Find and Replace operations" 24 | msgstr "Appliquer une liste de plusieurs opérations de Rechercher et Remplacer" 25 | 26 | #: action.py:83 27 | msgid "&Quick Search/Replace…" 28 | msgstr "&Rechercher/Remplacer rapide…" 29 | 30 | #: action.py:87 31 | msgid "&Selection" 32 | msgstr "&Sélection" 33 | 34 | #: action.py:91 35 | msgid "&Current search" 36 | msgstr "&Recherche actuelle" 37 | 38 | #: action.py:95 39 | msgid "&Virtual library" 40 | msgstr "Bibliothèque &virtuel" 41 | 42 | #: action.py:99 43 | msgid "&Library" 44 | msgstr "&Bibliothèque" 45 | 46 | #: action.py:105 47 | msgid "&Customize plugin…" 48 | msgstr "&Personnaliser l'extension…" 49 | 50 | #: action.py:146 51 | msgid "the selected books" 52 | msgstr "les livres sélectionnés" 53 | 54 | #: action.py:149 55 | msgid "all books in the library {:s}" 56 | msgstr "tous les livres de la bibliothèque {:s}" 57 | 58 | #: action.py:154 59 | msgid "the virtual library {:s}" 60 | msgstr "la bibliothèque virtuel {:s}" 61 | 62 | #: action.py:159 63 | msgid "the current search" 64 | msgstr "la recherche actuelle" 65 | 66 | #: action.py:164 67 | msgid "({:d} books)" 68 | msgstr "({:d} livres)" 69 | 70 | #: action.py:195 71 | msgid "Invalide menu configuration, the \"{:s}\" key is missing." 72 | msgstr "Configuration de menu non valide, la clé « {:s} » est manquante." 73 | 74 | #: action.py:202 common_utils/dialogs.py:242 75 | #, python-brace-format 76 | msgid "{PLUGIN_NAME} progress" 77 | msgstr "Progression de {PLUGIN_NAME}" 78 | 79 | #: action.py:205 80 | msgid "Search/Replace {:d} of {:d}. Book {:d} of {:d}." 81 | msgstr "Rechercher/Remplacer {:d} sur {:d}. Livre {:d} sur {:d}." 82 | 83 | #: action.py:260 action.py:306 action.py:350 search_replace/__init__.py:215 84 | msgid "Invalid operation" 85 | msgstr "Opération non valide" 86 | 87 | #: action.py:261 88 | msgid "" 89 | "A invalid operations has detected:\n" 90 | "{:s}\n" 91 | "\n" 92 | "Mass Search/Replace was canceled." 93 | msgstr "" 94 | "Une opération non valide a été détectée :\n" 95 | "{:s}\n" 96 | "\n" 97 | "Mass Search/Replace a été annulée." 98 | 99 | #: action.py:290 100 | msgid "The library a was restored to its original state." 101 | msgstr "La bibliothèque a été restaurée a son état d'origine." 102 | 103 | #: action.py:293 104 | msgid "Cannot update the library" 105 | msgstr "Impossible de mettre à jour la bibliothèque" 106 | 107 | #: action.py:299 108 | msgid "Exceptions during the library update" 109 | msgstr "Exceptions lors de la mise à jour de la bibliothèque" 110 | 111 | #: action.py:300 112 | msgid "" 113 | "{:d} exceptions have occurred during the library update.\n" 114 | "Some fields may not have been updated." 115 | msgstr "" 116 | "{:d} exceptions sont survenue lors de la mise à jour de la bibliothèque.\n" 117 | "Certains champs peuvent ne pas avoir était mis à jour." 118 | 119 | #: action.py:307 120 | msgid "{:d} invalid operations has detected and have been ignored." 121 | msgstr "{:d} opérations non valides ont été détectées et ont été ignorées." 122 | 123 | #: action.py:312 124 | msgid "Update Report" 125 | msgstr "Rapport de mise à jour" 126 | 127 | #: action.py:313 128 | msgid "Mass Search/Replace performed for {:d} books with a total of {:d} fields modify." 129 | msgstr "Mass Search/Replace effectué pour {:d} livres avec un total de {:d} champs modifier." 130 | 131 | #: action.py:351 132 | msgid "" 133 | "A invalid operations has detected:\n" 134 | "{:s}\n" 135 | "\n" 136 | "Continue the execution of Mass Search/Replace?\n" 137 | "Other errors may exist and will be ignored." 138 | msgstr "" 139 | "Une opération non valide a été détectée :\n" 140 | "{:s}\n" 141 | "\n" 142 | "Poursuivre l'exécution de Mass Search/Replace ?\n" 143 | "D'autres erreurs peuvent exister et seront ignorées." 144 | 145 | #: action.py:411 146 | msgid "Update the library for {:d} books with a total of {:d} fields…" 147 | msgstr "Mise a jour de la bibliothèque pour {:d} livres avec un total de {:d} champs…" 148 | 149 | #: common_utils/__init__.py:407 150 | msgid "You cannot configure this plugin before calibre is restarted." 151 | msgstr "Vous ne pouvez pas configurer ce plugin avant le redémarrage de Calibre." 152 | 153 | #: common_utils/dialogs.py:52 common_utils/dialogs.py:82 154 | msgid "Keyboard shortcuts" 155 | msgstr "Raccourcis clavier" 156 | 157 | #: common_utils/dialogs.py:83 158 | msgid "Edit the keyboard shortcuts associated with this plugin" 159 | msgstr "Modifier les raccourcis clavier associés à cette extension" 160 | 161 | #: common_utils/dialogs.py:99 162 | msgid "Preferences for:" 163 | msgstr "Préférences pour :" 164 | 165 | #: common_utils/dialogs.py:122 166 | msgid "Clear all settings for this plugin" 167 | msgstr "Effacer tous les paramètres de ce plugin" 168 | 169 | #: common_utils/dialogs.py:164 170 | msgid "The changes cannot be applied." 171 | msgstr "Les modifications ne peuvent pas être appliquées." 172 | 173 | #: common_utils/dialogs.py:168 174 | msgid "Are you sure you want to change your settings in this library for this plugin?" 175 | msgstr "Êtes-vous sûr de vouloir modifier vos paramètres dans cette bibliothèque pour ce plugin ?" 176 | 177 | #: common_utils/dialogs.py:169 common_utils/dialogs.py:181 178 | msgid "Any settings in other libraries or stored in a JSON file in your calibre plugins folder will not be touched." 179 | msgstr "Les paramètres présents dans d'autres bibliothèques ou stockés dans un fichier JSON dans le dossier des plugins de Calibre ne seront pas modifiés." 180 | 181 | #: common_utils/dialogs.py:180 182 | msgid "Are you sure you want to clear your settings in this library for this plugin?" 183 | msgstr "Êtes-vous sûr de vouloir effacer vos paramètres dans cette bibliothèque pour ce plugin ?" 184 | 185 | #: common_utils/dialogs.py:201 186 | msgid "View library preferences" 187 | msgstr "Afficher les préférences de la bibliothèque" 188 | 189 | #: common_utils/dialogs.py:202 190 | msgid "View data stored in the library database for this plugin" 191 | msgstr "Afficher les données stockées dans la base de données de la bibliothèque pour ce plugin" 192 | 193 | #: common_utils/dialogs.py:232 194 | msgid "Cancel" 195 | msgstr "Annuler" 196 | 197 | #: common_utils/dialogs.py:298 198 | msgid "Book {:d} of {:d}" 199 | msgstr "Livre {:d} sur {:d}" 200 | 201 | #: common_utils/dialogs.py:333 202 | msgid "Copy to clipboard" 203 | msgstr "Copier dans le presse-papiers" 204 | 205 | #: common_utils/dialogs.py:352 206 | msgid "Add New Image" 207 | msgstr "Ajouter une nouvelle image" 208 | 209 | #: common_utils/dialogs.py:360 210 | msgid "&Select image source" 211 | msgstr "&Sélectionner la source de l'image" 212 | 213 | #: common_utils/dialogs.py:363 214 | msgid "From &web domain favicon" 215 | msgstr "Depuis favicon de site &web" 216 | 217 | #: common_utils/dialogs.py:370 218 | msgid "From .png &file" 219 | msgstr "Depuis un &fichier .png" 220 | 221 | #: common_utils/dialogs.py:383 222 | msgid "&Save as filename:" 223 | msgstr "&Enregitrement comme nom de fichier :" 224 | 225 | #: common_utils/dialogs.py:404 226 | msgid "Select a .png file for the menu icon" 227 | msgstr "Sélectionner un fichier .png pour l'icône du menu" 228 | 229 | #: common_utils/dialogs.py:410 common_utils/dialogs.py:419 230 | #: common_utils/dialogs.py:422 common_utils/dialogs.py:437 231 | #: common_utils/dialogs.py:443 common_utils/dialogs.py:445 232 | #: common_utils/dialogs.py:447 233 | msgid "Cannot import image" 234 | msgstr "Impossible d'importer l'image" 235 | 236 | #: common_utils/dialogs.py:410 common_utils/dialogs.py:445 237 | msgid "Source image must be a .png file." 238 | msgstr "L'image source doit être un fichier .png." 239 | 240 | #: common_utils/dialogs.py:419 241 | msgid "You must specify a filename to save as." 242 | msgstr "Vous devez spécifier un nom de fichier pour l'enregistrer." 243 | 244 | #: common_utils/dialogs.py:422 245 | msgid "The save as filename should consist of a filename only." 246 | msgstr "L'enregitrement en tant que nom de fichier doit consister uniquement en un nom de fichier." 247 | 248 | #: common_utils/dialogs.py:427 config.py:515 config.py:979 249 | msgid "Are you sure?" 250 | msgstr "Êtes-vous sûr ?" 251 | 252 | #: common_utils/dialogs.py:427 253 | msgid "An image with this name already exists - overwrite it?" 254 | msgstr "Une image portant ce nom existe déjà, l'écraser ?" 255 | 256 | #: common_utils/dialogs.py:437 257 | msgid "You must specify a web domain url" 258 | msgstr "Vous devez spécifier une url de site web" 259 | 260 | #: common_utils/dialogs.py:443 261 | msgid "You must specify a source file." 262 | msgstr "Vous devez spécifier un fichier source." 263 | 264 | #: common_utils/dialogs.py:447 265 | msgid "Source image does not exist!" 266 | msgstr "L'image source n'existe pas !" 267 | 268 | #: common_utils/dialogs.py:477 269 | #, python-brace-format 270 | msgid "The {PLUGIN_NAME} plugin has encounter a unhandled exception." 271 | msgstr "Le plugin {PLUGIN_NAME} a rencontré une exception non gérée." 272 | 273 | #: common_utils/dialogs.py:486 274 | msgid "Unhandled exception" 275 | msgstr "Exception non gérée" 276 | 277 | #: common_utils/dialogs.py:500 278 | msgid "Select a ZIP archive file to import…" 279 | msgstr "Sélectionnez un fichier d'archive ZIP à importer…" 280 | 281 | #: common_utils/dialogs.py:511 282 | msgid "Save ZIP archive file as…" 283 | msgstr "Enregistrer l'archive ZIP sous…" 284 | 285 | #: common_utils/dialogs.py:523 286 | msgid "Select a JSON file to import…" 287 | msgstr "Sélectionnez un fichier JSON à importer…" 288 | 289 | #: common_utils/dialogs.py:534 290 | msgid "Save the JSON file as…" 291 | msgstr "Enregistrer le fichier JSON sous…" 292 | 293 | #: common_utils/librarys.py:48 294 | msgid "Could not to launch {:s}" 295 | msgstr "Impossible de lancer {:s}" 296 | 297 | #: common_utils/librarys.py:62 298 | msgid "No book selected" 299 | msgstr "Aucun livre sélectionné" 300 | 301 | #: common_utils/librarys.py:67 302 | msgid "No book in the library" 303 | msgstr "Pas de livres dans bibliothèque" 304 | 305 | #: common_utils/librarys.py:72 common_utils/librarys.py:78 306 | msgid "No book in the virtual library" 307 | msgstr "Pas de livres dans la bibliothèque virtuel" 308 | 309 | #: common_utils/librarys.py:83 310 | msgid "No book in the current search" 311 | msgstr "Pas de livres dans la recherche actuelle" 312 | 313 | #: common_utils/templates.py:57 314 | msgid "Unknown" 315 | msgstr "Inconnu(e)" 316 | 317 | #: common_utils/templates.py:64 318 | msgid "Template Error" 319 | msgstr "Erreur de modèle" 320 | 321 | #: common_utils/templates.py:65 322 | msgid "Running the template returned an error:" 323 | msgstr "L'exécution du modèle a renvoyé une erreur :" 324 | 325 | #: common_utils/templates.py:77 326 | msgid "Enter a template to test using data from the selected book" 327 | msgstr "Saisissez un modèle à tester en utilisant les données du livre sélectionné" 328 | 329 | #: common_utils/templates.py:84 330 | msgid "Template editor" 331 | msgstr "Éditeur de modèles" 332 | 333 | #: common_utils/templates.py:105 common_utils/templates.py:106 334 | #: search_replace/text.py:31 335 | msgid "Open the template editor" 336 | msgstr "Ouvrir l'éditeur de modèles" 337 | 338 | #: common_utils/widgets.py:66 339 | msgid "Restart required" 340 | msgstr "Redémarrage nécessaire" 341 | 342 | #: common_utils/widgets.py:67 343 | msgid "Title image not found - you must restart Calibre before using this plugin!" 344 | msgstr "L'image d'icone n'a pas était trouvée - vous devriez mieux redémarrer Calibre avant d'utiliser ce plugin !" 345 | 346 | #: common_utils/widgets.py:122 347 | msgid "Undefined" 348 | msgstr "Non défini" 349 | 350 | #: common_utils/widgets.py:270 351 | msgid "Subset of values associate to the books" 352 | msgstr "Sous-ensemble de valeurs associées aux livres" 353 | 354 | #: common_utils/widgets.py:271 355 | msgid "No books" 356 | msgstr "Aucun livre" 357 | 358 | #: common_utils/widgets.py:272 359 | msgid "{:d} books (no values)" 360 | msgstr "{:d} livres (pas de valeurs)" 361 | 362 | #: common_utils/widgets.py:273 363 | msgid "{:d} books" 364 | msgstr "{:d} livres" 365 | 366 | #: common_utils/widgets.py:396 367 | msgid "No notes" 368 | msgstr "Aucune notes" 369 | 370 | #: common_utils/widgets.py:442 371 | msgid "Add New Image…" 372 | msgstr "Ajouter une nouvelle image…" 373 | 374 | #: config.py:86 375 | msgid "Interrupt execution" 376 | msgstr "Interrompre l'exécution" 377 | 378 | #: config.py:87 379 | msgid "Stop Mass Search/Replace and display the error normally without further action." 380 | msgstr "Arrêter Mass Search/Replace et affichez l'erreur normalement sans autre action." 381 | 382 | #: config.py:90 383 | msgid "Restore the library" 384 | msgstr "Restaurer la bibliothèque" 385 | 386 | #: config.py:91 387 | msgid "Stop Mass Search/Replace and restore the library to its original state." 388 | msgstr "Arrêter Mass Search/Replace et rétablir la bibliothèque dans son état initial." 389 | 390 | #: config.py:94 391 | msgid "Updates the fields one by one. This operation can be slower than other strategies." 392 | msgstr "Met à jour les champs un par un. Cette opération peut être plus lente que les autres stratégies." 393 | 394 | #: config.py:97 395 | msgid "Carefully executed (slower)" 396 | msgstr "Exécuter prudemment (plus lent)" 397 | 398 | #: config.py:98 399 | msgid "When a error occurs, stop Mass Search/Replace and display the error normally without further action." 400 | msgstr "Lorsqu'une erreur se produit, arrêté Mass Search/Replace et affiché l'erreur normalement sans autre action." 401 | 402 | #: config.py:101 403 | msgid "Don't stop (slower, not recomanded)" 404 | msgstr "Ne pas s'arrêter (plus lent, non recommandé)" 405 | 406 | #: config.py:102 407 | msgid "Update the library, no matter how many errors are encountered. The problematics fields will not be updated." 408 | msgstr "Mettre à jour la bibliothèque, quel que soit le nombre d'erreurs rencontrées. Les champs problématiques ne seront pas mis à jour." 409 | 410 | #: config.py:116 411 | msgid "Abbort" 412 | msgstr "Abandonner" 413 | 414 | #: config.py:117 415 | msgid "If an invalid operation is detected, abort the changes." 416 | msgstr "Si une opération non valide est détectée, annulé les modifications." 417 | 418 | #: config.py:120 419 | msgid "Asked" 420 | msgstr "Demander" 421 | 422 | #: config.py:121 423 | msgid "If an invalid operation is detected, asked whether to continue or abort the changes." 424 | msgstr "Si une opération non valide est détectée, demandé s'il faut poursuivre ou annuler les modifications." 425 | 426 | #: config.py:124 427 | msgid "Hidden" 428 | msgstr "Masquer" 429 | 430 | #: config.py:125 431 | msgid "Ignore all invalid operations." 432 | msgstr "Ignorer toutes les opérations non valide." 433 | 434 | #: config.py:174 435 | msgid "Select and configure the menu items to display:" 436 | msgstr "Sélectionner et configurer les éléments du menu à afficher :" 437 | 438 | #: config.py:190 439 | msgid "Move menu item up" 440 | msgstr "Déplacer la ligne de menu vers le haut" 441 | 442 | #: config.py:197 443 | msgid "Add menu item" 444 | msgstr "Ajouter une ligne de menu" 445 | 446 | #: config.py:204 447 | msgid "Copy menu item" 448 | msgstr "Copier la ligne de menu" 449 | 450 | #: config.py:211 451 | msgid "Delete menu item" 452 | msgstr "Supprimer une ligne de menu" 453 | 454 | #: config.py:218 455 | msgid "Move menu item down" 456 | msgstr "Déplacer la ligne de menu vers le bas" 457 | 458 | #: config.py:235 459 | msgid "Mark the updated books" 460 | msgstr "Marquer les livres mis à jour" 461 | 462 | #: config.py:239 463 | msgid "Display a update report" 464 | msgstr "Afficher un rapport de mise à jour" 465 | 466 | #: config.py:243 467 | msgid "Error strategy" 468 | msgstr "Stratégie d'erreur" 469 | 470 | #: config.py:244 471 | msgid "Define the strategy when a error occurs during the library update" 472 | msgstr "Définir la stratégie lorsqu'une erreur se produit lors de la mise à jour de la bibliothèque" 473 | 474 | #: config.py:267 config.py:700 475 | msgid "Name" 476 | msgstr "Nom" 477 | 478 | #: config.py:267 479 | msgid "Submenu" 480 | msgstr "Sous-menu" 481 | 482 | #: config.py:267 483 | msgid "Image" 484 | msgstr "Image" 485 | 486 | #: config.py:267 487 | msgid "Operation" 488 | msgstr "Opération" 489 | 490 | #: config.py:288 491 | msgid "&Add image…" 492 | msgstr "&Ajouter une image…" 493 | 494 | #: config.py:292 495 | msgid "&Open images folder" 496 | msgstr "&Ouvrir le dossier des images" 497 | 498 | #: config.py:300 config.py:831 499 | msgid "&Import…" 500 | msgstr "&Importer…" 501 | 502 | #: config.py:304 config.py:835 503 | msgid "&Export…" 504 | msgstr "&Exporter…" 505 | 506 | #: config.py:327 config.py:346 config.py:850 507 | msgid "Import failed" 508 | msgstr "Echec de l'importation" 509 | 510 | #: config.py:327 511 | msgid "This is not a valid OWIP export archive" 512 | msgstr "Ceci n'est pas une archive d'exportation OWIP valide" 513 | 514 | #: config.py:343 config.py:854 515 | msgid "Import completed" 516 | msgstr "Importation terminée" 517 | 518 | #: config.py:343 519 | msgid "{:d} menu items imported" 520 | msgstr "{:d} éléments de menu importés" 521 | 522 | #: config.py:349 523 | msgid "Select a menu file archive to import…" 524 | msgstr "Sélectionnez un fichier d'archive de menu à importer…" 525 | 526 | #: config.py:359 config.py:384 config.py:857 config.py:870 config.py:881 527 | msgid "Export failed" 528 | msgstr "Echec de l'exportation" 529 | 530 | #: config.py:359 531 | msgid "No menu items selected to export" 532 | msgstr "Aucun élément de menu sélectionné pour l'exportation" 533 | 534 | #: config.py:381 config.py:878 535 | msgid "Export completed" 536 | msgstr "Exportation terminée" 537 | 538 | #: config.py:381 539 | msgid "" 540 | "{:d} menu items exported to\n" 541 | "{:s}" 542 | msgstr "" 543 | "{:d} éléments de menu exportés\n" 544 | "{:s}" 545 | 546 | #: config.py:387 547 | msgid "Save menu archive as…" 548 | msgstr "Enregistrer l'archive sous…" 549 | 550 | #: config.py:499 551 | msgid "(copy)" 552 | msgstr "(copie)" 553 | 554 | #: config.py:512 555 | msgid "Are you sure you want to delete this menu item?" 556 | msgstr "Êtes-vous sûr de vouloir supprimer cette ligne du menu ?" 557 | 558 | #: config.py:514 559 | msgid "Are you sure you want to delete the selected {:d} menu items?" 560 | msgstr "Êtes-vous sûr de vouloir supprimer les {:d} lignes de menu sélectionnés ?" 561 | 562 | #: config.py:646 563 | msgid "{:d}/{:d} operations" 564 | msgstr "{:d}/{:d} opérations" 565 | 566 | #: config.py:648 567 | msgid "{:d} operations" 568 | msgstr "{:d} opérations" 569 | 570 | #: config.py:664 571 | msgid "This operations list contain a error" 572 | msgstr "Cette liste d'opérations contient une erreur" 573 | 574 | #: config.py:667 575 | msgid "Edit the operations list" 576 | msgstr "Modifier la liste d'opérations" 577 | 578 | #: config.py:700 579 | msgid "Columns" 580 | msgstr "Colonnes" 581 | 582 | #: config.py:700 583 | msgid "Template" 584 | msgstr "Modèle" 585 | 586 | #: config.py:700 search_replace/text.py:20 587 | msgid "Search mode" 588 | msgstr "Type de recherche" 589 | 590 | #: config.py:700 591 | msgid "Search" 592 | msgstr "Rechercher" 593 | 594 | #: config.py:700 595 | msgid "Replace" 596 | msgstr "Remplacer" 597 | 598 | #: config.py:711 599 | msgid "List of operations for a quick Search/Replaces" 600 | msgstr "Liste des opérations pour un Rechercher/Remplacer rapide" 601 | 602 | #: config.py:716 603 | msgid "List of Search/Replace operations for {:s}" 604 | msgstr "Liste des opérations de Rechercher/Remplacer pour {:s}" 605 | 606 | #: config.py:730 607 | msgid "Select and configure the order of execution of the operations of Search/Replace operations:" 608 | msgstr "Sélectionner et configurer l'ordre d'exécution des opérations de Rechercher/Remplacer :" 609 | 610 | #: config.py:750 611 | msgid "Move operation up" 612 | msgstr "Déplacer l'opération vers le haut" 613 | 614 | #: config.py:758 615 | msgid "Add operation" 616 | msgstr "Ajouter une opération" 617 | 618 | #: config.py:766 619 | msgid "Copy operation" 620 | msgstr "Copier l'opération de menu" 621 | 622 | #: config.py:774 623 | msgid "Delete operation" 624 | msgstr "Supprimer l'opération" 625 | 626 | #: config.py:782 627 | msgid "Move operation down" 628 | msgstr "Déplacer l'opération vers le bas" 629 | 630 | #: config.py:850 631 | msgid "This is not a valid JSON file" 632 | msgstr "Ceci n'est pas fichier JSON valide" 633 | 634 | #: config.py:854 635 | msgid "{:d} operations imported" 636 | msgstr "{:d} opérations importés" 637 | 638 | #: config.py:870 639 | msgid "No operations selected to export" 640 | msgstr "Aucune opérations sélectionné pour l'exportation" 641 | 642 | #: config.py:878 643 | msgid "" 644 | "{:d} operations exported to\n" 645 | "{:s}" 646 | msgstr "" 647 | "{:d} opérations exportés\n" 648 | "{:s}" 649 | 650 | #: config.py:976 651 | msgid "Are you sure you want to delete this operation?" 652 | msgstr "Êtes-vous sûr de vouloir supprimer cette opération ?" 653 | 654 | #: config.py:978 655 | msgid "Are you sure you want to delete the selected {:d} operations?" 656 | msgstr "Êtes-vous sûr de vouloir supprimer les {:d} opérations ?" 657 | 658 | #: config.py:1141 659 | msgid "Error Strategy" 660 | msgstr "Stratégie d'erreur" 661 | 662 | #: config.py:1150 663 | msgid "Set the strategy when an invalid operation has detected:" 664 | msgstr "Définir la stratégie lorsqu'une opération non valide est détectée :" 665 | 666 | #: config.py:1161 667 | msgid "Define the strategy when a error occurs during the library update:" 668 | msgstr "Définir la stratégie lorsqu'une erreur se produit lors de la mise à jour de la bibliothèque :" 669 | 670 | #: search_replace/__init__.py:66 671 | msgid "Invalid operation, the \"{:s}\" key is missing." 672 | msgstr "Opération non valide, la clé « {:s} » est manquante." 673 | 674 | #: search_replace/__init__.py:84 675 | msgid "Search field \"{:s}\" is not available for this library" 676 | msgstr "Le champ de recherche « {:s} » n'est pas disponible pour cette bibliothèque" 677 | 678 | #: search_replace/__init__.py:87 679 | msgid "Destination field \"{:s}\" is not available for this library" 680 | msgstr "Le champ de destination « {:s} » n'est pas disponible pour cette bibliothèque" 681 | 682 | #: search_replace/__init__.py:94 683 | msgid "Identifier type \"{:s}\" is not available for this library" 684 | msgstr "Le type d'identifiant « {:s} » n'est pas disponible pour cette bibliothèque" 685 | 686 | #: search_replace/__init__.py:197 687 | msgid "Configuration of a Search/Replace operation" 688 | msgstr "Configuration d'une opération de Rechercher/Remplacer" 689 | 690 | #: search_replace/__init__.py:216 691 | msgid "" 692 | "The registering of Find/Replace operation has failed.\n" 693 | "{:s}\n" 694 | "Do you want discard the changes?" 695 | msgstr "" 696 | "L'enregistrement de l'opération « Rechercher/Remplacer » a échoué.\n" 697 | "{:s}\n" 698 | "Voulez-vous abandonner les modifications ?" 699 | 700 | #: search_replace/__init__.py:241 701 | msgid "Changed operation" 702 | msgstr "Opération modifier" 703 | 704 | #: search_replace/__init__.py:242 705 | msgid "" 706 | "The content of the Find/Replace operation \"{:s}\" was edited after being loaded into the editor.\n" 707 | "The operation will be saved has it and not as a shared named operation!\n" 708 | "Do you want continue?" 709 | msgstr "" 710 | "Le contenu de l'opération Rechercher/Remplacer « {:s} » a été modifié après avoir été chargé dans l'éditeur.\n" 711 | "L'opération sera enregistrée comme telle et non comme une opération nommée partagée !\n" 712 | "Voulez-vous continuer ?" 713 | 714 | #: search_replace/text.py:15 715 | msgid "You must specify a \"Search field\"" 716 | msgstr "Vous devez spécifier un « Champs de Recherche »" 717 | 718 | #: search_replace/text.py:18 719 | msgid "Case to be applied" 720 | msgstr "Casse a appliquer" 721 | 722 | #: search_replace/text.py:19 723 | msgid "Replace mode" 724 | msgstr "Mode de remplacement" 725 | 726 | #: search_replace/text.py:21 727 | msgid "Identifier type" 728 | msgstr "Type d'identifiant" 729 | 730 | #: search_replace/text.py:23 731 | msgid "Replace field" 732 | msgstr "Remplacer le champ" 733 | 734 | #: search_replace/text.py:26 735 | msgid "In field replacement mode, the specified field is set to the text and all previous values are erased. After replacement is finished, the text can be changed to upper-case, lower-case, or title-case." 736 | msgstr "En mode de remplacement de champ, le 'Champ de destination' est défini au texte spécifier et toutes les valeurs précédentes sont effacées. Une fois le remplacement effectué, la casse peut être modifiée avec l'option 'Casse à appliquer sur le remplacement'." 737 | 738 | #: search_replace/text.py:33 739 | msgid "Invalid identifier string. It must be a comma-separated list of pairs of strings separated by a colon." 740 | msgstr "Chaîne d'identifiant invalide. Ce doit être une liste séparée par des virgules contenant des paires de chaînes séparées par un deux point (:)." 741 | 742 | #: search_replace/text.py:36 743 | msgid "The field \"{:s}\" is not defined" 744 | msgstr "Le champ « {:s} » n'est pas définie" 745 | 746 | #: search_replace/text.py:39 747 | msgid "The operation field \"{:s}\" contains a invalid value ({:s})." 748 | msgstr "Le champ de l'opération « {:s} » contient une valeur non valide ({:s})." 749 | 750 | #: search_replace/text.py:42 751 | msgid "The value of this field is localized (translated). This can cause problems when using settings shared on internet or when changing the user interface language." 752 | msgstr "La valeur de ce champ est localisée (traduite). Cela peut poser problème lors de l'utilisation de paramètres partagée sur internet ou d'un changement de la langue de l'interface utilisateur." 753 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /config.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | __license__ = 'GPL v3' 4 | __copyright__ = '2020, un_pogaz ' 5 | 6 | 7 | try: 8 | load_translations() 9 | except NameError: 10 | pass # load_translations() added in calibre 1.9 11 | 12 | import copy 13 | import json 14 | import os 15 | from functools import partial 16 | from typing import Any, Dict, List 17 | 18 | try: 19 | from qt.core import ( 20 | QAbstractItemView, 21 | QAction, 22 | QCheckBox, 23 | QHBoxLayout, 24 | QLabel, 25 | QPushButton, 26 | QSizePolicy, 27 | QSpacerItem, 28 | Qt, 29 | QTableWidget, 30 | QTableWidgetItem, 31 | QTextEdit, 32 | QToolButton, 33 | QVBoxLayout, 34 | QWidget, 35 | ) 36 | except ImportError: 37 | from PyQt5.Qt import ( 38 | QAbstractItemView, 39 | QAction, 40 | QCheckBox, 41 | QHBoxLayout, 42 | QLabel, 43 | QPushButton, 44 | QSizePolicy, 45 | QSpacerItem, 46 | Qt, 47 | QTableWidget, 48 | QTableWidgetItem, 49 | QTextEdit, 50 | QToolButton, 51 | QVBoxLayout, 52 | QWidget, 53 | ) 54 | 55 | from calibre.gui2 import error_dialog, info_dialog, open_local_file, question_dialog 56 | from calibre.gui2.widgets2 import Dialog 57 | from calibre.utils.config import JSONConfig 58 | from calibre.utils.zipfile import ZipFile 59 | from polyglot.builtins import unicode_type 60 | 61 | from .common_utils import CALIBRE_VERSION, GUI, PREFS_json, debug_print, get_icon, get_image_map, local_resource 62 | from .common_utils.dialogs import ( 63 | ImageDialog, 64 | KeyboardConfigDialogButton, 65 | pick_archive_to_export, 66 | pick_archive_to_import, 67 | pick_json_to_export, 68 | pick_json_to_import, 69 | ) 70 | from .common_utils.librarys import get_BookIds_selected 71 | from .common_utils.templates import TEMPLATE_FIELD 72 | from .common_utils.widgets import ( 73 | CheckableTableWidgetItem, 74 | ImageComboBox, 75 | KeyValueComboBox, 76 | ReadOnlyTableWidgetItem, 77 | TextIconWidgetItem, 78 | ) 79 | from .search_replace import KEY_QUERY, Operation, SearchReplaceDialog, clean_empty_operation 80 | 81 | 82 | class ICON: 83 | PLUGIN = 'images/plugin.png' 84 | ADD_IMAGE = 'images/image_add.png' 85 | EXPORT = 'images/export.png' 86 | IMPORT = 'images/import.png' 87 | WARNING = 'images/warning.png' 88 | 89 | 90 | class KEY_MENU: 91 | MENU = 'Menu' 92 | ACTIVE = 'Active' 93 | IMAGE = 'Image' 94 | TEXT = 'Text' 95 | SUBMENU = 'SubMenu' 96 | OPERATIONS = 'Operations' 97 | 98 | ALL = [ 99 | ACTIVE, 100 | TEXT, 101 | SUBMENU, 102 | IMAGE, 103 | OPERATIONS, 104 | ] 105 | 106 | QUICK = 'Quick' 107 | UPDATE_REPORT = 'UpdateReport' 108 | USE_MARK = 'UseMark' 109 | 110 | 111 | class KEY_ERROR: 112 | ERROR = 'ErrorStrategy' 113 | UPDATE = 'Update' 114 | OPERATION = 'Operation' 115 | 116 | 117 | class ERROR_UPDATE: 118 | 119 | INTERRUPT = 'interrupt' 120 | INTERRUPT_NAME = _('Interrupt execution') 121 | INTERRUPT_DESC = _('Stop Mass Search/Replace and display the error normally without further action.') 122 | 123 | RESTORE = 'restore' 124 | RESTORE_NAME = _('Restore the library') 125 | RESTORE_DESC = _('Stop Mass Search/Replace and restore the library to its original state.') 126 | 127 | safely_txt = _('Updates the fields one by one. This operation can be slower than other strategies.') 128 | 129 | SAFELY = 'safely stop' 130 | SAFELY_NAME = _('Carefully executed (slower)') 131 | SAFELY_DESC = (safely_txt+'\n'+ 132 | _('When a error occurs, stop Mass Search/Replace and display the error normally without further action.')) 133 | 134 | DONT_STOP = "don't stop" 135 | DONT_STOP_NAME = _("Don't stop (slower, not recomanded)") 136 | DONT_STOP_DESC = (safely_txt+'\n'+ 137 | _('Update the library, no matter how many errors are encountered. The problematics fields will not be updated.')) 138 | 139 | LIST = { 140 | INTERRUPT: [INTERRUPT_NAME, INTERRUPT_DESC], 141 | RESTORE: [RESTORE_NAME, RESTORE_DESC], 142 | SAFELY: [SAFELY_NAME, SAFELY_DESC], 143 | DONT_STOP: [DONT_STOP_NAME, DONT_STOP_DESC], 144 | } 145 | 146 | DEFAULT = INTERRUPT 147 | 148 | 149 | class ERROR_OPERATION: 150 | 151 | ABORT = 'abort' 152 | ABORT_NAME = _('Abbort') 153 | ABORT_DESC = _('If an invalid operation is detected, abort the changes.') 154 | 155 | ASK = 'ask' 156 | ASK_NAME = _('Asked') 157 | ASK_DESC = _('If an invalid operation is detected, asked whether to continue or abort the changes.') 158 | 159 | HIDE = 'hide' 160 | HIDE_NAME = _('Hidden') 161 | HIDE_DESC = _('Ignore all invalid operations.') 162 | 163 | LIST = { 164 | ABORT: [ABORT_NAME, ABORT_DESC], 165 | ASK: [ASK_NAME, ASK_DESC], 166 | HIDE: [HIDE_NAME, HIDE_DESC], 167 | } 168 | 169 | DEFAULT = ASK 170 | 171 | 172 | # This is where all preferences for this plugin are stored 173 | PREFS = PREFS_json() 174 | # Set defaults 175 | PREFS.defaults[KEY_MENU.MENU] = [] 176 | PREFS.defaults[KEY_MENU.QUICK] = [] 177 | PREFS.defaults[KEY_MENU.UPDATE_REPORT] = False 178 | PREFS.defaults[KEY_MENU.USE_MARK] = True 179 | 180 | PREFS.defaults[KEY_ERROR.ERROR] = { 181 | KEY_ERROR.OPERATION : ERROR_UPDATE.DEFAULT, 182 | KEY_ERROR.UPDATE : ERROR_OPERATION.DEFAULT 183 | } 184 | 185 | OWIP = 'owip' 186 | 187 | 188 | def get_default_menu() -> Dict[str, Any]: 189 | menu = {} 190 | menu[KEY_MENU.ACTIVE] = True 191 | menu[KEY_MENU.TEXT] = '' 192 | menu[KEY_MENU.SUBMENU] = '' 193 | menu[KEY_MENU.IMAGE] = '' 194 | menu[KEY_MENU.OPERATIONS] = [] 195 | return menu 196 | 197 | 198 | class ConfigWidget(QWidget): 199 | def __init__(self): 200 | QWidget.__init__(self) 201 | 202 | layout = QVBoxLayout(self) 203 | self.setLayout(layout) 204 | 205 | menu_list = [] 206 | for menu in PREFS[KEY_MENU.MENU]: 207 | menu[KEY_MENU.OPERATIONS] = [Operation(o) for o in menu[KEY_MENU.OPERATIONS]] 208 | menu_list.append(menu) 209 | 210 | heading_layout = QHBoxLayout() 211 | layout.addLayout(heading_layout) 212 | heading_label = QLabel(_('Select and configure the menu items to display:'), self) 213 | heading_layout.addWidget(heading_label) 214 | 215 | # Add a horizontal layout containing the table and the buttons next to it 216 | table_layout = QHBoxLayout() 217 | layout.addLayout(table_layout) 218 | 219 | # Create a table the user can edit the menu list 220 | self.table = MenuTableWidget(menu_list, self) 221 | heading_label.setBuddy(self.table) 222 | table_layout.addWidget(self.table) 223 | 224 | # Add a vertical layout containing the the buttons to move up/down etc. 225 | button_layout = QVBoxLayout() 226 | table_layout.addLayout(button_layout) 227 | move_up_button = QToolButton(self) 228 | move_up_button.setToolTip(_('Move menu item up')) 229 | move_up_button.setIcon(get_icon('arrow-up.png')) 230 | button_layout.addWidget(move_up_button) 231 | spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 232 | button_layout.addItem(spacerItem) 233 | 234 | add_button = QToolButton(self) 235 | add_button.setToolTip(_('Add menu item')) 236 | add_button.setIcon(get_icon('plus.png')) 237 | button_layout.addWidget(add_button) 238 | spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 239 | button_layout.addItem(spacerItem1) 240 | 241 | copy_button = QToolButton(self) 242 | copy_button.setToolTip(_('Copy menu item')) 243 | copy_button.setIcon(get_icon('edit-copy.png')) 244 | button_layout.addWidget(copy_button) 245 | spacerItem2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 246 | button_layout.addItem(spacerItem2) 247 | 248 | delete_button = QToolButton(self) 249 | delete_button.setToolTip(_('Delete menu item')) 250 | delete_button.setIcon(get_icon('minus.png')) 251 | button_layout.addWidget(delete_button) 252 | spacerItem3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 253 | button_layout.addItem(spacerItem3) 254 | 255 | move_down_button = QToolButton(self) 256 | move_down_button.setToolTip(_('Move menu item down')) 257 | move_down_button.setIcon(get_icon('arrow-down.png')) 258 | button_layout.addWidget(move_down_button) 259 | 260 | move_up_button.clicked.connect(self.table.move_rows_up) 261 | move_down_button.clicked.connect(self.table.move_rows_down) 262 | add_button.clicked.connect(self.table.add_row) 263 | delete_button.clicked.connect(self.table.delete_rows) 264 | copy_button.clicked.connect(self.table.copy_row) 265 | 266 | # --- Keyboard shortcuts --- 267 | keyboard_layout = QHBoxLayout() 268 | layout.addLayout(keyboard_layout) 269 | keyboard_layout.addWidget(KeyboardConfigDialogButton(parent=self)) 270 | keyboard_layout.insertStretch(-1) 271 | 272 | if CALIBRE_VERSION >= (5,41,0): 273 | self.useMark = QCheckBox(_('Mark the updated books'), self) 274 | self.useMark.setChecked(PREFS[KEY_MENU.USE_MARK]) 275 | keyboard_layout.addWidget(self.useMark) 276 | 277 | self.updateReport = QCheckBox(_('Display a update report'), self) 278 | self.updateReport.setChecked(PREFS[KEY_MENU.UPDATE_REPORT]) 279 | keyboard_layout.addWidget(self.updateReport) 280 | 281 | error_button = QPushButton(_('Error strategy')+'…', self) 282 | error_button.setToolTip(_('Define the strategy when a error occurs during the library update')) 283 | error_button.clicked.connect(self.edit_error_strategy) 284 | keyboard_layout.addWidget(error_button) 285 | 286 | def save_settings(self): 287 | PREFS[KEY_MENU.MENU] = self.table.get_menu_list() 288 | PREFS[KEY_MENU.UPDATE_REPORT] = self.updateReport.checkState() == Qt.Checked 289 | if CALIBRE_VERSION >= (5,41,0): 290 | PREFS[KEY_MENU.USE_MARK] = self.useMark.checkState() == Qt.Checked 291 | debug_print('Save settings: menu operation count:', len(PREFS[KEY_MENU.MENU]), '\n') 292 | # debug_print('Save settings:\n', PREFS, '\n') 293 | 294 | def edit_error_strategy(self): 295 | d = ErrorStrategyDialog() 296 | if d.exec(): 297 | PREFS[KEY_ERROR.ERROR] = { 298 | KEY_ERROR.OPERATION : d.error_operation, 299 | KEY_ERROR.UPDATE : d.error_update 300 | } 301 | 302 | debug_print('Error Strategy settings:', PREFS[KEY_ERROR.ERROR], '\n') 303 | 304 | 305 | COL_NAMES = ['', _('Name'), _('Submenu'), _('Image'), _('Operation')] 306 | 307 | 308 | class MenuTableWidget(QTableWidget): 309 | def __init__(self, menu_list=None, *args): 310 | QTableWidget.__init__(self, *args) 311 | 312 | self.setAlternatingRowColors(True) 313 | self.setSelectionBehavior(QAbstractItemView.SelectRows) 314 | self.setSortingEnabled(False) 315 | self.setMinimumSize(600, 0) 316 | 317 | self.append_context_menu(self) 318 | 319 | self.image_map = get_image_map() 320 | 321 | self.populate_table(menu_list) 322 | 323 | self.cellChanged.connect(self.cell_changed) 324 | 325 | def append_context_menu(self, parent): 326 | parent.setContextMenuPolicy(Qt.ActionsContextMenu) 327 | 328 | act_add_image = QAction(get_icon(ICON.ADD_IMAGE), _('&Add image…'), parent) 329 | act_add_image.triggered.connect(self.add_new_image_dialog) 330 | parent.addAction(act_add_image) 331 | 332 | act_open = QAction(get_icon('document_open.png'), _('&Open images folder'), parent) 333 | act_open.triggered.connect(self.open_images_folder) 334 | parent.addAction(act_open) 335 | 336 | sep2 = QAction(parent) 337 | sep2.setSeparator(True) 338 | parent.addAction(sep2) 339 | 340 | act_import = QAction(get_icon(ICON.IMPORT), _('&Import…'), parent) 341 | act_import.triggered.connect(self.import_menus) 342 | parent.addAction(act_import) 343 | 344 | act_export = QAction(get_icon(ICON.EXPORT), _('&Export…'), parent) 345 | act_export.triggered.connect(self.export_menus) 346 | parent.addAction(act_export) 347 | 348 | def open_images_folder(self): 349 | if not os.path.exists(local_resource.IMAGES): 350 | os.makedirs(local_resource.IMAGES) 351 | open_local_file(local_resource.IMAGES) 352 | 353 | def import_menus(self): 354 | archive_path = pick_archive_to_import(parent=self) 355 | if not archive_path: 356 | return 357 | 358 | json_name = OWIP+'.json' 359 | 360 | # Write the whole file contents into the resources\images directory 361 | if not os.path.exists(local_resource.IMAGES): 362 | os.makedirs(local_resource.IMAGES) 363 | with ZipFile(archive_path, 'r') as zf: 364 | contents = zf.namelist() 365 | if json_name not in contents: 366 | return error_dialog(self, _('Import failed'), _('This is not a valid OWIP export archive'), show=True) 367 | for resource in contents: 368 | if resource == json_name: 369 | json_import = json.loads(zf.read(resource)) 370 | else: 371 | fs = os.path.join(local_resource.IMAGES, resource) 372 | with open(fs,'wb') as f: 373 | f.write(zf.read(resource)) 374 | 375 | try: 376 | # Read the .JSON file to add to the menus then delete it. 377 | menu_list = json_import[KEY_MENU.MENU] 378 | for idx in range(len(menu_list)): 379 | menu_list[idx][KEY_MENU.OPERATIONS] = [Operation(e) for e in menu_list[idx][KEY_MENU.OPERATIONS]] 380 | # Now insert the menus into the table 381 | self.append_menu_list(menu_list) 382 | info_dialog(self, _('Import completed'), _('{:d} menu items imported').format(len(menu_list)), 383 | show=True, show_copy_button=False) 384 | except Exception as e: 385 | return error_dialog(self, _('Import failed'), e, show=True) 386 | 387 | def export_menus(self): 388 | menu_list = [m for m in self.get_selected_menu() if m['Text']] 389 | if len(menu_list) == 0: 390 | return error_dialog(self, _('Export failed'), _('No menu items selected to export'), show=True) 391 | archive_path = pick_archive_to_export(parent=self) 392 | if not archive_path: 393 | return 394 | 395 | # Build our unique list of images that need to be exported 396 | image_map = {} 397 | for menu in menu_list: 398 | image_name = menu[KEY_MENU.IMAGE] 399 | if image_name and image_name not in image_map: 400 | image_path = I(image_name) 401 | if os.path.exists(image_path): 402 | image_map[image_name] = image_path 403 | 404 | try: 405 | # Create the zip file archive 406 | with ZipFile(archive_path, 'w') as archive_zip: 407 | archive_zip.writestr(OWIP+'.json', json.dumps({KEY_MENU.MENU: menu_list})) 408 | # Add any images referred to in those menu items that are local resources 409 | for image_name, image_path in image_map.items(): 410 | archive_zip.write(image_path, os.path.basename(image_path)) 411 | 412 | info_dialog(self, 413 | _('Export completed'), 414 | _('{:d} menu items exported to\n{:s}').format(len(menu_list), archive_path), 415 | show=True, show_copy_button=False, 416 | ) 417 | except Exception as e: 418 | return error_dialog(self, _('Export failed'), e, show=True) 419 | 420 | def populate_table(self, menu_list=None): 421 | self.clear() 422 | self.setColumnCount(len(COL_NAMES)) 423 | self.setHorizontalHeaderLabels(COL_NAMES) 424 | self.verticalHeader().setDefaultSectionSize(24) 425 | 426 | menu_list = menu_list or [] 427 | self.setRowCount(len(menu_list)) 428 | for row, menu in enumerate(menu_list, 0): 429 | self.populate_table_row(row, menu) 430 | 431 | self.selectRow(-1) 432 | 433 | def populate_table_row(self, row, menu): 434 | self.blockSignals(True) 435 | icon_name = menu[KEY_MENU.IMAGE] 436 | menu_text = menu[KEY_MENU.TEXT] 437 | 438 | self.setItem(row, 0, CheckableTableWidgetItem(menu[KEY_MENU.ACTIVE])) 439 | self.setItem(row, 1, TextIconWidgetItem(menu_text, icon_name)) 440 | self.setItem(row, 2, QTableWidgetItem(menu[KEY_MENU.SUBMENU])) 441 | if menu_text: 442 | self.set_editable_cells_in_row(row, icon_name=icon_name, menu=menu) 443 | else: 444 | # Make all the later column cells non-editable 445 | self.set_noneditable_cells_in_row(row) 446 | 447 | self.resizeColumnsToContents() 448 | self.blockSignals(False) 449 | 450 | def cell_changed(self, row, col): 451 | self.blockSignals(True) 452 | 453 | if col == 1 or col == 2: 454 | menu_text = self.item(row, col).text().strip() 455 | self.item(row, col).setText(menu_text) 456 | 457 | if self.item(row, 1).text(): 458 | # Make sure that the other columns in this row are enabled if not already. 459 | if not self.cellWidget(row, len(COL_NAMES)-1): 460 | self.set_editable_cells_in_row(row) 461 | self.cellWidget(row, 4).set_menu(self.convert_row_to_menu(row)) 462 | else: 463 | # Blank menu text so treat it as a separator row 464 | self.set_noneditable_cells_in_row(row) 465 | 466 | self.resizeColumnsToContents() 467 | self.blockSignals(False) 468 | 469 | def image_combo_index_changed(self, combo, row): 470 | # Update image on the title column 471 | title_item = self.item(row, 1) 472 | title_item.setIcon(combo.itemIcon(combo.currentIndex())) 473 | 474 | def create_image_combo_box(self, row, icon_name=None) -> ImageComboBox: 475 | rslt = ImageComboBox(self.image_map, icon_name) 476 | rslt.currentIndexChanged.connect(partial(self.image_combo_index_changed, rslt, row)) 477 | rslt.new_image_added.connect(self.update_all_image_combo_box) 478 | self.append_context_menu(rslt) 479 | return rslt 480 | 481 | def set_editable_cells_in_row(self, row, icon_name=None, menu=None): 482 | self.setCellWidget(row, 3, self.create_image_combo_box(row, icon_name)) 483 | menu = menu or get_default_menu() 484 | self.setCellWidget(row, 4, SettingsButton(self, menu)) 485 | 486 | def set_noneditable_cells_in_row(self, row): 487 | for col in range(3, len(COL_NAMES)): 488 | if self.cellWidget(row, col): 489 | self.removeCellWidget(row, col) 490 | item = QTableWidgetItem() 491 | item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled) 492 | self.setItem(row, col, item) 493 | self.item(row, 1).setIcon(get_icon(None)) 494 | 495 | def add_new_image_dialog(self): 496 | d = ImageDialog(existing_images=self.image_map.keys()) 497 | if d.exec(): 498 | self.update_all_image_combo_box(d.image_name) 499 | 500 | def update_all_image_combo_box(self, new_image): 501 | self.image_map[new_image] = get_icon(new_image) 502 | self.image_map = {k:self.image_map[k] for k in sorted(self.image_map.keys())} 503 | for update_row in range(self.rowCount()): 504 | cellCombo = self.cellWidget(update_row, 3) 505 | if cellCombo: 506 | cellCombo.blockSignals(True) 507 | cellCombo.populate_combo(self.image_map, cellCombo.currentText()) 508 | cellCombo.blockSignals(False) 509 | 510 | def add_row(self): 511 | self.setFocus() 512 | # We will insert a blank row below the currently selected row 513 | row = self.currentRow() + 1 514 | self.insertRow(row) 515 | self.populate_table_row(row, get_default_menu()) 516 | self.select_and_scroll_to_row(row) 517 | 518 | def copy_row(self): 519 | self.setFocus() 520 | currentRow = self.currentRow() 521 | if currentRow < 0: 522 | return 523 | menu = self.convert_row_to_menu(currentRow) 524 | menu[KEY_MENU.TEXT] += ' ' + _('(copy)') 525 | # We will insert a blank row below the currently selected row 526 | row = self.currentRow() + 1 527 | self.insertRow(row) 528 | self.populate_table_row(row, menu) 529 | self.select_and_scroll_to_row(row) 530 | self.resizeColumnsToContents() 531 | 532 | def delete_rows(self): 533 | self.setFocus() 534 | rows = self.selectionModel().selectedRows() 535 | if len(rows) == 0: 536 | return 537 | message = _('Are you sure you want to delete this menu item?') 538 | if len(rows) > 1: 539 | message = _('Are you sure you want to delete the selected {:d} menu items?').format(len(rows)) 540 | if not question_dialog(self, _('Are you sure?'), message, show_copy_button=False): 541 | return 542 | first_sel_row = self.currentRow() 543 | for selrow in reversed(rows): 544 | self.removeRow(selrow.row()) 545 | if first_sel_row < self.rowCount(): 546 | self.select_and_scroll_to_row(first_sel_row) 547 | elif self.rowCount() > 0: 548 | self.select_and_scroll_to_row(first_sel_row - 1) 549 | 550 | def move_rows_up(self): 551 | self.setFocus() 552 | rows = self.selectionModel().selectedRows() 553 | if len(rows) == 0: 554 | return 555 | first_sel_row = rows[0].row() 556 | if first_sel_row <= 0: 557 | return 558 | for selrow in rows: 559 | self.swap_row_widgets(selrow.row() - 1, selrow.row() + 1) 560 | scroll_to_row = first_sel_row - 1 561 | if scroll_to_row > 0: 562 | scroll_to_row = scroll_to_row - 1 563 | self.scrollToItem(self.item(scroll_to_row, 0)) 564 | 565 | def move_rows_down(self): 566 | self.setFocus() 567 | rows = self.selectionModel().selectedRows() 568 | if len(rows) == 0: 569 | return 570 | last_sel_row = rows[-1].row() 571 | if last_sel_row == self.rowCount() - 1: 572 | return 573 | for selrow in reversed(rows): 574 | self.swap_row_widgets(selrow.row() + 2, selrow.row()) 575 | scroll_to_row = last_sel_row + 1 576 | if scroll_to_row < self.rowCount() - 1: 577 | scroll_to_row += 1 578 | self.scrollToItem(self.item(scroll_to_row, 0)) 579 | 580 | def swap_row_widgets(self, src_row, dest_row): 581 | self.blockSignals(True) 582 | self.insertRow(dest_row) 583 | 584 | for col in range(3): 585 | self.setItem(dest_row, col, self.takeItem(src_row, col)) 586 | 587 | menu_text = self.item(dest_row, 1).text().strip() 588 | if menu_text: 589 | for col in range(3, len(COL_NAMES)): 590 | if col == 3: 591 | # Image column has a combobox we have to recreate as cannot move widget (Qt crap) 592 | icon_name = self.cellWidget(src_row, col).currentText() 593 | self.setCellWidget(dest_row, col, self.create_image_combo_box(dest_row, icon_name)) 594 | elif col == 4: 595 | self.setCellWidget(dest_row, col, self.cellWidget(src_row, col)) 596 | else: 597 | # This is a separator row 598 | self.set_noneditable_cells_in_row(dest_row) 599 | 600 | self.removeRow(src_row) 601 | self.blockSignals(False) 602 | 603 | def select_and_scroll_to_row(self, row): 604 | self.selectRow(row) 605 | self.scrollToItem(self.currentItem()) 606 | 607 | def get_menu_list(self) -> List[Dict[str, Any]]: 608 | menu_list = [] 609 | for row in range(self.rowCount()): 610 | menu_list.append(self.convert_row_to_menu(row)) 611 | 612 | # Remove any blank separator row items from at the start and the end 613 | while len(menu_list) > 0 and not menu_list[-1][KEY_MENU.TEXT]: 614 | menu_list.pop() 615 | while len(menu_list) > 0 and not menu_list[0][KEY_MENU.TEXT]: 616 | menu_list.pop(0) 617 | return menu_list 618 | 619 | def convert_row_to_menu(self, row) -> Dict[str, Any]: 620 | menu = get_default_menu() 621 | menu[KEY_MENU.ACTIVE] = self.item(row, 0).checkState() == Qt.Checked 622 | menu[KEY_MENU.TEXT] = self.item(row, 1).text().strip() 623 | menu[KEY_MENU.SUBMENU] = self.item(row, 2).text().strip() 624 | if menu[KEY_MENU.TEXT]: 625 | menu[KEY_MENU.IMAGE] = self.cellWidget(row, 3).currentText().strip() 626 | menu[KEY_MENU.OPERATIONS] = self.cellWidget(row, 4).get_operation_list() 627 | return menu 628 | 629 | def get_selected_menu(self) -> List[Dict[str, Any]]: 630 | menu_list = [] 631 | for row in self.selectionModel().selectedRows(): 632 | menu_list.append(self.convert_row_to_menu(row.row())) 633 | return menu_list 634 | 635 | def append_menu_list(self, menu_list): 636 | for menu in reversed(menu_list): 637 | row = self.currentRow() + 1 638 | self.insertRow(row) 639 | self.populate_table_row(row, menu) 640 | 641 | 642 | class SettingsButton(QToolButton): 643 | def __init__(self, table, menu): 644 | QToolButton.__init__(self) 645 | 646 | self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) 647 | 648 | self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) 649 | self.clicked.connect(self._clicked) 650 | 651 | self.table = table 652 | self._initial_menu = copy.deepcopy(menu) 653 | self.set_menu(menu) 654 | 655 | def set_menu(self, menu): 656 | self._menu = menu 657 | self.update_text() 658 | self.has_error() 659 | 660 | def get_menu(self) -> Dict[str, Any]: 661 | return copy.copy(self._menu) 662 | 663 | def update_text(self): 664 | count = len(self.get_operation_list()) 665 | active = 0 666 | for operation in self.get_operation_list(): 667 | if operation.get(KEY_QUERY.ACTIVE, True): 668 | active += 1 669 | 670 | txt = '' 671 | if active < count: 672 | txt = _('{:d}/{:d} operations').format(active, count) 673 | else: 674 | txt = _('{:d} operations').format(count) 675 | 676 | if self.get_has_changed(): 677 | txt+='*' 678 | self.setText(txt) 679 | 680 | def has_error(self) -> bool: 681 | has_error = False 682 | 683 | for operation in self.get_operation_list(): 684 | if operation.get_error(): 685 | has_error = True 686 | break 687 | 688 | if has_error: 689 | self.setIcon(get_icon(ICON.WARNING)) 690 | self.setToolTip(_('This operations list contain a error')) 691 | else: 692 | self.setIcon(get_icon('gear.png')) 693 | self.setToolTip(_('Edit the operations list')) 694 | 695 | return has_error 696 | 697 | def get_has_changed(self) -> bool: 698 | op_lst = self.get_operation_list() 699 | initial_op_lst = self._initial_menu[KEY_MENU.OPERATIONS] 700 | if len(op_lst) != len(initial_op_lst): 701 | return True 702 | 703 | for i in range(len(op_lst)): 704 | if op_lst[i].get(KEY_QUERY.ACTIVE, True) != initial_op_lst[i].get(KEY_QUERY.ACTIVE, True): 705 | return True 706 | 707 | for key in KEY_QUERY.ALL: 708 | if op_lst[i][key] != initial_op_lst[i][key]: 709 | return True 710 | 711 | return False 712 | 713 | def set_operation_list(self, operation_list): 714 | self._menu[KEY_MENU.OPERATIONS] = operation_list 715 | self.set_menu(self._menu) 716 | 717 | def get_operation_list(self) -> List[Operation]: 718 | return copy.copy(self._menu[KEY_MENU.OPERATIONS]) 719 | 720 | def _clicked(self): 721 | d = ConfigOperationListDialog(self.get_menu()) 722 | if d.exec(): 723 | self.set_operation_list(d.operation_list) 724 | 725 | 726 | COL_CONFIG = ['', _('Name'), _('Columns'), _('Template'), _('Search mode'), _('Search'), _('Replace')] 727 | 728 | 729 | class ConfigOperationListDialog(Dialog): 730 | def __init__(self, menu, book_ids=None): 731 | menu = menu or get_default_menu() 732 | name = menu[KEY_MENU.TEXT] 733 | sub_menu = menu[KEY_MENU.SUBMENU] 734 | self.operation_list = menu[KEY_MENU.OPERATIONS] 735 | self.book_ids = book_ids 736 | 737 | title = '' 738 | if not name: 739 | title = _('List of operations for a quick Search/Replaces') 740 | else: 741 | if sub_menu: 742 | name = f'{sub_menu} > {name}' 743 | 744 | title = _('List of Search/Replace operations for {:s}').format(name) 745 | 746 | Dialog.__init__(self, 747 | title=title, 748 | name='plugin.MassSearchReplace:config_list_SearchReplace', 749 | parent=GUI, 750 | ) 751 | 752 | def setup_ui(self): 753 | layout = QVBoxLayout(self) 754 | self.setLayout(layout) 755 | 756 | heading_layout = QHBoxLayout() 757 | layout.addLayout(heading_layout) 758 | heading_label = QLabel( 759 | _('Select and configure the order of execution of the operations of Search/Replace operations:'), 760 | self, 761 | ) 762 | heading_layout.addWidget(heading_label) 763 | # help_label = QLabel(' ', self) 764 | # help_label.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard) 765 | # help_label.setAlignment(Qt.AlignRight) 766 | # heading_layout.addWidget(help_label) 767 | 768 | # Add a horizontal layout containing the table and the buttons next to it 769 | table_layout = QHBoxLayout() 770 | layout.addLayout(table_layout) 771 | 772 | # Create a table the user can edit the operation list 773 | self.table = OperationListTableWidget(self.operation_list, self.book_ids, self) 774 | heading_label.setBuddy(self.table) 775 | table_layout.addWidget(self.table) 776 | 777 | # Add a vertical layout containing the the buttons to move up/down etc. 778 | button_layout = QVBoxLayout() 779 | table_layout.addLayout(button_layout) 780 | move_up_button = QToolButton(self) 781 | move_up_button.setToolTip(_('Move operation up')) 782 | move_up_button.setIcon(get_icon('arrow-up.png')) 783 | button_layout.addWidget(move_up_button) 784 | 785 | spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 786 | button_layout.addItem(spacerItem) 787 | 788 | add_button = QToolButton(self) 789 | add_button.setToolTip(_('Add operation')) 790 | add_button.setIcon(get_icon('plus.png')) 791 | button_layout.addWidget(add_button) 792 | 793 | spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 794 | button_layout.addItem(spacerItem1) 795 | 796 | copy_button = QToolButton(self) 797 | copy_button.setToolTip(_('Copy operation')) 798 | copy_button.setIcon(get_icon('edit-copy.png')) 799 | button_layout.addWidget(copy_button) 800 | 801 | spacerItem2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 802 | button_layout.addItem(spacerItem2) 803 | 804 | delete_button = QToolButton(self) 805 | delete_button.setToolTip(_('Delete operation')) 806 | delete_button.setIcon(get_icon('minus.png')) 807 | button_layout.addWidget(delete_button) 808 | 809 | spacerItem3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) 810 | button_layout.addItem(spacerItem3) 811 | 812 | move_down_button = QToolButton(self) 813 | move_down_button.setToolTip(_('Move operation down')) 814 | move_down_button.setIcon(get_icon('arrow-down.png')) 815 | button_layout.addWidget(move_down_button) 816 | 817 | move_up_button.clicked.connect(self.table.move_rows_up) 818 | move_down_button.clicked.connect(self.table.move_rows_down) 819 | add_button.clicked.connect(self.table.add_row) 820 | delete_button.clicked.connect(self.table.delete_rows) 821 | copy_button.clicked.connect(self.table.copy_row) 822 | 823 | # -- Accept/Reject buttons -- 824 | layout.addWidget(self.bb) 825 | 826 | def add_empty_operation(self): 827 | self.table.add_row() 828 | 829 | def accept(self): 830 | self.operation_list = self.table.get_operation_list() 831 | 832 | if len(self.operation_list)==0: 833 | debug_print('Saving a empty list') 834 | else: 835 | txt = 'Saved operation list:\n' + '\n'.join( 836 | (f'Operation {i} > '+ operation.string_info()) for i, operation in enumerate(self.operation_list, 1) 837 | ) 838 | # txt += '\n[ '+ ',\n'.join( [str(operation) for operation in self.operation_list] ) +' ]\n' 839 | debug_print(txt) 840 | 841 | Dialog.accept(self) 842 | 843 | 844 | class OperationListTableWidget(QTableWidget): 845 | def __init__(self, operation_list=None, book_ids=None, *args): 846 | QTableWidget.__init__(self, *args) 847 | 848 | self.book_ids = (book_ids or get_BookIds_selected(show_error=False))[:10] 849 | 850 | self.setAlternatingRowColors(True) 851 | self.setSelectionBehavior(QAbstractItemView.SelectRows) 852 | self.setSortingEnabled(False) 853 | self.setMinimumSize(800, 0) 854 | 855 | self.append_context_menu() 856 | 857 | self.populate_table(operation_list) 858 | 859 | self.itemDoubleClicked.connect(self.settings_doubleClick) 860 | 861 | def append_context_menu(self): 862 | self.setContextMenuPolicy(Qt.ActionsContextMenu) 863 | act_import = QAction(get_icon(ICON.IMPORT), _('&Import…'), self) 864 | act_import.triggered.connect(self.import_operations) 865 | self.addAction(act_import) 866 | 867 | act_export = QAction(get_icon(ICON.EXPORT), _('&Export…'), self) 868 | act_export.triggered.connect(self.export_operations) 869 | self.addAction(act_export) 870 | 871 | def import_operations(self): 872 | json_path = pick_json_to_import(parent=self) 873 | if not json_path: 874 | return 875 | 876 | try: 877 | with open(json_path) as fr: 878 | json_import = json.load(fr) 879 | 880 | if KEY_MENU.OPERATIONS not in json_import: 881 | return error_dialog(self, _('Import failed'), _('This is not a valid JSON file'), show=True) 882 | operation_list = [Operation(e) for e in json_import[KEY_MENU.OPERATIONS]] 883 | self.append_operation_list(operation_list) 884 | 885 | info_dialog(self, 886 | _('Import completed'), 887 | _('{:d} operations imported').format(len(operation_list), json_path), 888 | show=True, show_copy_button=False, 889 | ) 890 | except Exception as e: 891 | return error_dialog(self, _('Export failed'), e, show=True) 892 | 893 | def export_operations(self): 894 | operation_list = self.get_selected_operation() 895 | if len(operation_list) == 0: 896 | return error_dialog(self, _('Export failed'), _('No operations selected to export'), show=True) 897 | json_path = pick_json_to_export(parent=self) 898 | if not json_path: 899 | return 900 | 901 | try: 902 | with open(json_path, 'w') as fw: 903 | json.dump({KEY_MENU.OPERATIONS: operation_list}, fw) 904 | info_dialog(self, 905 | _('Export completed'), 906 | _('{:d} operations exported to\n{:s}').format(len(operation_list), json_path), 907 | show=True, show_copy_button=False, 908 | ) 909 | except Exception as e: 910 | return error_dialog(self, _('Export failed'), e, show=True) 911 | 912 | def populate_table(self, operation_list=None): 913 | self.clear() 914 | self.setColumnCount(len(COL_CONFIG)) 915 | self.setHorizontalHeaderLabels(COL_CONFIG) 916 | self.verticalHeader().setDefaultSectionSize(24) 917 | 918 | operation_list = clean_empty_operation(operation_list) 919 | calibre_queries = JSONConfig('search_replace_queries') 920 | 921 | self.setRowCount(len(operation_list)) 922 | for row, operation in enumerate(operation_list): 923 | is_active = operation[KEY_QUERY.ACTIVE] 924 | calibre_operation = calibre_queries.get(unicode_type(operation.get(KEY_QUERY.NAME, None))) 925 | if calibre_operation: 926 | operation = Operation(calibre_operation) 927 | operation[KEY_QUERY.ACTIVE] = is_active 928 | 929 | self.populate_table_row(row, operation) 930 | 931 | self.test_column_hidden() 932 | 933 | self.selectRow(-1) 934 | 935 | def populate_table_row(self, row, operation): 936 | self.blockSignals(True) 937 | 938 | self.setItem(row, 0, OperationWidgetItem(self, operation)) 939 | 940 | for i in range(1, len(COL_CONFIG)): 941 | item = ReadOnlyTableWidgetItem('') 942 | self.setItem(row, i, item) 943 | 944 | self.update_row(row) 945 | 946 | self.resizeColumnsToContents() 947 | self.blockSignals(False) 948 | 949 | def test_column_hidden(self): 950 | no_name = True 951 | no_template = True 952 | for i_row in range(self.rowCount()): 953 | item = self.item(i_row, 0) 954 | operation = item.get_operation() if item else {} 955 | if no_name and operation.get(KEY_QUERY.NAME, ''): 956 | no_name = False 957 | if no_template and operation.get(KEY_QUERY.SEARCH_FIELD, '') == TEMPLATE_FIELD: 958 | no_template = False 959 | 960 | self.setColumnHidden(1, no_name) 961 | self.setColumnHidden(3, no_template) 962 | self.resizeColumnsToContents() 963 | 964 | def update_row(self, row): 965 | operation = self.convert_row_to_operation(row) 966 | 967 | for col, val in enumerate(operation.get_para_list(), 1): 968 | self.item(row, col).setText(val) 969 | 970 | def add_row(self): 971 | self.setFocus() 972 | # We will insert a blank row below the currently selected row 973 | row = self.currentRow() + 1 974 | self.insertRow(row) 975 | 976 | self.populate_table_row(row, self.create_blank_row_operation()) 977 | self.select_and_scroll_to_row(row) 978 | 979 | def copy_row(self): 980 | self.setFocus() 981 | currentRow = self.currentRow() 982 | if currentRow < 0: 983 | return 984 | operation = self.convert_row_to_operation(currentRow) 985 | # We will insert a blank row below the currently selected row 986 | row = self.currentRow() + 1 987 | self.insertRow(row) 988 | self.populate_table_row(row, operation) 989 | self.select_and_scroll_to_row(row) 990 | 991 | def delete_rows(self): 992 | self.setFocus() 993 | rows = self.selectionModel().selectedRows() 994 | if len(rows) == 0: 995 | return 996 | message = _('Are you sure you want to delete this operation?') 997 | if len(rows) > 1: 998 | message = _('Are you sure you want to delete the selected {:d} operations?').format(len(rows)) 999 | if not question_dialog(self, _('Are you sure?'), message, show_copy_button=False): 1000 | return 1001 | first_sel_row = self.currentRow() 1002 | for selrow in reversed(rows): 1003 | self.removeRow(selrow.row()) 1004 | if first_sel_row < self.rowCount(): 1005 | self.select_and_scroll_to_row(first_sel_row) 1006 | elif self.rowCount() > 0: 1007 | self.select_and_scroll_to_row(first_sel_row - 1) 1008 | 1009 | if self.rowCount(): 1010 | self.update_row(0) 1011 | 1012 | def move_rows_up(self): 1013 | self.setFocus() 1014 | rows = self.selectionModel().selectedRows() 1015 | if len(rows) == 0: 1016 | return 1017 | first_sel_row = rows[0].row() 1018 | if first_sel_row <= 0: 1019 | return 1020 | # Workaround for strange selection bug in Qt which "alters" the selection 1021 | # in certain circumstances which meant move down only worked properly "once" 1022 | selrows = [] 1023 | for row in rows: 1024 | selrows.append(row.row()) 1025 | selrows.sort() 1026 | for selrow in selrows: 1027 | self.swap_row_widgets(selrow - 1, selrow + 1) 1028 | scroll_to_row = first_sel_row - 1 1029 | if scroll_to_row > 0: 1030 | scroll_to_row = scroll_to_row - 1 1031 | self.scrollToItem(self.item(scroll_to_row, 0)) 1032 | 1033 | def move_rows_down(self): 1034 | self.setFocus() 1035 | rows = self.selectionModel().selectedRows() 1036 | if len(rows) == 0: 1037 | return 1038 | last_sel_row = rows[-1].row() 1039 | if last_sel_row == self.rowCount() - 1: 1040 | return 1041 | # Workaround for strange selection bug in Qt which "alters" the selection 1042 | # in certain circumstances which meant move down only worked properly "once" 1043 | selrows = [] 1044 | for row in rows: 1045 | selrows.append(row.row()) 1046 | selrows.sort() 1047 | for selrow in reversed(selrows): 1048 | self.swap_row_widgets(selrow + 2, selrow) 1049 | scroll_to_row = last_sel_row + 1 1050 | if scroll_to_row < self.rowCount() - 1: 1051 | scroll_to_row += 1 1052 | self.scrollToItem(self.item(scroll_to_row, 0)) 1053 | 1054 | def swap_row_widgets(self, src_row, dest_row): 1055 | self.blockSignals(True) 1056 | self.insertRow(dest_row) 1057 | 1058 | for col in range(len(COL_CONFIG)): 1059 | self.setItem(dest_row, col, self.takeItem(src_row, col)) 1060 | 1061 | self.update_row(dest_row) 1062 | self.removeRow(src_row) 1063 | self.blockSignals(False) 1064 | 1065 | def select_and_scroll_to_row(self, row): 1066 | self.selectRow(row) 1067 | self.scrollToItem(self.currentItem()) 1068 | 1069 | def create_blank_row_operation(self) -> Operation: 1070 | return Operation() 1071 | 1072 | def get_operation_list(self) -> List[Operation]: 1073 | operation_list = [] 1074 | for row in range(self.rowCount()): 1075 | operation = self.convert_row_to_operation(row) 1076 | operation_list.append(operation) 1077 | 1078 | return clean_empty_operation(operation_list) 1079 | 1080 | def convert_row_to_operation(self, row) -> Operation: 1081 | return self.item(row, 0).get_operation() 1082 | 1083 | def get_selected_operation(self) -> List[Operation]: 1084 | operation_list = [] 1085 | for row in self.selectionModel().selectedRows(): 1086 | operation_list.append(self.convert_row_to_operation(row.row())) 1087 | return clean_empty_operation(operation_list) 1088 | 1089 | def append_operation_list(self, operation_list): 1090 | for operation in reversed(clean_empty_operation(operation_list)): 1091 | row = self.currentRow() + 1 1092 | self.insertRow(row) 1093 | self.populate_table_row(row, operation) 1094 | 1095 | self.test_column_hidden() 1096 | 1097 | def settings_doubleClick(self): 1098 | self.setFocus() 1099 | row = self.currentRow() 1100 | 1101 | src_operation = self.convert_row_to_operation(row) 1102 | d = SearchReplaceDialog(src_operation, self.book_ids) 1103 | if d.exec(): 1104 | d.operation[KEY_QUERY.ACTIVE] = src_operation.get(KEY_QUERY.ACTIVE, True) 1105 | self.populate_table_row(row, d.operation) 1106 | 1107 | self.test_column_hidden() 1108 | 1109 | 1110 | class OperationWidgetItem(QTableWidgetItem): 1111 | def __init__(self, table, operation): 1112 | QTableWidgetItem.__init__(self, '') 1113 | self.setFlags(Qt.ItemFlag(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)) 1114 | 1115 | self.table = table 1116 | self._operation = operation 1117 | self._has_error = False 1118 | self.set_operation(operation) 1119 | 1120 | def set_operation(self, operation): 1121 | operation = operation or Operation() 1122 | self._operation = operation 1123 | 1124 | checked = self._operation.get(KEY_QUERY.ACTIVE, True) 1125 | if checked: 1126 | self.setCheckState(Qt.Checked) 1127 | else: 1128 | self.setCheckState(Qt.Unchecked) 1129 | 1130 | self.has_error() 1131 | 1132 | def get_operation(self) -> Operation: 1133 | self._operation[KEY_QUERY.ACTIVE] = Qt.Checked == self.checkState() 1134 | return copy.copy(self._operation) 1135 | 1136 | def has_error(self) -> bool: 1137 | err = self._operation.test_full_error() 1138 | 1139 | if err: 1140 | self.setIcon(get_icon(ICON.WARNING)) 1141 | self.setToolTip(str(err)) 1142 | return True 1143 | else: 1144 | self.setIcon(get_icon(None)) 1145 | self.setToolTip('') 1146 | return False 1147 | 1148 | 1149 | class ErrorStrategyDialog(Dialog): 1150 | def __init__(self): 1151 | self.error_update = PREFS[KEY_ERROR.ERROR][KEY_ERROR.UPDATE] 1152 | self.error_operation = PREFS[KEY_ERROR.ERROR][KEY_ERROR.OPERATION] 1153 | 1154 | if self.error_operation not in ERROR_OPERATION.LIST.keys(): 1155 | self.error_operation = ERROR_OPERATION.DEFAULT 1156 | 1157 | if self.error_update not in ERROR_UPDATE.LIST.keys(): 1158 | self.error_update = ERROR_UPDATE.DEFAULT 1159 | 1160 | Dialog.__init__(self, 1161 | title=_('Error Strategy'), 1162 | name='plugin.MassSearchReplace:config_ErrorStrategy', 1163 | parent=GUI, 1164 | ) 1165 | 1166 | def setup_ui(self): 1167 | layout = QVBoxLayout(self) 1168 | self.setLayout(layout) 1169 | 1170 | operation_label = QLabel(_('Set the strategy when an invalid operation has detected:'), self) 1171 | layout.addWidget(operation_label) 1172 | 1173 | self.operationStrategy = KeyValueComboBox( 1174 | {key:value[0] for key, value in ERROR_OPERATION.LIST.items()}, 1175 | self.error_operation, 1176 | parent=self, 1177 | ) 1178 | self.operationStrategy.currentIndexChanged.connect(self.operation_strategy_index_changed) 1179 | layout.addWidget(self.operationStrategy) 1180 | 1181 | operation_label.setBuddy(self.operationStrategy) 1182 | 1183 | layout.addWidget(QLabel(' ', self)) 1184 | 1185 | update_label = QLabel(_('Define the strategy when a error occurs during the library update:'), self) 1186 | layout.addWidget(update_label) 1187 | 1188 | self.updateStrategy = KeyValueComboBox( 1189 | {key:value[0] for key, value in ERROR_UPDATE.LIST.items()}, 1190 | self.error_update, 1191 | parent=self, 1192 | ) 1193 | self.updateStrategy.currentIndexChanged.connect(self.update_strategy_index_changed) 1194 | layout.addWidget(self.updateStrategy) 1195 | 1196 | update_label.setBuddy(self.updateStrategy) 1197 | 1198 | self.desc = QTextEdit(' ', self) 1199 | self.desc.setReadOnly(True) 1200 | layout.addWidget(self.desc) 1201 | 1202 | layout.insertStretch(-1) 1203 | 1204 | # -- Accept/Reject buttons -- 1205 | layout.addWidget(self.bb) 1206 | 1207 | def operation_strategy_index_changed(self, idx): 1208 | error_operation = self.operationStrategy.selected_key() 1209 | self.desc.setText(ERROR_OPERATION.LIST[error_operation][1]) 1210 | 1211 | def update_strategy_index_changed(self, idx): 1212 | error_update = self.updateStrategy.selected_key() 1213 | self.desc.setText(ERROR_UPDATE.LIST[error_update][1]) 1214 | 1215 | def accept(self): 1216 | self.error_operation = self.operationStrategy.selected_key() 1217 | if self.error_operation not in ERROR_OPERATION.LIST.keys(): 1218 | self.error_operation = ERROR_OPERATION.DEFAULT 1219 | 1220 | self.error_update = self.updateStrategy.selected_key() 1221 | if self.error_update not in ERROR_UPDATE.LIST.keys(): 1222 | self.error_update = ERROR_UPDATE.DEFAULT 1223 | 1224 | Dialog.accept(self) 1225 | --------------------------------------------------------------------------------