Skip to content

Loading…

Getcwdu #574

Merged
merged 3 commits into from

3 participants

@jstenar
IPython member

Branch to change usage of getcwd into getcwdu.

I did not change the usage of getcwd in core/prompts.py. Because Itpl templates are used there and it appears they do not work well with unicode and takluyver said he is working on replacing Itpl with the builtin templates.

/Jörgen

@jstenar
IPython member

This pull request relates to issue #569

@minrk
IPython member

Does this actually fix #569, or not?

@takluyver
IPython member

@jstenar: yes, I've got a prompt refactor in PR #507, which I need to rebase. It won't be in 0.11.

@minrk
IPython member

Merging this now, but let me know if #569 should be closed.

@minrk minrk merged commit 8509782 into ipython:master
@jstenar
IPython member

This fixes the problem in #569.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 11, 2011
  1. Switching to unicode version of os.getcwd in filefind

    J�rgen Stenarson committed
Commits on Jul 12, 2011
  1. Reverting debugging code left in b4b4ede

    J�rgen Stenarson committed
View
4 IPython/core/crashhandler.py
@@ -119,9 +119,9 @@ def __call__(self, etype, evalue, etb):
try:
rptdir = self.app.ipython_dir
except:
- rptdir = os.getcwd()
+ rptdir = os.getcwdu()
if rptdir is None or not os.path.isdir(rptdir):
- rptdir = os.getcwd()
+ rptdir = os.getcwdu()
report_name = os.path.join(rptdir,self.crash_report_fname)
# write the report filename into the instance dict so it can get
# properly expanded out in the user message template
View
4 IPython/core/history.py
@@ -47,7 +47,7 @@ class HistoryManager(Configurable):
dir_hist = List()
def _dir_hist_default(self):
try:
- return [os.getcwd()]
+ return [os.getcwdu()]
except OSError:
return []
@@ -173,7 +173,7 @@ def reset(self, new_session=True):
optionally open a new session."""
self.output_hist.clear()
# The directory history can't be completely empty
- self.dir_hist[:] = [os.getcwd()]
+ self.dir_hist[:] = [os.getcwdu()]
if new_session:
if self.session_number:
View
2 IPython/core/interactiveshell.py
@@ -500,7 +500,7 @@ def init_instance_attrs(self):
# keep track of where we started running (mainly for crash post-mortem)
# This is not being used anywhere currently.
- self.starting_dir = os.getcwd()
+ self.starting_dir = os.getcwdu()
# Indentation management
self.indent_current_nsp = 0
View
14 IPython/core/magic.py
@@ -2673,7 +2673,7 @@ def magic_rehashx(self, parameter_s = ''):
winext += '|py'
execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
- savedir = os.getcwd()
+ savedir = os.getcwdu()
# Now walk the paths looking for executables to alias.
try:
@@ -2726,7 +2726,7 @@ def magic_pwd(self, parameter_s = ''):
In [9]: pwd
Out[9]: '/home/tsuser/sprint/ipython'
"""
- return os.getcwd()
+ return os.getcwdu()
@skip_doctest
def magic_cd(self, parameter_s=''):
@@ -2772,7 +2772,7 @@ def magic_cd(self, parameter_s=''):
parameter_s = parameter_s.strip()
#bkms = self.shell.persist.get("bookmarks",{})
- oldcwd = os.getcwd()
+ oldcwd = os.getcwdu()
numcd = re.match(r'(-)(\d+)$',parameter_s)
# jump in directory history by number
if numcd:
@@ -2846,7 +2846,7 @@ def magic_cd(self, parameter_s=''):
except OSError:
print sys.exc_info()[1]
else:
- cwd = os.getcwd()
+ cwd = os.getcwdu()
dhist = self.shell.user_ns['_dh']
if oldcwd != cwd:
dhist.append(cwd)
@@ -2856,7 +2856,7 @@ def magic_cd(self, parameter_s=''):
os.chdir(self.shell.home_dir)
if hasattr(self.shell, 'term_title') and self.shell.term_title:
set_term_title('IPython: ' + '~')
- cwd = os.getcwd()
+ cwd = os.getcwdu()
dhist = self.shell.user_ns['_dh']
if oldcwd != cwd:
@@ -2880,7 +2880,7 @@ def magic_pushd(self, parameter_s=''):
dir_s = self.shell.dir_stack
tgt = os.path.expanduser(parameter_s)
- cwd = os.getcwd().replace(self.home_dir,'~')
+ cwd = os.getcwdu().replace(self.home_dir,'~')
if tgt:
self.magic_cd(parameter_s)
dir_s.insert(0,cwd)
@@ -3145,7 +3145,7 @@ def magic_bookmark(self, parameter_s=''):
if not args:
raise UsageError("%bookmark: You must specify the bookmark name")
elif len(args)==1:
- bkms[args[0]] = os.getcwd()
+ bkms[args[0]] = os.getcwdu()
elif len(args)==2:
bkms[args[0]] = args[1]
self.db['bookmarks'] = bkms
View
2 IPython/core/profiledir.py
@@ -167,7 +167,7 @@ def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None):
is not found, a :class:`ProfileDirError` exception will be raised.
The search path algorithm is:
- 1. ``os.getcwd()``
+ 1. ``os.getcwdu()``
2. ``ipython_dir``
Parameters
View
2 IPython/core/tests/test_application.py
@@ -14,7 +14,7 @@ def test_unicode_cwd():
old_wd = os.getcwdu()
os.chdir(wd)
- #raise Exception(repr(os.getcwd()))
+ #raise Exception(repr(os.getcwdu()))
try:
app = BaseIPythonApplication()
# The lines below are copied from Application.initialize()
View
2 IPython/external/path/_path.py
@@ -245,7 +245,7 @@ def relpath(self):
""" Return this path as a relative path,
based from the current working directory.
"""
- cwd = self.__class__(os.getcwd())
+ cwd = self.__class__(os.getcwdu())
return cwd.relpathto(self)
def relpathto(self, dest):
View
2 IPython/quarantine/ipy_rehashdir.py
@@ -104,7 +104,7 @@ def isjunk(fname):
execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
- savedir = os.getcwd()
+ savedir = os.getcwdu()
try:
# write the whole loop for posix/Windows so we don't have an if in
# the innermost part
View
2 IPython/quarantine/ipy_synchronize_with.py
@@ -37,7 +37,7 @@ def find_filename(filename):
filename = "".join(filename)
if not os.path.isabs(filename):
- filename = os.path.join(os.getcwd(), filename)
+ filename = os.path.join(os.getcwdu(), filename)
if os.path.isfile(filename):
return filename
View
2 IPython/quarantine/ipy_workdir.py
@@ -33,7 +33,7 @@ def workdir_f(ip,line):
if os.path.isfile(head):
cmd = os.path.abspath(head) + ' ' + tail
print "Execute command '" + cmd+ "' in",workdir
- olddir = os.getcwd()
+ olddir = os.getcwdu()
os.chdir(workdir)
try:
os.system(cmd)
View
4 IPython/quarantine/jobctrl.py
@@ -92,7 +92,7 @@ def run(self):
self.output.append(out)
def add(self,cmd):
- self.q.put_nowait((cmd, os.getcwd()))
+ self.q.put_nowait((cmd, os.getcwdu()))
def dumpoutput(self):
while self.output:
@@ -220,7 +220,7 @@ def jobctrl_shellcmd(ip,cmd):
p = Popen(cmd,shell = True)
jobentry = 'tasks/t' + str(p.pid)
- ip.db[jobentry] = (p.pid,cmd,os.getcwd(),time.time())
+ ip.db[jobentry] = (p.pid,cmd,os.getcwdu(),time.time())
p.communicate()
finally:
View
2 IPython/testing/iptest.py
@@ -385,7 +385,7 @@ def run_iptestall():
# to clean up any junk files left over by accident. This also makes it
# robust against being run in non-writeable directories by mistake, as the
# temp dir will always be user-writeable.
- curdir = os.getcwd()
+ curdir = os.getcwdu()
testdir = tempfile.gettempdir()
os.chdir(testdir)
View
2 IPython/testing/plugin/ipdoctest.py
@@ -250,7 +250,7 @@ def runTest(self):
# Save our current directory and switch out to the one where the
# test was originally created, in case another doctest did a
# directory change. We'll restore this in the finally clause.
- curdir = os.getcwd()
+ curdir = os.getcwdu()
#print 'runTest in dir:', self._ori_dir # dbg
os.chdir(self._ori_dir)
View
2 IPython/utils/_process_win32.py
@@ -49,7 +49,7 @@ class AvoidUNCPath(object):
os.system(cmd)
"""
def __enter__(self):
- self.path = os.getcwd()
+ self.path = os.getcwdu()
self.is_unc_path = self.path.startswith(r"\\")
if self.is_unc_path:
# change to c drive (as cmd.exe cannot handle UNC addresses)
View
2 IPython/utils/path.py
@@ -137,7 +137,7 @@ def filefind(filename, path_dirs=None):
path_dirs = (path_dirs,)
for path in path_dirs:
- if path == '.': path = os.getcwd()
+ if path == '.': path = os.getcwdu()
testname = expand_path(os.path.join(path, filename))
if os.path.isfile(testname):
return os.path.abspath(testname)
View
2 IPython/utils/process.py
@@ -129,7 +129,7 @@ def arg_split(s, posix=False):
def abbrev_cwd():
""" Return abbreviated version of cwd, e.g. d:mydir """
- cwd = os.getcwd().replace('\\','/')
+ cwd = os.getcwdu().replace('\\','/')
drivepart = ''
tail = cwd
if sys.platform == 'win32':
View
2 IPython/utils/terminal.py
@@ -102,7 +102,7 @@ def _set_term_title(title):
try:
# Cannot be on network share when issuing system commands
- curr = os.getcwd()
+ curr = os.getcwdu()
os.chdir("C:")
ret = os.system("title " + title)
finally:
View
2 docs/do_sphinx.py
@@ -15,7 +15,7 @@ def oscmd(c):
oscmd('sphinx-build -b latex -d build/doctrees source build/latex')
# Produce pdf.
- topdir = os.getcwd()
+ topdir = os.getcwdu()
os.chdir('build/latex')
# Change chapter style to section style: allows chapters to start on
View
2 docs/examples/newparallel/davinci/pwordfreq.py
@@ -69,7 +69,7 @@ def pwordfreq(view, fnames):
with open('davinci%i.txt'%i, 'w') as f:
f.write('\n'.join(chunk))
- cwd = os.path.abspath(os.getcwd())
+ cwd = os.path.abspath(os.getcwdu())
fnames = [ os.path.join(cwd, 'davinci%i.txt'%i) for i in range(n)]
tic = time.time()
pfreqs = pwordfreq(view,fnames)
View
4 docs/gh-pages.py
@@ -69,7 +69,7 @@ def sh3(cmd):
def init_repo(path):
"""clone the gh-pages repo if we haven't already."""
sh("git clone %s %s"%(pages_repo, path))
- here = os.getcwd()
+ here = os.getcwdu()
cd(path)
sh('git checkout gh-pages')
cd(here)
@@ -87,7 +87,7 @@ def init_repo(path):
except CalledProcessError:
tag = "dev" # Fallback
- startdir = os.getcwd()
+ startdir = os.getcwdu()
if not os.path.exists(pages_dir):
# init the repo
init_repo(pages_dir)
View
2 tools/gitwash_dumper.py
@@ -16,7 +16,7 @@
def clone_repo(url, branch):
- cwd = os.getcwd()
+ cwd = os.getcwdu()
tmpdir = tempfile.mkdtemp()
try:
cmd = 'git clone %s %s' % (url, tmpdir)
View
2 tools/make_tarball.py
@@ -18,7 +18,7 @@
# to the top of the tree. There are long threads (since 2007) on the git list
# about this and it still doesn't work in a sensible way...
-start_dir = os.getcwd()
+start_dir = os.getcwdu()
cd('..')
git_tpl = 'git archive --format=tar --prefix={0}/ HEAD | gzip > {1}'
sh(git_tpl.format(base_name, tar_name))
Something went wrong with that request. Please try again.