관리-도구
편집 파일: argparse_utils.cpython-311.pyc
� �Cg�, � �� � d Z ddlZddlZddlZddlmZ ddlmZmZ G d� dej � � Z G d� dej � � Zd � Z d � Zd� Zd� Zd � Zd� Zd� Zdd�Zd� ZdZd� Zd� Zd� ZdS )z: Extensions for validation and output formatting argparse � N)�PrettyTable)� parse_date� parse_period2c � � e Zd ZdZd� Zd� ZdS )�SmartFormattera# Format argparse help in many line, to format many lines use "R|" at start line >>>import argparse >>>parser = argparse.ArgumentParser(formatter_class=SmartFormatter) >>>parser.add_argument('-a', '--argument', help="R| Descriptions: \n first new line\n second new line") c � � |� d� � r|dd � � � � S t j � | ||� � S )NzR|� )� startswith� splitlines�argparse� HelpFormatter�_split_lines)�self�text�widths ��/builddir/build/BUILDROOT/lve-stats-4.2.10-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/commons/argparse_utils.pyr zSmartFormatter._split_lines sK � ��?�?�4� � � )�����8�&�&�(�(�(��%�2�2�4��u�E�E�E� c �� � t |t � � r.| � ||� � }t |d� � � � S t j � | ||� � S )N� )� isinstance� ParseDatetime�_metavar_formatter�strr r �_format_args)r �action�default_metavar�get_metavars r r zSmartFormatter._format_args! sZ � ��f�m�,�,� '��1�1�&�/�J�J�K��{�{�1�~�~�&�&�&��%�2�2�4���Q�Q�Qr N)�__name__� __module__�__qualname__�__doc__r r � r r r r sD � � � � � �� �F� F� F� R� R� R� R� Rr r c � � e Zd ZdZdd�ZdS )r z� Interprets a string ([YY]YY-MM-DD[ HH:MM]) as a datetime for argument parsing. return parsed data as <type 'datetime.datetime'> Nc � � t |d� � rd� |� � n|} t |� � }n+# t $ r}t j | |� d�� � |�d }~ww xY wt || j |� � d S )N�__iter__� z/ is an invalid; use [YY]YY-MM-DD[ HH:MM] format)�hasattr�joinr � ValueErrorr � ArgumentError�setattr�dest)r �parser� namespace�values� option_string�datetime_str�result_datetime�es r �__call__zParseDatetime.__call__- s� � �+2�6�:�+F�+F�R�s�x�x��'�'�'�F�� �(��6�6�O�O��� � � ��(���P�P�P�� � � ����� ���� � �4�9�o�6�6�6�6�6s �9 � A!�A�A!�N)r r r r! r4 r"