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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-27 17:08:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-27 17:08:33 +0300
commit87acf919a5023e690e67bfbf3846081a70838bea (patch)
tree0fb9ced9ea30ab68fc4acff43dff91253565643c /release
parent4ab33ae8592ab58425c4ca87e2dd7fc520bc6bbf (diff)
lazy load pydoc module. move help() replacement into console code rather then on startup since importing pydoc pulls in lots of other modules too.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy/__init__.py12
-rw-r--r--release/scripts/op/console_python.py16
2 files changed, 16 insertions, 12 deletions
diff --git a/release/scripts/modules/bpy/__init__.py b/release/scripts/modules/bpy/__init__.py
index 5c636d3a0df..ed7b4baa806 100644
--- a/release/scripts/modules/bpy/__init__.py
+++ b/release/scripts/modules/bpy/__init__.py
@@ -37,18 +37,6 @@ import sys as _sys
def _main():
- ## security issue, dont allow the $CWD in the path.
- ## note: this removes "" but not "." which are the same, security
- ## people need to explain how this is even a fix.
- # _sys.path[:] = filter(None, _sys.path)
-
- # because of how the console works. we need our own help() pager func.
- # replace the bold function because it adds crazy chars
- import pydoc
- pydoc.getpager = lambda: pydoc.plainpager
- pydoc.Helper.getline = lambda self, prompt: None
- pydoc.TextDoc.use_bold = lambda self, text: text
-
# Possibly temp. addons path
from os.path import join, dirname, normpath
_sys.path.append(normpath(join(dirname(__file__), "..", "..", "addons", "modules")))
diff --git a/release/scripts/op/console_python.py b/release/scripts/op/console_python.py
index dc2a0a7713c..84b2ed24350 100644
--- a/release/scripts/op/console_python.py
+++ b/release/scripts/op/console_python.py
@@ -33,6 +33,20 @@ def add_scrollback(text, text_type):
type=text_type)
+def replace_help(namespace):
+ def _help(value):
+ # because of how the console works. we need our own help() pager func.
+ # replace the bold function because it adds crazy chars
+ import pydoc
+ pydoc.getpager = lambda: pydoc.plainpager
+ pydoc.Helper.getline = lambda self, prompt: None
+ pydoc.TextDoc.use_bold = lambda self, text: text
+
+ help(value)
+
+ namespace["help"] = _help
+
+
def get_console(console_id):
'''
helper function for console operators
@@ -83,6 +97,8 @@ def get_console(console_id):
namespace["bpy"] = bpy
namespace["C"] = bpy.context
+ replace_help(namespace)
+
console = InteractiveConsole(locals=namespace, filename="<blender_console>")
console.push("from mathutils import *")