pylint
parent
ccdb16c748
commit
9a86bbff80
|
@ -1,13 +1,13 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
import gi
|
|
||||||
import json
|
import json
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import gi
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
from gi.repository import Gtk, GdkPixbuf
|
from gi.repository import Gtk, GdkPixbuf
|
||||||
|
|
||||||
|
@ -54,7 +54,8 @@ class Hello():
|
||||||
self.builder.get_object(btn.get_name()).set_from_file(icon_path)
|
self.builder.get_object(btn.get_name()).set_from_file(icon_path)
|
||||||
|
|
||||||
for widget in self.builder.get_object("homepage").get_children():
|
for widget in self.builder.get_object("homepage").get_children():
|
||||||
if isinstance(widget, Gtk.Button) and widget.get_image_position() is Gtk.PositionType.RIGHT:
|
if isinstance(widget, Gtk.Button) and \
|
||||||
|
widget.get_image_position() is Gtk.PositionType.RIGHT:
|
||||||
img = Gtk.Image.new_from_file(
|
img = Gtk.Image.new_from_file(
|
||||||
self.preferences["data_path"] + "img/external-link.png")
|
self.preferences["data_path"] + "img/external-link.png")
|
||||||
img.set_margin_left(2)
|
img.set_margin_left(2)
|
||||||
|
@ -83,7 +84,8 @@ class Hello():
|
||||||
self.builder.get_object("autostart").set_active(self.autostart)
|
self.builder.get_object("autostart").set_active(self.autostart)
|
||||||
|
|
||||||
# Live systems
|
# Live systems
|
||||||
if os.path.exists(self.preferences["live_path"]) and os.path.isfile(self.preferences["installer_path"]):
|
if os.path.exists(self.preferences["live_path"]) and \
|
||||||
|
os.path.isfile(self.preferences["installer_path"]):
|
||||||
self.builder.get_object("installlabel").set_visible(True)
|
self.builder.get_object("installlabel").set_visible(True)
|
||||||
self.builder.get_object("install").set_visible(True)
|
self.builder.get_object("install").set_visible(True)
|
||||||
|
|
||||||
|
@ -119,9 +121,9 @@ class Hello():
|
||||||
:type locale: str
|
:type locale: str
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
tr = gettext.translation(self.app, self.preferences[
|
translation = gettext.translation(self.app, self.preferences[
|
||||||
"locale_path"], [locale], fallback=True)
|
"locale_path"], [locale], fallback=True)
|
||||||
tr.install()
|
translation.install()
|
||||||
except OSError:
|
except OSError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -186,14 +188,14 @@ class Hello():
|
||||||
i3_config = fix_path("~/.i3/config")
|
i3_config = fix_path("~/.i3/config")
|
||||||
if os.path.isfile(i3_config):
|
if os.path.isfile(i3_config):
|
||||||
i3_autostart = "exec --no-startup-id " + self.app
|
i3_autostart = "exec --no-startup-id " + self.app
|
||||||
with open(i3_config, "r+") as f:
|
with open(i3_config, "r+") as fil:
|
||||||
content = f.read()
|
content = fil.read()
|
||||||
f.seek(0)
|
fil.seek(0)
|
||||||
if autostart:
|
if autostart:
|
||||||
f.write(content.replace("#" + i3_autostart, i3_autostart))
|
fil.write(content.replace("#" + i3_autostart, i3_autostart))
|
||||||
else:
|
else:
|
||||||
f.write(content.replace(i3_autostart, "#" + i3_autostart))
|
fil.write(content.replace(i3_autostart, "#" + i3_autostart))
|
||||||
f.truncate()
|
fil.truncate()
|
||||||
self.autostart = autostart
|
self.autostart = autostart
|
||||||
except OSError as error:
|
except OSError as error:
|
||||||
print(error)
|
print(error)
|
||||||
|
@ -210,8 +212,8 @@ class Hello():
|
||||||
filename = self.preferences["data_path"] + \
|
filename = self.preferences["data_path"] + \
|
||||||
"pages/{}/{}".format(self.preferences["default_locale"], name)
|
"pages/{}/{}".format(self.preferences["default_locale"], name)
|
||||||
try:
|
try:
|
||||||
with open(filename, "r") as f:
|
with open(filename, "r") as fil:
|
||||||
return f.read()
|
return fil.read()
|
||||||
except OSError:
|
except OSError:
|
||||||
return _("Can't load page.")
|
return _("Can't load page.")
|
||||||
|
|
||||||
|
@ -269,8 +271,8 @@ def read_json(path):
|
||||||
"""
|
"""
|
||||||
path = fix_path(path)
|
path = fix_path(path)
|
||||||
try:
|
try:
|
||||||
with open(path, "r") as f:
|
with open(path, "r") as fil:
|
||||||
return json.load(f)
|
return json.load(fil)
|
||||||
except OSError:
|
except OSError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -284,8 +286,8 @@ def write_json(path, content):
|
||||||
"""
|
"""
|
||||||
path = fix_path(path)
|
path = fix_path(path)
|
||||||
try:
|
try:
|
||||||
with open(path, "w") as f:
|
with open(path, "w") as fil:
|
||||||
json.dump(content, f)
|
json.dump(content, fil)
|
||||||
except OSError as error:
|
except OSError as error:
|
||||||
print(error)
|
print(error)
|
||||||
|
|
||||||
|
@ -295,8 +297,8 @@ def get_lsb_infos():
|
||||||
:rtype: dict"""
|
:rtype: dict"""
|
||||||
lsb = {}
|
lsb = {}
|
||||||
try:
|
try:
|
||||||
with open("/etc/lsb-release") as f:
|
with open("/etc/lsb-release") as fil:
|
||||||
for line in f:
|
for line in fil:
|
||||||
if "=" in line:
|
if "=" in line:
|
||||||
var, arg = line.rstrip().split("=")
|
var, arg = line.rstrip().split("=")
|
||||||
if var.startswith("DISTRIB_"):
|
if var.startswith("DISTRIB_"):
|
||||||
|
|
Loading…
Reference in New Issue