robotframework-locust 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. LocustLibrary/__init__.py +143 -0
  2. LocustLibrary/builder.py +169 -0
  3. LocustLibrary/calllog.py +115 -0
  4. LocustLibrary/checks.py +122 -0
  5. LocustLibrary/distributed.py +52 -0
  6. LocustLibrary/feed.py +61 -0
  7. LocustLibrary/k6/__init__.py +1 -0
  8. LocustLibrary/k6/cli.py +66 -0
  9. LocustLibrary/k6/emit.py +69 -0
  10. LocustLibrary/k6/options.py +128 -0
  11. LocustLibrary/k6/profile.py +130 -0
  12. LocustLibrary/k6/robot_files.py +127 -0
  13. LocustLibrary/k6/scan.py +195 -0
  14. LocustLibrary/parsing.py +80 -0
  15. LocustLibrary/reporting.py +108 -0
  16. LocustLibrary/runner.py +135 -0
  17. LocustLibrary/scenario.py +102 -0
  18. LocustLibrary/shape.py +33 -0
  19. LocustLibrary/shared.py +28 -0
  20. LocustLibrary/stats.py +81 -0
  21. LocustLibrary/stoprules.py +93 -0
  22. LocustLibrary/studio/__init__.py +3 -0
  23. LocustLibrary/studio/app.py +170 -0
  24. LocustLibrary/studio/build_tab.py +73 -0
  25. LocustLibrary/studio/fonts/Inter-Medium.ttf +0 -0
  26. LocustLibrary/studio/fonts/Inter-OFL.txt +92 -0
  27. LocustLibrary/studio/fonts/Inter-Regular.ttf +0 -0
  28. LocustLibrary/studio/fonts/Inter-SemiBold.ttf +0 -0
  29. LocustLibrary/studio/fonts/JetBrainsMono-Medium.ttf +0 -0
  30. LocustLibrary/studio/fonts/JetBrainsMono-OFL.txt +93 -0
  31. LocustLibrary/studio/fonts/JetBrainsMono-Regular.ttf +0 -0
  32. LocustLibrary/studio/fonts.py +17 -0
  33. LocustLibrary/studio/live.py +131 -0
  34. LocustLibrary/studio/panels.py +139 -0
  35. LocustLibrary/studio/report_tab.py +50 -0
  36. LocustLibrary/studio/run_tab.py +187 -0
  37. LocustLibrary/studio/sidebar.py +82 -0
  38. LocustLibrary/studio/themes.py +83 -0
  39. LocustLibrary/studio/worker.py +39 -0
  40. LocustLibrary/suiteplan.py +76 -0
  41. LocustLibrary/users.py +153 -0
  42. LocustLibrary/validation.py +55 -0
  43. LocustLibrary/webui.py +32 -0
  44. robotframework_locust-1.0.1.dist-info/METADATA +178 -0
  45. robotframework_locust-1.0.1.dist-info/RECORD +49 -0
  46. robotframework_locust-1.0.1.dist-info/WHEEL +5 -0
  47. robotframework_locust-1.0.1.dist-info/entry_points.txt +3 -0
  48. robotframework_locust-1.0.1.dist-info/licenses/LICENSE +21 -0
  49. robotframework_locust-1.0.1.dist-info/top_level.txt +1 -0
LocustLibrary/stats.py ADDED
@@ -0,0 +1,81 @@
1
+ """Stats parsing for LocustLibrary."""
2
+
3
+ import csv
4
+ from pathlib import Path
5
+ from typing import Any
6
+
7
+ from .scenario import Stats, StatsRow
8
+
9
+
10
+ def parse_stats_csv(path: str | Path) -> Stats:
11
+ """Parse a Locust stats CSV file into a Stats object."""
12
+ stats = Stats()
13
+ with open(path, newline="", encoding="utf-8") as f:
14
+ reader = csv.DictReader(f)
15
+ for row in reader:
16
+ name = row.get("Name", "").strip()
17
+ task_type = (row.get("Type") or "").strip()
18
+ if name == "Aggregated":
19
+ name = "Aggregated"
20
+ sr = StatsRow(
21
+ name=name if name else task_type,
22
+ request_count=int(float(row.get("Request Count", 0) or 0)),
23
+ failure_count=int(float(row.get("Failure Count", 0) or 0)),
24
+ median=float(row.get("Median Response Time", 0) or 0),
25
+ average=float(row.get("Average Response Time", 0) or 0),
26
+ min=float(row.get("Min Response Time", 0) or 0),
27
+ max=float(row.get("Max Response Time", 0) or 0),
28
+ rps=float(row.get("Requests/s", 0) or 0),
29
+ failures_s=float(row.get("Failures/s", 0) or 0),
30
+ p50=float(row.get("50%", 0) or 0),
31
+ p90=float(row.get("90%", 0) or 0),
32
+ p95=float(row.get("95%", 0) or 0),
33
+ p99=float(row.get("99%", 0) or 0),
34
+ p999=float(row.get("99.9%", 0) or 0),
35
+ )
36
+ if name == "Aggregated":
37
+ stats.aggregated = sr
38
+ else:
39
+ stats.rows.append(sr)
40
+ if stats.aggregated and stats.aggregated.request_count:
41
+ stats.fail_ratio = stats.aggregated.failure_count / stats.aggregated.request_count
42
+ return stats
43
+
44
+
45
+ def _pct(entry: object, quantile: float) -> float:
46
+ reader = getattr(entry, "get_response_time_percentile", None)
47
+ if reader is None:
48
+ return 0.0
49
+ return float(reader(quantile))
50
+
51
+
52
+ def _row_from_entry(name: str, entry: object) -> StatsRow:
53
+ return StatsRow(
54
+ name=name,
55
+ request_count=int(getattr(entry, "num_requests", 0)),
56
+ failure_count=int(getattr(entry, "num_failures", 0)),
57
+ median=float(getattr(entry, "median_response_time", 0.0)),
58
+ average=float(getattr(entry, "avg_response_time", 0.0)),
59
+ # Locust keeps no minimum until the first request lands.
60
+ min=float(getattr(entry, "min_response_time", 0.0) or 0.0),
61
+ max=float(getattr(entry, "max_response_time", 0.0)),
62
+ rps=float(getattr(entry, "total_rps", 0.0)),
63
+ failures_s=float(getattr(entry, "total_fail_per_sec", 0.0)),
64
+ p50=_pct(entry, 0.5),
65
+ p90=_pct(entry, 0.9),
66
+ p95=_pct(entry, 0.95),
67
+ p99=_pct(entry, 0.99),
68
+ p999=_pct(entry, 0.999),
69
+ )
70
+
71
+
72
+ def _stats_from_env(env: Any) -> Stats:
73
+ stats = Stats()
74
+ rs = env.stats
75
+ for (name, _method), entry in (rs.entries or {}).items():
76
+ stats.rows.append(_row_from_entry(name if name else "/", entry))
77
+ stats.aggregated = _row_from_entry("Aggregated", rs.total)
78
+ if stats.aggregated.request_count:
79
+ counted = stats.aggregated
80
+ stats.fail_ratio = counted.failure_count / counted.request_count
81
+ return stats
@@ -0,0 +1,93 @@
1
+ """Stop rules: end a run once a measured value stays past its limit for a whole window.
2
+
3
+ The rule text follows Taurus pass/fail criteria, for example `p95 > 1s for 10s, stop as failed`.
4
+ """
5
+
6
+ import fnmatch
7
+ import re
8
+ from dataclasses import dataclass
9
+ from typing import Any
10
+
11
+ import psutil
12
+
13
+ _RULE = re.compile(
14
+ r"^\s*(?P<metric>p\d+(?:\.\d+)?|fail|rc[\d?*]{1,3}|cpu|mem)\s*>\s*(?P<limit>\d+(?:\.\d+)?)"
15
+ r"\s*(?P<unit>ms|s|%)?\s*(?:for\s+(?P<window>\d+(?:\.\d+)?)s)?"
16
+ r"\s*(?:,\s*stop\s+as\s+(?P<status>failed|passed))?\s*$")
17
+
18
+
19
+ @dataclass
20
+ class StopRule:
21
+ metric: str
22
+ limit: float
23
+ window: float
24
+ fail_run: bool
25
+ text: str
26
+
27
+
28
+ def parse_rule(text: str) -> StopRule:
29
+ found = _RULE.match(text)
30
+ timed = bool(found and found["metric"].startswith("p"))
31
+ if not found or (found["unit"] == "%") == timed:
32
+ raise ValueError(f"Stop rule '{text}' is not like 'p95 > 1s for 10s, stop as failed'; "
33
+ "metrics: pN, fail, rcNNN, cpu, mem")
34
+ limit = float(found["limit"]) * (1000 if found["unit"] == "s" else 1)
35
+ return StopRule(found["metric"], limit, float(found["window"] or 0),
36
+ found["status"] != "passed", text.strip())
37
+
38
+
39
+ class RuleWatch:
40
+ """Checks every rule on each tick; the first rule that held for its window names the stop."""
41
+
42
+ def __init__(self, rules: list[StopRule], local: Any) -> None:
43
+ self.rules, self.local, self.failed = rules, local, False
44
+ self._since: dict[int, float] = {}
45
+ self._codes: list[int] = []
46
+ self._seen = {"codes": 0, "requests": 0, "failures": 0}
47
+ if any(rule.metric.startswith("rc") for rule in rules):
48
+ local.environment.events.request.add_listener(self._record)
49
+
50
+ def _record(self, response: Any = None, **_kwargs: Any) -> None:
51
+ code = getattr(response, "status_code", None)
52
+ if code is not None:
53
+ self._codes.append(int(code))
54
+
55
+ def check(self, elapsed: float) -> str:
56
+ values = self._measure()
57
+ for index, rule in enumerate(self.rules):
58
+ value = values.get(rule.metric)
59
+ if value is None:
60
+ # A tick with no responses says nothing, so the window neither grows nor restarts.
61
+ continue
62
+ if value <= rule.limit:
63
+ self._since.pop(index, None)
64
+ continue
65
+ start = self._since.setdefault(index, elapsed)
66
+ if elapsed - start >= rule.window:
67
+ self.failed = rule.fail_run
68
+ return f"stopped after {elapsed:.0f} s: {rule.text}"
69
+ return ""
70
+
71
+ def _measure(self) -> dict[str, float | None]:
72
+ needs_fail = any(rule.metric == "fail" for rule in self.rules)
73
+ values: dict[str, float | None] = {"fail": self._fail_share()} if needs_fail else {}
74
+ codes, self._seen["codes"] = self._codes[self._seen["codes"]:], len(self._codes)
75
+ for rule in self.rules:
76
+ if rule.metric.startswith("p"):
77
+ share = float(rule.metric[1:]) / 100
78
+ values[rule.metric] = self.local.stats.total.get_current_response_time_percentile(share)
79
+ elif rule.metric.startswith("rc") and codes:
80
+ hits = sum(fnmatch.fnmatch(str(code), rule.metric[2:]) for code in codes)
81
+ values[rule.metric] = 100 * hits / len(codes)
82
+ elif rule.metric == "cpu":
83
+ values["cpu"] = psutil.cpu_percent()
84
+ elif rule.metric == "mem":
85
+ values["mem"] = psutil.virtual_memory().percent
86
+ return values
87
+
88
+ def _fail_share(self) -> float | None:
89
+ total = self.local.stats.total
90
+ requests = total.num_requests - self._seen["requests"]
91
+ failures = total.num_failures - self._seen["failures"]
92
+ self._seen["requests"], self._seen["failures"] = total.num_requests, total.num_failures
93
+ return 100 * failures / requests if requests else None
@@ -0,0 +1,3 @@
1
+ """Optional PySide studio GUI for LocustLibrary."""
2
+
3
+ __all__ = ["main"]
@@ -0,0 +1,170 @@
1
+ """Main studio application window."""
2
+
3
+ import sys
4
+ from typing import Any
5
+
6
+ try:
7
+ from PySide6.QtCore import Qt
8
+ from PySide6.QtGui import QKeySequence, QShortcut, QTextCursor
9
+ from PySide6.QtWidgets import (
10
+ QApplication,
11
+ QCheckBox,
12
+ QComboBox,
13
+ QFormLayout,
14
+ QHBoxLayout,
15
+ QLabel,
16
+ QMainWindow,
17
+ QSplitter,
18
+ QStackedWidget,
19
+ QTabBar,
20
+ QTextEdit,
21
+ QVBoxLayout,
22
+ QWidget,
23
+ )
24
+ except ImportError as exc: # pragma: no cover
25
+ raise SystemExit("PySide6 required for studio") from exc
26
+
27
+ from .build_tab import BuildTab
28
+ from .fonts import load_fonts
29
+ from .panels import set_table_colors
30
+ from .report_tab import ReportTab
31
+ from .run_tab import RunTab
32
+ from .sidebar import Sidebar
33
+ from .themes import THEMES, get_theme
34
+
35
+
36
+ class MainWindow(QMainWindow): # type: ignore[misc]
37
+ def __init__(self) -> None:
38
+ super().__init__()
39
+ self.setWindowTitle("robotframework-locust studio")
40
+ self.resize(1440, 900)
41
+ self.setMinimumSize(900, 600)
42
+ load_fonts()
43
+ self._theme_name = "graphite"
44
+ self.build_tab = BuildTab()
45
+ self.run_tab = RunTab(self.build_tab.scenario)
46
+ self.report_tab = ReportTab()
47
+ self.sidebar = Sidebar()
48
+ self.pages = QStackedWidget()
49
+ self.tabs = QTabBar()
50
+ self.tabs.setDrawBase(False)
51
+ self.tabs.setAccessibleName("Sections")
52
+ for page, title in ((self.build_tab, "Build"), (self.run_tab, "Run"),
53
+ (self.report_tab, "Report"), (self._make_settings_tab(), "Settings")):
54
+ self.pages.addWidget(page)
55
+ self.tabs.addTab(title)
56
+ self.tabs.currentChanged.connect(self.pages.setCurrentIndex)
57
+ splitter = QSplitter(Qt.Horizontal)
58
+ splitter.setHandleWidth(1)
59
+ splitter.addWidget(self.sidebar)
60
+ splitter.addWidget(self.pages)
61
+ splitter.addWidget(self._make_right_panel())
62
+ splitter.setSizes([210, 1000, 260])
63
+ central = QWidget()
64
+ lay = QVBoxLayout(central)
65
+ lay.setContentsMargins(0, 0, 0, 0)
66
+ lay.setSpacing(0)
67
+ lay.addWidget(self._make_header())
68
+ lay.addWidget(splitter, 1)
69
+ self.setCentralWidget(central)
70
+ self._connect()
71
+ self.apply_theme(self._theme_name)
72
+
73
+ def _connect(self) -> None:
74
+ self.sidebar.suite_opened.connect(self.run_tab.set_suite)
75
+ self.run_tab.console.connect(self._append_log)
76
+ self.run_tab.final.connect(self.report_tab.show_final)
77
+ self.run_tab.outputs.connect(self.report_tab.set_outputs)
78
+ for keys, action in (("Ctrl+R", self.run_tab.run), ("Ctrl+O", self.sidebar.choose_suite),
79
+ ("Ctrl+,", lambda: self.tabs.setCurrentIndex(3))):
80
+ QShortcut(QKeySequence(keys), self).activated.connect(action)
81
+
82
+ def apply_theme(self, name: str) -> None:
83
+ self._theme_name = name
84
+ theme = get_theme(name)
85
+ self.setStyleSheet(theme["qss"])
86
+ for table in (self.run_tab.stats_table, self.report_tab.table):
87
+ set_table_colors(table, theme["colors"])
88
+ self.run_tab.charts.set_colors(theme["colors"])
89
+
90
+ def _make_header(self) -> Any:
91
+ header = QWidget()
92
+ header.setObjectName("header")
93
+ row = QHBoxLayout(header)
94
+ row.setContentsMargins(12, 8, 12, 8)
95
+ row.setSpacing(12)
96
+ name = QLabel("Locust Studio")
97
+ name.setObjectName("title")
98
+ track = QWidget()
99
+ track.setObjectName("track")
100
+ track_row = QHBoxLayout(track)
101
+ track_row.setContentsMargins(2, 2, 2, 2)
102
+ track_row.addWidget(self.tabs)
103
+ for widget in (name, track):
104
+ row.addWidget(widget)
105
+ row.addStretch(1)
106
+ for widget in (self.run_tab.status_label, self.run_tab.stop_btn, self.run_tab.run_btn):
107
+ row.addWidget(widget)
108
+ return header
109
+
110
+ def _toggle_rtl(self, checked: bool) -> None:
111
+ QApplication.instance().setLayoutDirection(
112
+ Qt.RightToLeft if checked else Qt.LeftToRight
113
+ )
114
+
115
+ def resizeEvent(self, event: object) -> None:
116
+ super().resizeEvent(event)
117
+ if hasattr(self, "sidebar"):
118
+ self.sidebar.setVisible(self.width() >= 1000)
119
+
120
+ def _make_right_panel(self) -> Any:
121
+ w = QWidget()
122
+ w.setObjectName("pane")
123
+ lay = QVBoxLayout(w)
124
+ lay.setContentsMargins(12, 12, 12, 12)
125
+ title = QLabel("Live log")
126
+ title.setObjectName("label")
127
+ lay.addWidget(title)
128
+ self.log_text = QTextEdit()
129
+ self.log_text.setObjectName("console")
130
+ self.log_text.setReadOnly(True)
131
+ self.log_text.setAccessibleName("Live log")
132
+ self.log_text.setLineWrapMode(QTextEdit.LineWrapMode.NoWrap)
133
+ lay.addWidget(self.log_text)
134
+ return w
135
+
136
+ def _append_log(self, text: str) -> None:
137
+ self.log_text.moveCursor(QTextCursor.End)
138
+ self.log_text.insertPlainText(text)
139
+ self.log_text.ensureCursorVisible()
140
+ self.log_text.horizontalScrollBar().setValue(0)
141
+
142
+ def _make_settings_tab(self) -> Any:
143
+ w = QWidget()
144
+ lay = QVBoxLayout(w)
145
+ form = QFormLayout()
146
+ self.theme_combo = QComboBox()
147
+ self.theme_combo.setAccessibleName("Theme")
148
+ for k, v in THEMES.items():
149
+ self.theme_combo.addItem(v["name"], k)
150
+ self.theme_combo.currentIndexChanged.connect(
151
+ lambda: self.apply_theme(self.theme_combo.currentData())
152
+ )
153
+ form.addRow("Theme", self.theme_combo)
154
+ self.rtl_check = QCheckBox("Right-to-left layout")
155
+ self.rtl_check.toggled.connect(self._toggle_rtl)
156
+ form.addRow(self.rtl_check)
157
+ lay.addLayout(form)
158
+ lay.addStretch()
159
+ return w
160
+
161
+
162
+ def main() -> None:
163
+ app = QApplication(sys.argv)
164
+ win = MainWindow()
165
+ win.show()
166
+ sys.exit(app.exec())
167
+
168
+
169
+ if __name__ == "__main__":
170
+ main()
@@ -0,0 +1,73 @@
1
+ """Build tab: HTTP tasks put together by hand, run when no suite is open."""
2
+
3
+ from typing import Any
4
+
5
+ from PySide6.QtWidgets import (
6
+ QComboBox,
7
+ QFormLayout,
8
+ QHBoxLayout,
9
+ QLabel,
10
+ QLineEdit,
11
+ QListWidget,
12
+ QPushButton,
13
+ QSpinBox,
14
+ QVBoxLayout,
15
+ QWidget,
16
+ )
17
+
18
+
19
+ class BuildTab(QWidget): # type: ignore[misc]
20
+ def __init__(self) -> None:
21
+ super().__init__()
22
+ self.tasks: list[dict[str, Any]] = []
23
+ lay = QVBoxLayout(self)
24
+ lay.setContentsMargins(12, 12, 12, 12)
25
+ form = QFormLayout()
26
+ self.host_edit = QLineEdit("http://127.0.0.1:8765")
27
+ self.host_edit.setAccessibleName("Host URL")
28
+ self.wait_min_edit = QLineEdit("0.1s")
29
+ self.wait_max_edit = QLineEdit("0.5s")
30
+ form.addRow("Host", self.host_edit)
31
+ form.addRow("Wait min", self.wait_min_edit)
32
+ form.addRow("Wait max", self.wait_max_edit)
33
+ lay.addLayout(form)
34
+ self.task_list = QListWidget()
35
+ self.task_list.setAccessibleName("Task list")
36
+ lay.addWidget(QLabel("Tasks"))
37
+ self.empty_tasks_label = QLabel("No tasks yet. Add one below.")
38
+ lay.addWidget(self.empty_tasks_label)
39
+ lay.addWidget(self.task_list)
40
+ lay.addLayout(self._task_row())
41
+
42
+ def _task_row(self) -> QHBoxLayout:
43
+ row = QHBoxLayout()
44
+ self.task_name = QLineEdit("Get Home")
45
+ self.task_name.setAccessibleName("Task name")
46
+ self.task_path = QLineEdit("/")
47
+ self.task_path.setAccessibleName("Task path")
48
+ self.task_method = QComboBox()
49
+ self.task_method.addItems(["GET", "POST"])
50
+ self.task_weight = QSpinBox()
51
+ self.task_weight.setValue(1)
52
+ add_btn = QPushButton("Add task")
53
+ add_btn.setAccessibleName("Add task")
54
+ add_btn.clicked.connect(self._add_task)
55
+ for widget in (self.task_name, self.task_method, self.task_path, QLabel("w"), self.task_weight,
56
+ add_btn):
57
+ row.addWidget(widget)
58
+ return row
59
+
60
+ def _add_task(self) -> None:
61
+ t = {
62
+ "name": self.task_name.text(),
63
+ "method": self.task_method.currentText(),
64
+ "path": self.task_path.text(),
65
+ "weight": self.task_weight.value(),
66
+ }
67
+ self.tasks.append(t)
68
+ self.task_list.addItem(f"{t['method']} {t['path']} (w{t['weight']}) - {t['name']}")
69
+ self.empty_tasks_label.hide()
70
+
71
+ def scenario(self) -> dict[str, Any]:
72
+ return {"host": self.host_edit.text(), "wait_min": self.wait_min_edit.text(),
73
+ "wait_max": self.wait_max_edit.text(), "tasks": list(self.tasks)}
@@ -0,0 +1,92 @@
1
+ Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+ -----------------------------------------------------------
8
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9
+ -----------------------------------------------------------
10
+
11
+ PREAMBLE
12
+ The goals of the Open Font License (OFL) are to stimulate worldwide
13
+ development of collaborative font projects, to support the font creation
14
+ efforts of academic and linguistic communities, and to provide a free and
15
+ open framework in which fonts may be shared and improved in partnership
16
+ with others.
17
+
18
+ The OFL allows the licensed fonts to be used, studied, modified and
19
+ redistributed freely as long as they are not sold by themselves. The
20
+ fonts, including any derivative works, can be bundled, embedded,
21
+ redistributed and/or sold with any software provided that any reserved
22
+ names are not used by derivative works. The fonts and derivatives,
23
+ however, cannot be released under any other type of license. The
24
+ requirement for fonts to remain under this license does not apply
25
+ to any document created using the fonts or their derivatives.
26
+
27
+ DEFINITIONS
28
+ "Font Software" refers to the set of files released by the Copyright
29
+ Holder(s) under this license and clearly marked as such. This may
30
+ include source files, build scripts and documentation.
31
+
32
+ "Reserved Font Name" refers to any names specified as such after the
33
+ copyright statement(s).
34
+
35
+ "Original Version" refers to the collection of Font Software components as
36
+ distributed by the Copyright Holder(s).
37
+
38
+ "Modified Version" refers to any derivative made by adding to, deleting,
39
+ or substituting -- in part or in whole -- any of the components of the
40
+ Original Version, by changing formats or by porting the Font Software to a
41
+ new environment.
42
+
43
+ "Author" refers to any designer, engineer, programmer, technical
44
+ writer or other person who contributed to the Font Software.
45
+
46
+ PERMISSION AND CONDITIONS
47
+ Permission is hereby granted, free of charge, to any person obtaining
48
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
49
+ redistribute, and sell modified and unmodified copies of the Font
50
+ Software, subject to the following conditions:
51
+
52
+ 1) Neither the Font Software nor any of its individual components,
53
+ in Original or Modified Versions, may be sold by itself.
54
+
55
+ 2) Original or Modified Versions of the Font Software may be bundled,
56
+ redistributed and/or sold with any software, provided that each copy
57
+ contains the above copyright notice and this license. These can be
58
+ included either as stand-alone text files, human-readable headers or
59
+ in the appropriate machine-readable metadata fields within text or
60
+ binary files as long as those fields can be easily viewed by the user.
61
+
62
+ 3) No Modified Version of the Font Software may use the Reserved Font
63
+ Name(s) unless explicit written permission is granted by the corresponding
64
+ Copyright Holder. This restriction only applies to the primary font name as
65
+ presented to the users.
66
+
67
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68
+ Software shall not be used to promote, endorse or advertise any
69
+ Modified Version, except to acknowledge the contribution(s) of the
70
+ Copyright Holder(s) and the Author(s) or with their explicit written
71
+ permission.
72
+
73
+ 5) The Font Software, modified or unmodified, in part or in whole,
74
+ must be distributed entirely under this license, and must not be
75
+ distributed under any other license. The requirement for fonts to
76
+ remain under this license does not apply to any document created
77
+ using the Font Software.
78
+
79
+ TERMINATION
80
+ This license becomes null and void if any of the above conditions are
81
+ not met.
82
+
83
+ DISCLAIMER
84
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,17 @@
1
+ """Register the bundled Inter and JetBrains Mono faces with Qt."""
2
+
3
+ from pathlib import Path
4
+
5
+ from PySide6.QtGui import QFontDatabase
6
+
7
+ _FONTS = Path(__file__).parent / "fonts"
8
+
9
+
10
+ def load_fonts() -> list[str]:
11
+ """Return the family names Qt took; a file Qt cannot read is skipped, Segoe UI and Consolas fill in."""
12
+ families: set[str] = set()
13
+ for path in sorted(_FONTS.glob("*.ttf")):
14
+ font_id = QFontDatabase.addApplicationFont(str(path))
15
+ if font_id >= 0:
16
+ families.update(QFontDatabase.applicationFontFamilies(font_id))
17
+ return sorted(families)