diff --git a/IPython/core/component.py b/IPython/core/component.py index c0fc202..dfce84d 100644 --- a/IPython/core/component.py +++ b/IPython/core/component.py @@ -165,7 +165,7 @@ class Component(HasTraitlets): else: self.name = name self.root = self # This is the default, it is set when parent is set - self.parent = parent + self.parent = parent if config is not None: self.config = deepcopy(config) else: diff --git a/IPython/core/iplib.py b/IPython/core/iplib.py index 46e283d..856c98d 100644 --- a/IPython/core/iplib.py +++ b/IPython/core/iplib.py @@ -58,7 +58,7 @@ from IPython.utils.strdispatch import StrDispatch from IPython.utils.platutils import toggle_set_term_title, set_term_title from IPython.utils.traitlets import ( - Int, Float, Str, CBool, CaselessStrEnum, Enum, List + Int, Float, Str, CBool, CaselessStrEnum, Enum, List, Unicode ) #----------------------------------------------------------------------------- @@ -232,6 +232,7 @@ class InteractiveShell(Component, Magic): editor = Str(get_default_editor(), config_key='EDITOR') filename = Str("") interactive = CBool(False, config_key='INTERACTIVE') + ipythondir= Unicode('', config_key='IPYTHONDIR') # Set to os.getcwd() in __init__ logstart = CBool(False, config_key='LOGSTART') logfile = Str('', config_key='LOGFILE') logplay = Str('', config_key='LOGPLAY') @@ -294,7 +295,7 @@ class InteractiveShell(Component, Magic): # Subclasses with thread support should override this as needed. isthreaded = False - def __init__(self, parent=None, config=None, usage=None, + def __init__(self, parent=None, ipythondir=None, config=None, usage=None, user_ns=None, user_global_ns=None, banner1=None, banner2=None, custom_exceptions=((),None), embedded=False): @@ -305,6 +306,7 @@ class InteractiveShell(Component, Magic): # passing it to children components. super(InteractiveShell, self).__init__(parent, config=config, name='__IP') + self.init_ipythondir(ipythondir) self.init_instance_attrs() self.init_term_title() self.init_usage(usage) @@ -367,6 +369,16 @@ class InteractiveShell(Component, Magic): # init_* methods called by __init__ #------------------------------------------------------------------------- + def init_ipythondir(self, ipythondir): + if ipythondir is not None: + self.ipythondir = ipythondir + return + + if not hasattr(self.config, 'IPYTHONDIR'): + # cdw is always defined + self.ipythondir = os.getcwd() + return + def init_instance_attrs(self): self.jobs = BackgroundJobManager() self.more = False