mò
­fIc           @   s¥   d  Z  d k Z d k Z d k Z y 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.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 d g 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(   ia i a(   ia i a(   t   opent   filenamet   ost   extsept   ft   closeR   t   libraryt   syst   platformt   IOErrort   Nonet   dt	   _dbmerrort   statt   st_sizet   sizet   readt   OSErrort   s16t   st   lent   structt   unpackt   magict   error(   R   R%   R   R   R    R!   R   (    (    t$   /mit/python/lib/python2.4/whichdb.pyt   whichdb   sn     
 


 	
		t   __main__i   t   UNKNOWN(   t   __doc__R   R#   R   R   R&   R   t   ImportErrorR   R   R(   t   __name__t   argvR   (   R   R#   R   R   R(   R   R   (    (    R'   t   ?   s   					b 