Adapt pycapi namespace for modules

This commit is contained in:
Fierelier 2023-05-02 04:38:30 +02:00
parent d8c2ce876b
commit f9a7d0793b
7 changed files with 14 additions and 13 deletions

View File

@ -4,5 +4,5 @@ REM Change python whatever
set pyexe=python34\python.exe
REM And now, run all the various tests we have
%pyexe% user\modules\test_myutils.py
%pyexe% user\modules\test_contentapi.py
%pyexe% user\modules\pycapi\test_utils.py
%pyexe% user\modules\pycapi\test_contentapi.py

View File

@ -16,8 +16,9 @@ import win_unicode_console
from collections import OrderedDict
from colorama import Fore, Back, Style, init as colorama_init, ansi as colorama_ansi
import contentapi
import myutils
import app
contentapi = app.loadmod("contentapi")
utils = app.loadmod("utils")
VERSION="0.2.0" # Arbitrary but whatever
CONFIGFILE="config.toml"
@ -281,14 +282,14 @@ def load_or_create_global_config():
# Read and deserialize the config file
with open(CONFIGFILE, 'r', encoding='utf-8') as f:
temp_config = toml.load(f)
myutils.merge_dictionary(temp_config, config)
utils.merge_dictionary(temp_config, config)
else:
# Serialize and write the config dictionary to the config file
logging.warn("No config found at " + CONFIGFILE + ", creating now")
with open(CONFIGFILE, 'w', encoding='utf-8') as f:
toml.dump(config, f)
myutils.set_logging_level(config["default_loglevel"])
utils.set_logging_level(config["default_loglevel"])
# Set the room to listen to on the websocket. Will also update the userlist, if

View File

@ -1,5 +1,5 @@
import unittest
import myutils
import utils
class TestMergeDictionary(unittest.TestCase):
@ -8,7 +8,7 @@ class TestMergeDictionary(unittest.TestCase):
base = {'a': 1, 'b': 2}
new = {'b': 3, 'c': 4}
expected = {'a': 1, 'b': 3, 'c': 4}
myutils.merge_dictionary(new, base)
utils.merge_dictionary(new, base)
self.assertDictEqual(base, expected)
def test_nested(self):
@ -16,7 +16,7 @@ class TestMergeDictionary(unittest.TestCase):
base = {'a': {'b': 1, 'c': 2}, 'd': 3}
new = {'a': {'b': 4, 'e': 5}, 'f': 6}
expected = {'a': {'b': 4, 'c': 2, 'e': 5}, 'd': 3, 'f': 6}
myutils.merge_dictionary(new, base)
utils.merge_dictionary(new, base)
self.assertDictEqual(base, expected)
def test_emptybase(self):
@ -24,7 +24,7 @@ class TestMergeDictionary(unittest.TestCase):
base = {}
new = {'a': 1, 'b': {'c': 2}}
expected = {'a': 1, 'b': {'c': 2}}
myutils.merge_dictionary(new, base)
utils.merge_dictionary(new, base)
self.assertDictEqual(base, expected)
def test_emptynew(self):
@ -32,7 +32,7 @@ class TestMergeDictionary(unittest.TestCase):
base = {'a': 1, 'b': {'c': 2}}
new = {}
expected = {'a': 1, 'b': {'c': 2}}
myutils.merge_dictionary(new, base)
utils.merge_dictionary(new, base)
self.assertDictEqual(base, expected)
def test_nooverlap(self):
@ -40,8 +40,8 @@ class TestMergeDictionary(unittest.TestCase):
base = {'a': 1}
new = {'b': 2}
expected = {'a': 1, 'b': 2}
myutils.merge_dictionary(new, base)
utils.merge_dictionary(new, base)
self.assertDictEqual(base, expected)
if __name__ == '__main__':
unittest.main()
unittest.main()