qrc.py
Go to the documentation of this file.
00001 import os
00002 import sys
00003 from string import Template
00004 
00005 qrc_template = \
00006 """
00007 <!DOCTYPE RCC><RCC version="1.0">
00008 <qresource>
00009 ${filelist}
00010 </qresource>
00011 </RCC>
00012 """
00013 
00014 item_template = """     <file>${filename}</file>\n"""
00015 
00016 def generate(directory, qrc_file):
00017     files = [x for x in os.listdir(directory)]
00018     files.sort()
00019     print >> sys.stderr, "\nCreating {}, based on the content of {}...".format(qrc_file, directory)
00020     items = ""
00021     item = Template(item_template)
00022     qrc = Template(qrc_template)
00023     for x in files:
00024         filename = os.path.join(directory, x)
00025         print >> sys.stderr, "Processing ", filename
00026         items += item.substitute(filename=filename)
00027 
00028     f = open(qrc_file, 'w')
00029     f.write(qrc.substitute(filelist=items))
00030     f.close
00031     print >> sys.stderr, "Done."
00032 


aseba
Author(s): Stéphane Magnenat
autogenerated on Sun Oct 5 2014 23:46:39