
    ^i
                         S r SSKrSSKrSSKJrJr  \R                  S:  a  SSKJr	  OSSK
r	SSKJr  SSKJr  SSKJr   " S S	\5      rS
\4S jrS
\\   4S jrg)z-General utils for the fake_useragent package.    N)	TypedDictUnion)   
   )Path)FakeUserAgentError)loggerc                       \ rS rSr% Sr\\S'    \\S'    \\S'    \\S4   \S'    \\S4   \S'    \\S	'    \\S
'    \\S4   \S'    \\S4   \S'    \\S'   Sr	g)BrowserUserAgentData   zVThe 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____firstlineno____doc__str__annotations__floatr   __static_attributes__r       N/home/james-whalen/.local/lib/python3.13/site-packages/fake_useragent/utils.pyr   r      s    `N N1
IFT	"":39>7!&&=c4i3c4i  M9r!   r   returnc                       [         R                  " S5      R                  S5      n [        [	        U 5      5      $ ! [
         a&  n[        R                  " SUS9  [        S5      UeSnAff = f)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   8; 
A+!A&&A+c                  X   / n  [        5       nUR                  5       R                  5        H(  nU R                  [        R
                  " U5      5        M*     U (       d  [        SU 5      e[        U [        5      (       d  [        SU 5      eU $ ! [         a  n[        S5      UeSnAff = f)zLoad 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"   loadr9   @   s     DS*,	'')446DKK

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