|
|
|
@ -13,6 +13,7 @@ if len(sys.argv) < 4:
|
|
|
|
|
print("Operations:")
|
|
|
|
|
print(" del_model <reg_ex_filter> Delete models with the name matching regular expression.")
|
|
|
|
|
print(" geo_name <geo_name> Rename the name of the .geo .")
|
|
|
|
|
print(" rename_model <old> <new> Rename model <old> to <new>.")
|
|
|
|
|
exit()
|
|
|
|
|
|
|
|
|
|
fn_in = sys.argv[1]
|
|
|
|
@ -26,6 +27,7 @@ geo = Geo()
|
|
|
|
|
geo.loadFromFile(fh_in)
|
|
|
|
|
fh_in.close()
|
|
|
|
|
print("Done.")
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
arg_i = 3
|
|
|
|
|
while arg_i < len(sys.argv):
|
|
|
|
@ -47,10 +49,24 @@ while arg_i < len(sys.argv):
|
|
|
|
|
arg_i += 1
|
|
|
|
|
print("Rename GEO from '%s' to '%s'" % (geo.header_modelheader_name.decode("utf-8"), name))
|
|
|
|
|
geo.header_modelheader_name = bytes(name, "utf-8")
|
|
|
|
|
elif operation == "rename_model":
|
|
|
|
|
nameold = bytes(sys.argv[arg_i], "utf-8")
|
|
|
|
|
namenew = bytes(sys.argv[arg_i+1], "utf-8")
|
|
|
|
|
arg_i += 2
|
|
|
|
|
renamed = False
|
|
|
|
|
for m in geo.models:
|
|
|
|
|
if m.name == nameold:
|
|
|
|
|
m.name = namenew
|
|
|
|
|
print("Renamed model '%s' to '%s'" % (nameold.decode("utf-8"), namenew.decode("utf-8")))
|
|
|
|
|
renamed +=1
|
|
|
|
|
break
|
|
|
|
|
if renamed <= 0:
|
|
|
|
|
print(" **Warning!*** Rename failed, no model name matched '%s'." % (nameold.decode("utf-8"), ))
|
|
|
|
|
else:
|
|
|
|
|
print("Unknown operation: '%s'" % (operation, ))
|
|
|
|
|
exit()
|
|
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
print("Writing '%s'..." % (fn_out, ))
|
|
|
|
|
fh_out = open(fn_out, "wb")
|
|
|
|
|
geo.saveToFile(fh_out)
|
|
|
|
|