#!/usr/bin/python3
import getopt, sys, urllib, time
import os,platform
def extract_animation(fname):
ofile = fname + ".txt"
bWritable = False;
try:
f0 = open(fname, 'r')
f1 = open(ofile, 'w')
for line in f0:
ana = line[1:10]
brk = line[0:1]
if(ana == "animation"):
bWritable = True
line=line[14:]
if(bWritable):
f1.write(line);
if(brk == "}"):
bWritable = False
except IOError:
print("exception occurred")
f0.close()
f1.close()
def main(argv):
ll = len(argv)
name, ext = os.path.splitext(argv[0])
# print(name, "-----", ext)
for ifile in argv[1:]:
extract_animation(ifile)
ofname = name + "_" + "merge" + ".js"
bMergable = False
bAnimation = False
try:
f0 = open(argv[0], 'r')
f1 = open(ofname, 'w')
for line in f0:
ana = line[1:10]
first = line[0:1]
if(ana == "animation"):
line0 = "\"animations\" : "
line1 = line[14:]
line = line0 + "[" + line1
bAnimation = True
if(bAnimation):
if(first == "}"):
f1.write("}")
for item in argv[1:]:
f1.write(",");
ifile = item + ".txt"
try:
ff = open(ifile, 'r')
for rr in ff:
f1.write(rr)
except IOError:
print("exception occurred")
os.remove(ifile)
f1.write("]")
bAnimation = False
else:
f1.write(line)
else:
f1.write(line)
f0.close()
f1.close()
except IOError:
print("exception occurred")
#-------------------------------
if __name__ == "__main__":
platform_arch=platform.architecture()
platform_system=platform.system()
platform_version=platform.version()
platform_machine=platform.machine()
platform_dist=platform.dist()
platform_node=platform.node()
platform_uname=platform.uname()
platform_python_version=platform.python_version()
codename = sys.getdefaultencoding()
print("codename = [%s]\n" %(codename))
print("arch = [%s %s]\n" %(platform_arch))
print("system = [%s]\n" %(platform_system))
print("version = [%s]\n" %(platform_version))
print("machine = [%s]\n" %(platform_machine))
print("dist = [%s %s %s]\n" %(platform_dist))
print("node = [%s]\n" %(platform_node))
print("uname = [%s %s %s %s %s %s]\n" %(platform_uname))
print("python_version = [%s]\n" %(platform_python_version))
main(sys.argv[1:])
# extract_animation('t0.js')