Repository URL to install this package:
| 
      
        
        
        Version: 
        
         
          
          3.4.52  ▾
        
         | 
ó
°EYc           @   s  d  d l  Z  d  d l Z d  d l m Z d  d l m Z d  d l m Z d  d l m	 Z	 m
 Z
 m Z m Z d  d l
 m Z d  d l m Z d  d l m Z m Z d  d	 l m Z d  d
 l m Z d  d l m Z d e f d
     YZ d e f d     YZ d f  d     YZ d S(   iÿÿÿÿN(   t   MutableMapping(   t   sha1(   t   HMAC(   t   bt   ut   encodebytest   decodebytes(   t   DSSKey(   t   RSAKey(   t
   get_loggert   constant_time_bytes_eq(   t   ECDSAKey(   t
   Ed25519Key(   t   SSHExceptiont   HostKeysc           B   sª   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z
 d   Z d   Z d
   Z d   Z d   Z e d d   Z RS(   sZ  
    Representation of an OpenSSH-style "known hosts" file.  Host keys can be
    read from one or more files, and then individual hosts can be looked up to
    verify server keys during SSH negotiation.
    A `.HostKeys` object can be treated like a dict; any dict lookup is
    equivalent to calling `lookup`.
    .. versionadded:: 1.5.3
    c         C   s)   g  |  _  | d k	 r% |  j |  n  d S(   s¿   
        Create a new HostKeys object, optionally loading keys from an OpenSSH
        style host-key file.
        :param str filename: filename to load host keys from, or ``None``
        N(   t   _entriest   Nonet   load(   t   selft   filename(    (    sF   /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/hostkeys.pyt   __init__1   s    	c         C   se   xB |  j  D]7 } | | j k r
 | j j   | k r
 | | _ d Sq
 W|  j  j t | g |   d S(   s.  
        Add a host key entry to the table.  Any existing entry for a
        ``(hostname, keytype)`` pair will be replaced.
        :param str hostname: the hostname (or IP) to add
        :param str keytype: key type (``"ssh-rsa"`` or ``"ssh-dss"``)
        :param .PKey key: the key to add
        N(   R   t	   hostnamest   keyt   get_namet   appendt   HostKeyEntry(   R   t   hostnamet   keytypeR   t   e(    (    sF   /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/hostkeys.pyt   add=   s
    	$	c         C   s  t  | d  û } xñ t | d  D]à \ } } | j   } t |  d k s" | d d k rb q" n  y t j | |  } Wn t k
 r q" n X| d k	 r" | j } x6 | D]. } |  j	 | | j
  r« | j j |  q« q« Wt | j  r|  j j
 |  qq" q" WWd QXd S(   s]  
        Read a file of known SSH host keys, in the format used by OpenSSH.
        This type of file unfortunately doesn't exist on Windows, but on
        posix, it will usually be stored in
        ``os.path.expanduser("~/.ssh/known_hosts")``.
        If this method is called multiple times, the host keys are merged,
        not cleared.  So multiple calls to `load` will just call `add`,
        replacing any existing entries and adding new ones.
        :param str filename: name of the file to read host keys from
        :raises: ``IOError`` -- if there was an error reading the file
        t   ri   i    t   #N(   t   opent	   enumeratet   stript   lenR   t	   from_lineR
   R   R   t   checkR   t   removeR   R   (   R   R   t   ft   linenot   lineR   t
   _hostnamest   h(    (    sF   /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/hostkeys.pyR   L   s     "
	
c         C   sR   t  | d  = } x3 |  j D]( } | j   } | r | j |  q q WWd QXd S(   sç  
        Save host keys into a file, in the format used by OpenSSH.  The order
        of keys in the file will be preserved when possible (if these keys were
        loaded from a file originally).  The single exception is that combined
        lines will be split into individual key lines, which is arguably a bug.
        :param str filename: name of the file to write
        :raises: ``IOError`` -- if there was an error writing the file
        .. versionadded:: 1.6.1
        t   wN(   R    R   t   to_linet   write(   R   R   R'   R   R)   (    (    sF   /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/hostkeys.pyt   savel   s
    
c            s~   d t  f   f d     Y} g  } x3 |  j D]( } |  j   |  r, | j |  q, q, Wt |  d k rn d S|   | |   S(   s  
        Find a hostkey entry for a given hostname or IP.  If no entry is found,
        ``None`` is returned.  Otherwise a dictionary of keytype to key is
        returned.  The keytype will be either ``"ssh-rsa"`` or ``"ssh-dss"``.
        :param str hostname: the hostname (or IP) to lookup
        :return: dict of `str` -> `.PKey` keys associated with this host
            (or ``None``)
        t   SubDictc              sM   e  Z d    Z d   Z d   Z d   Z d   Z   f d   Z d   Z RS(   c         S   s   | |  _  | |  _ | |  _ d  S(   N(   t	   _hostnameR   t	   _hostkeys(   R   R   t   entriest   hostkeys(    (    sF   /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/hostkeys.pyR      s    		c         s   s    x |  j    D] } | Vq
 Wd  S(   N(   t   keys(   R   t   k(    (    sF   /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/hostkeys.pyt   __iter__   s    c         S   s   t  |  j    S(   N(   R#   R5   (   R   (    (    sF   /home/tvault/.virtenv/lib/python2.7/site-packages/paramiko/hostkeys.pyt   __len__   s    c         S   sR   xK t  |  j  D]. } | j j   | k r |  j j |  q q Wt |   d  S(   N(   t   listR   R   R   R&