diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/ChooserButtonWidgets.py b/files/usr/share/cinnamon/cinnamon-settings/bin/ChooserButtonWidgets.py index 0d40e97e66..516065deb2 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/ChooserButtonWidgets.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/ChooserButtonWidgets.py @@ -130,7 +130,7 @@ def create_scaled_surface(self, path): if pixbuf: return Gdk.cairo_surface_create_from_pixbuf(pixbuf, self.scale) except GLib.Error as e: - print("Could not load thumbnail file '%s': %s" % (path, e.message)) + print(f"Could not load thumbnail file '{path}': {e.message}") return None def set_picture_from_file (self, path): @@ -408,7 +408,7 @@ def __init__(self, time, window, use_seconds, use24hour): self.time = {'hour': time.hour, 'minute': time.minute, 'second': time.second} self.use_seconds = use_seconds self.use24hour = use24hour - self.markup = lambda text: '%s' % text + self.markup = lambda text: f'{text}' content = self.get_content_area() diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py b/files/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py index d554f1067e..aea1af04d2 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/CinnamonGtkSettings.py @@ -95,7 +95,7 @@ def __init__(self, selector): self.selector = selector - self.rule_separator = "/***** %s - cinnamon-settings-generated - do not edit *****/" % self.selector + self.rule_separator = f"/***** {self.selector} - cinnamon-settings-generated - do not edit *****/" rules = [] file = Gio.File.new_for_path(self._path) @@ -368,7 +368,7 @@ def apply_later(self, *args): def apply(self): editor = get_css_editor() for name in self.decl_names: - value_as_str = "%d%s" % (int(self.content_widget.get_value()), self.units) + value_as_str = f"{int(self.content_widget.get_value()):d}{self.units}" editor.set_declaration(self.selector, name, value_as_str) editor.save_stylesheet() @@ -429,7 +429,7 @@ def __init__(self, ui_scale): if e.code == Gio.IOErrorEnum.NOT_FOUND: pass else: - print("Could not load .gtkrc-2.0 file: %s" % e.message) + print(f"Could not load .gtkrc-2.0 file: {e.message}") self.parse_contents() @@ -446,7 +446,7 @@ def on_set_size_timeout(self, size): c = self._contents if size > 0: - style_prop = "GtkScrollbar::slider-width = %d" % size + style_prop = f"GtkScrollbar::slider-width = {size:d}" final_contents = c[:self.style_prop_start] + style_prop + c[self.style_prop_start:] else: final_contents = self._contents @@ -463,7 +463,7 @@ def on_set_size_timeout(self, size): 0, None) except GLib.Error as e: - print("Could not save .gtkrc-2.0 file: %s" % e.message) + print(f"Could not save .gtkrc-2.0 file: {e.message}") self.timeout_id = 0 return False diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/JsonSettingsWidgets.py b/files/usr/share/cinnamon/cinnamon-settings/bin/JsonSettingsWidgets.py index 806813f812..fd3ac21bcf 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/JsonSettingsWidgets.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/JsonSettingsWidgets.py @@ -154,7 +154,7 @@ def get_settings(self): try: settings = json.loads(raw_data, object_pairs_hook=collections.OrderedDict) except: - raise Exception("Failed to parse settings JSON data for file %s" % self.filepath) + raise Exception(f"Failed to parse settings JSON data for file {self.filepath}") return settings def save_settings(self): @@ -206,7 +206,7 @@ def load_from_file(self, filepath): try: settings = json.loads(raw_data, object_pairs_hook=collections.OrderedDict) except: - raise Exception("Failed to parse settings JSON data for file %s" % self.filepath) + raise Exception(f"Failed to parse settings JSON data for file {self.filepath}") for key in self.settings: if "value" not in self.settings[key]: @@ -215,7 +215,7 @@ def load_from_file(self, filepath): self.settings[key]["value"] = settings[key]["value"] self.do_key_update(key) else: - print("Skipping key %s: the key does not exist in %s or has no value" % (key, filepath)) + print(f"Skipping key {key}: the key does not exist in {filepath} or has no value") self.save_settings() def save_to_file(self, filepath): diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/KeybindingWidgets.py b/files/usr/share/cinnamon/cinnamon-settings/bin/KeybindingWidgets.py index 0dc3439f8f..c972581cb0 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/KeybindingWidgets.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/KeybindingWidgets.py @@ -110,7 +110,7 @@ def do_get_property(self, prop): if prop.name == 'accel-string': return self.accel_string else: - raise AttributeError('unknown property %s' % prop.name) + raise AttributeError(f'unknown property {prop.name}') def do_set_property(self, prop, value): if prop.name == 'accel-string': @@ -118,7 +118,7 @@ def do_set_property(self, prop, value): self.accel_string = value self.keybinding_cell.set_value(value) else: - raise AttributeError('unknown property %s' % prop.name) + raise AttributeError(f'unknown property {prop.name}') def get_accel_string(self): return self.accel_string @@ -168,7 +168,7 @@ def do_get_property(self, prop): if prop.name == 'accel-string': return self.accel_string else: - raise AttributeError('unknown property %s' % prop.name) + raise AttributeError(f'unknown property {prop.name}') def do_set_property(self, prop, value): if prop.name == 'accel-string': @@ -176,7 +176,7 @@ def do_set_property(self, prop, value): self.accel_string = value self.update_label() else: - raise AttributeError('unknown property %s' % prop.name) + raise AttributeError(f'unknown property {prop.name}') def update_label(self): text = _("unassigned") if self.default_value else self.text_string diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py b/files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py index a00c300ec8..e5d4747dcc 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py @@ -453,7 +453,7 @@ def _load_metadata(self): try: keyfile.load_from_file(full_path, GLib.KeyFileFlags.KEEP_TRANSLATIONS) except GLib.Error as e: - print("Could not read action file '%s': %s" % (full_path, e.message)) + print(f"Could not read action file '{full_path}': {e.message}") continue try: @@ -469,7 +469,7 @@ def _load_metadata(self): name = keyfile.get_locale_string('Nemo Action', 'Name') metadata['name'] = name.replace("_", "") except GLib.Error as e: - print("Could not read Name field for action. Skipping '%s': %s" % (full_path, e.message)) + print(f"Could not read Name field for action. Skipping '{full_path}': {e.message}") continue try: @@ -797,8 +797,8 @@ def _uninstall(self, job): if os.path.exists(locale_inst): i19_folders = os.listdir(locale_inst) for i19_folder in i19_folders: - if os.path.isfile(os.path.join(locale_inst, i19_folder, 'LC_MESSAGES', '%s.mo' % uuid)): - os.remove(os.path.join(locale_inst, i19_folder, 'LC_MESSAGES', '%s.mo' % uuid)) + if os.path.isfile(os.path.join(locale_inst, i19_folder, 'LC_MESSAGES', f'{uuid}.mo')): + os.remove(os.path.join(locale_inst, i19_folder, 'LC_MESSAGES', f'{uuid}.mo')) # Clean-up this locale folder removeEmptyFolders(os.path.join(locale_inst, i19_folder)) diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/capi.py b/files/usr/share/cinnamon/cinnamon-settings/bin/capi.py index 77621a98a8..abd0a565b4 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/capi.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/capi.py @@ -38,9 +38,9 @@ def __init__(self): x86archs = ["i386", "i486", "i586", "i686"] if architecture in x86archs: for arch in x86archs: - paths += ["/usr/lib/%s" % arch] + paths += [f"/usr/lib/{arch}"] else: - paths += ["/usr/lib/%s" % architecture] + paths += [f"/usr/lib/{architecture}"] for path in paths: if not os.path.islink(path): @@ -49,12 +49,12 @@ def __init__(self): try: self.modules = self.modules + Gio.io_modules_load_all_in_directory(path) except Exception as e: - print("capi failed to load multiarch modules from %s: " % path, e) + print(f"capi failed to load multiarch modules from {path}: ", e) def get_c_widget(self, mod_id): extension = self.extension_point.get_extension_by_name(mod_id) if extension is None: - print("Could not load %s module; is the cinnamon-control-center package installed?" % mod_id) + print(f"Could not load {mod_id} module; is the cinnamon-control-center package installed?") return None panel_type = extension.get_type() return GObject.new(panel_type) @@ -62,7 +62,7 @@ def get_c_widget(self, mod_id): def lookup_c_module(self, mod_id): extension = self.extension_point.get_extension_by_name(mod_id) if extension is None: - print("Could not find %s module; is the cinnamon-control-center package installed?" % mod_id) + print(f"Could not find {mod_id} module; is the cinnamon-control-center package installed?") return False else: return True diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/imtools.py b/files/usr/share/cinnamon/cinnamon-settings/bin/imtools.py index 36695338a0..b7b411b925 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/imtools.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/imtools.py @@ -442,7 +442,7 @@ def generate_layer(image_size, mark, method, mark = mark.transpose(orientation_value) paste(layer, mark, location, force=True) else: - raise ValueError('Unknown method "%s" for generate_layer.' % method) + raise ValueError(f'Unknown method "{method}" for generate_layer.') return layer diff --git a/files/usr/share/cinnamon/cinnamon-settings/bin/proxygsettings.py b/files/usr/share/cinnamon/cinnamon-settings/bin/proxygsettings.py index b6fc1cd37a..7adaed4163 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/bin/proxygsettings.py +++ b/files/usr/share/cinnamon/cinnamon-settings/bin/proxygsettings.py @@ -71,14 +71,14 @@ def proxy_url_from_settings(scheme, gsettings): proxy_url = "" if username is not None: if pwd is not None: - proxy_url = "%s:%s@%s:%d" % (username,pwd,host,port) + proxy_url = f"{username}:{pwd}@{host}:{port:d}" else: - proxy_url = "%s@%s:%d" % (username,host,port) + proxy_url = f"{username}@{host}:{port:d}" else: - proxy_url = "%s:%d" % (host,port) + proxy_url = f"{host}:{port:d}" if protocol is not None: - proxy_url = "%s://%s" % (protocol, proxy_url) + proxy_url = f"{protocol}://{proxy_url}" return proxy_url diff --git a/files/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py b/files/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py index e6fd3a5d8a..14b39f9e42 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py +++ b/files/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py @@ -158,7 +158,7 @@ def wrapper(*args, **kwargs): t1 = time.time() res = func(*args, **kwargs) t2 = time.time() - print('%s took %0.3f ms' % (func.__name__, (t2-t1)*1000.0)) + print(f'{func.__name__} took {(t2-t1)*1000.0:0.3f} ms') return res return wrapper @@ -262,7 +262,7 @@ def deselect(self, cat): # Create the UI def __init__(self, parsed_args): Gio.Application.__init__(self, - application_id="org.cinnamon.Settings_%d" % os.getpid(), + application_id=f"org.cinnamon.Settings_{os.getpid():d}", flags=Gio.ApplicationFlags.NON_UNIQUE | Gio.ApplicationFlags.HANDLES_OPEN) self.builder = Gtk.Builder() self.builder.set_translation_domain('cinnamon') # let it translate! @@ -360,7 +360,7 @@ def init_settings_overview(self): # Don't allow item names (and their translations) to be more than 30 chars long. It looks ugly and it creates huge gaps in the icon views name = sp.name if len(name) > 30: - name = "%s..." % name[:30] + name = f"{name[:30]}..." self.store_by_cat[sp_cat].append([name, Gio.ThemedIcon.new(sp.icon), sp, sp_cat]) self.min_label_length = 0 @@ -571,7 +571,7 @@ def prepCategory(self, category): widget = Gtk.Label(yalign=0.5) widget.set_use_markup(True) - widget.set_markup('%s' % category["label"]) + widget.set_markup(f'{category["label"]}') box.pack_start(widget, False, False, 1) self.side_view_container.pack_start(box, False, False, 0) widget = Gtk.IconView.new_with_model(self.storeFilter[category["id"]]) @@ -761,9 +761,9 @@ def _quit(self, *args): if i == 8: formatted_mods += "\n " i = 0 - EPILOG = """ + EPILOG = f""" Available modules: - %s + {formatted_mods} To see a list of available tabs for a specific module, use `cinnamon-settings MODULE --tab help` @@ -773,7 +773,7 @@ def _quit(self, *args): 2 | date: Sort by date 3 | installed: Show installed first 4 | update: Show upgradable first, then sort by date - """ % formatted_mods + """ sort_options = list(SORT_CHOICES.keys()) + list(SORT_CHOICES.values()) parser = argparse.ArgumentParser( @@ -798,11 +798,11 @@ def find_module_name(name): if args.module is not None and args.tab == "help": if args.module in TABS: - print("Available tabs for '%s':" % args.module) + print(f"Available tabs for '{args.module}':") for key in TABS[args.module]: - print(" %s" % key) + print(" {key}") else: - print("Module '%s' does not have any tabs." % args.module) + print("Module '{args.module}' does not have any tabs.") exit(0) if args.panel is not None and args.module not in ("applets", "panel"): diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_applets.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_applets.py index e0952d0264..7865795f17 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_applets.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_applets.py @@ -49,7 +49,7 @@ def load(self, window): self.stack.add_titled(download_applets_page, "more", _("Download")) class ManageAppletsPage(ManageSpicesPage): - directories = ["%s/.local/share/cinnamon/applets" % GLib.get_home_dir(), "/usr/share/cinnamon/applets"] + directories = [f"{GLib.get_home_dir()}/.local/share/cinnamon/applets", "/usr/share/cinnamon/applets"] collection_type = "applet" installed_page_title = _("Installed applets") instance_button_text = _("Add") diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_backgrounds.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_backgrounds.py index fff176a6f0..1c64f0f453 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_backgrounds.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_backgrounds.py @@ -366,7 +366,7 @@ def get_user_backgrounds(self): def format_source(self, type, path): # returns 'type://path' - return "%s://%s" % (type, path) + return f"{type}://{path}" def get_initial_path(self): try: @@ -484,7 +484,7 @@ def update_folder_list(self): if folder[STORE_PATH] == first_path: continue else: - file_data += "%s\n" % folder[STORE_PATH] + file_data += f"{folder[STORE_PATH]}\n" with open(path, "w") as f: f.write(file_data) @@ -565,7 +565,7 @@ def parse_xml_backgrounds_list(self, filename): res.append(wallpaperData) return res except Exception as detail: - print("Could not parse %s!" % filename) + print(f"Could not parse {filename}!") print(detail) return [] @@ -644,11 +644,11 @@ def get_pix(self, filename, size=None): with open(cache_filename, "wb") as cache_file: pickle.dump([png_bytes.getvalue(), width, height], cache_file, PICKLE_PROTOCOL_VERSION) except Exception as detail: - print("Failed to save cache file: %s: %s" % (cache_filename, detail)) + print(f"Failed to save cache file: {cache_filename}: {detail}") pix = [self._image_to_pixbuf(img), width, height] except Exception as detail: - print("Failed to convert %s: %s" % (filename, detail)) + print(f"Failed to convert {filename}: {detail}") pix = None if pix: self._data[filename][size] = pix @@ -777,13 +777,13 @@ def _do_load(self, path): else: label = os.path.split(to_load["filename"])[1] if "artist" in to_load: - artist = "%s\n" % to_load["artist"] + artist = f"{to_load["artist"]}\n" else: artist = "" - dimensions = "%dx%d" % (pix[1], pix[2]) + dimensions = f"{pix[1]}x{pix[2]}" self._loaded_data_lock.acquire() - self._loaded_data.append((to_load, pix[0], "%s\n%s%s" % (label, artist, dimensions), path)) + self._loaded_data.append((to_load, pix[0], f"{label}\n{artist}{dimensions}", path)) self._loaded_data_lock.release() self._loading_lock.acquire() @@ -803,8 +803,8 @@ def getFirstFileFromBackgroundXml(self, filename): if len(staticNode) > 0 and staticNode[-1].tag == "size": return staticNode[-1].text return staticNode.text - print("Could not find filename in %s" % filename) + print(f"Could not find filename in {filename}") return None except Exception as detail: - print("Failed to read filename from %s: %s" % (filename, detail)) + print(f"Failed to read filename from {filename}: {detail}") return None diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_default.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_default.py index 4c69191d35..df9c0d2e41 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_default.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_default.py @@ -204,7 +204,7 @@ def __init__(self, title, content): super(ColumnBox, self).__init__() label = Gtk.Label.new("") - label.set_markup('%s\n' % title) + label.set_markup(f'{title}\n') label.set_alignment(0.5, 0.5) self.set_homogeneous(False) @@ -259,7 +259,7 @@ def onChanged(self, button): info = button.get_app_info() if info: - print("%s: " % info.get_name()) + print("{info.get_name()}: ") supported_mimetypes = info.get_supported_types() hardcoded_mimetypes = None @@ -273,24 +273,24 @@ def onChanged(self, button): for t in sorted(supported_mimetypes): if t.startswith(self.generic_content_type): if info.set_as_default_for_type (t): - print(" Set as default for supported %s" % t) + print(f" Set as default for supported {t}") set_mimes.append(t) else: - print(" Failed to set as default application for '%s'" % t) + print(f" Failed to set as default application for '{t}'") # Also assign mimes hardcoded in the mimetypes hashtable if hardcoded_mimetypes is not None: for t in sorted(hardcoded_mimetypes): if t not in set_mimes: if info.set_as_default_for_type (t): - print(" Set as default for hardcoded %s" % t) + print(f" Set as default for hardcoded {t}") else: - print(" Failed to set as default application for '%s'" % t) + print(f" Failed to set as default application for '{t}'") #Web if self.content_type == "x-scheme-handler/http": if not info.set_as_default_for_type("x-scheme-handler/https"): - print(" Failed to set '%s' as the default application for '%s'" % (info.get_name(), "x-scheme-handler/https")) + print(f" Failed to set '{info.get_name()}' as the default application for 'x-scheme-handler/https'") class DefaultTerminalButton(Gtk.AppChooserButton): #TODO: See if we can get this to change the x-terminal-emulator default to allow it to be a more global change rather then just cinnamon/nemo @@ -528,7 +528,7 @@ def getDescription(self, content_type): break if description is None: - print("Content type '%s' is missing from the info panel" % content_type) + print(f"Content type '{content_type}' is missing from the info panel") return Gio.content_type_get_description(content_type) return description diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_desklets.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_desklets.py index a346d41867..713d948301 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_desklets.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_desklets.py @@ -73,7 +73,7 @@ def load(self, window): settings.add_row(GSettingsSwitch(_("Lock desklets in their current position"), "org.cinnamon", "lock-desklets")) class ManageDeskletsPage(ManageSpicesPage): - directories = ["%s/.local/share/cinnamon/desklets" % GLib.get_home_dir(), "/usr/share/cinnamon/desklets"] + directories = [f"{GLib.get_home_dir()}/.local/share/cinnamon/desklets", "/usr/share/cinnamon/desklets"] collection_type = "desklet" installed_page_title = _("Installed desklets") instance_button_text = _("Add") diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_extensions.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_extensions.py index 3467be8535..293f8ff3a0 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_extensions.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_extensions.py @@ -48,7 +48,7 @@ def load(self, window): self.stack.add_titled(download_extensions_page, "more", _("Download")) class ManageExtensionsPage(ManageSpicesPage): - directories = ['/usr/share/cinnamon/extensions', "%s/.local/share/cinnamon/extensions" % GLib.get_home_dir()] + directories = ['/usr/share/cinnamon/extensions', f"{GLib.get_home_dir()}/.local/share/cinnamon/extensions"] collection_type = "extension" installed_page_title = _("Installed extensions") instance_button_text = _("Enable") diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_gestures.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_gestures.py index 99389861aa..aece125043 100644 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_gestures.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_gestures.py @@ -72,9 +72,9 @@ def setting_to_string(action="", command=None, phase="end"): return "" if command is not None: - return "%s::%s::%s" % (action, command, phase) + return f"{action}::{command}::{phase}" else: - return "%s::%s" % (action, phase) + return f"{action}::{phase}" class Module: name = "gestures" @@ -204,7 +204,6 @@ def sort_by_direction(key1, key2): for fingers in range(2, 5): section = page.add_section(_("Pinch with %d fingers") % fingers) - for key in keys: label = self.get_key_label(key, "pinch", fingers) diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_info.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_info.py index ccc46e04d7..6582c1234e 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_info.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_info.py @@ -250,7 +250,7 @@ def on_upload_button_clicked(self, button, spinner): subproc.wait_check_async(None, self.on_subprocess_complete, spinner) spinner.start() except GLib.Error as e: - print("upload-system-info failed to run: %s" % e.message) + print(f"upload-system-info failed to run: {e.message}") def on_subprocess_complete(self, subproc, result, spinner): spinner.stop() @@ -258,4 +258,4 @@ def on_subprocess_complete(self, subproc, result, spinner): try: success = subproc.wait_check_finish(result) except GLib.Error as e: - print("upload-system-info failed: %s" % e.message) + print(f"upload-system-info failed: {e.message}") diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_panel.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_panel.py index 9c39453c3c..3c386262d6 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_panel.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_panel.py @@ -293,10 +293,10 @@ def on_next_panel(self, widget): def id_or_monitor_position_used(self, kept_panels, monitor_layout, panel_id, monitor_id, position): for keeper in kept_panels: if keeper.panel_id == panel_id: - print("cs_panel: Ignoring panel definition with an already-used ID: (ID: %s, Monitor: %d, Position: %s)" % (panel_id, monitor_id, position)) + print(f"cs_panel: Ignoring panel definition with an already-used ID: (ID: {panel_id}, Monitor: {monitor_id:d}, Position: {position})") return True if monitor_layout[monitor_id].position_used(position): - print("cs_panel: Ignoring panel definition with an already-used monitor:position: (ID: %s, Monitor: %d, Position: %s)" % (panel_id, monitor_id, position)) + print(f"cs_panel: Ignoring panel definition with an already-used monitor:position: (ID: {panel_id}, Monitor: {monitor_id:d}, Position: {position})") return True return False @@ -328,7 +328,7 @@ def on_panel_list_changed(self, *args): monitor_id = int(monitor_id) if monitor_id >= n_mons: - print("cs_panel: Ignoring panel definition with a monitor out of range: (ID: %s, Monitor: %d, Position: %s)" % (panel_id, monitor_id, position)) + print(f"cs_panel: Ignoring panel definition with a monitor out of range: (ID: {panel_id}, Monitor: {monitor_id:d}, Position: {position})") elif self.id_or_monitor_position_used(already_defined_panels, monitor_layout, panel_id, monitor_id, position): removals.append(def_) continue diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py index 19304d1bbb..00f96ab532 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_power.py @@ -245,7 +245,7 @@ def on_module_selected(self): try: brightness = proxy.GetPercentage() except GLib.Error as e: - print("Power module brightness page not available: %s" % e.message) + print(f"Power module brightness page not available: {e.message}") if self.show_battery_page: self.sidePage.add_widget(self.sidePage.stack) @@ -284,7 +284,7 @@ def on_module_selected(self): try: brightness = proxy.GetPercentage() except GLib.Error as e: - print("Power module no keyboard backlight: %s" % e.message) + print(f"Power module no keyboard backlight: {e.message}") else: section = page.add_section(_("Keyboard backlight")) section.add_row(BrightnessSlider(section, proxy, _("Backlight brightness"))) @@ -408,7 +408,7 @@ def set_device_ups_primary(self, device): desc = _("UPS") if model != "" or vendor != "": - desc = "%s %s" % (vendor, model) + desc = f"{vendor} {model}" widget = self.create_battery_row(device_id, "battery", desc, percentage, battery_level, details) return widget @@ -453,7 +453,7 @@ def set_device_battery_primary(self, device): desc = _("Battery") if model != "" or vendor != "": - desc = "%s %s" % (vendor, model) + desc = f"{vendor} {model}" widget = self.create_battery_row(device_id, "battery", desc, percentage, battery_level, details) return widget @@ -498,7 +498,7 @@ def add_battery_device_secondary(self, device): desc = (_("Battery")) if model != "" or vendor != "": - desc = "%s %s" % (vendor, model) + desc = f"{vendor} {model}" widget = self.create_battery_row(device_id, icon_name, desc, percentage, battery_level) return widget @@ -573,7 +573,7 @@ def on_alias_changed(self, entry, event, device_id): self.aliases[device_id] = entry.get_text() aliases = [] for alias in self.aliases: - aliases.append("%s:=%s" % (alias, self.aliases[alias])) + aliases.append(f"{alias}:={self.aliases[alias]}") self.settings.set_strv("device-aliases", aliases) diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_sound.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_sound.py index 77e99f6adc..725610250e 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_sound.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_sound.py @@ -54,7 +54,7 @@ def __init__(self, title): self.set_spacing(5) label = Gtk.Label() - label.set_markup("%s" % title) + label.set_markup(f"{title}") label.set_xalign(0.0) self.add(label) @@ -134,8 +134,8 @@ def __init__(self, title, minLabel, maxLabel, minValue, maxValue, sizeGroup, ste max_label.set_alignment(0.0, 0.75) min_label.set_margin_right(6) max_label.set_margin_left(6) - min_label.set_markup("%s" % minLabel) - max_label.set_markup("%s" % maxLabel) + min_label.set_markup(f"{minLabel}") + max_label.set_markup(f"{maxLabel}") sizeGroup.add_widget(min_label) sizeGroup.add_widget(max_label) @@ -472,7 +472,7 @@ def test(self, b, info): try: util.play_sound_name(sound, position[1]) except GLib.Error as e: - print("Could not play test sound: %s" % e.message) + print(f"Could not play test sound: {e.message}") def setPositionHideState(self): map = self.stream.get_channel_map() @@ -814,7 +814,7 @@ def streamAdded(self, c, deviceId): if name is None: name = _("Unknown") - label = "%s: " % name + label = "{name}: " self.appList[deviceId] = VolumeBar(self.controller.get_vol_max_norm(), 100, diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_startup.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_startup.py index ac0158096b..45ddb6c204 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_startup.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_startup.py @@ -84,7 +84,7 @@ def ensure_user_autostart_dir(self): try: os.makedirs(user_autostart_dir) except: - print("Could not create autostart dir: %s" % user_autostart_dir) + print(f"Could not create autostart dir: {user_autostart_dir}") def gather_apps(self): system_files = [] @@ -129,7 +129,7 @@ def load(self): try: self.key_file.load_from_file(self.app, KEYFILE_FLAGS) except GLib.GError as e: - print("Failed to load %s" % self.app, e) + print(f"Failed to load {self.app}", e) return self.key_file_loaded = True @@ -227,7 +227,7 @@ def save(self): else: key_file.load_from_file(self.path, KEYFILE_FLAGS) except Exception as e: - print("Problem creating user keyfile: %s" % e) + print(f"Problem creating user keyfile: {e}") key_file.set_string(D_GROUP, GLib.KEY_FILE_DESKTOP_KEY_TYPE, "Application") key_file.set_string(D_GROUP, GLib.KEY_FILE_DESKTOP_KEY_EXEC, "/bin/false") @@ -584,7 +584,7 @@ def on_add_app(self, popup): try: shutil.copyfile(desktop_file_dir, user_desktop_file) except IOError: - print("Failed to copy desktop file %s" % desktop_file_name) + print(f"Failed to copy desktop file {desktop_file_name}") app = AutostartApp(user_desktop_file, user_position=os.path.dirname(user_desktop_file)) key = get_appname(user_desktop_file) @@ -622,14 +622,14 @@ def find_free_basename(self, suggested_name): else: base_path = os.path.join(GLib.get_user_config_dir(), "autostart", suggested_name) - filename = "%s.desktop" % base_path + filename = f"{base_path}.desktop" basename = os.path.basename(filename) i = 1 max_tries = 100 while (self.find_app_with_basename(basename) is not None and i < max_tries): - filename = "%s-%d.desktop" % (base_path, i) + filename = f"{base_path}-{i:d}.desktop" basename = os.path.basename(filename) i += 1 @@ -863,7 +863,7 @@ def run_dialog(self): if error_msg is not None: msg_box = Gtk.MessageDialog(self, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CANCEL, - "%s" % error_msg) + f"{error_msg}") error_msg = None msg_box.run() msg_box.destroy() diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_themes.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_themes.py index bb69247371..9d08006507 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_themes.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_themes.py @@ -826,7 +826,7 @@ def refresh_chooser(self, chooser, path_suffix, themes, callback): with open(icon_cache_path, 'w') as cache_file: for theme_name, icon_path_val in icon_paths.items(): # Renamed icon_path to avoid conflict - cache_file.write('%s:%s\\n' % (theme_name, icon_path_val)) + cache_file.write(f'{theme_name}:{icon_path_val}\\n') else: if path_suffix == "cinnamon": @@ -869,14 +869,14 @@ def refresh_chooser(self, chooser, path_suffix, themes, callback): theme_name = theme_info['name'] theme_path_val = theme_info['path'] # Renamed theme_path to avoid conflict try: - for path_option in ["%s/%s/%s/thumbnail.png" % (theme_path_val, theme_name, path_suffix), - "/usr/share/cinnamon/thumbnails/%s/%s.png" % (path_suffix, theme_name), - "/usr/share/cinnamon/thumbnails/%s/unknown.png" % path_suffix]: + for path_option in [f"{theme_path_val}/{theme_name}/{path_suffix}/thumbnail.png" + f"/usr/share/cinnamon/thumbnails/{path_suffix}/{theme_name}.png", + f"/usr/share/cinnamon/thumbnails/{path_suffix}/unknown.png"]: if os.path.exists(path_option): chooser.add_picture(path_option, callback, title=theme_name, id=theme_name) break except: - chooser.add_picture("/usr/share/cinnamon/thumbnails/%s/unknown.png" % path_suffix, callback, title=theme_name, id=theme_name) + chooser.add_picture(f"/usr/share/cinnamon/thumbnails/{path_suffix}/unknown.png", callback, title=theme_name, id=theme_name) GLib.timeout_add(5, self.increment_progress, (chooser, inc)) # Add a blank separator if both single and multi-item categories exist @@ -903,14 +903,14 @@ def refresh_chooser(self, chooser, path_suffix, themes, callback): current_variant = variant try: - for path_option in ["%s/%s/%s/thumbnail.png" % (theme_path_val, theme_name, path_suffix), - "/usr/share/cinnamon/thumbnails/%s/%s.png" % (path_suffix, theme_name), - "/usr/share/cinnamon/thumbnails/%s/unknown.png" % path_suffix]: + for path_option in [f"{theme_path_val}/{theme_name}/{path_suffix}/thumbnail.png", + f"/usr/share/cinnamon/thumbnails/{path_suffix}/{theme_name}.png", + f"/usr/share/cinnamon/thumbnails/{path_suffix}/unknown.png"]: if os.path.exists(path_option): chooser.add_picture(path_option, callback, title=theme_name, id=theme_name) break except: - chooser.add_picture("/usr/share/cinnamon/thumbnails/%s/unknown.png" % path_suffix, callback, title=theme_name, id=theme_name) + chooser.add_picture(f"/usr/share/cinnamon/thumbnails/{path_suffix}/unknown.png", callback, title=theme_name, id=theme_name) GLib.timeout_add(5, self.increment_progress, (chooser, inc)) GLib.timeout_add(500, self.hide_progress, chooser) @@ -958,14 +958,14 @@ def set_button_chooser(self, chooser, theme, path_prefix, path_suffix, button_pi else: try: for path in ([os.path.join(datadir, path_prefix, theme, path_suffix, "thumbnail.png") for datadir in GLib.get_system_data_dirs()] - + [os.path.expanduser("~/.%s/%s/%s/thumbnail.png" % (path_prefix, theme, path_suffix)), - "/usr/share/cinnamon/thumbnails/%s/%s.png" % (path_suffix, theme), - "/usr/share/cinnamon/thumbnails/%s/unknown.png" % path_suffix]): + + [os.path.expanduser(f"~/.{path_prefix}/{theme}/{path_suffix}/thumbnail.png"), + f"/usr/share/cinnamon/thumbnails/{path_suffix}/{theme}.png", + f"/usr/share/cinnamon/thumbnails/{path_suffix}/unknown.png"]): if os.path.exists(path): chooser.set_picture_from_file(path) break except: - chooser.set_picture_from_file("/usr/share/cinnamon/thumbnails/%s/unknown.png" % path_suffix) + chooser.set_picture_from_file(f"/usr/share/cinnamon/thumbnails/{path_suffix}/unknown.png") def set_button_chooser_text(self, chooser, theme): chooser.set_button_label(theme) @@ -1014,7 +1014,7 @@ def filter_func_gtk_dir(self, directory): return False def update_cursor_theme_link(self, path, name): - contents = "[icon theme]\nInherits=%s\n" % name + contents = f"[icon theme]\nInherits={name}\n" self._set_cursor_theme_at(ICON_FOLDERS[0], contents) self._set_cursor_theme_at(ICON_FOLDERS[1], contents) diff --git a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_user.py b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_user.py index c50dde949c..b6278971cc 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/modules/cs_user.py +++ b/files/usr/share/cinnamon/cinnamon-settings/modules/cs_user.py @@ -130,7 +130,7 @@ def update_preview_cb (self, dialog, preview): self.frame.show() return except GLib.Error as e: - print("Unable to generate preview for file '%s' - %s\n" % (filename, e.message)) + print(f"Unable to generate preview for file '{filename}' - {e.message}\n") preview.clear() self.frame.hide() diff --git a/files/usr/share/cinnamon/cinnamon-settings/xlet-settings.py b/files/usr/share/cinnamon/cinnamon-settings/xlet-settings.py index 770bc337d0..49a828066f 100755 --- a/files/usr/share/cinnamon/cinnamon-settings/xlet-settings.py +++ b/files/usr/share/cinnamon/cinnamon-settings/xlet-settings.py @@ -131,15 +131,15 @@ def _on_proxy_ready (self, obj, result, data=None): proxy.highlightXlet('(ssb)', self.uuid, self.selected_instance["id"], True) def load_xlet_data (self): - self.xlet_dir = "/usr/share/cinnamon/%ss/%s" % (self.type, self.uuid) + self.xlet_dir = f"/usr/share/cinnamon/{self.type}s/{self.uuid}" if not os.path.exists(self.xlet_dir): - self.xlet_dir = "%s/.local/share/cinnamon/%ss/%s" % (home, self.type, self.uuid) + self.xlet_dir = f"{home}/.local/share/cinnamon/{self.type}s/{self.uuid}" - if os.path.exists("%s/metadata.json" % self.xlet_dir): - raw_data = open("%s/metadata.json" % self.xlet_dir).read() + if os.path.exists(f"{self.xlet_dir}/metadata.json"): + raw_data = open(f"{self.xlet_dir}/metadata.json").read() self.xlet_meta = json.loads(raw_data) else: - print("Could not find %s metadata for uuid %s - are you sure it's installed correctly?" % (self.type, self.uuid)) + print(f"Could not find {self.type} metadata for uuid {self.uuid} - are you sure it's installed correctly?") quit() def build_window(self): @@ -244,7 +244,7 @@ def check_sizing(widget, data=None): def load_instances(self): self.instance_info = [] path = Path(os.path.join(settings_dir, self.uuid)) - old_path = Path("%s/.cinnamon/configs/%s" % (home, self.uuid)) + old_path = Path(f"{home}/.cinnamon/configs/{self.uuid}") instances = 0 new_items = os.listdir(path) if path.exists() else [] old_items = os.listdir(old_path) if old_path.exists() else [] @@ -271,7 +271,7 @@ def load_instances(self): continue # multi-instance should have file names of the form [instance-id].json instance_exists = False - enabled = self.gsettings.get_strv('enabled-%ss' % self.type) + enabled = self.gsettings.get_strv(f'enabled-{self.type}s') for definition in enabled: if self.uuid in definition and instance_id in definition.split(':'): instance_exists = True