mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Have -e write over original source file, then correct
This commit is contained in:
parent
0fd8491c51
commit
d733687834
1 changed files with 7 additions and 7 deletions
|
@ -243,15 +243,15 @@ def insert_embed_line(file_name: str, scene_name: str, line_marker: str):
|
|||
# Insert and write new file
|
||||
if n_spaces is None:
|
||||
n_spaces = get_indent(lines[prev_line_num])
|
||||
lines.insert(prev_line_num + 1, " " * n_spaces + "self.embed()\n")
|
||||
alt_file = file_name.replace(".py", "_inserted_embed.py")
|
||||
with open(alt_file, 'w') as fp:
|
||||
fp.writelines(lines)
|
||||
|
||||
new_lines = list(lines)
|
||||
new_lines.insert(prev_line_num + 1, " " * n_spaces + "self.embed()\n")
|
||||
with open(file_name, 'w') as fp:
|
||||
fp.writelines(new_lines)
|
||||
try:
|
||||
yield alt_file
|
||||
yield file_name
|
||||
finally:
|
||||
os.remove(alt_file)
|
||||
with open(file_name, 'w') as fp:
|
||||
fp.writelines(lines)
|
||||
|
||||
|
||||
def get_custom_config():
|
||||
|
|
Loading…
Add table
Reference in a new issue