관리-도구
편집 파일: lifecycle.cpython-39.pyc
a ����'�Dg"������������������� ���@���s����d�dl�Z�d�dlZd�dlZd�dlmZmZ�d�dlmZ�d�dlm Z �e� e�ZG�dd��de�Z ejG�dd��de��dg�d ����Zeeed �dd�Zejeeed �dd�Zdddd�eeee�eee d�dd�Zdd�eeed�dd�ZdS�)�����N)� NamedTuple�Optional)�features)�loggersc�������������������@���s���e�Zd�ZU�eed<�eed<�dS�)�DeprecationLogZ log_level�messageN)�__name__� __module__�__qualname__�int�__annotations__�str��r���r����7/usr/lib/python3.9/site-packages/cloudinit/lifecycle.pyr��� ���s��� r���c�����������������������s|���e�Zd�ZdZdeeeed�d���fdd� Zeed�d�dd��Zd d ��Z dd��Z d d��Zdd��Zdd��Z d�ed�dd�Z���ZS�)�Versiona>��A class for comparing versions. Implemented as a named tuple with all ordering methods. Comparisons between X.Y.N and X.Y always treats the more specific number as larger. :param major: the most significant number in a version :param minor: next greatest significant number after major :param patch: next greatest significant number after minor :param rev: the least significant number in a version :raises TypeError: If invalid arguments are given. :raises ValueError: If invalid arguments are given. Examples: >>> Version(2, 9) == Version.from_str("2.9") True >>> Version(2, 9, 1) > Version.from_str("2.9.1") False >>> Version(3, 10) > Version.from_str("3.9.9.9") True >>> Version(3, 7) >= Version.from_str("3.7") True ���)�major�minor�patch�rev�returnc��������������������s���t�t|���|�||||�S�)zPDefault of -1 allows us to tiebreak in favor of the most specific number)�superr����__new__)�clsr���r���r���r����� __class__r���r���r���/���s����zVersion.__new__)�versionr���c�����������������C���s���|�t�tt|�d�����S�)a%��Create a Version object from a string. :param version: A period-delimited version string, max 4 segments. :raises TypeError: Raised if invalid arguments are given. :raises ValueError: Raised if invalid arguments are given. :return: A Version object. �.)�list�mapr����split)r���r���r���r���r����from_str6���s����zVersion.from_strc�����������������C���s���d|���|�kS�)N����)�_compare_version��self�otherr���r���r����__gt__C���s����zVersion.__gt__c�����������������C���s0���|�j�|j�ko.|�j|jko.|�j|jko.|�j|jkS��N�r���r���r���r���r$���r���r���r����__eq__F���s���� � � �zVersion.__eq__c�����������������c���s6���|�j�|�j|�j|�jfD�]}|dkr,t|�V��q�q2qdS�)z)Iterate over the version (drop sentinels)r���N)r���r���r���r���r ���)r%����nr���r���r����__iter__N���s����zVersion.__iter__c�����������������C���s ���d��|��S�)Nr���)�join�r%���r���r���r����__str__V���s����zVersion.__str__c�����������������C���s���t�t|���S�r(���)�hashr ���r.���r���r���r����__hash__Y���s����zVersion.__hash__)r&���r���c�����������������C���sP���|�|krdS�|�j�|j�krdS�|�j|jkr,dS�|�j|jkr<dS�|�j|jkrLdS�dS�)z�Compare this Version to another. :param other: A Version object. :return: -1 if self > other, 1 if self < other, else 0 r���r"���r���r)���r$���r���r���r���r#���\���s����zVersion._compare_version)r���r���r���r���)r���r ���r ����__doc__r���r����classmethodr ���r!���r'���r*���r,���r/���r1���r#���� __classcell__r���r���r���r���r������s������r���r)���)r����boundary_versionr���c�����������������C���s���|dkpt��|��t��|�kS�)a��Determine if a deprecation message should be logged. :param version: The version in which the thing was deprecated. :param boundary_version: The version at which deprecation level is logged. :return: True if the message should be logged, else False. Zdevel)r���r!���)r���r5���r���r���r����should_log_deprecationp���s ������r6���)�loggerr����requested_level�msgc�����������������C���s,���t�|tj�r|��|||��n|��||��dS�)au��Log a message at the requested level, if that is acceptable. If the log level is too high due to the version boundary, log at DEBUG level. Useful to add new warnings to previously unguarded code without disrupting stable downstreams. :param logger: Logger object to log with :param version: Version string of the version that this log was introduced :param level: Preferred level at which this message should be logged :param msg: Message, as passed to the logger. :param args: Message formatting args, as passed to the logger :return: True if the message should be logged, else False. N)r6���r����DEPRECATION_INFO_BOUNDARY�log�debug)r7���r���r8���r9����argsr���r���r����log_with_downgradable_level}���s����r>�������F)� extra_message�schedule�skip_log)� deprecated�deprecated_versionr@���rA���rB���r���c�����������������C���s����t�td�sttdt����|pd}t|�|�|�t|���}t�|�}t|j|�|j �}|���d|��d|��d|���� ��} t|tj �s�tj} nt�td�r�tj} ntj} ttd�}|s�||vr�|�|��t�| | ��t| | �S�)a���Mark a "thing" as deprecated. Deduplicated deprecations are logged. :param deprecated: Noun to be deprecated. Write this as the start of a sentence, with no period. Version and extra message will be appended. :param deprecated_version: The version in which the thing was deprecated :param extra_message: A remedy for the user's problem. A good message will be actionable and specific (i.e., don't use a generic "Use updated key." if the user used a deprecated key). End the string with a period. :param schedule: Manually set the deprecation schedule. Defaults to 5 years. Leave a comment explaining your reason for deviation if setting this value. :param skip_log: Return log text rather than logging it. Useful for running prior to logging setup. :return: NamedTuple containing log level and log message DeprecationLog(level: int, message: str) Note: uses keyword-only arguments to improve legibility r;�����z is deprecated in z and scheduled to be removed in z. rC���)�hasattr� deprecate�setattr�setr0���r ���r���r!���r���r����rstripr6���r���r:����logging�INFO�LOGr���Z DEPRECATEDZWARN�getattr�addr;���r���)rC���rD���r@���rA���rB���r���Zdedupr���Zversion_removedZ deprecate_msg�levelZ log_cacher���r���r���rG�������s4���� ����� rG���)rA����rD���r@���rA���c��������������������s�������fdd�}|S�)a~��Mark a "thing" as deprecated. Deduplicated deprecations are logged. :param deprecated_version: The version in which the thing was deprecated :param extra_message: A remedy for the user's problem. A good message will be actionable and specific (i.e., don't use a generic "Use updated key." if the user used a deprecated key). End the string with a period. :param schedule: Manually set the deprecation schedule. Defaults to 5 years. Leave a comment explaining your reason for deviation if setting this value. Note: uses keyword-only arguments to improve legibility c��������������������s ���t����������fdd��}|S�)Nc���������������������s$����|�i�|��}t����j��d��|S�)N)rD���rC���r@���rA���)rG���r���)r=����kwargs�out)rD���r@����funcrA���r���r���� decorator����s�����z2deprecate_call.<locals>.wrapper.<locals>.decorator)� functools�wraps)rT���rU���rQ���)rT���r����wrapper����s����zdeprecate_call.<locals>.wrapperr���)rD���r@���rA���rX���r���rQ���r����deprecate_call����s����rY���)�collectionsrV���rK����typingr���r���Z cloudinitr���Z cloudinit.logr���Z getLoggerr���rM���r����total_ordering� namedtupler���r ����boolr6���ZLoggerr���r>���rG���rY���r���r���r���r����<module>���s@��� �]� ��9��