³ò
™›\Kc           @   s±   d  Z  d d k Z d d k Z d d k Z y d d k Z e i Z Wn e j
 o d Z e	 Z n Xd „  Z
 e d j o2 x/ e i 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Ñ  yt t  |  t i d d ƒ } | i ƒ  t i d j o t i d j p( t  |  t i d d ƒ } | i ƒ  n d SWn… t j
 oy yV t  |  t i d d ƒ } | i ƒ  t d j	 o! t i  |  ƒ } | i ƒ  d Sn Wqü t t
 f j
 o qü Xn Xy˜ t i |  t i d ƒ t i |  t i d ƒ i } | d	 j o d
 Sn t  |  t i d d ƒ } z" | i d ƒ d j o d
 Sn Wd | i ƒ  XWn t t f j
 o n Xy t  |  d ƒ } Wn t j
 o d Sn X| i d ƒ } | i ƒ  | d	 d !} t | ƒ d j o d Sn y t i d | ƒ \ } Wn t i j
 o d Sn X| d j o d Sn | d j o d Sn y t i d | d ƒ \ } Wn t i j
 o d Sn X| d j o d Sn d 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ÎšWt   gdbmia i at   bsddb185iüÿÿÿt   dbhash(   R   R	   (   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/lib/python2.5/whichdb.pyt   whichdb   sj    
 


	
		t   __main__i   t   UNKNOWN(   t   __doc__R   R   R   R   R   R   t   ImportErrorR   R   R'   t   __name__t   argvR    (    (    (    s   /usr/lib/python2.5/whichdb.pys   <module>   s   	b 