Sat, 31 Mar 2012 22:13:32 +0100
parse.lua: Update for gsoc12.csv, and *hack* the code to work with the new format
0 | 1 | local http = require "socket.http" |
2 | local have_https, https = pcall(require,"https"); | |
3 | local csv = require "csv" | |
4 | ||
2
5c9d6eba65bc
parse.lua: Update for gsoc12.csv, and *hack* the code to work with the new format
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
5 | for line in io.lines(arg[1] or "gsoc12.csv") do |
0 | 6 | local project = {}; |
7 | csv.read_record(line, function (v) project[#project+1] = v; end); | |
2
5c9d6eba65bc
parse.lua: Update for gsoc12.csv, and *hack* the code to work with the new format
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
8 | -- FIXME: The original code doesn't work this year, |
5c9d6eba65bc
parse.lua: Update for gsoc12.csv, and *hack* the code to work with the new format
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
9 | -- I think csv.lua doesn't handle quoted values |
5c9d6eba65bc
parse.lua: Update for gsoc12.csv, and *hack* the code to work with the new format
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
10 | -- (ie. the 'Tags' column) properly. |
5c9d6eba65bc
parse.lua: Update for gsoc12.csv, and *hack* the code to work with the new format
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
11 | --local url = project[5]:match("https?://[^\"]+"); |
5c9d6eba65bc
parse.lua: Update for gsoc12.csv, and *hack* the code to work with the new format
Matthew Wild <mwild1@gmail.com>
parents:
0
diff
changeset
|
12 | local url = line:match(",([^,]+)$"); |
0 | 13 | if url and url:match("^http"..(have_https and "s?" or "")..":") then |
14 | local data, err = http.request(url); | |
15 | if not data then | |
16 | print("[FAIL] "..project[2]..": "..tostring(err)); | |
17 | elseif data:match("[%W%p][Ll][Uu][Aa][%W%p]") then | |
18 | print(project[2]..": "..url); | |
19 | end | |
20 | elseif project[2] ~= "Name" then | |
21 | print("[FAIL] "..project[2]..": Couldn't fetch URL ("..(url or "couldn't find one")..")"); | |
22 | end | |
23 | end |