Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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: '<span weight="bold" size="xx-large">%s</span>' % text
self.markup = lambda text: f'<span weight="bold" size="xx-large">{text}</span>'

content = self.get_content_area()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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]:
Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ 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':
if value != self.accel_string:
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
Expand Down Expand Up @@ -168,15 +168,15 @@ 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':
if value != self.accel_string:
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
Expand Down
8 changes: 4 additions & 4 deletions files/usr/share/cinnamon/cinnamon-settings/bin/Spices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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))

Expand Down
10 changes: 5 additions & 5 deletions files/usr/share/cinnamon/cinnamon-settings/bin/capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -49,20 +49,20 @@ 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)

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
2 changes: 1 addition & 1 deletion files/usr/share/cinnamon/cinnamon-settings/bin/imtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 10 additions & 10 deletions files/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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!
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -571,7 +571,7 @@ def prepCategory(self, category):

widget = Gtk.Label(yalign=0.5)
widget.set_use_markup(True)
widget.set_markup('<span size="12000">%s</span>' % category["label"])
widget.set_markup(f'<span size="12000">{category["label"]}</span>')
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"]])
Expand Down Expand Up @@ -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`

Expand All @@ -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(
Expand All @@ -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"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 []

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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], "<b>%s</b>\n<small>%s%s</small>" % (label, artist, dimensions), path))
self._loaded_data.append((to_load, pix[0], f"<b>{label}</b>\n<small>{artist}{dimensions}</small>", path))
self._loaded_data_lock.release()

self._loading_lock.acquire()
Expand All @@ -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
Loading