##// END OF EJS Templates
rename py3compat.getcwd() -> os.getcwd()
Srinivas Reddy Thatiparthy -
Show More
@@ -126,7 +126,7 b' class BaseIPythonApplication(Application):'
126 config_file_paths = List(Unicode())
126 config_file_paths = List(Unicode())
127 @default('config_file_paths')
127 @default('config_file_paths')
128 def _config_file_paths_default(self):
128 def _config_file_paths_default(self):
129 return [py3compat.getcwd()]
129 return [os.getcwd()]
130
130
131 extra_config_file = Unicode(
131 extra_config_file = Unicode(
132 help="""Path to an extra config file to load.
132 help="""Path to an extra config file to load.
@@ -215,7 +215,7 b' class BaseIPythonApplication(Application):'
215 super(BaseIPythonApplication, self).__init__(**kwargs)
215 super(BaseIPythonApplication, self).__init__(**kwargs)
216 # ensure current working directory exists
216 # ensure current working directory exists
217 try:
217 try:
218 py3compat.getcwd()
218 os.getcwd()
219 except:
219 except:
220 # exit if cwd doesn't exist
220 # exit if cwd doesn't exist
221 self.log.error("Current working directory doesn't exist.")
221 self.log.error("Current working directory doesn't exist.")
@@ -487,7 +487,7 b' class HistoryManager(HistoryAccessor):'
487 @default('dir_hist')
487 @default('dir_hist')
488 def _dir_hist_default(self):
488 def _dir_hist_default(self):
489 try:
489 try:
490 return [py3compat.getcwd()]
490 return [os.getcwd()]
491 except OSError:
491 except OSError:
492 return []
492 return []
493
493
@@ -593,7 +593,7 b' class HistoryManager(HistoryAccessor):'
593 optionally open a new session."""
593 optionally open a new session."""
594 self.output_hist.clear()
594 self.output_hist.clear()
595 # The directory history can't be completely empty
595 # The directory history can't be completely empty
596 self.dir_hist[:] = [py3compat.getcwd()]
596 self.dir_hist[:] = [os.getcwd()]
597
597
598 if new_session:
598 if new_session:
599 if self.session_number:
599 if self.session_number:
@@ -549,7 +549,7 b' class InteractiveShell(SingletonConfigurable):'
549
549
550 # keep track of where we started running (mainly for crash post-mortem)
550 # keep track of where we started running (mainly for crash post-mortem)
551 # This is not being used anywhere currently.
551 # This is not being used anywhere currently.
552 self.starting_dir = py3compat.getcwd()
552 self.starting_dir = os.getcwd()
553
553
554 # Indentation management
554 # Indentation management
555 self.indent_current_nsp = 0
555 self.indent_current_nsp = 0
@@ -177,7 +177,7 b' class OSMagics(Magics):'
177 winext += '|py'
177 winext += '|py'
178 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
178 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
179 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
179 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
180 savedir = py3compat.getcwd()
180 savedir = os.getcwd()
181
181
182 # Now walk the paths looking for executables to alias.
182 # Now walk the paths looking for executables to alias.
183 try:
183 try:
@@ -239,7 +239,7 b' class OSMagics(Magics):'
239 In [9]: pwd
239 In [9]: pwd
240 Out[9]: '/home/tsuser/sprint/ipython'
240 Out[9]: '/home/tsuser/sprint/ipython'
241 """
241 """
242 return py3compat.getcwd()
242 return os.getcwd()
243
243
244 @skip_doctest
244 @skip_doctest
245 @line_magic
245 @line_magic
@@ -283,7 +283,7 b' class OSMagics(Magics):'
283 /home/tsuser/parent/child
283 /home/tsuser/parent/child
284 """
284 """
285
285
286 oldcwd = py3compat.getcwd()
286 oldcwd = os.getcwd()
287 numcd = re.match(r'(-)(\d+)$',parameter_s)
287 numcd = re.match(r'(-)(\d+)$',parameter_s)
288 # jump in directory history by number
288 # jump in directory history by number
289 if numcd:
289 if numcd:
@@ -351,7 +351,7 b' class OSMagics(Magics):'
351 except OSError:
351 except OSError:
352 print(sys.exc_info()[1])
352 print(sys.exc_info()[1])
353 else:
353 else:
354 cwd = py3compat.getcwd()
354 cwd = os.getcwd()
355 dhist = self.shell.user_ns['_dh']
355 dhist = self.shell.user_ns['_dh']
356 if oldcwd != cwd:
356 if oldcwd != cwd:
357 dhist.append(cwd)
357 dhist.append(cwd)
@@ -361,7 +361,7 b' class OSMagics(Magics):'
361 os.chdir(self.shell.home_dir)
361 os.chdir(self.shell.home_dir)
362 if hasattr(self.shell, 'term_title') and self.shell.term_title:
362 if hasattr(self.shell, 'term_title') and self.shell.term_title:
363 set_term_title('IPython: ' + '~')
363 set_term_title('IPython: ' + '~')
364 cwd = py3compat.getcwd()
364 cwd = os.getcwd()
365 dhist = self.shell.user_ns['_dh']
365 dhist = self.shell.user_ns['_dh']
366
366
367 if oldcwd != cwd:
367 if oldcwd != cwd:
@@ -436,7 +436,7 b' class OSMagics(Magics):'
436
436
437 dir_s = self.shell.dir_stack
437 dir_s = self.shell.dir_stack
438 tgt = os.path.expanduser(parameter_s)
438 tgt = os.path.expanduser(parameter_s)
439 cwd = py3compat.getcwd().replace(self.shell.home_dir,'~')
439 cwd = os.getcwd().replace(self.shell.home_dir,'~')
440 if tgt:
440 if tgt:
441 self.cd(parameter_s)
441 self.cd(parameter_s)
442 dir_s.insert(0,cwd)
442 dir_s.insert(0,cwd)
@@ -724,7 +724,7 b' class OSMagics(Magics):'
724 if not args:
724 if not args:
725 raise UsageError("%bookmark: You must specify the bookmark name")
725 raise UsageError("%bookmark: You must specify the bookmark name")
726 elif len(args)==1:
726 elif len(args)==1:
727 bkms[args[0]] = py3compat.getcwd()
727 bkms[args[0]] = os.getcwd()
728 elif len(args)==2:
728 elif len(args)==2:
729 bkms[args[0]] = args[1]
729 bkms[args[0]] = args[1]
730 self.shell.db['bookmarks'] = bkms
730 self.shell.db['bookmarks'] = bkms
@@ -180,10 +180,10 b' class ProfileList(Application):'
180 print("Available profiles in %s:" % self.ipython_dir)
180 print("Available profiles in %s:" % self.ipython_dir)
181 self._print_profiles(profiles)
181 self._print_profiles(profiles)
182
182
183 profiles = list_profiles_in(py3compat.getcwd())
183 profiles = list_profiles_in(os.getcwd())
184 if profiles:
184 if profiles:
185 print()
185 print()
186 print("Available profiles in current directory (%s):" % py3compat.getcwd())
186 print("Available profiles in current directory (%s):" % os.getcwd())
187 self._print_profiles(profiles)
187 self._print_profiles(profiles)
188
188
189 print()
189 print()
@@ -187,7 +187,7 b' class ProfileDir(LoggingConfigurable):'
187 is not found, a :class:`ProfileDirError` exception will be raised.
187 is not found, a :class:`ProfileDirError` exception will be raised.
188
188
189 The search path algorithm is:
189 The search path algorithm is:
190 1. ``py3compat.getcwd()``
190 1. ``os.getcwd()``
191 2. ``ipython_dir``
191 2. ``ipython_dir``
192
192
193 Parameters
193 Parameters
@@ -199,7 +199,7 b' class ProfileDir(LoggingConfigurable):'
199 will be "profile_<profile>".
199 will be "profile_<profile>".
200 """
200 """
201 dirname = u'profile_' + name
201 dirname = u'profile_' + name
202 paths = [py3compat.getcwd(), ipython_dir]
202 paths = [os.getcwd(), ipython_dir]
203 for p in paths:
203 for p in paths:
204 profile_dir = os.path.join(p, dirname)
204 profile_dir = os.path.join(p, dirname)
205 if os.path.isdir(profile_dir):
205 if os.path.isdir(profile_dir):
@@ -19,9 +19,9 b' def test_unicode_cwd():'
19 """Check that IPython starts with non-ascii characters in the path."""
19 """Check that IPython starts with non-ascii characters in the path."""
20 wd = tempfile.mkdtemp(suffix=u"€")
20 wd = tempfile.mkdtemp(suffix=u"€")
21
21
22 old_wd = py3compat.getcwd()
22 old_wd = os.getcwd()
23 os.chdir(wd)
23 os.chdir(wd)
24 #raise Exception(repr(py3compat.getcwd()))
24 #raise Exception(repr(os.getcwd()))
25 try:
25 try:
26 app = BaseIPythonApplication()
26 app = BaseIPythonApplication()
27 # The lines below are copied from Application.initialize()
27 # The lines below are copied from Application.initialize()
@@ -41,7 +41,7 b' class Test_magic_run_completer(unittest.TestCase):'
41 for d in self.dirs:
41 for d in self.dirs:
42 os.mkdir(join(self.BASETESTDIR, d))
42 os.mkdir(join(self.BASETESTDIR, d))
43
43
44 self.oldpath = py3compat.getcwd()
44 self.oldpath = os.getcwd()
45 os.chdir(self.BASETESTDIR)
45 os.chdir(self.BASETESTDIR)
46
46
47 def tearDown(self):
47 def tearDown(self):
@@ -94,7 +94,7 b' class Test_magic_run_completer_nonascii(unittest.TestCase):'
94 for fil in [u"aaø.py", u"a.py", u"b.py"]:
94 for fil in [u"aaø.py", u"a.py", u"b.py"]:
95 with open(join(self.BASETESTDIR, fil), "w") as sfile:
95 with open(join(self.BASETESTDIR, fil), "w") as sfile:
96 sfile.write("pass\n")
96 sfile.write("pass\n")
97 self.oldpath = py3compat.getcwd()
97 self.oldpath = os.getcwd()
98 os.chdir(self.BASETESTDIR)
98 os.chdir(self.BASETESTDIR)
99
99
100 def tearDown(self):
100 def tearDown(self):
@@ -485,7 +485,7 b' class TestSafeExecfileNonAsciiPath(unittest.TestCase):'
485 os.mkdir(self.TESTDIR)
485 os.mkdir(self.TESTDIR)
486 with open(join(self.TESTDIR, u"åäötestscript.py"), "w") as sfile:
486 with open(join(self.TESTDIR, u"åäötestscript.py"), "w") as sfile:
487 sfile.write("pass\n")
487 sfile.write("pass\n")
488 self.oldpath = py3compat.getcwd()
488 self.oldpath = os.getcwd()
489 os.chdir(self.TESTDIR)
489 os.chdir(self.TESTDIR)
490 self.fname = u"åäötestscript.py"
490 self.fname = u"åäötestscript.py"
491
491
@@ -393,9 +393,9 b' def test_parse_options():'
393
393
394 def test_dirops():
394 def test_dirops():
395 """Test various directory handling operations."""
395 """Test various directory handling operations."""
396 # curpath = lambda :os.path.splitdrive(py3compat.getcwd())[1].replace('\\','/')
396 # curpath = lambda :os.path.splitdrive(os.getcwd())[1].replace('\\','/')
397 curpath = py3compat.getcwd
397 curpath = os.getcwd
398 startdir = py3compat.getcwd()
398 startdir = os.getcwd()
399 ipdir = os.path.realpath(_ip.ipython_dir)
399 ipdir = os.path.realpath(_ip.ipython_dir)
400 try:
400 try:
401 _ip.magic('cd "%s"' % ipdir)
401 _ip.magic('cd "%s"' % ipdir)
@@ -408,7 +408,7 b' class TestMagicRunWithPackage(unittest.TestCase):'
408 self.value = int(random.random() * 10000)
408 self.value = int(random.random() * 10000)
409
409
410 self.tempdir = TemporaryDirectory()
410 self.tempdir = TemporaryDirectory()
411 self.__orig_cwd = py3compat.getcwd()
411 self.__orig_cwd = os.getcwd()
412 sys.path.insert(0, self.tempdir.name)
412 sys.path.insert(0, self.tempdir.name)
413
413
414 self.writefile(os.path.join(package, '__init__.py'), '')
414 self.writefile(os.path.join(package, '__init__.py'), '')
@@ -53,7 +53,7 b' class AvoidUNCPath(object):'
53 os.system(cmd)
53 os.system(cmd)
54 """
54 """
55 def __enter__(self):
55 def __enter__(self):
56 self.path = py3compat.getcwd()
56 self.path = os.getcwd()
57 self.is_unc_path = self.path.startswith(r"\\")
57 self.is_unc_path = self.path.startswith(r"\\")
58 if self.is_unc_path:
58 if self.is_unc_path:
59 # change to c drive (as cmd.exe cannot handle UNC addresses)
59 # change to c drive (as cmd.exe cannot handle UNC addresses)
@@ -173,7 +173,7 b' class AvoidUNCPath(object):'
173 os.system(cmd)
173 os.system(cmd)
174 """
174 """
175 def __enter__(self):
175 def __enter__(self):
176 self.path = py3compat.getcwd()
176 self.path = os.getcwd()
177 self.is_unc_path = self.path.startswith(r"\\")
177 self.is_unc_path = self.path.startswith(r"\\")
178 if self.is_unc_path:
178 if self.is_unc_path:
179 # change to c drive (as cmd.exe cannot handle UNC addresses)
179 # change to c drive (as cmd.exe cannot handle UNC addresses)
@@ -158,7 +158,7 b' def filefind(filename, path_dirs=None):'
158 path_dirs = (path_dirs,)
158 path_dirs = (path_dirs,)
159
159
160 for path in path_dirs:
160 for path in path_dirs:
161 if path == '.': path = py3compat.getcwd()
161 if path == '.': path = os.getcwd()
162 testname = expand_path(os.path.join(path, filename))
162 testname = expand_path(os.path.join(path, filename))
163 if os.path.isfile(testname):
163 if os.path.isfile(testname):
164 return os.path.abspath(testname)
164 return os.path.abspath(testname)
@@ -52,7 +52,7 b' def find_cmd(cmd):'
52
52
53 def abbrev_cwd():
53 def abbrev_cwd():
54 """ Return abbreviated version of cwd, e.g. d:mydir """
54 """ Return abbreviated version of cwd, e.g. d:mydir """
55 cwd = py3compat.getcwd().replace('\\','/')
55 cwd = os.getcwd().replace('\\','/')
56 drivepart = ''
56 drivepart = ''
57 tail = cwd
57 tail = cwd
58 if sys.platform == 'win32':
58 if sys.platform == 'win32':
@@ -93,7 +93,7 b" elif sys.platform == 'win32':"
93
93
94 try:
94 try:
95 # Cannot be on network share when issuing system commands
95 # Cannot be on network share when issuing system commands
96 curr = py3compat.getcwd()
96 curr = os.getcwd()
97 os.chdir("C:")
97 os.chdir("C:")
98 ret = os.system("title " + title)
98 ret = os.system("title " + title)
99 finally:
99 finally:
@@ -356,7 +356,7 b' class TestShellGlob(object):'
356 @classmethod
356 @classmethod
357 @contextmanager
357 @contextmanager
358 def in_tempdir(cls):
358 def in_tempdir(cls):
359 save = py3compat.getcwd()
359 save = os.getcwd()
360 try:
360 try:
361 os.chdir(cls.tempdir.name)
361 os.chdir(cls.tempdir.name)
362 yield
362 yield
General Comments 0
You need to be logged in to leave comments. Login now