Skip to content

Commit

Permalink
Merge pull request #3317 from minrk/fwrite
Browse files Browse the repository at this point in the history
Rename `%%file` to `%%writefile`, leaving `%%file` as an alias for backwards compatibility.
  • Loading branch information
fperez committed May 15, 2013
2 parents d7f1ab1 + c2f1374 commit b7cb333
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions IPython/core/interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -2055,11 +2055,14 @@ def init_magics(self):

# Register Magic Aliases
mman = self.magics_manager
# FIXME: magic aliases should be defined by the Magics classes
# or in MagicsManager, not here
mman.register_alias('ed', 'edit')
mman.register_alias('hist', 'history')
mman.register_alias('rep', 'recall')
mman.register_alias('SVG', 'svg', 'cell')
mman.register_alias('HTML', 'html', 'cell')
mman.register_alias('file', 'writefile', 'cell')

# FIXME: Move the color initialization to the DisplayHook, which
# should be split into a prompt manager and displayhook. We probably
Expand Down
4 changes: 2 additions & 2 deletions IPython/core/magics/osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,12 @@ def pycat(self, parameter_s=''):
help='file to write'
)
@cell_magic
def file(self, line, cell):
def writefile(self, line, cell):
"""Write the contents of the cell to a file.
The file will be overwritten unless the -a (--append) flag is specified.
"""
args = magic_arguments.parse_argstring(self.file, line)
args = magic_arguments.parse_argstring(self.writefile, line)
filename = os.path.expanduser(unquote_filename(args.filename))

if os.path.exists(filename):
Expand Down

0 comments on commit b7cb333

Please sign in to comment.