Ñò
mÈ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
 ov yS t  |  t i d d ƒ } | i ƒ  t d j	 o t i  |  ƒ } | i ƒ  d SWqù t t
 f j
 o qù Xn Xy’ t i |  t i d ƒ t i |  t i d ƒ i } | d	 j o d
 St  |  t i d d ƒ } z | i d ƒ d j o d
 SWd | i ƒ  XWn t t f j
 o n Xy t  |  d ƒ } Wn t j
 o d SX| i d ƒ } | i ƒ  | d	 d !} t | ƒ d j o d Sy t i d | ƒ \ } Wn t i j
 o d SX| d j o d S| d j o d Sy t i d | d ƒ \ } Wn t i j
 o d SX| d j o d S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.6/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.6/whichdb.pyt   <module>   s   	b 