From 5ba5a6b59e692a89e01ef12bd86b3adeca4f7e89 Mon Sep 17 00:00:00 2001 From: Johnathan Jenkins Date: Wed, 21 Dec 2016 06:35:54 -0800 Subject: [PATCH] minor pep8 and spelling --- README.md | 2 +- src/manjaro_hello.py | 13 +++++++++---- test/test.py | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fa59063..5825422 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/src/manjaro_hello.py b/src/manjaro_hello.py index 3e57bb9..2a410f5 100644 --- a/src/manjaro_hello.py +++ b/src/manjaro_hello.py @@ -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() diff --git a/test/test.py b/test/test.py index 4fd6e36..c332866 100644 --- a/test/test.py +++ b/test/test.py @@ -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)