##// END OF EJS Templates
Search of getcwd and replace with getcwdu. Ignoring core/prompts.py
Jörgen Stenarson -
Show More
@@ -119,9 +119,9 b' class CrashHandler(object):'
119 try:
119 try:
120 rptdir = self.app.ipython_dir
120 rptdir = self.app.ipython_dir
121 except:
121 except:
122 rptdir = os.getcwd()
122 rptdir = os.getcwdu()
123 if rptdir is None or not os.path.isdir(rptdir):
123 if rptdir is None or not os.path.isdir(rptdir):
124 rptdir = os.getcwd()
124 rptdir = os.getcwdu()
125 report_name = os.path.join(rptdir,self.crash_report_fname)
125 report_name = os.path.join(rptdir,self.crash_report_fname)
126 # write the report filename into the instance dict so it can get
126 # write the report filename into the instance dict so it can get
127 # properly expanded out in the user message template
127 # properly expanded out in the user message template
@@ -47,7 +47,7 b' class HistoryManager(Configurable):'
47 dir_hist = List()
47 dir_hist = List()
48 def _dir_hist_default(self):
48 def _dir_hist_default(self):
49 try:
49 try:
50 return [os.getcwd()]
50 return [os.getcwdu()]
51 except OSError:
51 except OSError:
52 return []
52 return []
53
53
@@ -173,7 +173,7 b' class HistoryManager(Configurable):'
173 optionally open a new session."""
173 optionally open a new session."""
174 self.output_hist.clear()
174 self.output_hist.clear()
175 # The directory history can't be completely empty
175 # The directory history can't be completely empty
176 self.dir_hist[:] = [os.getcwd()]
176 self.dir_hist[:] = [os.getcwdu()]
177
177
178 if new_session:
178 if new_session:
179 if self.session_number:
179 if self.session_number:
@@ -500,7 +500,7 b' class InteractiveShell(SingletonConfigurable, Magic):'
500
500
501 # keep track of where we started running (mainly for crash post-mortem)
501 # keep track of where we started running (mainly for crash post-mortem)
502 # This is not being used anywhere currently.
502 # This is not being used anywhere currently.
503 self.starting_dir = os.getcwd()
503 self.starting_dir = os.getcwdu()
504
504
505 # Indentation management
505 # Indentation management
506 self.indent_current_nsp = 0
506 self.indent_current_nsp = 0
@@ -2673,7 +2673,7 b' Defaulting color scheme to \'NoColor\'"""'
2673 winext += '|py'
2673 winext += '|py'
2674 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2674 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2675 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2675 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2676 savedir = os.getcwd()
2676 savedir = os.getcwdu()
2677
2677
2678 # Now walk the paths looking for executables to alias.
2678 # Now walk the paths looking for executables to alias.
2679 try:
2679 try:
@@ -2726,7 +2726,7 b' Defaulting color scheme to \'NoColor\'"""'
2726 In [9]: pwd
2726 In [9]: pwd
2727 Out[9]: '/home/tsuser/sprint/ipython'
2727 Out[9]: '/home/tsuser/sprint/ipython'
2728 """
2728 """
2729 return os.getcwd()
2729 return os.getcwdu()
2730
2730
2731 @skip_doctest
2731 @skip_doctest
2732 def magic_cd(self, parameter_s=''):
2732 def magic_cd(self, parameter_s=''):
@@ -2772,7 +2772,7 b' Defaulting color scheme to \'NoColor\'"""'
2772 parameter_s = parameter_s.strip()
2772 parameter_s = parameter_s.strip()
2773 #bkms = self.shell.persist.get("bookmarks",{})
2773 #bkms = self.shell.persist.get("bookmarks",{})
2774
2774
2775 oldcwd = os.getcwd()
2775 oldcwd = os.getcwdu()
2776 numcd = re.match(r'(-)(\d+)$',parameter_s)
2776 numcd = re.match(r'(-)(\d+)$',parameter_s)
2777 # jump in directory history by number
2777 # jump in directory history by number
2778 if numcd:
2778 if numcd:
@@ -2846,7 +2846,7 b' Defaulting color scheme to \'NoColor\'"""'
2846 except OSError:
2846 except OSError:
2847 print sys.exc_info()[1]
2847 print sys.exc_info()[1]
2848 else:
2848 else:
2849 cwd = os.getcwd()
2849 cwd = os.getcwdu()
2850 dhist = self.shell.user_ns['_dh']
2850 dhist = self.shell.user_ns['_dh']
2851 if oldcwd != cwd:
2851 if oldcwd != cwd:
2852 dhist.append(cwd)
2852 dhist.append(cwd)
@@ -2856,7 +2856,7 b' Defaulting color scheme to \'NoColor\'"""'
2856 os.chdir(self.shell.home_dir)
2856 os.chdir(self.shell.home_dir)
2857 if hasattr(self.shell, 'term_title') and self.shell.term_title:
2857 if hasattr(self.shell, 'term_title') and self.shell.term_title:
2858 set_term_title('IPython: ' + '~')
2858 set_term_title('IPython: ' + '~')
2859 cwd = os.getcwd()
2859 cwd = os.getcwdu()
2860 dhist = self.shell.user_ns['_dh']
2860 dhist = self.shell.user_ns['_dh']
2861
2861
2862 if oldcwd != cwd:
2862 if oldcwd != cwd:
@@ -2880,7 +2880,7 b' Defaulting color scheme to \'NoColor\'"""'
2880
2880
2881 dir_s = self.shell.dir_stack
2881 dir_s = self.shell.dir_stack
2882 tgt = os.path.expanduser(parameter_s)
2882 tgt = os.path.expanduser(parameter_s)
2883 cwd = os.getcwd().replace(self.home_dir,'~')
2883 cwd = os.getcwdu().replace(self.home_dir,'~')
2884 if tgt:
2884 if tgt:
2885 self.magic_cd(parameter_s)
2885 self.magic_cd(parameter_s)
2886 dir_s.insert(0,cwd)
2886 dir_s.insert(0,cwd)
@@ -3145,7 +3145,7 b' Defaulting color scheme to \'NoColor\'"""'
3145 if not args:
3145 if not args:
3146 raise UsageError("%bookmark: You must specify the bookmark name")
3146 raise UsageError("%bookmark: You must specify the bookmark name")
3147 elif len(args)==1:
3147 elif len(args)==1:
3148 bkms[args[0]] = os.getcwd()
3148 bkms[args[0]] = os.getcwdu()
3149 elif len(args)==2:
3149 elif len(args)==2:
3150 bkms[args[0]] = args[1]
3150 bkms[args[0]] = args[1]
3151 self.db['bookmarks'] = bkms
3151 self.db['bookmarks'] = bkms
@@ -167,7 +167,7 b' class ProfileDir(Configurable):'
167 is not found, a :class:`ProfileDirError` exception will be raised.
167 is not found, a :class:`ProfileDirError` exception will be raised.
168
168
169 The search path algorithm is:
169 The search path algorithm is:
170 1. ``os.getcwd()``
170 1. ``os.getcwdu()``
171 2. ``ipython_dir``
171 2. ``ipython_dir``
172
172
173 Parameters
173 Parameters
@@ -224,9 +224,9 b' def str_safe(arg):'
224 except Exception,msg:
224 except Exception,msg:
225 # let's keep this little duplication here, so that the most common
225 # let's keep this little duplication here, so that the most common
226 # case doesn't suffer from a double try wrapping.
226 # case doesn't suffer from a double try wrapping.
227 out = '<ERROR: %s>' % msg
227 out = '<ERRORx: %s>' % msg
228 except Exception,msg:
228 except Exception,msg:
229 out = '<ERROR: %s>' % msg
229 out = '<ERRORy: %s>' % msg
230 #raise # dbg
230 #raise # dbg
231 return out
231 return out
232
232
@@ -14,7 +14,7 b' def test_unicode_cwd():'
14
14
15 old_wd = os.getcwdu()
15 old_wd = os.getcwdu()
16 os.chdir(wd)
16 os.chdir(wd)
17 #raise Exception(repr(os.getcwd()))
17 #raise Exception(repr(os.getcwdu()))
18 try:
18 try:
19 app = BaseIPythonApplication()
19 app = BaseIPythonApplication()
20 # The lines below are copied from Application.initialize()
20 # The lines below are copied from Application.initialize()
@@ -196,7 +196,7 b' class Itpl:'
196 for live, chunk in self.chunks:
196 for live, chunk in self.chunks:
197 if live: app(str(eval(chunk,glob,loc)))
197 if live: app(str(eval(chunk,glob,loc)))
198 else: app(chunk)
198 else: app(chunk)
199 out = ''.join(result)
199 out = u''.join(result)
200 try:
200 try:
201 return str(out)
201 return str(out)
202 except UnicodeError:
202 except UnicodeError:
@@ -212,6 +212,9 b' class Itpl:'
212 loc, glob = frame.f_locals, frame.f_globals
212 loc, glob = frame.f_locals, frame.f_globals
213
213
214 return self._str(glob,loc)
214 return self._str(glob,loc)
215
216 def encode(self, encoding, errors):
217 return str(self)#.encode(encoding, errors)
215
218
216 class ItplNS(Itpl):
219 class ItplNS(Itpl):
217 """Class representing a string with interpolation abilities.
220 """Class representing a string with interpolation abilities.
@@ -245,7 +245,7 b' class path(unicode):'
245 """ Return this path as a relative path,
245 """ Return this path as a relative path,
246 based from the current working directory.
246 based from the current working directory.
247 """
247 """
248 cwd = self.__class__(os.getcwd())
248 cwd = self.__class__(os.getcwdu())
249 return cwd.relpathto(self)
249 return cwd.relpathto(self)
250
250
251 def relpathto(self, dest):
251 def relpathto(self, dest):
@@ -104,7 +104,7 b' def rehashdir_f(self,arg):'
104
104
105 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
105 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
106 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
106 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
107 savedir = os.getcwd()
107 savedir = os.getcwdu()
108 try:
108 try:
109 # write the whole loop for posix/Windows so we don't have an if in
109 # write the whole loop for posix/Windows so we don't have an if in
110 # the innermost part
110 # the innermost part
@@ -37,7 +37,7 b' def find_filename(filename):'
37 filename = "".join(filename)
37 filename = "".join(filename)
38
38
39 if not os.path.isabs(filename):
39 if not os.path.isabs(filename):
40 filename = os.path.join(os.getcwd(), filename)
40 filename = os.path.join(os.getcwdu(), filename)
41
41
42 if os.path.isfile(filename):
42 if os.path.isfile(filename):
43 return filename
43 return filename
@@ -33,7 +33,7 b' def workdir_f(ip,line):'
33 if os.path.isfile(head):
33 if os.path.isfile(head):
34 cmd = os.path.abspath(head) + ' ' + tail
34 cmd = os.path.abspath(head) + ' ' + tail
35 print "Execute command '" + cmd+ "' in",workdir
35 print "Execute command '" + cmd+ "' in",workdir
36 olddir = os.getcwd()
36 olddir = os.getcwdu()
37 os.chdir(workdir)
37 os.chdir(workdir)
38 try:
38 try:
39 os.system(cmd)
39 os.system(cmd)
@@ -92,7 +92,7 b' class AsyncJobQ(threading.Thread):'
92 self.output.append(out)
92 self.output.append(out)
93
93
94 def add(self,cmd):
94 def add(self,cmd):
95 self.q.put_nowait((cmd, os.getcwd()))
95 self.q.put_nowait((cmd, os.getcwdu()))
96
96
97 def dumpoutput(self):
97 def dumpoutput(self):
98 while self.output:
98 while self.output:
@@ -220,7 +220,7 b' def jobctrl_shellcmd(ip,cmd):'
220 p = Popen(cmd,shell = True)
220 p = Popen(cmd,shell = True)
221
221
222 jobentry = 'tasks/t' + str(p.pid)
222 jobentry = 'tasks/t' + str(p.pid)
223 ip.db[jobentry] = (p.pid,cmd,os.getcwd(),time.time())
223 ip.db[jobentry] = (p.pid,cmd,os.getcwdu(),time.time())
224 p.communicate()
224 p.communicate()
225
225
226 finally:
226 finally:
@@ -385,7 +385,7 b' def run_iptestall():'
385 # to clean up any junk files left over by accident. This also makes it
385 # to clean up any junk files left over by accident. This also makes it
386 # robust against being run in non-writeable directories by mistake, as the
386 # robust against being run in non-writeable directories by mistake, as the
387 # temp dir will always be user-writeable.
387 # temp dir will always be user-writeable.
388 curdir = os.getcwd()
388 curdir = os.getcwdu()
389 testdir = tempfile.gettempdir()
389 testdir = tempfile.gettempdir()
390 os.chdir(testdir)
390 os.chdir(testdir)
391
391
@@ -250,7 +250,7 b' class DocTestCase(doctests.DocTestCase):'
250 # Save our current directory and switch out to the one where the
250 # Save our current directory and switch out to the one where the
251 # test was originally created, in case another doctest did a
251 # test was originally created, in case another doctest did a
252 # directory change. We'll restore this in the finally clause.
252 # directory change. We'll restore this in the finally clause.
253 curdir = os.getcwd()
253 curdir = os.getcwdu()
254 #print 'runTest in dir:', self._ori_dir # dbg
254 #print 'runTest in dir:', self._ori_dir # dbg
255 os.chdir(self._ori_dir)
255 os.chdir(self._ori_dir)
256
256
@@ -49,7 +49,7 b' class AvoidUNCPath(object):'
49 os.system(cmd)
49 os.system(cmd)
50 """
50 """
51 def __enter__(self):
51 def __enter__(self):
52 self.path = os.getcwd()
52 self.path = os.getcwdu()
53 self.is_unc_path = self.path.startswith(r"\\")
53 self.is_unc_path = self.path.startswith(r"\\")
54 if self.is_unc_path:
54 if self.is_unc_path:
55 # change to c drive (as cmd.exe cannot handle UNC addresses)
55 # change to c drive (as cmd.exe cannot handle UNC addresses)
@@ -129,7 +129,7 b' def arg_split(s, posix=False):'
129
129
130 def abbrev_cwd():
130 def abbrev_cwd():
131 """ Return abbreviated version of cwd, e.g. d:mydir """
131 """ Return abbreviated version of cwd, e.g. d:mydir """
132 cwd = os.getcwd().replace('\\','/')
132 cwd = os.getcwdu().replace('\\','/')
133 drivepart = ''
133 drivepart = ''
134 tail = cwd
134 tail = cwd
135 if sys.platform == 'win32':
135 if sys.platform == 'win32':
@@ -102,7 +102,7 b" if sys.platform == 'win32':"
102
102
103 try:
103 try:
104 # Cannot be on network share when issuing system commands
104 # Cannot be on network share when issuing system commands
105 curr = os.getcwd()
105 curr = os.getcwdu()
106 os.chdir("C:")
106 os.chdir("C:")
107 ret = os.system("title " + title)
107 ret = os.system("title " + title)
108 finally:
108 finally:
@@ -15,7 +15,7 b" if sys.platform != 'win32':"
15 oscmd('sphinx-build -b latex -d build/doctrees source build/latex')
15 oscmd('sphinx-build -b latex -d build/doctrees source build/latex')
16
16
17 # Produce pdf.
17 # Produce pdf.
18 topdir = os.getcwd()
18 topdir = os.getcwdu()
19 os.chdir('build/latex')
19 os.chdir('build/latex')
20
20
21 # Change chapter style to section style: allows chapters to start on
21 # Change chapter style to section style: allows chapters to start on
@@ -69,7 +69,7 b" if __name__ == '__main__':"
69 with open('davinci%i.txt'%i, 'w') as f:
69 with open('davinci%i.txt'%i, 'w') as f:
70 f.write('\n'.join(chunk))
70 f.write('\n'.join(chunk))
71
71
72 cwd = os.path.abspath(os.getcwd())
72 cwd = os.path.abspath(os.getcwdu())
73 fnames = [ os.path.join(cwd, 'davinci%i.txt'%i) for i in range(n)]
73 fnames = [ os.path.join(cwd, 'davinci%i.txt'%i) for i in range(n)]
74 tic = time.time()
74 tic = time.time()
75 pfreqs = pwordfreq(view,fnames)
75 pfreqs = pwordfreq(view,fnames)
@@ -69,7 +69,7 b' def sh3(cmd):'
69 def init_repo(path):
69 def init_repo(path):
70 """clone the gh-pages repo if we haven't already."""
70 """clone the gh-pages repo if we haven't already."""
71 sh("git clone %s %s"%(pages_repo, path))
71 sh("git clone %s %s"%(pages_repo, path))
72 here = os.getcwd()
72 here = os.getcwdu()
73 cd(path)
73 cd(path)
74 sh('git checkout gh-pages')
74 sh('git checkout gh-pages')
75 cd(here)
75 cd(here)
@@ -87,7 +87,7 b" if __name__ == '__main__':"
87 except CalledProcessError:
87 except CalledProcessError:
88 tag = "dev" # Fallback
88 tag = "dev" # Fallback
89
89
90 startdir = os.getcwd()
90 startdir = os.getcwdu()
91 if not os.path.exists(pages_dir):
91 if not os.path.exists(pages_dir):
92 # init the repo
92 # init the repo
93 init_repo(pages_dir)
93 init_repo(pages_dir)
@@ -16,7 +16,7 b' verbose = False'
16
16
17
17
18 def clone_repo(url, branch):
18 def clone_repo(url, branch):
19 cwd = os.getcwd()
19 cwd = os.getcwdu()
20 tmpdir = tempfile.mkdtemp()
20 tmpdir = tempfile.mkdtemp()
21 try:
21 try:
22 cmd = 'git clone %s %s' % (url, tmpdir)
22 cmd = 'git clone %s %s' % (url, tmpdir)
@@ -18,7 +18,7 b" tar_name = '%s.tgz' % base_name"
18 # to the top of the tree. There are long threads (since 2007) on the git list
18 # to the top of the tree. There are long threads (since 2007) on the git list
19 # about this and it still doesn't work in a sensible way...
19 # about this and it still doesn't work in a sensible way...
20
20
21 start_dir = os.getcwd()
21 start_dir = os.getcwdu()
22 cd('..')
22 cd('..')
23 git_tpl = 'git archive --format=tar --prefix={0}/ HEAD | gzip > {1}'
23 git_tpl = 'git archive --format=tar --prefix={0}/ HEAD | gzip > {1}'
24 sh(git_tpl.format(base_name, tar_name))
24 sh(git_tpl.format(base_name, tar_name))
General Comments 0
You need to be logged in to leave comments. Login now