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