sphinx-needs-trace 0.1.0__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.
@@ -0,0 +1,38 @@
1
+ """
2
+ Traceability findings, totals, a trace graph and a merge of ``needs.json`` files for sphinx-needs.
3
+
4
+ ``extensions.append("sphinx_needs_trace")`` registers the directives; the merge functions need no Sphinx build.
5
+ """
6
+
7
+ from typing import Any
8
+
9
+ from sphinx.application import Sphinx
10
+ from sphinx_needs.api import add_field
11
+
12
+ from sphinx_needs_trace import findings, graph
13
+ from sphinx_needs_trace.merge import merge_needs_files, merge_trace_items, needs_file
14
+
15
+ __version__ = "0.1.0"
16
+
17
+ __all__ = ["merge_needs_files", "merge_trace_items", "needs_file", "setup"]
18
+
19
+
20
+ def setup(app: Sphinx) -> dict[str, Any]:
21
+ # The fields the merge writes, so that a project that imports a merged file declares nothing. sphinx-needs clears its fields in its own setup.
22
+ app.setup_extension("sphinx_needs")
23
+ names: dict[str, Any] = {"type": "array", "items": {"type": "string"}}
24
+ add_field("platforms", "Names of the builds that have the trace item", schema=names, default=[])
25
+ add_field("conflicting_fields", "Names of the fields that differ between the builds", schema=names, default=[])
26
+ app.add_node(findings.traceability_findings)
27
+ app.add_directive("traceability-findings", findings.TraceabilityFindingsDirective)
28
+ app.add_node(findings.traceability_totals)
29
+ app.add_directive("traceability-totals", findings.TraceabilityTotalsDirective)
30
+ app.connect("doctree-resolved", findings.fill_findings)
31
+ app.connect("doctree-resolved", findings.fill_totals)
32
+ app.connect("env-get-outdated", findings.pages_with_findings)
33
+ app.add_node(graph.trace_graph_link)
34
+ app.add_directive("trace-graph", graph.TraceGraphDirective)
35
+ app.connect("doctree-resolved", graph.fill_links)
36
+ app.connect("builder-inited", graph.add_static_files)
37
+ app.connect("build-finished", graph.write_graph_page)
38
+ return {"version": __version__, "parallel_read_safe": True, "parallel_write_safe": True}
@@ -0,0 +1,203 @@
1
+ """
2
+ The ``traceability-findings`` directive: the findings of the sphinx-needs schema rules as a table.
3
+
4
+ sphinx-needs writes its findings to ``schema_violations.json`` in the output folder when writing starts,
5
+ before any page is written, but has no directive that shows them. This directive places a node that is
6
+ filled from that file when its page is written, in every build. It never fails the build.
7
+ """
8
+
9
+ import json
10
+ import re
11
+ from collections import Counter
12
+ from collections.abc import Callable
13
+ from dataclasses import dataclass
14
+ from pathlib import Path
15
+ from typing import Any, ClassVar
16
+
17
+ from docutils import nodes
18
+ from docutils.parsers.rst import directives
19
+ from sphinx.application import Sphinx
20
+ from sphinx.environment import BuildEnvironment
21
+ from sphinx.util.docutils import SphinxDirective
22
+ from sphinx.util.typing import OptionSpec
23
+ from sphinx_needs.api import get_needs_view
24
+
25
+ FINDINGS_FILE = "schema_violations.json"
26
+ SEVERITY_ORDER = ("violation", "warning", "info")
27
+ # Set in the metadata of a page that has one of the directives.
28
+ SHOWS_FINDINGS = "traceability_findings"
29
+ NO_FINDINGS = "No findings: every trace item of this report satisfies the traceability rules."
30
+ NOT_CHECKED = f"The traceability rules were not checked: this build has no {FINDINGS_FILE}."
31
+
32
+
33
+ @dataclass(frozen=True)
34
+ class Finding:
35
+ need: str
36
+ rule: str
37
+ severity: str
38
+ message: str
39
+
40
+
41
+ def rule_name(schema_path: str) -> str:
42
+ """
43
+ The rule of a finding.
44
+
45
+ The findings file has no field for it, only ``schema_path``, whose first part is the rule's ``id``
46
+ and its index (``spec-is-tested[3] > validate > ...``).
47
+ """
48
+ return re.sub(r"\[\d+\]$", "", schema_path.split(" > ")[0])
49
+
50
+
51
+ def read_findings(report: dict[str, Any]) -> list[Finding]:
52
+ """The top-level findings of a findings file, most severe first."""
53
+ findings = [
54
+ Finding(
55
+ need=need,
56
+ rule=rule_name(warning["details"]["schema_path"]),
57
+ severity=warning["details"]["severity"],
58
+ message=warning["details"].get("user_msg") or warning["details"].get("validation_msg", ""),
59
+ )
60
+ for need, warnings in report.get("validation_warnings", {}).items()
61
+ for warning in warnings
62
+ ]
63
+ return sorted(findings, key=lambda f: (SEVERITY_ORDER.index(f.severity) if f.severity in SEVERITY_ORDER else len(SEVERITY_ORDER), f.rule, f.need))
64
+
65
+
66
+ def _table(header: list[str], rows: list[list[nodes.Node]], caption: str = "") -> nodes.table:
67
+ group = nodes.tgroup(cols=len(header))
68
+ group += [nodes.colspec(colwidth=1) for _ in header]
69
+ group += nodes.thead("", nodes.row("", *[nodes.entry("", nodes.paragraph(text=title)) for title in header]))
70
+ group += nodes.tbody("", *[nodes.row("", *[nodes.entry("", cell) for cell in row]) for row in rows])
71
+ return nodes.table("", *([nodes.title(text=caption)] if caption else []), group)
72
+
73
+
74
+ def render(
75
+ findings: list[Finding] | None,
76
+ need_link: Callable[[str], nodes.Node],
77
+ need_type: Callable[[str], str],
78
+ need_platforms: Callable[[str], str] | None = None,
79
+ ) -> list[nodes.Node]:
80
+ """The count per rule and the table of findings, or the "no findings" line. A Platforms column follows Type when ``need_platforms`` is given."""
81
+ if findings is None:
82
+ return [nodes.paragraph(text=NOT_CHECKED)]
83
+ if not findings:
84
+ return [nodes.paragraph(text=NO_FINDINGS)]
85
+ counts = Counter(finding.rule for finding in findings)
86
+ return [
87
+ _table(["Rule", "Findings"], [[nodes.paragraph(text=rule), nodes.paragraph(text=str(count))] for rule, count in sorted(counts.items())], "Findings per rule"),
88
+ _table(
89
+ ["Trace item", "Type", *(["Platforms"] if need_platforms else []), "Rule", "Severity", "Message"],
90
+ [
91
+ [
92
+ nodes.paragraph("", "", need_link(finding.need)),
93
+ nodes.paragraph(text=need_type(finding.need)),
94
+ *([nodes.paragraph(text=need_platforms(finding.need))] if need_platforms else []),
95
+ nodes.paragraph(text=finding.rule),
96
+ nodes.paragraph(text=finding.severity),
97
+ nodes.paragraph(text=finding.message),
98
+ ]
99
+ for finding in findings
100
+ ],
101
+ "Trace items with findings",
102
+ ),
103
+ ]
104
+
105
+
106
+ def totals(types: list[tuple[str, str]], trace_items: dict[str, str], findings: list[Finding]) -> list[tuple[str, int, int, int]]:
107
+ """Per type: (title, total, traced, missing). Missing counts the trace items with at least one finding."""
108
+ with_finding = {finding.need for finding in findings}
109
+ rows = []
110
+ for type_name, title in types:
111
+ ids = [item_id for item_id, item_type in trace_items.items() if item_type == type_name]
112
+ missing = sum(item_id in with_finding for item_id in ids)
113
+ rows.append((title, len(ids), len(ids) - missing, missing))
114
+ return rows
115
+
116
+
117
+ def selected_types(schema_definitions: dict[str, Any], need_types: list[dict[str, Any]]) -> list[tuple[str, str]]:
118
+ """The (type, title) of every type a schema rule selects, in the order of ``needs_types``."""
119
+ selected: set[str] = set()
120
+ for schema in schema_definitions.get("schemas", []):
121
+ type_select = schema.get("select", {}).get("properties", {}).get("type", {})
122
+ selected.update([type_select["const"]] if "const" in type_select else type_select.get("enum", []))
123
+ return [(t["directive"], t["title"]) for t in need_types if t["directive"] in selected]
124
+
125
+
126
+ class traceability_findings(nodes.General, nodes.Element):
127
+ """Filled with the findings when its page is written."""
128
+
129
+
130
+ class TraceabilityFindingsDirective(SphinxDirective):
131
+ option_spec: ClassVar[OptionSpec] = {"platforms": directives.flag}
132
+
133
+ def run(self) -> list[nodes.Node]:
134
+ self.env.metadata[self.env.docname][SHOWS_FINDINGS] = True
135
+ return [traceability_findings(platforms="platforms" in self.options)]
136
+
137
+
138
+ class traceability_totals(nodes.General, nodes.Element):
139
+ """Filled with the totals per trace item type when its page is written."""
140
+
141
+
142
+ class TraceabilityTotalsDirective(SphinxDirective):
143
+ def run(self) -> list[nodes.Node]:
144
+ self.env.metadata[self.env.docname][SHOWS_FINDINGS] = True
145
+ return [traceability_totals()]
146
+
147
+
148
+ def pages_with_findings(app: Sphinx, env: BuildEnvironment, added: set[str], changed: set[str], removed: set[str]) -> list[str]:
149
+ """A change on any page can change the findings, so a page that shows them is read again in every build."""
150
+ return [docname for docname, metadata in env.metadata.items() if metadata.get(SHOWS_FINDINGS)]
151
+
152
+
153
+ def load_findings(app: Sphinx) -> list[Finding] | None:
154
+ """The findings of this build; None when sphinx-needs wrote no findings file, so the rules did not run."""
155
+ findings_file = Path(app.outdir) / FINDINGS_FILE
156
+ return read_findings(json.loads(findings_file.read_text(encoding="utf-8"))) if findings_file.is_file() else None
157
+
158
+
159
+ def fill_totals(app: Sphinx, doctree: nodes.document, docname: str) -> None:
160
+ placeholders = list(doctree.findall(traceability_totals))
161
+ if not placeholders:
162
+ return
163
+ findings = load_findings(app)
164
+ if findings is None:
165
+ table: nodes.Node = nodes.paragraph(text=NOT_CHECKED)
166
+ else:
167
+ trace_items = {need_id: need["type"] for need_id, need in get_needs_view(app).items()}
168
+ rows = totals(selected_types(app.config.needs_schema_definitions, app.config.needs_types), trace_items, findings)
169
+ table = _table(["Type", "Total", "Traced", "Missing"], [[nodes.paragraph(text=str(value)) for value in row] for row in rows])
170
+ for placeholder in placeholders:
171
+ placeholder.replace_self(table.deepcopy())
172
+
173
+
174
+ def fill_findings(app: Sphinx, doctree: nodes.document, docname: str) -> None:
175
+ placeholders = list(doctree.findall(traceability_findings))
176
+ if not placeholders:
177
+ return
178
+ findings = load_findings(app)
179
+ needs = get_needs_view(app)
180
+
181
+ def need_link(need_id: str) -> nodes.Node:
182
+ need = needs.get(need_id)
183
+ if not need or not need["docname"]:
184
+ return nodes.Text(need_id)
185
+ uri = f"{app.builder.get_relative_uri(docname, need['docname'])}#{need_id}"
186
+ return nodes.reference("", need_id, refuri=uri, internal=True)
187
+
188
+ def need_type(need_id: str) -> str:
189
+ need = needs.get(need_id)
190
+ return need["type_name"] if need else ""
191
+
192
+ def need_platforms(need_id: str) -> str:
193
+ need = needs.get(need_id)
194
+ # A project that merges no builds has no such field.
195
+ return ", ".join(need.get("platforms") or []) if need else ""
196
+
197
+ for placeholder in placeholders:
198
+ rendered = render(findings, need_link, need_type, need_platforms if placeholder["platforms"] else None)
199
+ for table in rendered:
200
+ # A table with a caption needs an ID, or Sphinx warns when it numbers the tables.
201
+ if isinstance(table, nodes.table):
202
+ doctree.set_id(table)
203
+ placeholder.replace_self(rendered)
@@ -0,0 +1,162 @@
1
+ """
2
+ The ``trace-graph`` directive: a link to the trace graph of the report, a page of its own.
3
+
4
+ The graph shows the trace items of the build it runs in, with their links and their findings. The page is
5
+ written once per build, when the build is done and the findings exist. It has no settings: what the types
6
+ and links are, it reads from the configuration of sphinx-needs and sphinx-test-reports.
7
+ """
8
+
9
+ import json
10
+ from collections.abc import Callable, Collection
11
+ from dataclasses import dataclass
12
+ from html import escape
13
+ from pathlib import Path
14
+ from typing import Any, ClassVar
15
+ from urllib.parse import quote
16
+
17
+ from docutils import nodes
18
+ from docutils.parsers.rst import directives
19
+ from sphinx.application import Sphinx
20
+ from sphinx.util.docutils import SphinxDirective
21
+ from sphinx.util.typing import OptionSpec
22
+ from sphinx_needs.api import get_needs_view
23
+
24
+ from sphinx_needs_trace.findings import load_findings
25
+
26
+ PAGE = "trace_graph.html"
27
+ PAGE_TEMPLATE = Path(__file__).with_name("trace_graph_page.html")
28
+ STATIC_DIR = Path(__file__).with_name("static")
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class TraceModel:
33
+ """What the graph knows of the project's types."""
34
+
35
+ #: (type, title, colour) in the order of the list on the page; the colour may be empty
36
+ types: list[tuple[str, str, str]]
37
+ #: The type of a test result; None without sphinx-test-reports
38
+ result_type: str | None
39
+ #: Report structure of sphinx-test-reports, not trace chain: test suites and test files
40
+ left_out_types: frozenset[str]
41
+
42
+
43
+ def trace_model(need_types: list[dict[str, Any]], tr_case: list[str] | None, tr_suite: list[str] | None, tr_file: list[str] | None) -> TraceModel:
44
+ """
45
+ The types from ``needs_types`` and from the type settings of sphinx-test-reports, which are None when it is not loaded.
46
+
47
+ sphinx-test-reports keeps its types out of ``needs_types``. A setting holds directive, type, title, prefix, colour and style.
48
+ """
49
+ types = [(need_type["directive"], need_type["title"], need_type.get("color") or "") for need_type in need_types]
50
+ if tr_case:
51
+ types.append((tr_case[1], tr_case[2], tr_case[4]))
52
+ return TraceModel(types, tr_case[1] if tr_case else None, frozenset(setting[1] for setting in (tr_suite, tr_file) if setting))
53
+
54
+
55
+ def graph_elements(
56
+ trace_items: dict[str, dict[str, Any]], link_types: list[str], url: Callable[[str], str], findings: dict[str, list[str]], left_out_types: Collection[str]
57
+ ) -> list[dict[str, Any]]:
58
+ """Cytoscape elements: a node per trace item, an edge per outgoing link to another trace item; without the left out types and their links."""
59
+ items = {item_id: item for item_id, item in trace_items.items() if item["type"] not in left_out_types}
60
+ elements: list[dict[str, Any]] = [
61
+ {
62
+ "data": {
63
+ "id": item_id,
64
+ "title": item["title"],
65
+ "type": item["type"],
66
+ "type_name": item.get("type_name", item["type"]),
67
+ "platforms": list(item.get("platforms") or []),
68
+ "result": item.get("result") or "",
69
+ "findings": findings.get(item_id, []),
70
+ "url": url(item_id),
71
+ }
72
+ }
73
+ for item_id, item in items.items()
74
+ ]
75
+ elements += [
76
+ {"data": {"id": f"{item_id}-{link}-{target}", "source": item_id, "target": target, "link": link}}
77
+ for item_id, item in items.items()
78
+ for link in link_types
79
+ for target in item.get(link, [])
80
+ if target in items
81
+ ]
82
+ return elements
83
+
84
+
85
+ def graph_settings(model: TraceModel, elements: list[dict[str, Any]]) -> dict[str, Any]:
86
+ """
87
+ What the page script needs to know of the trace model.
88
+
89
+ A test result is linked from its test, so in the chain it sits below the test, although the link points at it:
90
+ a link type whose targets are all test results points down.
91
+ """
92
+ type_of = {element["data"]["id"]: element["data"]["type"] for element in elements if "source" not in element["data"]}
93
+ targets: dict[str, set[str]] = {}
94
+ for element in elements:
95
+ if "source" in element["data"]:
96
+ targets.setdefault(element["data"]["link"], set()).add(type_of[element["data"]["target"]])
97
+ return {
98
+ "types": [[type_name, title] for type_name, title, _ in model.types],
99
+ "colors": {type_name: color for type_name, _, color in model.types if color},
100
+ "result_type": model.result_type,
101
+ "down_links": sorted(link for link, target_types in targets.items() if target_types == {model.result_type}),
102
+ }
103
+
104
+
105
+ def graph_data_html(elements: list[dict[str, Any]], settings: dict[str, Any]) -> str:
106
+ """The settings and the elements as a JSON data block; a title with ``</script>`` cannot end it."""
107
+ data = json.dumps({"settings": settings, "elements": elements}).replace("<", "\\u003c").replace(">", "\\u003e").replace("&", "\\u0026")
108
+ return f'<script type="application/json" class="trace-graph-data">{data}</script>'
109
+
110
+
111
+ class trace_graph_link(nodes.General, nodes.Element):
112
+ """Replaced by the link when its page is written, because the way to the root depends on the builder."""
113
+
114
+
115
+ class TraceGraphDirective(SphinxDirective):
116
+ """A link to the trace graph page; ``:start:`` names the trace item whose trace the page opens on, by ID or by title."""
117
+
118
+ option_spec: ClassVar[OptionSpec] = {"start": directives.unchanged}
119
+
120
+ def run(self) -> list[nodes.Node]:
121
+ self.env.metadata[self.env.docname]["trace_graph"] = True
122
+ return [trace_graph_link(start=f"#start={quote(self.options['start'])}" if self.options.get("start") else "")]
123
+
124
+
125
+ def fill_links(app: Sphinx, doctree: nodes.document, docname: str) -> None:
126
+ # The graph page is in the root of the output folder.
127
+ to_root = "../" * app.builder.get_target_uri(docname).count("/")
128
+ for placeholder in list(doctree.findall(trace_graph_link)):
129
+ link = nodes.reference("", "Open the trace graph", refuri=f"{to_root}{PAGE}{placeholder['start']}", internal=True)
130
+ placeholder.replace_self(nodes.paragraph("", "", link))
131
+
132
+
133
+ def add_static_files(app: Sphinx) -> None:
134
+ """The files the graph page loads are copied to ``_static`` with the project's own static files."""
135
+ if app.builder.format == "html":
136
+ app.config.html_static_path.append(str(STATIC_DIR))
137
+
138
+
139
+ def write_graph_page(app: Sphinx, exception: Exception | None) -> None:
140
+ if exception or app.builder.format != "html" or not any(meta.get("trace_graph") for meta in app.env.metadata.values()):
141
+ return
142
+ needs = get_needs_view(app)
143
+ findings: dict[str, list[str]] = {}
144
+ for finding in load_findings(app) or []:
145
+ if finding.rule not in findings.setdefault(finding.need, []):
146
+ findings[finding.need].append(finding.rule)
147
+
148
+ def url(need_id: str) -> str:
149
+ docname = needs[need_id]["docname"]
150
+ return f"{app.builder.get_target_uri(docname)}#{need_id}" if docname else ""
151
+
152
+ tr_case, tr_suite, tr_file = (getattr(app.config, name, None) for name in ("tr_case", "tr_suite", "tr_file"))
153
+ model = trace_model(app.config.needs_types, tr_case, tr_suite, tr_file)
154
+ elements = graph_elements(dict(needs.items()), list(app.config.needs_links), url, findings, model.left_out_types)
155
+ page = (
156
+ PAGE_TEMPLATE.read_text(encoding="utf-8")
157
+ .replace("__TITLE__", escape(app.config.project))
158
+ # The front page of the report; the graph page is in the root of the output folder.
159
+ .replace("__BACK__", escape(app.builder.get_target_uri(app.config.root_doc) or "./"))
160
+ .replace("__DATA__", graph_data_html(elements, graph_settings(model, elements)))
161
+ )
162
+ (Path(app.outdir) / PAGE).write_text(page, encoding="utf-8")
@@ -0,0 +1,69 @@
1
+ """Merges the trace items of several builds of one product into one set. Plain JSON code: it needs no Sphinx."""
2
+
3
+ import json
4
+ from collections.abc import Mapping
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ # The fields the merge writes. A build that loads the extension has them, empty, in its needs.json.
9
+ MERGE_FIELDS = ("platforms", "conflicting_fields")
10
+
11
+
12
+ def merge_trace_items(builds: dict[str, dict[str, dict[str, Any]]], link_types: list[str]) -> dict[str, dict[str, Any]]:
13
+ """
14
+ Merge the trace items of the builds of one product, keyed by the name of the build (the platform).
15
+
16
+ A trace item may exist in only some builds (a test case only on the test platform), so each ID is kept
17
+ once and `platforms` says where it was found. Link lists are joined, any other field comes from the
18
+ first build in sorted order and a field that differs is named in `conflicting_fields`.
19
+ """
20
+ merged: dict[str, dict[str, Any]] = {}
21
+ for platform in sorted(builds):
22
+ for item_id, item in builds[platform].items():
23
+ merged.setdefault(item_id, {})[platform] = item
24
+ return {item_id: _merge_one(by_platform, link_types) for item_id, by_platform in merged.items()}
25
+
26
+
27
+ def _merge_one(by_platform: dict[str, dict[str, Any]], link_types: list[str]) -> dict[str, Any]:
28
+ items = list(by_platform.values())
29
+ result = dict(items[0])
30
+ for link_type in link_types:
31
+ result[link_type] = sorted({target for item in items for target in item.get(link_type, [])})
32
+ result["platforms"] = list(by_platform)
33
+ fields = {name for item in items for name in item} - set(link_types)
34
+ conflicting = sorted(name for name in fields if any(item.get(name) != items[0].get(name) for item in items))
35
+ if conflicting:
36
+ result["conflicting_fields"] = conflicting
37
+ return result
38
+
39
+
40
+ def needs_file(needs: dict[str, dict[str, Any]]) -> dict[str, Any]:
41
+ """Wrap the merged set in the `needs.json` format that `needimport` reads."""
42
+ return {"current_version": "", "versions": {"": {"needs": needs}}}
43
+
44
+
45
+ def merge_needs_files(files: Mapping[str, str | Path]) -> dict[str, Any]:
46
+ """
47
+ Merge the `needs.json` files of the builds of one product, keyed by the name of the build.
48
+
49
+ For a caller that should not know the file format: the result is the content of the merged file.
50
+ The back links are left out because sphinx-needs computes them again from the merged links.
51
+ """
52
+ builds: dict[str, dict[str, dict[str, Any]]] = {}
53
+ link_types: set[str] = set()
54
+ for build, path in files.items():
55
+ try:
56
+ data = json.loads(Path(path).read_text(encoding="utf-8"))
57
+ version = data["versions"][data["current_version"]]
58
+ field_types = {name: field.get("field_type") for name, field in version["needs_schema"]["properties"].items()}
59
+ builds[build] = {
60
+ item_id: {name: value for name, value in item.items() if field_types.get(name) != "backlinks" and name not in MERGE_FIELDS}
61
+ for item_id, item in version["needs"].items()
62
+ }
63
+ links = {name for name, field_type in field_types.items() if field_type == "links"}
64
+ if any(not isinstance(item.get(name, []), list) for item in builds[build].values() for name in links):
65
+ raise TypeError("a link field is not a list")
66
+ except (OSError, ValueError, LookupError, TypeError, AttributeError) as error:
67
+ raise ValueError(f"{path} is not a readable needs.json: {error!r}") from error
68
+ link_types.update(links)
69
+ return needs_file(merge_trace_items(builds, sorted(link_types)))
File without changes
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2016-2026, The Cytoscape Consortium.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the “Software”), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.