~openerp-groupes/openobject-server/6.0-fix-setup-windows

« back to all changes in this revision

Viewing changes to bin/reportlab/lib/units.py

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
New trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python2.3
 
2
#Copyright ReportLab Europe Ltd. 2000-2004
 
3
#see license.txt for license details
 
4
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/lib/units.py
 
5
__version__=''' $Id$ '''
 
6
 
 
7
inch = 72.0
 
8
cm = inch / 2.54
 
9
mm = cm * 0.1
 
10
pica = 12.0
 
11
 
 
12
def toLength(s):
 
13
    '''convert a string to  a length'''
 
14
    try:
 
15
        if s[-2:]=='cm': return float(s[:-2])*cm
 
16
        if s[-2:]=='in': return float(s[:-2])*inch
 
17
        if s[-2:]=='pt': return float(s[:-2])
 
18
        if s[-1:]=='i': return float(s[:-1])*inch
 
19
        if s[-2:]=='mm': return float(s[:-2])*mm
 
20
        if s[-4:]=='pica': return float(s[:-2])*pica
 
21
        return float(s)
 
22
    except:
 
23
        raise ValueError, "Can't convert '%s' to length" % s
 
 
b'\\ No newline at end of file'