o
    ú½“hÂ”  ã                   @   sr  d Z ddlZddlZddlZddlZej d¡Zej 	e¡ ddl
mZ ddl
mZ ddl
mZ dZdZeeeƒZg Zi Zi Zi Zi ZeeeƒZG d	d
„ d
ƒZdd„ Zdd„ Zdd„ ZG dd„ dƒZdd„ ZG dd„ dƒZdd„ ZG dd„ dƒZdd„ Z dd„ Z!G dd „ d ƒZ"d!d"„ Z#d#d$„ Z$d%d&„ Z%d'd(„ Z&d)d*„ Z'd+d,„ Z(e)d-kr·e *¡ s¬d.ej+v r®dS e(ƒ  e ,¡  dS dS )/zÌ
   htmldoc.py - Create web pages for BIRCH documentation from birchdb database

   Synopsis: htmldoc.py

@modified: July 25, 2023
@author: Brian Fristensky and Dale Hamel
@contact: frist@cc.umanitoba.ca
é    NÚBIRCHLIB)ÚBirchmod)Ú	Htmlutils)Ú
HTMLWriterzhtmldoc.py: z3
	 USAGE: htmldoc.py [currently takes no paramters]c                   @   s   e Zd ZdZdd„ ZdS )Ú
Parametersz#Wrapper class for global parametersc                 C   s   d}t j |¡r@tdƒ d| _d| _t|dƒ}|D ]!}| d¡}|d dkr-|d  ¡ | _|d d	kr:|d  ¡ | _q| 	¡  n
td
ƒ t j
d | _d}zt j
d }W n   Y |dkr_|| _td| j ƒ td| j ƒ | jd | _| jd | _| jd | _d| _d| _d| _d| _d| _dS )a.  
          Get the location of the BIRCH home directory, BIRCHPATH
          Preferrably, we get it from the BIRCH.properties file,
          but if that isn't found, we get it from the BIRCH
          environment variable. The one catch is that since
          we don't already know the location of BIRCHPATH,
          the former will only work if the current working
          directory is install-scripts. Normally, this would
          only be used when installing or updating BIRCH
          Otherwise, the environment variable will be read.
          z../local/admin/BIRCH.propertiesz0htmldoc.py: Reading $BIRCH from BIRCH.propertiesÚ Úrú=r   zBirchProps.homediré   zBirchProps.platformzEhtmldoc.py: Reading $BIRCH and $BIRCH_PLATFORM environment variables.ÚBIRCHÚBIRCH_PLATFORMzhtmldoc.py: BIRCHPATH set to: z#htmldoc.py: BIRCH_PLATFORM set to: z/public_htmlz/public_html/birchdbz/local/public_html/birchdbN)ÚosÚpathÚexistsÚprintÚ	BIRCHPATHr   ÚopenÚsplitÚstripÚcloseÚenvironÚBIRCHWEBPATHÚBIRCHDBPATHÚBIRCHLOCALDBPATHÚBFNÚLFNÚINFILEÚOFNÚOUTFILE)ÚselfÚFNÚFILEÚLINEÚTOKENSÚplat© r%   ú,/home/birch/BIRCH/install-scripts/htmldoc.pyÚ__init__)   sB   

€

zParameters.__init__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r'   r%   r%   r%   r&   r   &   s    r   c                 C   sŠ   ddl }t | j¡ | jd | j }| d| j| j|dg¡}| ¡  tj 	| j
d ¡rCt | j
¡ | d| j| j
|dg¡}| ¡  dS dS )zƒ
    Dump the core BIRCH and local databases to .ace files
    @param P: Instasnce of Paramters object
    @type P: Parameters
    r   Nz/bin-z./tbirchdb.shz
tace.inputz/database/ACEDB.wrm)Ú
subprocessr   Úchdirr   r   r   ÚPopenÚwaitr   r   r   )ÚPr,   ÚTACEDIRÚpr%   r%   r&   Ú	DUMPTOACEa   s   ýr3   c                 C   sL   |   d¡}|  d¡}| |d |… } |  dd¡} |  dd¡} |  dd¡} | S )	al  
    Read the first string delimited by double quotes
    @param LINE: The line to be cleaned up
    @type LINE: str

    Each quoted line is modified as follows:
         escape characters \ added by ACEDB are deleted
         '>' and '<' characters are changed to '&gt;' and '&lt;' so
         they are not accidentally recognized by HTML as tag delimiters.
    ú"r
   ú\r   ú>z&gt;ú<z&lt;)ÚfindÚrfindÚreplace)r"   ÚIÚJr%   r%   r&   ÚGetStr{   s   

r=   c                 C   s   || v rdS |   |¡ dS )zØ
    If a list contains NAME, do nothing
    If it does not exist, append it to the list
    @param L: The list to check for name
    @type L: list
    @param NAME: The name to be checked for
    @type NAME: str
    N)Úappend)ÚLÚNAMEr%   r%   r&   Ú	AddToList’   s   
rA   c                   @   ó   e Zd Zdd„ ZdS )ÚCategoryc                 C   s   d| _ g | _g | _dS )zv
          Initializes arguments:
                name=""
                program=[]
                pkg=[]
          r   N)ÚnameÚprogramÚpkg©r   r%   r%   r&   r'   §   s   
zCategory.__init__N©r(   r)   r*   r'   r%   r%   r%   r&   rC   ¥   ó    rC   c                    s¤   ‡ fdd„}t j | ¡rPt| dƒ}|D ]6}t d|¡r"|t|ƒƒ}qt d|¡r6t |¡}t	|j
|d ƒ qt d|¡rIt |¡}t	|j|d ƒ q| ¡  dS dS )	zÈ
    Read category.ace into a list of category objects
    @param FN: THe name of the file to be read
    @type FN: str
    @param CATS: The categories object to be read into
    @type CATS: list
    c                    ó.   | t v r
t |  }|S tƒ }ˆ  |¡ | |_|S )zó
        "If a category called NAME already exists, return a pointer"
        "If it does not exist, create a new category object and return a pointer"
        @param NAME: The name of the category to check for
        @type NAME: str
        )ÚCATDICTrC   r>   rD   )r@   ÚC©ÚCATSr%   r&   ÚAssignCategoryÀ   ó   ý
z$ReadCategory.<locals>.AssignCategoryr   zCategory\s:\s".+"úProgram\s+".+"r
   úPackage\s+".+"N)r   r   r   r   ÚreÚmatchr=   ÚHTÚtokenizerA   rE   rF   r   )r    rN   rO   r!   r"   rL   r#   r%   rM   r&   ÚReadCategoryµ   s   


€ñrW   c                   @   rB   )ÚPackagec                 C   s4   d| _ d| _g | _g | _g | _g | _g | _g | _dS )a  
          Initializes arguments:
                name=""
                description=""
                category=[]
                doc=[]
                program=[]
                data=[]
                platform=[]
                installation=[]
          r   N)rD   ÚdescriptionÚcategoryÚdocrE   ÚdataÚplatformÚinstallationrG   r%   r%   r&   r'   è   s   
zPackage.__init__NrH   r%   r%   r%   r&   rX   æ   rI   rX   c                    sh  ‡ fdd„}t j | ¡r²t| dƒ}|D ]˜}t d|¡r"|t|ƒƒ}qt d|¡r.t|ƒ|_qt d|¡rBt 	|¡}t
|j|d ƒ qt d|¡rVt 	|¡}t
|j|d ƒ qt d	|¡rjt 	|¡}t
|j|d ƒ qt d
|¡r~t 	|¡}t
|j|d ƒ qt d|¡r’t 	|¡}t
|j|d ƒ qt d|¡rŸt
|jdƒ qt d|¡r«t
|jdƒ q| ¡  dS dS )zÎ
    Read package.ace into a list of Package objects
    @param FN: The name of the file to be read in
    @type FN: str
    @param PKGS: The list of package objects to be read into
    @type PKGS:list
    c                    rJ   )zã
        If a package called NAME already exists, return a pointer
        If it does not exist, create a new package object and return a pointer
        @param NAME:The name to attempt to assign
        @type NAME:str
        )ÚPKGDICTrX   r>   rD   )r@   ÚPK©ÚPKGSr%   r&   ÚAssignPackage	  rP   z"ReadPackage.<locals>.AssignPackager   zPackage\s:\s".+"úDescription\s+".+"úCategory\s+".+"r
   úDocumentation\s+".+"rQ   úData\s+".+"úPlatform\s+".+"r   ÚlocalN)r   r   r   r   rS   rT   r=   rY   rU   rV   rA   rZ   r[   rE   r\   r]   r^   r   )r    rb   rc   r!   r"   r`   r#   r%   ra   r&   ÚReadPackageþ   s<   





€årj   c                   @   rB   )ÚProgramc                 C   s@   d| _ d| _g | _g | _d| _g | _g | _g | _g | _g | _	dS )aA  
          Initializes arguments:
                name=""
                description=""
                category=[]
                interface=[]
                package=""
                doc=[]
                data=[]
                sampleinput=[]
                sampleoutput=[]
                platform=[]
          r   N)
rD   rY   rZ   Ú	interfaceÚpackager[   r\   ÚsampleinputÚsampleoutputr]   rG   r%   r%   r&   r'   9  s   
zProgram.__init__NrH   r%   r%   r%   r&   rk   7  rI   rk   c                    sê  ‡ fdd„}t j | ¡rót| dƒ}|D ]×}t d|¡r$|t|ƒƒ}qt d|¡r0t|ƒ|_qt d|¡rDt 	|¡}t
|j|d ƒ qt d|¡rU|j d	t|ƒg¡ qt d
|¡rf|j dt|ƒg¡ qt d|¡rw|j dt|ƒg¡ qt d|¡rŽ| dd¡ |j dt|ƒg¡ qt d|¡rŸ|j dt|ƒg¡ qt d|¡r°|j dt|ƒg¡ qt d|¡rÁ|j dt|ƒg¡ qt d|¡rÒ|j dt|ƒg¡ qt d|¡rã|j dt|ƒg¡ qt d|¡rô|j dt|ƒg¡ qt d|¡r|j dt|ƒg¡ qt d|¡r|j d t|ƒg¡ qt d!|¡r*|j d"t|ƒg¡ qt d#|¡r<|j d$t|ƒg¡ qt d%|¡rN|j d&t|ƒg¡ qt d'|¡r`|j d(t|ƒg¡ qt d)|¡rr|j d*t|ƒg¡ qt d+|¡r„t 	|¡}|d |_qt d,|¡r™t 	|¡}t
|j|d ƒ qt d-|¡r®t 	|¡}t
|j|d ƒ qt d.|¡rÃt 	|¡}t
|j|d ƒ qt d/|¡rØt 	|¡}t
|j|d ƒ qt d0|¡rìt 	|¡}t
|j|d ƒ q| ¡  d1S d1S )2z×
    Read program.ace into a list of Program objects
    @param FN: The name of the file to be read in
    @type FN: str
    @param PROGS: The list of Program objects to read the file into
    @type PROGS: list
    c                    rJ   )zå
        If a program called NAME already exists, return a pointer
        If it does not exist, create a new program object and return a pointer
        @param NAME: The name to attempt to assign
        @type NAME: str
        )ÚPROGDICTrk   r>   rD   )r@   ÚPR©ÚPROGSr%   r&   ÚAssignProgram^  rP   z"ReadProgram.<locals>.AssignProgramr   zProgram\s:\s".+"rd   re   r
   zcommand\s+".+"Úcommandzinteractive\s+".+"Úinteractivez
gui\s+".+"Úguiz_birch_\s+".+"Ú_birch_Úbirchzbirchadmin\s+".+"Ú
birchadminzbldna\s+".+"Úbldnazblnalign\s+".+"Úblnalignzblprotein\s+".+"Ú	blproteinzblpalign\s+".+"Úblpalignzbldata\s+".+"Úbldatazblmarker\s+".+"Úblmarkerzblnfetch\s+".+"Úblnfetchzblpfetch\s+".+"Úblpfetchzblreads\s+".+"Úblreadszblncbi\s+".+"Úblncbizbltable\s+".+"Úbltablezbltree\s+".+"ÚbltreerR   rf   rg   zSample_input\s+".+"zSample_output\s+".+"rh   N)r   r   r   r   rS   rT   r=   rY   rU   rV   rA   rZ   rl   r>   r:   rm   r[   r\   rn   ro   r]   r   )r    rs   rt   r!   r"   rq   r#   r%   rr   r&   ÚReadProgramS  s†   








€¸r‡   c           	      C   sò   	 dd„ }t | dƒ}tƒ }| |d¡ | |dd¡ | |dd¡ | |dd¡ tt ¡ ƒ}|jd	d
„ d |D ])}t| }||ƒ | |dd¡ |jd }|jd }| 	||d|¡ | 
|d¡ q8| 
|d¡ | |¡ | ¡  t | d¡ dS )zR
            FIXME
            @param catfn:
            @type catfn:
            c                 S   s<  	 | j d }t|dƒ}tƒ }| |d| j  ¡ | |dd¡ | |dd¡ | d¡ | |d¡ | |dd¡ | jjd	d
„ d | jD ]=}| |dd¡ d| d }z|d t	| j
 d }| ||d|¡ W qC ty€   td| ƒ | |ddd| ¡ Y qCw | |d¡ | |d¡ | |¡ | ¡  t |d¡ dS )z>
         FIXME
         @param c:
         @type c:
         ú.htmlÚwz
category: Úhrr   Úh1z	programs:Úulc                 S   ó   |   ¡ S ©N©Úlower©rD   r%   r%   r&   Ú<lambda>Ô  ó    z7write_category_page.<locals>.writecat.<locals>.<lambda>©ÚkeyÚliú../program/ú - Ú
zIn writecat: KeyError: z
KeyError: é´  N)rD   r   r   Ú
start_pageÚstartÚwriteÚendrE   Úsortrp   rY   ÚlinkÚKeyErrorr   Úend_pager   r   Úchmod)ÚcÚcatfnÚcatpagefileÚhÚpnameÚurlÚtextr%   r%   r&   ÚwritecatÁ  s4   



þ
z%write_category_page.<locals>.writecatr‰   zprograms by categoryrŠ   r   ÚbrrŒ   c                 S   r   rŽ   r   r‘   r%   r%   r&   r’   ö  r“   z%write_category_page.<locals>.<lambda>r”   r–   rˆ   r™   rš   N)r   r   r›   rœ   ÚlistrK   ÚkeysrŸ   rD   r    rž   r¢   r   r   r£   )	r¥   r«   Úcatfiler§   ÚcatlistÚcatkeyr¤   r©   rª   r%   r%   r&   Úwrite_category_page¸  s,   
)


r²   c                   @   rB   )ÚFilec                 C   s   d| _ d| _d| _d| _dS )z«
          Initializes arguments:
                name=""
                description=""
                command='"$ACE_FILE_LAUNCHER" '
                path=""
          r   z"$ACE_FILE_LAUNCHER" N)rD   rY   ru   r   rG   r%   r%   r&   r'     s   
zFile.__init__NrH   r%   r%   r%   r&   r³     rI   r³   c                    sŽ   ‡ fdd„}t j | ¡rEt| dƒ}|D ]+}t d|¡r"|t|ƒƒ}qt d|¡r.t|ƒ|_qt d|¡r>t 	|¡}|d |_q| 
¡  dS dS )	zÎ
    Read file.ace into a list of file objects
    @param FN: The name of the file to be read in
    @type FN: str
    @param DOCFILES: the list of file objects to be read into
    @type DOCFILES: list
    c                    rJ   )z×
        If a file called NAME already exists, return a pointer
If it does not exist, create a new file object and return a pointer
        @param NAME: The name to attempt to assign
        @type NAME: str
        )ÚDOCDICTr³   r>   rD   )r@   ÚFL©ÚDOCFILESr%   r&   Ú
AssignFile   rP   z ReadDocFiles.<locals>.AssignFiler   zFile\s:\s".+"rd   zPick_me_to_call\s+".+"é   N)r   r   r   r   rS   rT   r=   rY   rU   rV   r   )r    r·   r¸   r!   r"   rµ   r#   r%   r¶   r&   ÚReadDocFiles  s   


€ôrº   c                 C   s0   t j | ¡rt | ¡ t  | ¡ t  | d¡ dS )z±
    Delete an existing directory and create an empty directory
    with the same name.
    @param DIRNAME: The name of the directory to be refreshed
    @type DIRNAME: str
    iý  N)r   r   ÚisdirÚshutilÚrmtreeÚmkdirr£   )ÚDIRNAMEr%   r%   r&   ÚFreshDirB  s   

rÀ   c           
         s  ‡ fdd„}t | dƒ}tƒ }| |d¡ | |dd¡ | |dd¡ | |dd¡ tt ¡ ƒ}|jd	d
„ d |D ]1}t| }||ƒ | |dd¡ |jd }|jd t|j j	 d }	| 
||d|	¡ | |d¡ q9| |d¡ | |¡ | ¡  t | d¡ dS )zÓ
    Write HTML page listing program packages.
    @param PKGFN: The name of the html page to be created
    @type PKGFN: str
    @param P: An instance of the Paramaters object
    @type P: Paramters object
    c                    sÐ  | j d }t|dƒ}tƒ }| |d| j  ¡ d}| |d|¡ d}| |d|¡ d}| |d|¡ d}| |d	|¡ d}| |d
|¡ | | j d | j ¡ | |d
¡ | |d	¡ | |d¡ t||d| j	t
ˆ ƒ t||d| jt
ˆ ƒ d}| |d|¡ d}| |d	|¡ d}| |d
|¡ d}d}d}| ||||¡ | d¡ | |d
¡ d}| jD ]}| |¡ |d }|t| jƒk rÄ| d¡ q­| |d	¡ | |d¡ d}| |d|¡ d}| |d	|¡ d}| |d
|¡ d}d}d}| ||||¡ | d¡ | |d
¡ d}| jD ]}	| |	¡ |d }|t| jƒk r"| d¡ q
| |d	¡ | |d¡ d}| |d|¡ d}| |d	|¡ d}| |d
|¡ d}d}d}| ||||¡ | d¡ | |d
¡ | |d	¡ | |d¡ d}| |d|¡ d}| |d	|¡ | |dd¡ | jjdd„ d | jD ])}
| |dd¡ d |
 d }|
d t|
 j d! }| ||d|¡ | |d¡ q•| |d¡ | |d	¡ | |d¡ | |d¡ | |¡ | ¡  t |d"¡ d#S )$zs
        Write a page for a given package
        @param PK: The name of the package
        @type PK: str
        rˆ   r‰   z	Package: ú1 style="font-family: helvetica,arial,sans-serif;"Útabler   ÚtrúE colspan="2" rowspan="1" style= "background-color: rgb(51, 255, 51);"ÚtdÚbigr˜   ÚDocumentationÚDataúG colspan="2" rowspan="1" style= "background-color: rgb(204, 204, 204);"ú!../Doc_definitions.html#PlatformsÚ	Platformsútarget="FrameWindow"ú: r   r
   ú, z$../Doc_definitions.html#InstallationÚInstallationz ../Doc_definitions.html#ProgramsÚProgramszG colspan="2" rowspan="1" style= "background-color: rgb(255, 255, 255);"rŒ   c                 S   r   rŽ   r   r‘   r%   r%   r&   r’   É  r“   z4WritePackagePage.<locals>.WritePkg.<locals>.<lambda>r”   r–   r—   r™   rš   N)rD   r   r   r›   rœ   r   rY   rž   ÚDocRowsr[   r´   r\   r    r]   Úlenr^   rE   rŸ   rp   r¢   r   r   r£   )r`   ÚPKGFNÚPKGPAGEFILEÚHÚ
ATTRIBUTESÚURLÚTEXTr;   ÚPLATÚINSTÚPNAME©r0   r%   r&   ÚWritePkg\  s¾   





€



€


z"WritePackagePage.<locals>.WritePkgr‰   zPrograms by PackagerŠ   r   r¬   rŒ   c                 S   r   rŽ   r   r‘   r%   r%   r&   r’   ç  r“   z"WritePackagePage.<locals>.<lambda>r”   r–   rˆ   r˜   r™   rš   N)r   r   r›   rœ   r­   r_   r®   rŸ   rD   rY   r    rž   r¢   r   r   r£   )
rÓ   r0   rÝ   ÚPKGFILErÕ   ÚPKGLISTÚPKGKEYr`   r×   rØ   r%   rÜ   r&   ÚWritePackagePageQ  s*   
~

rá   c                 C   s@  d}|  | d|¡ d}|  | d|¡ d}|  | d|¡ d| dd¡ }|}d	}| | |||¡ | | d¡ | | d¡ | | d¡ |D ]Z}	d}|	|v r||	 }
t|
jƒd
kr|  | d|¡ d}|  | d|¡ |
j}| | |¡ | | d¡ d}|  | d|¡ t 	|
j|j
¡}|
j}| | |d|¡ | | d¡ | | d¡ qCdS )a&  
    Write rows for documentation lines:
    Documentation, Data, Sample input, Sample output

    @param OUTFILE: The name of the output file
    @type OUTFILE: str
    @param H: An instance of HTMLWriter
    @type H: HTMLWriter
    @param HEADING: The heading to place in each row
    @type HEADING: str
    @param FILELIST: The list of files to be documented
    @type FILELIST: list
    @param D: The dictionary to use for documentation
    @type D: dictionary
    @param P: An instance of the Parameters class
    @type P: Parameters object
    r   rÃ   rÉ   rÅ   rÆ   z../Doc_definitions.html#ú Ú_rÌ   r   úR border="0" colspan="1" rowspan="1" style= "background-color: rgb(255, 255, 255);"N)rœ   r:   r    rž   rÒ   r   rY   Úindent_textrU   Úname_to_urlÚ	DOCPREFIX)r   rÕ   ÚHEADINGÚFILELISTÚDr0   rÖ   r×   rØ   ÚDOCNAMEÚDOCUMENTÚDOCTYPEr%   r%   r&   rÑ   ø  sB   €ïrÑ   c           
      C   sô   dd„ }t | dƒ}tƒ }| |d¡ | |dd¡ | |dd¡ tt ¡ ƒ}|jdd	„ d
 |D ]2}t| }|||ƒ | |dd¡ |jd }|jd t|j j	 d }	| 
||d|	¡ | |d¡ q0| |d¡ | |¡ | ¡  t | d¡ dS )zá
    Write HTML page listing programs in alphabetical order.
    @param PROGFN: The basename of the page to be written
    @type PROGFN: str
    @param P: An instance of the Parameters class
    @type P: Paramters object
    c                 S   s´  | j d }t|dƒ}tƒ }| || j ¡ d}| |d|¡ d}| |d|¡ d}| |d|¡ d}| |d|¡ d}| |d	|¡ | | j d
 | j ¡ | |d	¡ | |d¡ | |d¡ d}| |d|¡ d}| |d|¡ d}| |d	|¡ d}d}d}| ||||¡ | |d	¡ | |d¡ | |d¡ | j	D ]M}d}| |d|¡ d}| |d|¡ | 
||d ¡ | |d¡ d}| |d|¡ d}| |d|¡ | |d ¡ | |d¡ | |d¡ | |d¡ qœt||d| jt|ƒ t||d| jt|ƒ t||d| jt|ƒ t||d| jt|ƒ d}| |d|¡ d}| |d|¡ d}| |d	|¡ d}d}d}| ||||¡ | d¡ | |d	¡ d| j d }| j}| ||d|¡ | |d¡ | |d¡ d}| |d|¡ d}| |d|¡ d}| |d	|¡ d}d}d}| ||||¡ | d¡ | |d	¡ d}	| jD ]}
| |
¡ |	d }	|	t| jƒk rµ| d¡ q| |d¡ | |d¡ | |d¡ | |¡ | ¡  t |d¡ d S )!zâ
        Write a page for a given program
        @param PR: The name of the program to write the page for
        @type PR: str
        @param P: An instance of the Parameters class
        @type P: Parameters object
        rˆ   r‰   rÁ   rÂ   r   rÃ   rÄ   rÅ   rÆ   r˜   rÉ   z!../Doc_definitions.html#LaunchingzLaunching the programrÌ   rä   r   z face="Courier New,Courier"Úfontr
   rÇ   rÈ   zSample inputzSample outputz../Doc_definitions.html#PackagerX   rÍ   z../package/rÊ   rË   rÎ   rš   N)rD   r   r   r›   rœ   r   rY   rž   r    rl   rå   rÑ   r[   r´   r\   rn   ro   rm   r]   rÒ   r¢   r   r   r£   )rq   r0   ÚPROGFNÚPROGPAGEFILErÕ   rÖ   r×   rØ   ÚCOMMANDr;   rÙ   r%   r%   r&   Ú	WriteProg;  s¸   








€
z#WriteProgramPage.<locals>.WriteProgr‰   zProgram IndexrŠ   r   rŒ   c                 S   r   rŽ   r   r‘   r%   r%   r&   r’   È  r“   z"WriteProgramPage.<locals>.<lambda>r”   r–   rˆ   r˜   r™   rš   N)r   r   r›   rœ   r­   rp   r®   rŸ   rD   rY   r    rž   r¢   r   r   r£   )
rï   r0   rò   ÚPROGFILEr§   ÚPROGLISTÚPROGKEYrq   r×   rØ   r%   r%   r&   ÚWriteProgramPage0  s*    



rö   c                  C   sB  t dƒ tƒ } t dƒ t | jd¡| _| j dd¡| _t d| j ƒ | jdkr*d}nd}t d	ƒ t| ƒ g }t d
ƒ t 	| j
¡ td|ƒ t dtt|ƒƒ ƒ |D ]}|t|j< qQtj | j¡rut 	| j¡ td|ƒ |D ]}|t|j< qmt dtttƒƒ ƒ g }t dƒ t 	| j
¡ td|ƒ t dtt|ƒƒ ƒ |D ]}|t|j< qœtj | j¡rÀt 	| j¡ td|ƒ |D ]}|t|j< q¸t dtttƒƒ ƒ t dƒ t 	| j
¡ tdtƒ t dtttƒƒ ƒ tD ]}|t|j< qåtj | j¡rt 	| j¡ tdtƒ tD ]}|t|j< qt dtttƒƒ ƒ g }t dƒ t 	| j
¡ td|ƒ |D ]}|t|j< q(tj | j¡rOt 	| j¡ td|ƒ |D ]}|t|j< qFt dƒ t 	| jd ¡ tdƒ tdƒ tdƒ |rŸt dƒ t dƒ t 	d¡ d}	t|	ƒ t d ƒ t 	d!¡ d"}
t|
| ƒ t d#ƒ t 	d$¡ d%}t|| ƒ d&S d&S )'z0
    Called when not in documentation mode.
    z***** obtaining parametersz***** reading BIRCH.propertiesÚbirchURLr5   r   zP.DOCPREFIX: TFz***** dumping to ACEz***** reading categorieszcategory.acezCategories:zCATDICT size: z***** reading packageszpackage.acez	Packages:zPKGDICT size: z***** reading programszprogram.acezProgs:zPROGDICT size: z%***** reading documentation filenameszfile.acez***** freshdirz/public_html/birchdocrZ   rm   rE   z***** read OK *****z***** writing category pageszcategory.htmlz***** writing program pagesz
../programzprogram.htmlz***** writing package pagesz
../packagezpackage.htmlN)r   r   ÚBMÚGetBIRCHPropertiesr   rç   r:   r3   r   r-   r   rW   ÚstrrÒ   rK   rD   r   r   r   rj   r_   r‡   rs   rp   rº   r´   rÀ   r²   rö   rá   )r0   ÚOKAYrN   rL   rb   r`   rq   r·   rµ   ÚCATFNrï   rÓ   r%   r%   r&   ÚmainÚ  s    













érý   Ú__main__z-test)-r+   r   rS   r¼   Úsysr   ÚgetÚblibr   r>   Úbirchlibr   r   r   ÚPROGRAMÚUSAGErø   rs   rK   rp   r_   r´   rU   r   r3   r=   rA   rC   rW   rX   rj   rk   r‡   r²   r³   rº   rÀ   rá   rÑ   rö   rý   r(   Ú
documentorÚargvÚexit_successr%   r%   r%   r&   Ú<module>   s\   

;19eM- (8 + 
û