<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.stringwiki.org/w/index.php?action=history&amp;feed=atom&amp;title=Listcitations.py</id>
	<title>Listcitations.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.stringwiki.org/w/index.php?action=history&amp;feed=atom&amp;title=Listcitations.py"/>
	<link rel="alternate" type="text/html" href="http://www.stringwiki.org/w/index.php?title=Listcitations.py&amp;action=history"/>
	<updated>2026-05-17T21:52:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>http://www.stringwiki.org/w/index.php?title=Listcitations.py&amp;diff=1936&amp;oldid=prev</id>
		<title>Tom at 17:34, 11 July 2007</title>
		<link rel="alternate" type="text/html" href="http://www.stringwiki.org/w/index.php?title=Listcitations.py&amp;diff=1936&amp;oldid=prev"/>
		<updated>2007-07-11T17:34:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Copy the following text into a file called listcitations.py with your favourite text editor&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#! /usr/bin/python&lt;br /&gt;
&lt;br /&gt;
## list citations script version 0.1&lt;br /&gt;
&lt;br /&gt;
## Copyright 2007 Tom Brown&lt;br /&gt;
&lt;br /&gt;
## This program is free software; you can redistribute it and/or&lt;br /&gt;
## modify it under the terms of the GNU General Public License as&lt;br /&gt;
## published by the Free Software Foundation; either version 3 of the&lt;br /&gt;
## License, or (at your option) any later version.&lt;br /&gt;
&lt;br /&gt;
## This program is distributed in the hope that it will be useful,&lt;br /&gt;
## but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the&lt;br /&gt;
## GNU General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
## You should have received a copy of the GNU General Public License&lt;br /&gt;
## along with this program.  If not, see &amp;lt;http://www.gnu.org/licenses/&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
## See http://www.stringwiki.org/wiki/SPIRES_script for more usage&lt;br /&gt;
## instructions&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;list citations script&lt;br /&gt;
Usage:&lt;br /&gt;
python listcitations.py TeX_file_name.tex [ -hbiv ] [ --help ]&lt;br /&gt;
&lt;br /&gt;
TeX_file_name must contain citations as standard arXiv references,&lt;br /&gt;
e.g. hep-th/9711200, 0705.0303, Maldacena:1997re or SPIRES journal&lt;br /&gt;
references, e.g. CMPHA,43,199&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
-h, --help&lt;br /&gt;
displays this help message&lt;br /&gt;
-b&lt;br /&gt;
displays the BiBTeX entry&lt;br /&gt;
-i&lt;br /&gt;
displays the bibitem entry&lt;br /&gt;
-v&lt;br /&gt;
verbose mode&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
__version__ = &amp;quot;0.1&amp;quot;&lt;br /&gt;
__author__ = &amp;quot;Tom Brown&amp;quot;&lt;br /&gt;
__copyright__ = &amp;quot;Copyright 2007 Tom Brown, GNU GPL 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
import os, sys, spires, getopt, re&lt;br /&gt;
&lt;br /&gt;
bibtexOpt = 0&lt;br /&gt;
bibitemOpt = 0&lt;br /&gt;
verboseOpt = 0&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    options, arguments = getopt.gnu_getopt(sys.argv[1:], &amp;#039;hbiv&amp;#039;, [&amp;#039;help&amp;#039;])&lt;br /&gt;
except getopt.error:&lt;br /&gt;
    print &amp;#039;error: you tried to use an unknown option or the argument for an option that requires it was missing; try \&amp;#039;listcitations.py -h\&amp;#039; for more information&amp;#039;&lt;br /&gt;
    sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
for o,a in options:&lt;br /&gt;
    if o in  (&amp;#039;-h&amp;#039;,&amp;#039;--help&amp;#039;):&lt;br /&gt;
        print __doc__&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;#039;-b&amp;#039;:&lt;br /&gt;
        bibtexOpt = 1&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;#039;-i&amp;#039;:&lt;br /&gt;
        bibitemOpt = 1&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;#039;-v&amp;#039;:&lt;br /&gt;
        verboseOpt = 1&lt;br /&gt;
&lt;br /&gt;
if len(arguments) != 1:&lt;br /&gt;
    print &amp;#039;you didn\&amp;#039;t specify a TeX file; try \&amp;#039;listcitations.py -h\&amp;#039; for more information&amp;#039;&lt;br /&gt;
    sys.exit(0)&lt;br /&gt;
else:&lt;br /&gt;
    TeXfilename = os.path.expanduser(arguments[0])&lt;br /&gt;
&lt;br /&gt;
if len(options) == 0:&lt;br /&gt;
    bibitemOpt = 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
print TeXfilename&lt;br /&gt;
&lt;br /&gt;
citations = spires.listCitations(TeXfilename)&lt;br /&gt;
&lt;br /&gt;
for citation in citations:&lt;br /&gt;
    if verboseOpt:&lt;br /&gt;
        print citation&lt;br /&gt;
    type,ref = spires.findRefType(citation)&lt;br /&gt;
    if verboseOpt:&lt;br /&gt;
        print type, ref&lt;br /&gt;
    if bibtexOpt:&lt;br /&gt;
        BiBTeX = spires.getBiBTeX(ref,type)&lt;br /&gt;
        BiBTeX = re.sub(&amp;#039;Article{[^,]*,&amp;#039;,&amp;#039;Article{&amp;#039; + citation + &amp;#039;,&amp;#039;,BiBTeX)&lt;br /&gt;
        print BiBTeX&lt;br /&gt;
    if bibitemOpt:&lt;br /&gt;
        bibitem = spires.getBibitem(ref,type)&lt;br /&gt;
        bibitem = re.sub(&amp;#039;bibitem{[^}]*}&amp;#039;,&amp;#039;bibitem{&amp;#039; + citation + &amp;#039;}&amp;#039;,bibitem)&lt;br /&gt;
        print bibitem&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tom</name></author>
	</entry>
</feed>