³ò
°QþNc           @   s²  d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z	 d d k l
 Z
 d d k l Z e i Z d d k Z d d k l Z d d k l Z d d k l Z d d k l Z d d	 k l Z d d
 k l Z l Z yE d d k Z e i d ƒ d d k l Z d d k Z d d k Z Wn e j
 o n Xd e i  f d „  ƒ  YZ  d d „ Z! d „  Z" d „  Z# d „  Z$ d „  Z% d „  Z& d S(   s*   

    KeepNote
    Export HTML Extension

iÿÿÿÿN(   t   minidom(   t   escape(   t   unicode_gtk(   t   NoteBookError(   t   notebook(   t   tasklib(   t   tarfile(   t	   extensiont   FileChooserDialogs   2.0(   t   gdkt	   Extensionc           B   s8   e  Z d  „  Z d „  Z d „  Z d „  Z d d „ Z RS(   c         C   s    t  i i |  | ƒ | |  _ d S(   s   Initialize extensionN(   R   R
   t   __init__t   app(   t   selfR   (    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyR   E   s    c         C   s   d d d f g S(   Nt   keepnotes   >=i    i   i   (   i    i   i   (    (   R   (    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt   get_dependsL   s    c            s6   ˆ  i  ˆ d d ‡  ‡ f d †  ƒ ˆ  i ˆ d ƒ d S(   s,   Initialize extension for a particular windows   Export HTMLs   _HTML...c            s   ˆ  i  ˆ ˆ i ƒ  ƒ S(    (   t   on_export_notebookt   get_notebook(   t   w(   R   t   window(    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt   <lambda>U   s   s&  
            <ui>
            <menubar name="main_menu_bar">
               <menu action="File">
                  <menu action="Export">
                     <menuitem action="Export HTML"/>
                  </menu>
               </menu>
            </menubar>
            </ui>
            N(   t
   add_actiont   add_ui(   R   R   (    (   R   R   s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt	   on_add_uiP   s    	c         C   sM  | d j o d Sn t d | d t i d d t i d t i f d |  i d d	 ƒ} t i t	 i
 i | i ƒ  ƒ d
 ƒ } |  i i d	 ƒ } | o/ t	 i
 i | ƒ o t i | | d d ƒ } n | } | i t	 i
 i | ƒ ƒ | i ƒ  } | t i j oC | i ƒ  o6 t | i ƒ  ƒ } | i ƒ  |  i | | d | ƒn | i ƒ  d S(   s*   Callback from gui for exporting a notebookNs   Export Notebookt   actiont   buttonst   Cancelt   ExportR   t   persistent_patht   archive_notebook_paths	   -%Y-%m-%dt    t   .R   (   t   NoneR   t   gtkt   FILE_CHOOSER_ACTION_SAVEt   RESPONSE_CANCELt   RESPONSE_OKR   t   timet   strftimet   ost   patht   basenamet   get_patht   get_default_patht   existst   notebooklibt   get_unique_filenamet   set_current_namet   runt   get_filenameR   t   destroyt   export_notebook(   R   R   R   t   dialogR)   R(   t   filenamet   response(    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyR   f   s,    				

c   	         s(  ˆ d  j o d  Sn | oø t i ‡ ‡  f d †  ƒ } | i d t i i ˆ  ƒ d | ƒ y; | i ƒ  \ } } } | o
 | ‚ n | i d ƒ t	 SWq$t
 j
 o4 } | i d ƒ | i d | i | | ƒ t Sq$t j
 o- } | i d ƒ | i d | | ƒ t Sq$Xn t ˆ ˆ  d  ƒ d  S(   Nc            s   t  ˆ  ˆ |  ƒ S(    (   R3   (   t   task(   R   R5   (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyR      s    s   Exporting to '%s'...s   Beginning export...s   Notebook exportedR   s"   Error while exporting notebook:
%ss   unknown error(   R    R   t   Taskt   wait_dialogR'   R(   R)   t   exc_infot
   set_statust   TrueR   t   errort   msgt   Falset	   ExceptionR3   (	   R   R   R5   R   R7   t   tyR=   t   tracebkt   e(    (   R5   R   s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyR3   ‰   s0    	
N(   t   __name__t
   __module__R   R   R   R   R    R3   (    (    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyR
   C   s
   				#id   c         C   s.   t  |  ƒ | j o d |  | d }  n |  S(   Ns   ...i   (   t   len(   R5   t   maxsize(    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt   truncate_filename°   s    c         C   sÜ   |  d  } } | d  } } g  } g  } x“ | | j o… | d j p | d j ok t | ƒ t | ƒ j o) t i i | ƒ \ } } | i | ƒ q) t i i | ƒ \ } } | i d ƒ q) W| i t | ƒ ƒ d i | ƒ S(   NR   u   ..u   /(	   R    RF   R'   R(   t   splitt   appendt   extendt   reversedt   join(   R(   t   startt   headt   tailt   head2t   tail2t   relt   rel2(    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt   relpath¶   s     'c         C   s®   |  i  | ƒ } | o t | i ƒ  | ƒ } | i d ƒ d j o d i | d f ƒ } n3 | i d ƒ o" d i | | i d ƒ f ƒ } n t i | i d ƒ ƒ Sn d Sd  S(   Nt   content_types   text/xhtml+xmlu   /u	   page.htmlt   payload_filenamet   utf8R   (	   t   get_node_by_idRU   R*   t   get_attrRM   t   has_attrt   urllibt   quotet   encode(   R   R(   t   nodeidt   notet   newpath(    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt   nodeid2html_linkÉ   s    "c            s#   ‡ ‡ ‡  f d †  ‰ ˆ | ƒ d  S(   Nc            s´   |  i  |  i j o |  i d j oo |  i d ƒ } t i | ƒ oL t i | ƒ \ } } t ˆ  ˆ | ƒ } | d j o |  i d | ƒ qŽ q’ n x |  i	 D] } ˆ | ƒ qœ Wd  S(   Nt   at   hrefR   (
   t   nodeTypet   ELEMENT_NODEt   tagNamet   getAttributeR-   t   is_node_urlt   parse_node_urlRb   t   setAttributet
   childNodes(   t   nodet   urlt   hostR_   t   url2t   child(   R   t   walkR(   (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyRr   Ú   s    #
 (    (   R   R(   Rm   (    (   R(   R   Rr   s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt   translate_linksØ   s    c            sÑ   | i  ƒ  ‰  t i i | d ƒ } t i i | d ƒ } t i | d d ƒ ‰ ˆ i d t | i ƒ  ƒ ƒ ˆ i	 ƒ  t i | d d ƒ ‰ ˆ i d ƒ ‡ ‡  ‡ ‡ f d †  ‰ ˆ | ƒ ˆ i d ƒ ˆ i	 ƒ  d  S(	   Ns
   index.htmls	   tree.htmlt   wbs   utf-8uÕ   <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>%s</title>
</head>
<frameset cols="20%%, *">
  <frame src="tree.html">
  <frame name="viewer" src="">
</frameset>
</html>
uÕ  <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<style>
.node
{
    padding-left: 20px;
    display: block;
}

.node_collapsed
{
    padding-left: 20px;
    display: none;

    
    visibility: hidden;
    display: none;
}



a:active
{
text-decoration:none;
color: #0000FF;
font-weight: bold;
}

a:visited
{
text-decoration:none;
color: #000;
font-weight: bold;
}

a:link
{
text-decoration:none;
color: #000;
font-weight: bold;
}

a:hover
{
text-decoration: underline;
color: #500;
font-weight: bold;
}

</style>


<script language="javascript">
  
    var displayStates = [];

    function showDiv(div)
    {    
        div.style.height     = "";
        div.style.display    = "block";
        div.style.visibility = "visible";
    }

    function hideDiv(div)
    {
        div.style.height     = "0px";
        div.style.display    = "none";      
        div.style.visibility = "hidden";
    }

    function toggleDiv(div, defaultState)
    {

        // set default on first use
        if (displayStates[div] == undefined)
            displayStates[div] = defaultState;

        // toggle state
        displayStates[div] = !displayStates[div];       

        // hide / show
        if (displayStates[div])
            showDiv(div);
        else {
            hideDiv(div);
        }
    }

    function toggleDivName(divname, defaultState)
    {
        toggleDiv(document.getElementById(divname), defaultState);
    }

</script>

c            sQ  |  i  d ƒ } |  i  d t ƒ } t |  i ƒ  ƒ d j o+ ˆ i d | d d g t | ƒ f ƒ n ˆ i d ƒ |  i  d ƒ t i j o! ˆ i d	 t |  i	 ƒ  ƒ ƒ n0 ˆ i d
 t
 ˆ  ˆ | ƒ t |  i	 ƒ  ƒ f ƒ t |  i ƒ  ƒ d j oY ˆ i d | d d g t | ƒ f ƒ x |  i ƒ  D] } ˆ | ƒ q(Wˆ i d ƒ n d  S(   NR_   t   expandedi    uH   <nobr><tt><a href='javascript: toggleDivName("%s", %s)'>+</a>&nbsp;</tt>u   falseu   trueu   <nobr><tt>&nbsp;&nbsp;</tt>RV   u   %s</nobr><br/>
u0   <a href='%s' target='viewer'>%s</a></nobr><br/>
u   <div id='%s' class='node%s'>u
   _collapsedR   u   </div>
(   RZ   R?   RF   t   get_childrent   writet   intR-   t   CONTENT_TYPE_DIRR   t	   get_titleRb   (   Rm   R_   t   expandRq   (   R   t   rootpathRr   t   out(    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyRr   h  s$    	"!		 u   </body></html>(
   R*   R'   R(   RM   t   codecst   openRw   R   Rz   t   close(   R   Rm   R(   t
   index_filet	   tree_file(    (   R|   Rr   R   R}   s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt   write_indexì   s    

b
c            sV  ˆ d j o t i ƒ  ‰ n t i i | ƒ o t d | ƒ ‚ n y ˆ i ƒ  Wn$ t j
 o } t d | ƒ ‚ n Xd g ‰ ‡ ‡ f d †  ‰ ˆ ˆ ƒ ˆ i	 d d ˆ d f ƒ d g ‰ ‡ ‡ f d †  ‰  t
 ‡ ‡ ‡ ‡ ‡ ‡  ‡ f d † ‰ ‡ ‡ f d	 †  ‰ ˆ ˆ ˆ i ƒ  | t ƒ ˆ i	 d ƒ ˆ i	 d ƒ ˆ o ˆ i ƒ  n d S(   sM   Export notebook to HTML

       filename -- filename of export to create
    s   File '%s' already existss(   Could not save notebook before archivingi    c            s5   ˆ  d c d 7<x |  i  ƒ  D] } ˆ | ƒ q Wd  S(   Ni    i   (   Rv   (   Rm   Rq   (   t   nnodesRr   (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyRr      s     t   texts   Exporting %d notes...c            sÆ   t  i i | d ƒ } t  i i | d ƒ } y t i | ƒ } Wn" t j
 o } ˆ  | | ƒ nb Xt ˆ | | i ƒ t i	 | d d ƒ } | i
 o | i
 i | ƒ n | i i | ƒ | i ƒ  d  S(   Ns	   page.htmlRt   s   utf-8(   R'   R(   RM   R    t   parseR@   Rs   t   documentElementR~   R   t   doctypet   writexmlR€   (   Rm   R(   t   arcnameR5   t	   filename2t   domRC   R}   (   t   export_filesR   (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyt   export_pageª  s    
c      	      sŸ  ˆ  i  ƒ  o t d ƒ ‚ n ˆ d c d 7<ˆ  i d t | ƒ f ƒ ˆ  i ˆ d t ˆ d ƒ ƒ t d „  |  i ƒ  Dƒ ƒ } t i	 | ƒ | o t
 ˆ |  | ƒ n |  i d ƒ d j o! | i d ƒ ˆ |  | | ƒ n xg t i | ƒ D]V } t i i | ƒ o< | | j o/ ˆ t i i | | ƒ t i i | | ƒ ƒ qð qð WxN |  i ƒ  D]@ } | i ƒ  } ˆ | t i i | | ƒ t i i | | ƒ ƒ qWWd  S(	   Ns   Backup canceledi    i   t   detailc         s   s   x |  ] } | i  ƒ  Vq Wd  S(   N(   t   get_basename(   t   .0Rq   (    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pys	   <genexpr>Î  s   	RV   s   text/xhtml+xmls	   page.html(   t   abortedR   t   set_messageRH   t   set_percentt   floatt   setRv   R'   t   mkdirRƒ   RZ   t   addt   listdirR(   t   islinkRM   R   (   Rm   R(   RŠ   t   indext	   skipfilest   fRq   (   R7   R   R   t   export_nodeR„   RŽ   t   nnodes2(    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyRž   Ã  s0    	 ! c            sÈ   ˆ  i  ƒ  o t d ƒ ‚ n t i i |  ƒ o t i |  | ƒ n t i i |  ƒ om t i | ƒ x] t i	 |  ƒ D]H } t i i
 | ƒ p/ ˆ t i i |  | ƒ t i i | | ƒ ƒ qt qt Wn d  S(   Ns   Backup canceled(   R’   R   R'   R(   t   isfilet   shutilt   copyt   isdirR—   R™   Rš   RM   (   R(   RŠ   R   (   R7   R   (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyR   ê  s     s   Closing export...R   R   N(   s   texts   Closing export...(   s   detailR   (   R    R   R8   R'   R(   R,   R   t   saveR@   R“   R?   R*   R<   t   finish(   R   R5   R7   RC   (    (   RŽ   R7   R   R„   Rž   R   Rr   RŸ   s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pyR3   Š  s*    	
	$'('   t   __doc__R~   t   gettextR'   t   sysR%   R¡   R\   t   xml.domt   xmlR    t   xml.sax.saxutilsR   t   _R   R   t   keepnote.notebookR   R   R-   R   R   t   keepnote.guiR   R   t   pygtkt   requireR!   R	   t	   gtk.gladet   gobjectt   ImportErrorR
   RH   RU   Rb   Rs   Rƒ   R3   (    (    (    s—   \\192.168.178.73\Gero\!!!!!!!!!!!!!!! Neue Aufgaben ab 26.02.2022\2 Datenbank portable\KeepNotePortable\App\KeepNote\extensions\export_html\__init__.pys   <module>   sB   	m				ž