D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
saltstack
/
salt
/
lib
/
python3.10
/
site-packages
/
__pycache__
/
Filename :
gnupg.cpython-310.pyc
back
Copy
o �j; � @ s� d Z ddlZddlmZ ddlZddlZddlZddlZddlm Z m Z ddlZddlZdZ dZdZdZejdkrQzdd lmZmZmZ W n eyP dZY nw ze d ZeZeZeefZW n eyq dZeZeZefZY nw e�e�Z e j!s�e �"e�#� � d Z$ej%jdkr�d d� Z&n e�'d�Z(dd� Z&e�)� Z*dd� Z+dd� Z,dd� Z-dd� Z.dd� Z/dd� Z0dd� Z1G dd � d e2�Z3G d!d"� d"e3�Z4G d#d$� d$e3�Z5e�'d%ej6�Z7d&d'd(d)d*d+d,�Z8G d-d.� d.e3�Z9d/d0� Z:G d1d2� d2e3e;�Z<G d3d4� d4e<�Z=G d5d6� d6e=�Z>G d7d8� d8e2�Z?d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdH�Z@dIdJ� ZAG dKdL� dLe4e?�ZBG dMdN� dNe3�ZCG dOdP� dPe3�ZDG dQdR� dReC�ZEG dSdT� dTe3�ZFG dUdV� dVeF�ZGG dWdX� dXe3e?�ZHe�'dY�IdZ��ZJe�'d[ej6�ZKe�'d\�ZLG d]d^� d^e2�ZMdS )_a� A wrapper for the GnuPG `gpg` command. Portions of this module are derived from A.M. Kuchling's well-designed GPG.py, using Richard Jones' updated version 1.3, which can be found in the pycrypto CVS repository on Sourceforge: http://pycrypto.cvs.sourceforge.net/viewvc/pycrypto/gpg/GPG.py This module is *not* forward-compatible with amk's; some of the old interface has changed. For instance, since I've added decrypt functionality, I elected to initialize with a 'gnupghome' argument instead of 'keyring', so that gpg can find both the public and secret keyrings. I've also altered some of the returned objects in order for the caller to not have to know as much about the internals of the result classes. While the rest of ISconf is released under the GPL, I am releasing this single file under the same terms that A.M. Kuchling used for pycrypto. Steve Traugott, stevegt@terraluna.org Thu Jun 23 21:27:20 PDT 2005 This version of the module has been modified from Steve Traugott's version (see http://trac.t7a.org/isconf/browser/trunk/lib/python/isconf/GPG.py) by Vinay Sajip to make use of the subprocess module (Steve's version uses os.fork() and so does not work on Windows). Renamed to gnupg.py to avoid confusion with the previous versions. Modifications Copyright (C) 2008-2023 Vinay Sajip. All rights reserved. For the full documentation, see https://docs.red-dove.com/python-gnupg/ or https://gnupg.readthedocs.io/ � N)�StringIO)�Popen�PIPEz0.5.2zVinay Sajipz$12-Dec-2023 07:52:07$�nt)�STARTUPINFO�STARTF_USESHOWWINDOW�SW_HIDEFT�ntpathc C s d| S )Nz"%s"� ��sr r �9/opt/saltstack/salt/lib/python3.10/site-packages/gnupg.py�shell_quoteT s r z[^\w%+,./:=@-]c C sL t | t�s tdt| � ��| sd}|S t�| �s| }|S d| �dd� }|S )au Quote text so that it is safe for POSIX command shells. For example, "*.py" would be converted to "'*.py'". If the text is considered safe it is returned unquoted. Args: s (str): The value to quote Returns: str: A safe version of the input, from the point of view of POSIX command shells. zExpected string type, got %sz''z'%s'�'z'\'')� isinstance�string_types� TypeError�type�UNSAFE�search�replace)r �resultr r r r ] s ��c C s t st| t�r| �t�} | S )z7 Legacy function which is a no-op on Python 3. )�_py3kr � text_type�encode� fsencodingr r r r �no_quote� s r c C s� |dksJ �d}t tjd�rtjj}nd} z| �|�}W n ty- tjddd� Y n1w |s1n-|t|�7 }z|� |� W n t yO |� |�|�� Y n ty\ t�d� Y nw qz|� � W n tyt tjd dd� Y nw t�d |� d S )Nr �encoding�asciiTz Exception occurred while reading� )�exc_infozError sending dataz)Exception occurred while closing: ignoredzclosed output, %d bytes sent)�hasattr�sys�stdinr �read� Exception�logger�warning�len�write�UnicodeErrorr � exception�close�IOError�debug)�instream� outstream�buffer_size�sent�enc�datar r r � _copy_data� s<