Merge pull request #3 from shaggytwodope/master

minor pep8 and spelling
merge-requests/64/head
Hugo Posnic 2016-12-21 15:40:41 +01:00 committed by GitHub
commit 5026204cc2
3 changed files with 12 additions and 6 deletions

View File

@ -13,7 +13,7 @@ Manjaro-hello is widely inspired by [manjaro-welcome](https://github.com/manjaro
- By using web technologies and Webkit, the renderer is a little bit slower than using native technologies.
- Can't know if each link will be open in an external browser or in app.
For all this reasons, I have choosen to build a new software from scratch but keeping the original structure.
For all this reasons, I have chosen to build a new software from scratch but keeping the original structure.
Currently, manjaro-hello has all the major features of manjaro-welcome plus a translation system.
- Interface is translated using gettext and po files. (po/)

View File

@ -11,6 +11,7 @@ import webbrowser
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf
class ManjaroHello():
def __init__(self):
# App vars
@ -57,14 +58,14 @@ class ManjaroHello():
self.builder.get_object("aboutdialog").set_logo(logo)
# Init translation
self.locales = ("de", "en", "fr", "pl") # supported locales
self.locales = ("de", "en", "fr", "pl") # supported locales
self.default_locale = "en"
self.sys_locale = locale.getdefaultlocale()[0]
self.default_texts = {}
self.preferences["locale"] = self.get_best_locale()
# Select current locale in languages menu
self.builder.get_object("languages").set_active_id(self.preferences["locale"]);
self.builder.get_object("languages").set_active_id(self.preferences["locale"])
self.builder.get_object("languages").connect("changed", self.on_languages_changed)
# Make translation
@ -95,7 +96,7 @@ class ManjaroHello():
if os.path.isfile("/usr/bin/cli-installer"):
self.builder.get_object("installcli").set_visible(True)
self.window.show();
self.window.show()
def get_best_locale(self):
"""Choose best locale, based on user's preferences.
@ -107,7 +108,7 @@ class ManjaroHello():
else:
# If user's locale is supported
if self.sys_locale in self.locales:
return self.sys_locale
return self.sys_locale
# If two first letters of user's locale is supported (ex: en_US -> en)
elif self.sys_locale[:2] in self.locales:
return self.sys_locale[:2]
@ -236,6 +237,7 @@ class ManjaroHello():
self.save_preferences()
Gtk.main_quit(*args)
def get_infos():
"""Get informations about user's system.
:return: informations about user's system
@ -249,6 +251,7 @@ def get_infos():
infos["live"] = os.path.exists("/bootmnt/manjaro") or os.path.exists("/run/miso/bootmnt/manjaro")
return infos
def get_lsb_infos():
"""Read informations from the lsb-release file.
:return: args from lsb-release file
@ -270,6 +273,7 @@ def get_lsb_infos():
print(e)
return lsb
def read_json(path):
try:
with open(path, "r") as f:
@ -277,6 +281,7 @@ def read_json(path):
except OSError as e:
return None
if __name__ == "__main__":
ManjaroHello()
Gtk.main()

View File

@ -2,13 +2,14 @@ import unittest
from src import manjaro_hello
class ManjaroHello(unittest.TestCase):
def setUp(self):
self.path = "test/"
def test_read_json(self):
json = manjaro_hello.read_json(self.path + "test.json")
self.assertEqual(json, {"test":"json"})
self.assertEqual(json, {"test": "json"})
json = manjaro_hello.read_json(self.path + "test")
self.assertEqual(json, None)