Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: tools/lua/gradients.py

Issue 2150663002: Add verb field in scraping scripts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/lua/gradients.lua ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2016 Google Inc. 3 # Copyright 2016 Google Inc.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 import argparse 8 import argparse
9 import sqlite3 9 import sqlite3
10 10
11 def create_database(inpath, outpath): 11 def create_database(inpath, outpath):
12 with sqlite3.connect(outpath) as conn: 12 with sqlite3.connect(outpath) as conn:
13 c = conn.cursor(); 13 c = conn.cursor();
14 c.execute('''CREATE TABLE IF NOT EXISTS gradients ( 14 c.execute('''CREATE TABLE IF NOT EXISTS gradients (
15 ColorCount INTEGER, 15 ColorCount INTEGER,
16 GradientType TEXT, 16 GradientType TEXT,
17 TileMode TEXT, 17 TileMode TEXT,
18 EvenlySpaced INTEGER, 18 EvenlySpaced INTEGER,
19 HardStopCount INTEGER, 19 HardStopCount INTEGER,
20 Verb TEXT,
20 Positions TEXT 21 Positions TEXT
21 )'''); 22 )''');
22 c.execute("DELETE FROM gradients"); 23 c.execute("DELETE FROM gradients");
23 24
24 with open(inpath, "r") as results: 25 with open(inpath, "r") as results:
25 gradients = [] 26 gradients = []
26 for line in [line.strip() for line in results]: 27 for line in [line.strip() for line in results]:
27 gradients.append(line.split()); 28 gradients.append(line.split());
28 29
29 c.executemany("INSERT INTO gradients VALUES (?, ?, ?, ?, ?, ?)", 30 c.executemany("INSERT INTO gradients VALUES (?, ?, ?, ?, ?, ?, ?)",
30 gradients); 31 gradients);
31 32
32 conn.commit(); 33 conn.commit();
33 34
34 35
35 if __name__ == "__main__": 36 if __name__ == "__main__":
36 parser = argparse.ArgumentParser( 37 parser = argparse.ArgumentParser(
37 description = "Transform Lua script output to a SQL DB"); 38 description = "Transform Lua script output to a SQL DB");
38 parser.add_argument("inpath", help="Path to Lua script output file"); 39 parser.add_argument("inpath", help="Path to Lua script output file");
39 parser.add_argument("outpath", help="Path to SQL DB"); 40 parser.add_argument("outpath", help="Path to SQL DB");
40 args = parser.parse_args(); 41 args = parser.parse_args();
41 42
42 create_database(args.inpath, args.outpath); 43 create_database(args.inpath, args.outpath);
OLDNEW
« no previous file with comments | « tools/lua/gradients.lua ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698