| 22 | | text: !htfile %(PDO)s%(HTFILE)s |
|---|
| 23 | | """ |
|---|
| 24 | | |
|---|
| 25 | | wiki_index_yml = """--- !fragment |
|---|
| 26 | | template: index.html |
|---|
| 27 | | # The data to pass to the template |
|---|
| 28 | | local: |
|---|
| 29 | | title: !htfiledata |
|---|
| 30 | | file: %(PDO)s%(HTFILE)s |
|---|
| 31 | | key: title |
|---|
| 32 | | content: !fragment content.yml |
|---|
| 33 | | """ |
|---|
| 34 | | |
|---|
| 35 | | wiki_content_yml = """--- !fragment |
|---|
| 36 | | # Type of template to use |
|---|
| 37 | | template: content.html |
|---|
| 38 | | |
|---|
| 39 | | # The data to pass to the template |
|---|
| 40 | | local: |
|---|
| 41 | | content: |
|---|
| 42 | | breadcrumb: !breadcrumb nav.yml nav |
|---|
| 43 | | text: !wikiurl %(WIKIPREFIX)s%(WIKIURL)s |
|---|
| | 26 | text: !%(TYPE)s %(PATH)s |
|---|
| 51 | | def mkpydir(type,dir,path,outputdir): |
|---|
| | 34 | |
|---|
| | 35 | def writeIndexYml(out,title): |
|---|
| | 36 | iyml = file(os.path.join(out,'index.yml'),'w') |
|---|
| | 37 | iyml.write(index_yml % {'TITLE':title} ) |
|---|
| | 38 | iyml.close() |
|---|
| | 39 | |
|---|
| | 40 | def writeContentYml(out,path,directive): |
|---|
| | 41 | cyml = file(os.path.join(out,'content.yml'),'w') |
|---|
| | 42 | cyml.write(content_yml % {'TYPE': directive,'PATH': path} ) |
|---|
| | 43 | cyml.close() |
|---|
| | 44 | |
|---|
| | 45 | |
|---|
| | 46 | def mkpydir(directive,prefix,path,outputdir,copy,title): |
|---|
| | 52 | if copy is True: |
|---|
| | 53 | htfile = 'content.ht' |
|---|
| | 54 | title = httitle % {'PATH': htfile} |
|---|
| | 55 | writeIndexYml(OUTPUTDIR,title) |
|---|
| | 56 | writeContentYml(OUTPUTDIR,htfile,directive) |
|---|
| | 57 | copyfrom = '%s%s'%(prefix,path) |
|---|
| | 58 | copyto = os.path.join(OUTPUTDIR,'content.ht') |
|---|
| | 59 | shutil.copyfile(copyfrom,copyto) |
|---|
| | 60 | else: |
|---|
| | 61 | htfile = '%s%s' % ('%(PDO)s',path) |
|---|
| | 62 | title = httitle % {'PATH': htfile} |
|---|
| | 63 | writeIndexYml(OUTPUTDIR,title) |
|---|
| | 64 | writeContentYml(OUTPUTDIR,htfile,directive) |
|---|
| | 65 | elif directive == 'wikiurl': |
|---|
| | 66 | wikiurl= '%s%s' % (prefix,path) |
|---|
| | 67 | writeIndexYml(OUTPUTDIR,title) |
|---|
| | 68 | writeContentYml(OUTPUTDIR,wikiurl,directive) |
|---|
| | 69 | elif directive == 'restfile': |
|---|
| | 70 | if copy is True: |
|---|
| | 71 | restfile = 'content.rst' |
|---|
| | 72 | writeIndexYml(OUTPUTDIR,title) |
|---|
| | 73 | writeContentYml(OUTPUTDIR,restfile,directive) |
|---|
| | 74 | copyfrom = '%s%s'%(prefix,path) |
|---|
| | 75 | copyto = os.path.join(OUTPUTDIR,restfile) |
|---|
| | 76 | shutil.copyfile(copyfrom,copyto) |
|---|
| | 77 | else: |
|---|
| | 78 | restfile = '%s%s' % ('%(PDO)s',path) |
|---|
| | 79 | writeIndexYml(OUTPUTDIR,title) |
|---|
| | 80 | writeContentYml(OUTPUTDIR,restfile,directive) |
|---|
| 77 | 95 | parser.add_option("-t", "--type", dest="type", help="the type of pydir content to be created", metavar="TYPE") |
|---|
| 78 | 96 | 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 | 97 | parser.add_option("-p", "--path", dest="path", help="the path to the asset", metavar="PATH") |
|---|
| 80 | 98 | 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") |
|---|
| | 99 | parser.add_option("-T", "--title", dest="title", help="the page title", metavar="TITLE") |
|---|
| | 100 | parser.add_option("-R", "--replace", action="store_true", dest="replace", help="if the directory exists, replace it with the new one", metavar="REPLACE") |
|---|
| | 101 | parser.add_option("-l", "--link", action="store_false", help="use a link to an existing ht file", dest="copy", metavar="COPY",default=True) |
|---|
| | 102 | parser.add_option("-c", "--copy", action="store_true", help="copy the htfile into the directory",dest="copy", metavar="COPY",default=True) |
|---|