git.schokokeks.org
Repositories
Help
Report an Issue
invoice.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
40e1cda
Branches
Tags
factur-x_localdata
master
invoice.git
Invoice
__init__.py
Test-Script lauffähig
Bernd Wurst
commited
40e1cda
at 2024-02-14 13:27:16
__init__.py
Blame
History
Raw
import re def _formatPrice(price, symbol='€'): '''_formatPrice(price, symbol='€'): Gets a floating point value and returns a formatted price, suffixed by 'symbol'. ''' s = ("%.2f" % price).replace('.', ',') pat = re.compile(r'([0-9])([0-9]{3}[.,])') while pat.search(s): s = pat.sub(r'\1.\2', s) return s + ' ' + symbol def split_to_width(s, length): '''Fügt zeilenumbrüche in einen String ein, dass er maximal 'length' Zeichen lang ist''' orig = s ret = [] while len(s) > 0: if len(s) < length: ret.append(s) s = '' else: index = s.rfind(' ', 0, length) if index == -1: index = length ret.append(s[:index]) s = s[index + 1:] return ret