2016-06-28 21:03:03 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2016-07-12 16:17:39 +00:00
|
|
|
# Copyright 2016 Google Inc.
|
2016-06-28 21:03:03 +00:00
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import sqlite3
|
|
|
|
|
|
|
|
def create_database(inpath, outpath):
|
|
|
|
with sqlite3.connect(outpath) as conn:
|
|
|
|
c = conn.cursor();
|
|
|
|
c.execute('''CREATE TABLE IF NOT EXISTS gradients (
|
2016-07-18 15:20:06 +00:00
|
|
|
FileName TEXT,
|
2016-07-12 16:17:39 +00:00
|
|
|
ColorCount INTEGER,
|
|
|
|
GradientType TEXT,
|
|
|
|
TileMode TEXT,
|
|
|
|
EvenlySpaced INTEGER,
|
|
|
|
HardStopCount INTEGER,
|
2016-07-14 14:44:50 +00:00
|
|
|
Verb TEXT,
|
2016-07-18 20:33:37 +00:00
|
|
|
BoundsWidth INTEGER,
|
|
|
|
BoundsHeight INTEGER,
|
2016-07-12 16:17:39 +00:00
|
|
|
Positions TEXT
|
2016-06-28 21:03:03 +00:00
|
|
|
)''');
|
|
|
|
c.execute("DELETE FROM gradients");
|
|
|
|
|
|
|
|
with open(inpath, "r") as results:
|
|
|
|
gradients = []
|
|
|
|
for line in [line.strip() for line in results]:
|
|
|
|
gradients.append(line.split());
|
|
|
|
|
2016-07-18 15:20:06 +00:00
|
|
|
c.executemany(
|
2016-07-18 20:33:37 +00:00
|
|
|
"INSERT INTO gradients VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
2016-07-18 15:20:06 +00:00
|
|
|
gradients);
|
2016-06-28 21:03:03 +00:00
|
|
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description = "Transform Lua script output to a SQL DB");
|
|
|
|
parser.add_argument("inpath", help="Path to Lua script output file");
|
|
|
|
parser.add_argument("outpath", help="Path to SQL DB");
|
|
|
|
args = parser.parse_args();
|
|
|
|
|
|
|
|
create_database(args.inpath, args.outpath);
|