generate_qml.py 625 Bytes
Newer Older
Michael Winkelmann's avatar
Michael Winkelmann committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#!/usr/bin/env python
import sys
import csv
import os    

if len(sys.argv) < 1:
    print "Usage: ./generate_qml.py input.csv > Output.qml"
    exit()

input_csv = sys.argv[1]

print "pragma Singleton"
print "import QtQuick 2.0"
print ""
print "QtObject {"
print '\treadonly property FontLoader font: FontLoader { source: \"%s\" }' % (input_csv[0:-4]+".ttf")

with open(input_csv, 'rb') as csvfile:
    reader = csv.reader(csvfile, delimiter=',', quotechar='"')
    for row in reader:
        if len(row) < 2:
            continue
        print '\treadonly property string %s: "\\u%s"' % (row[1],row[0].upper())

print "}"