ó
Gh\c           @   sf   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z d  d l m Z d e f d     YZ	 d S(   i˙˙˙˙N(   t   LocalStatusFolder(   t   LocalStatusSQLiteFolder(   t   BaseRepository(   t   OfflineImapErrort   LocalStatusRepositoryc           B   sY   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c         C   sô   t  j |  | |  i  |  _ i t d 6t j j | j   d  d 6|  j d <i t d 6t j j | j   d  d 6|  j d <|  j	 j
 d d   d  k	 rŻ t d t j j   n  |  j d  t j j |  j  sç t j |  j d	  n  i  |  _ d  S(
   Nt   classs   LocalStatus-sqlitet   roott   sqlitet   LocalStatust   plaint   status_backendsm   the 'status_backend' configuration option is not supported anymore; please, remove this configuration option.iÀ  (   R   t   __init__t   backendsR   t   ost   patht   joint   getaccountmetaR    t   accountt   getconft   NoneR   t   ERRORt   REPOt   setup_backendt   existsR   t   mkdirt   _folders(   t   selft	   reposnameR   (    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyR      s     	&&c         C   s   |  j  | |   S(   N(   t   LocalStatusFolderClass(   R   t
   foldername(    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyt   _instanciatefolder8   s    c         C   sM   | |  j  j   k rI | |  _ |  j  | d |  _ |  j  | d |  _ n  d  S(   NR   R   (   R   t   keyst   _backendR   R   (   R   t   backend(    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyR   ;   s    	c         C   sÑ   xÊ |  j  j   D]ı \ } } | d t |  k r8 q n  t |  j |  j  } | j |  | d | j |  } | j   s |  j j	 d | |  j
 |  j | j f  | j   | j | _ | j   Pq q Wd  S(   NR   sA   Migrating LocalStatus cache from %s to %s status folder for %s:%s(   R   t   itemst   typeR   t   nameR   R   t   isnewfoldert   uit   _msgR    t   cachemessagelistt   messagelistt   saveall(   R   t   foldert   bkt   dict   repobkt   folderbk(    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyt   import_other_backendA   s    

c         C   s   d S(   Nt   .(    (   R   (    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyt   getsepV   s    c         C   sU   |  j  j r d S|  j |  } | j   | j   | j   | j   |  j   d S(   s   Create a LocalStatus Folder.N(   R   t   dryrunR   t   purget	   openfilest   savet
   closefilest   forgetfolders(   R   R   R+   (    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyt
   makefolderY   s    



c         C   sV   | |  j  k r |  j  | S|  j |  } | j   rE |  j |  n  | |  j  | <| S(   sl   Return the Folder() object for a foldername.

        Caller must call closefiles() on the folder when done.(   R   R   R%   R0   (   R   R   R+   (    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyt	   getfolderl   s    c         C   s   d S(   s  Returns a list of all cached folders.

        Does nothing for this backend. We mangle the folder file names
        (see getfolderfilename) so we can not derive folder names from
        the file names that we have available. TODO: need to store a
        list of folder names somehow?N(    (   R   (    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyt
   getfolders}   s    c         C   s   i  |  _  d S(   sT   Forgets the cached list of folders, if any.  Useful to run
        after a sync run.N(   R   (   R   (    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyR8      s    (   t   __name__t
   __module__R   R   R   R0   R2   R9   R:   R;   R8   (    (    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyR      s   								
(
   R   t   offlineimap.folder.LocalStatusR    t$   offlineimap.folder.LocalStatusSQLiteR   t   offlineimap.repository.BaseR   t   offlineimap.errorR   R   (    (    (    s<   /usr/share/offlineimap/offlineimap/repository/LocalStatus.pyt   <module>   s
   