2
# -*- coding: utf-8 -*-
4
# ***** BEGIN GPL LICENSE BLOCK *****
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software Foundation,
18
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
# The Original Code is Copyright (C) 2009 Blender Foundation.
21
# All rights reserved.
23
# Contributor(s): Campbell Barton
25
# ***** END GPL LICENCE BLOCK *****
33
sys.stdout.write("Usage: ctodata <c_file>\n")
36
filename = sys.argv[1]
39
fpin = open(filename, "r")
41
sys.stdout.write("Unable to open input %s\n" % sys.argv[1])
44
data = fpin.read().rsplit("{")[-1].split("}")[0]
45
data = data.replace(",", " ")
47
data = [int(v) for v in data]
48
# for some reason all data gets trailing byte
53
dname = filename + ".ctodata"
55
sys.stdout.write("Making DATA file <%s>\n" % dname)
58
fpout = open(dname, "wb")
60
sys.stdout.write("Unable to open output %s\n" % dname)
63
size = fpout.write(data)
65
sys.stdout.write("%d\n" % size)