diff --git a/soitool/coder.py b/soitool/coder.py index da8d36164d1a991be10bafe8f77ad9b12e3521fd..7caf2581a96a18868593c37820a370bb6ab5bc4b 100644 --- a/soitool/coder.py +++ b/soitool/coder.py @@ -109,38 +109,23 @@ def get_code_length_needed(number_of_entries): def insert_spaces(code, interval): - """Add spaces between code-character each interval. + """Insert space after every x'th character, x = interval. Parameters ---------- code : string - Code to add spaces to. + String to add spaces to. interval : int Interval for inserting spaces. Returns ------- string - Code separated with spaces. + code separated with spaces. """ - # Choose starting point for separating code with spaces, depending on - # SEPARATE_INTERVAL and CODE_LENGTH being even or odd numbers. - # If code is 1234567 and interval is 3, code will be 1234 567 instead - # of 123 456 7 after space separation. - code_length = len(code) - if ( - interval % 2 == 0 - and code_length % 2 == 0 - or interval % 2 != 0 - and code_length % 2 != 0 - ): - start = interval - 1 - else: - start = interval - - # Convert to list to add spaces in-between characters + # Convert to list to insert spaces between characters code = list(code) - for i in range(start, code_length - interval, interval): + for i in range(interval - 1, len(code), interval): code[i] += " " return "".join(code) diff --git a/soitool/modules/module_authentification_board.py b/soitool/modules/module_authentication_board.py similarity index 97% rename from soitool/modules/module_authentification_board.py rename to soitool/modules/module_authentication_board.py index e3fabaa3e4bed49e17dfca70ba7c1888e64b545b..450630d1491a5e20a58b42cf78f9c9afbf4806b2 100644 --- a/soitool/modules/module_authentification_board.py +++ b/soitool/modules/module_authentication_board.py @@ -12,23 +12,22 @@ from soitool.modules.module_base import ( ) START_NO_OF_AUTHENTICATION_CODES = 10 -CODE_LENGTH = 26 +CODE_LENGTH = 25 CODE_CHARACTERS = "ascii" # Has to be 'ascii', 'digits' or 'combo' # Codes will consist of A-Z if 'ascii', 0-9 if 'digits' and A-Z+0-9 if 'combo'. ROW_IDENTIFIERS = string.ascii_uppercase # Characters for first column, # it's length determines maximum number of codes (rows). SPACE_INTERVAL = 5 # Adds space between sets of characters, 0 => no spaces # If code is 123456 and interval is 2, code will be 12 34 56 -# If code is 1234567 and interval is 2, code will be 123 45 67 -HEADLINE_TEXT = "Autentifiseringstavle" +HEADLINE_TEXT = "Autentiseringstavle" class Meta(type(ModuleBase), type(QTableWidget)): """Used as a metaclass to enable multiple inheritance.""" -class AuthentificationBoardModule(ModuleBase, QTableWidget, metaclass=Meta): +class AuthenticationBoardModule(ModuleBase, QTableWidget, metaclass=Meta): """Modified QTableWidget representing a 'Autentifiseringstavle'. By default, the widget initializes with a headline, a row-count of @@ -171,7 +170,7 @@ class AuthentificationBoardModule(ModuleBase, QTableWidget, metaclass=Meta): ): self.remove_row() else: - super(AuthentificationBoardModule, self).keyPressEvent(event) + super(AuthenticationBoardModule, self).keyPressEvent(event) def add_row(self): """Insert row below the selected row and add data.""" @@ -265,7 +264,7 @@ class AuthentificationBoardModule(ModuleBase, QTableWidget, metaclass=Meta): @staticmethod def get_user_friendly_name(): """Get user-friendly name of module.""" - return "Autentifiseringstavle" + return "Autentiseringstavle" @staticmethod def get_icon(): diff --git a/soitool/new_module_dialog.py b/soitool/new_module_dialog.py index 29f94eb1d90906e09ef4e865d3f6ebd82003d4e1..2fd3501b3b27c606dac34482280c70d95d975138 100644 --- a/soitool/new_module_dialog.py +++ b/soitool/new_module_dialog.py @@ -13,8 +13,8 @@ from PySide2.QtWidgets import ( ) from PySide2.QtCore import QSize, Qt from soitool.modules.module_table import TableModule -from soitool.modules.module_authentification_board import ( - AuthentificationBoardModule, +from soitool.modules.module_authentication_board import ( + AuthenticationBoardModule, ) @@ -23,7 +23,7 @@ from soitool.modules.module_authentification_board import ( # placed here, and the rest of the program will respect them. MODULE_CHOICES = [ TableModule, - AuthentificationBoardModule, + AuthenticationBoardModule, ] diff --git a/soitool/serialize_export_import_soi.py b/soitool/serialize_export_import_soi.py index 07ce5cd0b9065b42374f2079e46a501da7d7b6f5..a5c1dc80224023b4c042fa1343507e7bc955cf0a 100644 --- a/soitool/serialize_export_import_soi.py +++ b/soitool/serialize_export_import_soi.py @@ -5,8 +5,8 @@ from schema import Schema, And, Or from soitool.soi import SOI from soitool.compressor import compress, decompress from soitool.modules.module_table import TableModule -from soitool.modules.module_authentification_board import ( - AuthentificationBoardModule, +from soitool.modules.module_authentication_board import ( + AuthenticationBoardModule, ) # Valid schema for serialized SOI @@ -226,7 +226,7 @@ def import_soi(file_path): data = module["data"] modules.append( { - "widget": AuthentificationBoardModule(size, data), + "widget": AuthenticationBoardModule(size, data), "meta": module["meta"], } ) diff --git a/test/test_module_authentification_board.py b/test/test_module_authentication_board.py similarity index 90% rename from test/test_module_authentification_board.py rename to test/test_module_authentication_board.py index 9ef4b5f4e5b5cafef22920a37ff93456cf048f0a..d5f5869433a0dfe8c7ca36f467cee19e4a22c32a 100644 --- a/test/test_module_authentification_board.py +++ b/test/test_module_authentication_board.py @@ -1,11 +1,11 @@ -"""Test AuthentificationBoardModule.""" +"""Test AuthenticationBoardModule.""" import unittest from PySide2 import QtGui from PySide2.QtWidgets import QApplication from PySide2.QtCore import Qt from PySide2.QtTest import QTest -from soitool.modules.module_authentification_board import ( - AuthentificationBoardModule, +from soitool.modules.module_authentication_board import ( + AuthenticationBoardModule, START_NO_OF_AUTHENTICATION_CODES, HEADLINE_TEXT, ROW_IDENTIFIERS, @@ -19,12 +19,12 @@ else: app = QtGui.qApp -class TestDefaultAuthentificationBoardModule(unittest.TestCase): - """TestCase for AuthentificationBoardModule.""" +class TestDefaultAuthenticationBoardModule(unittest.TestCase): + """TestCase for AuthenticationBoardModule.""" def setUp(self): - """Create new AuthentificationBoardModule.""" - self.module = AuthentificationBoardModule() + """Create new AuthenticationBoardModule.""" + self.module = AuthenticationBoardModule() def test_default_module(self): """Test that module is initialized properly.""" @@ -148,11 +148,11 @@ class TestDefaultAuthentificationBoardModule(unittest.TestCase): self.assertTrue(soi.module_name_taken(module_name)) -class TestAuthentificationBoardModuleFromData(unittest.TestCase): - """TestCase for initializing AuthentificationBoardModule from data.""" +class TestAuthenticationBoardModuleFromData(unittest.TestCase): + """TestCase for initializing AuthenticationBoardModule from data.""" def test_create_from_data(self): - """Test creating AuthentificationBoardModule from data.""" + """Test creating AuthenticationBoardModule from data.""" test_data = [ "Headline text", ["A", "0", "TEST CODE ONE"], @@ -160,7 +160,7 @@ class TestAuthentificationBoardModuleFromData(unittest.TestCase): ] test_size = {"width": 100, "height": 100} - module = AuthentificationBoardModule(size=test_size, data=test_data) + module = AuthenticationBoardModule(size=test_size, data=test_data) # Assert module contains expected data self.assertEqual(module.item(0, 0).text(), "Headline text")