<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.stringwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Newacct</id>
	<title>String Theory Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://www.stringwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Newacct"/>
	<link rel="alternate" type="text/html" href="http://www.stringwiki.org/wiki/Special:Contributions/Newacct"/>
	<updated>2026-05-14T02:57:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.1</generator>
	<entry>
		<id>http://www.stringwiki.org/w/index.php?title=Arxiv.py&amp;diff=2475</id>
		<title>Arxiv.py</title>
		<link rel="alternate" type="text/html" href="http://www.stringwiki.org/w/index.php?title=Arxiv.py&amp;diff=2475"/>
		<updated>2010-04-10T01:55:44Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Copy the following text into a file called arxiv.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;
## arXiv script version 0.2&lt;br /&gt;
&lt;br /&gt;
## Copyright 2008 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/ArXiv_script for more usage&lt;br /&gt;
## instructions&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;arXiv script&lt;br /&gt;
Usage:&lt;br /&gt;
python arxiv.py reference [ -htabcjdps ] [ --help ]&lt;br /&gt;
&amp;quot;reference&amp;quot; must be a standard arXiv reference, e.g. hep-th/9711200, 0705.0303.&lt;br /&gt;
Options:&lt;br /&gt;
-h, --help&lt;br /&gt;
displays this help message&lt;br /&gt;
-t&lt;br /&gt;
displays the title&lt;br /&gt;
-a&lt;br /&gt;
displays the author(s)&lt;br /&gt;
-b&lt;br /&gt;
displays the aBstract&lt;br /&gt;
-c&lt;br /&gt;
displays the comments&lt;br /&gt;
-j&lt;br /&gt;
displays the journal reference&lt;br /&gt;
-d&lt;br /&gt;
downloads the PDF&lt;br /&gt;
-p&lt;br /&gt;
downloads the PS&lt;br /&gt;
-s&lt;br /&gt;
downloads the source file&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
__version__ = &amp;quot;0.2&amp;quot;&lt;br /&gt;
__author__ = &amp;quot;Tom Brown&amp;quot;&lt;br /&gt;
__copyright__ = &amp;quot;Copyright 2008 Tom Brown, GNU GPL 3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import sys, os, getopt, re, urllib,gzip&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def findRefType(ref):&lt;br /&gt;
    ref = ref.replace(&#039;arxiv:&#039;,&#039;&#039;)&lt;br /&gt;
    if re.search(r&#039;^[a-zA-Z\-]+/\d{7}$&#039;,ref):&lt;br /&gt;
        type = &#039;old-style eprint&#039;&lt;br /&gt;
    elif re.search(r&#039;^\d{7}$&#039;,ref):&lt;br /&gt;
        type = &#039;old-style eprint&#039;&lt;br /&gt;
        ref = &#039;hep-th/&#039; + ref&lt;br /&gt;
    elif re.search(&#039;^\d{4}\.\d{4}$&#039;,ref):&lt;br /&gt;
        type = &#039;new-style eprint&#039;&lt;br /&gt;
    else:&lt;br /&gt;
        type = &#039;not arXiv&#039;&lt;br /&gt;
&lt;br /&gt;
    return type, ref&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def downloadPDF(ref,type,downloadPath):&lt;br /&gt;
    downloadPath = os.path.expanduser(downloadPath)&lt;br /&gt;
    if type == &#039;old-style eprint&#039;:&lt;br /&gt;
        urllib.urlretrieve(&#039;http://arxiv.org/pdf/&#039; + ref, downloadPath + ref.replace(&#039;/&#039;,&#039;-&#039;) + &#039;.pdf&#039;)&lt;br /&gt;
    elif type == &#039;new-style eprint&#039;:&lt;br /&gt;
        urllib.urlretrieve(&#039;http://arxiv.org/pdf/&#039; + ref, downloadPath + ref + &#039;.pdf&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def downloadPS(ref,type,downloadPath):&lt;br /&gt;
    downloadPath = os.path.expanduser(downloadPath)&lt;br /&gt;
    filename = downloadPath + ref.replace(&#039;/&#039;,&#039;-&#039;)&lt;br /&gt;
    urllib.urlretrieve(&#039;http://arxiv.org/ps/&#039; + ref, filename)&lt;br /&gt;
    gzipFile =  gzip.GzipFile(filename)&lt;br /&gt;
    psFile = open(filename + &amp;quot;.ps&amp;quot;,&amp;quot;w&amp;quot;)&lt;br /&gt;
    psFile.write(gzipFile.read())&lt;br /&gt;
    psFile.close()&lt;br /&gt;
    gzipFile.close()&lt;br /&gt;
    os.remove(filename)&lt;br /&gt;
&lt;br /&gt;
def downloadSource(ref,type,downloadPath):&lt;br /&gt;
    downloadPath = os.path.expanduser(downloadPath)&lt;br /&gt;
    filename = downloadPath + ref.replace(&#039;/&#039;,&#039;-&#039;)&lt;br /&gt;
    urllib.urlretrieve(&#039;http://arxiv.org/e-print/&#039; + ref, filename + &amp;quot;.dum&amp;quot;)&lt;br /&gt;
    gzipFile =  gzip.GzipFile(filename + &amp;quot;.dum&amp;quot;)&lt;br /&gt;
    sourceFile = open(filename,&amp;quot;w&amp;quot;)&lt;br /&gt;
    sourceFile.write(gzipFile.read())&lt;br /&gt;
    sourceFile.close()&lt;br /&gt;
    gzipFile.close()&lt;br /&gt;
    os.remove(filename + &amp;quot;.dum&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getTitle(html):&lt;br /&gt;
    title = html[html.find(&amp;quot;&amp;gt;Title:&amp;lt;/span&amp;gt;&amp;quot;)+15:]&lt;br /&gt;
    title = title[:title.find(&amp;quot;&amp;lt;/h1&amp;gt;&amp;quot;)]&lt;br /&gt;
    return title&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getAuthors(html):&lt;br /&gt;
    authors = html[html.find(&amp;quot;&amp;gt;Authors:&amp;lt;/span&amp;gt;&amp;quot;):]&lt;br /&gt;
    authors = authors[authors.find(&amp;quot;\&amp;quot;&amp;gt;&amp;quot;)+2:]&lt;br /&gt;
    authors = authors[:authors.find(&amp;quot;&amp;lt;/div&amp;gt;&amp;quot;)]&lt;br /&gt;
    authors = re.sub(&#039;&amp;lt;[^&amp;gt;]*&amp;gt;&#039;,&#039;&#039;,authors)&lt;br /&gt;
    authors = authors.replace(&amp;quot;\n&amp;quot;,&amp;quot;&amp;quot;)&lt;br /&gt;
    return authors&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getAbstract(html):&lt;br /&gt;
    abstract = html[html.find(&amp;quot;Abstract:&amp;lt;/span&amp;gt;&amp;quot;)+17:]&lt;br /&gt;
    abstract = abstract[:abstract.find(&amp;quot;&amp;lt;/blockquote&amp;gt;&amp;quot;)-1]&lt;br /&gt;
    return abstract&lt;br /&gt;
&lt;br /&gt;
def getComments(html):&lt;br /&gt;
    if &amp;quot;comments&amp;quot; not in html:&lt;br /&gt;
        return &amp;quot;no comments&amp;quot;&lt;br /&gt;
    else:&lt;br /&gt;
        comments = html[html.find(&amp;quot;comments\&amp;quot;&amp;gt;&amp;quot;)+10:]&lt;br /&gt;
        comments = comments[:comments.find(&amp;quot;&amp;lt;/td&amp;gt;&amp;quot;)]&lt;br /&gt;
        return comments&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getJref(html):&lt;br /&gt;
    if &amp;quot;jref&amp;quot; not in html:&lt;br /&gt;
        return &amp;quot;no journal reference&amp;quot;&lt;br /&gt;
    else:&lt;br /&gt;
        jref = html[html.find(&amp;quot;jref\&amp;quot;&amp;gt;&amp;quot;)+6:]&lt;br /&gt;
        jref = jref[:jref.find(&amp;quot;&amp;lt;/td&amp;gt;&amp;quot;)]&lt;br /&gt;
        return jref&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
    authorOpt = 0&lt;br /&gt;
    titleOpt = 0&lt;br /&gt;
    abstractOpt = 0&lt;br /&gt;
    commentsOpt = 0&lt;br /&gt;
    jrefOpt = 0&lt;br /&gt;
    pdfOpt = 0&lt;br /&gt;
    psOpt = 0&lt;br /&gt;
    sourceOpt = 0&lt;br /&gt;
&lt;br /&gt;
    try:&lt;br /&gt;
        options, arguments = getopt.gnu_getopt(sys.argv[1:], &lt;br /&gt;
        &#039;hatbcjdpsv&#039;, [&#039;help&#039;])&lt;br /&gt;
    except getopt.error:&lt;br /&gt;
        print &#039;error: you tried to use an unknown option or the argument for an option that requires it was missing; try \&#039;arxiv.py -h\&#039; for more information&#039;&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    for o,a in options:&lt;br /&gt;
        if o in  (&#039;-h&#039;,&#039;--help&#039;):&lt;br /&gt;
            print __doc__&lt;br /&gt;
            sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-a&#039;:&lt;br /&gt;
            authorOpt = 1&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-t&#039;:&lt;br /&gt;
            titleOpt = 1&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-b&#039;:&lt;br /&gt;
            abstractOpt = 1&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-c&#039;:&lt;br /&gt;
            commentsOpt = 1&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-j&#039;:&lt;br /&gt;
            jrefOpt = 1&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-d&#039;:&lt;br /&gt;
            pdfOpt = 1&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-p&#039;:&lt;br /&gt;
            psOpt = 1&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-s&#039;:&lt;br /&gt;
            sourceOpt = 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    if len(options) == 0:&lt;br /&gt;
        authorOpt = 1&lt;br /&gt;
        titleOpt = 1&lt;br /&gt;
        abstractOpt = 1&lt;br /&gt;
        commentsOpt = 1&lt;br /&gt;
        jrefOpt = 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    if len(arguments) != 1:&lt;br /&gt;
        print &#039;you didn\&#039;t specify an arXiv reference; try \&#039;arxiv.py -h\&#039; for more information&#039;&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
    else:&lt;br /&gt;
        ref=arguments[0]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    type, ref = findRefType(ref)&lt;br /&gt;
&lt;br /&gt;
    if type==&amp;quot;not arXiv&amp;quot;:&lt;br /&gt;
        print &amp;quot;type not of arXiv form&amp;quot;&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    if authorOpt+titleOpt+abstractOpt+commentsOpt+jrefOpt &amp;gt; 0:&lt;br /&gt;
        htmlObject = urllib.urlopen(&#039;http://arxiv.org/abs/&#039; + ref)&lt;br /&gt;
        html = htmlObject.read()&lt;br /&gt;
&lt;br /&gt;
    if titleOpt:&lt;br /&gt;
        title = getTitle(html)&lt;br /&gt;
        print title&lt;br /&gt;
&lt;br /&gt;
    if authorOpt:&lt;br /&gt;
        authors = getAuthors(html)&lt;br /&gt;
        print authors&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    if abstractOpt:&lt;br /&gt;
        abstract = getAbstract(html)&lt;br /&gt;
        print abstract&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    if commentsOpt:&lt;br /&gt;
        comments = getComments(html)&lt;br /&gt;
        print comments&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    if jrefOpt:&lt;br /&gt;
        jref = getJref(html)&lt;br /&gt;
        print jref&lt;br /&gt;
&lt;br /&gt;
    if pdfOpt:&lt;br /&gt;
        downloadPDF(ref,type,&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if psOpt:&lt;br /&gt;
        downloadPS(ref,type,&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if sourceOpt:&lt;br /&gt;
        downloadSource(ref,type,&amp;quot;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>http://www.stringwiki.org/w/index.php?title=Spires.py&amp;diff=2426</id>
		<title>Spires.py</title>
		<link rel="alternate" type="text/html" href="http://www.stringwiki.org/w/index.php?title=Spires.py&amp;diff=2426"/>
		<updated>2010-02-05T21:44:12Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Copy the following text into a file called spires.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;
## SPIRES script version 0.3&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;
&#039;&#039;&#039;SPIRES script&lt;br /&gt;
Usage:&lt;br /&gt;
python spires.py reference [ -hbiatcev ] [ --help ] [ --library library.bib ] [ --download download_path/ ]&lt;br /&gt;
&amp;quot;reference&amp;quot; must be a standard arXiv reference, e.g. hep-th/9711200, 0705.0303, Maldacena:1997re or a SPIRES journal reference, e.g. CMPHA,43,199&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;
-a&lt;br /&gt;
displays the author(s)&lt;br /&gt;
-t&lt;br /&gt;
displays the title&lt;br /&gt;
-c&lt;br /&gt;
displays the TeX citation key&lt;br /&gt;
-e&lt;br /&gt;
displays everything&lt;br /&gt;
-v&lt;br /&gt;
verbose mode&lt;br /&gt;
&lt;br /&gt;
--download download_path/&lt;br /&gt;
for arXiv references downloads a pdf of the paper from the arXiv to the directory download_path/&lt;br /&gt;
--library library.bib&lt;br /&gt;
if it is not already in library.bib, appends the BiBTeX entry to library.bib; use at your own risk&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
__version__ = &amp;quot;0.2&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;
&lt;br /&gt;
import sys, os, getopt, re, urllib&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def findRefType(ref):&lt;br /&gt;
    ref = ref.replace(&#039;arxiv:&#039;,&#039;&#039;)&lt;br /&gt;
    if re.search(r&#039;^[a-zA-Z\-]+/\d{7}$&#039;,ref):&lt;br /&gt;
        type = &#039;old-style eprint&#039;&lt;br /&gt;
    elif re.search(r&#039;^\d{7}$&#039;,ref):&lt;br /&gt;
        type = &#039;old-style eprint&#039;&lt;br /&gt;
        ref = &#039;hep-th/&#039; + ref&lt;br /&gt;
    elif re.search(&#039;^\d{4}\.\d{4}$&#039;,ref):&lt;br /&gt;
        type = &#039;new-style eprint&#039;&lt;br /&gt;
    elif re.search(r&#039;^\D+:\d{4}[a-zA-Z]{2}$&#039;,ref):&lt;br /&gt;
        type = &#039;texkey&#039;&lt;br /&gt;
    else:&lt;br /&gt;
        type = &#039;journal&#039;&lt;br /&gt;
&lt;br /&gt;
    return type, ref&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getBiBTeX(ref,type):&lt;br /&gt;
    if type == &#039;old-style eprint&#039;:&lt;br /&gt;
        query = &#039;eprint=&#039; + ref&lt;br /&gt;
    elif type == &#039;new-style eprint&#039;:&lt;br /&gt;
        query = &#039;eprint=arXiv:&#039; + ref&lt;br /&gt;
    elif type == &#039;texkey&#039;:&lt;br /&gt;
        query = &#039;texkey=&#039; + ref&lt;br /&gt;
    elif type == &#039;journal&#039;:&lt;br /&gt;
        query = &#039;j=&#039; + ref&lt;br /&gt;
    else:&lt;br /&gt;
        return &amp;quot;no records were found in SPIRES to match your search, please try again&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    BiBTeX = urllib.urlopen(&#039;http://www.slac.stanford.edu/spires/find/hep/wwwbriefbibtex?&#039; + query + &#039;&amp;amp;server=sunspi5&#039;).read()&lt;br /&gt;
&lt;br /&gt;
    if &#039;No records&#039; in BiBTeX:&lt;br /&gt;
        return &amp;quot;no records were found in SPIRES to match your search, please try again&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    BiBTeX = BiBTeX[BiBTeX.find(&#039;&amp;lt;!-- START RESULTS --&amp;gt;&#039;):]&lt;br /&gt;
    BiBTeX = BiBTeX[BiBTeX.find(&#039;@&#039;):]&lt;br /&gt;
&lt;br /&gt;
    BiBTeX = BiBTeX[:BiBTeX.rfind(&#039;&amp;lt;!-- END RESULTS --&amp;gt;&#039;)+1]&lt;br /&gt;
    BiBTeX = BiBTeX[:BiBTeX.rfind(&#039;}&#039;)+1]&lt;br /&gt;
        &lt;br /&gt;
    return BiBTeX&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getBibitem(ref,type):&lt;br /&gt;
    if type == &#039;old-style eprint&#039;:&lt;br /&gt;
        query = &#039;eprint=&#039; + ref&lt;br /&gt;
    elif type == &#039;new-style eprint&#039;:&lt;br /&gt;
        query = &#039;eprint=arXiv:&#039; + ref&lt;br /&gt;
    elif type == &#039;texkey&#039;:&lt;br /&gt;
        query = &#039;texkey=&#039; + ref&lt;br /&gt;
    elif type == &#039;journal&#039;:&lt;br /&gt;
        query = &#039;j=&#039; + ref&lt;br /&gt;
    else:&lt;br /&gt;
        return &amp;quot;no records were found in SPIRES to match your search, please try again&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    bibitem = urllib.urlopen(&#039;http://www.slac.stanford.edu/spires/find/hep/wwwbrieflatex2?&#039; + query + &#039;&amp;amp;server=sunspi5&#039;).read()&lt;br /&gt;
&lt;br /&gt;
    if &#039;No records&#039; in bibitem:&lt;br /&gt;
        return &amp;quot;no records were found in SPIRES to match your search, please try again&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    bibitem = bibitem[bibitem.find(&#039;&amp;lt;!-- START RESULTS --&amp;gt;&#039;):]&lt;br /&gt;
    bibitem = bibitem[bibitem.find(&#039;%&#039;):]&lt;br /&gt;
    &lt;br /&gt;
    bibitem = bibitem[:bibitem.rfind(&#039;&amp;lt;!-- END RESULTS --&amp;gt;&#039;)+1]&lt;br /&gt;
    bibitem = bibitem[:bibitem.rfind(&#039;%&#039;)+1]&lt;br /&gt;
&lt;br /&gt;
    return bibitem&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def extractauthor(BiBTeX):&lt;br /&gt;
    # remove excess white space and replace with a single space&lt;br /&gt;
    data = re.sub(r&#039;\s+&#039;,r&#039; &#039;,BiBTeX)&lt;br /&gt;
&lt;br /&gt;
    author = data[data.find(&#039;author&#039;):]&lt;br /&gt;
    author = author[author.find(&#039;\&amp;quot;&#039;)+1:]&lt;br /&gt;
    author = author[:author.find(&#039;\&amp;quot;&#039;)]&lt;br /&gt;
&lt;br /&gt;
    return author&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def extracttitle(BiBTeX):&lt;br /&gt;
    # remove excess white space and replace with a single space&lt;br /&gt;
    data = re.sub(r&#039;\s+&#039;,r&#039; &#039;,BiBTeX)&lt;br /&gt;
&lt;br /&gt;
    title = data[data.find(&#039;title&#039;):]&lt;br /&gt;
    title = title[title.find(&#039;\&amp;quot;&#039;)+2:]&lt;br /&gt;
    title = title[:title.find(&#039;\&amp;quot;&#039;)-1]&lt;br /&gt;
&lt;br /&gt;
    return title&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def extractcite(BiBTeX):&lt;br /&gt;
    cite = BiBTeX[BiBTeX.find(&#039;{&#039;)+1:BiBTeX.find(&#039;,&#039;)]&lt;br /&gt;
    return cite&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def downloadeprint(ref,type,downloadPath):&lt;br /&gt;
    downloadPath = os.path.expanduser(downloadPath)&lt;br /&gt;
    if type == &#039;old-style eprint&#039;:&lt;br /&gt;
        urllib.urlretrieve(&#039;http://arxiv.org/pdf/&#039; + ref, downloadPath + ref.replace(&#039;/&#039;,&#039;-&#039;) + &#039;.pdf&#039;)&lt;br /&gt;
    elif type == &#039;new-style eprint&#039;:&lt;br /&gt;
        urllib.urlretrieve(&#039;http://arxiv.org/pdf/&#039; + ref, downloadPath + ref + &#039;.pdf&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def updatelibrary(cite,BiBTeX,BiBTeXlibraryFileName):&lt;br /&gt;
    BiBTeXlibraryFileName = os.path.expanduser(BiBTeXlibraryFileName)&lt;br /&gt;
    libraryfile = open(BiBTeXlibraryFileName, &#039;r&#039;)&lt;br /&gt;
    library = libraryfile.read()&lt;br /&gt;
    libraryfile.close()&lt;br /&gt;
&lt;br /&gt;
    if cite in library:&lt;br /&gt;
        print &#039;adding BiBTeX entry to &#039; + BiBTeXlibraryFileName&lt;br /&gt;
        #find the end of the file (the second argument means count from&lt;br /&gt;
        #the end of the file&lt;br /&gt;
        libraryfile = open(BiBTeXlibraryFileName, &#039;a&#039;)&lt;br /&gt;
        libraryfile.write(&#039;\n&#039; + BiBTeX + &#039;\n&#039;)&lt;br /&gt;
        libraryfile.close()      &lt;br /&gt;
    else:&lt;br /&gt;
        print &#039;BiBTeX entry already in library&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def listCitations(fileName):&lt;br /&gt;
    fileName = os.path.expanduser(fileName)&lt;br /&gt;
    f=open(fileName, &#039;r&#039;)&lt;br /&gt;
    data = f.read()&lt;br /&gt;
&lt;br /&gt;
    if r&#039;\begin{thebibliography}&#039; in data:&lt;br /&gt;
        data = data[:data.find(r&#039;\begin{thebibliography}&#039;)]&lt;br /&gt;
&lt;br /&gt;
    citations = []&lt;br /&gt;
&lt;br /&gt;
    while r&#039;\cite{&#039; in data:&lt;br /&gt;
        data = data[data.find(r&#039;\cite{&#039;) + 6:]&lt;br /&gt;
        if &#039;}&#039; in data:&lt;br /&gt;
            citation = data[:data.find(&#039;}&#039;)]&lt;br /&gt;
            data = data[data.find(&#039;}&#039;)+1:]&lt;br /&gt;
            citation += &#039;,&#039;&lt;br /&gt;
            while &#039;,&#039; in citation:&lt;br /&gt;
                if citation[:citation.find(&#039;,&#039;)] not in citations:&lt;br /&gt;
                    citations.append(citation[:citation.find(&#039;,&#039;)])&lt;br /&gt;
                citation = citation[citation.find(&#039;,&#039;)+1:]&lt;br /&gt;
    return citations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
    authorOpt = False&lt;br /&gt;
    titleOpt = False&lt;br /&gt;
    bibtexOpt = False&lt;br /&gt;
    bibitemOpt = False&lt;br /&gt;
    citeOpt = False&lt;br /&gt;
    verboseOpt = False&lt;br /&gt;
    libraryOpt = False&lt;br /&gt;
    downloadOpt = False&lt;br /&gt;
&lt;br /&gt;
    try:&lt;br /&gt;
        options, arguments = getopt.gnu_getopt(sys.argv[1:], &lt;br /&gt;
        &#039;hbiatcev&#039;, [&#039;help&#039;,&#039;library=&#039;,&#039;download=&#039;])&lt;br /&gt;
    except getopt.error:&lt;br /&gt;
        print &#039;error: you tried to use an unknown option or the argument for an option that requires it was missing; try \&#039;spires.py -h\&#039; for more information&#039;&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    for o,a in options:&lt;br /&gt;
        if o in  (&#039;-h&#039;,&#039;--help&#039;):&lt;br /&gt;
            print __doc__&lt;br /&gt;
            sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;--library&#039;:&lt;br /&gt;
            if a == &#039;&#039;:&lt;br /&gt;
                print &#039;--library expects an argument&#039;&lt;br /&gt;
                sys.exit(0)&lt;br /&gt;
            libraryOpt = 1&lt;br /&gt;
            BiBTeXlibraryFileName = os.path.expanduser(a)&lt;br /&gt;
            print &#039;library file name is &#039; + BiBTeXlibraryFileName&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;--download&#039;:&lt;br /&gt;
            downloadOpt = True&lt;br /&gt;
            if a == &#039;&#039;:&lt;br /&gt;
                a = &#039;./&#039;&lt;br /&gt;
            elif a[-1] != &#039;/&#039;:&lt;br /&gt;
                a += &#039;/&#039;&lt;br /&gt;
            downloadPath = os.path.expanduser(a)&lt;br /&gt;
            print &#039;download path is &#039; + downloadPath&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-b&#039;:&lt;br /&gt;
            bibtexOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-i&#039;:&lt;br /&gt;
            bibitemOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-a&#039;:&lt;br /&gt;
            authorOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-t&#039;:&lt;br /&gt;
            titleOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-c&#039;:&lt;br /&gt;
            citeOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-e&#039;:&lt;br /&gt;
            bibtexOpt = True&lt;br /&gt;
            authorOpt = True&lt;br /&gt;
            titleOpt = True&lt;br /&gt;
            citeOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-v&#039;:&lt;br /&gt;
            verboseOpt = True&lt;br /&gt;
&lt;br /&gt;
    if len(arguments) != 1:&lt;br /&gt;
        print &amp;quot;you didn&#039;t specify a SPIRES reference; try &#039;spires.py -h&#039; for more information&amp;quot;&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
    else:&lt;br /&gt;
        ref=arguments[0]&lt;br /&gt;
&lt;br /&gt;
    if len(options) == 0:&lt;br /&gt;
        bibtexOpt = True&lt;br /&gt;
        authorOpt = True&lt;br /&gt;
        titleOpt = True&lt;br /&gt;
        citeOpt = True&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    type, ref = findRefType(ref)&lt;br /&gt;
&lt;br /&gt;
    if verboseOpt:&lt;br /&gt;
        print &#039;the reference &#039; + ref + &#039; is a(n) &#039; + type&lt;br /&gt;
&lt;br /&gt;
    if bibtexOpt or authorOpt or titleOpt or citeOpt or libraryOpt:&lt;br /&gt;
        BiBTeX = getBiBTeX(ref,type)&lt;br /&gt;
        if &#039;no records&#039; in BiBTeX:&lt;br /&gt;
            print BiBTeX&lt;br /&gt;
            sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    if bibtexOpt:&lt;br /&gt;
        print BiBTeX&lt;br /&gt;
&lt;br /&gt;
    if bibitemOpt:&lt;br /&gt;
        bibitem = getBibitem(ref,type)&lt;br /&gt;
        print bibitem&lt;br /&gt;
        if &#039;no records&#039; in bibitem:&lt;br /&gt;
            sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    if authorOpt:&lt;br /&gt;
        author = extractauthor(BiBTeX)&lt;br /&gt;
        print author&lt;br /&gt;
&lt;br /&gt;
    if titleOpt:&lt;br /&gt;
        title = extracttitle(BiBTeX)&lt;br /&gt;
        print title&lt;br /&gt;
&lt;br /&gt;
    if citeOpt or libraryOpt:&lt;br /&gt;
        cite = extractcite(BiBTeX)&lt;br /&gt;
&lt;br /&gt;
    if citeOpt:&lt;br /&gt;
        print &#039;\cite{&#039; + cite + &#039;}&#039;&lt;br /&gt;
&lt;br /&gt;
    if libraryOpt:&lt;br /&gt;
        updatelibrary(cite,BiBTeX,BiBTeXlibraryFileName)&lt;br /&gt;
&lt;br /&gt;
    if downloadOpt:&lt;br /&gt;
        downloadeprint(ref,type,downloadPath)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>http://www.stringwiki.org/w/index.php?title=Spires.py&amp;diff=2404</id>
		<title>Spires.py</title>
		<link rel="alternate" type="text/html" href="http://www.stringwiki.org/w/index.php?title=Spires.py&amp;diff=2404"/>
		<updated>2009-12-25T10:42:46Z</updated>

		<summary type="html">&lt;p&gt;Newacct: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Copy the following text into a file called spires.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;
## SPIRES script version 0.3&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;
&#039;&#039;&#039;SPIRES script&lt;br /&gt;
Usage:&lt;br /&gt;
python spires.py reference [ -hbiatcev ] [ --help ] [ --library library.bib ] [ --download download_path/ ]&lt;br /&gt;
&amp;quot;reference&amp;quot; must be a standard arXiv reference, e.g. hep-th/9711200, 0705.0303, Maldacena:1997re or a SPIRES journal reference, e.g. CMPHA,43,199&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;
-a&lt;br /&gt;
displays the author(s)&lt;br /&gt;
-t&lt;br /&gt;
displays the title&lt;br /&gt;
-c&lt;br /&gt;
displays the TeX citation key&lt;br /&gt;
-e&lt;br /&gt;
displays everything&lt;br /&gt;
-v&lt;br /&gt;
verbose mode&lt;br /&gt;
&lt;br /&gt;
--download download_path/&lt;br /&gt;
for arXiv references downloads a pdf of the paper from the arXiv to the directory download_path/&lt;br /&gt;
--library library.bib&lt;br /&gt;
if it is not already in library.bib, appends the BiBTeX entry to library.bib; use at your own risk&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
__version__ = &amp;quot;0.2&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;
&lt;br /&gt;
import sys, os, getopt, re, urllib&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def findRefType(ref):&lt;br /&gt;
    ref = ref.replace(&#039;arxiv:&#039;,&#039;&#039;)&lt;br /&gt;
    if re.search(r&#039;^[a-zA-Z\-]+/\d{7}$&#039;,ref):&lt;br /&gt;
        type = &#039;old-style eprint&#039;&lt;br /&gt;
    elif re.search(r&#039;^\d{7}$&#039;,ref):&lt;br /&gt;
        type = &#039;old-style eprint&#039;&lt;br /&gt;
        ref = &#039;hep-th/&#039; + ref&lt;br /&gt;
    elif re.search(&#039;^\d{4}\.\d{4}$&#039;,ref):&lt;br /&gt;
        type = &#039;new-style eprint&#039;&lt;br /&gt;
    elif re.search(r&#039;^\D+:\d{4}[a-zA-Z]{2}$&#039;,ref):&lt;br /&gt;
        type = &#039;texkey&#039;&lt;br /&gt;
    else:&lt;br /&gt;
        type = &#039;journal&#039;&lt;br /&gt;
&lt;br /&gt;
    return type, ref&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getBiBTeX(ref,type):&lt;br /&gt;
    if type == &#039;old-style eprint&#039;:&lt;br /&gt;
        query = &#039;eprint=&#039; + ref&lt;br /&gt;
    elif type == &#039;new-style eprint&#039;:&lt;br /&gt;
        query = &#039;eprint=arXiv:&#039; + ref&lt;br /&gt;
    elif type == &#039;texkey&#039;:&lt;br /&gt;
        query = &#039;texkey=&#039; + ref&lt;br /&gt;
    elif type == &#039;journal&#039;:&lt;br /&gt;
        query = &#039;j=&#039; + ref&lt;br /&gt;
    else:&lt;br /&gt;
        return &amp;quot;no records were found in SPIRES to match your search, please try again&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    BiBTeX = urllib.urlopen(&#039;http://www.slac.stanford.edu/spires/find/hep/wwwbriefbibtex?&#039; + query + &#039;&amp;amp;server=sunspi5&#039;).read()&lt;br /&gt;
&lt;br /&gt;
    if &#039;No records&#039; in BiBTeX:&lt;br /&gt;
        return &amp;quot;no records were found in SPIRES to match your search, please try again&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    BiBTeX = BiBTeX[BiBTeX.find(&#039;&amp;lt;!-- START RESULTS --&amp;gt;&#039;):]&lt;br /&gt;
    BiBTeX = BiBTeX[BiBTeX.find(&#039;@&#039;):]&lt;br /&gt;
&lt;br /&gt;
    BiBTeX = BiBTeX[:BiBTeX.rfind(&#039;&amp;lt;!-- END RESULTS --&amp;gt;&#039;)+1]&lt;br /&gt;
    BiBTeX = BiBTeX[:BiBTeX.rfind(&#039;}&#039;)+1]&lt;br /&gt;
        &lt;br /&gt;
    return BiBTeX&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getBibitem(ref,type):&lt;br /&gt;
    if type == &#039;old-style eprint&#039;:&lt;br /&gt;
        query = &#039;eprint=&#039; + ref&lt;br /&gt;
    elif type == &#039;new-style eprint&#039;:&lt;br /&gt;
        query = &#039;eprint=arXiv:&#039; + ref&lt;br /&gt;
    elif type == &#039;texkey&#039;:&lt;br /&gt;
        query = &#039;texkey=&#039; + ref&lt;br /&gt;
    elif type == &#039;journal&#039;:&lt;br /&gt;
        query = &#039;j=&#039; + ref&lt;br /&gt;
    else:&lt;br /&gt;
        return &amp;quot;no records were found in SPIRES to match your search, please try again&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    bibitem = urllib.urlopen(&#039;http://www.slac.stanford.edu/spires/find/hep/wwwbrieflatex2?&#039; + query + &#039;&amp;amp;server=sunspi5&#039;).read()&lt;br /&gt;
&lt;br /&gt;
    if &#039;No records&#039; in bibitem:&lt;br /&gt;
        return &amp;quot;no records were found in SPIRES to match your search, please try again&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    bibitem = bibitem[bibitem.find(&#039;&amp;lt;!-- START RESULTS --&amp;gt;&#039;):]&lt;br /&gt;
    bibitem = bibitem[bibitem.find(&#039;%&#039;):]&lt;br /&gt;
    &lt;br /&gt;
    bibitem = bibitem[:bibitem.rfind(&#039;&amp;lt;!-- END RESULTS --&amp;gt;&#039;)+1]&lt;br /&gt;
    bibitem = bibitem[:bibitem.rfind(&#039;%&#039;)+1]&lt;br /&gt;
&lt;br /&gt;
    return bibitem&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def extractauthor(BiBTeX):&lt;br /&gt;
    # remove excess white space and replace with a single space&lt;br /&gt;
    data = re.sub(r&#039;\s+&#039;,r&#039; &#039;,BiBTeX)&lt;br /&gt;
&lt;br /&gt;
    author = data[data.find(&#039;author&#039;):]&lt;br /&gt;
    author = author[author.find(&#039;\&amp;quot;&#039;)+1:]&lt;br /&gt;
    author = author[:author.find(&#039;\&amp;quot;&#039;)]&lt;br /&gt;
&lt;br /&gt;
    return author&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def extracttitle(BiBTeX):&lt;br /&gt;
    # remove excess white space and replace with a single space&lt;br /&gt;
    data = re.sub(r&#039;\s+&#039;,r&#039; &#039;,BiBTeX)&lt;br /&gt;
&lt;br /&gt;
    title = data[data.find(&#039;title&#039;):]&lt;br /&gt;
    title = title[title.find(&#039;\&amp;quot;&#039;)+2:]&lt;br /&gt;
    title = title[:title.find(&#039;\&amp;quot;&#039;)-1]&lt;br /&gt;
&lt;br /&gt;
    return title&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def extractcite(BiBTeX):&lt;br /&gt;
    cite = BiBTeX[BiBTeX.find(&#039;{&#039;)+1:BiBTeX.find(&#039;,&#039;)]&lt;br /&gt;
    return cite&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def downloadeprint(ref,type,downloadPath):&lt;br /&gt;
    downloadPath = os.path.expanduser(downloadPath)&lt;br /&gt;
    if type == &#039;old-style eprint&#039;:&lt;br /&gt;
        urllib.urlretrieve(&#039;http://arxiv.org/pdf/&#039; + ref, downloadPath + ref.replace(&#039;/&#039;,&#039;-&#039;) + &#039;.pdf&#039;)&lt;br /&gt;
    elif type == &#039;new-style eprint&#039;:&lt;br /&gt;
        urllib.urlretrieve(&#039;http://arxiv.org/pdf/&#039; + ref, downloadPath + ref + &#039;.pdf&#039;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def updatelibrary(cite,BiBTeX,BiBTeXlibraryFileName):&lt;br /&gt;
    BiBTeXlibraryFileName = os.path.expanduser(BiBTeXlibraryFileName)&lt;br /&gt;
    libraryfile = open(BiBTeXlibraryFileName, &#039;r&#039;)&lt;br /&gt;
    library = libraryfile.read()&lt;br /&gt;
    libraryfile.close()&lt;br /&gt;
&lt;br /&gt;
    if library.count(cite) == 0:&lt;br /&gt;
        print &#039;adding BiBTeX entry to &#039; + BiBTeXlibraryFileName&lt;br /&gt;
        #find the end of the file (the second argument means count from&lt;br /&gt;
        #the end of the file&lt;br /&gt;
        libraryfile = open(BiBTeXlibraryFileName, &#039;a&#039;)&lt;br /&gt;
        libraryfile.write(&#039;\n&#039; + BiBTeX + &#039;\n&#039;)&lt;br /&gt;
        libraryfile.close()      &lt;br /&gt;
    else:&lt;br /&gt;
        print &#039;BiBTeX entry already in library&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def listCitations(fileName):&lt;br /&gt;
    fileName = os.path.expanduser(fileName)&lt;br /&gt;
    f=open(fileName, &#039;r&#039;)&lt;br /&gt;
    data = f.read()&lt;br /&gt;
&lt;br /&gt;
    if r&#039;\begin{thebibliography}&#039; in data:&lt;br /&gt;
        data = data[:data.find(r&#039;\begin{thebibliography}&#039;)]&lt;br /&gt;
&lt;br /&gt;
    citations = []&lt;br /&gt;
&lt;br /&gt;
    while r&#039;\cite{&#039; in data:&lt;br /&gt;
        data = data[data.find(r&#039;\cite{&#039;) + 6:]&lt;br /&gt;
        if &#039;}&#039; in data:&lt;br /&gt;
            citation = data[:data.find(&#039;}&#039;)]&lt;br /&gt;
            data = data[data.find(&#039;}&#039;)+1:]&lt;br /&gt;
            citation += &#039;,&#039;&lt;br /&gt;
            while &#039;,&#039; in citation:&lt;br /&gt;
                if citation[:citation.find(&#039;,&#039;)] not in citations:&lt;br /&gt;
                    citations.append(citation[:citation.find(&#039;,&#039;)])&lt;br /&gt;
                citation = citation[citation.find(&#039;,&#039;)+1:]&lt;br /&gt;
    return citations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
    authorOpt = False&lt;br /&gt;
    titleOpt = False&lt;br /&gt;
    bibtexOpt = False&lt;br /&gt;
    bibitemOpt = False&lt;br /&gt;
    citeOpt = False&lt;br /&gt;
    verboseOpt = False&lt;br /&gt;
    libraryOpt = False&lt;br /&gt;
    downloadOpt = False&lt;br /&gt;
&lt;br /&gt;
    try:&lt;br /&gt;
        options, arguments = getopt.gnu_getopt(sys.argv[1:], &lt;br /&gt;
        &#039;hbiatcev&#039;, [&#039;help&#039;,&#039;library=&#039;,&#039;download=&#039;])&lt;br /&gt;
    except getopt.error:&lt;br /&gt;
        print &#039;error: you tried to use an unknown option or the argument for an option that requires it was missing; try \&#039;spires.py -h\&#039; for more information&#039;&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    for o,a in options:&lt;br /&gt;
        if o in  (&#039;-h&#039;,&#039;--help&#039;):&lt;br /&gt;
            print __doc__&lt;br /&gt;
            sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;--library&#039;:&lt;br /&gt;
            if a == &#039;&#039;:&lt;br /&gt;
                print &#039;--library expects an argument&#039;&lt;br /&gt;
                sys.exit(0)&lt;br /&gt;
            libraryOpt = 1&lt;br /&gt;
            BiBTeXlibraryFileName = os.path.expanduser(a)&lt;br /&gt;
            print &#039;library file name is &#039; + BiBTeXlibraryFileName&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;--download&#039;:&lt;br /&gt;
            downloadOpt = True&lt;br /&gt;
            if a == &#039;&#039;:&lt;br /&gt;
                a = &#039;./&#039;&lt;br /&gt;
            elif a[-1] != &#039;/&#039;:&lt;br /&gt;
                a += &#039;/&#039;&lt;br /&gt;
            downloadPath = os.path.expanduser(a)&lt;br /&gt;
            print &#039;download path is &#039; + downloadPath&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-b&#039;:&lt;br /&gt;
            bibtexOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-i&#039;:&lt;br /&gt;
            bibitemOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-a&#039;:&lt;br /&gt;
            authorOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-t&#039;:&lt;br /&gt;
            titleOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-c&#039;:&lt;br /&gt;
            citeOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-e&#039;:&lt;br /&gt;
            bibtexOpt = True&lt;br /&gt;
            authorOpt = True&lt;br /&gt;
            titleOpt = True&lt;br /&gt;
            citeOpt = True&lt;br /&gt;
&lt;br /&gt;
        elif o == &#039;-v&#039;:&lt;br /&gt;
            verboseOpt = True&lt;br /&gt;
&lt;br /&gt;
    if len(arguments) != 1:&lt;br /&gt;
        print &amp;quot;you didn&#039;t specify a SPIRES reference; try &#039;spires.py -h&#039; for more information&amp;quot;&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
    else:&lt;br /&gt;
        ref=arguments[0]&lt;br /&gt;
&lt;br /&gt;
    if len(options) == 0:&lt;br /&gt;
        bibtexOpt = True&lt;br /&gt;
        authorOpt = True&lt;br /&gt;
        titleOpt = True&lt;br /&gt;
        citeOpt = True&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    type, ref = findRefType(ref)&lt;br /&gt;
&lt;br /&gt;
    if verboseOpt:&lt;br /&gt;
        print &#039;the reference &#039; + ref + &#039; is a(n) &#039; + type&lt;br /&gt;
&lt;br /&gt;
    if bibtexOpt or authorOpt or titleOpt or citeOpt or libraryOpt:&lt;br /&gt;
        BiBTeX = getBiBTeX(ref,type)&lt;br /&gt;
        if &#039;no records&#039; in BiBTeX:&lt;br /&gt;
            print BiBTeX&lt;br /&gt;
            sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    if bibtexOpt:&lt;br /&gt;
        print BiBTeX&lt;br /&gt;
&lt;br /&gt;
    if bibitemOpt:&lt;br /&gt;
        bibitem = getBibitem(ref,type)&lt;br /&gt;
        print bibitem&lt;br /&gt;
        if &#039;no records&#039; in bibitem:&lt;br /&gt;
            sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    if authorOpt:&lt;br /&gt;
        author = extractauthor(BiBTeX)&lt;br /&gt;
        print author&lt;br /&gt;
&lt;br /&gt;
    if titleOpt:&lt;br /&gt;
        title = extracttitle(BiBTeX)&lt;br /&gt;
        print title&lt;br /&gt;
&lt;br /&gt;
    if citeOpt or libraryOpt:&lt;br /&gt;
        cite = extractcite(BiBTeX)&lt;br /&gt;
&lt;br /&gt;
    if citeOpt:&lt;br /&gt;
        print &#039;\cite{&#039; + cite + &#039;}&#039;&lt;br /&gt;
&lt;br /&gt;
    if libraryOpt:&lt;br /&gt;
        updatelibrary(cite,BiBTeX,BiBTeXlibraryFileName)&lt;br /&gt;
&lt;br /&gt;
    if downloadOpt:&lt;br /&gt;
        downloadeprint(ref,type,downloadPath)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
</feed>