"""Writes surfaces_mako.py: surfaces_head.py (the Mako's sets, atlases and screen UVs) + the Spearfish's surfaces body (its helper functions and the run: UV layers, the drawn screens, bakes, node dressing; models/tender-spearfish/build/surfaces_spearfish.py from '# --- UV layers' to the end, without its own screen_uvs) with the names changed. Plain python: python build/make_surfaces.py""" import os HERE = os.path.dirname(os.path.abspath(__file__)) src = open(os.path.join(HERE, "..", "..", "tender-spearfish", "build", "surfaces_spearfish.py"), encoding="utf-8").read() body = src[src.index("# ------------------------------------------------------------------ UV layers"):] a = body.index("def screen_uvs(o):") b = body.index("# ------------------------------------------------------------------ the two baked maps") body = body[:a] + body[b:] # the head's screen_uvs is used instead a = body.index("def seam_value(nt, loc_x=0):") b = body.index("def bake_atlas(") body = body[:a] + body[b:] # v03: the head's seam_value (drawn from the measured lines) is used instead a = body.index("def dress_glass(mat, tint):") b = body.index("# ------------------------------------------------------------------ run") body = body[:a] + body[b:] # v03: the head's dress_glass (light blue, as the sheet) is used instead for old, new in [("SM_Spearfish", "SM_Mako"), ('"SPEARFISH | ', '"MAKO | '), ('startswith("SPEARFISH")', 'startswith("MAKO")'), ("T_Spearfish_", "T_Mako_")]: assert old in body, old body = body.replace(old, new) assert "SPEARFISH" not in body and "Spearfish" not in body, [l for l in body.splitlines() if "SPEARFISH" in l or "Spearfish" in l] out = open(os.path.join(HERE, "surfaces_head.py"), encoding="utf-8").read() + "\n\n" + body open(os.path.join(HERE, "surfaces_mako.py"), "w", encoding="utf-8").write(out) print("written", len(out.splitlines()), "lines")