[pypy-svn] r3767 - pypy/trunk/doc/funding/negotiations

arigo at codespeak.net arigo at codespeak.net
Mon Apr 5 14:04:21 CEST 2004


Author: arigo
Date: Mon Apr  5 14:04:20 2004
New Revision: 3767

Added:
   pypy/trunk/doc/funding/negotiations/locale-killer.py
Log:
Removes the dependency on the locale for cpf files


Added: pypy/trunk/doc/funding/negotiations/locale-killer.py
==============================================================================
--- (empty file)
+++ pypy/trunk/doc/funding/negotiations/locale-killer.py	Mon Apr  5 14:04:20 2004
@@ -0,0 +1,32 @@
+"""
+Transforms lines:
+
+        <tan_fixed_assets_t1>5,031,956.77</tan_fixed_assets_t1>
+
+--->
+
+        <tan_fixed_assets_t1>5031957</tan_fixed_assets_t1>
+"""
+
+import sys, re
+
+re_line = re.compile(r"\s*[<][^>]+[>]([0-9,.]+)[<][^>]+[>]\s*$")
+
+for line in sys.stdin:
+    match = re_line.match(line)
+    if match and (',' in line or '.' in line):
+        g = match.group(1)
+        extra = 0
+        if '.' in g:
+            assert g.index('.') == len(g)-3
+            assert '0' <= g[-2] <= '9'
+            assert '0' <= g[-1] <= '9'
+            if g[-2] >= '5':
+                extra = 1
+            g = g[:-3]
+        g = g.replace(',', '')
+        g = str(int(g) + extra)
+        start = line[:match.start(1)]
+        end = line[match.end(1):]
+        line = start + g + end
+    sys.stdout.write(line)


More information about the Pypy-commit mailing list