ó
©9Nc           @   sJ   d  Z  d d l Z d d l Z e j e j Z d Z d „  Z d „  Z d S(   sn   
escape/unescape routines available for backends which need
alphanumeric usernames, services, or other values
iÿÿÿÿNt   _c            s)   t  d „ ‰  d j ‡  f d †  |  Dƒ ƒ S(   s~   Escapes given value so the result consists of alphanumeric chars and underscore
    only, and alphanumeric chars are preservedc         S   s(   |  | k r |  Sd t  t |  ƒ f Sd  S(   Ns   %s%X(   t   ESCAPE_CHARt   ord(   t   ct   legal(    (    s7   /usr/lib/python2.7/dist-packages/keyring/util/escape.pyt   escape_char   s    t    c         3   s   |  ] } ˆ  | ƒ Vq d  S(   N(    (   t   .0R   (   R   (    s7   /usr/lib/python2.7/dist-packages/keyring/util/escape.pys	   <genexpr>   s    (   t   LEGAL_CHARSt   join(   t   value(    (   R   s7   /usr/lib/python2.7/dist-packages/keyring/util/escape.pyt   escape   s    c         C   s"   t  j d ƒ } | j d „  |  ƒ S(   s   Reverts escapes   _([0-9A-F]{2})c         S   s   t  t |  j d ƒ d ƒ ƒ S(   Ni   i   (   t   chrt   intt   group(   t   i(    (    s7   /usr/lib/python2.7/dist-packages/keyring/util/escape.pyt   <lambda>   s    (   t   ret   compilet   sub(   R
   t   re_esc(    (    s7   /usr/lib/python2.7/dist-packages/keyring/util/escape.pyt   unescape   s    (	   t   __doc__t   stringR   t   letterst   digitsR   R   R   R   (    (    (    s7   /usr/lib/python2.7/dist-packages/keyring/util/escape.pyt   <module>   s
   	