HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/samba/netcmd/__pycache__/__init__.cpython-310.pyc
o

�/a�&�@s�ddlZddlZddlmZddlmZddlmZddlmZddl	Z	ddl
Z
ddlZGdd�de�ZGdd	�d	ej
�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZdS)�N)�colour)�SambaOption)�get_samba_logger)�LdbErrorc@seZdZejZdS)�OptionN)�__name__�
__module__�__qualname__�optparse�
SUPPRESS_HELP�rr�7/usr/lib/python3/dist-packages/samba/netcmd/__init__.pyrsrc@seZdZddd�Zdd�ZdS)�PlainHelpFormatter�csF|j|j�d|j�|�d�}��fdd�|D�}d�|�d}|S)N� �
csg|]}tj|���d��qS))�initial_indent�subsequent_indent)�textwrap�fill)�.0�p��
desc_width�indentrr
�
<listcomp>*s���z9PlainHelpFormatter.format_description.<locals>.<listcomp>)�width�current_indent�split�join)�self�description�
paragraphs�wrapped_paragraphs�resultrrr
�format_description&s

�z%PlainHelpFormatter.format_descriptioncCs|rd|dSdS)Nrrr)r �epilogrrr
�
format_epilog3sz PlainHelpFormatter.format_epilogN)r)rrr	r%r'rrrr
r%s

rc@s�eZdZdZdd�Zee�Zdd�Zee�Zdd�Z	ee	�Z
dZgZgZ
iZd	ZdZdZdZejejfd
d�Zddd
�Zdd�Zddd�Zdd�Zdd�Zdd�Zddd�Zdd�ZdS) �CommandzA samba-tool command.cCs|j��d�d�S)Nrr)�__doc__�
splitlines�rstrip�r rrr
�_get_short_description=�zCommand._get_short_descriptioncCs0|j�d�}|ddt�d�|dd���S)Nrr�)r)rr�dedentr)r �linesrrr
�_get_full_descriptionBs$zCommand._get_full_descriptioncCs"|jj}|�d�r|dd�S|S)N�cmd_�)�	__class__r�
startswith)r �namerrr
�	_get_nameHs
zCommand._get_nameNFcCs||_||_dS�N)�outf�errf)r r:r;rrr
�__init__]s
zCommand.__init__cCs|�|�\}}|��dSr9)�_create_parser�print_usage)r �prog�parser�_rrr
�usageasz
Command.usagec
Cs2t|t�r|j\}}}|j}|j}d}n
t��\}}}|}d}d}t|t�r6|j\}}	|j	�
d||	f�nOt|t�rF|j	�
d|�d}n?t|t�rV|j	�
d||f�n/t
|�turi|j	�
d||f�d}n|durv|j	�
d	|�n|j	�
d
t|�||f�d}|s�t��dkr�tj||j	d�dSdS)
zdisplay a command errorFzuncaught exceptionTzERROR(ldb): %s - %s
zERROR(assert): %s
zERROR(runtime): %s - %s
zERROR(exception): %s - %s
Nz
ERROR: %s
zERROR(%s): %s - %s
�)�file)�
isinstance�CommandError�exception_info�inner_exception�message�sys�exc_infor�argsr;�write�AssertionError�RuntimeError�type�	Exception�str�samba�get_debug_level�	traceback�print_tb)
r �e�etype�evalue�
etracebackrHrI�force_traceback�	ldb_ecode�ldb_emsgrrr
�show_command_errores6




�zCommand.show_command_errorcCsjtj|j|jt�||d�}|�|j�i}t|j�	��D]}|j|}||�||<|�
||�q||fS)N)rBr!�	formatterr?r&)r
�OptionParser�synopsis�full_descriptionr�add_options�
takes_options�sorted�takes_optiongroups�keys�add_option_group)r r?r&r@�optiongroupsr7�optiongrouprrr
r=�s�
zCommand._create_parsercCs|j�|d�dS)Nr)r:rM)r �textrrr
rI�r.zCommand.messagec
GsV|�|d�\}}|�t|��\}}|dd�}t|j�}|jD]}|jD]}|jdur0||j=q%q |�|�d}	d}
d}t	|j
�D]'\}}
|
ddkrV|
ddkrV|	d7}	|
ddksb|
ddkred}qB|
d7}
qBt|�|	ksx|s~t|�|
kr~|��dSt|�|_
||_||_z	|j|i|��WSty�}z|�|�WYd}~dSd}~ww)	Nrr/F����?�*�+T)r=�
parse_args�list�dict�__dict__�
option_groups�option_list�dest�update�	enumerate�
takes_args�lenr>�raw_argv�raw_args�
raw_kwargs�runrQr^)r �argvr@ri�optsrL�kwargs�option_group�option�min_args�max_args�undetermined_max_args�i�argrWrrr
�_run�sB



��



��zCommand._runcCs
t|j��)z=Run the command. This should be overridden by all subclasses.)�NotImplementedErrorr~r,rrr
r~�s
zCommand.runrcKs td|p|j|j||d�|��S)zGet a logger object.)r7�stream�verbose�quietNr)rr7r;)r r7r�r�r�rrr
�
get_logger�s��zCommand.get_loggercCsn|��}|dkrt��dS|dkrt��dS|dkr3t|jd�r-|j��r-t��dSt��dStd��)z�Heuristics to work out whether the user wants colour output, from a
        --color=yes|no|auto option. This alters the ANSI 16 bit colour
        "constants" in the colour module to be either real colours or empty
        strings.
        �no�yes�auto�isattyz;Unknown --color option: %s please choose from yes, no, autoN)�lowerr�switch_colour_off�switch_colour_on�hasattrr:r�rF)r �	requestedrrr
�apply_colour_choice�szCommand.apply_colour_choicer9)NN)rFF)rrr	r)r-�property�short_descriptionr2rbr8r7raryrdrf�hiddenr{r|r}rJ�stdout�stderrr<rBr^r=rIr�r~r�r�rrrr
r(:s2

!(
r(c@s"eZdZdZdZiZddd�ZdS)�SuperCommandz&A samba-tool command with subcommands.z%prog <subcommand>NcGs|||jvr|j|jd||fg|�R�S|dvr#td||f�g}|dkrht|�dkrf|j�|d�}t|t�rN|jd||dfdg|dd��R�S|durf|jd||dfdg|dd��R�Sd}d}t|j���}|�	�t
d	d
�|D��}|D]}|j|}	|	js�|d|||	jf7}q�|d|7}|j
||d
�\}
}t|�}|r�|�d|�|
�|�\}
}|
��dS)Nz%s %s)�--help�helpNz-hz-Vz	--versionz%s: no such subcommand: %s
r�rr/r�z
Available subcommands:
cSsg|]}t|��qSr)rz)r�crrr
rsz%SuperCommand._run.<locals>.<listcomp>z  %*s  - %s
zQFor more help on a specific subcommand, please type: %s <subcommand> (-h|--help)
)r&rl)�subcommandsr��printrz�getrEr�rqrg�sort�maxr�r�r=�insertrp�
print_help)r �myname�
subcommandrL�subr&�subcmds�
max_length�cmd_name�cmdr@ri�	args_listr�rrr
r��sP


��

�
�

��zSuperCommand._runr9)rrr	r)rar�r�rrrr
r��s
r�c@s"eZdZdZddd�Zdd�ZdS)rFz1An exception class for samba-tool Command errors.NcCs||_||_t��|_dSr9)rIrHrJrKrG)r rIrHrrr
r<szCommandError.__init__cCs
d|jS)NzCommandError(%s))rIr,rrr
�__repr__s
zCommandError.__repr__r9)rrr	r)r<r�rrrr
rFs
rF)r
rSr�samba.getoptr�samba.loggerr�ldbrrJrUrr�IndentedHelpFormatterr�objectr(r�rQrFrrrr
�<module>s)1