File: //lib64/python2.7/whichdb.pyc
�
ٜSec           @   s�   d  Z  d d l Z d d l Z d d l Z y d d l Z e j Z Wn e k
 rb d Z e	 Z n Xd �  Z
 e d k r� x- e j d D] Z
 e
 e
 � p� d Ge
 GHq� Wn  d S(   s0   Guess which db package to use to open a db file.i����Nc         C   s�  yq t  |  t j d d � } | j �  t j d k oB t j d k sl t  |  t j d d � } | j �  n  d SWn| t k
 r� yQ t  |  t j d d � } | j �  t d k	 r� t j  |  � } | j �  d SWq� t t
 f k
 r� q� Xn Xy� t j |  t j d � t j |  t j d � j } | d	 k r8d
 St  |  t j d d � } z | j
 d � d k rnd
 SWd | j �  XWn t t f k
 r�n Xy t  |  d � } Wn t k
 r�d SX| j
 d � } | j �  | d	 d !} t | � d k r�d Sy t j d | � \ } Wn t j k
 r,d SX| d k r=d S| d k rMd Sy t j d | d � \ } Wn t j k
 r�d SX| d k r�d Sd S(    sg  Guess which db package to use to open a db file.
    Return values:
    - None if the database file can't be read;
    - empty string if the file can be read but can't be recognized
    - the module name (e.g. "dbm" or "gdbm") if recognized.
    Importing the given module may still fail, and opening the
    database using that module may still fail.
    t   pagt   rbs   GNU gdbmt   os2emxt   dirt   dbmt   dbt   dati    t   dumbdbmi   t   't   "Ni   i   t    s   =liΚWi͚WiϚWt   gdbmia i at   bsddb185i����t   dbhash(   R   R	   (   iΚWi͚WiϚW(   ia i a(   ia i a(   t   opent   ost   extsept   closeR   t   libraryt   syst   platformt   IOErrort   Nonet	   _dbmerrort   statt   st_sizet   readt   OSErrort   lent   structt   unpackt   error(   t   filenamet   ft   dt   sizet   s16t   st   magic(    (    s   /usr/lib64/python2.7/whichdb.pyt   whichdb   sj    
t   __main__i   t   UNKNOWN(   t   __doc__R   R   R   R   R   R   t   ImportErrorR   R   R'