def insert(self, index, item): if item is None: return elif edition_check(item, self.conf) is False: return outputs = resolve_outputs_for_redirect(item['outputs'], self.conf) for doc in process_redirect_inputs(outputs, item): super(HtaccessData, self).insert(index, RedirectSpecification(doc))
def pdf_tasks(sconf, conf, app): target = sconf.builder if 'pdfs' not in conf.system.files.data: return tex_regexes = [ ( re.compile(r'(index|bfcode)\{(.*)--(.*)\}'), r'\1\{\2-\{-\}\3\}'), ( re.compile(r'\\PYGZsq{}'), "'"), ( re.compile(r'\\code\{/(?!.*{}/|etc|usr|data|var|srv|data|bin|dev|opt|proc|24|private)'), r'\code{' + conf.project.url + r'/' + conf.project.tag + r'/') ] process_app = app.add('app') render_app = app.add('app') migrate_app = app.add('app') link_app = app.add('app') for i in conf.system.files.data.pdfs: if edition_check(i, conf) is False: continue i = i.dict() tagged_name = i['output'][:-4] + '-' + i['tag'] deploy_fn = tagged_name + '-' + conf.git.branches.current + '.pdf' link_name = deploy_fn.replace('-' + conf.git.branches.current, '') if 'edition' in conf.project and conf.project.edition != conf.project.name: if 'edition' in i and conf.project.edition != i['edition']: continue latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, hyph_concat(target, conf.project.edition)) else: latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, target) deploy_path = os.path.join(conf.paths.projectroot, conf.paths.public_site_output) i['source'] = os.path.join(latex_dir, i['output']) i['processed'] = os.path.join(latex_dir, tagged_name + '.tex') i['pdf'] = os.path.join(latex_dir, tagged_name + '.pdf') i['deployed'] = os.path.join(deploy_path, deploy_fn) i['link'] = os.path.join(deploy_path, link_name) i['path'] = latex_dir process_page(i['source'], i['processed'], tex_regexes, process_app, builder='tex-munge', copy='ifNeeded') render_task = render_app.add('task') render_task.dependency = i['processed'] render_task.target = i['pdf'] render_task.job = _render_tex_into_pdf render_task.args = (i['processed'], i['deployed'], i['path']) if i['link'] != i['deployed']: link_task = link_app.add('task') link_task.dependency = i['deployed'] link_task.target = i['link'] link_task.job = create_link link_task.args = (deploy_fn, i['link'])
def pdf_tasks(sconf, conf): """Returns a list of Tasks() to generate all PDFs.""" tasks = [] target = sconf.builder if 'pdfs' not in conf.system.files.data: return [] # a list of tuples in (compileRegex, substitution) format. tex_regexes = [ (re.compile(r'(index|bfcode)\{(.*)--(.*)\}'), r'\1\{\2-\{-\}\3\}'), (re.compile(r'\\PYGZsq{}'), "'"), (re.compile(r'\\code\{/(?!.*{}/|etc|usr|data|var|srv|data|bin|dev|opt|proc|24|private)'), r'\code{' + conf.project.url + r'/' + conf.project.tag + r'/')] # the path that sphinx writes tex files to are are different for editions. if 'edition' in conf.project and conf.project.edition != conf.project.name: latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, '-'.join((target, conf.project.edition))) else: latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, target) deploy_path = os.path.join(conf.paths.projectroot, conf.paths.public_site_output) # special case operations on "offset pdfs", which use EPS images. if 'tags' in sconf and "offset" in sconf.tags: output_format = "dvi" sty_file = os.path.join(latex_dir, 'sphinx.sty') t = process_page_task(fn=sty_file, output_fn=sty_file, regex=(re.compile(r'\\usepackage\[pdftex\]\{graphicx\}'), r'\usepackage{graphicx}'), builder='sphinx-latex', copy='ifNeeded') tasks.append(t) else: output_format = "pdf" for i in conf.system.files.data.pdfs: if edition_check(i, conf) is False: continue # compatibility shim for new/old images i = i.dict() if len(i['tag']) == 0: tagged_name = i['output'][:-4] else: tagged_name = i['output'][:-4] + '-' + i['tag'] deploy_fn = tagged_name + '-' + conf.git.branches.current + '.pdf' link_name = deploy_fn.replace('-' + conf.git.branches.current, '') i['source'] = os.path.join(latex_dir, i['output']) i['processed'] = os.path.join(latex_dir, tagged_name + '.tex') i['pdf'] = os.path.join(latex_dir, tagged_name + '.pdf') i['deployed'] = os.path.join(deploy_path, deploy_fn) i['link'] = os.path.join(deploy_path, link_name) i['path'] = latex_dir # add the processing task t = process_page_task(fn=i['source'], output_fn=i['processed'], regex=tex_regexes, builder='tex-munge', copy='ifNeeded') tasks.append(t) # add task for changing TEX to PDF. (this also copies the pdf to the deployed path). render_task = libgiza.task.Task(job=_render_tex_into_pdf, args=(i['processed'], i['deployed'], i['path'], output_format), target=i['pdf'], dependency=None) # i['processed'] t.finalizers.append(render_task) # if needed create links. if i['link'] != i['deployed']: link_task = libgiza.task.Task(job=create_link, args=(deploy_fn, i['link']), target=i['link'], dependency=i['deployed']) render_task.finalizers.append(link_task) return tasks
def pdf_tasks(sconf, conf, app): target = sconf.builder if 'pdfs' not in conf.system.files.data: return tex_regexes = [ (re.compile(r'(index|bfcode)\{(.*)--(.*)\}'), r'\1\{\2-\{-\}\3\}'), (re.compile(r'\\PYGZsq{}'), "'"), (re.compile( r'\\code\{/(?!.*{}/|etc|usr|data|var|srv|data|bin|dev|opt|proc|24|private)' ), r'\code{' + conf.project.url + r'/' + conf.project.tag + r'/') ] process_app = app.add('app') render_app = app.add('app') migrate_app = app.add('app') link_app = app.add('app') for i in conf.system.files.data.pdfs: if edition_check(i, conf) is False: continue i = i.dict() tagged_name = i['output'][:-4] + '-' + i['tag'] deploy_fn = tagged_name + '-' + conf.git.branches.current + '.pdf' link_name = deploy_fn.replace('-' + conf.git.branches.current, '') if 'edition' in conf.project and conf.project.edition != conf.project.name: if 'edition' in i and conf.project.edition != i['edition']: continue latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, hyph_concat(target, conf.project.edition)) else: latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, target) deploy_path = os.path.join(conf.paths.projectroot, conf.paths.public_site_output) i['source'] = os.path.join(latex_dir, i['output']) i['processed'] = os.path.join(latex_dir, tagged_name + '.tex') i['pdf'] = os.path.join(latex_dir, tagged_name + '.pdf') i['deployed'] = os.path.join(deploy_path, deploy_fn) i['link'] = os.path.join(deploy_path, link_name) i['path'] = latex_dir process_page(i['source'], i['processed'], tex_regexes, process_app, builder='tex-munge', copy='ifNeeded') render_task = render_app.add('task') render_task.dependency = i['processed'] render_task.target = i['pdf'] render_task.job = _render_tex_into_pdf render_task.args = (i['processed'], i['deployed'], i['path']) if i['link'] != i['deployed']: link_task = link_app.add('task') link_task.dependency = i['deployed'] link_task.target = i['link'] link_task.job = create_link link_task.args = (deploy_fn, i['link'])
def pdf_tasks(sconf, conf): """Returns a list of Tasks() to generate all PDFs.""" tasks = [] target = sconf.builder if 'pdfs' not in conf.system.files.data: return [] # a list of tuples in (compileRegex, substitution) format. tex_regexes = [ (re.compile(r'(index|bfcode)\{(.*)--(.*)\}'), r'\1\{\2-\{-\}\3\}'), (re.compile(r'\\PYGZsq{}'), "'"), (re.compile( r'\\code\{/(?!.*{}/|etc|usr|data|var|srv|data|bin|dev|opt|proc|24|private)' ), r'\code{' + conf.project.url + r'/' + conf.project.tag + r'/') ] # the path that sphinx writes tex files to are are different for editions. if 'edition' in conf.project and conf.project.edition != conf.project.name: latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, '-'.join( (target, conf.project.edition))) else: latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, target) deploy_path = os.path.join(conf.paths.projectroot, conf.paths.public_site_output) # special case operations on "offset pdfs", which use EPS images. if 'tags' in sconf and "offset" in sconf.tags: output_format = "dvi" sty_file = os.path.join(latex_dir, 'sphinx.sty') t = process_page_task( fn=sty_file, output_fn=sty_file, regex=(re.compile(r'\\usepackage\[pdftex\]\{graphicx\}'), r'\usepackage{graphicx}'), builder='sphinx-latex', copy='ifNeeded') tasks.append(t) else: output_format = "pdf" for i in conf.system.files.data.pdfs: if edition_check(i, conf) is False: continue # compatibility shim for new/old images i = i.dict() if len(i['tag']) == 0: tagged_name = i['output'][:-4] else: tagged_name = i['output'][:-4] + '-' + i['tag'] deploy_fn = tagged_name + '-' + conf.git.branches.current + '.pdf' link_name = deploy_fn.replace('-' + conf.git.branches.current, '') i['source'] = os.path.join(latex_dir, i['output']) i['processed'] = os.path.join(latex_dir, tagged_name + '.tex') i['pdf'] = os.path.join(latex_dir, tagged_name + '.pdf') i['deployed'] = os.path.join(deploy_path, deploy_fn) i['link'] = os.path.join(deploy_path, link_name) i['path'] = latex_dir # add the processing task t = process_page_task(fn=i['source'], output_fn=i['processed'], regex=tex_regexes, builder='tex-munge', copy='ifNeeded') tasks.append(t) # add task for changing TEX to PDF. (this also copies the pdf to the deployed path). render_task = libgiza.task.Task(job=_render_tex_into_pdf, args=(i['processed'], i['deployed'], i['path'], output_format), target=i['pdf'], dependency=None) # i['processed'] t.finalizers.append(render_task) # if needed create links. if i['link'] != i['deployed']: link_task = libgiza.task.Task(job=create_link, args=(deploy_fn, i['link']), target=i['link'], dependency=i['deployed']) render_task.finalizers.append(link_task) return tasks
def pdf_tasks(sconf, conf, app): """Adds tasks to a BuildApp() to generate all PDFs.""" target = sconf.builder if 'pdfs' not in conf.system.files.data: return # a list of tuples in (compileRegex, substitution) format. tex_regexes = [ (re.compile(r'(index|bfcode)\{(.*)--(.*)\}'), r'\1\{\2-\{-\}\3\}'), (re.compile(r'\\PYGZsq{}'), "'"), (re.compile( r'\\code\{/(?!.*{}/|etc|usr|data|var|srv|data|bin|dev|opt|proc|24|private)' ), r'\code{' + conf.project.url + r'/' + conf.project.tag + r'/') ] # the ordering of tasks. First post-process the tex generated by sphinx: process_app = app.add('app') # then convert tex to pdf render_app = app.add('app') # then migrate to build/public/ migrate_app = app.add('app') # then create symlinks for alternate named files. link_app = app.add('app') # the path that sphinx writes tex files to are are different for editions. if 'edition' in conf.project and conf.project.edition != conf.project.name: latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, hyph_concat(target, conf.project.edition)) else: latex_dir = os.path.join(conf.paths.projectroot, conf.paths.branch_output, target) deploy_path = os.path.join(conf.paths.projectroot, conf.paths.public_site_output) # special case operations on "offset pdfs", which use EPS images. if 'tags' in sconf and "offset" in sconf.tags: output_format = "dvi" sty_file = os.path.join(latex_dir, 'sphinx.sty') process_page(fn=sty_file, output_fn=sty_file, regex=(re.compile(r'\\usepackage\[pdftex\]\{graphicx\}'), r'\usepackage{graphicx}'), app=process_app, builder='sphinx-latex', copy='ifNeeded') else: output_format = "pdf" for i in conf.system.files.data.pdfs: if edition_check(i, conf) is False: continue #compatibility shim for new/old images i = i.dict() tagged_name = i['output'][:-4] + '-' + i['tag'] deploy_fn = tagged_name + '-' + conf.git.branches.current + '.pdf' link_name = deploy_fn.replace('-' + conf.git.branches.current, '') i['source'] = os.path.join(latex_dir, i['output']) i['processed'] = os.path.join(latex_dir, tagged_name + '.tex') i['pdf'] = os.path.join(latex_dir, tagged_name + '.pdf') i['deployed'] = os.path.join(deploy_path, deploy_fn) i['link'] = os.path.join(deploy_path, link_name) i['path'] = latex_dir # add the processing task process_page(i['source'], i['processed'], tex_regexes, process_app, builder='tex-munge', copy='ifNeeded') # add task for changing TEX to PDF. render_task = render_app.add('task') render_task.dependency = None #i['processed'] render_task.target = i['pdf'] render_task.job = _render_tex_into_pdf render_task.args = (i['processed'], i['deployed'], i['path'], output_format) # if needed create links. if i['link'] != i['deployed']: link_task = link_app.add('task') link_task.dependency = i['deployed'] link_task.target = i['link'] link_task.job = create_link link_task.args = (deploy_fn, i['link'])