Changeset 453

Show
Ignore:
Timestamp:
09/01/08 16:35:37 (3 months ago)
Author:
apdavison
Message:

Started adapting poster.py to PyNN v0.4

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doc/poster/trunk/poster.py

    r452 r453  
    11# encoding: utf-8 
    22""" 
    3 Script to generate the poster for the CNS*2007 meeting. 
     3Script to generate a poster about PyNN 
    44""" 
    55 
     
    1818import sys 
    1919import StringIO 
    20  
    2120 
    2221class Author(object): 
     
    152151    frame.addFromList(paragraph_list, poster) 
    153152     
     153def checkout_pyNN(): 
     154    svn_client = pysvn.Client() 
     155    svn_client.checkout(svnpath, "pyNN_%s" % VERSION) 
     156    os.system("ln -s pyNN_%s/src pyNN" % VERSION) 
    154157 
    155158def make_users_guide(styles,x,y,width,height,_debug=False): 
    156159    global poster 
    157     svn_client = pysvn.Client() 
    158     svn_client.checkout(svnpath, "pyNN") 
     160    checkout_pyNN() 
    159161    import pyNN 
    160162    import docutils.core 
     
    167169 
    168170    for section in "High-level API", : #"Introduction", "Installation", "Low-level API": #, "High-level API": 
    169         filename = "pyNN/doc/" + section.lower().replace("-","").replace(" ","") + ".txt" 
     171        filename = "pyNN_%s/doc/" % VERSION + section.lower().replace("-","").replace(" ","") + ".txt" 
    170172        filename, xmltext = restxsl.transform.restxsl(filename, 
    171173                                                      smartPunctuation=False, 
     
    192194def make_apidocs(styles,x,y,width,height,_debug=False): 
    193195    global poster 
    194     svn_client = pysvn.Client() 
    195     svn_client.checkout(svnpath, "pyNN") 
    196     wikidoc = imp.load_source('wikidoc', os.path.join('pyNN','doc','wikidoc.py')) 
     196    checkout_pyNN() 
     197    wikidoc = imp.load_source('wikidoc', os.path.join('pyNN_%s' % VERSION,'doc','wikidoc.py')) 
    197198    import re 
    198199    from pyNN import __version__ 
     
    231232        else: 
    232233            style = groups['style'] 
    233         paragraph_list += [Paragraph(content, styles[style])] 
     234        try: 
     235            paragraph_list += [Paragraph(content, styles[style])] 
     236        except: 
     237            print "Error in >%s<" % content 
     238            content = content.replace("<","&lt;") ### 
     239             
    234240        #apidoc_frame.add(Paragraph(content, styles[style]), poster) 
    235241    pad = 0.5*cm 
     
    277283    styles['Title'].alignment = TA_LEFT 
    278284    styles['Code'].leftIndent = 0 
    279     svn_client = pysvn.Client() 
    280     svn_client.checkout(svnpath, "pyNN") 
    281     f = open(os.path.join('pyNN','test','VAbenchmarks.py'),'r') 
     285    checkout_pyNN() 
     286    f = open(os.path.join('pyNN_%s' % VERSION,'test','VAbenchmarks.py'),'r') 
    282287    example_script = f.read() 
    283288    f.close() 
     
    362367            f_height += p.wrap(width-2*pad,pageheight)[1] + p.getSpaceAfter() + p.getSpaceBefore() 
    363368        return f_height 
     369    i = 0 
    364370    while calc_height() > height: 
     371        if i > 100: 
     372            print "Warning: height failed to converge after 100 iterations (final value %s)" % calc_height() 
     373            break 
    365374        #print styles['BodyText'].fontSize 
    366375        scale_style(styles['BodyText'], 0.99) 
     376        i += 1 
    367377    scale_style(styles['BodyText'], 1/0.99) 
    368378    styles['BodyText'].alignment = TA_JUSTIFY # otherwise we get a 'bad align' error 
     
    428438 
    429439if __name__ == "__main__": 
    430     svnpath = "https://neuralensemble.kip.uni-heidelberg.de/svn/PyNN/branches/0.3" 
     440    VERSION = "0.4" 
     441    FILENAME = "poster_incf2008.pdf" 
     442    svnpath = "https://neuralensemble.kip.uni-heidelberg.de/svn/PyNN/branches/%s" % VERSION 
    431443    DEBUG = False 
    432444     
     
    507519    ##styles = getStyleSheet(36, 8) 
    508520 
    509     poster = Canvas("poster_cns2007.pdf"
     521    poster = Canvas(FILENAME
    510522                pagesize=landscape(A0), 
    511523                pageCompression=False, 
     
    539551    #huge_url(poster._pagesize[0]/2.0, title_bottom/2.0, pagewidth) 
    540552     
     553    print "--- Making API docs ---" 
    541554    apiwidth = 0.25*pagewidth 
    542555    x_api,y_api,w_api,h_api = make_apidocs(getStyleSheet(9,36),margins['left']+pagewidth-apiwidth, title_bottom, apiwidth, 
    543556                 colheight, DEBUG) 
    544  
    545557     
    546558    #make_users_guide(getStyleSheet(15),margins['left']+colwidth+colsep, title_bottom, colwidth, colheight, DEBUG) 
     559     
     560    print "--- Making example figure ---" 
    547561    x_ex,y_ex,w_ex,h_ex = make_example(getStyleSheet(10.5,36), x_api-colsep, title_bottom, colwidth, colheight, DEBUG) 
     562     
    548563    make_fancy_box(x_ex, margins['bottom'],w_ex+colsep+w_api,w_ex,y_ex-colsep-margins['bottom'],y_api-colsep-margins['bottom']) 
    549564    make_example_figure("VAbenchmark_CUBA_exc.png", x_ex, y_ex-colsep, w_ex, y_ex-colsep-margins['bottom'], DEBUG) 
     565    print "--- Making caption ---" 
    550566    make_example_figure_caption(CAPTIONS["VAbenchmark_CUBA_exc.png"], x_api-colsep, y_api-colsep, w_api+colsep, y_api-colsep-margins['bottom'], DEBUG) 
    551567     
    552  
     568    print "--- Adding QA ---" 
    553569    make_deflist_frame(getStyleSheet(36, 72),QA, margins['left'], title_bottom, x_ex-margins['left']-colsep, colheight, DEBUG) 
    554570 
     
    557573    poster.drawCentredString(margins['left']+pagewidth/2.0, 0.2*margins['bottom'], ACKNOWLEDGEMENTS) 
    558574 
     575    print "--- Saving poster ---" 
    559576    poster.save()