Skip to content

Commit 129b3bf

Browse files
authored
Attempt to read tex_template from config file if needed (#505)
* Attempt to read tex_template from config file if not present in command line arguments. * Updated changelog to mention that is read from config. * Small improvement when `tex_template` is empty in config file where it is interpreted as `None` instead of an empty string. * Added default `tex_template` entry to default.cfg (None). * Updated changelog.rst to better reflect the changes in the previous two commits.
1 parent 043cc53 commit 129b3bf

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

docs/source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Command line
3030
#. Re-implement GIF export with the :code:`-i` flag (using this flag outputs ONLY a .gif file, and no .mp4 file)
3131
#. Added a :code:`--verbose` flag
3232
#. You can save the logs to a file by using :code:`--log_to_file`
33+
#. Read :code:`tex_template` from config file if not specified by :code:`--tex_template`.
3334
#. Add experimental javascript rendering with :code:`--use_js_renderer`
3435
#. Add :code:`-q/--quality [k|h|m|l]` flag and removed :code:`-m/-l` flags.
3536
#. Removed :code:`--sound` flag

manim/config/config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ def _parse_config(config_parser, args):
135135
config["left_side"] = config["frame_x_radius"] * constants.LEFT
136136
config["right_side"] = config["frame_x_radius"] * constants.RIGHT
137137

138-
# Handle the --tex_template flag. Note we accept None if the flag is absent
139-
tex_fn = os.path.expanduser(args.tex_template) if args.tex_template else None
138+
# Handle the --tex_template flag, if the flag is absent read it from the config.
139+
if args.tex_template:
140+
tex_fn = os.path.expanduser(args.tex_template)
141+
else:
142+
tex_fn = default["tex_template"] if default["tex_template"] != "" else None
140143

141144
if tex_fn is not None and not os.access(tex_fn, os.R_OK):
142145
# custom template not available, fallback to default

manim/config/default.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ max_files_cached = 100
108108
flush_cache = False
109109
disable_caching = False
110110

111+
# Default tex_template
112+
# --tex_template
113+
tex_template =
114+
111115
# These override the previous by using -t, --transparent
112116
[transparent]
113117
png_mode = RGBA

0 commit comments

Comments
 (0)