관리-도구
편집 파일: _datasource.cpython-37.pyc
B ��FdS � @ s~ d Z ddlmZmZmZ ddlZddlZddlZeZ G dd� de �Ze� Zdej fdd�ZG d d � d e �ZG dd� de�ZdS ) a� 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 seamlessly 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() � )�division�absolute_import�print_functionNc @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd S )�_FileOpenersa� 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 c C s d| _ d ti| _d S )NF)�_loaded�open� _file_openers)�self� r �H/opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/_datasource.py�__init__J s z_FileOpeners.__init__c C sp | j r d S ydd l}|j| jd<