Skip to content

Commit

Permalink
Continuing on quoting consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
zas committed Sep 24, 2023
1 parent d088dc1 commit f9200b9
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 60 deletions.
12 changes: 6 additions & 6 deletions picard/ui/ratingwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def __init__(self, parent, track):
super().__init__(parent)
self._track = track
config = get_config()
self._maximum = config.setting["rating_steps"] - 1
self._maximum = config.setting['rating_steps'] - 1
try:
self._rating = int(track.metadata["~rating"] or 0)
self._rating = int(track.metadata['~rating'] or 0)
except ValueError:
self._rating = 0
self._highlight = 0
Expand Down Expand Up @@ -105,12 +105,12 @@ def _submitted(self, document, http, error):
def _update_track(self):
track = self._track
rating = str(self._rating)
track.metadata["~rating"] = rating
track.metadata['~rating'] = rating
for file in track.files:
file.metadata["~rating"] = rating
file.metadata['~rating'] = rating
config = get_config()
if config.setting["submit_ratings"]:
ratings = {("recording", track.id): self._rating}
if config.setting['submit_ratings']:
ratings = {('recording', track.id): self._rating}
try:
self.tagger.mb_api.submit_ratings(ratings, self._submitted)
except ValueError: # This should never happen as self._rating is always an integer
Expand Down
80 changes: 40 additions & 40 deletions picard/ui/scripteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def update_examples(self, override=None, script_text=None):
if script_text and isinstance(script_text, str):
self.script_text = script_text

if self.settings["move_files"] or self.settings["rename_files"]:
if self.settings['move_files'] or self.settings['rename_files']:
if not self._sampled_example_files:
self.update_sample_example_files()
self.example_list = [self._example_to_filename(example) for example in self._sampled_example_files]
Expand All @@ -159,14 +159,14 @@ def _example_to_filename(self, file):
c_metadata.copy(file.metadata)
try:
# Only apply scripts if the original file metadata has not been changed.
if self.settings["enable_tagger_scripts"] and not c_metadata.diff(file.orig_metadata):
for s_pos, s_name, s_enabled, s_text in self.settings["list_of_scripts"]:
if self.settings['enable_tagger_scripts'] and not c_metadata.diff(file.orig_metadata):
for s_pos, s_name, s_enabled, s_text in self.settings['list_of_scripts']:
if s_enabled and s_text:
parser = ScriptParser()
parser.eval(s_text, c_metadata)
filename_before = file.filename
filename_after = file.make_filename(filename_before, c_metadata, self.settings, self.script_text)
if not self.settings["move_files"]:
if not self.settings['move_files']:
return os.path.basename(filename_before), os.path.basename(filename_after)
return filename_before, filename_after
except (ScriptError, TypeError, WinPathTooLong):
Expand Down Expand Up @@ -316,7 +316,7 @@ def confirmation_dialog(parent, message):
"""
dialog = QtWidgets.QMessageBox(
QtWidgets.QMessageBox.Icon.Warning,
_('Confirm'),
_("Confirm"),
message,
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel,
parent
Expand Down Expand Up @@ -395,15 +395,15 @@ class ScriptEditorDialog(PicardDialog, SingletonDialog):

PROFILES_KEY = SettingConfigSection.PROFILES_KEY
SETTINGS_KEY = SettingConfigSection.SETTINGS_KEY
SELECTED_SCRIPT_KEY = "selected_file_naming_script_id"
SCRIPTS_LIST_KEY = "file_renaming_scripts"
SELECTED_SCRIPT_KEY = 'selected_file_naming_script_id'
SCRIPTS_LIST_KEY = 'file_renaming_scripts'

help_url = PICARD_URLS["doc_naming_script_edit"]
help_url = PICARD_URLS['doc_naming_script_edit']

options = [
BoolOption('persist', 'script_editor_show_documentation', False),
Option("setting", SCRIPTS_LIST_KEY, {}),
TextOption("setting", SELECTED_SCRIPT_KEY, ""),
Option('setting', SCRIPTS_LIST_KEY, {}),
TextOption('setting', SELECTED_SCRIPT_KEY, ''),
]

signal_save = QtCore.pyqtSignal()
Expand Down Expand Up @@ -456,7 +456,7 @@ def __init__(self, parent=None, examples=None):
self.installEventFilter(self)

# Dialog buttons
self.reset_button = QtWidgets.QPushButton(_('Reset'))
self.reset_button = QtWidgets.QPushButton(_("Reset"))
self.reset_button.setToolTip(self.reset_action.toolTip())
self.reset_button.clicked.connect(self.reload_from_config)
self.ui.buttonbox.addButton(self.reset_button, QtWidgets.QDialogButtonBox.ButtonRole.ActionRole)
Expand Down Expand Up @@ -530,7 +530,7 @@ def make_menu(self):
main_menu = QtWidgets.QMenuBar()

# File menu settings
file_menu = main_menu.addMenu(_('&File'))
file_menu = main_menu.addMenu(_("&File"))
file_menu.setToolTipsVisible(True)

self.import_action = QtWidgets.QAction(_("&Import a script file"), self)
Expand Down Expand Up @@ -563,7 +563,7 @@ def make_menu(self):
file_menu.addAction(self.close_action)

# Script menu settings
script_menu = main_menu.addMenu(_('&Script'))
script_menu = main_menu.addMenu(_("&Script"))
script_menu.setToolTipsVisible(True)

self.details_action = QtWidgets.QAction(_("View/Edit Script &Metadata"), self)
Expand All @@ -590,7 +590,7 @@ def make_menu(self):
script_menu.addAction(self.delete_action)

# Display menu settings
display_menu = main_menu.addMenu(_('&View'))
display_menu = main_menu.addMenu(_("&View"))
display_menu.setToolTipsVisible(True)

self.examples_action = QtWidgets.QAction(_("&Reload random example files"), self)
Expand All @@ -611,7 +611,7 @@ def make_menu(self):
display_menu.addAction(self.docs_action)

# Help menu settings
help_menu = main_menu.addMenu(_('&Help'))
help_menu = main_menu.addMenu(_("&Help"))
help_menu.setToolTipsVisible(True)

self.help_action = QtWidgets.QAction(_("&Help…"), self)
Expand All @@ -638,7 +638,7 @@ def _add_menu_item(title, script):
self.add_action.addAction(script_action)

# Add blank script template
_add_menu_item(_('Empty / blank script'), f"$noop( {_('New Script')} )")
_add_menu_item(_("Empty / blank script"), f"$noop( {_('New Script')} )")

# Add preset script templates
for script_item in get_file_naming_script_presets():
Expand Down Expand Up @@ -802,12 +802,12 @@ def scripts_in_profiles(self):
profiles = config.profiles[self.PROFILES_KEY]
profile_settings = config.profiles[self.SETTINGS_KEY]
for profile in profiles:
settings = profile_settings[profile["id"]]
settings = profile_settings[profile['id']]
if self.SELECTED_SCRIPT_KEY in settings:
profiles_list.append(
self.Profile(
profile["id"],
profile["title"],
profile['id'],
profile['title'],
settings[self.SELECTED_SCRIPT_KEY]
)
)
Expand All @@ -818,7 +818,7 @@ def update_script_text(self):
"""
selected = self.ui.preset_naming_scripts.currentIndex()
script_item = self.ui.preset_naming_scripts.itemData(selected)
script_item["script"] = self.get_script()
script_item['script'] = self.get_script()
self.update_combo_box_item(selected, script_item)

def check_duplicate_script_title(self, new_title=None):
Expand Down Expand Up @@ -849,7 +849,7 @@ def update_script_title(self):
script_item = self.ui.preset_naming_scripts.itemData(selected)
if title:
if self.check_duplicate_script_title(new_title=title):
script_item["title"] = title
script_item['title'] = title
self.update_combo_box_item(selected, script_item)
self.save_script()
self.signal_selection_changed.emit()
Expand All @@ -858,7 +858,7 @@ def update_script_title(self):
self.ui.script_title.setFocus()
else:
self.display_error(OptionsCheckError(_("Error"), _("The script title must not be empty.")))
self.ui.script_title.setText(script_item["title"])
self.ui.script_title.setText(script_item['title'])
self.ui.script_title.setFocus()

def populate_script_selector(self):
Expand All @@ -872,7 +872,7 @@ def toggle_documentation(self):
"""
checked = self.docs_action.isChecked()
config = get_config()
config.persist["script_editor_show_documentation"] = checked
config.persist['script_editor_show_documentation'] = checked
self.ui.documentation_frame.setVisible(checked)

def view_script_details(self):
Expand Down Expand Up @@ -916,7 +916,7 @@ def _insert_item(self, script_item):
Args:
script_item (dict): File naming script to insert as produced by FileNamingScript().to_dict()
"""
self.selected_script_id = script_item["id"]
self.selected_script_id = script_item['id']
self.naming_scripts[self.selected_script_id] = script_item
idx = populate_script_selection_combo_box(
self.naming_scripts,
Expand Down Expand Up @@ -958,11 +958,11 @@ def make_it_so(self):
"""Save the scripts and settings to configuration and exit.
"""
script_item = self.get_selected_item()
self.selected_script_id = script_item["id"]
self.selected_script_id = script_item['id']
self.naming_scripts = self.get_scripts_dict()
config = get_config()
config.setting[self.SCRIPTS_LIST_KEY] = self.naming_scripts
config.setting[self.SELECTED_SCRIPT_KEY] = script_item["id"]
config.setting[self.SELECTED_SCRIPT_KEY] = script_item['id']
self.close()

def get_scripts_dict(self):
Expand All @@ -974,7 +974,7 @@ def get_scripts_dict(self):
naming_scripts = {}
for idx in range(self.ui.preset_naming_scripts.count()):
script_item = self.ui.preset_naming_scripts.itemData(idx)
naming_scripts[script_item["id"]] = script_item
naming_scripts[script_item['id']] = script_item
return naming_scripts

def get_selected_item(self, idx=None):
Expand All @@ -999,7 +999,7 @@ def set_selected_script_id(self, id):
idx = 0
for i in range(self.ui.preset_naming_scripts.count()):
script_item = self.ui.preset_naming_scripts.itemData(i)
if script_item["id"] == id:
if script_item['id'] == id:
idx = i
break
self.set_selected_script_index(idx)
Expand Down Expand Up @@ -1119,7 +1119,7 @@ def delete_script(self):
).exec_()
return

if confirmation_dialog(self, _('Are you sure that you want to delete the script?')):
if confirmation_dialog(self, _("Are you sure that you want to delete the script?")):
widget = self.ui.preset_naming_scripts
idx = widget.currentIndex()
widget.blockSignals(True)
Expand Down Expand Up @@ -1159,8 +1159,8 @@ def save_script(self):
if title:
script_item = self.ui.preset_naming_scripts.itemData(selected)
if self.check_duplicate_script_title(new_title=title):
script_item["title"] = title
script_item["script"] = self.get_script()
script_item['title'] = title
script_item['script'] = self.get_script()
self.update_combo_box_item(selected, script_item)
else:
self.display_error(OptionsCheckError(_("Error"), _("The script title must not be empty.")))
Expand Down Expand Up @@ -1224,7 +1224,7 @@ def import_script(self):
continue
box = QtWidgets.QMessageBox()
box.setIcon(QtWidgets.QMessageBox.Icon.Question)
box.setWindowTitle(_('Confirm'))
box.setWindowTitle(_("Confirm"))
box.setText(
_(
"A script named \"{script_name}\" already exists.\n"
Expand Down Expand Up @@ -1279,7 +1279,7 @@ def check_format(self):
parser.eval(script_text)
except Exception as e:
raise ScriptCheckError("", str(e))
if config.setting["rename_files"]:
if config.setting['rename_files']:
if not self.get_script():
raise ScriptCheckError("", _("The file naming format must not be empty."))

Expand Down Expand Up @@ -1318,7 +1318,7 @@ class ScriptDetailsEditor(PicardDialog):
"""View / edit the metadata details for a script.
"""
NAME = 'scriptdetails'
TITLE = N_('Script Details')
TITLE = N_("Script Details")

signal_save = QtCore.pyqtSignal()

Expand Down Expand Up @@ -1401,12 +1401,12 @@ def save_changes(self):
last_updated = self.ui.script_last_updated
if not last_updated.isModified() or not last_updated.text().strip():
self.set_last_updated()
self.script_item["title"] = self.ui.script_title.text().strip()
self.script_item["author"] = self.ui.script_author.text().strip()
self.script_item["version"] = self.ui.script_version.text().strip()
self.script_item["license"] = self.ui.script_license.text().strip()
self.script_item["description"] = self.ui.script_description.toPlainText().strip()
self.script_item["last_updated"] = self.ui.script_last_updated.text().strip()
self.script_item['title'] = self.ui.script_title.text().strip()
self.script_item['author'] = self.ui.script_author.text().strip()
self.script_item['version'] = self.ui.script_version.text().strip()
self.script_item['license'] = self.ui.script_license.text().strip()
self.script_item['description'] = self.ui.script_description.toPlainText().strip()
self.script_item['last_updated'] = self.ui.script_last_updated.text().strip()
self.signal_save.emit()
self.skip_change_check = True
self.close_window()
Expand Down
4 changes: 2 additions & 2 deletions picard/ui/statusindicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def __init__(self, bus, app_id):
@property
def current_progress(self):
return {
"progress": self._progress,
"progress-visible": self._visible,
'progress': self._progress,
'progress-visible': self._visible,
}

@property
Expand Down
6 changes: 3 additions & 3 deletions picard/ui/tagsfromfilenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class TagsFromFileNamesDialog(PicardDialog):
help_url = 'doc_tags_from_filenames'

options = [
TextOption("persist", "tags_from_filenames_format", ""),
TextOption('persist', 'tags_from_filenames_format', ''),
]

def __init__(self, files, parent=None):
Expand All @@ -118,7 +118,7 @@ def __init__(self, files, parent=None):
"%artist% - %album%/%tracknumber% - %title%",
]
config = get_config()
tff_format = config.persist["tags_from_filenames_format"]
tff_format = config.persist['tags_from_filenames_format']
if tff_format not in items:
selected_index = 0
if tff_format:
Expand Down Expand Up @@ -163,5 +163,5 @@ def accept(self):
file.metadata.update(metadata)
file.update()
config = get_config()
config.persist["tags_from_filenames_format"] = self.ui.format.currentText()
config.persist['tags_from_filenames_format'] = self.ui.format.currentText()
super().accept()
4 changes: 2 additions & 2 deletions picard/ui/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def is_dark_theme(self):
r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize") as key:
dark_theme = winreg.QueryValueEx(key, "AppsUseLightTheme")[0] == 0
except OSError:
log.warning('Failed reading AppsUseLightTheme from registry')
log.warning("Failed reading AppsUseLightTheme from registry")
return dark_theme

@property
Expand All @@ -190,7 +190,7 @@ def accent_color(self):
accent_color_hex = '#{:06x}'.format(accent_color_dword & 0xffffff)
accent_color = QtGui.QColor(accent_color_hex)
except OSError:
log.warning('Failed reading ColorizationColor from registry')
log.warning("Failed reading ColorizationColor from registry")
return accent_color

def update_palette(self, palette, dark_theme, accent_color):
Expand Down
14 changes: 7 additions & 7 deletions picard/ui/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class StandardButton(QtWidgets.QPushButton):
CLOSE = 4

__types = {
OK: (N_('&Ok'), 'SP_DialogOkButton'),
CANCEL: (N_('&Cancel'), 'SP_DialogCancelButton'),
HELP: (N_('&Help'), 'SP_DialogHelpButton'),
CLOSE: (N_('Clos&e'), 'SP_DialogCloseButton'),
OK: (N_("&Ok"), 'SP_DialogOkButton'),
CANCEL: (N_("&Cancel"), 'SP_DialogCancelButton'),
HELP: (N_("&Help"), 'SP_DialogHelpButton'),
CLOSE: (N_("Clos&e"), 'SP_DialogCloseButton'),
}

def __init__(self, btntype):
Expand All @@ -65,10 +65,10 @@ def __init__(self, btntype):

def find_starting_directory():
config = get_config()
if config.setting["starting_directory"]:
path = config.setting["starting_directory_path"]
if config.setting['starting_directory']:
path = config.setting['starting_directory_path']
else:
path = config.persist["current_directory"] or QtCore.QDir.homePath()
path = config.persist['current_directory'] or QtCore.QDir.homePath()
return find_existing_path(path)


Expand Down

0 comments on commit f9200b9

Please sign in to comment.