forked from Project-StudioQ/animation_shift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
46 lines (33 loc) · 1.47 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
This file is part of Animation Offset Shift.
Copyright (C) 2021 Project Studio Q inc.
Animation Offset Shift is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
import importlib
import os
def get_funcs(func_name):
this_path = os.path.dirname(__file__)
module_list = [f for f in os.listdir(this_path) if (f.endswith(".py")) and (f != "__init__.py")]
path_list = ["." + os.path.splitext(f)[0] for f in module_list]
functions = []
for path in path_list:
module = importlib.import_module(path, package=__package__)
if hasattr(module, func_name):
functions += [getattr(module, func_name)]
return functions
def register_package():
for func in get_funcs("register"):
func()
def unregister_package():
for func in get_funcs("unregister"):
func()