Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4b4ede

Browse files
author
J�rgen Stenarson
committed
Search of getcwd and replace with getcwdu. Ignoring core/prompts.py
1 parent de070f2 commit b4b4ede

23 files changed

Lines changed: 37 additions & 34 deletions

IPython/core/crashhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def __call__(self, etype, evalue, etb):
119119
try:
120120
rptdir = self.app.ipython_dir
121121
except:
122-
rptdir = os.getcwd()
122+
rptdir = os.getcwdu()
123123
if rptdir is None or not os.path.isdir(rptdir):
124-
rptdir = os.getcwd()
124+
rptdir = os.getcwdu()
125125
report_name = os.path.join(rptdir,self.crash_report_fname)
126126
# write the report filename into the instance dict so it can get
127127
# properly expanded out in the user message template

IPython/core/history.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class HistoryManager(Configurable):
4747
dir_hist = List()
4848
def _dir_hist_default(self):
4949
try:
50-
return [os.getcwd()]
50+
return [os.getcwdu()]
5151
except OSError:
5252
return []
5353

@@ -173,7 +173,7 @@ def reset(self, new_session=True):
173173
optionally open a new session."""
174174
self.output_hist.clear()
175175
# The directory history can't be completely empty
176-
self.dir_hist[:] = [os.getcwd()]
176+
self.dir_hist[:] = [os.getcwdu()]
177177

178178
if new_session:
179179
if self.session_number:

IPython/core/interactiveshell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def init_instance_attrs(self):
500500

501501
# keep track of where we started running (mainly for crash post-mortem)
502502
# This is not being used anywhere currently.
503-
self.starting_dir = os.getcwd()
503+
self.starting_dir = os.getcwdu()
504504

505505
# Indentation management
506506
self.indent_current_nsp = 0

IPython/core/magic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,7 +2673,7 @@ def magic_rehashx(self, parameter_s = ''):
26732673
winext += '|py'
26742674
execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
26752675
isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2676-
savedir = os.getcwd()
2676+
savedir = os.getcwdu()
26772677

26782678
# Now walk the paths looking for executables to alias.
26792679
try:
@@ -2726,7 +2726,7 @@ def magic_pwd(self, parameter_s = ''):
27262726
In [9]: pwd
27272727
Out[9]: '/home/tsuser/sprint/ipython'
27282728
"""
2729-
return os.getcwd()
2729+
return os.getcwdu()
27302730

27312731
@skip_doctest
27322732
def magic_cd(self, parameter_s=''):
@@ -2772,7 +2772,7 @@ def magic_cd(self, parameter_s=''):
27722772
parameter_s = parameter_s.strip()
27732773
#bkms = self.shell.persist.get("bookmarks",{})
27742774

2775-
oldcwd = os.getcwd()
2775+
oldcwd = os.getcwdu()
27762776
numcd = re.match(r'(-)(\d+)$',parameter_s)
27772777
# jump in directory history by number
27782778
if numcd:
@@ -2846,7 +2846,7 @@ def magic_cd(self, parameter_s=''):
28462846
except OSError:
28472847
print sys.exc_info()[1]
28482848
else:
2849-
cwd = os.getcwd()
2849+
cwd = os.getcwdu()
28502850
dhist = self.shell.user_ns['_dh']
28512851
if oldcwd != cwd:
28522852
dhist.append(cwd)
@@ -2856,7 +2856,7 @@ def magic_cd(self, parameter_s=''):
28562856
os.chdir(self.shell.home_dir)
28572857
if hasattr(self.shell, 'term_title') and self.shell.term_title:
28582858
set_term_title('IPython: ' + '~')
2859-
cwd = os.getcwd()
2859+
cwd = os.getcwdu()
28602860
dhist = self.shell.user_ns['_dh']
28612861

28622862
if oldcwd != cwd:
@@ -2880,7 +2880,7 @@ def magic_pushd(self, parameter_s=''):
28802880

28812881
dir_s = self.shell.dir_stack
28822882
tgt = os.path.expanduser(parameter_s)
2883-
cwd = os.getcwd().replace(self.home_dir,'~')
2883+
cwd = os.getcwdu().replace(self.home_dir,'~')
28842884
if tgt:
28852885
self.magic_cd(parameter_s)
28862886
dir_s.insert(0,cwd)
@@ -3145,7 +3145,7 @@ def magic_bookmark(self, parameter_s=''):
31453145
if not args:
31463146
raise UsageError("%bookmark: You must specify the bookmark name")
31473147
elif len(args)==1:
3148-
bkms[args[0]] = os.getcwd()
3148+
bkms[args[0]] = os.getcwdu()
31493149
elif len(args)==2:
31503150
bkms[args[0]] = args[1]
31513151
self.db['bookmarks'] = bkms

IPython/core/profiledir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None):
167167
is not found, a :class:`ProfileDirError` exception will be raised.
168168
169169
The search path algorithm is:
170-
1. ``os.getcwd()``
170+
1. ``os.getcwdu()``
171171
2. ``ipython_dir``
172172
173173
Parameters

IPython/core/prompts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ def str_safe(arg):
224224
except Exception,msg:
225225
# let's keep this little duplication here, so that the most common
226226
# case doesn't suffer from a double try wrapping.
227-
out = '<ERROR: %s>' % msg
227+
out = '<ERRORx: %s>' % msg
228228
except Exception,msg:
229-
out = '<ERROR: %s>' % msg
229+
out = '<ERRORy: %s>' % msg
230230
#raise # dbg
231231
return out
232232

IPython/core/tests/test_application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_unicode_cwd():
1414

1515
old_wd = os.getcwdu()
1616
os.chdir(wd)
17-
#raise Exception(repr(os.getcwd()))
17+
#raise Exception(repr(os.getcwdu()))
1818
try:
1919
app = BaseIPythonApplication()
2020
# The lines below are copied from Application.initialize()

IPython/external/Itpl/_Itpl.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def _str(self,glob,loc):
196196
for live, chunk in self.chunks:
197197
if live: app(str(eval(chunk,glob,loc)))
198198
else: app(chunk)
199-
out = ''.join(result)
199+
out = u''.join(result)
200200
try:
201201
return str(out)
202202
except UnicodeError:
@@ -212,6 +212,9 @@ def __str__(self):
212212
loc, glob = frame.f_locals, frame.f_globals
213213

214214
return self._str(glob,loc)
215+
216+
def encode(self, encoding, errors):
217+
return str(self)#.encode(encoding, errors)
215218

216219
class ItplNS(Itpl):
217220
"""Class representing a string with interpolation abilities.

IPython/external/path/_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def relpath(self):
245245
""" Return this path as a relative path,
246246
based from the current working directory.
247247
"""
248-
cwd = self.__class__(os.getcwd())
248+
cwd = self.__class__(os.getcwdu())
249249
return cwd.relpathto(self)
250250

251251
def relpathto(self, dest):

IPython/quarantine/ipy_rehashdir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def isjunk(fname):
104104

105105
execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
106106
isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
107-
savedir = os.getcwd()
107+
savedir = os.getcwdu()
108108
try:
109109
# write the whole loop for posix/Windows so we don't have an if in
110110
# the innermost part

0 commit comments

Comments
 (0)