From 1ce8873a964b0e7de0b3d522a4ac749ed39ea0fb 2006-01-13 19:16:41 From: vivainio Date: 2006-01-13 19:16:41 Subject: [PATCH] Added platutils modules, now only needed for %cd to change terminal title string. Implemented for Linux. "Authors" list also modified to include myself. --- diff --git a/IPython/Magic.py b/IPython/Magic.py index c240c4e..e8b48b1 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 1005 2006-01-12 08:39:26Z fperez $""" +$Id: Magic.py 1014 2006-01-13 19:16:41Z vivainio $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -49,7 +49,7 @@ from IPython.PyColorize import Parser from IPython.ipstruct import Struct from IPython.macro import Macro from IPython.genutils import * - +from IPython import platutils #*************************************************************************** # Utility functions def on_off(tag): @@ -2329,12 +2329,16 @@ Defaulting color scheme to 'NoColor'""" if ps: try: os.chdir(os.path.expanduser(ps)) + ttitle = ("IPy:" + ( + os.getcwd() == '/' and '/' or os.path.basename(os.getcwd()))) + platutils.set_term_title(ttitle) except OSError: print sys.exc_info()[1] else: self.shell.user_ns['_dh'].append(os.getcwd()) else: os.chdir(self.shell.home_dir) + platutils.set_term_title("IPy:~") self.shell.user_ns['_dh'].append(os.getcwd()) if not 'q' in opts: print self.shell.user_ns['_dh'][-1] diff --git a/IPython/Release.py b/IPython/Release.py index 24e73bf..1d27f54 100644 --- a/IPython/Release.py +++ b/IPython/Release.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Release data for the IPython project. -$Id: Release.py 1002 2006-01-11 22:18:29Z fperez $""" +$Id: Release.py 1014 2006-01-13 19:16:41Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez @@ -24,7 +24,7 @@ name = 'ipython' version = '0.7.1.svn' -revision = '$Revision: 1002 $' +revision = '$Revision: 1014 $' description = "An enhanced interactive Python shell." @@ -64,7 +64,8 @@ license = 'BSD' authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'), 'Janko' : ('Janko Hauser','jhauser@zscout.de'), - 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu') + 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'), + 'Ville' : ('Ville Vainio','vivainio@gmail.com') } url = 'http://ipython.scipy.org' diff --git a/IPython/__init__.py b/IPython/__init__.py index 15d7363..6988403 100644 --- a/IPython/__init__.py +++ b/IPython/__init__.py @@ -27,7 +27,7 @@ IPython tries to: IPython requires Python 2.2 or newer. -$Id: __init__.py 1005 2006-01-12 08:39:26Z fperez $""" +$Id: __init__.py 1014 2006-01-13 19:16:41Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2004 Fernando Perez. @@ -43,7 +43,8 @@ if sys.version[0:3] < '2.3': # Define what gets imported with a 'from IPython import *' __all__ = ['deep_reload','genutils','ipstruct','ultraTB','DPyGetOpt', - 'Itpl','hooks','ConfigLoader','OutputTrap','Release','Shell'] + 'Itpl','hooks','ConfigLoader','OutputTrap','Release','Shell', + 'platutils','platutils_win32','platutils_posix','platutils_dummy'] # Load __all__ in IPython namespace so that a simple 'import IPython' gives # access to them via IPython. diff --git a/IPython/platutils.py b/IPython/platutils.py new file mode 100644 index 0000000..fbb9af6 --- /dev/null +++ b/IPython/platutils.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +""" Proxy module for accessing platform specific utility functions. + +Importing this module should give you the implementations that are correct +for your operation system, from platutils_PLATFORMNAME module. + +$Id: ipstruct.py 1005 2006-01-12 08:39:26Z fperez $ + + +""" + + +#***************************************************************************** +# Copyright (C) 2001-2006 Fernando Perez +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#***************************************************************************** + +from IPython import Release +__author__ = '%s <%s>' % Release.authors['Ville'] +__license__ = Release.license + +import os + +if os.name == 'posix': + from platutils_posix import * +elif os.name == 'win32': + from platutils_win32 import * +else: + from platutils_dummy import * + import warnings + warnings.warn("Platutils not available for platform '%s', some features may be missing" % + os.name) + del warnings diff --git a/IPython/platutils_dummy.py b/IPython/platutils_dummy.py new file mode 100644 index 0000000..149acb9 --- /dev/null +++ b/IPython/platutils_dummy.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" Platform specific utility functions, dummy version + +This has empty implementation of the platutils functions, used for +unsupported operating systems. + +$Id: ipstruct.py 1005 2006-01-12 08:39:26Z fperez $ + + +""" + + +#***************************************************************************** +# Copyright (C) 2001-2006 Fernando Perez +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#***************************************************************************** + +from IPython import Release +__author__ = '%s <%s>' % Release.authors['Ville'] +__license__ = Release.license + + +def _dummy(*args,**kw): + pass + +set_term_title = _dummy + diff --git a/IPython/platutils_posix.py b/IPython/platutils_posix.py new file mode 100644 index 0000000..387504d --- /dev/null +++ b/IPython/platutils_posix.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +""" Platform specific utility functions, posix version + +Importing this module directly is not portable - rather, import platutils +to use these functions in platform agnostic fashion. + +$Id: ipstruct.py 1005 2006-01-12 08:39:26Z fperez $ + +""" + + +#***************************************************************************** +# Copyright (C) 2001-2006 Fernando Perez +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#***************************************************************************** + +from IPython import Release +__author__ = '%s <%s>' % Release.authors['Ville'] +__license__ = Release.license + +import sys + +def set_term_title(title): + sys.stdout.write('\033]%d;%s\007' % (0,title)) diff --git a/IPython/platutils_win32.py b/IPython/platutils_win32.py new file mode 100644 index 0000000..9d3bcd5 --- /dev/null +++ b/IPython/platutils_win32.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +""" Platform specific utility functions, win32 version + +Importing this module directly is not portable - rather, import platutils +to use these functions in platform agnostic fashion. + +$Id: ipstruct.py 1005 2006-01-12 08:39:26Z fperez $ + +""" + + +#***************************************************************************** +# Copyright (C) 2001-2006 Fernando Perez +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#***************************************************************************** + +from IPython import Release +__author__ = '%s <%s>' % Release.authors['Ville'] +__license__ = Release.license + + +def set_term_title(title): + """ TBD """ diff --git a/doc/ChangeLog b/doc/ChangeLog index 698dcb1..01e05d2 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,12 @@ +2006-01-13 Ville Vainio + + * IPython/platutils*.py: platform specific utility functions, + so far only set_term_title is implemented (change terminal + label in windowing systems). %cd now changes the title to + current dir. + + * Added myself to "authors" list, had to create new files. + 2006-01-13 Fernando Perez * IPython/iplib.py (raw_input): temporarily deactivate all