| 1 | #!/usr/bin/env pike |
|---|
| 2 | |
|---|
| 3 | import .Sgf; |
|---|
| 4 | |
|---|
| 5 | int main(int argc, array(string) argv) |
|---|
| 6 | { |
|---|
| 7 | foreach (argv[1..], string filename) |
|---|
| 8 | { |
|---|
| 9 | if (!has_suffix(filename, ".sgf")) |
|---|
| 10 | { |
|---|
| 11 | werror("Not an sgf file: %s\n", filename); |
|---|
| 12 | continue; |
|---|
| 13 | } |
|---|
| 14 | string s = Stdio.read_file(filename); |
|---|
| 15 | if (!s) |
|---|
| 16 | { |
|---|
| 17 | write("Could not read file: %s\n", filename); |
|---|
| 18 | continue; |
|---|
| 19 | } |
|---|
| 20 | SgfNode sgf = parse_sgf(s); |
|---|
| 21 | for (SgfNode p = sgf; p; p = p->get_child(0)) |
|---|
| 22 | { |
|---|
| 23 | p->remove_property("CR"); |
|---|
| 24 | p->remove_property("WL"); |
|---|
| 25 | p->remove_property("BL"); |
|---|
| 26 | p->remove_property("OW"); |
|---|
| 27 | p->remove_property("OB"); |
|---|
| 28 | p->remove_property("KGSDE"); |
|---|
| 29 | p->remove_property("KGSSW"); |
|---|
| 30 | p->remove_property("KGSSB"); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | Stdio.write_file(filename + ".orig", s); |
|---|
| 34 | Stdio.write_file(filename, sgf->write() + "\n"); |
|---|
| 35 | } |
|---|
| 36 | return 0; |
|---|
| 37 | } |
|---|
| 38 | |
|---|