Sindbad~EG File Manager

Current Path : /usr/share/hplip/__pycache__/
Upload File :
Current File : //usr/share/hplip/__pycache__/fab.cpython-310.pyc

o

�/�a�a�@s@dZdZdZdZddlZddlZddlZddlTddlm	Z	m
Z
mZddlm
Z
zdd	lmZWneyMZze�e�dd
lmZWYdZ[ndZ[wwGdd�dej�Ze�eeeedeefeeef�Ze�ej �ej!d
d�\Z"Z#Z$Z%Z&Z'e&dkr�e	�(�s�e�)de�eZ%n
e	�*�s�e�)de�eZ%e%ek�r�e&dk�r�e�+d�zddl,Tddl-m.Z.Wney�e�)d�e/�0d�YnwdZ1dZ2e3e/j4�Z1e'dur�e5�6ddd�Z'e'�7�dkr�e8e9�:��Z'e�de'�e'�7�dk�rCdZze'�;d�\Z<Z=d�>e<eg�Z'Wne?�ye'Z<d�>e'eg�Z'Ynwe�de'�e@d�ZAde<ZBe�deB�eA�CeBeDjE�ZFeF�rAe1�GeA�ndZ'e'dk�rNe�d �n)e�d!e'�eH�IeHe'��e'eD_:ze:�Je:jKe:�Le'��Wne:jM�yvYnwe.�Z2e2�N�e1�Oe2�ze�d"�e1�P�Wn
eQ�y�Ynwe/�0d�dSe	�Re&�\Z3ZSeeSd#�ZTe�+d$�	e3e/j4�Z1eT�Ud�ZVeV�N�ze�d"�e1�W�WdSeQ�y�e/�0d�YdSwzdd%lXmXZXWne�y�e�)d&�e/�0d�Ynwe�ZYzeY�Z�WneQ�ye�)d'�Ynwe�[d(�e�[d)�dS)*z6.0zFax Address Bookzhp-fabz$A simple fax address book for HPLIP.�N)�*)�utils�tui�module)�input)�
import_module)�dyn_import_modc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd:dd�Zd:dd�Zdd �ZeZd!d"�Zd#d$�Zd%d&�ZeZd'd(�ZeZd)d*�ZeZd+d,�ZeZd-d.�Zd/d0�ZeZd1d2�Z e Z!d3d4�Z"e"Z#d5d6�Z$d7d8�Z%d9S);�ConsolecCs,tj�|�d|_t��|_t�d�|_	dS)NzBType 'help' for a list of commands. Type 'exit' or 'quit' to quit.z	hp-fab > )
�cmd�Cmd�__init__�intro�fax�FaxAddressBook�db�log�bold�prompt��self�r�/usr/share/hplip/fab.pyr6s
zConsole.__init__cCst|j�dS)z/Print a list of commands that have been enteredN)�print�_hist�r�argsrrr�do_hist=szConsole.do_histcC�dS�zExits from the console���rrrrr�do_exitA�zConsole.do_exitcCrrrrrrr�do_quitEr!zConsole.do_quitcCs
|�|�S)z$Exit on system end of file character)r rrrr�do_EOFJs
zConsole.do_EOFcCstj�||�dS)z�Get help on commands
           'help' or '?' with no arguments prints a list of commands for which help is available
           'help <command>' or '? <command>' gives help on <command>
        N)r
r�do_helprrrrr$NszConsole.do_helpcCs,tj�|�g|_i|_i|_|�d�dS)z�Initialization before prompting user for commands.
           Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub.
        �N)r
r�preloopr�_locals�_globals�do_listrrrrr&Ws
zConsole.preloopcCstj�|�td�dS)z�Take care of any unfinished business.
           Despite the claims in the Cmd documentaion, Cmd.postloop() is not a stub.
        z
Exiting...N)r
r�postlooprrrrrr*bszConsole.postloopcCs|j|��g7_|S)z� This method is called after the line has been input but before
            it has been interpreted. If you want to modifdy the input line
            before execution (for example, variable substitution) do it here.
        )r�strip�r�linerrr�precmdiszConsole.precmdcCs|S)z�If you want to stop the console, return something that evaluates to true.
           If you want to do some post command processing, do it here.
        r)r�stopr-rrr�postcmdqszConsole.postcmdcCr)zDo nothing on empty input lineNrrrrr�	emptylinewr!zConsole.emptylinecCst�d�dS)Nz2Unrecognized command. Use 'help' to list commands.)r�errorr,rrr�default{szConsole.defaultTFcCs�|sU	|rtt�d����}n	tt�d����}|��dkr'tt�d��dS|s3|r-dSt�d�q|rD|j�	|�durCt�d�qn|j�	|�durRt�d	�q	|S|��}|rl|j�	|�durjt�d�dS|S|j�	|�dur{t�d	�dS|S)
NTz?Enter the name to add to the group (<enter>=done*, c=cancel) ? zEnter name (c=cancel) ? �c�Canceledr%zName must not be blank.z4Name already exists. Please choose a different name.z.Name not found. Please enter a different name.)
rrrr+�lowerr�redr2r�get)rr�
fail_if_match�alt_text�nicknamerrr�get_nickname~sB

�
�
�
zConsole.get_nicknamecCs�|j��}|s\	|rtt�d����}n	tt�d����}|��dkr,tt�d��dS|s8|r2dSt�	d�q|dkrBtd	�dS|rO||vrNt�	d
�qn
||vrYt�	d�q	|S|��}|ro||vrmt�	d
�dS|S||vrzt�	d�dS|S)NTz4Enter the group to join (<enter>=done*, c=cancel) ? zEnter the group (c=cancel) ? r4r5r%z!The group name must not be blank.�Allz<Cannot specify group 'All'. Please choose a different group.z6Group already exists. Please choose a different group.z0Group not found. Please enter a different group.)
r�get_all_groupsrrrr+r6rr7r2)rrr9r:�
all_groups�	groupnamerrr�
get_groupname�sJ


�
�
�
zConsole.get_groupnamecCs\|r"|����d}|�d�r|�d�dS|�d�r"|�d�dS|�d�|�d�dS)zl
        List names and/or groups.
        list [names|groups|all|]
        dir [names|groups|all|]
        r�namr%N�gro)r+�split�
startswith�do_names�	do_groups)rr�scoperrrr)�s




zConsole.do_listc
Cs�|j��}t�|�tt�d��t|�dkrEt��}d|_	t
|���D]\}}|�d�s?|�
||d|dd�|d�f�q$|��ntd	�t�d
S)z+
        List names.
        names
        z
Names:
r)�Namez
Fax Number�Notes�Member of Group(s)�__r�notes�, �groups�(None)N�r�get_all_recordsr�debugrr�lenr�	Formatter�header�list�itemsrE�add�join�output�rr�all_entries�f�name�errrrF�s


$�

zConsole.do_namesc
Cs�|j��}t�|�tt�d��t|�r9t��}d|_	|D]}|�
|d�dd�|j�|�D��f�q|�
�ntd�t�dS)z-
        List groups.
        groups
        z	
Groups:
)�Group�MembersrNcSsg|]	}|�d�s|�qS)rL)rE)�.0�xrrr�
<listcomp> sz%Console.do_groups.<locals>.<listcomp>rPN)rr>rrSrrrTrrUrVrYrZ�
group_membersr[)rrr?r^�grouprrrrGs

(

zConsole.do_groupsc	Cs`|j|dd�}|sdS|j�|�}t�|�tt�d|��d}d}d}|d}	tt�d|����}|�	�d	krDtt�
d
��dS|sN|sNt�d�q)|sR|}d}	|D]}
|
dvret�d
�d}	nqV|	rinq*|d}tt�d|����}|�	�d	kr�tt�
d
��dS|s�|}|dr�td�g}
|dD]%}|dkr�q�tj
d|dd�\}	}|	s�tt�
d
��dS|r�|
�|�q�td�	|jdddd�}|�	�d	kr�tt�
d
��dS|s�n;|j��}||v�rt�d�tj
ddd�\}	}|	�stt�
d
��dS|�sq�||dv�rt�d�q�|
�|�q�|j�||||||
|�|�|�t�dS)zI
        Edit an name.
        edit [name]
        modify [name]
        F�r9Nz!
Edit/modify information for %s:
r%rTz&Fax Number (<enter>='%s', c=cancel) ? r4r5�Fax number must not be empty.�0123456789-(+) *#zOInvalid characters in fax number. Fax number may only contain '0123456789-(+) 'rMz!Notes (<enter>='%s', c=cancel) ? rOz
Leave or Stay in a Group:
r=zStay in group %s �*(y=yes* (stay), n=no (leave), c=cancel) ? ��
choice_promptz
Join New Group(s):
�r9r:�Group not found.zIs this a new groupz!(y=yes* (new), n=no, c=cancel) ? �TGroup already specified. Choose a different group name or press <enter> to continue.)r<rr8rrSrrrr+r6r7r2r�enter_yes_no�appendrAr>�warn�set�do_show)rrr;r`�lastname�	firstname�title�save_faxnum�faxnum�okr4�
save_notesrM�
new_groups�g�ans�	add_groupr?rrr�do_edit)s�
 

��

�
�



�

�

zConsole.do_editc	Cs�|j|dd�}|sdS|j�|�}g}td�|D]'}|�d�s,tjd|dd�\}}nq|s9tt�d	��dS|r@|�	|�qtd
�	|j
dddd
�}|��dkr]tt�d	��dS|��sbn|�	|�qF|j�||�t�dS)zQ
        Edit a group.
        editgrp [group]
        modifygrp [group]
        FrhNz
Existing Names in Group:
rLzShould '%s' stay in this group rkrlr5z
Add New Names to Group:
Tr%rnr4)
rArrfrrErrqrr7rrr<r6�
update_groups)	rrrg�old_entries�new_entriesr`r{rr;rrr�
do_editgrp�s:

�
�
�
zConsole.do_editgrpc	Cs�|j|dd�}|sdStt�d|��d}d}d}	tt�d����}|��dkr3tt�d��dS|s;t�d	�qd}|D]}|d
vrNt�d�d}nq?|rRnqtt�d
����}	|	����dkrmtt�d��dSg}
|j	�
�}	tt�d����}|��dkr�tt�d��dS|s�nA|dkr�tt�d��qt||vr�t�d�	tt�d������}
|
dvr�t�d�q�	|
dkr�qt||
vr�t�d�qt|
�|�qu|
�d�|j	�
||||||
|	�|�|�dS)zD
        Add an name.
        add [name]
        new [name]
        TrhNz
Enter information for %s:
r%zFax Number (c=cancel) ? r4r5rirjzQInvalid characters in fax number. Fax number may only contain '0123456789-(+) *#'FzNotes (c=cancel) ? z,Member of group (<enter>=done*, c=cancel) ? r=zCannot specify 'All'.roz%Is this a new group (y=yes*, n=no) ? )r%�n�yz1Please enter 'y', 'n' or press <enter> for 'yes'.r�rp)r<rrrrr+r6r7r2rr>rsrrrtru)rrr;rxrwrvrzr{r4rMrOr?r��
user_inputrrr�do_add�sr

��




�
#zConsole.do_addcCsx|j|dd�}|sdSg}	|jdddd�}|��dkr%tt�d��dS|��s*n|�|�q|j�||�t�dS)	zL
        Add a group.
        addgrp [group]
        newgrp [group]
        TrhNr%Frnr4r5)	rAr<r6rrr7rrrr�)rrrg�entriesr;rrr�	do_addgrpRs
�
zConsole.do_addgrpc
Cs�|j��}t�|�tt�d��t|�dkrDt��}d|_	t
|���D]\}}|�d�s?|�
||d|dd�|d�f�q$|��t�d	S)
z2
        View all name data.
        view
        z
View all Data:
r)rI�FaxrJrKrLrrMrNrONrQr\rrr�do_viewos


$�
zConsole.do_viewcCs�|j|dd�}|sdS|j�|�}|rDt��}d|_|�d|f�|�d|df�|�d|d	f�|�d
d�|d�f�|��nt	�
d
�t�dS)zW
        Show a name (all details).
        show [name]
        details [name]
        FrhN)�Key�ValuezName:zFax Number:rzNotes:rMzMember of Group(s):rNrOz:Name not found. Use the 'names' command to view all names.)r<rr8rrUrVrYrZr[rr2r)rrr_r`r^rrrru�s


zConsole.do_showcC�,|j|dd�}|sdS|j�|�t�dS)zE
        Remove a name.
        rm [name]
        del [name]
        FrhN)r<r�deleter)rrr;rrr�do_rm��
z
Console.do_rmcCr�)zN
        Remove a group.
        rmgrp [group]
        delgrp [group]
        FrhN)rAr�delete_groupr)rrrgrrr�do_rmgrp�r�zConsole.do_rmgrpcCst�tt�dS)z
About fab.N)r�	log_title�	__title__�__version__rrrr�do_about�szConsole.do_aboutcCsH|����}|st�d�dS|d}t|�dkr |d��}nd}|dvr/t�d|�dStj�|�s>t�d|�dS|dkrmtj�	|�d��}|d	krSd
}n|dkrZd}nt
|d
��d���}d|vrkd
}nd}|dkr�td|�|j
�|�\}}n|dvr�td|�|j
�|�\}}|s�t�|�n|�d�t�dS)z]
        Import LDIF
        import <filename> [type]
        [type] = vcf|ldif|auto
        z+You must specify a filename to import from.Nr��auto)r��ldif�vcf�vcardzInvalid type: %szFile %s not found.z.vcfr�z.ldifr��rizbegin:vcardzImporting from LDIF file %s...)r�r�zImporting from VCF file %s...r%)r+rDrr2rTr6�os�path�exists�splitext�open�readrr�import_ldif�import_vcardr))rr�filename�typ�ext�headr{�	error_strrrr�	do_import�sD


zConsole.do_importN)TF)&�__name__�
__module__�__qualname__rrr r"r#r$r&r*r.r0r1r3r<rAr)�do_dirrFrGr��	do_modifyr��do_modifygrpr��do_newr��	do_newgrpr�ru�
do_detailsr��do_delr��	do_delgrpr�r�rrrrr	4sJ	

05/g

r	F)�handle_device_printer�qt3zU%s GUI mode requires GUI support (try running with --qt4). Entering interactive mode.zU%s GUI mode requires GUI support (try running with --qt3). Entering interactive mode.zhp-fab(qt3))�FaxAddrBookFormz,Unable to load Qt3 support. Is it installed?r��ui�loc�systemzUsing system locale: %sr4�utf8�.z&Trying to load .qm file for %s locale.zhplip_%s.qmzName of .qm file: %szUsing default 'C' localezUsing locale: %szStarting GUI loop...z
.fabwindowzhp-fab(qt4))rz1Fax address book disabled - Python 2.3+ required.z
User exit.r%zDone.)\r�r��__mod__�__doc__r
�getoptr��base.g�baserrr�base.sixext.movesr�	importlibr�ImportErrorr`rrS�
base.utilsrrr	�Module�GUI_MODE�INTERACTIVE_MODE�UI_TOOLKIT_QT3�UI_TOOLKIT_QT4�UI_TOOLKIT_QT5�mod�setUsage�USAGE_FLAG_NONE�parseStdOpts�opts�
device_uri�printer_name�mode�
ui_toolkitr��canEnterGUIModer2�canEnterGUIMode4�
set_module�qt�ui.faxaddrbookformr��sys�exit�app�addrbook�QApplication�argv�	user_confr8r6�str�
QTextCodec�localerD�lrdrZ�
ValueError�QTranslator�trans�qm_file�load�prop�localization_dir�loaded�installTranslator�QLocale�
setDefault�	setlocale�LC_ALL�	normalize�Error�show�
setMainWidget�	exec_loop�KeyboardInterrupt�
import_dialog�
ui_packager��	FABWindow�fab�exec_r�console�cmdloop�inforrrr�<module>s�
��S�
��



�
�
�

�



�
��


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists