
    ,h
                         d Z ddlZddlZddlmZmZ ej                  dk\  rddlmZ	 nddl
Z	ddlmZ ddlmZ ddlmZ  G d d	e      Zd
efdZd
ee   fdZy)z-General utils for the fake_useragent package.    N)	TypedDictUnion)   
   )Path)FakeUserAgentError)loggerc                       e Zd ZU dZeed<   	 eed<   	 eed<   	 eedf   ed<   	 eedf   ed<   	 eed<   	 eed	<   	 eedf   ed
<   	 eedf   ed<   	 eed<   y)BrowserUserAgentDatazVThe schema for the browser user agent data that the `browsers.jsonl` file must follow.	useragentpercenttypeNdevice_brandbrowserbrowser_versionbrowser_version_major_minoros
os_versionplatform)__name__
__module____qualname____doc__str__annotations__floatr        V/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/fake_useragent/utils.pyr   r      s    `N N1
IFT	"":39>7!&&=c4i3c4i  M9r   r   returnc                      	 t        j                  d      j                  d      } t        t	        |             S # t
        $ r(}t        j                  d|       t        d      |d}~ww xY w)zFind the path to the browsers.json file.

    Returns:
        Path: Path to the browsers.json file.

    Raises:
        FakeUserAgentError: If unable to find the file.
    zfake_useragent.datazbrowsers.jsonlz?Unable to find local data/jsonl file using importlib-resources.)exc_infoz$Could not locate browsers.jsonl fileN)	ilrfilesjoinpathr   r   	Exceptionr	   warningr   )	file_pathexcs     r   find_browser_json_pathr*   ,   sf    RII34==>NO	C	N## RM	
 !!GHcQRs   7: 	A+#A&&A+c                  >   g } 	 t               }|j                         j                         D ]&  }| j                  t	        j
                  |             ( 	 | st        d|       t        | t              st        d|       | S # t        $ r}t        d      |d}~ww xY w)a  Load the included `browser.json` file into memory.

    Raises:
        FakeUserAgentError: If unable to load or parse the data.

    Returns:
        list[BrowserUserAgentData]: The list of browser user agent data, following the
            `BrowserUserAgentData` schema.
    z%Failed to load or parse browsers.jsonNzData list is emptyzData is not a list)
r*   	read_text
splitlinesappendjsonloadsr&   r   
isinstancelist)data	json_pathliner)   s       r   loadr6   @   s     DS*,	'')446 	*DKK

4()	*
  !5t<<dD! !5t<<K  S !HIsRSs   AB 	BBB)r   r/   systypingr   r   version_infoimportlib.resources	resourcesr#   importlib_resourcespathlibr   fake_useragent.errorsr   fake_useragent.logr	   r   r*   r2   r6   r   r   r   <module>r@      s\    3  
 # w%%  4 %:9 :2R R(d'( r   