o
    *‘siáY  ã                   @   sô  d Z ddlZddl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mZmZmZmZmZmZ ddlmZmZ ddlmZmZ dd	lmZ dd
lmZ ddlmZ e	rjddl m!Z! ddl"m#Z# ee$ej%f Z&ededef f Z'	 ede'f Z(eded d�Z)		d5de&de*fdd„Z+ddde&ddfdd„Z,		d6ddde&dee& de-ded f
d d!„Z.d"e)d#e$fd$d%„Z/d&ed de*fd'd(„Z0	d7d)dd*e(ded+ fd,d-„Z1G d.d/„ d/ee) ƒZ2G d0d1„ d1e2d2 ƒZ3G d3d4„ d4e2d ƒZ4dS )8ze
Load setuptools configuration from ``setup.cfg`` files.

**API will be made private in the future**
é    N)Údefaultdict)Úpartial©Úwraps)ÚTYPE_CHECKINGÚCallableÚAnyÚDictÚGenericÚIterableÚListÚOptionalÚTupleÚTypeVarÚUnion)ÚDistutilsOptionErrorÚDistutilsFileError)ÚVersionÚInvalidVersion)ÚSpecifierSet)ÚSetuptoolsDeprecationWarningé   )Úexpand©ÚDistribution)ÚDistributionMetadataÚstrÚTarget)r   r   )ÚboundFÚfilepathÚreturnc                 C   s8   ddl m} |ƒ }|r| ¡ ng }t|| ||ƒ}t|ƒS )a,  Read given configuration file and returns options from it as a dict.

    :param str|unicode filepath: Path to configuration file
        to get options from.

    :param bool find_others: Whether to search for other configuration files
        which could be on in various places.

    :param bool ignore_option_errors: Whether to silently ignore
        options, values of which could not be resolved (e.g. due to exceptions
        in directives such as file:, attr:, etc.).
        If False exceptions are propagated as expected.

    :rtype: dict
    r   r   )Úsetuptools.distr   Zfind_config_filesÚ_applyÚconfiguration_to_dict)r   Zfind_othersÚignore_option_errorsr   ÚdistÚ	filenamesÚhandlers© r(   úC:\Users\PC\students\dividedattentionclub\pushnotificationexperiment\lib\python3.10\site-packages\setuptools/config/setupcfg.pyÚread_configuration&   s
   r*   r%   r   c                 C   s   t | |ƒ |  ¡  | S )z`Apply the configuration from a ``setup.cfg`` file into an existing
    distribution object.
    )r"   Z_finalize_requires)r%   r   r(   r(   r)   Úapply_configurationB   s   
r+   r(   Úother_filesr$   )ÚConfigHandler.c              	   C   sš   ddl m} tj |¡}tj |¡std| ƒ‚t ¡ }t tj 	|¡¡ g |¢|‘}z|j
| |d� t| | j|d�}|  ¡  W t |¡ |S t |¡ w )zHRead configuration from ``filepath`` and applies to the ``dist`` object.r   )Ú_Distributionz%Configuration file %s does not exist.)r&   )r$   )r!   r.   ÚosÚpathÚabspathÚisfiler   ÚgetcwdÚchdirÚdirnameZparse_config_filesÚparse_configurationÚcommand_optionsZ_finalize_license_files)r%   r   r,   r$   r.   Zcurrent_directoryr&   r'   r(   r(   r)   r"   K   s    ÿ

þr"   Ú
target_objÚkeyc                 C   s2   dj di tƒ ¤Ž}t t| |¡}t| ||ƒ}|ƒ S )z 
    Given a target object and option key, get that option from
    the target object, either through a get_{key} method or
    from an attribute directly.
    z	get_{key}Nr(   )ÚformatÚlocalsÚ	functoolsr   Úgetattr)r8   r9   Zgetter_nameZby_attributeÚgetterr(   r(   r)   Ú_get_optionh   s   r?   r'   c                 C   s<   t tƒ}| D ]}|jD ]}t|j|ƒ}|||j |< qq|S )z»Returns configuration data gathered by given handlers as a dict.

    :param list[ConfigHandler] handlers: Handlers list,
        usually from parse_configuration()

    :rtype: dict
    )r   ÚdictÚset_optionsr?   r8   Úsection_prefix)r'   Zconfig_dictÚhandlerÚoptionÚvaluer(   r(   r)   r#   t   s   
þr#   Údistributionr7   )ÚConfigMetadataHandlerÚConfigOptionsHandlerc                 C   s|   t  | ¡�-}t| |||ƒ}| ¡  | js|j| _t| j|||| j| jƒ}| ¡  W d  ƒ ||fS 1 s5w   Y  ||fS )aÒ  Performs additional parsing of configuration options
    for a distribution.

    Returns a list of used option handlers.

    :param Distribution distribution:
    :param dict command_options:
    :param bool ignore_option_errors: Whether to silently ignore
        options, values of which could not be resolved (e.g. due to exceptions
        in directives such as file:, attr:, etc.).
        If False exceptions are propagated as expected.
    :rtype: list
    N)r   ÚEnsurePackagesDiscoveredrH   ÚparseÚpackage_dirrG   ÚmetadataÚsrc_root)rF   r7   r$   Úensure_discoveredÚoptionsÚmetar(   r(   r)   r6   †   s.   üú

ìêr6   c                   @   sâ   e Zd ZU dZeed< 	 i Zeeef ed< 	 dede	de
jfdd„Zed	d
„ ƒZdd„ Zed&dd„ƒZedd„ ƒZedd„ ƒZedd„ ƒZedefdd„ƒZdefdd„Zedd„ ƒZed'dd„ƒZd d!„ Zd"d#„ Zd$d%„ ZdS )(r-   z1Handles metadata supplied in configuration files.rB   Úaliasesr8   rO   rN   c           	      C   sd   i }| j }| ¡ D ]\}}| |¡sq	| |d¡ d¡}|||< q	|| _|| _|| _g | _|| _	d S )NÚ Ú.)
rB   ÚitemsÚ
startswithÚreplaceÚstripr$   r8   ÚsectionsrA   rN   )	Úselfr8   rO   r$   rN   rX   rB   Úsection_nameÚsection_optionsr(   r(   r)   Ú__init__Á   s   


zConfigHandler.__init__c                 C   s   t d| jj ƒ‚)ú.Metadata item name to parser function mapping.z!%s must provide .parsers property)ÚNotImplementedErrorÚ	__class__Ú__name__)rY   r(   r(   r)   ÚparsersØ   s   
ÿzConfigHandler.parsersc           	      C   sÄ   t ƒ }| j}| j ||¡}t|||ƒ}||u rt|ƒ‚|rd S d}| j |¡}|r?z||ƒ}W n ty>   d}| js<‚ Y nw |rCd S t|d| d ƒ}|d u rVt	|||ƒ n||ƒ | j
 |¡ d S )NFTzset_%s)Útupler8   rQ   Úgetr=   ÚKeyErrorra   Ú	Exceptionr$   ÚsetattrrA   Úappend)	rY   Zoption_namerE   Úunknownr8   Úcurrent_valueZskip_optionÚparserÚsetterr(   r(   r)   Ú__setitem__ß   s4   ÿþzConfigHandler.__setitem__ú,c                 C   s8   t |tƒr|S d|v r| ¡ }n| |¡}dd„ |D ƒS )z×Represents value as a list.

        Value is split either by separator (defaults to comma) or by lines.

        :param value:
        :param separator: List items separator character.
        :rtype: list
        Ú
c                 S   s   g | ]
}|  ¡ r|  ¡ ‘qS r(   ©rW   )Ú.0Úchunkr(   r(   r)   Ú
<listcomp>  s    z-ConfigHandler._parse_list.<locals>.<listcomp>)Ú
isinstanceÚlistÚ
splitlinesÚsplit)ÚclsrE   Ú	separatorr(   r(   r)   Ú_parse_list  s   



zConfigHandler._parse_listc                 C   sP   d}i }|   |¡D ]}| |¡\}}}||krtd| ƒ‚| ¡ || ¡ < q	|S )zPRepresents value as a dict.

        :param value:
        :rtype: dict
        ú=z(Unable to parse option value to dict: %s)ry   Ú	partitionr   rW   )rw   rE   rx   ÚresultÚliner9   ÚsepÚvalr(   r(   r)   Ú_parse_dict  s   ÿzConfigHandler._parse_dictc                 C   s   |  ¡ }|dv S )zQRepresents value as boolean.

        :param value:
        :rtype: bool
        )Ú1ÚtrueÚyes)Úlower©rw   rE   r(   r(   r)   Ú_parse_bool,  s   zConfigHandler._parse_boolc                    ó   ‡ fdd„}|S )zßReturns a parser function to make sure field inputs
        are not files.

        Parses a value after getting the key so error messages are
        more informative.

        :param key:
        :rtype: callable
        c                    s    d}|   |¡rtd ˆ ¡ƒ‚| S )Núfile:zCOnly strings are accepted for the {0} field, files are not accepted)rU   Ú
ValueErrorr:   )rE   Zexclude_directive©r9   r(   r)   rj   B  s   
þz3ConfigHandler._exclude_files_parser.<locals>.parserr(   )rw   r9   rj   r(   rŠ   r)   Ú_exclude_files_parser6  s   	z#ConfigHandler._exclude_files_parserÚroot_dirc                 C   sP   d}t |tƒs	|S | |¡s|S |t|ƒd… }dd„ | d¡D ƒ}t ||¡S )aO  Represents value as a string, allowing including text
        from nearest files using `file:` directive.

        Directive is sandboxed and won't reach anything outside
        directory with setup.py.

        Examples:
            file: README.rst, CHANGELOG.md, src/file.txt

        :param str value:
        :rtype: str
        rˆ   Nc                 s   s   � | ]}|  ¡ V  qd S ©Nro   )rp   r0   r(   r(   r)   Ú	<genexpr>d  s   € z,ConfigHandler._parse_file.<locals>.<genexpr>rm   )rs   r   rU   Úlenrv   r   Z
read_files)rw   rE   rŒ   Zinclude_directiveÚspecZ	filepathsr(   r(   r)   Ú_parse_fileM  s   

zConfigHandler._parse_filec                 C   s:   d}|  |¡s	|S | |d¡}| | jj¡ t |||¡S )z·Represents value as a module attribute.

        Examples:
            attr: package.attr
            attr: package.module.attr

        :param str value:
        :rtype: str
        zattr:rR   )rU   rV   ÚupdaterN   rK   r   Z	read_attr)rY   rE   rK   rŒ   Zattr_directiveZ	attr_descr(   r(   r)   Ú_parse_attrg  s   

zConfigHandler._parse_attrc                    r‡   )z¹Returns parser function to represents value as a list.

        Parses a value applying given methods one after another.

        :param parse_methods:
        :rtype: callable
        c                    s   | }ˆ D ]}||ƒ}q|S r�   r(   )rE   ÚparsedÚmethod©Úparse_methodsr(   r)   rJ   …  s   
z1ConfigHandler._get_parser_compound.<locals>.parser(   )rw   r—   rJ   r(   r–   r)   Ú_get_parser_compound{  s   
z"ConfigHandler._get_parser_compoundNc                 C   s6   i }|pdd„ }|  ¡ D ]\}\}}||ƒ||< q|S )zÊParses section options into a dictionary.

        Optionally applies a given parser to values.

        :param dict section_options:
        :param callable values_parser:
        :rtype: dict
        c                 S   s   | S r�   r(   )r   r(   r(   r)   Ú<lambda>š  s    z6ConfigHandler._parse_section_to_dict.<locals>.<lambda>)rT   )rw   r[   Zvalues_parserrE   r9   Ú_r   r(   r(   r)   Ú_parse_section_to_dict�  s
   
z$ConfigHandler._parse_section_to_dictc              	   C   s8   |  ¡ D ]\}\}}z|| |< W q ty   Y qw dS )zQParses configuration file section.

        :param dict section_options:
        N)rT   rd   )rY   r[   Únamerš   rE   r(   r(   r)   Úparse_sectionŸ  s   ÿüzConfigHandler.parse_sectionc                 C   sb   | j  ¡ D ])\}}d}|rd| }t| d|  dd¡dƒ}|du r*td| j|f ƒ‚||ƒ qdS )zTParses configuration file items from one
        or more related sections.

        rR   z_%szparse_section%srS   Ú__Nz0Unsupported distribution option section: [%s.%s])rX   rT   r=   rV   r   rB   )rY   rZ   r[   Zmethod_postfixZsection_parser_methodr(   r(   r)   rJ   «  s"   üÿÿ
ízConfigHandler.parsec                    s   t ˆ ƒ‡ ‡‡fdd„ƒ}|S )zèthis function will wrap around parameters that are deprecated

        :param msg: deprecation message
        :param warning_class: class of warning exception to be raised
        :param func: function to be wrapped around
        c                     s   t  ˆˆ¡ ˆ | i |¤ŽS r�   )ÚwarningsÚwarn)ÚargsÚkwargs©ÚfuncÚmsgÚwarning_classr(   r)   Úconfig_handlerÍ  s   z@ConfigHandler._deprecated_config_handler.<locals>.config_handlerr   )rY   r¤   r¥   r¦   r§   r(   r£   r)   Ú_deprecated_config_handlerÅ  s   z(ConfigHandler._deprecated_config_handler)rm   r�   )r`   Ú
__module__Ú__qualname__Ú__doc__r   Ú__annotations__rQ   r	   r   ÚAllCommandOptionsr   rI   r\   Úpropertyra   rl   Úclassmethodry   r€   r†   r‹   Ú_Pathr‘   r“   r˜   r›   r�   rJ   r¨   r(   r(   r(   r)   r-   ±   sD   
 þý
û
&

	

r-   c                       sp   e Zd ZdZdddddœZdZ	 dejfd	d
dede	de
jdee def‡ fdd„Zedd„ ƒZdd„ Z‡  ZS )rG   rL   ÚurlÚdescriptionÚclassifiersÚ	platforms)Z	home_pageÚsummaryZ
classifierÚplatformFNr8   r   rO   r$   rN   rK   rŒ   c                    s"   t ƒ  ||||¡ || _|| _d S r�   )Úsuperr\   rK   rŒ   )rY   r8   rO   r$   rN   rK   rŒ   ©r_   r(   r)   r\   æ  s   	
zConfigMetadataHandler.__init__c                 C   sh   | j }t| j| jd�}| j}| j}||||  |dt¡||  ||¡|dƒ|  |dƒdt¡|||| j	|dœS )r]   ©rŒ   z[The requires parameter is deprecated, please use install_requires for runtime dependencies.ÚlicenseÚlicense_filezDThe license_file parameter is deprecated, use license_files instead.)r´   ÚkeywordsZprovidesÚrequiresZ	obsoletesr³   rº   r»   Zlicense_filesr²   Zlong_descriptionÚversionZproject_urls)
ry   r   r‘   rŒ   r€   r‹   r¨   r   r˜   Ú_parse_version)rY   Ú
parse_listÚ
parse_fileÚ
parse_dictZexclude_files_parserr(   r(   r)   ra   ó  s4   ü
üézConfigMetadataHandler.parsersc                 C   sn   |   || j¡}||kr+| ¡ }zt|ƒ W |S  ty*   d}t|jdi tƒ ¤Žƒ‚w t 	|  
|| j| j¡¡S )zSParses `version` option value.

        :param value:
        :rtype: str

        zCVersion loaded from {value} does not comply with PEP 440: {version}Nr(   )r‘   rŒ   rW   r   r   r   r:   r;   r   r¾   r“   rK   )rY   rE   r¾   Útmplr(   r(   r)   r¿     s   
ùÿû	z$ConfigMetadataHandler._parse_version)r`   r©   rª   rB   rQ   Zstrict_moder/   Úcurdirr­   Úboolr   rI   r   r@   r°   r\   r®   ra   r¿   Ú__classcell__r(   r(   r¸   r)   rG   Õ  s6    üùþýüûúù
!rG   r   c                       s¤   e Zd ZdZdddededejf‡ fdd„Ze	dd	„ ƒZ
d
d„ Zdd„ Zedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Z‡  ZS )"rH   rO   r8   r   r$   rN   c                    s$   t ƒ  ||||¡ |j| _i | _d S r�   )r·   r\   rM   rŒ   rK   )rY   r8   rO   r$   rN   r¸   r(   r)   r\   4  s   
zConfigOptionsHandler.__init__c                 C   s   | j |dd�S )Nú;)rx   )ry   r…   r(   r(   r)   Ú_parse_list_semicolon?  s   z*ConfigOptionsHandler._parse_list_semicolonc                 C   s   | j || jd�S )Nr¹   )r‘   rŒ   )rY   rE   r(   r(   r)   Ú_parse_file_in_rootC  s   z(ConfigOptionsHandler._parse_file_in_rootc                 C   s   |   |  |¡¡}dd„ |D ƒS )Nc                 S   s   g | ]	}|  d ¡s|‘qS )ú#)rU   )rp   r}   r(   r(   r)   rr   K  s    zAConfigOptionsHandler._parse_requirements_list.<locals>.<listcomp>)rÈ   rÉ   )rY   rE   r”   r(   r(   r)   Ú_parse_requirements_listF  s   z-ConfigOptionsHandler._parse_requirements_listc                 C   sP   | j }| j}| j}| j}|||||||  |dt¡| j| j| j| j| j	|t
|dœS )r]   zeThe namespace_packages parameter is deprecated, consider using implicit namespaces instead (PEP 420).)Zzip_safeZinclude_package_datarK   ÚscriptsZeager_resourcesZdependency_linksÚnamespace_packagesZinstall_requiresZsetup_requiresZtests_requireÚpackagesÚentry_pointsZ
py_modulesZpython_requiresÚcmdclass)ry   r†   r€   Ú_parse_cmdclassr¨   r   rË   rÈ   Ú_parse_packagesrÉ   r   )rY   rÀ   Z
parse_boolrÂ   Zparse_cmdclassr(   r(   r)   ra   M  s0   üìzConfigOptionsHandler.parsersc                 C   s   | j j}t |  |¡|| j¡S r�   )rN   rK   r   rÐ   r€   rŒ   )rY   rE   rK   r(   r(   r)   rÑ   l  s   z$ConfigOptionsHandler._parse_cmdclassc                 C   sb   ddg}|  ¡ }||vr|  |¡S |  | j di ¡¡}|j||d k| j| jd� tj	di |¤ŽS )zTParses `packages` option value.

        :param value:
        :rtype: list
        zfind:zfind_namespace:zpackages.findr   )Ú
namespacesrŒ   Zfill_package_dirNr(   )
rW   ry   Úparse_section_packages__findrX   rc   r’   rŒ   rK   r   Zfind_packages)rY   rE   Zfind_directivesZtrimmed_valueÚfind_kwargsr(   r(   r)   rÒ   p  s   
ÿ
ýz$ConfigOptionsHandler._parse_packagesc                    sR   |   || j¡}g d¢‰ t‡ fdd„| ¡ D ƒƒ}| d¡}|dur'|d |d< |S )zœParses `packages.find` configuration file section.

        To be used in conjunction with _parse_packages().

        :param dict section_options:
        )ÚwhereÚincludeÚexcludec                    s$   g | ]\}}|ˆ v r|r||f‘qS r(   r(   )rp   ÚkÚv©Z
valid_keysr(   r)   rr   •  s   $ zEConfigOptionsHandler.parse_section_packages__find.<locals>.<listcomp>rÖ   Nr   )r›   ry   r@   rT   rc   )rY   r[   Zsection_datarÕ   rÖ   r(   rÛ   r)   rÔ   ‰  s   ÿ
z1ConfigOptionsHandler.parse_section_packages__findc                 C   ó   |   || j¡}|| d< dS )z`Parses `entry_points` configuration file section.

        :param dict section_options:
        rÏ   N)r›   ry   ©rY   r[   r”   r(   r(   r)   Úparse_section_entry_pointsž  s   z/ConfigOptionsHandler.parse_section_entry_pointsc                 C   s   |   || j¡}t |¡S r�   )r›   ry   r   Zcanonic_package_data)rY   r[   Úpackage_datar(   r(   r)   Ú_parse_package_data¦  s   
z(ConfigOptionsHandler._parse_package_datac                 C   ó   |   |¡| d< dS )z`Parses `package_data` configuration file section.

        :param dict section_options:
        rß   N©rà   ©rY   r[   r(   r(   r)   Úparse_section_package_dataª  ó   z/ConfigOptionsHandler.parse_section_package_datac                 C   rá   )zhParses `exclude_package_data` configuration file section.

        :param dict section_options:
        Zexclude_package_dataNrâ   rã   r(   r(   r)   Ú"parse_section_exclude_package_data±  rå   z7ConfigOptionsHandler.parse_section_exclude_package_datac                 C   rÜ   )zbParses `extras_require` configuration file section.

        :param dict section_options:
        Zextras_requireN)r›   rË   rÝ   r(   r(   r)   Úparse_section_extras_require¸  s
   þz1ConfigOptionsHandler.parse_section_extras_requirec                 C   s$   |   || j¡}t || j¡| d< dS )z^Parses `data_files` configuration file section.

        :param dict section_options:
        Z
data_filesN)r›   ry   r   Zcanonic_data_filesrŒ   rÝ   r(   r(   r)   Úparse_section_data_filesÃ  s   z-ConfigOptionsHandler.parse_section_data_files)r`   r©   rª   rB   r­   rÅ   r   rI   r\   r¯   rÈ   rÉ   rË   r®   ra   rÑ   rÒ   rÔ   rÞ   rà   rä   ræ   rç   rè   rÆ   r(   r(   r¸   r)   rH   0  s4    þýüû

rH   )FF)r(   F)F)5r«   r/   rŸ   r<   Úcollectionsr   r   r   Útypingr   r   r   r	   r
   r   r   r   r   r   r   Zdistutils.errorsr   r   Z#setuptools.extern.packaging.versionr   r   Z&setuptools.extern.packaging.specifiersr   Zsetuptools._deprecation_warningr   rR   r   r!   r   Údistutils.distr   r   ÚPathLiker°   ZSingleCommandOptionsr­   r   r@   r*   r+   rÅ   r"   r?   r#   r6   r-   rG   rH   r(   r(   r(   r)   Ú<module>   sr    4ýÿ
üýÿÿþý
üýÿþ
ü+  &[