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 .gle file (or GLE source text) as a gleplot Figure.

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 a UserWarning whose text is "category: message". Use parse_gle_figure directly to get the notes as data instead.

Parameters:
  • path (str or pathlib.Path) – Path to a .gle file, or raw GLE source text.

  • base_dir (str or pathlib.Path, optional) – Directory for resolving relative data references when path is raw source text.

Return type:

Figure

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_figure for the full list and each note’s line span.

gleplot.parser.parse_gle_figure(path_or_text, *, base_dir=None)[source]

Recognize a .gle document into a RecognizedFigure.

Parameters:
  • path_or_text (str or pathlib.Path) – Either a filesystem path to a .gle file, or the GLE source text itself. A value is treated as a path when it is a pathlib.Path, or when it is a str that names an existing file; otherwise it is treated as source text.

  • base_dir (str or pathlib.Path, optional) – Directory used to resolve relative data references when path_or_text is raw text (defaults to the current directory). When path_or_text is a path, its parent directory is used and base_dir is ignored.

Returns:

.figure is the reconstructed model; .notes lists the recovery notes.

Return type:

RecognizedFigure

class gleplot.parser.RecognizedFigure(figure, notes=<factory>)[source]

Result of parse_gle_figure().

Parameters:
figure

The reconstructed object model.

Type:

Figure

notes

Structured recovery notes: category, message, and a source span where one can be determined. warnings is derived from these.

Type:

tuple of ImportNote

warnings

Human-readable "category: message" strings, one per note, in the same order. Computed on each access from notes.

Type:

list of str

class gleplot.parser.ImportNote(category, message, source_span=None)[source]

One recovered ambiguity or loss from a .gle import.

Parameters:
category

What kind of recovery this is (see ImportCategory).

Type:

ImportCategory

message

Human-readable description of what was recovered and how.

Type:

str

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. None when no single location is responsible – either the note is a whole-figure aggregate (e.g. mixed smooth flags 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 has start_line == end_line.

Type:

(int, int) or None

property rendered: str

The note as a "category: message" string.

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'