File tree Expand file tree Collapse file tree 5 files changed +22
-84
lines changed Expand file tree Collapse file tree 5 files changed +22
-84
lines changed Original file line number Diff line number Diff line change 1- import functools
2-
31from demosys .core import finders
42from demosys .conf import settings
5- from demosys .core .exceptions import ImproperlyConfigured
6- from demosys .utils .module_loading import import_string
73
84
95class FileSystemFinder (finders .BaseFileSystemFinder ):
@@ -18,20 +14,4 @@ class EffectDirectoriesFinder(finders.BaseEffectDirectoriesFinder):
1814
1915def get_finders ():
2016 for finder in settings .DATA_FINDERS :
21- yield get_finder (finder )
22-
23-
24- @functools .lru_cache (maxsize = None )
25- def get_finder (import_path ):
26- """
27- Get a finder class from an import path.
28- Raises ``demosys.core.exceptions.ImproperlyConfigured`` if the finder is not found.
29- This function uses an lru cache.
30-
31- :param import_path: string representing an import path
32- :return: An instance of the finder
33- """
34- Finder = import_string (import_path )
35- if not issubclass (Finder , finders .BaseFileSystemFinder ):
36- raise ImproperlyConfigured ('Finder {} is not a subclass of core.finders.FileSystemFinder' .format (import_path ))
37- return Finder ()
17+ yield finders .get_finder (finder )
Original file line number Diff line number Diff line change 11"""
22Base finders
33"""
4+ import functools
45from collections import namedtuple
56from pathlib import Path
67
78from demosys .conf import settings
89from demosys .core .exceptions import ImproperlyConfigured
10+ from demosys .utils .module_loading import import_string
911
1012FinderEntry = namedtuple ('FinderEntry' , ['path' , 'abspath' , 'exists' ])
1113
@@ -57,3 +59,19 @@ def __init__(self):
5759 def find (self , path : Path ):
5860 path = Path (self .directory ) / Path (path )
5961 return super ().find (path )
62+
63+
64+ @functools .lru_cache (maxsize = None )
65+ def get_finder (import_path ):
66+ """
67+ Get a finder class from an import path.
68+ Raises ``demosys.core.exceptions.ImproperlyConfigured`` if the finder is not found.
69+ This function uses an lru cache.
70+
71+ :param import_path: string representing an import path
72+ :return: An instance of the finder
73+ """
74+ Finder = import_string (import_path )
75+ if not issubclass (Finder , BaseFileSystemFinder ):
76+ raise ImproperlyConfigured ('Finder {} is not a subclass of core.finders.FileSystemFinder' .format (import_path ))
77+ return Finder ()
Original file line number Diff line number Diff line change 1- import functools
2-
31from demosys .core import finders
42from demosys .conf import settings
5- from demosys .core .exceptions import ImproperlyConfigured
6- from demosys .utils .module_loading import import_string
73
84
95class FileSystemFinder (finders .BaseFileSystemFinder ):
@@ -18,20 +14,4 @@ class EffectDirectoriesFinder(finders.BaseEffectDirectoriesFinder):
1814
1915def get_finders ():
2016 for finder in settings .SCENE_FINDERS :
21- yield get_finder (finder )
22-
23-
24- @functools .lru_cache (maxsize = None )
25- def get_finder (import_path ):
26- """
27- Get a finder class from an import path.
28- Raises ``demosys.core.exceptions.ImproperlyConfigured`` if the finder is not found.
29- This function uses an lru cache.
30-
31- :param import_path: string representing an import path
32- :return: An instance of the finder
33- """
34- Finder = import_string (import_path )
35- if not issubclass (Finder , finders .BaseFileSystemFinder ):
36- raise ImproperlyConfigured ('Finder {} is not a subclass of core.finders.FileSystemFinder' .format (import_path ))
37- return Finder ()
17+ yield finders .get_finder (finder )
Original file line number Diff line number Diff line change 1- import functools
2-
31from demosys .core import finders
42from demosys .conf import settings
5- from demosys .core .exceptions import ImproperlyConfigured
6- from demosys .utils .module_loading import import_string
73
84
95class FileSystemFinder (finders .BaseFileSystemFinder ):
@@ -18,20 +14,4 @@ class EffectDirectoriesFinder(finders.BaseEffectDirectoriesFinder):
1814
1915def get_finders ():
2016 for finder in settings .SHADER_FINDERS :
21- yield get_finder (finder )
22-
23-
24- @functools .lru_cache (maxsize = None )
25- def get_finder (import_path ):
26- """
27- Get a finder class from an import path.
28- Raises ``demosys.core.exceptions.ImproperlyConfigured`` if the finder is not found.
29- This function uses an lru cache.
30-
31- :param import_path: string representing an import path
32- :return: An instance of the finder
33- """
34- Finder = import_string (import_path )
35- if not issubclass (Finder , finders .BaseFileSystemFinder ):
36- raise ImproperlyConfigured ('Finder {} is not a subclass of core.finders.FileSystemFinder' .format (import_path ))
37- return Finder ()
17+ yield finders .get_finder (finder )
Original file line number Diff line number Diff line change 1- import functools
2-
31from demosys .core import finders
42from demosys .conf import settings
5- from demosys .core .exceptions import ImproperlyConfigured
6- from demosys .utils .module_loading import import_string
73
84
95class FileSystemFinder (finders .BaseFileSystemFinder ):
@@ -18,20 +14,4 @@ class EffectDirectoriesFinder(finders.BaseEffectDirectoriesFinder):
1814
1915def get_finders ():
2016 for finder in settings .TEXTURE_FINDERS :
21- yield get_finder (finder )
22-
23-
24- @functools .lru_cache (maxsize = None )
25- def get_finder (import_path ):
26- """
27- Get a finder class from an import path.
28- Raises ``demosys.core.exceptions.ImproperlyConfigured`` if the finder is not found.
29- This function uses an lru cache.
30-
31- :param import_path: string representing an import path
32- :return: An instance of the finder
33- """
34- Finder = import_string (import_path )
35- if not issubclass (Finder , finders .BaseFileSystemFinder ):
36- raise ImproperlyConfigured ('Finder {} is not a subclass of core.finders.FileSystemFinder' .format (import_path ))
37- return Finder ()
17+ yield finders .get_finder (finder )
You can’t perform that action at this time.
0 commit comments