source: BibTeX.py @ 12:b209ea521e96

Revision 12:b209ea521e96, 5.0 KB checked in by andre.hagenbruch@rub.de, 7 years ago (diff)

Preparations for feed process refactoring.

Line 
1#!/usr/bin/env python
2# encoding: utf-8
3
4#  The MIT License
5#
6#  Copyright 2010 Andre Hagenbruch <andre.hagenbruch@ruhr-uni-bochum.de>.
7#
8#  Permission is hereby granted, free of charge, to any person obtaining a copy
9#  of this software and associated documentation files (the "Software"), to deal
10#  in the Software without restriction, including without limitation the rights
11#  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12#  copies of the Software, and to permit persons to whom the Software is
13#  furnished to do so, subject to the following conditions:
14#
15#  The above copyright notice and this permission notice shall be included in
16#  all copies or substantial portions of the Software.
17#
18#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24#  THE SOFTWARE.
25
26__author__ = "Andre Hagenbruch <andre.hagenbruch@ruhr-uni-bochum.de>"
27__date__ = "$23.01.2010 20:21:53$"
28
29from jinja2 import Template
30
31class BibTeX(object):
32    """
33    Documentation
34    """
35    TYPES = ('article', 'book', 'booklet', 'conference' 'inbook',
36             'incollection', 'inproceedings', 'manual', 'mastersthesis',
37             'misc', 'phdthesis', 'proceedings', 'techreport',
38             'unpublished', 'collection', 'patent')
39
40    TEMPLATE = '''
41        @{{ genre }}{{ "{" ~ id ~ "}" }},
42        {% for cat, val in body.items() -%}
43          {{ cat }}  = {{ "{" ~ val~ "}" }},
44        {% endfor -%}
45        }
46        '''
47
48    def __init__(self, address=None, annote=None, author=None,
49                 booktitle=None, chapter=None, crossref=None, edition=None,
50                 editor=None, howpublished=None, institution=None,
51                 journal=None, key=None, month=None, note=None,
52                 number=None, organization=None, pages=None, publisher=None,
53                 school=None, series=None, title=None, type=None,
54                 volume=None, year=None, affiliation=None, abstract=None,
55                 contents=None, copyright=None, ISBN=None, ISSN=None,
56                 keywords=None, language=None, location=None, LCCN=None,
57                 price=None, mrnumber=None, size=None, URL=None
58                 ):
59        """Documentation"""
60        self.address = address
61        self.annote = annote
62        self.author = author
63        self.booktitle = booktitle
64        self.chapter = chapter
65        self.crossref = crossref
66        self.edition = edition
67        self.editor = editor
68        self.howpublished = howpublished
69        self.institution = institution
70        self.journal = journal
71        self.key = key
72        self.month = month
73        self.number = number
74        self.organization = organization
75        self.pages = pages
76        self.publisher = publisher
77        self.school = school
78        self.series = series
79        self.title = title
80        self.type = type
81        self.volume = volume
82        self.year = year
83        self.affiliation = affiliation
84        self.abstract = abstract
85        self.contents = contents
86        self.copyright = copyright
87        self.ISBN = ISBN
88        self.ISSN = ISSN
89        self.keywords = keywords
90        self.language = language
91        self.location = location
92        self.LCCN = LCCN
93        self.price = price
94        self.mrnumber = mrnumber
95        self.size = size
96        self.URL = URL
97
98    def umlaut(self, text):
99        text = text.replace(u'"', '{"}')
100        text = text.replace(u'ü', '{\\"u}')
101        text = text.replace(u'Ü', '{\\"U}')
102        text = text.replace(u'ä', '{\\"a}')
103        text = text.replace(u'Ö', '{\\"O}')
104        text = text.replace(u'Ä', '{\\"A}')
105        text = text.replace(u'ö', '{\\"o}')
106        text = text.replace(u'ß', '{\\"s}')
107        text = text.replace(u'é', "{\\'e}")
108        text = text.replace(u'è', "{\\`e}")
109        text = text.replace(u'É', "{\\'E}")
110        text = text.replace(u'á', "{\\'a}")
111        text = text.replace(u'à', "{\\`a}")
112        text = text.replace(u'À', "{\\`A}")
113        text = text.replace(u'ó', "{\\'o}")
114        text = text.replace(u'ò', "{\\`o}")
115        text = text.replace(u'ú', "{\\'u}")
116        text = text.replace(u'ù', "{\\`u}")
117        text = text.replace(u'í', "{\\'i}")
118        text = text.replace(u'ì', "{\\`i}")
119        text = text.replace(u'â', "{\\^a}")
120        text = text.replace(u'ô', "{\\^o}")
121        text = text.replace(u'û', "{\\^u}")
122        text = text.replace(u'ê', "{\\^e}")
123        text = text.replace(u'î', "{\\^i}")
124        text = text.replace(u'ç', "{\\cc}")
125        text = text.replace(u'ñ', "{\\~n}")
126        text = text.replace(u'§', "$\\S$")
127        text = text.replace(u'°', "$\\circ$")
128        text = text.replace(u'²', "$\\^2$")
129        text = text.replace(u'³', "$\\^3$")
130        text = text.replace(u'Ù18O', "$\\beta$")
131        text = text.replace(u'µ', "$\\mu$")
132        text = text.replace(u'«', "{\\flqq}")
133        text = text.replace(u'»', "{\\frqq}")
134        text = text.replace(u'Å', "{\\AA}")
135        return text
136
137
138def main():
139    pass
140
141if __name__ == '__main__':
142    main()
Note: See TracBrowser for help on using the repository browser.