From db2d122211d14ead052c3e7cfed3aa2c6eaa767e Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 26 Dec 2021 13:16:07 -0500 Subject: [PATCH] lib: Replace version.DEBUG with the __debug__ constant Implements #27 (Check __debug__ constant instead of a .debug file) Signed-off-by: Anna Schumaker --- data/emmental | 2 +- lib/data.py | 2 +- lib/test_version.py | 2 +- lib/version.py | 10 +--------- ui/icons.py | 3 +-- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/data/emmental b/data/emmental index dd8d154..55ee16c 100644 --- a/data/emmental +++ b/data/emmental @@ -1,3 +1,3 @@ #!/bin/bash -python {EMMENTAL_LIB}/emmental.py $* +python -O {EMMENTAL_LIB}/emmental.py $* diff --git a/lib/data.py b/lib/data.py index 35ca279..4dfeee2 100644 --- a/lib/data.py +++ b/lib/data.py @@ -7,7 +7,7 @@ import xdg.BaseDirectory __resource = "emmental" if version.TESTING == True: __resource = "emmental-testing" -elif version.DEBUG == True: +elif __debug__ == True: __resource = "emmental-debug" READ = 'rb' diff --git a/lib/test_version.py b/lib/test_version.py index df9f40f..38673f3 100644 --- a/lib/test_version.py +++ b/lib/test_version.py @@ -7,7 +7,7 @@ class TestVersion(unittest.TestCase): self.assertEqual(version.MAJOR, 2) self.assertEqual(version.MINOR, 9) - self.assertTrue(version.DEBUG) + self.assertTrue(__debug__) self.assertTrue(version.TESTING) self.assertEqual(version.string(), "Emmental 2.9-debug") diff --git a/lib/version.py b/lib/version.py index 0edd1b3..d83a3d7 100644 --- a/lib/version.py +++ b/lib/version.py @@ -4,15 +4,7 @@ import sys MAJOR = 2 MINOR = 9 - -DEBUG = False -if os.path.exists(".debug"): - with open(".debug") as f: - if f.read().strip() == "emmental": - DEBUG = True - TESTING = "unittest" in sys.modules - def string(): - return f"Emmental {MAJOR}.{MINOR}{'-debug' if DEBUG else ''}" + return f"Emmental {MAJOR}.{MINOR}{'-debug' if __debug__ else ''}" diff --git a/ui/icons.py b/ui/icons.py index 74bb7b6..6b186e8 100644 --- a/ui/icons.py +++ b/ui/icons.py @@ -1,12 +1,11 @@ # Copyright 2021 (c) Anna Schumaker. from . import window -from lib import version from gi.repository import Gtk import pathlib IconPath = pathlib.Path("data/").absolute() -if version.DEBUG == True: +if __debug__ == True: Display = Gtk.Label().get_display() Theme = Gtk.IconTheme.get_for_display(Display)