reportlab/lib/utils.py
author rgbecker
Wed, 25 Oct 2000 08:57:46 +0000
changeset 494 54257447cfe9
parent 474 5c5a9505fba1
child 519 0452f833153c
permissions -rw-r--r--
Changed to indirect copyright
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
494
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     1
#copyright ReportLab Inc. 2000
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     2
#see license.txt for license details
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     3
#history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/lib/utils.py?cvsroot=reportlab
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     4
#$Header: /tmp/reportlab/reportlab/lib/utils.py,v 1.5 2000/10/25 08:57:45 rgbecker Exp $
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 474
diff changeset
     5
__version__=''' $Id: utils.py,v 1.5 2000/10/25 08:57:45 rgbecker Exp $ '''
413
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
     6
from types import *
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
     7
SeqTypes = (ListType,TupleType)
452
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
     8
import string, os
413
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
     9
try:
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
    10
	#raise ImportError
474
5c5a9505fba1 Changes to make freezing easier
rgbecker
parents: 452
diff changeset
    11
	try:
5c5a9505fba1 Changes to make freezing easier
rgbecker
parents: 452
diff changeset
    12
		from reportlab.lib._rl_accel import fp_str	# specific
5c5a9505fba1 Changes to make freezing easier
rgbecker
parents: 452
diff changeset
    13
	except ImportError:
5c5a9505fba1 Changes to make freezing easier
rgbecker
parents: 452
diff changeset
    14
		from _rl_accel import fp_str				# in case of builtin version
413
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
    15
except ImportError:
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
    16
	def fp_str(*a):
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
    17
		if len(a)==1 and type(a[0]) in SeqTypes: a = a[0]
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
    18
		s = []
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
    19
		for i in a:
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
    20
			s.append('%0.2f' % i)
6312e8296c9b Initial version
rgbecker
parents:
diff changeset
    21
		return string.join(s)
448
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    22
452
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
    23
def getHyphenater(hDict=None):
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
    24
	try:
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
    25
		from reportlab.lib.pyHnj import Hyphen
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
    26
		if hDict is None: hDict=os.path.join(os.path.dirname(__file__),'hyphen.mashed')
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
    27
		return Hyphen(hDict)
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
    28
	except ImportError:
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
    29
		return None
6bb011a0d63e Initial version of D Yoo's pyHnj
rgbecker
parents: 448
diff changeset
    30
448
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    31
def _className(self):
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    32
	'''Return a shortened class name'''
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    33
	try:
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    34
		name = self.__class__.__name__
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    35
		i=string.rfind(name,'.')
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    36
		if i>=0: return name[i+1:]
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    37
		return name
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    38
	except AttributeError:
cb0c4d97e29b Added _className func
rgbecker
parents: 413
diff changeset
    39
		return str(self)