Alter display code to pad with spaces and simplify
[uccvend-vendserver.git] / VendServer / VendingMachine.py
index e5a0251..72cec3d 100644 (file)
@@ -160,10 +160,9 @@ class VendingMachine:
                return (code == '501', code, string)
 
        def display(self, string):
-               if len(string) > 10:
-                       string = string[0:10]
-               string = re.sub('(.)\.', lambda match: '.'+match.group(1), string)
-               self.wfh.write('D'+string+'\n')
+               # display first ten characters of string, left aligned
+               self.wfh.write('D%-10.10s\n' % string)
+
                (code, string) = self.get_response()
                return (code == '300', code, string)
 

UCC git Repository :: git.ucc.asn.au