From ea0fea7855b70665b1b155f1d20495e88096b73a Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 11 May 2014 18:38:51 +0200 Subject: [PATCH] Turn resources into a module, which can hold mutators too --- naja/resources/__init__.py | 3 +++ naja/{resources.py => resources/loader.py} | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 naja/resources/__init__.py rename naja/{resources.py => resources/loader.py} (96%) diff --git a/naja/resources/__init__.py b/naja/resources/__init__.py new file mode 100644 index 0000000..191cbd4 --- /dev/null +++ b/naja/resources/__init__.py @@ -0,0 +1,3 @@ +from naja.resources.loader import Loader + +resources = Loader('data') diff --git a/naja/resources.py b/naja/resources/loader.py similarity index 96% rename from naja/resources.py rename to naja/resources/loader.py index 00ebe1c..28a3c7a 100644 --- a/naja/resources.py +++ b/naja/resources/loader.py @@ -9,7 +9,8 @@ except ImportError: def resource_filename(mod, path): # There are better ways of doing this, but I've spent too much # time going down this rabbithole already - return os.path.join(os.path.dirname(__file__), '..', 'data', path) + return os.path.join(os.path.dirname(__file__), '..', '..', 'data', + path) import pygame @@ -17,7 +18,7 @@ class ResourceNotFound(Exception): pass -class Resources(object): +class Loader(object): CONVERT_ALPHA = True def __init__(self, resource_module, language=None): @@ -98,6 +99,3 @@ class Resources(object): self._cache[key] = pygame.font.Font(fn, font_size) return self._cache[key] - - -resources = Resources('data') -- 2.34.1