[Pycodeocr-main] SF.net SVN: pycodeocr:[40] branches/laserb/Modules
Status: Beta
Brought to you by:
drtrigon
|
From: <la...@us...> - 2011-03-01 16:56:37
|
Revision: 40
http://pycodeocr.svn.sourceforge.net/pycodeocr/?rev=40&view=rev
Author: laserb
Date: 2011-03-01 16:56:31 +0000 (Tue, 01 Mar 2011)
Log Message:
-----------
make it runable
Added Paths:
-----------
branches/laserb/Modules/RunExternal.py
branches/laserb/Modules/__init__.py
branches/laserb/Modules/checksum.py
Added: branches/laserb/Modules/RunExternal.py
===================================================================
--- branches/laserb/Modules/RunExternal.py (rev 0)
+++ branches/laserb/Modules/RunExternal.py 2011-03-01 16:56:31 UTC (rev 40)
@@ -0,0 +1,29 @@
+## Run external shell command/application.
+import subprocess
+class RunExternal:
+
+ error_msg = [ "/bin/sh: " ]
+
+ ## initialize
+ def __init__(self, cmd, error_msg):
+ self.cmd = cmd
+ self.error_msg += error_msg
+
+ ## call
+ def __call__(self):
+ (self.error, self.stdout, self.stderr) = self._run()
+ return self.error
+
+ ## Execute external shell command.
+ def _run(self, piped=True):
+ if piped:
+ run = subprocess.Popen( self.cmd,
+ stdin =subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ shell=True )
+ (stdoutdata, stderrdata) = run.communicate()
+ return ((max(map(stderrdata.find, self.error_msg)) != -1), stdoutdata, stderrdata)
+ else:
+ os.system( self.cmd )
+ return (False, "", "")
Added: branches/laserb/Modules/__init__.py
===================================================================
Added: branches/laserb/Modules/checksum.py
===================================================================
--- branches/laserb/Modules/checksum.py (rev 0)
+++ branches/laserb/Modules/checksum.py 2011-03-01 16:56:31 UTC (rev 40)
@@ -0,0 +1,19 @@
+## @file checksum.py
+# Modulo 10 checksum for e-banking codes
+class modulo10:
+ # thanks to http://www.hosang.ch/modulo10.aspx
+ # much more details http://www.sic.ch/de/dl_tkicch_dta.pdf ( page 51 )
+ # @see http://www.bundesbank.de/download/zahlungsverkehr/zv_pz201012.pdf
+ # @see http://www.bundesbank.de/zahlungsverkehr/zahlungsverkehr_pruefziffernberechnung.php
+ def __init__(self):
+ self.tabelle = [0,9,4,6,8,2,7,1,3,5]
+
+ def run(self,nr):
+ self.uebertrag = 0
+ # iterate over each character
+ for i in range(len(nr)):
+ self.uebertrag = self.tabelle[(self.uebertrag + int(nr[i]) )%10]
+
+ return (10-self.uebertrag)%10
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|