
    Ri                         U d dl Z d dlmZmZ  edeeeeeef   eeeeed      ZdeddfdZ e j                  de j                        Ze j                  e   ed	<   d
eeeef   defdZy)    N)	TypedDictUnionSearchResults)linknamesizeseedsleech
engine_url	desc_linkpub_date
dictionaryreturnc                 v   dj                  | d   | d   j                  dd      t        t        | d               t        | d         t        | d         | d   | j	                  d	d
      t        | j	                  dd            f      }t        dddd      5 }t        ||       d d d        y # 1 sw Y   y xY w)N|r   r    r   r	   r
   r   r    r      wzutf-8F)encodingclosefd)file)joinreplacestranySizeToBytesgetopenprint)r   outtext
utf8stdouts      (/config/qBittorrent/nova3/novaprinter.pyprettyPrinterr$   *   s    hh66""3,N:f-./Jw Jw < {B'JNN:r*+	 	G 
aw	6*gJ' 
7	6	6s   B//B8z'^(?P<size>\d*\.?\d+) *(?P<unit>[a-z]+)?sizeUnitRegexsize_stringc                 |   t        | t              r| S t        | t              rt        |       S t        j                  | j                               }|yt        |j                  d            }|j                  d      }|2ddddd}|j                  |d	   j                         d	      }|d
|z  z  }t        |      S )z
    Convert a string like '1 KB' to '1024' (bytes)

    The canonical type for `size_string` is `str`. However numeric types are also accepted in order to
    accommodate poorly written plugins.
    r   r   unit(         
   )TGMKr      )

isinstanceintfloatroundr%   matchstripgroupr   upper)r&   r6   r   r(   units_exponentsexponents         r#   r   r   ?   s     +s#+u%[!! 1 1 34E}V$%D;;vD ""2>"&&tAw}}:8;    )retypingr   r   r   r4   r3   r   r$   compile
IGNORECASEr%   Pattern__annotations__r    r<   r#   <module>rD      s   6 
 #/%c/"	, 	(m ( (" ",,VXZXeXe!frzz# feS#o 6 3 r<   