MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _parse_cycler_string

Function _parse_cycler_string

lib/matplotlib/rcsetup.py:818–834  ·  view source on GitHub ↗

Parse a string representation of a cycler into a Cycler object safely, without using eval(). Accepts expressions like:: cycler('color', ['r', 'g', 'b']) cycler('color', 'rgb') + cycler('linewidth', [1, 2, 3]) cycler(c='rgb', lw=[1, 2, 3]) cycler('c', 'r

(s)

Source from the content-addressed store, hash-verified

816
817
818def _parse_cycler_string(s):
819 """
820 Parse a string representation of a cycler into a Cycler object safely,
821 without using eval().
822
823 Accepts expressions like::
824
825 cycler('color', ['r', 'g', 'b'])
826 cycler('color', 'rgb') + cycler('linewidth', [1, 2, 3])
827 cycler(c='rgb', lw=[1, 2, 3])
828 cycler('c', 'rgb') * cycler('linestyle', ['-', '--'])
829 """
830 try:
831 tree = ast.parse(s, mode='eval')
832 except SyntaxError as e:
833 raise ValueError(f"Could not parse {s!r}: {e}") from e
834 return _eval_cycler_expr(tree.body)
835
836
837def _eval_cycler_expr(node):

Callers 1

validate_cyclerFunction · 0.85

Calls 2

_eval_cycler_exprFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…