Repository navigation
Expand file tree
/
Copy pathconfig.py
More file actions
85 lines (62 loc) · 3.02 KB
/
Copy pathconfig.py
File metadata and controls
85 lines (62 loc) · 3.02 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import os
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
def _get_path(var_name, default) -> Path:
def _get():
value = os.environ.get(var_name, default)
return Path(value)
return _get
def _get_boolean(var_name, default) -> bool:
def _get():
value = os.environ.get(var_name)
return default if not value else bool(value.lower() == "true")
return _get
class SvgTextType(str, Enum):
PATH = "path"
ELEMENT = "element"
@dataclass
class Settings:
data_path: Path = field(default_factory=_get_path("STARPLOT_DATA_PATH", Path.cwd()))
"""
Path that Starplot will use for data and the DuckDB spatial extension, which is required for the data backend.
Default = current working directory
"""
svg_text_type: SvgTextType = field(
default_factory=lambda: os.environ.get(
"STARPLOT_SVG_TEXT_TYPE", SvgTextType.ELEMENT
)
)
"""
Method for rendering text in SVG exports:
- `"path"` (default) will render all text as paths. This will increase the filesize,
but allow all viewers to see the font correctly (even if they don't have the font
installed on their system).
- `"element"` will render all text as an [SVG `<text>` element](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/text),
which means the text will be editable in graphic design applications but the text may render in a system default font if the original
font isn't available.
"""
language: str = field(
default_factory=lambda: os.environ.get("STARPLOT_LANGUAGE", "en-US")
)
"""
Default language for plotted labels, as an ISO-639 code. Case insensitive.
Supported values:
- `en-us` = English (default)
- `es` = Spanish
- `fa` = Persian (Farsi). Make sure you have a Persian font installed that supports RTL (such as [Vazir](https://github.com/rastikerdar/vazir-font) or [Noto Sans Arabic](https://fonts.google.com/noto/specimen/Noto+Sans+Arabic)) and set it as the font in your plot's style.
- `fr` = French
- `it` = Italian
- `lt` = Lithuanian
- `nl` = Dutch
- `zh-cn` = Chinese. Make sure you have a good Chinese font installed (such as [Noto Sans SC](https://fonts.google.com/noto/specimen/Noto+Sans+SC)) and you'll also need to set that as the font in your plot's style.
- `zh-tw` = Traditional Chinese
**🌐 Want to see another language available? Please help us add it! [Details here](https://github.com/steveberardi/starplot/tree/main/data/raw/translations).**
"""
debug: bool = field(default_factory=_get_boolean("STARPLOT_DEBUG", False))
"""Global setting for debug mode. When this is enabled, Starplot will log debugging information and plot polygons for debugging text issues"""
precision: int = field(
default_factory=lambda: int(os.environ.get("STARPLOT_PRECISION", "4"))
)
"""Number of decimal places to round coordinates and dimensions to when rendering SVG output."""
settings = Settings()