/usr/local/lib/python3.6/site-packages/fsspec/implementations/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/fsspec/implementations/__pycache__/http.cpython-36.pyc (20752B)
3
8%Egd @ sX d dl mZmZmZ d dlZd dlZd dlZd dlZd dlZd dl m Z d dl
mZ d dlZd dl
Z
d dlmZmZmZ d dlmZ d dlmZ d dlmZ d d lmZmZmZ d
dlmZ ejdZejd
Z ej!dZ"dd Z#G dd deZ$G dd deZ%d#ddZ&ejdZ'dd Z(G dd deZ)d$ddZ*d%dd Z+d&d!d"Z,ee,Z-dS )' )absolute_importdivisionprint_functionN)copy)urlparse)AsyncFileSystemsyncsync_wrapper)_DEFAULT_CALLBACK)FSTimeoutError)AbstractBufferedFile)DEFAULT_BLOCK_SIZEnullcontexttokenize )AllBytesz6<(a|A)\s+(?:[^>]*?\s+)?(href|HREF)=["'](?P
[^"']+)z-(?Phttp[s]?://[-a-zA-Z0-9@:%_+.~#?&/=]+)zfsspec.httpc s t jf | S )N)aiohttpZ
ClientSession)kwargs r E/usr/local/lib/python3.6/site-packages/fsspec/implementations/http.py
get_client s r c
s e Zd ZdZdZdddddddddef
fdd Zed d
Zdd Z e
d
d Ze
fddZd0ddZ
d1ddZeeZdd Zd2ddZd4efddZd6edfdd Zd!d" Zd#d$ Zd7d&d'Zd(d) Zd*d+ Zd,d- Zd.d/ Z ZS )8HTTPFileSystema2
Simple File-System for fetching data via HTTP(S)
``ls()`` is implemented by loading the parent page and doing a regex
match on the result. If simple_link=True, anything of the form
"http(s)://server.com/stuff?thing=other"; otherwise only links within
HTML href tags will be used.
/TNbytesFc
s t j| f||d| |dk r&|nt| _|| _|| _|| _|| _| pJi | _|
| _ || _
d| _t|}|j
dd| _|j
dd |j
dd |j
dd || _
|st| j| j dS )a
NB: if this is called async, you must await set_client
Parameters
----------
block_size: int
Blocks to read bytes; if 0, will default to raw requests file-like
objects instead of HTTPFile instances
simple_links: bool
If True, will consider both HTML tags and anything that looks
like a URL; if False, will consider only the former.
same_scheme: True
When doing ls/glob, if this is True, only consider paths that have
http/https matching the input URLs.
size_policy: this argument is deprecated
client_kwargs: dict
Passed to aiohttp.ClientSession, see
https://docs.aiohttp.org/en/stable/client_reference.html
For example, ``{'auth': aiohttp.BasicAuth('user', 'pass')}``
get_client: Callable[..., aiohttp.ClientSession]
A callable which takes keyword arguments and constructs
an aiohttp.ClientSession. It's state will be managed by
the HTTPFileSystem class.
storage_options: key-value
Any other parameters passed on to requests
cache_type, cache_options: defaults used in open
)asynchronousloopNuse_listings_cacheFZlistings_expiry_timeZ max_pathsZskip_instance_cache)super__init__r
block_sizesimple_linkssame_schema
cache_type
cache_options
client_kwargsr r _sessionr popr r r set_session)
selfr r Zsame_schemesize_policyr" r# r r r$ r Zstorage_optionsZrequest_options) __class__r r r , s$ )
zHTTPFileSystem.__init__c C s^ | d k r>| j r>yt| |jdd d S ttfk
r< Y nX t|dd }|d k rZ|j d S )Ng?)timeoutZ
_connector)
is_runningr closeTimeoutErrorr getattr_close)r sessionZ connectorr r r
close_sessionn s zHTTPFileSystem.close_sessionc sL | j d krF| jf d| ji| jI d H | _ | jsFtj| | j| j| j | j S )Nr )r% r r r$ r weakreffinalizer2 )r( r r r r' { s
zHTTPFileSystem.set_sessionc C s |S )z-For HTTP, we always want to keep the full URLr )clspathr r r _strip_protocol s zHTTPFileSystem._strip_protocolc s t j|}t|dkr|S dS )N )r _parentlen)r5 r6 par)r* r r r: s zHTTPFileSystem._parentc
s | j j }|j| tj| | j I d H }|j|f| j 4 I d H }| j|| |j I d H }W d Q I d H R X | j rt
j|dd tj|D }ndd tj|D }t
} t|}
x|D ]}t|tr|d }|jdrt|dkr|
jd |
j | }|jdrf| jr4|j|jdd r4| j| n0|jddj|jddjdd r| j| q|dkr| jdj|jd|jdg qW | r|jdr| j|jdddI d H } |rd
d | D S tt| S | S )Nc S s g | ]}|d qS )r r ).0ur r r