Subversion Repositories pyptex

Compare Revisions

Ignore whitespace Rev 24 → Rev 25

/trunk/lib/__init__.py
15,7 → 15,7
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
from template import Template, templates, useAgain
from param import param, authortype, datetype, between, insteadOf
from param import param, noparam, authortype, datetype, between, insteadOf
from exceptions import *
from parser import BibParser
from output import Output
/trunk/lib/param.py
54,6 → 54,9
return fnc
return temp_param
 
def noparam(order = None):
return param(None, order)
 
def authortype(value):
name = None
old = None
/trunk/lib/entry.py
27,23 → 27,7
for name, (value, pos) in values.iteritems():
fnc = getattr(self, name, None)
if fnc is not None and getattr(fnc, 'param', False):
if isinstance(fnc.order, str):
tmp = getattr(self, fnc.order, None)
if tmp is None:
raise exceptions.RenderError(Exception("Bad order"), *pos)
fnc.im_func.order = param.insteadOf(tmp)
elif isinstance(fnc.order, tuple):
tmp1 = fnc.order[0]
if tmp1 is not None:
tmp1 = getattr(self, tmp1, None)
if tmp1 is None:
raise exceptions.RenderError(Exception("Bad order"), *pos)
tmp2 = fnc.order[1]
if tmp2 is not None:
tmp2 = getattr(self, tmp2, None)
if tmp2 is None:
raise exceptions.RenderError(Exception("Bad order"), *pos)
fnc.im_func.order = param.between(tmp1, tmp2)
self.__fixOrder(fnc, pos)
self.__params.append((name, fnc, pos))
type = getattr(fnc, 'type', str)
if type is str:
53,8 → 37,39
except Exception, e:
raise exceptions.RenderError(e, *pos)
for name in dir(self):
fnc = getattr(self, name)
if fnc is not None and getattr(fnc, 'param', False) and getattr(fnc, 'type', None) is None:
self.__fixOrder(fnc, None)
self.__params.append((None, fnc, None))
self.__params.sort(lambda x, y: cmp(x[1].order, y[1].order))
def __fixOrder(self, fnc, pos = None):
if isinstance(fnc.order, str):
tmp = getattr(self, fnc.order, None)
if tmp is None:
raise self.__mkException(Exception("Bad order"), pos)
fnc.im_func.order = param.insteadOf(tmp)
elif isinstance(fnc.order, tuple):
tmp1 = fnc.order[0]
if tmp1 is not None:
tmp1 = getattr(self, tmp1, None)
if tmp1 is None:
raise self.__mkException(Exception("Bad order"), pos)
tmp2 = fnc.order[1]
if tmp2 is not None:
tmp2 = getattr(self, tmp2, None)
if tmp2 is None:
raise self.__mkException(Exception("Bad order"), pos)
fnc.im_func.order = param.between(tmp1, tmp2)
def __mkException(self, exception, pos):
if pos is None:
return exception
else:
return exceptions.RenderError(exception, *pos)
def compareBy(self):
return u''
88,8 → 103,11
for name, fnc, pos in self.__params:
try:
fnc(out, self.__values[name])
if name is None:
fnc(out)
else:
fnc(out, self.__values[name])
except Exception, e:
raise exceptions.RenderError(e, *pos)
raise self.__mkException(e, pos)
out.unindent()
/trunk/lib/iso_690_2.py
74,9 → 74,9
 
def isoentry(id, separator = None, bSeparator = None):
def temp_block(fnc):
def do_block(self, out, value):
def do_block(self, out, *args):
out.beginEntry(id, separator, bSeparator)
fnc(self, out, value)
fnc(self, out, *args)
do_block.__name__ = fnc.__name__
return do_block
/trunk/templates/supertex.py
17,7 → 17,7
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
from lib import Template, param, authortype, encodetoascii, insteadOf, useAgain
from lib import Template, param, noparam, authortype, encodetoascii, insteadOf, useAgain
from lib.iso_690_2 import ISOFormat, isoentry
 
################################################################################
140,6 → 140,11
# prispevku v monografii
chap = 'kap.'
sec = 'odd.'
########################################################################
# techrepname = { 'Technick\\\'a spr\\\'ava' }
# oznacenie pre technicku spravu.
techrepname = 'Technick\\\'a spr\\\'ava'
 
class Labeling:
__noentry__ = True
458,6 → 463,17
def school(self, out, value):
out.write(value)
 
class TechReport(Misc):
@param(str, insteadOf('publisher'))
@isoentry('publisher')
def institution(self, out, value):
out.write(value)
@noparam(insteadOf('note'))
@isoentry('note')
def typenote(self, out):
out.write(self.techrepname)
 
class SlovakBaseNum(SlovakBase):
class Labeling:
__noentry__ = True
489,6 → 505,7
vol = 'vol.'
chap = 'kap.'
sec = 'odd.'
techrepname = 'Technick\\\'a spr\\\'ava'
 
class SlovakNum(SlovakBase):
Labeling = useAgain(SlovakBaseNum.Labeling)