Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Vegdahl <cessen@cessen.com>2010-11-17 10:03:00 +0300
committerNathan Vegdahl <cessen@cessen.com>2010-11-17 10:03:00 +0300
commite501ab49f8e772e037d7ed40bb39ea2df2d97ddd (patch)
treea55af07f638add6eaa95ecd477c3fe0ac2e376ec /rigify/__init__.py
parent471be493e60fd1562fa2d8147a09fd22efdafef3 (diff)
Rigify patch from Campbell, to clean up some of the code.
Diffstat (limited to 'rigify/__init__.py')
-rw-r--r--rigify/__init__.py38
1 files changed, 19 insertions, 19 deletions
diff --git a/rigify/__init__.py b/rigify/__init__.py
index 0609b709..1cbad51a 100644
--- a/rigify/__init__.py
+++ b/rigify/__init__.py
@@ -27,45 +27,45 @@ bl_addon_info = {
"tracker_url": "",
"category": "Rigging"}
-import bpy
-import bpy_types
-import os
-from imp import reload
-
-
-try:
+if "bpy" in locals():
reload(generate)
reload(ui)
reload(utils)
reload(metarig_menu)
-except NameError:
+else:
from rigify import generate, ui, utils, metarig_menu
+import bpy
+import bpy_types
+import os
+
def get_rig_list(path):
""" Recursively searches for rig types, and returns a list.
"""
rigs = []
- files = os.listdir(os.path.dirname(__file__) + "/" + utils.RIG_DIR + "/" + path)
- files = sorted(files)
+ MODULE_DIR = os.path.dirname(__file__)
+ RIG_DIR_ABS = os.path.join(MODULE_DIR, utils.RIG_DIR)
+ SEARCH_DIR_ABS = os.path.join(RIG_DIR_ABS, path)
+ path_strip = path.strip(os.sep)
+ files = os.listdir(SEARCH_DIR_ABS)
+ files.sort()
for f in files:
- if not f.startswith("_"):
- if os.path.isdir(os.path.dirname(__file__) + "/" + utils.RIG_DIR + "/" + path + f):
+ if not f.startswith("_") and not f.startswith("."):
+ f_abs = os.path.join(SEARCH_DIR_ABS, f)
+ if os.path.isdir(f_abs):
# Check directories
try:
- rig = utils.get_rig_type((path + f).replace("/", "."))
+ rig = utils.get_rig_type(os.path.join(path_strip, f).replace(os.sep, "."))
except ImportError as e:
print("Rigify: " + str(e))
else:
# Check if it's a rig itself
- try:
- rig.Rig
- except AttributeError:
+ if not hasattr(rig, "Rig"):
# Check for sub-rigs
- ls = get_rig_list(path + f + "/")
- for l in ls:
- rigs += [f + '.' + l]
+ ls = get_rig_list(os.path.join(path, f, "")) # "" adds a final slash
+ rigs.extend(["%s.%s" % (f, l) for l in ls])
else:
rigs += [f]