1#!/usr/bin/env python3
 2
 3"""Symbols and lines used in flot and mpl plots."""
 4
 5
 6
 7from json import dumps
 8from enum import Enum
 9
10
11class LineType(Enum):
12    """Type of line style to use."""
13
14    SOLID = 'solid'
15    DOTTED = 'dotted'
16    DASHED = 'dashed'
17    NONE = 'none'
18
19LineType.SOLID.flot = '-'
20LineType.SOLID.mpl = '-'
21LineType.DOTTED.flot = '..'
22LineType.DOTTED.mpl = ':'
23LineType.DASHED.flot = '--'
24LineType.DASHED.mpl = '--'
25LineType.NONE.flot = 'none'
26LineType.NONE.mpl = ''
27
28
29def flot_lines_json():
30    """Return the JSON representation of line type dictionary."""
31    lines = {}
32    for item in LineType:
33        lines[item.value] = item.flot
34
35    return dumps(lines)
36
37
38class MarkerShape(Enum):
39    """Type of markers to use."""
40
41    CIRCLE = 'circle'
42    SQUARE = 'square'
43    DIAMOND = 'diamond'
44    TRIANGLE = 'triangle'
45    CROSS = 'cross'
46    PLUS = 'plus'
47    STAR = 'star'
48    NONE = 'none'
49
50MarkerShape.CIRCLE.flot = '\u25CB'
51MarkerShape.CIRCLE.mpl = 'o'
52MarkerShape.SQUARE.flot = '\u25A1'
53MarkerShape.SQUARE.mpl = 's'
54MarkerShape.DIAMOND.flot = '\u25C7'
55MarkerShape.DIAMOND.mpl = 'D'
56MarkerShape.TRIANGLE.flot = '\u25B3'
57MarkerShape.TRIANGLE.mpl = '^'
58MarkerShape.CROSS.flot = 'X'
59MarkerShape.CROSS.mpl = 'x'
60MarkerShape.PLUS.flot = '+'
61MarkerShape.PLUS.mpl = '+'
62MarkerShape.STAR.flot = '\u2606'
63MarkerShape.STAR.mpl = '*'
64MarkerShape.NONE.flot = 'none'
65MarkerShape.NONE.mpl = None
66
67
68def flot_markers_json():
69    """Return the JSON representation of marker shape dictionary."""
70    # return {item.name: item.value.flot for item in aaa}
71    markers = {}
72    for item in MarkerShape:
73        markers[item.value] = item.flot
74
75    return dumps(markers)