U
    cc                     @   s   d Z ddlZddlmZ ddlmZmZmZmZ ddl	m
Z
 ddlmZmZ ddlmZ eeZd	d
dgZeddG dd dZG dd	 d	ZG dd
 d
ZG dd deZdS )z
Module defining common API types for use by rules and policies.

In principle, these aren't relevant to the high-level validation API.
    N)	dataclass)IterableOptionalTupleUnion)	Reference)HistoricalResolver
RawPdfPath   )ModificationLevelQualifiedWhitelistRuleWhitelistRuleReferenceUpdateT)frozenc                   @   sJ   e Zd ZU eed< dZeeee	e f  ed< dZ
eed< edd ZdS )r   updated_refNpaths_checkedFblanket_approvec                    s    fddS )Nc                    s    f d| iS )Nr    )refclskwargsr   ^/var/www/html/project/venv/lib/python3.8/site-packages/pyhanko/sign/diff_analysis/rules_api.py<lambda>(       z+ReferenceUpdate.curry_ref.<locals>.<lambda>r   r   r   r   r   	curry_ref&   s    zReferenceUpdate.curry_ref)__name__
__module____qualname__r   __annotations__r   r   r   r	   r   r   boolclassmethodr   r   r   r   r   r      s   
c                   @   s.   e Zd ZdZeeeeeef  dddZ	dS )r   a  
    Abstract base class for a whitelisting rule that outputs references together
    with the modification level at which they're cleared.

    This is intended for use by complicated whitelisting rules that need to
    differentiate between multiple levels.
    oldnewreturnc                 C   s   t dS z
        Apply the rule to the changes between two revisions.

        :param old:
            The older, base revision.
        :param new:
            The newer revision to be vetted.
        NNotImplementedErrorselfr#   r$   r   r   r   apply_qualified4   s    
z&QualifiedWhitelistRule.apply_qualifiedN)
r   r   r   __doc__r   r   r   r   r   r+   r   r   r   r   r   +   s   c                   @   s6   e Zd ZdZeeee dddZee	dddZ
dS )	r   aM  
    Abstract base class for a whitelisting rule that simply outputs
    cleared references without specifying a modification level.

    These rules are more flexible than rules of type
    :class:`.QualifiedWhitelistRule`, since the modification level can be
    specified separately (see :meth:`.WhitelistRule.as_qualified`).
    r"   c                 C   s   t dS r&   r'   r)   r   r   r   applyK   s    
zWhitelistRule.apply)levelr%   c                 C   s
   t | |S )ae  
        Construct a new :class:`QualifiedWhitelistRule` that whitelists the
        object references from this rule at the level specified.

        :param level:
            The modification level at which the output of this rule should be
            cleared.
        :return:
            A :class:`.QualifiedWhitelistRule` backed by this rule.
        )_WrappingQualifiedWhitelistRule)r*   r.   r   r   r   as_qualifiedW   s    zWhitelistRule.as_qualifiedN)r   r   r   r,   r   r   r   r-   r   r   r0   r   r   r   r   r   A   s
   	c                   @   s:   e Zd ZeedddZeeeeee	f  dddZ
dS )r/   ruler.   c                 C   s   || _ || _d S Nr1   )r*   r2   r.   r   r   r   __init__g   s    z(_WrappingQualifiedWhitelistRule.__init__r"   c                 c   s$   | j ||D ]}| j|fV  qd S r3   )r2   r-   r.   )r*   r#   r$   r   r   r   r   r+   k   s    z/_WrappingQualifiedWhitelistRule.apply_qualifiedN)r   r   r   r   r   r4   r   r   r   r   r+   r   r   r   r   r/   e   s   r/   )r,   loggingdataclassesr   typingr   r   r   r   Zpyhanko.pdf_utils.genericr   Zpyhanko.pdf_utils.readerr   r	   Z
policy_apir   	getLoggerr   logger__all__r   r   r   r/   r   r   r   r   <module>   s    
  $