# -*- coding: ISO-8859-1 -*- """ capellaScript -- Copyright (c) 2011 Peter Becker >>> Dateiname einfügen Der Dateiname wird an der Seite verankert eingefügt|| Bei Problemen bitte eine Mail an peter_becker@freenet.de <<< Insert file name

The file name is inserted, anchored at the page.

In case of problems please a mail to peter_becker@freenet.de

Dateiname einfügen

Der Dateiname wird an der Seite verankert eingefügt.

Bei Problemen bitte eine Mail an peter_becker@freenet.de

Bestandsnaam invoegen

De bestandsnaam wordt, aan de pagina verankerd, ingevoegd.

Bij problemen graag een mail naar peter_becker@freenet.de

History: 19.02.11 - Erste Ausgabe 16.03.12 - Anpassung an korrektes UTF Handling ab Capella 7.1-08 12.05.13 - V 1.1.0 Anzeigetiefe einstellbar 13.05.13 - V 1.1.1 Dateipfad in Menü einblenden 07.01.14 - V 1.1.2 Position einstellbar 25.04.16 - V 1.2.0 Verbesserte Oberfläche, Filteroptionen, Festwert einsteuern 26.04.16 - V 1.2.1 Schriftgröße bis 50 erlaubt 04.05.16 - V 1.2.2 erweiterte Positionierung 05.05.16 - V 1.2.3 erweiterte Positionierung 09.05.16 - V 1.3.0 Batch eingebaut 10.05.16 - V 1.3.1 Korrektur im Batch durch Paul Villiger 10.05.16 - V 1.3.2 Korrektur der Positionrechnung im Batchbetrieb 11.05.16 - V 1.3.3 Korrektur der Positionrechnung im Batchbetrieb 29.10.17 - V 1.3.4 WW Internationalisierung (eng-de-nl) + kleinen Fehler berichtigt 25.12.17 - V 1.3.5 PB pathName() gibt in Capella 8 Slash statt Backslash zurück. Umgehung eingebaut 11.10.19 - V 1.2.6 WW KLeine Korrekturen in den Übersetzungen 30.03.20 - V 1.3.7 PB Timestamp hinzugefügt 31.03.20 - V 1.3.8 PB Timestamp Format Auswahl 01.04.20 - V 1.3.9 PB internationalisiert, Timestamp Format merken 08.08.20 - V 1.3.10 WW Korrektur/Ergänzung Timestamp 18.03.21 - V 1.3.11 PB Extension unterdrückbar 18.09.21 - V 1.3.12 PB englische und holländisch für neuen Menüeintrag, neue Checkbox in die Options übernommen """ #---------------------------------------------- english = { 'error' :'ERROR', 'notSaved' :'The file has not yet been saved', 'stand' :'Standard', 'italic' :'Italic', 'bold' :'Bold', 'BoldItalic' :'Bold Italic', 'pathFileNoFilter' :'Path + file name without filter', 'pathNoFilter' :'Only path without filter', 'fileFilter' :'File name with filter', 'dirFilter' :'Own directory with filter', 'path' :'Path description : ', 'fileN' :'Filename : ', 'pathdepth' :'Pathdepth ', 'abs' :'Absolute', 'top' :'Top', 'bottom' :'Bottom', 'left' :'Left ( + horizontal and vertical )', 'mid' :'Middle ( + horizontal and vertical )', 'right' :'Right ( + horizontal and vertical )', 'warning' :'Warning: This script functions only correctly from capella 7.1-08 !', 'indicDepth' :'0 = only filename, 1 = + own directory, etc.', 'hor' :'horizontal', 'ver' :'vertical', 'kon' :'Addition ', 'filter' :'Filter', 'begins' :'begins with [ , ends with ] , between them $ = print, - = do not print ;', 'plusKon' :'before or behind it : A = insert addition , e.g. : A[--$$$$$]', 'batchOperation' :'Batch operation of more files', 'style' :'Style', 'size' :'Size', 'font' :'Font', 'format' :'Format', 'posPlace' :'Position - placing', 'posType' :'Position - type', 'opt' :'Options', 'showdepth' :'Number of levels that are shown', 'showDefine' :'How will the file name be displayed ? ', 'title' :'Insert file name (Version ', 'selSourceDir' :'Please select source directory', 'capfiles' :'capella files', 'selTargetDir' :'Please select target directory', 'formatDate' :'Format', 'addTime' :'Timestamp', 'noTime' :'Without timestamp', 'extension' :'File name without extension' } german = { 'error' :'ERROR', 'notSaved' :'Die Datei wurde noch nicht gespeichert', 'stand' :'Standard', 'italic' :'Kursiv', 'bold' :'Fett', 'BoldItalic' :'Fett Kursiv', 'pathFileNoFilter' :'Pfad + Dateiname ohne Filter', 'pathNoFilter' :'nur Pfad ohne Filter', 'fileFilter' :'Dateiname mit Filter', 'dirFilter' :'eigenes Verzeichnis mit Filter', 'path' :'Pfadname : ', 'fileN' :'Dateiname : ', 'pathdepth' :'Pfadtiefe ', 'abs' :'absolut', 'top' :'oben', 'bottom' :'unten', 'left' :'links ( + horizontal und vertikal )', 'mid' :'mitte ( + horizontal und vertikal )', 'right' :'rechts ( + horizontal und vertikal )', 'warning' :'Achtung: Dieses Skript funktioniert erst ab Capella 7.1-08 korrekt !', 'indicDepth' :'0 = nur Dateiname, 1 = eigenes Verzeichnis, usw', 'hor' :'horizontal', 'ver' :'vertikal', 'kon' :'Addition ', 'filter' :'Filter', 'begins' :'beginnt mit [ , endet mit ] , dazwischen $ = ausdrucken, - = nicht ausdrucken ;', 'plusKon' :'davor oder danach : A = Addition einfügen .z.B.: A[--$$$$$]', 'batchOperation' :'Stapelverarbeitung von mehreren Dateien', 'style' :'Schriftschnitt', 'size' :'Größe', 'font' :'Schriftart', 'format' :'Schrift', 'posPlace' :'Position - Plazierung', 'posType' :'Position - Typ', 'opt' :'Optionen', 'showdepth' :'Anzeigetiefe', 'showDefine' :'Anzeige definieren', 'title' :'Dateiname einfügen (Version ', 'selSourceDir' :'Bitte Quellordner auswählen', 'capfiles' :'capella-Dateien', 'selTargetDir' :'Bitte Zielordner auswählen', 'formatDate' :'Format', 'addTime' :'Zeitstempel', 'noTime' :'ohne Zeitstempel', 'extension' :'Dateiname ohne Dateiendung' } dutch = { 'error' :'ERROR', 'notSaved' :'Het bestand is nog niet opgeslagen', 'stand' :'Standaard', 'italic' :'Cursief', 'bold' :'Vet', 'BoldItalic' :'Vet Cursief', 'pathFileNoFilter' :'Pad + bestandsnaam zonder filter', 'pathNoFilter' :'Slechts pad zonder filter', 'fileFilter' :'Bestandsnaam met filter', 'dirFilter' :'Eigen map met filter', 'path' :'Padbeschrijving : ', 'fileN' :'Bestandsnaam : ', 'pathdepth' :'Paddiepte ', 'abs' :'Absoluut', 'top' :'Boven', 'bottom' :'Onder', 'left' :'Links ( + horizontaal en verticaal )', 'mid' :'Midden ( + horizontaal en verticaal )', 'right' :'Rechts ( + horizontaal en verticaal )', 'warning' :'N.B.: Dit script functioneert pas correct vanaf capella 7.1-08 !', 'indicDepth' :'0 = slechts bestandsnaam, 1 = + eigen map, enz.', 'hor' :'horizontaal', 'ver' :'verticaal', 'kon' :'Additie ', 'filter' :'Filter', 'begins' :'begint met [ , eindigt met ] , daartussen $ = afdrukken, - = niet afdrukken ;', 'plusKon' :'ervoor of erachter : A = additie toevoegen , bv. : A[--$$$$$]', 'batchOperation' :'Stapelverwerking van meerdere bestanden', 'style' :'Tekenstijl', 'size' :'Grootte', 'font' :'Lettertype', 'format' :'Opmaak', 'posPlace' :'Positie - situering', 'posType' :'Positie - type', 'opt' :'Opties', 'showdepth' :'Aantal niveaus, dat wordt getoond', 'showDefine' :'Hoe wordt de bestandsnaam weergegeven ?', 'title' :'Bestandsnaam invoegen (Versie ', 'selSourceDir' :'Kies bronmap', 'capfiles' :'capella-bestanden', 'selTargetDir' :'Kies doelmap', 'formatDate' :'Opmaak', 'addTime' :'Tijdstempel', 'noTime' :'Zonder tijdstempel', 'extension' :'bestandsnaam zonder extensie' } try: setStringTable( ("en", english), ("de", german), ("nl", dutch)) except: def tr(s): return german[s] #--------------------------------------- from xml.dom.minidom import NodeList, Node, Element from caplib.capDOM import * from re import sub import tempfile, string, new, datetime import tkFont import Tkinter import os.path import time import locale, datetime import string, new locale.setlocale(locale.LC_ALL, '') today = datetime.datetime.today() #from xml.dom.minidom import * doc = [] # parentNode von score version = "1.3.12" def latin1_d(u): if isinstance(u, unicode): return u else: return u.decode('Latin-1') def getElementObjects(objList): # returns a List newList = NodeList() for n in range(objList.length): if objList[n].nodeType == objList[n].ELEMENT_NODE: newList.append(objList[n]) return newList def findElementNode(el,tagName): global doc childs = el.childNodes for n in range(childs.length): if childs[n].nodeType ==childs[n].ELEMENT_NODE and childs[n].tagName == tagName: return childs[n] return 'NONE' def addElementNode(el,tagName): # Neue Node zu "el" hinzufügen wenn Node "tagName" nicht existiert # ansonsten existierende Node zurückmelden global doc childs = el.childNodes for n in range(childs.length): if childs[n].nodeType ==childs[n].ELEMENT_NODE and childs[n].tagName == tagName: return childs[n] newChild = doc.createElement(tagName) el.appendChild(newChild) return newChild def addNewElementNode(el,tagName): # add new Node with tagName "tagName" to el global doc newChild = doc.createElement(tagName) el.appendChild(newChild) return newChild def getElementObjects(objList): # returns a List newList = NodeList() for n in range(objList.length): if objList[n].nodeType == objList[n].ELEMENT_NODE: newList.append(objList[n]) return newList def gotoChild(self, name, new=False): newEl = None if new: pass else: for child in self.childNodes: if child.nodeType == child.ELEMENT_NODE and child.tagName == name: newEl = child break if newEl == None: newEl = doc.createElement(name) self.appendChild(newEl) return newEl Node.gotoChild = new.instancemethod(gotoChild,None,Node) def addFileName(score,file2): global doc, Font, Hoehe, Schriftschnitt, hor, ver, PosOpt, PosPlatz global paperHight, paperWidth, paperLeft, paperRight, paperTop, paperBottom, paperLineDist global curDate, dateFormat #file = utf8_e(file2) if int(dateFormat.value()) <> 0: file2 = file2 + ' ' + curDate pOs = score.getElementsByTagName('pageObjects') #Position ermitteln if PosOpt == 0: # absolut #messageBox('PosOpt0',str(hor) + '\n' + str(ver)) x = hor y = ver elif PosOpt == 1: # oben y = str(0 + float(ver)) if PosPlatz == 2: x = str((((float(paperWidth) - float(paperLeft) - float(paperRight))) / ((float(paperLineDist)))) + float(hor)) elif PosPlatz == 1: x = str((((float(paperWidth) - float(paperLeft) - float(paperRight))) / (((float(paperLineDist)*2.0)))) + float(hor)) else: x = str(0 + float(hor)) elif PosOpt == 2: # unten y = str((((float(paperHight) - float(paperTop) - float(paperBottom) + 3 ))) / ((float(paperLineDist))) + float(ver)) if PosPlatz == 2: x = str((((float(paperWidth) - float(paperLeft) - float(paperRight))) / ((float(paperLineDist)))) + float(hor)) elif PosPlatz == 1: x = str((((float(paperWidth) - float(paperLeft) - float(paperRight))) / (((float(paperLineDist)*2.0)))) + float(hor)) else: x = str(0 + float(hor)) if not pOs: sys = findElementNode(score,'systems') newChild = doc.createElement('pageObjects') score.insertBefore(newChild,sys) pOs = score.getElementsByTagName('pageObjects') #messageBox('SYS',str(pOs)) drawObj = addNewElementNode(pOs[0],'drawObj') text = addNewElementNode(drawObj,'text') font = addNewElementNode(text,'font') content = addNewElementNode(text,'content') font.setAttribute('face',Font) font.setAttribute('height',str(Hoehe)) font.setAttribute('pitchAndFamily','0') if Schriftschnitt == 0: weight = '0' elif Schriftschnitt == 1: weight = '0' font.setAttribute('italic','true') elif Schriftschnitt == 2: weight = '700' elif Schriftschnitt == 3: weight = '700' font.setAttribute('italic','true') font.setAttribute('weight',weight) #messageBox('POS','x = ' + str(hor) + '\ny = ' + str(ver) + '\nalign = ' + str(PosPlatz)) text.setAttribute('y',y) text.setAttribute('x',x) if PosPlatz == 0: text.setAttribute('align','left') elif PosPlatz == 1: text.setAttribute('align','center') else: text.setAttribute('align','right') content.appendChild(score.parentNode.createTextNode(str(file2))) return def changeDoc(score): global doc, TiefeOpt, TiefeAnz, konstante, filt, PosOpt, PosPlatz global paperHight, paperWidth, paperLeft, paperRight, paperTop, paperBottom, paperLineDist layout = score.gotoChild('layout') # Abstand System distances = layout.gotoChild('distances') # Abstand Notenlinien staffLines = distances.gotoChild('staffLines') paperLineDist = staffLines.getAttribute('pageObj') # Abstand Seitenrand pages = layout.gotoChild('pages') paperSize = pages.getAttribute('paperSize') paperLeft = pages.getAttribute('left') paperRight = pages.getAttribute('right') ##(ww) war 'top' paperTop = pages.getAttribute('top') ##(ww) war 'right' paperBottom = pages.getAttribute('bottom') paperHight = 297.0 paperWidth = 210.0 if paperSize == 'A4': pass elif paperSize == 'A3': paperHight = 420.0 paperWidth = 297.0 elif paperSize == 'A5': paperHight = 210.0 paperWidth = 148.0 elif paperSize == 'B4': paperHight = 354.0 paperWidth = 250.0 elif paperSize == 'B5': paperHight = 257.0 paperWidth = 182.0 elif paperSize == 'Letter': paperHight = 279.0 paperWidth = 216.0 elif paperSize == 'Legal': paperHight = 356.0 paperWidth = 216.0 elif paperSize == 'Tabloid': paperHight = 432.0 paperWidth = 279.0 if pages.hasAttribute('landscape'): if pages.getAttribute('landscape') == 'true': h = paperHight w = paperWidth paperHight = w paperWidth = h doc = score.parentNode file = activeScore().pathName() #messageBox('EXT',str(ext)) if ext == 1: test = file.split('.cap') file = test[0] #messageBox('TEST',str(file)) #messageBox('file1',str(file)) printname = os.path.split(file)[1] file = sub('\\\\','/',file) # Umgehung für Capella 8 Fehler #messageBox('file2',str(file)) # pathName() gibt Slash statt Backslash zurück fileList = file.split('/') # daher Umwandlung von Backslah in Slash #messageBox('fileList',str(fileList)) printCt = TiefeAnz pathIx = len(fileList)-2 if printCt > 0 and TiefeOpt < 2: # anzuzeigenden Pfad ermitteln while pathIx > -1: printname = fileList[pathIx] + "\\" + printname printCt = printCt - 1 pathIx = pathIx - 1 if printCt == 0: break if TiefeOpt == 2: printname = printname if TiefeOpt == 3: printCt = 1 while pathIx > -1: printname = fileList[pathIx] printCt = printCt - 1 pathIx = pathIx - 1 if printCt == 0: break if len(file) == 0: messageBox(tr('error'),tr('notSaved')) else: if TiefeOpt == 1 and TiefeAnz <> 0: printname = os.path.split(printname)[0] #messageBox('1',str(printname)) if TiefeOpt == 2 or TiefeOpt == 3: filterIx = int(0) nameIx = int(0) filterLen = len(filt) #messageBox('2',str(filterIx) + '\n' + str(filterLen) + '\n' + str(filt)) if filterLen > 0: fiStart = 0 fiEnd = 0 result = '' while filterLen > 0: op = filt[filterIx] filterLen = filterLen-1 filterIx = filterIx+1 #messageBox('OP',str(op)) if fiStart == 0: if len(konstante) > 0: if op == 'A': ##(WW) Damit für mehrere Sprachen geeignet result = result + konstante fiStart = 1 if op == '[': fiStart = 1 elif fiStart == 1 and fiEnd == 0: if op == '$': #messageBox('printname',str(printname) + '\n' + str(nameIx)) wert = printname[nameIx] nameIx = nameIx + 1 result = result + wert if op == '-': nameIx = nameIx + 1 result = result + ' ' if op == ']': fiEnd = 1 elif len(konstante) > 0 and fiEnd == 1 and op == 'A': ##(WW) zugefügt: "and op == 'A' " result = result + konstante printname = result addFileName(score, printname) return def getFonts(): root = Tkinter.Tk() FontListT= tkFont.families() FontList = [] FontList2 = [] i=0 while i < len(FontListT): #FontList += [latin1_e(FontListT[i])] FontList += [FontListT[i]] i+=1 j=0 while j < len(FontList): FontName = FontList[j] FontList[j] = FontName[0].upper() + FontName[1:] j+=1 FontList.sort() root.destroy() return FontList #def pqDialog(FontList): # # global Hoehe, Font, Schriftschnitt, TiefeOpt, TiefeAnz, hor, ver, konstante, filt, PosOpt, PosPlatz sc = '2' # Startcount options = ScriptOptions() opt = options.get() #messageBox('Opt',str(opt)) Font = 'Times New Roman' Hoehe = '8' Schriftschnitt = '0' TiefeOpt = 0 TiefeAnz = 0 horizontal = '0' vertikal = '0' konstante = '' filt = '' PosOpt = 0 PosPlatz = 0 checkExt = 0 dateFo = 0 file1 = activeScore().pathName() # hier auf keinen Fall file = verwenden, sonst wird wird die file() Funktion dsname = os.path.split(file1)[1] # überschrieben. options.set(opt) stürzt dann ohne Fehlermeldung ab. pathname = os.path.split(file1)[0] # Danke an Paul Villiger ! FontList = getFonts() if opt: Font = opt.get('FontTyp',Font) Hoehe = opt.get('FontHigh',Hoehe) TiefeOpt = int( opt.get('TiefeOpt',str(TiefeOpt) ) ) TiefeAnz = int( opt.get('TiefeAnz',str(TiefeAnz) ) ) Schriftschnitt = opt.get('FontWeight',Schriftschnitt) horizontal= opt.get('horizontal',horizontal) vertikal = opt.get('vertikal',vertikal) konstante = opt.get('konstante',konstante) filt = opt.get('filt',filt) PosOpt = int( opt.get('PosOpt',str(PosOpt)) ) PosPlatz = int( opt.get('PosPlatz',str(PosPlatz) ) ) checkExt = int( opt.get('checkExt',str(checkExt) ) ) FontList = [Font] + FontList dateFo = int(opt.get('dateFo',dateFo)) #messageBox('OPT',str(opt)) Schriftschnitte = [tr('stand'),tr('italic'),tr('bold'),tr('BoldItalic')] TiefeLbl = [tr('pathFileNoFilter'),tr('pathNoFilter'),tr('fileFilter'), tr('dirFilter')] PathLbl = Label(tr('path') + pathname,width=70) DsLbl = Label(tr('fileN') + dsname,width=70) PtLbl = Label(tr('pathdepth') + ' ') PosLbl = [tr('abs'),tr('top'),tr('bottom')] PlatzLbl = [tr('left'),tr('mid'),tr('right')] placeholder1 = Label(' ',width=1) placeholder2 = Label(' ',width=1) placeholder3 = Label(' ',width=1) placeholder4 = Label(' ',width=1) hinweis = Label(tr('warning'),width=6) hinweisT = Label(tr('indicDepth'),width=10) horText = Label(tr('hor'),width=8) verText = Label(tr('ver'),width=5) konText = Label(tr('kon'),width=8) filText = Label(tr('filter'),width=8) layout1 = Label(tr('begins')) layout2 = Label(tr('plusKon')) fileExt = (tr('extension')) #messageBox('PQ',str(Font) + '\n' + str(FontList)) radTiefe = Radio(TiefeLbl, value=int(opt.get('TiefeOpt',str(TiefeOpt))), padding = 0) #checkExt = CheckBox(fileExt, value = 'false') checkExt = CheckBox(fileExt, value = checkExt) editTiefe = Edit(str(TiefeAnz), width=4, min = 0, max = 99) radSchnitt = Radio(Schriftschnitte, value=int(opt.get('FontWeight',str(Schriftschnitt))), padding = 0,text=tr('opt')) editHeight = Edit(Hoehe, width=4, min = 1, max = 50) comboFont = ComboBox(FontList, width=20, value=0) editHor = Edit(horizontal, width=5) editVer = Edit(vertikal, width=5) editKon = Edit(konstante, width=15) editFil = Edit(filt, width=15) radPos = Radio(PosLbl, value=PosOpt, padding = 0) radPlatz = Radio(PlatzLbl, value=PosPlatz, padding = 0) #checkTime = CheckBox('Timestamp hinzufügen', value = 'false') dateFormat = ComboBox([tr('noTime'), datetime.date.strftime(today,'%d. %B %Y'), datetime.date.strftime(today,'%d %B %Y'), datetime.date.strftime(today,'%B %Y'), datetime.date.strftime(today,'%d.%m.%Y'), datetime.date.strftime(today,'%d-%m-%Y'), datetime.date.strftime(today,'%d.%m.%Y - %H:%M'), datetime.date.strftime(today,'%d-%m-%Y %H:%M'), datetime.date.strftime(today,'%Y-%m-%d'), datetime.date.strftime(today,'%Y-%m-%d %H:%M') ], padding = 8, width = 30, value = dateFo) batchConversion = CheckBox(tr('batchOperation'), value = False) bC = VBox([batchConversion],text = ' ',padding = 5) box1aa = HBox([radSchnitt], padding = 0,text=tr('style')) box1ab = HBox([editHeight], padding = 0,text=tr('size')) box1ac = HBox([comboFont], padding = 50,text=tr('font')) box1a01 = HBox([box1ac, box1ab, placeholder4], padding = 8,text='') box1a = VBox([box1a01, box1aa], padding = 0,text=tr('format')) box2aa = HBox([horText,editHor,placeholder4], padding = 0,text='') box2ab = HBox([verText,editVer], padding = 0,text='') box2a = HBox([box2aa,box2ab,placeholder4],padding = 0) box2ac = VBox([box2a,radPlatz],padding = 0,text=tr('posPlace')) box2b = VBox([radPos],padding = 10,text=tr('posType')) box2c = HBox([box1a,box2b,box2ac],padding = 10,text='') box3aa = HBox([checkExt,radTiefe], padding = 50,text=tr('opt')) box3aaa = HBox([Label(tr('formatDate'), width=15),dateFormat ],text=tr('addTime')) box3ab = VBox([DsLbl,PathLbl],padding = 1,text='') box3ac = HBox([PtLbl,editTiefe, hinweisT], padding = 8,text=tr('showdepth')) box3acc = VBox([box3ac, box3aa, hinweisT], padding = 8,text=tr('showdepth')) box3ad = HBox([konText,editKon], padding = 10,text='') box3ae = HBox([filText,editFil], padding = 10,text='') box3af = VBox([layout1,layout2],text='') box3ag = HBox([box3ae,box3af,placeholder4], padding = 10,text='') box3ah = VBox([box3ad,box3ag], padding = 10,text='') box3a01 = HBox([box3aa,box3ac,placeholder4], padding = 8,text='') box3a = VBox([box3a01,placeholder4,box3ah],padding = 0,text=tr('showDefine')) box = VBox([box3ab,placeholder4,box3a,box2c,box3aaa,bC,hinweis,placeholder1],padding=1) dlg = Dialog(tr('title') + version + ')', box) if dlg.run(): Hoehe = editHeight.value() TiefeAnz = int( editTiefe.value() ) TiefeOpt = int( radTiefe.value() ) Font = FontList[comboFont.value()] Schriftschnitt = radSchnitt.value() hor = editHor.value() ver = editVer.value() konstante = editKon.value() filt = editFil.value() PosOpt = int( radPos.value() ) PosPlatz = int( radPlatz.value() ) checkExt = int( checkExt.value() ) batchConversion = batchConversion.value() continueScript = True dateFo = int(dateFormat.value()) ext = checkExt opt['FontTyp'] = str(Font) opt['FontHigh'] = str(Hoehe) opt['TiefeOpt'] = str(TiefeOpt) opt['TiefeAnz'] = str(TiefeAnz) opt['FontWeight'] = str(Schriftschnitt) opt['horizontal'] = str(hor) opt['vertikal'] = str(ver) opt['konstante'] = str(konstante) opt['filt'] = str(filt) opt['PosOpt'] = str(PosOpt) opt['PosPlatz'] = str(PosPlatz) opt['dateFo'] = str(dateFo) opt['checkExt'] = str(checkExt) options.set( opt ) #messageBox('Options Set', str(dateFormat.value())) if int(dateFormat.value()): ix = dateFormat.value() dFormat = ('', '%d. %B %Y', '%d %B %Y', '%B %Y', '%d.%m.%Y','%d-%m-%Y', '%d.%m.%Y - %H:%M', '%d-%m-%Y %H:%M', '%Y-%m-%d', '%Y-%m-%d %H:%M' )[ix] today = datetime.datetime.today() curDate = latin1_d( datetime.date.strftime(today, dFormat) ) dlgEnd = True #messageBox('DLGend2','dlg') if batchConversion: dlg = FileDialog() dlg.__init__(bOpen=False) dlg.setTitle(tr('selSourceDir')) dlg.addFilter(tr('capfiles'), '*.cap;*.capx') dlg.setStartFile('$$XX.cap') if dlg.run(): capFile=dlg.filePath() capDir, capName = os.path.split(capFile) else: continueScript = False dlg = FileDialog() dlg.__init__(bOpen=False) dlg.setTitle(tr('selTargetDir')) dlg.addFilter(tr('capfiles'), '*.cap;*.capx') dlg.setStartFile('$$XX.cap') if continueScript and dlg.run(): destFile=dlg.filePath() destDir, destName = os.path.split(destFile) else: continueScript = False else: continueScript = False dlgEnd = False # Hauptprogramm: from caplib.capDOM import ScoreChange import tempfile class ScoreChange(ScoreChange): def changeScore(self, score): if dlgEnd: changeDoc(score) # Hauptprogramm: if continueScript: if batchConversion: dirlist = os.listdir(capDir) dirlist.sort() for capFile in dirlist: head, tail = os.path.splitext(capFile) if tail.lower() not in ['.cap','.capx']: continue isXML = False if tail.lower() == '.capx': isXML = True capFileName = os.path.join(capDir,capFile) destFileName = os.path.join(destDir,capFile) if not os.path.isfile(capFileName): continue openScore(capFileName) if activeScore(): tempInput = tempfile.mktemp('.capx') tempOutput = tempfile.mktemp('.capx') activeScore().write(tempInput) ScoreChange(tempInput, tempOutput) activeScore().read(tempOutput) os.remove(tempInput) os.remove(tempOutput) activeScore().write(destFileName, xml = isXML) closeActiveScore() elif activeScore(): activeScore().registerUndo("Dateiname einfügen") tempInput = tempfile.mktemp('.capx') tempOutput = tempfile.mktemp('.capx') activeScore().write(tempInput) ScoreChange(tempInput, tempOutput) activeScore().read(tempOutput) os.remove(tempInput) os.remove(tempOutput)