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

Expand user dir (~) in file IO

e.g., g.save("~/foo.xml")
parent 8ae75c9f
...@@ -549,6 +549,7 @@ class Graph(object): ...@@ -549,6 +549,7 @@ class Graph(object):
"""Load graph from 'filename' (which can also be a file-like """Load graph from 'filename' (which can also be a file-like
object). The format is guessed from the file name, or can be specified object). The format is guessed from the file name, or can be specified
by 'format', which can be either 'xml' or 'dot'.""" by 'format', which can be either 'xml' or 'dot'."""
filename = os.path.expanduser(filename)
if format == 'auto' and isinstance(filename, str): if format == 'auto' and isinstance(filename, str):
if filename.endswith(".xml") or filename.endswith(".xml.gz") or \ if filename.endswith(".xml") or filename.endswith(".xml.gz") or \
filename.endswith(".xml.bz2"): filename.endswith(".xml.bz2"):
...@@ -577,6 +578,7 @@ class Graph(object): ...@@ -577,6 +578,7 @@ class Graph(object):
def save(self, filename, format="auto"): def save(self, filename, format="auto"):
"""Save graph to file. The format is guessed from the 'file' name, or """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'.""" 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 format == 'auto' and isinstance(filename, str):
if filename.endswith(".xml") or filename.endswith(".xml.gz") or \ if filename.endswith(".xml") or filename.endswith(".xml.gz") or \
filename.endswith(".xml.bz2"): filename.endswith(".xml.bz2"):
......
Supports Markdown
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