diff --git a/bin/pyqso b/bin/pyqso index d253ff6..e758167 100755 --- a/bin/pyqso +++ b/bin/pyqso @@ -62,10 +62,10 @@ class PyQSO: # Get the PyQSO main window defined in the Glade file. self.builder = Gtk.Builder() try: - glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join(os.pardir, "res", "pyqso.glade")) + glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join("res", "pyqso.glade")) except ImportError: # Assume the resources directory is in the parent directory of the directory containing this file. - glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade") + glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "pyqso", "res", "pyqso.glade") self.builder.add_from_file(glade_file_path) self.window = self.builder.get_object("pyqso") @@ -133,10 +133,10 @@ class PyQSO: # Get the About dialog defined in the Glade file. try: - glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join(os.pardir, "res", "pyqso.glade")) + glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join("res", "pyqso.glade")) except ImportError: # Assume the resources directory is in the parent directory of the directory containing this file. - glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade") + glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "pyqso", "res", "pyqso.glade") self.builder.add_objects_from_file(glade_file_path, ("about_dialog",)) about = self.builder.get_object("about_dialog") diff --git a/pyqso/cabrillo_export_dialog.py b/pyqso/cabrillo_export_dialog.py index 52214af..38c0aac 100644 --- a/pyqso/cabrillo_export_dialog.py +++ b/pyqso/cabrillo_export_dialog.py @@ -35,7 +35,7 @@ class CabrilloExportDialog: logging.debug("Building new Cabrillo export dialog...") self.builder = application.builder - glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade") + glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade") self.builder.add_objects_from_file(glade_file_path, ("cabrillo_export_dialog",)) self.dialog = self.builder.get_object("cabrillo_export_dialog") diff --git a/pyqso/calendar_dialog.py b/pyqso/calendar_dialog.py index f02a46a..40159e7 100644 --- a/pyqso/calendar_dialog.py +++ b/pyqso/calendar_dialog.py @@ -32,7 +32,7 @@ class CalendarDialog: """ self.builder = application.builder - glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade") + glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade") self.builder.add_objects_from_file(glade_file_path, ("calendar_dialog",)) self.dialog = self.builder.get_object("calendar_dialog") self.calendar = self.builder.get_object("calendar") diff --git a/pyqso/log_name_dialog.py b/pyqso/log_name_dialog.py index 45d0e0e..dbd00eb 100644 --- a/pyqso/log_name_dialog.py +++ b/pyqso/log_name_dialog.py @@ -36,7 +36,7 @@ class LogNameDialog: logging.debug("Building new log name dialog...") self.builder = application.builder - glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade") + glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade") self.builder.add_objects_from_file(glade_file_path, ("log_name_dialog",)) self.dialog = self.builder.get_object("log_name_dialog") diff --git a/pyqso/preferences_dialog.py b/pyqso/preferences_dialog.py index 35f4c04..ba3762b 100644 --- a/pyqso/preferences_dialog.py +++ b/pyqso/preferences_dialog.py @@ -58,7 +58,7 @@ class PreferencesDialog: self.application = application self.builder = self.application.builder - glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade") + glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade") self.builder.add_objects_from_file(glade_file_path, ("preferences_dialog",)) self.dialog = self.builder.get_object("preferences_dialog") diff --git a/pyqso/record_dialog.py b/pyqso/record_dialog.py index 9081233..1d925be 100644 --- a/pyqso/record_dialog.py +++ b/pyqso/record_dialog.py @@ -56,7 +56,7 @@ class RecordDialog: self.application = application self.builder = self.application.builder - glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade") + glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade") self.builder.add_objects_from_file(glade_file_path, ("record_dialog",)) self.dialog = self.builder.get_object("record_dialog") self.builder.get_object("record_dialog").connect("key-press-event", self.on_key_press) diff --git a/res/log_1024x1024.xcf b/pyqso/res/log_1024x1024.xcf similarity index 100% rename from res/log_1024x1024.xcf rename to pyqso/res/log_1024x1024.xcf diff --git a/res/log_14x14.png b/pyqso/res/log_14x14.png similarity index 100% rename from res/log_14x14.png rename to pyqso/res/log_14x14.png diff --git a/res/log_192x192.png b/pyqso/res/log_192x192.png similarity index 100% rename from res/log_192x192.png rename to pyqso/res/log_192x192.png diff --git a/res/log_64x64.png b/pyqso/res/log_64x64.png similarity index 100% rename from res/log_64x64.png rename to pyqso/res/log_64x64.png diff --git a/res/pyqso.glade b/pyqso/res/pyqso.glade similarity index 100% rename from res/pyqso.glade rename to pyqso/res/pyqso.glade diff --git a/pyqso/summary.py b/pyqso/summary.py index 61ca6cf..4ed3f85 100644 --- a/pyqso/summary.py +++ b/pyqso/summary.py @@ -19,7 +19,6 @@ from gi.repository import Gtk import logging -from os import pardir from os.path import basename, getmtime, expanduser, dirname, join, realpath from datetime import datetime, date try: @@ -51,7 +50,7 @@ class Summary(object): self.application = application self.logbook = self.application.logbook self.builder = self.application.builder - glade_file_path = join(realpath(dirname(__file__)), pardir, "res", "pyqso.glade") + glade_file_path = join(realpath(dirname(__file__)), "res", "pyqso.glade") self.builder.add_objects_from_file(glade_file_path, ("summary_page",)) self.summary_page = self.builder.get_object("summary_page") diff --git a/pyqso/telnet_connection_dialog.py b/pyqso/telnet_connection_dialog.py index 00fba14..4105dec 100644 --- a/pyqso/telnet_connection_dialog.py +++ b/pyqso/telnet_connection_dialog.py @@ -31,7 +31,7 @@ class TelnetConnectionDialog: """ self.builder = application.builder - glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade") + glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade") self.builder.add_objects_from_file(glade_file_path, ("telnet_connection_dialog",)) self.dialog = self.builder.get_object("telnet_connection_dialog") self.sources = {"HOST": self.builder.get_object("host_entry"), diff --git a/setup.py b/setup.py index b7a2c8e..c373e55 100644 --- a/setup.py +++ b/setup.py @@ -35,7 +35,7 @@ setup(name="PyQSO", ], packages=["pyqso"], package_dir={"pyqso": "pyqso"}, - package_data={"pyqso": ["../res/pyqso.glade", "../res/log_64x64.png"]}, + package_data={"pyqso": ["res/pyqso.glade", "res/log_64x64.png"]}, scripts=["bin/pyqso"], zip_safe=False ) diff --git a/res/invalid.db b/tests/res/invalid.db similarity index 100% rename from res/invalid.db rename to tests/res/invalid.db diff --git a/res/test.db b/tests/res/test.db similarity index 100% rename from res/test.db rename to tests/res/test.db diff --git a/tests/test_adif.py b/tests/test_adif.py index e007ac9..16bb826 100644 --- a/tests/test_adif.py +++ b/tests/test_adif.py @@ -163,7 +163,7 @@ class TestADIF(unittest.TestCase): """ Check that records can be written to an ADIF file from a test database file. """ import sqlite3 import os.path - path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db") + path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db") self.connection = sqlite3.connect(path_to_test_database) self.connection.row_factory = sqlite3.Row diff --git a/tests/test_awards.py b/tests/test_awards.py index a7ecf0e..0ff3e07 100644 --- a/tests/test_awards.py +++ b/tests/test_awards.py @@ -36,7 +36,7 @@ class TestAwards(unittest.TestCase): PyQSO = mock.MagicMock() self.awards = Awards(application=PyQSO()) self.logbook = Logbook(application=PyQSO()) - path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db") + path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db") success = self.logbook.db_connect(path_to_test_database) assert(success) self.logbook.logs = self.logbook.get_logs() diff --git a/tests/test_logbook.py b/tests/test_logbook.py index e534cba..14091d8 100644 --- a/tests/test_logbook.py +++ b/tests/test_logbook.py @@ -38,7 +38,7 @@ class TestLogbook(unittest.TestCase): self.logbook = Logbook(application=mock.MagicMock()) # Open the test database file. - path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db") + path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db") opened = self.logbook.open(path=path_to_test_database) assert(opened) assert(self.logbook.connection is not None) @@ -75,7 +75,7 @@ class TestLogbook(unittest.TestCase): def test_open_invalid_logbook(self, mock_handle_gtk_dialog): """ Open an invalid database file (comprising only one line of plain text) and check that an error occurs. """ invalid_logbook = Logbook(application=mock.MagicMock()) - path_to_invalid_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/invalid.db") + path_to_invalid_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "invalid.db") opened = invalid_logbook.open(path=path_to_invalid_database) assert(not opened) assert(not invalid_logbook.logs) @@ -86,7 +86,7 @@ class TestLogbook(unittest.TestCase): def test_new_log(self, mock_LogNameDialog, mock_handle_gtk_dialog, mock_render_log): """ Create an empty logbook file, open it, and check that a new log can successfully be added. """ # Create a copy of the test database just for use in this particular test, since the contents will need to be modified. - path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db") + path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db") destination = "Logbook.test_new_log.db" copyfile(path_to_test_database, destination) opened = self.logbook.open(path=destination) diff --git a/tests/test_summary.py b/tests/test_summary.py index 018d267..ae640c9 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -36,7 +36,7 @@ class TestSummary(unittest.TestCase): PyQSO = mock.MagicMock() self.summary = Summary(application=PyQSO()) self.summary.logbook = Logbook(application=PyQSO()) - path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db") + path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db") success = self.summary.logbook.db_connect(path_to_test_database) assert(success) self.summary.logbook.logs = self.summary.logbook.get_logs()