[Scipy-svn] r3389 - trunk/scipy/io
scipy-svn at scipy.org
scipy-svn at scipy.org
Tue Oct 2 20:06:43 EDT 2007
Author: chris.burns
Date: 2007-10-02 19:06:40 -0500 (Tue, 02 Oct 2007)
New Revision: 3389
Modified:
trunk/scipy/io/datasource.py
Log:
Documentation updates and code refactoring.
Modified: trunk/scipy/io/datasource.py
===================================================================
--- trunk/scipy/io/datasource.py 2007-10-02 09:00:27 UTC (rev 3388)
+++ trunk/scipy/io/datasource.py 2007-10-03 00:06:40 UTC (rev 3389)
@@ -19,7 +19,7 @@
file_openers = {".gz":gzip.open, ".bz2":bz2.BZ2File, None:file}
def iszip(filename):
- """Is filename a zip file.
+ """Test if the given file is a zip file.
*Parameters*:
@@ -37,17 +37,17 @@
return ext in zipexts
def unzip(filename):
- """Unzip filename into another file.
+ """Unzip the given file and return the path object to the new file.
*Parameters*:
- filename : {string}
+ filename : string
Filename to unzip.
*Returns*:
- string
- Name of the unzipped file.
+ path
+ Path object of the unzipped file.
"""
@@ -75,9 +75,11 @@
"""
- return mode.find("w")>-1 or mode.find("+")>-1
+ _writemodes = ("w", "+", "a")
+ for c in mode:
+ if c in _writemodes: return True
+ return False
-
def splitzipext(filename):
"""Return a tuple containing the filename and the zip extension separated.
@@ -105,36 +107,39 @@
def isurl(pathstr):
- """
- Check whether a given string can be parsed as a URL.
+ """Test whether a given string can be parsed as a URL.
- :Parameters:
- `pathstr` : string
+ *Parameters*
+ pathstr : {string}
The string to be checked.
- :Returns: ``bool``
+ *Returns*:
+ bool
+ Results of test.
+
"""
- scheme, netloc, _, _, _, _ = urlparse(pathstr)
+
+ scheme, netloc, _tmp, _tmp, _tmp, _tmp = urlparse(pathstr)
return bool(scheme and netloc)
+def ensuredirs(directory):
+ """Ensure that the given directory path actually exists.
+ If the directory does not exist, it is created.
+ *Parameters*:
+ directory : {path object}
+
+ *Returns*:
+ None
-def ensuredirs(directory):
"""
- Ensure that the given directory path actually exists.
- If it doesn't, create it.
- :Returns: ``None``
- """
if not isinstance(directory, path):
directory = path(directory)
if not directory.exists():
directory.makedirs()
-
-
-
class Cache (object):
"""A file cache.
More information about the Scipy-svn
mailing list