
     [1fG                        d Z ddlZddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZ 	 ddlmZ ddlmZmZmZ  ee      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      ZddZddZd Z edk(  r e         e        yy# e$ r ddlmZ ddlmZmZmZ Y w xY w)z,
Generate JSON schemas from pydantic models
    N)	getLogger)Path)pprint)DictListLiteralOptionalUnion)	BaseModel)Fieldconlistconstrc                        e Zd Z G d d      Zy)r   c                       e Zd ZdZy)BaseModel.ConfigforbidN)__name__
__module____qualname__extra     0lib/python3.12/site-packages/menuinst/_schema.pyConfigr      s    r   r   N)r   r   r   r   r   r   r   r   r      s     r   r   c                   ,   e Zd ZU dZdZe ed         ed<   	 dZee	   ed<   	 dZ
e ed         ed<   	 dZe ee	d         ed	<   	 dZe ed         ed
<   	 dZe ed         ed<   	 dZe ed         ed<   	 dZee   ed<   	 dZee   ed<   y)BasePlatformSpecificz
    Same as :class:`MenuItem`, but without ``platforms``, and all is optional.

    Note:
    * This needs to be kept up-to-date with :class:`MenuItem`!
    * Default value is always ``None``.
    N   
min_lengthnamedescriptionicon	min_itemscommandworking_dir
precommand	precreateactivateterminal)r   r   r   __doc__r    r	   r   __annotations__r!   strr"   r%   r   r&   r'   r(   r)   boolr*   r   r   r   r   r      s     ,0D(6Q'
(/!%K#%E+/D(6Q'
(/;37GXgcQ/07 37K&A./6 26J1-.5 15Ix!,-4T#Hhtn#L#Hhtn#r   r   c                       e Zd ZU dZdZee   ed<   	 dZee   ed<   	 dZ	ee
 ed            ed<   	 dZee
 ed	            ed
<   	 dZe edd         ed<   y)WindowszJWindows-specific instructions. You can override global keys here if neededTdesktopquicklaunchNz\S+regexurl_protocolsz\.\S*file_extensionsz\S+\.\S+   )r4   
max_lengthapp_user_model_id)r   r   r   r+   r1   r	   r.   r,   r2   r5   r   r   r6   r9   r   r   r   r0   r0   H   s{    P"GXd^"J"&K$&O:>M8Df!567>>>BOXd6#9:;B@MQx[S IJQr   r0   c                   &   e Zd ZU dZdZeeee    e	d      f      e
d<   	 dZee   e
d<   	 dZee   e
d<   	 dZee   e
d<   	 dZeeee    e	d      f      e
d	<   	 dZeeee    e	d      f      e
d
<   	 dZeeee    e	d      f      e
d<   	 dZee   e
d<   	 dZeeee    e	d      f      e
d<   	 dZeeee    e	d      f      e
d<   	 dZee   e
d<   	 dZee   e
d<   	 dZee   e
d<   	 dZee   e
d<   	 dZeee e	d      f      e
d<   y)Linuxa  
    Linux-specific instructions.

    Check the `Desktop entry specification <desktop-entry-spec>`__ for more details.

    .. desktop-entry-spec: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys
    Nz^.+;$r3   
CategoriesDBusActivatableGenericNameHidden
ImplementsKeywordsMimeType	NoDisplay	NotShowIn
OnlyShowInPrefersNonDefaultGPUStartupNotifyStartupWMClassTryExecz.*\*.*glob_patterns)r   r   r   r+   r<   r	   r
   r   r-   r   r,   r=   r.   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   r   r   r   r   r;   r;   _   s    FJJtCy&x*@@ABI '+OXd^*W!%K#% "FHTN!5EIJtCy&x*@@ABI
 DHHhuT#YX(>>?@GECGHhuT#YX(>>?@G !%Ix~$
 EIIxd3ih)??@AH FJJtCy&x*@@ABI ,0(4./W$(M8D>(
 %)NHSM(
 "GXc]!
 CGM8Df9&=!=>?Fr   r;   c                      e Zd ZU dZ G d de      Z G d de      Z G d de      ZdZe	e
   ed	<   	 dZe	 ed
         ed<   	 dZe	 ed         ed<   	 dZe	e
   ed<   	 dZe	 ed         ed<   	 dZe	ee      ed<   	 dZe	ee      ed<   	 dZe	 ed         ed<   	 dZe	e   ed<   	 dZe	ee
e
f      ed<   	 dZe	 ed         ed<   	 dZe	e   ed<   	 dZe	e   ed<   	 dZe	ee      ed<   	 dZe	ee      ed<   	 dZe	e ed            ed <   	 dZe	e ed!"       ed#      f      ed$<   	 dZ e	 ed!"         ed%<   y)&MacOSa  
    Mac-specific instructions. Check these URLs for more info:

    - ``CF*`` keys: see `Core Foundation Keys <cf-keys>`_
    - ``LS*`` keys: see `Launch Services Keys <ls-keys>`_
    - ``entitlements``: see `entitlements docs <entitlements-docs>`_

    .. _cf-keys: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
    .. _ls-keys: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html
    .. _entitlements-docs: https://developer.apple.com/documentation/bundleresources/entitlements.
    c                   n    e Zd ZU dZdZeed      ed<   	 dZe	e
   ed<   	 dZee
   ed<   	 dZee
   ed<   y)	MacOS.CFBundleURLTypesModelz/Describes a URL scheme associated with the app.NEditorViewerShellNoneCFBundleTypeRole.CFBundleURLSchemesCFBundleURLNameCFBundleURLIconFile)r   r   r   r+   rT   r	   r   r,   rU   r   r-   rV   rW   r   r   r   CFBundleURLTypesModelrN      sS    9SW(7+N#OPWD(+DI+H)-#-C-1Xc]1Cr   rX   c                   ~    e Zd ZU dZdZee   ed<   	 dZeed<   	 dZ	ee
d      ed<   	 dZee   ed<   	 dZe
d	   ed
<   y) MacOS.CFBundleDocumentTypesModelz2Describes a document type associated with the app.NCFBundleTypeIconFile.CFBundleTypeNamerO   rT   LSItemContentTypes)OwnerDefault	AlternateLSHandlerRank)r   r   r   r+   r[   r	   r-   r,   r\   rT   r   r]   r   ra   r   r   r   CFBundleDocumentTypesModelrZ      sk    <.2hsm2C ###HSW(7+N#OPWE(+DI+	 CFw>?E	r   rb   c                       e Zd ZU dZee   ed<   	 dZee   ed<   	 dZ	ee   ed<   	 dZ
eed<   	 dZee   ed<   	 dZeeee   f   ed<   y)	MacOS.UTTypeDeclarationModel.UTTypeConformsToNUTTypeDescriptionUTTypeIconFileUTTypeIdentifierUTTypeReferenceURLUTTypeTagSpecification)r   r   r   re   r   r-   r,   rf   r	   rg   rh   ri   rj   r   r   r   r   UTTypeDeclarationModelrd      sr    &)$s))G+/8C=/&(,,? ###=,0HSM0H7:S$s)^ 4:Hr   rk   NCFBundleDisplayNamez^[A-z0-9\-\.]+$r3   CFBundleIdentifier   )r8   CFBundleNameCFBundleSpokenNamez^\S+$CFBundleVersionCFBundleURLTypesCFBundleDocumentTypesz^public\.app-category\.\S+$LSApplicationCategoryTypeLSBackgroundOnlyLSEnvironmentz^\d+\.\d+\.\d+$LSMinimumSystemVersionLSMultipleInstancesProhibitedLSRequiresNativeExecutionUTExportedTypeDeclarationsUTImportedTypeDeclarationsz[a-z0-9\.\-]+entitlementsr   r   z^(?!\/)(?!\.\./).*link_in_bundleevent_handler)!r   r   r   r+   r   rX   rb   rk   rl   r	   r-   r,   rm   r   ro   rp   rq   rr   r   rs   rt   ru   r.   rv   r   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   rL   rL      s   
	D	 	DY 6I I *.#- FJ.@!ABI 59L(6R018 )-, 9=OXf845<
 ?Cht$9:;B IM8D)C$DEL Y]x5S(TU\Q'+htn+=.2M8DcN+2DIMHV2D%EFM 59!8D>8Y04x~4 JN.D)E FMAIM.D)E FMSCGL(4-= >?@G 	 HVq!60E#FFG 
 59M8Fa018r   rL   c                   F    e Zd ZU dZee   ed<   	 ee   ed<   	 ee   ed<   y)	Platformsz
    Platform specific options.

    Note each of these fields supports the same keys as the top-level :class:`MenuItem`
    (sans ``platforms`` itself), in case overrides are needed.
    linuxosxwinN)	r   r   r   r+   r	   r;   r,   rL   r0   r   r   r   r   r   D  s1     E?>	%>	'	Br   r   c                   &   e Zd ZU dZdZ ed      ed<   	 dZeed<   	 dZ	 e
ed      ed<   	 d	Ze ed         ed
<   	 d	Ze ed         ed<   	 d	Ze ed         ed<   	 d	Ze ed         ed<   	 dZee   ed<   	 dZee   ed<   	 eed<   y	)MenuItemz<Instructions to create a menu item across operating systems..r   r   r    r!   r#   r%   Nr"   r'   r(   r&   Tr)   Fr*   	platforms)r   r   r   r+   r    r   r,   r!   r-   r%   r   r"   r	   r'   r(   r&   r)   r.   r*   r   r   r   r   r   r   T  s    B!$D&A
$ KE),GWSA&, ,0D(6Q'
(/;15J1-.5 15Ix!,-4T26K&A./6  $Hhtn#L$Hhtn$
 br   r   c                       e Zd ZU dZ eddd      Zed   ed<    eddd	      Zed
   ed<   dZ	 e
d      ed<   	 dZ eed      ed<   y)MenuInstSchemazRMetadata required to create menu items across operating systems with ``menuinst``..zVersion of the menuinst schema.$id)r!   alias/https://schemas.conda.io/menuinst-1.schema.jsonid_z)Standard of the JSON schema we adhere to.$schema'https://json-schema.org/draft-07/schemaschema_r   r   	menu_namer#   
menu_itemsN)r   r   r   r+   r   r   r   r,   r   r   r   r   r   r   r   r   r   r   r   z  ss    XFK5GCB	C 
 CH?CGW>? 
 '*Iv#)M14JA.4Ar   r   c                    | rt        t              j                  }t        j	                  d      }t        |       t        |dz  dz  d      5 }|j                  |       |j                  d       d d d        t        j                         S t        j                         S # 1 sw Y   t        j                         S xY w)N   indentdatazmenuinst.schema.jsonw
)	r   __file__parentr   schema_jsonprintopenwriteschema)r   herer   fs       r   dump_schema_to_jsonr     s    H~$$++1+5f$-"88#> 	!GGFOGGDM	   "">  ""	   ""s   #B""B>c                    t        t              j                  }t        dddgi       j	                         }t               j	                         t               j	                         t               j	                         d|d<   t        dd|gddddj	                         }|d	   d
   d   j                         D ]D  }t        |j                               D ]&  }|t        j                  v s|j                  |       ( F | rQt        |       t        |dz  dz  d      5 }t!        j"                  ||d       |j%                  d       d d d        |S |S # 1 sw Y   |S xY w)NREQUIRED)r    r!   r%   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   r   zmenuinst.default.jsonr   r   r   r   r   )r   r   r   r   dictr0   rL   r;   r   valueslistkeys
__fields__popr   r   jsondumpr   )r   r   default_itemdefaultplatform_valuekeyr   s          r   dump_default_to_jsonr     sZ   >  DZ*QS
df  y~~w||~!L
   > E@
 df  ",/2;?FFH (++-. 	(Ch)))""3'	(( w$-"993? 	1IIgq+GGDM	 N7N	 Ns   "*EE"c                     t        | t        t        f      r*t        |       5 }t	        j
                  |      }d d d        n| }t        di S # 1 sw Y   xY w)Nr   )
isinstancer-   r   r   r   loadr   )metadata_or_pathr   metadatas      r   validater     sX    "S$K0"# 	$qyy|H	$ 	$ $%H%%		$ 	$s   AA__main__)T)!r+   r   loggingr   pathlibr   r   typingr   r   r   r	   r
   pydantic.v1r   
_BaseModelr   r   r   ImportErrorpydanticr   logr   r0   r;   rL   r   r   r   r   r   r   r   r   r   <module>r      s        7 70322 
 
'9 'T" .Q  QhN  NbC	 C #cy #cLBY B&#<& z _  00//0s   B8 8CC