diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-12-01 01:32:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-12-01 01:32:04 +0300 |
commit | 33c444f9651d8b726b6203c36051db21c24829b1 (patch) | |
tree | 0c12ae743265758e69eef09cb68b58d0b1baf16a /release/scripts/modules/bpy | |
parent | 168fe0b4b53b048fa7c125f46112f53670610bd4 (diff) |
User Script support added back.
- the scripts path set in the user preferences or ~/.blender/scripts/ui (io, op, io etc..) will be used to load scripts.
- the default home dir part probably only works in *nix os's
- Added a missing sync callback to vector.toTuple()
Diffstat (limited to 'release/scripts/modules/bpy')
-rw-r--r-- | release/scripts/modules/bpy/__init__.py | 29 | ||||
-rw-r--r-- | release/scripts/modules/bpy/utils.py | 18 |
2 files changed, 31 insertions, 16 deletions
diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py index 39b8fd340ba..0df11659336 100644 --- a/release/scripts/modules/bpy/__init__.py +++ b/release/scripts/modules/bpy/__init__.py @@ -46,20 +46,21 @@ def load_scripts(reload_scripts=False): for base_path in utils.script_paths(): for path_subdir in ("ui", "op", "io"): path = os.path.join(base_path, path_subdir) - sys.path.insert(0, path) - for f in sorted(os.listdir(path)): - if f.endswith(".py"): - # python module - mod = test_import(f[0:-3]) - elif "." not in f: - # python package - mod = test_import(f) - else: - mod = None - - if reload_scripts and mod: - print("Reloading:", mod) - reload(mod) + if os.path.isdir(path): + sys.path.insert(0, path) + for f in sorted(os.listdir(path)): + if f.endswith(".py"): + # python module + mod = test_import(f[0:-3]) + elif "." not in f: + # python package + mod = test_import(f) + else: + mod = None + + if reload_scripts and mod: + print("Reloading:", mod) + reload(mod) def _main(): diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index a10c8bc4dd9..3af163e1069 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -57,12 +57,26 @@ _scripts = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardi _scripts = (os.path.normpath(_scripts), ) def script_paths(*args): + scripts = list(_scripts) + + # add user scripts dir + user_script_path = bpy.context.user_preferences.filepaths.python_scripts_directory + + if not user_script_path: + # XXX - WIN32 needs checking, perhaps better call a blender internal function. + user_script_path = os.path.join(os.path.expanduser("~"), ".blender", "scripts") + + user_script_path = os.path.normpath(user_script_path) + + if user_script_path not in scripts and os.path.isdir(user_script_path): + scripts.append(user_script_path) + if not args: - return _scripts + return scripts subdir = os.path.join(*args) script_paths = [] - for path in _scripts: + for path in scripts: script_paths.append(os.path.join(path, subdir)) return script_paths |