Just a few things
parent
d3d4380466
commit
6e7b4c506f
|
@ -13,6 +13,8 @@ from gi.repository import Gtk, GdkPixbuf
|
||||||
|
|
||||||
|
|
||||||
class ManjaroHello():
|
class ManjaroHello():
|
||||||
|
"""Manjaro-Hello"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# App vars
|
# App vars
|
||||||
self.app = "manjaro-hello"
|
self.app = "manjaro-hello"
|
||||||
|
@ -202,16 +204,16 @@ class ManjaroHello():
|
||||||
f.write(content.replace(i3_autostart, "#" + i3_autostart))
|
f.write(content.replace(i3_autostart, "#" + i3_autostart))
|
||||||
f.truncate()
|
f.truncate()
|
||||||
self.autostart = autostart
|
self.autostart = autostart
|
||||||
except OSError as e:
|
except OSError as error:
|
||||||
print(e)
|
print(error)
|
||||||
|
|
||||||
def save_preferences(self):
|
def save_preferences(self):
|
||||||
"""Save preferences in config file."""
|
"""Save preferences in config file."""
|
||||||
try:
|
try:
|
||||||
with open(self.preferences_path, "w") as f:
|
with open(self.preferences_path, "w") as f:
|
||||||
json.dump(self.preferences, f)
|
json.dump(self.preferences, f)
|
||||||
except OSError as e:
|
except OSError as error:
|
||||||
print(e)
|
print(error)
|
||||||
|
|
||||||
def get_preferences(self):
|
def get_preferences(self):
|
||||||
"""Read preferences from config file."""
|
"""Read preferences from config file."""
|
||||||
|
@ -300,12 +302,16 @@ def get_lsb_infos():
|
||||||
arg = arg[1:-1]
|
arg = arg[1:-1]
|
||||||
if arg:
|
if arg:
|
||||||
lsb[var] = arg
|
lsb[var] = arg
|
||||||
except OSError as e:
|
except OSError as error:
|
||||||
print(e)
|
print(error)
|
||||||
return lsb
|
return lsb
|
||||||
|
|
||||||
|
|
||||||
def read_json(path):
|
def read_json(path):
|
||||||
|
"""Read content of a json file.
|
||||||
|
:return: json content
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
with open(path, "r") as f:
|
with open(path, "r") as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"test": "json"
|
|
||||||
}
|
|
17
test/test.py
17
test/test.py
|
@ -1,17 +0,0 @@
|
||||||
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"})
|
|
||||||
json = manjaro_hello.read_json(self.path + "test")
|
|
||||||
self.assertEqual(json, None)
|
|
||||||
|
|
||||||
def test_get_lsb_infos(self):
|
|
||||||
self.assertIsInstance(manjaro_hello.get_lsb_infos(), dict)
|
|
Loading…
Reference in New Issue