Show More
@@ -30,7 +30,7 b' from string import Formatter' | |||
|
30 | 30 | |
|
31 | 31 | from IPython.config.configurable import Configurable |
|
32 | 32 | from IPython.core import release |
|
33 | from IPython.utils import coloransi | |
|
33 | from IPython.utils import coloransi, py3compat | |
|
34 | 34 | from IPython.utils.traitlets import (Unicode, Instance, Dict, Bool, Int) |
|
35 | 35 | |
|
36 | 36 | #----------------------------------------------------------------------------- |
@@ -95,7 +95,13 b' class LazyEvaluate(object):' | |||
|
95 | 95 | return self.func(*self.args, **self.kwargs) |
|
96 | 96 | |
|
97 | 97 | def __str__(self): |
|
98 |
return |
|
|
98 | return py3compat.cast_bytes_py2(self()) | |
|
99 | ||
|
100 | def __unicode__(self): | |
|
101 | return py3compat.cast_unicode(self()) | |
|
102 | ||
|
103 | def __format__(self, format_spec): | |
|
104 | return format(unicode(self), format_spec) | |
|
99 | 105 | |
|
100 | 106 | def multiple_replace(dict, text): |
|
101 | 107 | """ Replace in 'text' all occurences of any key in the given |
@@ -202,7 +208,7 b' def cwd_filt(depth):' | |||
|
202 | 208 | $HOME is always replaced with '~'. |
|
203 | 209 | If depth==0, the full path is returned.""" |
|
204 | 210 | |
|
205 | cwd = os.getcwd().replace(HOME,"~") | |
|
211 | cwd = os.getcwdu().replace(HOME,"~") | |
|
206 | 212 | out = os.sep.join(cwd.split(os.sep)[-depth:]) |
|
207 | 213 | return out or os.sep |
|
208 | 214 | |
@@ -212,7 +218,7 b' def cwd_filt2(depth):' | |||
|
212 | 218 | $HOME is always replaced with '~'. |
|
213 | 219 | If depth==0, the full path is returned.""" |
|
214 | 220 | |
|
215 | full_cwd = os.getcwd() | |
|
221 | full_cwd = os.getcwdu() | |
|
216 | 222 | cwd = full_cwd.replace(HOME,"~").split(os.sep) |
|
217 | 223 | if '~' in cwd and len(cwd) == depth+1: |
|
218 | 224 | depth += 1 |
@@ -228,9 +234,9 b' def cwd_filt2(depth):' | |||
|
228 | 234 | #----------------------------------------------------------------------------- |
|
229 | 235 | |
|
230 | 236 | lazily_evaluate = {'time': LazyEvaluate(time.strftime, "%H:%M:%S"), |
|
231 | 'cwd': LazyEvaluate(os.getcwd), | |
|
232 | 'cwd_last': LazyEvaluate(lambda: os.getcwd().split(os.sep)[-1]), | |
|
233 | 'cwd_x': [LazyEvaluate(lambda: os.getcwd().replace("%s","~"))] +\ | |
|
237 | 'cwd': LazyEvaluate(os.getcwdu), | |
|
238 | 'cwd_last': LazyEvaluate(lambda: os.getcwdu().split(os.sep)[-1]), | |
|
239 | 'cwd_x': [LazyEvaluate(lambda: os.getcwdu().replace("%s","~"))] +\ | |
|
234 | 240 | [LazyEvaluate(cwd_filt, x) for x in range(1,6)], |
|
235 | 241 | 'cwd_y': [LazyEvaluate(cwd_filt2, x) for x in range(6)] |
|
236 | 242 | } |
General Comments 0
You need to be logged in to leave comments.
Login now