Page MenuHomec4science

Pyblio.Format-module.html
No OneTemporary

File Metadata

Created
Thu, Jul 3, 11:38

Pyblio.Format-module.html

<?xml version="1.0" encoding="ascii"?>
<!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" />
<script type="text/javascript" src="epydoc.js"></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="Pyblio-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Tree link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Index link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Help link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
>pyblio-core 1.3.4</th>
</tr></table></th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<span class="breadcrumbs">
<a href="Pyblio-module.html">Package&nbsp;Pyblio</a> ::
Package&nbsp;Format
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
<tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
<tr><td align="right"><span class="options"
>[<a href="frames.html" target="_top">frames</a
>]&nbsp;|&nbsp;<a href="Pyblio.Format-module.html"
target="_top">no&nbsp;frames</a>]</span></td></tr>
</table>
</td>
</tr>
</table>
<!-- ==================== PACKAGE DESCRIPTION ==================== -->
<h1 class="epydoc">Package Format</h1><span class="codelink"><a href="Pyblio.Format-pysrc.html">source&nbsp;code</a></span><br /><br />
<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="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>authors = lastFirst(all(<span class="py-string">'author'</span>))</pre>
<pre class="py-doctest">
<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-more">... </span> <span class="py-string">'num. '</span> + one (<span class="py-string">'number'</span>), ]</pre>
<pre class="py-doctest">
<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>] ]</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="py-doctest">
<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-more">... </span> <span class="py-string">'num. '</span> + one(<span class="py-string">'number'</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="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>formatter = citation(db)</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="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>cited = formatter(record)</pre>
</li>
<li>
<b>stage 4:</b> the abstract representation is turned into a
concrete representations (plain text, HTML,...)
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>html = HTML.generate(cited)</pre>
</li>
</ul>
The ideas for the syntax have been heavily borrowed from nevow's
stan.<br /><br />
<!-- ==================== SUBMODULES ==================== -->
<a name="section-Submodules"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td colspan="2" class="table-header">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr valign="top">
<td align="left"><span class="table-header">Submodules</span></td>
<td align="right" valign="top"
><span class="options">[<a href="#section-Submodules"
class="privatelink" onclick="toggle_private();"
>hide private</a>]</span></td>
</tr>
</table>
</td>
</tr>
<tr><td class="summary">
<ul class="nomargin">
<li> <strong class="uidlink"><a href="Pyblio.Format.Base-module.html">Pyblio.Format.Base</a></strong>: <em class="summary">(Base classes of the formatting code)</em> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.DSL-module.html">Pyblio.Format.DSL</a></strong>: <em class="summary">Basic syntactic elements used to format a citation.</em> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.Date-module.html">Pyblio.Format.Date</a></strong>: <em class="summary">Date formatting functions.</em> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.Generator-module.html">Pyblio.Format.Generator</a></strong>: <em class="summary">A base generator, specialized for every output style.</em> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.HTML-module.html">Pyblio.Format.HTML</a></strong>: <em class="summary">Transformation of the formatted record into an HTML
representation.</em> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.Misc-module.html">Pyblio.Format.Misc</a></strong>: <em class="summary">Miscellanous formatting helpers.</em> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.OpenOffice-module.html">Pyblio.Format.OpenOffice</a></strong> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.Pages-module.html">Pyblio.Format.Pages</a></strong> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.Person-module.html">Pyblio.Format.Person</a></strong> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.S2-module.html">Pyblio.Format.S2</a></strong>: <em class="summary">(Data structures for stage 2 of the formatter)</em> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.S3-module.html">Pyblio.Format.S3</a></strong>: <em class="summary">(Stage 3 objects, ie abstract representation of the actual
layout)</em> </li>
<li> <strong class="uidlink"><a href="Pyblio.Format.Text-module.html">Pyblio.Format.Text</a></strong>: <em class="summary">Transformation of the formatted record into a textual
representation.</em> </li>
</ul></td></tr>
</table>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="Pyblio-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Tree link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Index link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Help link -->
<th>&nbsp;&nbsp;&nbsp;<a
href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
>pyblio-core 1.3.4</th>
</tr></table></th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0beta1 on Thu Sep 13 21:54:18 2007
</td>
<td align="right" class="footer">
<a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
// Private objects are initially displayed (because if
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
checkCookie()
// -->
</script>
</body>
</html>

Event Timeline