
    .eG                        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 n# e$ r ddlmZ ddlmZmZmZ Y nw xY w 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             dS dS )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dS )r   c                       e Zd ZdZdS )BaseModel.ConfigforbidN)__name__
__module____qualname__extra     0lib/python3.11/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<   dS )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      sP          ,0D(66Q'''
(///!%K#%%%E+/D(66Q'''
(///;37GXggcQ///0777 37K&&A.../666 26J1---.555 15Ix!,,,-44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<   dS )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P"GXd^"""J"&K$&&&O:>M8Df!5!5!567>>>>>BOXd66#9#9#9:;BBB@MQx[S I I IJQQ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<   dS )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;   _   sk          FJJtCy&&x*@*@*@@ABIII '+OXd^***W!%K#%%% "FHTN!!!5EIJtCy&&x*@*@*@@ABIII
 DHHhuT#YX(>(>(>>?@GGGECGHhuT#YX(>(>(>>?@GGG !%Ix~$$$
 EIIxd3ih)?)?)??@AHHH FJJtCy&&x*@*@*@@ABIII ,0(4.///W$(M8D>(((
 %)NHSM(((
 "GXc]!!!
 CGM8Dff9&=&=&=!=>?FFF r   r;   c                   n   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%<   dS )&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                       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<   dS )	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      s{         99SW(7+N#OPWWWD(+DI+++H)-#---C-1Xc]111C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
<   dS ) 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      s         <<.2hsm222C #####HSW(7+N#OPWWWE(+DI+++	 CFw>?EE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<   dS )	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      s         &)$s))))G+/8C=///&(,,,,? #####=,0HSM000H7:S$s)^ 4:::H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      sN        
 
	D 	D 	D 	D 	D	 	D 	D 	D    Y   6I I I I I I I I *.#--- FJ.@!A!A!ABIII 59L(66R0001888 )-,,, 9=OXff84445<<<
 ?Cht$9:;BBB IM8D)C$DELLL Y]x5S(T(T(TU\\\Q'+htn+++=.2M8DcN+222DIMHVV2D%E%E%EFMMM 59!8D>888Y04x~444 JN.D)E FMMMAIM.D)E FMMMSCGL(4-= > > >?@GGG 	 HVVq!!!660E#F#F#FFG   
 59M8FFa0001888 r   rL   c                   Z    e Zd ZU dZee         ed<   	 ee         ed<   	 ee         ed<   dS )	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  sU           E?>	%>	'	BBr   r   c                   p   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<   d	S )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  sK        BB!$D&&A


$$$ KE),GWWSA&&&,,, ,0D(66Q'''
(///;15J1---.555 15Ix!,,,-444T26K&&A.../666  $Hhtn###L$Hhtn$$$
 b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<   dS )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  s         XXFKe5G G GCB	C   
 CH%?C C CGW>?   
 '*Ivv###)))M14JA...444AAr   r   Tc                 n   | rt          t                    j        }t                              d          }t          |           t          |dz  dz  d          5 }|                    |           |                    d           d d d            n# 1 swxY w Y   t                                          S )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5f$-"88#>> 	!GGFOOOGGDMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   """s   +BBBc                 J   t          t                    j        }t          dddgi                                           }t                                                      t                                                      t                                                      d|d<   t          dd|gdddd                                }|d	         d
         d         	                                D ]I}t          |                                          D ]%}|t          j        v r|                    |           &J| rit          |           t          |dz  dz  d          5 }t!          j        ||d           |                    d           d d d            n# 1 swxY w Y   |S )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     s   >> DZ*QS  
dff  yy~~ww||~~! !L
   >  E@
 
  dff  ",/2;?FFHH ( (++--.. 	( 	(Ch)))""3'''	(  w$-"993?? 	1Igq++++GGDMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 Ns   -FFFc                     t          | t          t          f          r<t          |           5 }t	          j        |          }d d d            n# 1 swxY w Y   n| }t          di |S )Nr   )
isinstancer-   r   r   r   loadr   )metadata_or_pathr   metadatas      r   validater     s    "S$K00 $"## 	$qy||H	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ $%%H%%%s   A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 7 7 7 7 7 7 7 7 7 7 7 7033333322222222222 0 0 0000000////////////0 i    
   
' ' ' ' '9 ' ' 'T    "   .Q Q Q Q Q  Q Q QhN N N N N  N N NbC C C C C	 C C C #c #c #c #c #cy #c #c #cLB B B B BY B B B&# # # #   <& & & z s   9 AA