
    i	                         U d Z ddlZddlmZ ddlmZ ddlmZm	Z	m
Z
mZ ddlmZ ej                  rddlmZ ddlmZ d	d
dddddZddgZdZdZeed<   	 dZeed<   	 deddddfdZdddefdZy)ao  Engine to search in the collaborative software platform SourceHut_.

.. _SourceHut: https://sourcehut.org/

Configuration
=============

You can configure the following setting:

- :py:obj:`sourcehut_sort_order`

.. code:: yaml

  - name: sourcehut
    shortcut: srht
    engine: sourcehut
    # sourcehut_sort_order: longest-active

Implementations
===============

    N)	urlencode)html)
eval_xpatheval_xpath_listextract_textsearxng_useragent)EngineResults)SXNG_Response)OnlineParamszhttps://sourcehut.org	Q78514485zhttps://man.sr.ht/FHTML)websitewikidata_idofficial_api_documentationuse_official_apirequire_api_keyresultsitreposTzhttps://sr.ht/projectsbase_urlzrecently-updatedsourcehut_sort_orderqueryparamsr   returnc                 l    | |d   t         d}t         dt        |       |d<   t               |d   d<   y )Npageno)searchpagesort?urlheadersz
User-Agent)r   r   r   r   )r   r   argss      (/root/searxng/searx/engines/sourcehut.pyrequestr%   >   sA    VH%5?STDj)D/!23F5M '8&9F9l#    respr
   c                 .   t               }t        j                  | j                        }t	        |d      D ]  }|j                  |j                  j                  dt        t        t        |d            xs dz   t        t        |d            t        t        |d            t        t        |d            t        t        |d            xs dj                  d	      t	        |d
      D cg c]  }|j                  d       c}              |S c c}w )Nz>(//div[@class='event-list'])[1]/div[contains(@class, 'event')]zpackages.htmlz./h4/a[2]/@href z./h4z	./h4/a[2]z./pz	./h4/a[1]~z(./div[contains(@class, 'tags')]/a/text()#)templater!   titlepackage_namecontent
maintainertags)r	   r   
fromstringtextr   addtypesLegacyResultr   r   r   removeprefix)r'   resdocitemtags        r$   responser<   G   s    
/C
//$))
$C%ef 
II""(Z>O-P Q WUWX":dF#;<)*T;*GH$Ze%<=(D+)FGM2[[\_`5DTKu5v.1C$$S) # 
	

 Js   *D)__doc__typingturllib.parser   lxmlr   searx.utilsr   r   r   r   searx.result_typesr	   TYPE_CHECKINGsearx.extended_typesr
   searx.search.processorsr   about
categoriespagingr   str__annotations__r   r%   r<    r&   r$   <module>rM      s   .  "  T T ,??24 '"6	 G_
	(# (  / c .:3 : :4 :? } r&   