rendered paste body#!/bin/python# -*- coding: utf-8 -*-#Générateur de fichier xml pour optimport glob, string#nom du fichier xmlnom_fichier="imgs.xml"#Création du fichier xmlfichier = open(nom_fichier, 'w')fichier.write("""<?xml version="1.0"?><!DOCTYPE opt SYSTEM "opt.dtd"><opt> <defaults> <title color="#444444ff" font="VistaSansMed 50" /> <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 xmlfor file in glob.glob(r'imgs/*'): fichier.write (corps1 + '<title>' + str(file) + '</title>' + saut_ligne + '<img src="' + str(file) + '" />' + corps2) print file#Fin, ajout de la dernière ligne:fichier.write ("</opt>")print "Génération terminée"