Skip to content

Commit 0fd7f6c

Browse files
committed
Generic parse_package_string function
1 parent 8f930be commit 0fd7f6c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

demosys/effects/registry.py

+28
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,34 @@
66
from demosys.effects.effect import Effect
77

88

9+
def parse_package_string(path):
10+
"""
11+
Parse the effect package string.
12+
Can contain the package python path or path to effect class in an effect package.
13+
14+
Examples::
15+
16+
# Path to effect pacakge
17+
examples.cubes
18+
19+
# Path to effect class
20+
examples.cubes.Cubes
21+
22+
Args:
23+
path: python path to effect package. May also include effect class name.
24+
25+
Returns:
26+
tuple: (package_path, effect_class)
27+
"""
28+
parts = path.split('.')
29+
30+
# Is the last entry in the path capitalized?
31+
if parts[-1][0].isupper():
32+
return ".".join(parts[:-1]), parts[-1]
33+
34+
return path
35+
36+
937
class EffectRegistry:
1038
"""
1139
Registry for effects classes (not instances).

0 commit comments

Comments
 (0)