lazy load pydoc module. move help() replacement into console code rather then on startup since importing pydoc pulls in lots of other modules too.
This commit is contained in:
@@ -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")))
|
||||
|
||||
@@ -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 *")
|
||||
|
||||
Reference in New Issue
Block a user