Hallo
Die »Arbeits-logik« in python:
import re
from string import punctuation
rex = re.compile(rf'\s(\s+)|[§{re.escape(punctuation)}]+')
def dump_data( raw ):
clean = rex.sub("", raw).upper()
no_space = clean.replace(" ","")
try:
i_row = int(raw)
except ValueError:
ordinals = map(ord, no_space )
i_row = sum(x-48 if x<58 else x-55 for x in ordinals )
doc = XSCRIPTCONTEXT.getDocument()
sheet = doc.Sheets.Tabelle1
the_row = sheet[i_row,4:]
data = set(filter(None,the_row.DataArray[0]))
data.add(clean)
data = sorted(data)
the_row[0,:len(data)].DataArray = [data]
def main( event ):
source = event.Source
context = source.getAccessibleContext()
parent = context.getAccessibleParent()
input_box = parent.getAccessibleChild(1)
raw_text = input_box.getText()
dump_data( raw_text )
Das TestDokument mit eingebettetem python-code
Gematrikulator_python.ods (34.8 KB)
Ich hab die umlaute vergessen, neue Version:
import re
from string import punctuation
rex = re.compile(rf'(\s)(\s+)|([§{re.escape(punctuation)}äöüßÄÖÜ])')
def repl( match ):
umldict = {'ä':'AE',
'ö':'OE',
'ü':'UE',
'ß':'SS'}
return umldict.get(match.group().lower(), "")
def dump_data( raw ):
clean = rex.sub(repl, raw).upper()
no_space = clean.replace(" ","")
try:
i_row = int(raw)
except ValueError:
ordinals = map(ord, no_space )
i_row = sum(x-48 if x<58 else x-55 for x in ordinals )
doc = XSCRIPTCONTEXT.getDocument()
sheet = doc.Sheets.Tabelle1
the_row = sheet[i_row,4:]
data = set(filter(None,the_row.DataArray[0]))
data.add(clean)
data = sorted(data)
the_row[0,:len(data)].DataArray = [data]
def main( event ):
source = event.Source
context = source.getAccessibleContext()
parent = context.getAccessibleParent()
input_box = parent.getAccessibleChild(1)
raw_text = input_box.getText()
dump_data( raw_text )
Gematrikulator_python_2.ods (35.7 KB)