Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/wikipedia/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/wikipedia/__pycache__/wikipedia.cpython-312.pyc

�

(ٜg6P��D�ddlmZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZmZm
Z
mZmZmZddlmZmZmZddlZd	ad
adadadad�Zd
�Zed��fd�Zedd��Zedd��Zed��Z dd�Z!edd��Z"d d�Z#Gd�de$�Z%ed��Z&d�Z'd�Z(y)!�)�unicode_literalsN)�
BeautifulSoup)�datetime�	timedelta)�Decimal�)�	PageError�DisambiguationError�
RedirectError�HTTPTimeoutError�WikipediaException�ODD_ERROR_MESSAGE)�cache�
stdout_encode�debugz!http://en.wikipedia.org/w/api.phpFz3wikipedia (https://github.com/goldsmith/Wikipedia/)c�|�d|j�zdzatttfD]}|j��y)a~
  Change the language of the API being requested.
  Set `prefix` to one of the two letter prefixes found on the `list of all Wikipedias <http://meta.wikimedia.org/wiki/List_of_Wikipedias>`_.

  After setting the language, the cache for ``search``, ``suggest``, and ``summary`` will be cleared.

  .. note:: Make sure you search for page titles in the language that you have set.
  zhttp://z.wikipedia.org/w/api.phpN)�lower�API_URL�search�suggest�summary�clear_cache)�prefix�cached_funcs  �>/usr/local/lib/python3.12/site-packages/wikipedia/wikipedia.py�set_langrs7��
�����&�)C�C�'��g�w�/�k�����0�c��|ay)z�
  Set the User-Agent string to be used for all requests.

  Arguments:

  * user_agent_string - (string) a string specifying the User-Agent header
  N)�
USER_AGENT)�user_agent_strings r�set_user_agentr!&s	��!�*r�2)�millisecondsc��|a|sdaday|aday)a�
  Enable or disable rate limiting on requests to the Mediawiki servers.
  If rate limiting is not enabled, under some circumstances (depending on
  load on Wikipedia, the number of requests you and other `wikipedia` users
  are making, and other factors), Wikipedia may return an HTTP timeout error.

  Enabling rate limiting generally prevents that issue, but please note that
  HTTPTimeoutError still might be raised.

  Arguments:

  * rate_limit - (Boolean) whether to enable rate limiting or not

  Keyword arguments:

  * min_wait - if rate limiting is enabled, `min_wait` is a timedelta describing the minimum time to wait before requests.
         Defaults to timedelta(milliseconds=50)
  N)�
RATE_LIMIT�RATE_LIMIT_MIN_WAIT�RATE_LIMIT_LAST_CALL)�
rate_limit�min_waits  r�set_rate_limitingr*2s(��.�*�	�����#���rc�0�dd|||d�}|rd|d<t|�}d|vr&|dddvrt|��t|dd��d	�|d
dD�}|r7|d
jd�rt	|�|d
ddfSt	|�dfSt	|�S)
z�
  Do a Wikipedia search for `query`.

  Keyword arguments:

  * results - the maxmimum number of results returned
  * suggestion - if True, return results and suggestion (if any) in a tuple
  r�)�list�srprop�srlimit�limit�srsearch�
suggestion�srinfo�error�info�zHTTP request timed out.zPool queue is fullc3�&K�|]	}|d���y�w��titleN���.0�ds  r�	<genexpr>zsearch.<locals>.<genexpr>os����G�(F�1�A�g�J�(F����query�
searchinfoN)�
_wiki_requestrr
�getr-)r@�resultsr2�
search_params�raw_results�search_resultss      rrrRs���
���
���-��*�M�(���m�,�+�����7��F�#�'X�X��U�#�#��{�7�3�F�;�<�<�G��G�(<�X�(F�G�.���7�����-�
�.�
!�;�w�#7��#E�l�#S�
S�S�
�.�
!�4�
'�'�	
�n�	�rc�n�d|dj||�|d�}|r||d<t|�}d|vr6|dddvrtdj||���t|dd��|dj	d	d
�}|r"d�|j�D�}t
|�Sd�|ddD�}t
|�S)
a�
  Do a wikipedia geo search for `latitude` and `longitude`
  using HTTP API described in http://www.mediawiki.org/wiki/Extension:GeoData

  Arguments:

  * latitude (float or decimal.Decimal)
  * longitude (float or decimal.Decimal)

  Keyword arguments:

  * title - The title of an article to search for
  * results - the maximum number of results returned
  * radius - Search radius in meters. The value must be between 10 and 10000
  �	geosearchz{0}|{1})r-�gsradius�gscoord�gslimit�titlesr4r5r6r@�pagesNc3�8K�|]\}}|dk7s�|d���y�w)z-1r9Nr:)r<�k�vs   rr>zgeosearch.<locals>.<genexpr>�s!����O�-A�T�Q��Q�$�Y�a��j�-A�s�
�
c3�&K�|]	}|d���y�wr8r:r;s  rr>zgeosearch.<locals>.<genexpr>�s����L�*K�Q�a��j�*K�r?)�formatrBrr
rC�itemsr-)	�latitude�	longituder9rD�radiusrErF�search_pagesrGs	         rrIrIzs���&
������)�4��	�-��#�M�(���m�,�+�����7��F�#�'X�X��Y�-�-�h�	�B�C�C��{�7�3�F�;�<�<��W�%�)�)�'�4�8�,��O�\�-?�-?�-A�O�N�
�n�	��M�+�g�*>�{�*K�L�N�	
�n�	�rc�n�dddd�}||d<t|�}|djd�r|dddSy)	zk
  Get a Wikipedia search suggestion for `query`.
  Returns a string or None if no suggestion was found.
  rr2r,)r-r3r.r1r@rAN)rBrC)r@rE�
raw_results   rrr�sU��
����-�
$�-�
���]�+�*������\�*��g��|�,�\�:�:�	
rc��dd|d�}t|�}|ddD�cgc]}|d��	}}t|�dk(r|dS|Scc}w)z�
  Get a list of random Wikipedia article titles.

  .. note:: Random only gets articles from namespace 0, meaning no Category, User talk, or other meta-Wikipedia pages.

  Keyword arguments:

  * pages - the number of random pages returned (max of 10)
  �randomr)r-�rnnamespace�rnlimitr@r9r)rB�len)rN�query_params�request�pagerMs     rr\r\�se��
����,�
�,�'�'�&-�g�&6�x�&@�A�&@�d�D��M�&@�&�A���[�A���!�9��	�-��Bs�?c��t|||��}|j}|j}dd|d�}|r||d<n
|r||d<nd|d<t|�}|dd	|d
}	|	S)a�
  Plain text summary of the page.

  .. note:: This is a convenience wrapper - auto_suggest and redirect are enabled by default

  Keyword arguments:

  * sentences - if set, return the first `sentences` sentences (can be no greater than 10).
  * chars - if set, return only the first `chars` characters (actual text returned may be slightly longer).
  * auto_suggest - let Wikipedia find a valid page title for the query
  * redirect - allow redirection without raising RedirectError
  )�auto_suggest�redirect�extractsr,)�prop�explaintextrM�exsentences�exchars�exintror@rN�extract)rbr9�pageidrB)
r9�	sentences�charsrdre�	page_informr`rars
          rrr�s���"�5�|�h�G�)�
�/�/�%����&�
����,��"+�L����#�L��� �L����,�'�'��G��W�%�f�-�i�8�'�	�.rc��|�+|rt|dd��\}}	|xs|d}t|||��S|�
t||��St	d��#t$rt|��wxYw)a�
  Get a WikipediaPage object for the page with title `title` or the pageid
  `pageid` (mutually exclusive).

  Keyword arguments:

  * title - the title of the page to load
  * pageid - the numeric pageid of the page to load
  * auto_suggest - let Wikipedia find a valid page title for the query
  * redirect - allow redirection without raising RedirectError
  * preload - load content, summary, images, references, and links during initialization
  rT)rDr2r�re�preload)rmrs�,Either a title or a pageid must be specified)r�
IndexErrorr	�
WikipediaPage�
ValueError)r9rmrdrersrDr2s       rrbrb�s�����"�5�!��E��g�z���(�g�a�j�����7�C�C�
�����8�8�
�C�
D�D���������s�	A�Ac���eZdZdZdd�Zd�Zd�Zdd�Zd�Ze	d��Z
d	�Ze	d
��Ze	d��Z
e	d��Ze	d
��Ze	d��Ze	d��Ze	d��Ze	d��Ze	d��Ze	d��Zd�Zy)rvzd
  Contains data from a Wikipedia page.
  Uses property methods to filter data from the raw HTML.
  Nc��|�||_|xs||_n|�||_ntd��|j	||��|rdD]}t||��yy)Nrtrr)�contentr�images�
references�links�sections)r9�original_titlermrw�_WikipediaPage__load�getattr)�selfr9rmrersrrgs       r�__init__zWikipediaPage.__init__"sb�����d�j�*�3�e�d��	�	��d�k��E�F�F��K�K��7�K�3��U�$���d��V�rc�J�tdj|j��S)Nz<WikipediaPage '{}'>)rrSr9�r�s r�__repr__zWikipediaPage.__repr__1s���2�9�9�$�*�*�E�F�Frc��	|j|jk(xr4|j|jk(xr|j|jk(S#YyxYw)NF)rmr9�url)r��others  r�__eq__zWikipediaPage.__eq__4sP������u�|�|�#�	"��J�J�%�+�+�%�	"��H�H��	�	�!���
�
�s�AA�Ac
��ddddd�}t|dd�s|j|d<n|j|d	<t|�}|d
}t	|dj��d}|d|}d
|vr7t
|d�rt|j��t|j���d|vr�|rn|dd}d|vr+|dd}	|	d|jk(sJt��|	d}
n|j}
|d|
k(sJt��|j|d||��ytt|d|d���d|vr�ddddd�}t
|d�r|j|d	<n|j|d<t|�}|d
d|ddd}t|�jd�}|D�
cgc](}
ddj|
jdg��vs�'|
��*}}
|D�
cgc])}
|
js�|
jj!���+}}
t#t|d|d�|��||_|d|_|d|_ycc}
wcc}
w)z�
    Load basic information from Wikipedia.
    Confirm that page exists and is not a disambiguation/redirect.

    Does not need to be called manually, should be called automatically during __init__.
    zinfo|pagepropsr��disambiguationr,)rg�inprop�ppprop�	redirectsrmNrM�pageidsr@rNr�missingr9)rmr��
normalized�from�torr�	pageprops�	revisionsrzr)rg�rvprop�rvparse�rvlimit�*�li�
tocsection�class�fullurl)r�r9rmrBr-�keys�hasattrr	rr�rr�find_all�joinrC�a�get_textr
r�)r�rersr`rar@rmrbr�r��
from_title�html�lisr��filtered_lis�may_refer_tos                r�__loadzWikipediaPage.__load>s~���� ��	�L��4��4�(�#�z�z�l�8�� $���l�9���L�)�G��G��E�
�%��.�%�%�'�
(��
+�F���>�&�!�D��D��	��w�	���
�
�#�#��t�{�{�+�+�
��	�	��+�&�q�)�	��5� ��\�*�1�-�*��F�#�t�z�z�1�
D�3D�
D�1�!�$�'�*��z�z�*��� �J�.�A�0A�A�.�	
�
�
�i��o��'�
�J��G�D�'�4��=�A�B�B�

��	�����	�l�
��x�	 �"&�+�+��Y��!%����X���l�+�g�
�W�
�g�
&�v�
.�{�
;�A�
>�s�
C�d��$��(�(��.�c�#&�[�3�R�l�b�g�g�b�f�f�W�VX�FY�>Z�.Z�b�3�l�[�0<�E��"����b�d�d�m�m�o��l�E����g�t�G�}� E�|�T�T��d�k���=�d�j��i��d�h��\��Es�&(H?�H?�I�+Ic#�dK�|j|j�i}|jdd�}	|j�}|j|�t	|�}d|vry|dd}d|vr|j�D]}|���n||j|D]}|���d|vry|d}�}�w)zN
    Based on https://www.mediawiki.org/wiki/API:Query#Continuing_queries
    rgNr@rN�	generator�continue)�update�!_WikipediaPage__title_query_paramrC�copyrB�valuesrm)r�r`�
last_continuerg�paramsrarN�datums        r�__continued_queryzWikipediaPage.__continued_query�s���������0�0�1��M����F�D�)�D�
�� � �"�f��m�m�M�"��f�%�g�	��	�
��g��w�'�e�	��	$��\�\�^�E��+�$��4�;�;�'��-�E��+�.�
�7�	"�
��j�)�m�)�s�B.B0c�T�t|dd��d|jiSd|jiS)Nr9rMr�)r�r9rmr�s r�__title_query_paramz!WikipediaPage.__title_query_param�s/���t�W�d�#�/���
�
�
#�#�����
%�%rc��t|dd�s@dddd|jd�}t|�}|dd	|jdd
d|_|jS)zW
    Get full page HTML.

    .. warning:: This can get pretty slow on long pages.
    �_htmlFr�rzrr,)rgr�r�r�rMr@rNrr�)r�r9rBrmr��r�r`ras   rr�zWikipediaPage.html�si���4��%�(������*�*��l��l�+�g��7�#�G�,�T�[�[�9�+�F�q�I�#�N�d�j��:�:�rc�t�t|dd�s�dddd�}t|dd��|j|d	<n|j|d
<t|�}|dd|jd
|_|dd|jddd|_|dd|jddd|_|jS)zS
    Plain text content of the page, excluding images, tables, and other data.
    �_contentFzextracts|revisionsr,�ids)rgrhr�r9NrMr�r@rNrlr�r�revid�parentid)r�r9rmrBr��_revision_id�
_parent_idr�s   rrzzWikipediaPage.content�s����4��U�+�$����l�
�T�7�D�
)�
1�"&�*�*��h�	�#'�;�;��i�	 ��l�+�g�!�'�*�7�3�D�K�K�@��K�d�m�!�'�*�7�3�D�K�K�@��M�a�P�QX�Y�d��!�'�*�7�3�D�K�K�@��M�a�P�Q[�\�d�o��=�=�rc�L�t|dd�s|j|jS)a4
    Revision ID of the page.

    The revision ID is a number that uniquely identifies the current
    version of the page. It can be used to create the permalink or for
    other direct API calls. See `Help:Page history
    <http://en.wikipedia.org/wiki/Wikipedia:Revision>`_ for more
    information.
    �_revidF)r�rzr�r�s r�revision_idzWikipediaPage.revision_id�s#���4��5�)�
�l�l����rc�L�t|dd�s|j|jS)z
    Revision ID of the parent version of the current revision of this
    page. See ``revision_id`` for more information.
    �	_parentidF)r�rzr�r�s r�	parent_idzWikipediaPage.parent_id�s!���4��e�,�
�l�l��?�?�rc���t|dd�sZdddd�}t|dd��|j|d<n|j|d	<t|�}|d
d|jd|_|jS)
z)
    Plain text summary of the page.
    �_summaryFrfr,)rgrhrkr9NrMr�r@rNrl)r�r9rmrBr�r�s   rrzWikipediaPage.summarys����4��U�+�����l�
�T�7�D�
)�
1�"&�*�*��h�	�#'�;�;��i�	 ��l�+�g��g�&�w�/����<�Y�G�d�m��=�=�rc��t|dd�s6|jddddd��D�cgc]}d|vr|ddd��c}|_|jScc}w)	z-
    List of URLs of images on the page.
    �_imagesFr{�max�	imageinfor�)r��gimlimitrg�iipropr)r��_WikipediaPage__continued_queryr�)r�rbs  rr{zWikipediaPage.imagess{���4��E�*��*�*�����	,
��	��D��$��	
�[��!��U�#��	�d�l��<�<���	s�Ac��t|dd�sqdd|jd�}t|�}d|vrK|dd|jd}t	|dd	�t	|dd
�f|_|j
Sd|_|j
S)z=
    Tuple of Decimals in the form of (lat, lon) or None
    �_coordinatesF�coordinatesr�)rg�colimitrMr@rNr�lat�lonN)r�r9rBrmrr�)r�r`rar�s    rr�zWikipediaPage.coordinates+s���
�4���/����*�*��l��l�+�g�	�G�	��g�&�w�/����<�]�K��$�[��^�E�%:�;�W�[�QR�^�TY�EZ�=[�\�������!������rc��t|dd�s3d�}|jddd��D�cgc]
}||d���c}|_|jScc}w)z�
    List of URLs of external links on a page.
    May include external links within page that aren't technically cited anywhere.
    �_referencesFc�2�|jd�r|Sd|zS)N�httpzhttp:)�
startswith)r�s r�add_protocolz.WikipediaPage.references.<locals>.add_protocolIs���n�n�V�,�s�?�'�C�-�?r�extlinksr�)rg�ellimitr�)r�r�r�)r�r��links   rr|zWikipediaPage.referencesAsn���4���.�@�
�*�*���,
����D�	�T�#�Y����d�������s�A
c��t|dd�s+|jdddd��D�cgc]}|d��	c}|_|jScc}w)z�
    List of titles of Wikipedia page links on a page.

    .. note:: Only includes articles from namespace 0, meaning no Category, User talk, or other meta-Wikipedia pages.
    �_linksFr}rr�)rg�plnamespace�pllimitr9)r�r�r�)r�r�s  rr}zWikipediaPage.linksVsc���4��5�)��*�*����,
����D�	
�W�
���d�k��;�;���s�Ac���t|dd�sM|jddd��D�cgc]}|d��	c}D�cgc]}tjdd|���c}|_|jScc}wcc}w)	z'
    List of categories of a page.
    �_categoriesF�
categoriesr�)rg�cllimitr9z
^Category:r,)r�r��re�subr�)r�r��xs   rr�zWikipediaPage.categoriesjs����4���.��*�*���,
��	��D�
�g���	�	�	�<=�"�&�&���A�6�	�	�d�������	��	s
�A'�A,c���t|dd�sIddd�}|j|j�t|�}|ddD�cgc]}|d��	c}|_|jScc}w)zH
    List of section titles from the table of contents on the page.
    �	_sectionsF�parser~)�actionrg�line)r�r�r�rBr�)r�r`ra�sections    rr~zWikipediaPage.sections{ss���4��e�,����l����$�2�2�3��l�+�g�7>�w�7G�
�7S�T�7S�G����7S�T�d�n��>�>���Us�A#c�l�dj|�}	|jj|�t|�z}	|jjd|�}|j||jd�j
�S#t$rYywxYw#t$rt|j�}Y�[wxYw)a�
    Get the plain text content of a section from `self.sections`.
    Returns None if `section_title` isn't found, otherwise returns a whitespace stripped string.

    This is a convenience method that wraps self.content.

    .. warning:: Calling `section` on a section that has subheadings will NOT return
           the full text of all of the subsections. It only gets the text between
           `section_title` and the next subheading, which is often empty.
    z== {} ==Nz==�=)rSrz�indexr_rw�lstrip�strip)r��
section_titler�r��
next_indexs     rr�zWikipediaPage.section�s���� � ��/�G���l�l� � ��)�C��L�8�e�%��<�<�%�%�d�E�2�j��<�<��j�)�0�0��5�;�;�=�=����
���
�%��t�|�|�$�j�%�s"�'B�B�	B�B�B3�2B3)NNTFr,)TF)�__name__�
__module__�__qualname__�__doc__r�r�r�r�r��propertyr�r�rzr�r�rr{r�r|r}r�r~r�r:rrrvrvs	���

�G��P!�d*�>�&��&��*����,����"�
��
�����*����&����*����(����&���� ����">rrvc�f�tddd��}|dd}|D�cic]}|d|d��
c}Scc}w)a5
  List all the currently supported language prefixes (usually ISO language code).

  Can be inputted to `set_lang` to change the Mediawiki that `wikipedia` requests
  results from.

  Returns: dict of <prefix>: <local_lang_name> pairs. To get just a list of prefixes,
  use `wikipedia.languages().keys()`.
  �siteinfo�	languages)�meta�sipropr@�coder�)rB)�responser��langs   rr�r��s^�������(�
�w���,�)��
���	��L�$�s�)���
���
s�.c�2�ddl}|jdd��y)zA
  Open up the Wikimedia donate page in your favorite browser.
  rNzLhttps://donate.wikimedia.org/w/index.php?title=Special:FundraiserLandingPage�)�new)�
webbrowser�open)rs r�donater
�s����/�/�`�fg�/�hrc��d|d<d|vrd|d<dti}trvtrpttzt	j
�kDrNttzt	j
�z
}t
jt|j���tjt||��}trt	j
�a|j�S)zz
  Make a request to the Wikipedia API using the given search parameters.
  Returns a parsed dict of the JSON response.
  �jsonrSr�r@z
User-Agent)r��headers)rr%r'r&r�now�time�sleep�int�
total_seconds�requestsrCrr)r�r
�	wait_time�rs    rrBrB�s����&���	�V�	��F�8���*�
�'��(��.�.�����?�
&�(;�;�x�|�|�~�M�I��J�J�s�9�*�*�,�-�.��l�l�7�6�7�;�!��#�<�<�>��	
����/r)�
F)Nri�)r)rrTT)NNTTF))�
__future__rrr�bs4rrr�decimalr�
exceptionsr	r
rrr
r�utilrrrr�rr%r&r'rrr!r*rrIrr\rrb�objectrvr�r
rBr:rr�<module>rs���'����(��)�)�.�-�	�
-��
�
�����
B�
�
� 	!�,5�"�+E��@�$��$�N�(��(�V����*�4�$��$�NE�<H>�F�H>�V����.i�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists