Show More
@@ -3,26 +3,15 b'' | |||
|
3 | 3 | Note: this module is named 'osm' instead of 'os' to avoid a collision with the |
|
4 | 4 | builtin. |
|
5 | 5 | """ |
|
6 | #----------------------------------------------------------------------------- | |
|
7 | # Copyright (c) 2012 The IPython Development Team. | |
|
8 | # | |
|
9 | # Distributed under the terms of the Modified BSD License. | |
|
10 | # | |
|
11 | # The full license is in the file COPYING.txt, distributed with this software. | |
|
12 | #----------------------------------------------------------------------------- | |
|
13 | ||
|
14 | #----------------------------------------------------------------------------- | |
|
15 | # Imports | |
|
16 | #----------------------------------------------------------------------------- | |
|
17 | ||
|
18 | # Stdlib | |
|
6 | # Copyright (c) IPython Development Team. | |
|
7 | # Distributed under the terms of the Modified BSD License. | |
|
8 | ||
|
19 | 9 | import io |
|
20 | 10 | import os |
|
21 | 11 | import re |
|
22 | 12 | import sys |
|
23 | 13 | from pprint import pformat |
|
24 | 14 | |
|
25 | # Our own packages | |
|
26 | 15 | from IPython.core import magic_arguments |
|
27 | 16 | from IPython.core import oinspect |
|
28 | 17 | from IPython.core import page |
@@ -37,9 +26,7 b' from IPython.utils.process import abbrev_cwd' | |||
|
37 | 26 | from IPython.utils import py3compat |
|
38 | 27 | from IPython.utils.terminal import set_term_title |
|
39 | 28 | |
|
40 | #----------------------------------------------------------------------------- | |
|
41 | # Magic implementation classes | |
|
42 | #----------------------------------------------------------------------------- | |
|
29 | ||
|
43 | 30 | @magics_class |
|
44 | 31 | class OSMagics(Magics): |
|
45 | 32 | """Magics to interact with the underlying OS (shell-type functionality). |
@@ -239,7 +226,10 b' class OSMagics(Magics):' | |||
|
239 | 226 | In [9]: pwd |
|
240 | 227 | Out[9]: '/home/tsuser/sprint/ipython' |
|
241 | 228 | """ |
|
242 | return os.getcwd() | |
|
229 | try: | |
|
230 | return os.getcwd() | |
|
231 | except FileNotFoundError: | |
|
232 | raise UsageError("CWD no longer exists - please use %cd to change directory.") | |
|
243 | 233 | |
|
244 | 234 | @skip_doctest |
|
245 | 235 | @line_magic |
@@ -283,7 +273,12 b' class OSMagics(Magics):' | |||
|
283 | 273 | /home/tsuser/parent/child |
|
284 | 274 | """ |
|
285 | 275 | |
|
286 | oldcwd = os.getcwd() | |
|
276 | try: | |
|
277 | oldcwd = os.getcwd() | |
|
278 | except FileNotFoundError: | |
|
279 | # Happens if the CWD has been deleted. | |
|
280 | oldcwd = None | |
|
281 | ||
|
287 | 282 | numcd = re.match(r'(-)(\d+)$',parameter_s) |
|
288 | 283 | # jump in directory history by number |
|
289 | 284 | if numcd: |
General Comments 0
You need to be logged in to leave comments.
Login now