#!/bin/python # -*- coding: utf-8 -*- #Générateur de fichier xml pour opt import glob, string #nom du fichier xml nom_fichier="imgs.xml" #Création du fichier xml fichier = open(nom_fichier, 'w') fichier.write(""" <bullet color="#444444ff" font="VistaSansMed 40" /> <transition style="cube" /> <background src="bg.png" /> </defaults> """) corps1=""" <slide> """ corps2=""" <transition style="cube" /> </slide> """ saut_ligne=""" """ #A chaque fichier listé, ajouter le paragraphe correspondant dans le fichier xml for file in glob.glob(r'imgs/*'): fichier.write (corps1 + '<title>' + str(file) + '' + saut_ligne + '' + corps2) print file #Fin, ajout de la dernière ligne: fichier.write ("") print "Génération terminée"