⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.45
Server IP:
185.238.29.86
Server:
Linux server2 6.8.12-6-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-6 (2024-12-19T19:05Z) x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.31
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
lib
/
python3
/
dist-packages
/
__pycache__
/
View File Name :
texttable.cpython-38.pyc
U �]X � @ s, d Z ddlmZ ddgZdZdZdZdZdd lZdd l Z zdd l Z d d� ZW nL ek r� zdd l Z dd� ZW n" ek r� ej�d � � Y nX Y nX zdd lZdd� ZW n ek r� dd� ZY nX ddlmZ ejdkr�eZeZneZeZdd� Zdd� ZG dd� de�ZG dd� de�ZG dd� d�Ze dk�r(e� Z!e!�"dddg� e!�#dd d!g� e!�$d"d#d$gd%d&d'gd(d)d*gd+d,d-gg� e%e!�&� d. � e� Z!e!�'ej(� e!�)dd/d0d1d2g� e!�"dddddg� e!�$d3d4d5d6d7gd8d9d:d;d<gd=d>d?d@dAgdBdCdCdDdEgdFdGdHdIdJgg� e%e!�&� � d S )Ka� module for creating simple ASCII tables Example: table = Texttable() table.set_cols_align(["l", "r", "c"]) table.set_cols_valign(["t", "m", "b"]) table.add_rows([["Name", "Age", "Nickname"], ["Mr\nXavier\nHuon", 32, "Xav'"], ["Mr\nBaptiste\nClement", 1, "Baby"], ["Mme\nLouise\nBourgeau", 28, "Lou\n\nLoue"]]) print table.draw() + "\n" table = Texttable() table.set_deco(Texttable.HEADER) table.set_cols_dtype(['t', # text 'f', # float (decimal) 'e', # float (exponent) 'i', # integer 'a']) # automatic table.set_cols_align(["l", "r", "r", "r", "l"]) table.add_rows([["text", "float", "exp", "int", "auto"], ["abcd", "67", 654, 89, 128.001], ["efghijk", 67.5434, .654, 89.6, 12800000000000000000000.00023], ["lmn", 5e-78, 5e-78, 89.4, .000000000000128], ["opqrstu", .023, 5e+78, 92., 12800000000000000000000]]) print table.draw() Result: +----------+-----+----------+ | Name | Age | Nickname | +==========+=====+==========+ | Mr | | | | Xavier | 32 | | | Huon | | Xav' | +----------+-----+----------+ | Mr | | | | Baptiste | 1 | | | Clement | | Baby | +----------+-----+----------+ | Mme | | Lou | | Louise | 28 | | | Bourgeau | | Loue | +----------+-----+----------+ text float exp int auto =========================================== abcd 67.000 6.540e+02 89 128.001 efgh 67.543 6.540e-01 90 1.280e+22 ijkl 0.000 5.000e-78 89 0.000 mnop 0.023 5.000e+78 92 1.280e+22 � )�division� Texttable�ArraySizeErrorz%Gerome Fournier <jef(at)foutaise.org>ZMITz1.6.2a� Jeff Kowalczyk: - textwrap improved import - comment concerning header output Anonymous: - add_rows method, for adding rows in one go Sergey Simonenko: - redefined len() function to deal with non-ASCII characters Roger Lew: - columns datatype specifications Brian Peterson: - better handling of unicode errors Frank Sachsenheim: - add Python 2/3-compatibility Maximilian Hils: - fix minor bug for Python 3 compatibility frinkelpi: - preserve empty lines Nc C s t �| |�S �N)�cjkwrap�wrap�Ztxt�width� r �+/usr/lib/python3/dist-packages/texttable.py�textwrapperf s r c C s t �| |�S r )�textwrapr r r r r r k s zCan't import textwrap module! c C s t dt�| ��S )�:Return the rendering width of a unicode character r )�max�wcwidth��cr r r �uchar_widthv s r c C s( t �| �dkrdS t �| �r dS dS dS )r ZWF� r � N)�unicodedataZeast_asian_widthZ combiningr r r r r { s )�reduce)� r c C sz t | t�r| S t | t�rnzt| d�W S tk rj } z(tj�d| |f � t| dd� W Y �S d}~X Y qvX nt| �S dS )z7Return a unicode representation of a python object zutf-8z1UnicodeDecodeError exception for string '%s': %s �replaceN)� isinstance�unicode_type� bytes_type�UnicodeDecodeError�sys�stderr�write)�obj�strerrorr r r �obj2unicode� s $r# c C s6 t | t�st | t�r*tdd� t| �D ��S | �� S dS )zMRedefining len here so it will be able to work with non-ASCII characters c S s g | ]}t |��qS r )r )�.0r r r r � <listcomp>� s zlen.<locals>.<listcomp>N)r r r �sumr# �__len__)�iterabler r r �len� s r) c @ s e Zd ZdZdd� Zdd� ZdS )r zEException raised when specified rows don't fit the required size c C s || _ t�| |d� d S )N� )�msg� Exception�__init__)�selfr+ r r r r- � s zArraySizeError.__init__c C s | j S r )r+ �r. r r r �__str__� s zArraySizeError.__str__N)�__name__� __module__�__qualname__�__doc__r- r0 r r r r r � s c @ s e Zd ZdZdS )�FallbackToTextz#Used for failed conversion to floatN)r1 r2 r3 r4 r r r r r5 � s r5 c @ sT e Zd ZdZdZdZdZdOdd�Zdd � Zd d� Z dd � Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zdd� Zdd� Zdd� ZdPd!d"�Zd#d$� Zed%d&� �Zed'd(� �Zed)d*� �Zed+d,� �Zed-d.� �Zed/d0� �Zd1d2� Zd3d4� Zd5d6� Zd7d8� Z d9d:� Z!d;d<� Z"d=d>� Z#d?d@� Z$dQdBdC�Z%dDdE� Z&dFdG� Z'dHdI� Z(dRdJdK�Z)dLdM� Z*dNS )Sr r r � � �P c C sH | � |� d| _tjtjB tjB tjB | _| �ddddg� | � � dS )z�Constructor - max_width is an integer, specifying the maximum width of the table - if set to 0, size is unlimited, therefore cells won't be wrapped r �-�|�+�=N) � set_max_width� _precisionr �VLINES�HLINES�BORDER�HEADER�_deco� set_chars�reset�r. Z max_widthr r r r- � s �zTexttable.__init__c C s d| _ d| _g | _g | _| S )z<Reset the instance - reset rows and header N)� _hline_string� _row_size�_header�_rowsr/ r r r rE � s zTexttable.resetc C s |dkr|nd| _ | S )z�Set the maximum width of the table - max_width is an integer, specifying the maximum width of the table - if set to 0, size is unlimited, therefore cells won't be wrapped r F)� _max_widthrF r r r r= � s zTexttable.set_max_widthc C sD t |�dkrtd��dd� dd� |D �D �}|\| _| _| _| _| S )z�Set the characters used to draw lines between rows and columns - the array should contain 4 fields: [horizontal, vertical, corner, header] - default is set to: ['-', '|', '+', '='] r6 z!array should contain 4 charactersc S s g | ]}|d d� �qS )Nr r �r$ �xr r r r% � s z'Texttable.set_chars.<locals>.<listcomp>c S s g | ]}t |��qS r )�str)r$ �sr r r r% � s )r) r �_char_horiz� _char_vert�_char_corner�_char_header�r. �arrayr r r rD � s � zTexttable.set_charsc C s || _ | S )a� Set the table decoration - 'deco' can be a combinaison of: Texttable.BORDER: Border around the table Texttable.HEADER: Horizontal line below the header Texttable.HLINES: Horizontal lines between rows Texttable.VLINES: Vertical lines between columns All of them are enabled by default - example: Texttable.BORDER | Texttable.HEADER )rC )r. Zdecor r r �set_deco� s zTexttable.set_decoc C s | � |� || _| S )z�Set the desired header alignment - the elements of the array should be either "l", "c" or "r": * "l": column flushed left * "c": column centered * "r": column flushed right )�_check_row_size� _header_alignrT r r r �set_header_align s zTexttable.set_header_alignc C s | � |� || _| S )z�Set the desired columns alignment - the elements of the array should be either "l", "c" or "r": * "l": column flushed left * "c": column centered * "r": column flushed right )rW �_alignrT r r r �set_cols_align s zTexttable.set_cols_alignc C s | � |� || _| S )a, Set the desired columns vertical alignment - the elements of the array should be either "t", "m" or "b": * "t": column aligned on the top of the cell * "m": column aligned on the middle of the cell * "b": column aligned on the bottom of the cell )rW �_valignrT r r r �set_cols_valign& s zTexttable.set_cols_valignc C s | � |� || _| S )a. Set the desired columns datatype for the cols. - the elements of the array should be either a callable or any of "a", "t", "f", "e" or "i": * "a": automatic (try to use the most appropriate datatype) * "t": treat as text * "f": treat as float in decimal format * "e": treat as float in exponential format * "i": treat as int * a callable: should return formatted string for any value given - by default, automatic datatyping is used for each column )rW �_dtyperT r r r �set_cols_dtype4 s zTexttable.set_cols_dtypec C s\ | � |� z$ttt|��}tt|�dkr,t�W n" tk rP tj� d� � Y nX || _ | S )z�Set the desired columns width - the elements of the array should be integers, specifying the width of each column. For example: [10, 20, 5] r z-Wrong argument in column width specification )rW �list�map�intr �min� ValueErrorr r r �_widthrT r r r �set_cols_widthH s zTexttable.set_cols_widthc C s&