Changeset 125

Show
Ignore:
Timestamp:
02/18/06 14:52:45 (3 years ago)
Author:
tim
Message:

local commit before move

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/timhtcopy/pyramid/ht2pydir.py

    r124 r125  
    22from optparse import OptionParser 
    33 
    4 index_yml = """--- !fragment 
     4ht_index_yml = """--- !fragment 
    55template: index.html 
    66# The data to pass to the template 
    77local: 
    88  title: !htfiledata 
    9     file: %%(PDO)s%(HTFILE)s 
     9    file: %(PDO)s%(HTFILE)s 
    1010    key: title 
    1111  content: !fragment content.yml 
    1212""" 
    1313 
    14 content_yml = """--- !fragment 
     14ht_content_yml = """--- !fragment 
    1515# Type of template to use 
    1616template: content.html 
     
    2020  content: 
    2121    breadcrumb: !breadcrumb nav.yml nav 
    22     text: !htfile %%(PDO)s%(HTFILE)s 
     22    text: !htfile %(PDO)s%(HTFILE)s 
     23""" 
     24 
     25wiki_index_yml = """--- !fragment 
     26template: index.html 
     27# The data to pass to the template 
     28local: 
     29  title: !htfiledata 
     30    file: %(PDO)s%(HTFILE)s 
     31    key: title 
     32  content: !fragment content.yml 
     33""" 
     34 
     35wiki_content_yml = """--- !fragment 
     36# Type of template to use 
     37template: content.html 
     38 
     39# The data to pass to the template 
     40local: 
     41  content: 
     42    breadcrumb: !breadcrumb nav.yml nav 
     43    text: !wikiurl %(WIKIPREFIX)s%(WIKIURL)s 
    2344""" 
    2445 
     
    2849</n:invisible> 
    2950""" 
    30 def ht2pydir(htfile,outputdir): 
     51def mkpydir(type,dir,path,outputdir): 
    3152    OUTPUTDIR = os.path.abspath(outputdir) 
    3253    os.mkdir(OUTPUTDIR) 
    3354     
    34     iyml = file(os.path.join(OUTPUTDIR,'index.yml'),'w') 
    35     iyml.write(index_yml % {'HTFILE':htfile} ) 
    36     iyml.close() 
    37  
    38     cyml = file(os.path.join(OUTPUTDIR,'content.yml'),'w') 
    39     cyml.write(content_yml % {'HTFILE':htfile} ) 
    40     cyml.close() 
     55    if type == 'htfile': 
     56        iyml = file(os.path.join(OUTPUTDIR,'index.yml'),'w') 
     57        iyml.write(index_yml % {'HTFILE':htfile} ) 
     58        iyml.close() 
     59     
     60        cyml = file(os.path.join(OUTPUTDIR,'content.yml'),'w') 
     61        cyml.write(content_yml % {'HTFILE':htfile} ) 
     62        cyml.close() 
     63    elif type == 'wikiurl': 
     64         
    4165 
    4266    chtml = file(os.path.join(OUTPUTDIR,'content.html'),'w') 
     
    4569     
    4670def main(options,args): 
    47     ht2pydir(options.htfile,options.outputdir) 
     71         
     72    mkpydir(options.type,options,dir,options.path,options.outputdir,options.copy) 
    4873 
    4974def parseOptions(): 
     75    usage = "usage: mkpydir -t <type (wikiurl|htfile|html)> [-d <prefixdirforsourcefile>] -p <pathtosourcefile> -o <outputdir> [-l]" 
    5076    parser = OptionParser() 
    51     parser.add_option("-d", "--htfile", dest="htfile", help="the path to the htfile", metavar="HTFILE") 
     77    parser.add_option("-t", "--type", dest="type", help="the type of pydir content to be created", metavar="TYPE") 
     78    parser.add_option("-d", "--dir", dest="dir", help="the root directory for the an asset (to be used when sourcing pydotorg or wiki content)", metavar="DIR") 
     79    parser.add_option("-p", "--path", dest="path", help="the path to the asset", metavar="PATH") 
    5280    parser.add_option("-o", "--outputdir", dest="outputdir", help="directory in which to create the pyramid directory", metavar="OUTPUTDIR") 
     81    parser.add_option("-l", "--link", action="store_false", help="use a link to an existing ht file", dest="copy", metavar="LINK") 
     82    parser.add_option("-c", "--copy", action="store_true", help="copy the htfile into the directory",dest="copy", metavar="LINK") 
    5383    (options, args) = parser.parse_args() 
     84    if options.copy is not False: 
     85        options.copy=True 
    5486    main(options,args) 
    5587