File: __init__.py

package info (click to toggle)
python-altair 5.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,952 kB
  • sloc: python: 25,649; sh: 14; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 1,012 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
from typing import Set

# Set of the names of examples that should have SVG static images.
# This is for examples that VlConvert's PNG export does not support.
SVG_EXAMPLES: Set[str] = {"isotype_emoji"}


def iter_examples_arguments_syntax():
    """Iterate over the examples in this directory.

    Each item is a dict with the following keys:
    - "name" : the unique name of the example
    - "filename" : the full file path to the example
    - "use_svg": Flag indicating whether the static image for the
        example should be an SVG instead of a PNG
    """
    examples_arguments_syntax_dir = os.path.abspath(os.path.dirname(__file__))
    for filename in os.listdir(examples_arguments_syntax_dir):
        name, ext = os.path.splitext(filename)
        if name.startswith("_") or ext != ".py":
            continue
        yield {
            "name": name,
            "filename": os.path.join(examples_arguments_syntax_dir, filename),
            "use_svg": name in SVG_EXAMPLES
        }