Page MenuHomec4science

Pyblio.Format-module.html
No OneTemporary

File Metadata

Created
Fri, Jul 4, 02:06

Pyblio.Format-module.html

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Pyblio.Format</title>
<link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="Pyblio-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
pybliographer&nbsp;1.3.3
</p></th></tr></table>
</th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<font size="-1"><b class="breadcrumbs">
<a href="Pyblio-module.html">Package&nbsp;Pyblio</a> ::
Package&nbsp;Format
</b></font></br>
</td>
<td><table cellpadding="0" cellspacing="0">
<tr><td align="right"><font size="-2">[<a href="../private/Pyblio.Format-module.html">show&nbsp;private</a>&nbsp;|&nbsp;hide&nbsp;private]</font></td></tr>
<tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="Pyblio.Format-module.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
</table></td>
</tr></table>
<!-- =========== START OF PACKAGE DESCRIPTION =========== -->
<h2 class="package">Package Pyblio.Format</h2>
<p>Citation formatting layer.</p>
<p>Rationale: the difficult part in formatting the records is not how the
records are actually laid out on a page, the keys,... but rather the
actual layout of the authors, the publication information,... especially
given that all the records are not complete.</p>
<p>So, this module is only intended to handle <i>this specific
aspect</i>, not to compose a whole page.</p>
The code here allows the writing of citation styles with a convenient
syntax:
<pre class="doctestblock">
<span class="py-src"><span class="py-prompt">&gt;&gt;&gt; </span>authors = lastFirst(all(<span class="py-string">'author'</span>))</span></pre>
<pre class="doctestblock">
<span class="py-src"><span class="py-prompt">&gt;&gt;&gt; </span>location = join(<span class="py-string">', '</span>)[<span class="py-string">'vol. '</span> + one (<span class="py-string">'volume'</span>),
<span class="py-prompt">... </span> <span class="py-string">'num. '</span> + one (<span class="py-string">'number'</span>), ]</span></pre>
<pre class="doctestblock">
<span class="py-src"><span class="py-prompt">&gt;&gt;&gt; </span>citation = join(<span class="py-string">', '</span>)[ authors , I[one(<span class="py-string">'title'</span>) | <span class="py-string">'untitled'</span>] ]</span></pre>
Citing a reference is a multi-stage operation:
<ul>
<li>
<b>stage 1:</b> the citation is written by the programmer in a
convenient Domain Specific Language (DSL)
<pre class="doctestblock">
<span class="py-src"><span class="py-prompt">&gt;&gt;&gt; </span>citation = join(<span class="py-string">', '</span>)[<span class="py-string">'vol. '</span> + one(<span class="py-string">'volume'</span>),
<span class="py-prompt">... </span> <span class="py-string">'num. '</span> + one(<span class="py-string">'number'</span>)]</span></pre>
</li>
<li>
<b>stage 2:</b> the formatter of stage 1 is 'compiled' on a
specific database (which allows for some initial checks (existence of
the requested fields and txo for instance)
<pre class="doctestblock">
<span class="py-src"><span class="py-prompt">&gt;&gt;&gt; </span>formatter = citation(db)</span></pre>
</li>
<li>
<b>stage 3:</b> the compiled formatter can accept records, and
return an abstract representation of the citation, with style
indications
<pre class="doctestblock">
<span class="py-src"><span class="py-prompt">&gt;&gt;&gt; </span>cited = formatter(record)</span></pre>
</li>
<li>
<b>stage 4:</b> the abstract representation is turned into a
concrete representations (plain text, HTML,...)
<pre class="doctestblock">
<span class="py-src"><span class="py-prompt">&gt;&gt;&gt; </span>html = HTML.generate(cited)</span></pre>
</li>
</ul>
The ideas for the syntax have been heavily borrowed from nevow's
stan.
<hr/>
<!-- =========== START OF SUBMODULES =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
<th colspan="2">Submodules</th></tr>
<tr><td><ul>
<li> <b><a href="Pyblio.Format.Base-module.html"><code>Base</code></a></b>: <i>(Base classes of the formatting code)</i>
<li> <b><a href="Pyblio.Format.Date-module.html"><code>Date</code></a></b>: <i>Date formatting functions.</i>
<li> <b><a href="Pyblio.Format.DSL-module.html"><code>DSL</code></a></b>: <i>Basic syntactic elements used to format a citation.</i>
<li> <b><a href="Pyblio.Format.Generator-module.html"><code>Generator</code></a></b>: <i>A base generator, specialized for every output style.</i>
<li> <b><a href="Pyblio.Format.HTML-module.html"><code>HTML</code></a></b>: <i>Transformation of the formatted record into an HTML
representation.</i>
<li> <b><a href="Pyblio.Format.Misc-module.html"><code>Misc</code></a></b>: <i>Miscellanous formatting helpers.</i>
<li> <b><a href="Pyblio.Format.OpenOffice-module.html"><code>OpenOffice</code></a></b>
<li> <b><a href="Pyblio.Format.Pages-module.html"><code>Pages</code></a></b>
<li> <b><a href="Pyblio.Format.Person-module.html"><code>Person</code></a></b>
<li> <b><a href="Pyblio.Format.S2-module.html"><code>S2</code></a></b>: <i>(Data structures for stage 2 of the formatter)</i>
<li> <b><a href="Pyblio.Format.S3-module.html"><code>S3</code></a></b>: <i>(Stage 3 objects, ie abstract representation of the actual layout)</i>
<li> <b><a href="Pyblio.Format.Text-module.html"><code>Text</code></a></b>: <i>Transformation of the formatted record into a textual
representation.</i>
</ul></td></tr>
</table><br />
<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
<tr valign="center">
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="Pyblio-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center">
<p class="nomargin">
pybliographer&nbsp;1.3.3
</p></th></tr></table>
</th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left"><font size="-2">Generated by Epydoc 2.1 on Sun Sep 24 23:52:43 2006</font></td>
<td align="right"><a href="http://epydoc.sourceforge.net"
><font size="-2">http://epydoc.sf.net</font></a></td>
</tr>
</table>
</body>
</html>

Event Timeline