diff --git a/picard/acoustid/manager.py b/picard/acoustid/manager.py index 6a22fda5b..ff6fee0ae 100644 --- a/picard/acoustid/manager.py +++ b/picard/acoustid/manager.py @@ -89,7 +89,7 @@ class AcoustIDManager(QtCore.QObject): try: error = load_json(document) message = error["error"]["message"] - except : + except: message = "" mparms = { 'error': http.errorString(), diff --git a/picard/cluster.py b/picard/cluster.py index 19a71333d..4adc00fbf 100644 --- a/picard/cluster.py +++ b/picard/cluster.py @@ -71,7 +71,7 @@ class Cluster(QtCore.QObject, Item): return '' % ( self.related_album.id, self.related_album.metadata[u"album"] + '/' + self.metadata['album'] - ) + ) return '' % self.metadata['album'] def __len__(self): diff --git a/picard/config_upgrade.py b/picard/config_upgrade.py index 90aacbd22..63b7f789a 100644 --- a/picard/config_upgrade.py +++ b/picard/config_upgrade.py @@ -40,6 +40,7 @@ def upgrade_to_v1_0_0_final_0(): """In version 1.0, the file naming formats for single and various artist releases were merged. """ _s = config.setting + def remove_va_file_naming_format(merge=True): if merge: _s["file_naming_format"] = ( @@ -128,6 +129,7 @@ def upgrade_to_v1_3_0_dev_4(): """Option "release_type_scores" is now a list of tuples """ _s = config.setting + def load_release_type_scores(setting): scores = [] values = setting.split() @@ -188,7 +190,7 @@ def upgrade_to_v1_4_0_dev_4(): "$if($ne(%albumartist%,),$num(%tracknumber%,2) ,)" \ "$if(%_multiartist%,%artist% - ,)" \ "%title%" - _s["file_naming_format"] = _DEFAULT_FILE_NAMING_FORMAT + _s["file_naming_format"] = _DEFAULT_FILE_NAMING_FORMAT def upgrade_to_v1_4_0_dev_5(): diff --git a/picard/const/__init__.py b/picard/const/__init__.py index ec4a4230a..9129d28d7 100644 --- a/picard/const/__init__.py +++ b/picard/const/__init__.py @@ -124,20 +124,20 @@ PROGRAM_UPDATE_LEVELS = OrderedDict( [ ( 0, { - 'name': 'stable', - 'title': N_('Stable releases only'), + 'name': 'stable', + 'title': N_('Stable releases only'), } ), ( 1, { - 'name': 'beta', - 'title': N_('Stable and Beta releases'), + 'name': 'beta', + 'title': N_('Stable and Beta releases'), } ), ( 2, { - 'name': 'dev', - 'title': N_('Stable, Beta and Dev releases'), + 'name': 'dev', + 'title': N_('Stable, Beta and Dev releases'), } ), ] diff --git a/picard/coverart/__init__.py b/picard/coverart/__init__.py index 65dbe1375..f58c102d3 100644 --- a/picard/coverart/__init__.py +++ b/picard/coverart/__init__.py @@ -92,7 +92,6 @@ class CoverArt: except CoverArtImageIdentificationError as e: self.album.error_append(e) - def _coverart_downloaded(self, coverartimage, data, http, error): """Handle finished download, save it to metadata""" self.album._requests -= 1 diff --git a/picard/coverart/providers/__init__.py b/picard/coverart/providers/__init__.py index e0c1097dd..7c2a12885 100644 --- a/picard/coverart/providers/__init__.py +++ b/picard/coverart/providers/__init__.py @@ -74,7 +74,7 @@ def cover_art_providers(): try: return order.index(p.NAME) except ValueError: - return 666 # move to the end + return 666 # move to the end providers = [] for p in sorted(_cover_art_providers, key=_key_provider): providers.append(p) @@ -133,7 +133,7 @@ class CoverArtProvider(object): def queue_images(self): # this method has to return CoverArtProvider.FINISHED or # CoverArtProvider.WAIT - old = getattr(self, 'queue_downloads') #compat with old plugins + old = getattr(self, 'queue_downloads') # compat with old plugins if callable(old): log.warning('CoverArtProvider: queue_downloads() was replaced by queue_images()') return old() diff --git a/picard/coverart/providers/caa.py b/picard/coverart/providers/caa.py index 480321039..4d25d200e 100644 --- a/picard/coverart/providers/caa.py +++ b/picard/coverart/providers/caa.py @@ -73,8 +73,8 @@ _CAA_THUMBNAIL_SIZE_MAP = OrderedDict([ _CAA_IMAGE_SIZE_DEFAULT = 500 -_CAA_IMAGE_TYPE_DEFAULT_INCLUDE = ['front',] -_CAA_IMAGE_TYPE_DEFAULT_EXCLUDE = ['raw/unedited', 'watermark',] +_CAA_IMAGE_TYPE_DEFAULT_INCLUDE = ['front'] +_CAA_IMAGE_TYPE_DEFAULT_EXCLUDE = ['raw/unedited', 'watermark'] def caa_url_fallback_list(desired_size, thumbnails): @@ -229,9 +229,9 @@ class CAATypesSelectorDialog(QtWidgets.QDialog): self.fill_lists(types_include, types_exclude) # Set triggers when the lists receive the current focus - self.list_include.clicked.connect(partial(self.clear_focus, [self.list_ignore, self.list_exclude,])) - self.list_exclude.clicked.connect(partial(self.clear_focus, [self.list_ignore, self.list_include,])) - self.list_ignore.clicked.connect(partial(self.clear_focus, [self.list_include, self.list_exclude,])) + self.list_include.clicked.connect(partial(self.clear_focus, [self.list_ignore, self.list_exclude])) + self.list_exclude.clicked.connect(partial(self.clear_focus, [self.list_ignore, self.list_include])) + self.list_ignore.clicked.connect(partial(self.clear_focus, [self.list_include, self.list_exclude])) # Add instructions to the dialog box instructions = QtWidgets.QLabel() @@ -258,7 +258,7 @@ class CAATypesSelectorDialog(QtWidgets.QDialog): ) def add_widget(row=0, column=0, widget=None): - gridlayout.addWidget(widget, row, column) + gridlayout.addWidget(widget, row, column) add_widget(row=0, column=0, widget=QtWidgets.QLabel(_("Include types list"))) add_widget(row=1, column=0, widget=self.list_include) @@ -644,6 +644,6 @@ class CoverArtProviderCaa(CoverArtProvider): if config.setting["caa_save_single_front_image"] and \ config.setting["save_images_to_files"] and \ image["front"]: - break + break self.next_in_queue() diff --git a/picard/coverart/providers/local.py b/picard/coverart/providers/local.py index 12ffb55f1..409f77214 100644 --- a/picard/coverart/providers/local.py +++ b/picard/coverart/providers/local.py @@ -91,7 +91,7 @@ class CoverArtProviderLocal(CoverArtProvider): continue filepath = os.path.join(current_dir, root, filename) if os.path.exists(filepath): - types = self.get_types(m.group(1)) or [ 'front' ] + types = self.get_types(m.group(1)) or ['front'] self.queue_put(CoverArtImageFromFile(filepath, types=types, support_types=True)) diff --git a/picard/file.py b/picard/file.py index ca445dc83..699a0d700 100644 --- a/picard/file.py +++ b/picard/file.py @@ -136,7 +136,7 @@ class File(QtCore.QObject, Item): file_name, file_extension = os.path.splitext(self.base_filename) if file_extension not in supported_extensions(): self.remove() - log.error('Unsupported media file %r wrongly loaded. Removing ...',self) + log.error('Unsupported media file %r wrongly loaded. Removing ...', self) return else: self.error = None @@ -386,7 +386,6 @@ class File(QtCore.QObject, Item): # os.path.realpath can fail if cwd doesn't exist return new_path - def _rename(self, old_filename, metadata): new_filename, ext = os.path.splitext( self._make_filename(old_filename, metadata)) diff --git a/picard/formats/id3.py b/picard/formats/id3.py index c643f099e..953cff71a 100644 --- a/picard/formats/id3.py +++ b/picard/formats/id3.py @@ -140,7 +140,7 @@ class ID3File(File): 'TSO2': 'albumartistsort', } __rtranslate = dict([(v, k) for k, v in __translate.items()]) - __translate['GRP1'] = 'grouping' # Always read, but writing depends on itunes_compatible_grouping + __translate['GRP1'] = 'grouping' # Always read, but writing depends on itunes_compatible_grouping __translate_freetext = { 'MusicBrainz Artist Id': 'musicbrainz_artistid', @@ -170,7 +170,7 @@ class ID3File(File): 'Writer': 'writer', } __rtranslate_freetext = dict([(v, k) for k, v in __translate_freetext.items()]) - __translate_freetext['Work'] = 'work' # Always read, but writing depends on itunes_compatible_grouping + __translate_freetext['Work'] = 'work' # Always read, but writing depends on itunes_compatible_grouping __translate_freetext['writer'] = 'writer' # For backward compatibility of case _tipl_roles = { diff --git a/picard/formats/mutagenext/tak.py b/picard/formats/mutagenext/tak.py index bca26ce17..ecab827ac 100644 --- a/picard/formats/mutagenext/tak.py +++ b/picard/formats/mutagenext/tak.py @@ -54,4 +54,5 @@ class TAK(APEv2File): return header.startswith(b"tBaK") + filename.lower().endswith(".tak") score = staticmethod(score) + Open = TAK diff --git a/picard/formats/vorbis.py b/picard/formats/vorbis.py index bb4508f08..7fc49e889 100644 --- a/picard/formats/vorbis.py +++ b/picard/formats/vorbis.py @@ -356,6 +356,7 @@ def OggAudioFile(filename): options = [OggFLACFile, OggSpeexFile, OggVorbisFile] return guess_format(filename, options) + OggAudioFile.EXTENSIONS = [".oga"] OggAudioFile.NAME = "Ogg Audio" diff --git a/picard/i18n.py b/picard/i18n.py index 2f99ff11a..ac940f3e7 100644 --- a/picard/i18n.py +++ b/picard/i18n.py @@ -110,6 +110,8 @@ def setup_gettext(localedir, ui_language=None, logger=None): # strings due to that # This workaround is a hack until we get proper msgctxt support _CONTEXT_SEPARATOR = "\x04" + + def gettext_ctxt(gettext_, message, context=None): if context is None: return gettext_(message) diff --git a/picard/plugin.py b/picard/plugin.py index ced6ee6d7..33ee91aea 100644 --- a/picard/plugin.py +++ b/picard/plugin.py @@ -227,6 +227,7 @@ class PluginWrapper(PluginShared): class PluginData(PluginShared): """Used to store plugin data from JSON API""" + def __init__(self, d, module_name): self.__dict__ = d super().__init__() @@ -367,7 +368,7 @@ class PluginManager(QtCore.QObject): filepaths = [os.path.join(USER_PLUGIN_DIR, f) for f in os.listdir(USER_PLUGIN_DIR) if f in [plugin_name + ext for ext in fileexts] - ] + ] return (dirpath, filepaths) def remove_plugin(self, plugin_name): diff --git a/picard/script.py b/picard/script.py index 6c9fb3c20..0a8c808b4 100644 --- a/picard/script.py +++ b/picard/script.py @@ -322,8 +322,8 @@ def register_script_function(function, name=None, eval_args=True, name = function.__name__ ScriptParser._function_registry.register(function.__module__, (name, FunctionRegistryItem( - function, eval_args, - argcount if argcount and check_argcount else False) + function, eval_args, + argcount if argcount and check_argcount else False) ) ) diff --git a/picard/ui/infodialog.py b/picard/ui/infodialog.py index 82182134d..ea74dbb9c 100644 --- a/picard/ui/infodialog.py +++ b/picard/ui/infodialog.py @@ -364,6 +364,7 @@ class ClusterInfoDialog(InfoDialog): artist = m["artist"] or m["albumartist"] or cluster.metadata["albumartist"] tracklist.append(TrackListItem(m["tracknumber"], m["title"], artist, m["~length"])) + def sorttracknum(item): try: return int(item.tracknumber) diff --git a/picard/ui/itemviews.py b/picard/ui/itemviews.py index 451225a09..d23929756 100644 --- a/picard/ui/itemviews.py +++ b/picard/ui/itemviews.py @@ -640,8 +640,6 @@ class AlbumTreeView(BaseTreeView): class TreeItem(QtWidgets.QTreeWidgetItem): - __lt__ = lambda self, other: False - def __init__(self, obj, sortable, *args): super().__init__(*args) self.obj = obj @@ -657,6 +655,9 @@ class TreeItem(QtWidgets.QTreeWidgetItem): return (self.obj.metadata.length or 0) < (other.obj.metadata.length or 0) return self.text(column).lower() < other.text(column).lower() + def __lt__(self, other): + return False + class ClusterItem(TreeItem): diff --git a/picard/ui/logview.py b/picard/ui/logview.py index b375820c1..9cb3ada58 100644 --- a/picard/ui/logview.py +++ b/picard/ui/logview.py @@ -189,7 +189,6 @@ class LogView(LogViewCommon): self.hbox.addWidget(self.save_log_as_button) self.save_log_as_button.clicked.connect(self._save_log_as_do) - def _clear_highlight_do(self): self.highlight_text.setText('') self.highlight_button.setEnabled(False) diff --git a/picard/ui/mainwindow.py b/picard/ui/mainwindow.py index 4d9f81364..5cb4b3f39 100644 --- a/picard/ui/mainwindow.py +++ b/picard/ui/mainwindow.py @@ -629,7 +629,6 @@ class MainWindow(QtWidgets.QMainWindow, PreserveGeometry): else: self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) - def create_toolbar(self): self.create_search_toolbar() self.create_action_toolbar() @@ -863,7 +862,7 @@ class MainWindow(QtWidgets.QMainWindow, PreserveGeometry): return return self.tagger.analyze(self.selected_objects) - def _openUrl(self,url): + def _openUrl(self, url): # Resolves a bug in Qt opening remote URLs - QTBUG-13359 # See https://bugreports.qt.io/browse/QTBUG-13359 if url.startswith("\\\\") or url.startswith("//"): @@ -1124,6 +1123,7 @@ class MainWindow(QtWidgets.QMainWindow, PreserveGeometry): callback=update_last_check_date ) + def update_last_check_date(is_success): if is_success: config.persist['last_update_check'] = datetime.date.today().toordinal() diff --git a/picard/ui/metadatabox.py b/picard/ui/metadatabox.py index 5cd984263..a7d5406ea 100644 --- a/picard/ui/metadatabox.py +++ b/picard/ui/metadatabox.py @@ -162,7 +162,7 @@ class PreservedTags: self._tags = self._from_config() def _to_config(self): - config.setting[self.opt_name] = ", ".join(sorted(self._tags)) + config.setting[self.opt_name] = ", ".join(sorted(self._tags)) def _from_config(self): tags = config.setting[self.opt_name].split(',') diff --git a/picard/ui/options/cover.py b/picard/ui/options/cover.py index e47d86a6f..0017f6c26 100644 --- a/picard/ui/options/cover.py +++ b/picard/ui/options/cover.py @@ -119,4 +119,5 @@ class CoverOptionsPage(OptionsPage): enabled = self.ui.save_images_to_tags.isChecked() self.ui.cb_embed_front_only.setEnabled(enabled) + register_options_page(CoverOptionsPage) diff --git a/picard/ui/options/fingerprinting.py b/picard/ui/options/fingerprinting.py index 6a903e302..a13edca03 100644 --- a/picard/ui/options/fingerprinting.py +++ b/picard/ui/options/fingerprinting.py @@ -154,4 +154,5 @@ class FingerprintingOptionsPage(OptionsPage): def display_error(self, error): pass + register_options_page(FingerprintingOptionsPage) diff --git a/picard/ui/options/interface.py b/picard/ui/options/interface.py index 2acd9b748..4ee315b0f 100644 --- a/picard/ui/options/interface.py +++ b/picard/ui/options/interface.py @@ -55,47 +55,47 @@ class InterfaceOptionsPage(OptionsPage): 'label': N_('Add Folder'), 'icon': 'folder' }, - 'add_files_action': { + 'add_files_action': { 'label': N_('Add Files'), 'icon': 'document-open' }, - 'cluster_action': { + 'cluster_action': { 'label': N_('Cluster'), 'icon': 'picard-cluster' }, - 'autotag_action': { + 'autotag_action': { 'label': N_('Lookup'), 'icon': 'picard-auto-tag' }, - 'analyze_action': { + 'analyze_action': { 'label': N_('Scan'), 'icon': 'picard-analyze' }, - 'browser_lookup_action': { + 'browser_lookup_action': { 'label': N_('Lookup in Browser'), 'icon': 'lookup-musicbrainz' }, - 'save_action': { + 'save_action': { 'label': N_('Save'), 'icon': 'document-save' }, - 'view_info_action': { + 'view_info_action': { 'label': N_('Info'), 'icon': 'picard-edit-tags' }, - 'remove_action': { + 'remove_action': { 'label': N_('Remove'), 'icon': 'list-remove' }, - 'submit_acoustid_action': { + 'submit_acoustid_action': { 'label': N_('Submit AcoustIDs'), 'icon': 'acoustid-fingerprinter' }, - 'play_file_action': { + 'play_file_action': { 'label': N_('Open in Player'), 'icon': 'play-music' }, - 'cd_lookup_action': { + 'cd_lookup_action': { 'label': N_('Lookup CD...'), 'icon': 'media-optical' }, @@ -137,7 +137,8 @@ class InterfaceOptionsPage(OptionsPage): self.ui.setupUi(self) self.ui.ui_language.addItem(_('System default'), '') language_list = [(l[0], l[1], _(l[2])) for l in UI_LANGUAGES] - fcmp = lambda x: locale.strxfrm(x[2]) + + def fcmp(x): return locale.strxfrm(x[2]) for lang_code, native, translation in sorted(language_list, key=fcmp): if native and native != translation: name = '%s (%s)' % (translation, native) diff --git a/picard/ui/options/plugins.py b/picard/ui/options/plugins.py index f1b313abb..8bd29038d 100644 --- a/picard/ui/options/plugins.py +++ b/picard/ui/options/plugins.py @@ -53,6 +53,7 @@ from picard.ui.ui_options_plugins import Ui_PluginsOptionsPage COLUMN_NAME, COLUMN_VERSION, COLUMN_ACTION = range(3) + class PluginTreeWidgetItem(HashableTreeWidgetItem): def __lt__(self, other): @@ -254,9 +255,13 @@ class PluginsOptionsPage(OptionsPage): def uninstall_plugin(self): plugin = self.items[self.ui.plugins.selectedItems()[COLUMN_NAME]] - buttonReply = QtWidgets.QMessageBox.question(self, _("Uninstall plugin?"), - _("Do you really want to uninstall the plugin '%s' ?") % plugin.name, - QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) + buttonReply = QtWidgets.QMessageBox.question( + self, + _("Uninstall plugin?"), + _("Do you really want to uninstall the plugin '%s' ?") % plugin.name, + QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, + QtWidgets.QMessageBox.No + ) if buttonReply == QtWidgets.QMessageBox.Yes: self.tagger.pluginmanager.remove_plugin(plugin.module_name) item = self.ui.plugins.currentItem() diff --git a/picard/ui/options/releases.py b/picard/ui/options/releases.py index ae09dad92..caa76a0a3 100644 --- a/picard/ui/options/releases.py +++ b/picard/ui/options/releases.py @@ -243,7 +243,8 @@ class ReleasesOptionsPage(OptionsPage): in source.items()] else: source_list = [(c[0], _(c[1])) for c in source.items()] - fcmp = lambda x: strxfrm(x[1]) + + def fcmp(x): return strxfrm(x[1]) source_list.sort(key=fcmp) saved_data = config.setting[setting] move = [] diff --git a/picard/ui/options/renaming.py b/picard/ui/options/renaming.py index 746b89af5..2cd22b834 100644 --- a/picard/ui/options/renaming.py +++ b/picard/ui/options/renaming.py @@ -133,7 +133,6 @@ class RenamingOptionsPage(OptionsPage): else: self.ui.file_naming_format.setPalette(self.textEditPaletteReadOnly) - def check_formats(self): self.test() self.update_examples() @@ -303,4 +302,5 @@ class RenamingOptionsPage(OptionsPage): self.ui.renaming_error.setText(e.info) return + register_options_page(RenamingOptionsPage) diff --git a/picard/ui/options/scripting.py b/picard/ui/options/scripting.py index 657046dad..3218ada63 100644 --- a/picard/ui/options/scripting.py +++ b/picard/ui/options/scripting.py @@ -196,6 +196,7 @@ class AdvancedScriptItem(QtWidgets.QWidget): class ScriptItem: """Holds a script's list and text widget properties and improves readability""" + def __init__(self, pos, name=None, enabled=True, text=""): self.pos = pos if name is None: diff --git a/picard/ui/searchdialog/album.py b/picard/ui/searchdialog/album.py index a6062db94..5950bf76a 100644 --- a/picard/ui/searchdialog/album.py +++ b/picard/ui/searchdialog/album.py @@ -96,7 +96,6 @@ class CoverWidget(QtWidgets.QWidget): self.shown.emit() - class CoverCell: def __init__(self, parent, release, row, colname, on_show=None): diff --git a/picard/ui/tagsfromfilenames.py b/picard/ui/tagsfromfilenames.py index 72fac47c9..a7d9689f7 100644 --- a/picard/ui/tagsfromfilenames.py +++ b/picard/ui/tagsfromfilenames.py @@ -99,7 +99,7 @@ class TagsFromFileNamesDialog(PicardDialog): return format_re, columns def match_file(self, file, tff_format): - match = tff_format.search(file.filename.replace('\\','/')) + match = tff_format.search(file.filename.replace('\\', '/')) if match: result = {} for name, value in match.groupdict().items(): diff --git a/picard/ui/util.py b/picard/ui/util.py index 7a4663889..9d499ef7a 100644 --- a/picard/ui/util.py +++ b/picard/ui/util.py @@ -111,6 +111,7 @@ class MultiDirsSelectDialog(QtWidgets.QFileDialog): of multiple directories. Depending on the platform, dialog may fallback on non-native. """ + def __init__(self, *args): super().__init__(*args) self.setFileMode(self.Directory) diff --git a/picard/util/__init__.py b/picard/util/__init__.py index 20d0eeac7..4dda00509 100644 --- a/picard/util/__init__.py +++ b/picard/util/__init__.py @@ -376,7 +376,7 @@ def album_artist_from_path(filename, album, artist): """If album is not set, try to extract album and artist from path """ if not album: - dirs = os.path.dirname(filename).replace('\\','/').lstrip('/').split('/') + dirs = os.path.dirname(filename).replace('\\', '/').lstrip('/').split('/') if len(dirs) == 0: return album, artist # Strip disc subdirectory from list @@ -501,14 +501,14 @@ def load_json(data): def parse_json(reply): return load_json(reply.readAll()) + def restore_method(func): def func_wrapper(*args, **kwargs): - if not QtCore.QObject.tagger._no_restore: - return func(*args, **kwargs) + if not QtCore.QObject.tagger._no_restore: + return func(*args, **kwargs) return func_wrapper - def compare_version_tuples(version1, version2): '''Compare Versions diff --git a/picard/util/astrcmp.py b/picard/util/astrcmp.py index 60dbe0577..c708b8d26 100644 --- a/picard/util/astrcmp.py +++ b/picard/util/astrcmp.py @@ -9,7 +9,7 @@ # information, see -def astrcmp_py(a,b): +def astrcmp_py(a, b): "Calculates the Levenshtein distance between a and b." n, m = len(a), len(b) if n > m: diff --git a/picard/util/checkupdate.py b/picard/util/checkupdate.py index d6a86716c..703bdc94a 100644 --- a/picard/util/checkupdate.py +++ b/picard/util/checkupdate.py @@ -122,7 +122,7 @@ class UpdateCheckManager(QtCore.QObject): high_version = PICARD_VERSION for test_key in PROGRAM_UPDATE_LEVELS: test_version = self._available_versions[PROGRAM_UPDATE_LEVELS[test_key]['name']]['version'] - if self._update_level >= test_key and compare_version_tuples(high_version, test_version) > 0: + if self._update_level >= test_key and compare_version_tuples(high_version, test_version) > 0: key = PROGRAM_UPDATE_LEVELS[test_key]['name'] high_version = test_version if key: @@ -135,7 +135,7 @@ class UpdateCheckManager(QtCore.QObject): "Would you like to download the new version?").format( picard_old_version=PICARD_FANCY_VERSION_STR, picard_new_version=self._available_versions[key]['tag'] - ), + ), QMessageBox.Ok | QMessageBox.Cancel, QMessageBox.Cancel ) == QMessageBox.Ok: @@ -149,6 +149,6 @@ class UpdateCheckManager(QtCore.QObject): "Your version: {picard_old_version}\n").format( update_level=_(PROGRAM_UPDATE_LEVELS[self._update_level]['title']) if self._update_level in PROGRAM_UPDATE_LEVELS else _('unknown'), picard_old_version=PICARD_FANCY_VERSION_STR, - ), + ), QMessageBox.Ok, QMessageBox.Ok ) diff --git a/picard/util/devutil/__init__.py b/picard/util/devutil/__init__.py index 628421fe7..d2ef4d18d 100644 --- a/picard/util/devutil/__init__.py +++ b/picard/util/devutil/__init__.py @@ -78,7 +78,7 @@ def printable_node(node, indent=0): if node.attribs: l = [] - for k,v in node.attribs.items(): + for k, v in node.attribs.items(): l.append(repr(k).decode('unicode-escape') + ': ' + repr(v).decode('unicode-escape')) el.append(indented('attribs={', l, '}', indent+1)) diff --git a/picard/util/filenaming.py b/picard/util/filenaming.py index 664b12176..01c54033b 100644 --- a/picard/util/filenaming.py +++ b/picard/util/filenaming.py @@ -141,7 +141,7 @@ def shorten_path(path, length, mode): length: Maximum number of code points / bytes allowed in a node. mode: One of SHORTEN_BYTES, SHORTEN_UTF16, SHORTEN_UTF16_NFD. """ - shorten = lambda n, l: n and shorten_filename(n, l, mode).strip() or "" + def shorten(n, l): return n and shorten_filename(n, l, mode).strip() or "" dirpath, filename = os.path.split(path) fileroot, ext = os.path.splitext(filename) return os.path.join( @@ -188,7 +188,7 @@ def _make_win_short_filename(relpath, reserved=0): remaining = MAX_DIRPATH_LEN - reserved # to make things more readable... - shorten = lambda p, l: shorten_path(p, l, mode=SHORTEN_UTF16) + def shorten(p, l): return shorten_path(p, l, mode=SHORTEN_UTF16) xlength = _get_utf16_length # shorten to MAX_NODE_LEN from the beginning diff --git a/picard/util/textencoding.py b/picard/util/textencoding.py index 6d09ec4cf..9ad99552f 100644 --- a/picard/util/textencoding.py +++ b/picard/util/textencoding.py @@ -76,6 +76,7 @@ from picard.util import sanitize_filename def _re_any(iterable): return re.compile('([' + ''.join(iterable) + '])', re.UNICODE) + _additional_compatibility = { "\u0276": "Œ", # LATIN LETTER SMALL CAPITAL OE "\u1D00": "A", # LATIN LETTER SMALL CAPITAL A @@ -179,6 +180,7 @@ _simplify_punctuation = { _re_simplify_punctuation = _re_any(_simplify_punctuation.keys()) _pathsave_simplify_punctuation = {k: sanitize_filename(v) for k, v in _simplify_punctuation.items()} + def unicode_simplify_punctuation(string, pathsave=False): punctuation = _pathsave_simplify_punctuation if pathsave else _simplify_punctuation return _re_simplify_punctuation.sub(lambda m: punctuation[m.group(0)], string) diff --git a/setup.py b/setup.py index 5812b0abf..a2537abd8 100644 --- a/setup.py +++ b/setup.py @@ -97,6 +97,7 @@ class picard_build_locales(Command): self.mkpath(path) self.spawn(['msgfmt', '-o', mo, po]) + Distribution.locales = None @@ -123,7 +124,7 @@ class picard_install_locales(Command): ('install_locales', 'install_dir'), ('force', 'force'), ('skip_build', 'skip_build'), - ) + ) def run(self): if not self.skip_build: @@ -279,7 +280,7 @@ class picard_build_ui(Command): tmp = StringIO() uic.compileUi(uifile, tmp) source = tmp.getvalue() - rc = re.compile(r'\n\n#.*?(?=\n\n)', re.MULTILINE|re.DOTALL) + rc = re.compile(r'\n\n#.*?(?=\n\n)', re.MULTILINE | re.DOTALL) comment = ("\n\n# Automatically generated - don't edit.\n" "# Use `python setup.py %s` to update it." % _get_option_name(self)) @@ -401,8 +402,8 @@ except ImportError: def _get_option_name(obj): """Returns the name of the option for specified Command object""" for name, klass in obj.distribution.cmdclass.items(): - if obj.__class__ == klass: - return name + if obj.__class__ == klass: + return name raise Exception("No such command class") @@ -571,7 +572,7 @@ def _explode_path(path): """Return a list of components of the path (ie. "/a/b" -> ["a", "b"])""" components = [] while True: - (path,tail) = os.path.split(path) + (path, tail) = os.path.split(path) if tail == "": components.reverse() return components diff --git a/test/test_formats.py b/test/test_formats.py index 488a3200d..74df658b6 100644 --- a/test/test_formats.py +++ b/test/test_formats.py @@ -280,7 +280,6 @@ class CommonTests: self.assertEqual(f._fixed_splitext('.test'), os.path.splitext('.test')) self.assertNotEqual(f._fixed_splitext(f.EXTENSIONS[0]), os.path.splitext(f.EXTENSIONS[0])) - class ID3Test(FormatsTest): def setup_tags(self): diff --git a/test/test_metadata.py b/test/test_metadata.py index bb53fc169..65a47940f 100644 --- a/test/test_metadata.py +++ b/test/test_metadata.py @@ -37,12 +37,12 @@ class MetadataTest(unittest.TestCase): pass def test_metadata_setitem(self): - self.assertEqual(["single1-value"], dict.get(self.metadata,"single1")) - self.assertEqual(["single2-value"], dict.get(self.metadata,"single2")) - self.assertEqual(self.multi1, dict.get(self.metadata,"multi1")) - self.assertEqual(self.multi2, dict.get(self.metadata,"multi2")) - self.assertEqual(self.multi3, dict.get(self.metadata,"multi3")) - self.assertEqual(["hidden-value"], dict.get(self.metadata,"~hidden")) + self.assertEqual(["single1-value"], dict.get(self.metadata, "single1")) + self.assertEqual(["single2-value"], dict.get(self.metadata, "single2")) + self.assertEqual(self.multi1, dict.get(self.metadata, "multi1")) + self.assertEqual(self.multi2, dict.get(self.metadata, "multi2")) + self.assertEqual(self.multi3, dict.get(self.metadata, "multi3")) + self.assertEqual(["hidden-value"], dict.get(self.metadata, "~hidden")) def test_metadata_get(self): self.assertEqual("single1-value", self.metadata["single1"]) @@ -121,7 +121,7 @@ class MetadataTest(unittest.TestCase): self.assertNotIn("single1", self.metadata.deleted_tags) def test_metadata_applyfunc(self): - func = lambda x: x[1:] + def func(x): return x[1:] self.metadata.apply_func(func) self.assertEqual("ingle1-value", self.metadata["single1"]) diff --git a/test/test_util_filenaming.py b/test/test_util_filenaming.py index 5413fd6f4..de59b6a87 100644 --- a/test/test_util_filenaming.py +++ b/test/test_util_filenaming.py @@ -80,7 +80,7 @@ class ShortFilenameTest(unittest.TestCase): root = os.path.join(self.root, "w" * 10, "x" * 10, "y" * 9, "z" * 9) fn = make_short_filename( root, os.path.join("b" * 200, "c" * 200, "d" * 200 + ".ext"), - win_compat=True, relative_to = self.root) + win_compat=True, relative_to=self.root) self.assertEqual(fn, os.path.join("b" * 100, "c" * 100, "d" * 7 + ".ext")) def test_windows_node_maxlength_shortening(self): diff --git a/test/test_utils.py b/test/test_utils.py index 4cb69552f..a9761a880 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -178,8 +178,6 @@ class AlbumArtistFromPathTest(unittest.TestCase): self.assertEqual(aafp(file_4, 'album', 'artist'), ('album', 'artist')) - - class ImageInfoTest(unittest.TestCase): def test_gif(self):