lib: Replace version.DEBUG with the __debug__ constant

Implements #27 (Check __debug__ constant instead of a .debug file)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-12-26 13:16:07 -05:00
parent 10c5fd4cef
commit db2d122211
5 changed files with 5 additions and 14 deletions

View File

@ -1,3 +1,3 @@
#!/bin/bash
python {EMMENTAL_LIB}/emmental.py $*
python -O {EMMENTAL_LIB}/emmental.py $*

View File

@ -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'

View File

@ -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")

View File

@ -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 ''}"

View File

@ -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)