Freeciv - Copyright (C) 2009 - Andreas Røsdal [email protected] This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ''' import generate_packets packets = generate_packets.gen_main(); f = open('packhand_gen.js', 'w'); f.write(""" /* Generated by generate_js_hand.py */ function client_handle_packet(p) { if (p == null) return; try { for (var i = 0; i < p.length; i++) { if (p[i] == null) continue; var packet_type = p[i]['pid']; switch (packet_type) { """); for packet in packets.values():
help='path to (original) freeciv project') parser.add_argument('-o', '--outdir', required=True, help='path to webapp output directory') args = parser.parse_args() webapp_dir = args.outdir freeciv_dir = args.freeciv javascript_dir = path.join(webapp_dir, 'javascript') if not path.isdir(javascript_dir): sys.exit('Destination javascript directory does not exist: ' + javascript_dir) packets = generate_packets.gen_main(freeciv_dir) output_name = path.join(javascript_dir, 'packhand_gen.js') f = open(output_name, 'w') f.write(""" /* Generated by generate_js_hand.py */ function client_handle_packet(p) { if (p == null) return; try { for (var i = 0; i < p.length; i++) { if (p[i] == null) continue; var packet_type = p[i]['pid']; switch (packet_type) { """)