/usr/lib64/python2.6/site-packages/numpy/lib
NameSizeModeActions
benchmarks/-0755rm
tests/-0755rm
arraysetops.py137040644editdlrm
arraysetops.pyc133800644editdlrm
arraysetops.pyo133800644editdlrm
arrayterator.py64370644editdlrm
arrayterator.pyc70220644editdlrm
arrayterator.pyo70220644editdlrm
financial.py208720644editdlrm
financial.pyc215460644editdlrm
financial.pyo215460644editdlrm
format.py193090644editdlrm
format.pyc172790644editdlrm
format.pyo172790644editdlrm
function_base.py1005240644editdlrm
function_base.pyc991690644editdlrm
function_base.pyo991690644editdlrm
getlimits.py87900644editdlrm
getlimits.pyc100530644editdlrm
getlimits.pyo100530644editdlrm
index_tricks.py267900644editdlrm
index_tricks.pyc280080644editdlrm
index_tricks.pyo280080644editdlrm
info.py62400644editdlrm
info.pyc64250644editdlrm
info.pyo64250644editdlrm
io.py532260644editdlrm
io.pyc441020644editdlrm
io.pyo441020644editdlrm
machar.py106580644editdlrm
machar.pyc86880644editdlrm
machar.pyo86880644editdlrm
polynomial.py355620644editdlrm
polynomial.pyc381390644editdlrm
polynomial.pyo381390644editdlrm
recfunctions.py320380644editdlrm
recfunctions.pyc294510644editdlrm
recfunctions.pyo294510644editdlrm
scimath.py139970644editdlrm
scimath.pyc158670644editdlrm
scimath.pyo158670644editdlrm
setup.py5880644editdlrm
setup.pyc9180644editdlrm
setup.pyo9180644editdlrm
setupscons.py4700644editdlrm
setupscons.pyc8240644editdlrm
setupscons.pyo8240644editdlrm
shape_base.py243870644editdlrm
shape_base.pyc252910644editdlrm
shape_base.pyo252910644editdlrm
stride_tricks.py39720644editdlrm
stride_tricks.pyc38630644editdlrm
stride_tricks.pyo38630644editdlrm
twodim_base.py229460644editdlrm
twodim_base.pyc254640644editdlrm
twodim_base.pyo254640644editdlrm
type_check.py170750644editdlrm
type_check.pyc183920644editdlrm
type_check.pyo183920644editdlrm
ufunclike.py54520644editdlrm
ufunclike.pyc63110644editdlrm
ufunclike.pyo63110644editdlrm
user_array.py74750644editdlrm
user_array.pyc157270644editdlrm
user_array.pyo157270644editdlrm
utils.py340340644editdlrm
utils.pyc304220644editdlrm
utils.pyo304220644editdlrm
_compiled_base.so197200755editdlrm
_datasource.py206380644editdlrm
_datasource.pyc209860644editdlrm
_datasource.pyo209860644editdlrm
_iotools.py277120644editdlrm
_iotools.pyc269160644editdlrm
_iotools.pyo269160644editdlrm
__init__.py9360644editdlrm
__init__.pyc10380644editdlrm
__init__.pyo10380644editdlrm
Edit: /usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyo (20986B)
Ñò \ÐKc@s‰dZdZddkZddklZdefd„ƒYZeƒZdeid„Z d efd „ƒYZ d e fd „ƒYZ dS( sÚA file interface for handling local and remote data files. The goal of datasource is to abstract some of the file system operations when dealing with data files so the researcher doesn't have to know all the low-level details. Through datasource, a researcher can obtain and use a file with one function call, regardless of location of the file. DataSource is meant to augment standard python libraries, not replace them. It should work seemlessly with standard file IO operations and the os module. DataSource files can originate locally or remotely: - local files : '/home/guido/src/local/data.txt' - URLs (http, ftp, ...) : 'http://www.scipy.org/not/real/data.txt' DataSource files can also be compressed or uncompressed. Currently only gzip and bz2 are supported. Example:: >>> # Create a DataSource, use os.curdir (default) for local storage. >>> ds = datasource.DataSource() >>> >>> # Open a remote file. >>> # DataSource downloads the file, stores it locally in: >>> # './www.google.com/index.html' >>> # opens the file and returns a file object. >>> fp = ds.open('http://www.google.com/index.html') >>> >>> # Use the file as you normally would >>> fp.read() >>> fp.close() srestructuredtext eniÿÿÿÿN(trmtreet _FileOpenerscBs2eZdZd„Zd„Zd„Zd„ZRS(sÞ Container for different methods to open (un-)compressed files. `_FileOpeners` contains a dictionary that holds one method for each supported file format. Attribute lookup is implemented in such a way that an instance of `_FileOpeners` itself can be indexed with the keys of that dictionary. Currently uncompressed files as well as files compressed with ``gzip`` or ``bz2`` compression are supported. Notes ----- `_file_openers`, an instance of `_FileOpeners`, is made available for use in the `_datasource` module. Examples -------- >>> np.lib._datasource._file_openers.keys() [None, '.bz2', '.gz'] >>> np.lib._datasource._file_openers['.gz'] is gzip.open True cCst|_htd6|_dS(N(tFalset_loadedtopentNonet _file_openers(tself((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt__init__Ds c Csˆ|iodSy ddk}|i|id>> repos = DataSource() >>> repos.exists('www.google.com/index.html') False >>> repos.exists('http://www.google.com/index.html') True Temporary directories are deleted when the DataSource is deleted. Examples -------- :: >>> ds = DataSource('/home/guido') >>> urlname = 'http://www.google.com/index.html' >>> gfile = ds.open('http://www.google.com/index.html') # remote file >>> ds.abspath(urlname) '/home/guido/www.google.com/site/index.html' >>> ds = DataSource(None) # use with temporary file >>> ds.open('/home/guido/foobar.txt') >>> ds.abspath('/home/guido/foobar.txt') '/tmp/tmpy4pgsP/home/guido/foobar.txt' cCsQ|o"tii|ƒ|_t|_n%ddk}|iƒ|_t|_dS(s2Create a DataSource with a local path at destpath.iÿÿÿÿN( tosRtabspatht _destpathRt _istmpdestttempfiletmkdtempR (RRR((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyRÃs   cCs|iot|iƒndS(N(RRR(R((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt__del__Ís cCs(tii|ƒ\}}|tiƒjS(sMTest if the filename is a zip file by looking at the file extension. (RRtsplitextRR(Rtfilenametfnametext((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt_iszipÒscCs-d}x |D]}||jotSq WtS(s4Test if the given mode will open a file for writing.twt+(R'R((R R(RRt _writemodestc((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt _iswritemodeØs   cCs/|i|ƒotii|ƒS|dfSdS(sxSplit zip extension from filename and return filename. *Returns*: base, zip_ext : {tuple} N(R&RRR"R(RR#((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt _splitzipextâscCsT|g}|i|ƒp7x4tiƒD]"}|o|i||ƒq&q&Wn|S(s9Return a tuple containing compressed filename variations.(R&RRtappend(RR#tnamestzipext((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt_possible_namesïs  c Cs?ddkl}||ƒ\}}}}}}t|o|ƒS(s=Test if path is a net location. Tests the scheme and netloc.iÿÿÿÿ(turlparse(R1tbool( RRR1tschemetnetloctupathtuparamstuquerytufrag((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt_isurløscCs ddkl}l}|i|ƒ}tiitii|ƒƒptitii|ƒƒn|i |ƒoVy,||ƒ}t |dƒi |i ƒƒWq|j o|d|ƒ‚qXnVy/t |dƒ}t |dƒi |i ƒƒWn#t j ot d|ƒ‚nX|S(shCache the file specified by path. Creates a copy of the file in the datasource cache. iÿÿÿÿ(turlopentURLErrorR'sURL not found: %sRsFile not found: %s(turllib2R:R;RRRtexiststdirnametmakedirsR9tfiletwritetreadtIOError(RRR:R;R5t openedurltfp((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt_caches    cCs·|i|ƒp/|i|ƒ}||i|i|ƒƒ7}n,|i|i|ƒƒ}||i|ƒ}xF|D]>}|i|ƒo(|i|ƒo|i|ƒ}n|SqqWdS(sSearches for ``path`` and returns full path if found. If path is an URL, _findfile will cache a local copy and return the path to the cached file. If path is a local file, _findfile will return a path to that local file. The search will include possible compressed versions of the file and return the first occurence found. N(R9R0RR=RFR(RRtfilelisttname((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt _findfile's  c Cs›ddkl}|i|idƒ}t|ƒdjo|d}n||ƒ\}}}}}} |i|ƒ}|i|ƒ}tii|i||ƒS(sF Return absolute path of file in the DataSource directory. If `path` is an URL, then `abspath` will return either the location the file exists locally or the location it would exist when opened using the `open` method. Parameters ---------- path : str Can be a local file or a remote URL. Returns ------- out : str Complete path, including the `DataSource` destination directory. Notes ----- The functionality is based on `os.path.abspath`. iÿÿÿÿ(R1ii(R1tsplitRtlent_sanitize_relative_pathRRtjoin( RRR1t splitpathR3R4R5R6R7R8((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyRGs cCs…d}tii|ƒ}xf||joX|}|itiƒidƒ}|itiƒidƒ}tii|ƒ\}}qW|S(svReturn a sanitised relative path for which os.path.abspath(os.path.join(base, path)).startswith(base) t/s..N(RRRtnormpathtlstriptseptpardirt splitdrive(RRtlasttdrive((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyRLrs cCs›ddkl}l}tii|ƒotS|i|ƒ}tii|ƒotS|i|ƒo2y||ƒ}~tSWq—|j ot SXnt S(s( Test if path exists. Test if `path` exists as (and in this order): - a local file. - a remote URL that has been downloaded and stored locally in the `DataSource` directory. - a remote URL that has not been downloaded, but is valid and accessible. Parameters ---------- path : str Can be a local file or a remote URL. Returns ------- out : bool True if `path` exists. Notes ----- When `path` is an URL, `exists` will return True if it's either stored locally in the `DataSource` directory, or is a valid remote URL. `DataSource` does not discriminate between the two, the file is accessible if it exists in either location. iÿÿÿÿ(R:R;( R<R:R;RRR=R RR9R(RRR:R;R5tnetfile((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyR=€s  RcCs¥|i|ƒo |i|ƒotdƒ‚n|i|ƒ}|oK|i|ƒ\}}|djo|iddƒnt||d|ƒStd|ƒ‚dS(sR Open and return file-like object. If `path` is an URL, it will be downloaded, stored in the `DataSource` directory and opened from there. Parameters ---------- path : str Local file path or URL to open. mode : {'r', 'w', 'a'}, optional Mode to open `path`. Mode 'r' for reading, 'w' for writing, 'a' to append. Available modes depend on the type of object specified by `path`. Default is 'r'. Returns ------- out : file object File object. sURLs are not writeableR R(tRs %s not found.N(R9R+t ValueErrorRIR,treplaceRRC(RRRtfoundt_fnameR%((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyR´s  (RRRRtcurdirRR!R&R+R,R0R9RFRIRRLR=R(((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyR’s/    +  4t RepositorycBs_eZdZeid„Zd„Zd„Zd„Zd„Z d„Z dd„Z d „Z RS( sý Repository(baseurl, destpath='.') A data repository where multiple DataSource's share a base URL/directory. `Repository` extends `DataSource` by prepending a base URL (or directory) to all the files it handles. Use `Repository` when you will be working with multiple files from one base URL. Initialize `Repository` with the base URL, then refer to each file by its filename only. Parameters ---------- baseurl : str Path to the local directory or remote location that contains the data files. destpath : str or None, optional Path to the directory where the source file gets downloaded to for use. If `destpath` is None, a temporary directory will be created. The default path is the current directory. Examples -------- To analyze all files in the repository, do something like this (note: this is not self-contained code):: >>> repos = np.lib._datasource.Repository('/home/user/data/dir/') >>> for filename in filelist: ... fp = repos.open(filename) ... fp.analyze() ... fp.close() Similarly you could use a URL for a repository:: >>> repos = np.lib._datasource.Repository('http://www.xyz.edu/data') cCs ti|d|ƒ||_dS(s>Create a Repository with a shared url or directory of baseurl.RN(RRt_baseurl(RtbaseurlR((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyRscCsti|ƒdS(N(RR!(R((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyR! scCsN|i|idƒ}t|ƒdjotii|i|ƒ}n|}|S(s>Return complete path for path. Prepends baseurl if necessary.ii(RJR_RKRRRM(RRRNtresult((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt _fullpath s cCsti||i|ƒƒS(s8Extend DataSource method to prepend baseurl to ``path``.(RRIRb(RR((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyRIscCsti||i|ƒƒS(s_ Return absolute path of file in the Repository directory. If `path` is an URL, then `abspath` will return either the location the file exists locally or the location it would exist when opened using the `open` method. Parameters ---------- path : str Can be a local file or a remote URL. This may, but does not have to, include the `baseurl` with which the `Repository` was initialized. Returns ------- out : str Complete path, including the `DataSource` destination directory. (RRRb(RR((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyRscCsti||i|ƒƒS(sÈ Test if path exists prepending Repository base URL to path. Test if `path` exists as (and in this order): - a local file. - a remote URL that has been downloaded and stored locally in the `DataSource` directory. - a remote URL that has not been downloaded, but is valid and accessible. Parameters ---------- path : str Can be a local file or a remote URL. This may, but does not have to, include the `baseurl` with which the `Repository` was initialized. Returns ------- out : bool True if `path` exists. Notes ----- When `path` is an URL, `exists` will return True if it's either stored locally in the `DataSource` directory, or is a valid remote URL. `DataSource` does not discriminate between the two, the file is accessible if it exists in either location. (RR=Rb(RR((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyR=0sRcCsti||i|ƒ|ƒS(sÞ Open and return file-like object prepending Repository base URL. If `path` is an URL, it will be downloaded, stored in the DataSource directory and opened from there. Parameters ---------- path : str Local file path or URL to open. This may, but does not have to, include the `baseurl` with which the `Repository` was initialized. mode : {'r', 'w', 'a'}, optional Mode to open `path`. Mode 'r' for reading, 'w' for writing, 'a' to append. Available modes depend on the type of object specified by `path`. Default is 'r'. Returns ------- out : file object File object. (RRRb(RRR((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyRQscCs4|i|iƒo td‚nti|iƒSdS(s  List files in the source Repository. Returns ------- files : list of str List of file names (not containing a directory part). Notes ----- Does not currently work for remote repositories. s-Directory listing of URLs, not supported yet.N(R9R_tNotImplementedErrorRtlistdir(R((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyRdjs ( RRRRR]RR!RbRIRR=RRd(((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyR^ßs$    ! ( Rt __docformat__RtshutilRtobjectRRR]RRR^(((s;/usr/lib64/python2.6/site-packages/numpy/lib/_datasource.pyt!s ? $ÿN