
    ͈2g/K                        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 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                   X    e Zd ZU dZdZe ed         ed<   	 dZe ed         ed<   y)MenuItemNameDictz
    Variable menu item name.
    Use this dictionary if the menu item name depends on installation parameters
    such as the target environment.
    N   
min_lengthtarget_environment_is_basetarget_environment_is_not_base)	r   r   r   __doc__r    r	   r   __annotations__r!   r   r   r   r   r      s;     BF1)= >E;EI"HVq-A$BI?r   r   c                   6   e Zd ZU dZdZee ed      ef      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``.
    Nr   r   namedescriptionicon	min_itemscommandworking_dir
precommand	precreateactivateterminal)r   r   r   r"   r&   r	   r
   r   r   r#   r'   strr(   r+   r   r,   r-   r.   r/   boolr0   r   r   r   r%   r%   +   s     EID(51-/??@
AH "&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
d      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desktopFquicklaunchNr   r   terminal_profilez\S+regexurl_protocolsz\.\S*file_extensionsz\S+\.\S+   )r9   
max_lengthapp_user_model_id)r   r   r   r"   r5   r	   r2   r#   r6   r7   r   r:   r   r;   r>   r   r   r   r4   r4   X   s    P"GXd^"J"'K$'[-1f*1
 ;?M8Df!567>>>BOXd6#9:;B@MQx[S IJQr   r4   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
d<   	 dZeee e	d      f      e
d<   y)Linuxz
    Linux-specific instructions.

    Check the `Desktop entry specification
    <https://specifications.freedesktop.org/desktop-entry-spec/latest/recognized-keys.html>`__
    for more details.
    Nz^.+;$r8   
CategoriesDBusActivatableGenericNameHidden
ImplementsKeywordsMimeType	NoDisplay	NotShowIn
OnlyShowInPrefersNonDefaultGPUSingleMainWindowStartupNotifyStartupWMClassTryExecz.*\*.*glob_patterns)r   r   r   r"   rA   r	   r
   r   r1   r   r#   rB   r2   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r   r   r   r   r@   r@   u   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'+htn+ %)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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)'MacOSa5  
    Mac-specific instructions. Check these URLs for more info:

    - ``CF*`` keys: see `Core Foundation Keys <https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html>`__
    - ``LS*`` keys: see `Launch Services Keys <https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html>`__
    - ``entitlements``: see `Entitlements documentation <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"   rZ   r	   r   r#   r[   r   r1   r\   r]   r   r   r   CFBundleURLTypesModelrT      sS    9SW(7+N#OPWD(+DI+H)-#-C-1Xc]1Cr   r^   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.CFBundleTypeNamerU   rZ   LSItemContentTypes)OwnerDefault	AlternateLSHandlerRank)r   r   r   r"   ra   r	   r1   r#   rb   rZ   r   rc   r   rg   r   r   r   CFBundleDocumentTypesModelr`      sk    <.2hsm2C ###HSW(7+N#OPWE(+DI+		 CFw>?E	r   rh   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   rk   r   r1   r#   rl   r	   rm   rn   ro   rp   r   r   r   r   UTTypeDeclarationModelrj      sr    &)$s))G+/8C=/&(,,? ###=,0HSM0H7:S$s)^ 4:Hr   rq   NCFBundleDisplayNamez^[A-z0-9\-\.]+$r8   CFBundleIdentifier   )r=   CFBundleNameCFBundleSpokenNamez^\S+$CFBundleVersionCFBundleURLTypesCFBundleDocumentTypesz^public\.app-category\.\S+$LSApplicationCategoryTypeLSBackgroundOnlyLSEnvironmentz^\d+\.\d+\.\d+$LSMinimumSystemVersionLSMultipleInstancesProhibitedLSRequiresNativeExecution$NSSupportsAutomaticGraphicsSwitchingUTExportedTypeDeclarationsUTImportedTypeDeclarationsz[a-z0-9\.\-]+entitlementsr   r   z^(?!\/)(?!\.\./).*link_in_bundleevent_handler)"r   r   r   r"   r   r^   rh   rq   rr   r	   r1   r#   rs   r   ru   rv   rw   rx   r   ry   rz   r{   r2   r|   r   r}   r~   r   r   r   r   r   r   r   r   r   r   rR   rR      s*   	D	 	DY 2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 <@((4.?FIM.D)E FMAIM.D)E FMSCGL(4-= >?@G 	 HT&A"6EZ8["[\] 
 59M8Fa018r   rR   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#   rR   r4   r   r   r   r   r   U  s1     E?>	%>	'	Br   r   c                   0   e Zd ZU dZdZe ed      ef   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/   Fr0   	platforms)r   r   r   r"   r&   r
   r   r   r#   r'   r1   r+   r   r(   r	   r-   r.   r,   r/   r2   r0   r   r   r   r   r   r   e  s    B:=D%!$&66
7= 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     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   dictr4   rR   r@   r   valueslistkeys
__fields__popr   r   jsondumpr   )r   r   default_itemdefaultplatform_valuekeyr   s          r   dump_default_to_jsonr     sN   >  DZ*QS
df  y~~w||~!L
   > E@
 df  ",/2;?FFH++-.Ch)))""3' / I 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   )
isinstancer1   r   r   r   loadr   )metadata_or_pathr   metadatas      r   validater     sO    "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   r%   r4   r@   rR   r   r   r   r   r   r   r   r   r   <module>r      s        7 70322 
 

@y 
@*9 *Z" :Q  QhI  IXC	 C &cy &cRBY B&#<& z G  00//0s   C CC