GLE compiler
- class gleplot.GLECompiler(gle_path=None)[source]
Wrapper for GLE command-line compiler.
When
gle_pathis not given explicitly, the GLE executable is located viafind_gle(), which searches (in order) theGLE_PATHenvironment variable,PATH(viashutil.which()), and a set of platform-specific well-known install locations. SetGLE_PATHto pin a specific GLE binary, e.g. when multiple versions are installed.- Parameters:
gle_path (str | None)
- compile(input_file, output_format='pdf', dpi=150, verbose=False, timeout=30, cairo=False, transparent=False, grayscale=False)[source]
Compile GLE file to output format.
- Parameters:
input_file (str) – Path to .gle input file
output_format ({'pdf', 'png', 'eps', 'jpg', 'svg'}) – Output format
dpi (int) – DPI for raster formats (png, jpg)
verbose (bool) – Log GLE’s output (stdout and stderr) to the
gleplot.compilerlogger atINFOlevel. Nothing reaches the console unless logging is configured, e.g.logging.basicConfig(level="INFO"). On failure the output is in the raisedGLECompileErrorwhether or not this is set.timeout (int) – Maximum number of seconds to allow the GLE process to run.
cairo (bool) – Whether to pass GLE’s
-cairodevice flag (SPEC §6.1/§10.6). Required for any script using semi-transparency (anrgba(...)/rgba255(...)colour – e.g. afill_betweenwithalpha < 1); without it GLE fails outright on such a script (semi-transparency only supported with command line option '-cairo'). This method has noFigureto inspect, so it never decides this for you –cairois an explicit, caller-supplied override.gleplot.figure.Figure.savefig()is the caller that does have the figure and passesfigure.requires_cairo()here automatically; pass an explicitTrue/Falseyourself when compiling a.glefile this compiler didn’t write (or to force the flag either way). Ansvgalways gets the flag (seebuild_compile_args()).transparent (bool) – Give a PNG an alpha channel instead of a white background (GLE’s
-transparent); seebuild_compile_args()for the other formats and for a grayscale PNG.grayscale (bool) – Convert the colours GLE draws to their grey level (GLE’s
-nocolor); seebuild_compile_args()for colormap images.
- Returns:
Path to output file
- Return type:
Path
- Raises:
FileNotFoundError – If the input file does not exist.
GLECompileError – If compilation fails (nonzero exit code, or the expected output file was not produced). Carries structured
errorsand theraw_outputfrom the GLE process. When the failure is anincludefile GLE cannot find, the message names the file and points to installing GLE’s include library.