Commit 64018e6f authored by Tiago Peixoto's avatar Tiago Peixoto

Expand user dir (~) in file IO

e.g., g.save("~/foo.xml")
parent 8ae75c9f
......@@ -549,6 +549,7 @@ class Graph(object):
"""Load graph from 'filename' (which can also be a file-like
object). The format is guessed from the file name, or can be specified
by 'format', which can be either 'xml' or 'dot'."""
filename = os.path.expanduser(filename)
if format == 'auto' and isinstance(filename, str):
if filename.endswith(".xml") or filename.endswith(".xml.gz") or \
filename.endswith(".xml.bz2"):
......@@ -577,6 +578,7 @@ class Graph(object):
def save(self, filename, format="auto"):
"""Save graph to file. The format is guessed from the 'file' name, or
can be specified by 'format', which can be either 'xml' or 'dot'."""
filename = os.path.expanduser(filename)
if format == 'auto' and isinstance(filename, str):
if filename.endswith(".xml") or filename.endswith(".xml.gz") or \
filename.endswith(".xml.bz2"):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment