Opening GLE files
How to use these, and what the recovery notes mean: Opening GLE Files.
- gleplot.open_gle(path, *, base_dir=None)[source]
Open a
.glefile (or GLE source text) as a gleplotFigure.Convenience wrapper around
gleplot.parser.recognizer.parse_gle_figure()that returns just the reconstructed figure. Each recovery note (something kept as raw GLE, guessed, or converted) is raised as aUserWarningwhose text is"category: message". Useparse_gle_figuredirectly to get the notes as data instead.- Parameters:
path (str or pathlib.Path) – Path to a
.glefile, or raw GLE source text.base_dir (str or pathlib.Path, optional) – Directory for resolving relative
datareferences whenpathis raw source text.
- Return type:
- Warns:
UserWarning – One per recovery note. Python’s default warning filter shows a message it has already shown from the same line only once; use
parse_gle_figurefor the full list and each note’s line span.
- gleplot.parser.parse_gle_figure(path_or_text, *, base_dir=None)[source]
Recognize a
.gledocument into aRecognizedFigure.- Parameters:
path_or_text (str or pathlib.Path) – Either a filesystem path to a
.glefile, or the GLE source text itself. A value is treated as a path when it is apathlib.Path, or when it is astrthat names an existing file; otherwise it is treated as source text.base_dir (str or pathlib.Path, optional) – Directory used to resolve relative
datareferences whenpath_or_textis raw text (defaults to the current directory). Whenpath_or_textis a path, its parent directory is used andbase_diris ignored.
- Returns:
.figureis the reconstructed model;.noteslists the recovery notes.- Return type:
- class gleplot.parser.RecognizedFigure(figure, notes=<factory>)[source]
Result of
parse_gle_figure().- Parameters:
figure (Figure)
notes (Tuple[ImportNote, ...])
- notes
Structured recovery notes: category, message, and a source span where one can be determined.
warningsis derived from these.- Type:
tuple of ImportNote
- class gleplot.parser.ImportNote(category, message, source_span=None)[source]
One recovered ambiguity or loss from a
.gleimport.- Parameters:
category (ImportCategory)
message (str)
- category
What kind of recovery this is (see
ImportCategory).- Type:
- source_span
1-indexed, inclusive
(start_line, end_line)into the original file, when the recognizer can point at the source that produced the note.Nonewhen no single location is responsible – either the note is a whole-figure aggregate (e.g. mixedsmoothflags across every line dataset) or the underlying helper is shared by too many call sites to attribute a location without guessing. A single-line note hasstart_line == end_line.
- class gleplot.parser.ImportCategory(value)[source]
The recovery-note categories the recognizer emits.
Each member’s value is the prefix of
ImportNote.rendered(ImportCategory.DATA.value == "data"). What each category means is in the “Opening GLE Files” guide.- METADATA = 'metadata'
- STRUCTURE = 'structure'
- DATA = 'data'
- LEGEND = 'legend'
- LAYOUT = 'layout'
- SMOOTH = 'smooth'
- PROGRAMMATIC = 'programmatic'