commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/common/src TextUtils.py


From: Jason Cater
Subject: gnue/common/src TextUtils.py
Date: Tue, 12 Nov 2002 16:10:47 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/11/12 16:10:47

Modified files:
        common/src     : TextUtils.py 

Log message:
        added a textToMeasurment method that takes '12pt', '32cm', '1in' type 
strings and returns the measurement in inches

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/TextUtils.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gnue/common/src/TextUtils.py
diff -c gnue/common/src/TextUtils.py:1.1 gnue/common/src/TextUtils.py:1.2
*** gnue/common/src/TextUtils.py:1.1    Tue Sep 17 11:27:44 2002
--- gnue/common/src/TextUtils.py        Tue Nov 12 16:10:47 2002
***************
*** 53,55 ****
--- 53,66 ----
    return text
  
  
+ def textToMeasurement(text, multiplier=1):
+   # pt
+   if text[-1] in ('0','1','2','3','4','5','6','7','8','9'):
+     value = float(text) / 72 * multiplier
+   else:
+     unit = text[-2:]
+     text = text[:-2]
+     value = float(text) / {'pt':72, 'in':1, 'cm':2.54,
+                            'mm': 25.4}[unit.lower()] * multiplier
+ 
+   return value
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]