File: //usr/local/lib/python3.6/site-packages/feedparser/__pycache__/api.cpython-36.pyc
3
_9js, � @ s0 d dl Z d dlZd dlZd dlZddlmZmZ ddl m
Z
ddlT ddlm
Z
ddlmZ ddlmZ dd lmZ dd
lmZ ddlmZ ddlmZ ddlT dd
lmZmZ ddlmZ dgZdZdddddddddddddddd d!�Z d"d#� Z!e"d$eee
e#fi �Z$e"d%eeej%j&j'e#fi �Z(d(d&d'�Z)dS ))� N� )�registerDateHandler�_parse_date)�convert_to_utf8)�*)�_BaseHTMLProcessor)�http)�mixin)�_FeedParserMixin)�_LooseFeedParser)�_StrictFeedParser)�replace_doctype)�convert_to_idn�make_safe_absolute_uri)�FeedParserDictZdrv_libxml2T�unknownzRSS 0.90zRSS 0.91 (Netscape)zRSS 0.91 (Userland)zRSS 0.92zRSS 0.93zRSS 0.94zRSS 2.0zRSS 1.0zRSS (unknown version)zAtom 0.1zAtom 0.2zAtom 0.3zAtom 1.0zAtom (unknown version)ZCDF)� Zrss090Zrss091nZrss091uZrss092Zrss093Zrss094Zrss20Zrss10ZrssZatom01Zatom02Zatom03Zatom10ZatomZcdfc
C s� t | d�r| j� S t| t�rHtjj| �d dkrHtj| |||||||�S y"t | d��}|j� } W d Q R X W n t
ttt
fk
r� Y nX | S t| t�s�| jd
�S | S )aE URL, filename, or string --> stream
This function lets you define parsers that take any input source
(URL, pathname to local or network file, or actual data as a string)
and deal with it in a uniform manner. Returned object is guaranteed
to have all the basic stdio read methods (read, readline, readlines).
Just .close() the object when you're done with it.
If the etag argument is supplied, it will be used as the value of an
If-None-Match request header.
If the modified argument is supplied, it can be a tuple of 9 integers
(as returned by gmtime() in the standard Python time module) or a date
string in any format supported by feedparser. Regardless, it MUST
be in GMT (Greenwich Mean Time). It will be reformatted into an
RFC 1123-compliant date and used as the value of an If-Modified-Since
request header.
If the agent argument is supplied, it will be used as the value of a
User-Agent request header.
If the referrer argument is supplied, it will be used as the value of a
Referer[sic] request header.
If handlers is supplied, it is a list of handlers used to build a
urllib2 opener.
if request_headers is supplied it is a dictionary of HTTP request headers
that will override the values generated by FeedParser.
:return: A bytes object.
�readr r �https�ftp�file�feed�rbNzutf-8)r r r r r )�hasattrr �
isinstance�str�urllib�parse�urlparser �get�open�IOError�UnicodeEncodeError� TypeError�
ValueError�bytes�encode)
�url_file_stream_or_string�etag�modified�agent�referrer�handlers�request_headers�result�f�data� r1 �8/usr/local/lib/python3.6/site-packages/feedparser/api.py�_open_resourceL s "
r3 �LooseFeedParser�StrictFeedParserc
) C s� | s| dks|dkrddl }
|s(|
j}| dkr6|
j} |dkrD|
j}tdg t� i d�}yt| |||||||�}W n4 tjjk
r� }
z|j d|
d�� |S d}
~
X nX |s�|S |d j |p�i � t
|d ||�}|d r�dp�d}t|�\|d <