blockspec 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.
blockspec/edit.py ADDED
@@ -0,0 +1,234 @@
1
+ # SPDX-License-Identifier: Apache-2.0 OR MIT
2
+ """Edit a blockspec document one block at a time: `docs/editing-api.md`.
3
+
4
+ Three operations, each text in and text out: replace a block, insert one
5
+ beside a block, delete a block. A block is a top-level node (SPEC.md section
6
+ 6.1), named by its node path `[i]`. Every function changes only the lines its
7
+ operation is about, reads the result back with the reader, and refuses rather
8
+ than return a document whose other blocks or names read differently. Nothing
9
+ here reads or writes a `<doc>.notes/` record.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import re
15
+
16
+ from .document import Document, Refusal, parse
17
+
18
+ __all__ = ["EditRefused", "REASONS", "delete_block", "insert_block", "replace_block"]
19
+
20
+ #: The API's own refusal reasons, none spelled like a SPEC.md section 9 code.
21
+ REASONS = (
22
+ "bad-position",
23
+ "no-such-block",
24
+ "nested-node",
25
+ "not-one-block",
26
+ "changes-another-block",
27
+ "rebinds-name",
28
+ )
29
+
30
+
31
+ class EditRefused(Refusal):
32
+ """An edit refused for a reason of the API's own, in `code`."""
33
+
34
+
35
+ def _lines(text: str) -> list[list[str]]:
36
+ """[body, line ending] per line, split as the reader splits lines."""
37
+ out = []
38
+ for match in re.finditer(r"([^\r\n]*)(\r\n|\r|\n|$)", text):
39
+ if match.start() == len(text) and (not out or out[-1][1]):
40
+ break
41
+ out.append([match.group(1), match.group(2)])
42
+ if not match.group(2):
43
+ break
44
+ return out
45
+
46
+
47
+ def _join(lines: list[list[str]]) -> str:
48
+ return "".join(body + eol for body, eol in lines)
49
+
50
+
51
+ def _blank(body: str) -> bool:
52
+ return not body.strip(" \t")
53
+
54
+
55
+ def _eol(lines: list[list[str]], at: int) -> str:
56
+ """The line ending a new line at index `at` takes (editing-api.md, *Where
57
+ the lines go*)."""
58
+ if at > 0 and lines[at - 1][1]:
59
+ return lines[at - 1][1]
60
+ return next((eol for _, eol in lines if eol), "\n")
61
+
62
+
63
+ def _check_types(text, node=None, source=None) -> None:
64
+ if not isinstance(text, str):
65
+ raise TypeError(f"text must be a str, not {type(text).__name__}")
66
+ if source is not None and not isinstance(source, str):
67
+ raise TypeError(f"source must be a str, not {type(source).__name__}")
68
+ if node is not None and not (
69
+ isinstance(node, list | tuple)
70
+ and all(isinstance(i, int) and not isinstance(i, bool) for i in node)
71
+ ):
72
+ raise TypeError("a node path must be a list or tuple of ints")
73
+
74
+
75
+ def _block(doc: Document, node) -> int:
76
+ """The index of the block `node` names, or a refusal."""
77
+ path = list(node)
78
+ if len(path) == 1 and 0 <= path[0] < len(doc.blocks):
79
+ return path[0]
80
+ at = doc.root
81
+ for i in path:
82
+ if not 0 <= i < len(at.children):
83
+ at = None
84
+ break
85
+ at = at.children[i]
86
+ if len(path) > 1 and at is not None:
87
+ raise EditRefused("nested-node", f"{path} is a node inside block [{path[0]}]")
88
+ raise EditRefused("no-such-block", f"{path} names no block of the document")
89
+
90
+
91
+ def _source_lines(source: str) -> list[str]:
92
+ lines = [body for body, _ in _lines(source)]
93
+ if not lines:
94
+ raise EditRefused("not-one-block", "the source is empty")
95
+ return lines
96
+
97
+
98
+ def _declared(doc: Document, block: int | None) -> set[str]:
99
+ """The names markers in block `block` declare."""
100
+ if block is None:
101
+ return set()
102
+ return {
103
+ node.marker[0]
104
+ for node in doc.nodes
105
+ if node.marker is not None and node.path[0] == block and node.marker[1] != ":end"
106
+ }
107
+
108
+
109
+ def _by_block(doc: Document) -> dict[int, list]:
110
+ out: dict[int, list] = {}
111
+ for leaf in doc.leaves:
112
+ out.setdefault(leaf["node"][0], []).append(
113
+ (leaf["node"][1:], leaf["type"], leaf["content"])
114
+ )
115
+ return out
116
+
117
+
118
+ def _move(target: dict, mapping) -> dict | None:
119
+ if "region" in target:
120
+ region = [_move(n, mapping) for n in target["region"]]
121
+ return {"region": [n for n in region if n is not None]}
122
+ first = mapping(target["node"][0])
123
+ if first is None:
124
+ return None
125
+ return {"node": [first, *target["node"][1:]], "type": target["type"]}
126
+
127
+
128
+ def _read_back(old: Document, text: str, edited: int | None, new: int | None, span, mapping) -> str:
129
+ """Refuse `text` unless it reads as `old` with the edit applied: block
130
+ `edited` of `old` replaced or removed, block `new` of the result made of
131
+ exactly the lines `span`, and every other block and name as it was."""
132
+ doc = parse(text)
133
+ if new is not None:
134
+ if new >= len(doc.blocks) or doc.blocks[new]["lines"] != list(span):
135
+ raise EditRefused("not-one-block", "the new lines do not read as one block")
136
+ expected = len(old.blocks) + (new is not None) - (edited is not None)
137
+ if len(doc.blocks) != expected or doc.frontmatter != old.frontmatter:
138
+ raise EditRefused("changes-another-block", "the document's blocks would change")
139
+ before, after = _by_block(old), _by_block(doc)
140
+ for j, block in enumerate(old.blocks):
141
+ if j == edited:
142
+ continue
143
+ k = mapping(j)
144
+ got = doc.blocks[k]
145
+ if (
146
+ got["type"] != block["type"]
147
+ or got["lines"][1] - got["lines"][0] != block["lines"][1] - block["lines"][0]
148
+ or after.get(k, []) != before.get(j, [])
149
+ ):
150
+ raise EditRefused("changes-another-block", f"block [{j}] would read differently")
151
+ gone, added = _declared(old, edited), _declared(doc, new)
152
+ want = {n: _move(t, mapping) for n, t in old.names.items() if n not in gone}
153
+ got = {}
154
+ for name, target in doc.names.items():
155
+ if name in added:
156
+ continue
157
+ if "region" in target and new is not None:
158
+ target = {"region": [n for n in target["region"] if n["node"] != [new]]}
159
+ got[name] = target
160
+ if want != got:
161
+ moved = sorted(n for n in set(want) | set(got) if want.get(n) != got.get(n))
162
+ raise EditRefused("rebinds-name", f"#{moved[0]} would bind to something else")
163
+ return text
164
+
165
+
166
+ def replace_block(text: str, node, source: str, /) -> str:
167
+ """Replace block `node`'s lines with `source`'s. The diff is the block."""
168
+ _check_types(text, node, source)
169
+ doc = parse(text)
170
+ i = _block(doc, node)
171
+ new = _source_lines(source)
172
+ lines = _lines(text)
173
+ first, last = doc.blocks[i]["lines"]
174
+ if [body for body, _ in lines[first - 1 : last]] == new:
175
+ return text
176
+ eol = _eol(lines, first - 1)
177
+ lines[first - 1 : last] = [[b, eol] for b in new[:-1]] + [[new[-1], lines[last - 1][1]]]
178
+ span = (first, first + len(new) - 1)
179
+ return _read_back(doc, _join(lines), i, i, span, lambda j: j)
180
+
181
+
182
+ def insert_block(text: str, source: str, /, *, before=None, after=None) -> str:
183
+ """Insert `source` as a block before or after the block named, or after
184
+ the last block. A blank line separates it from a non-blank neighbour."""
185
+ _check_types(text, before, source)
186
+ _check_types(text, after)
187
+ doc = parse(text)
188
+ if before is not None and after is not None:
189
+ raise EditRefused("bad-position", "give before= or after=, not both")
190
+ lines = _lines(text)
191
+ if after is not None:
192
+ k = _block(doc, after) + 1
193
+ at = doc.blocks[k - 1]["lines"][1]
194
+ elif before is not None:
195
+ k = _block(doc, before)
196
+ at = doc.blocks[k]["lines"][0] - 1
197
+ else:
198
+ k = len(doc.blocks)
199
+ at = doc.blocks[-1]["lines"][1] if doc.blocks else len(lines)
200
+ new = _source_lines(source)
201
+ eol = _eol(lines, at)
202
+ above = at > 0 and not _blank(lines[at - 1][0])
203
+ below = at < len(lines) and not _blank(lines[at][0])
204
+ added = [[""]] * above + [[b] for b in new] + [[""]] * below
205
+ added = [[b[0], eol] for b in added]
206
+ if at == len(lines) and lines and not lines[-1][1]:
207
+ lines[-1][1] = eol
208
+ added[-1][1] = ""
209
+ lines[at:at] = added
210
+ first = at + 1 + above
211
+ span = (first, first + len(new) - 1)
212
+ return _read_back(doc, _join(lines), None, k, span, lambda j: j + (j >= k))
213
+
214
+
215
+ def delete_block(text: str, node, /) -> str:
216
+ """Delete block `node` and the blank lines between it and the next block,
217
+ or, for the last block, those between it and the line before it."""
218
+ _check_types(text, node)
219
+ doc = parse(text)
220
+ i = _block(doc, node)
221
+ lines = _lines(text)
222
+ first, last = doc.blocks[i]["lines"]
223
+ start, end = first - 1, last
224
+ following = next((j for j in range(last, len(lines)) if not _blank(lines[j][0])), None)
225
+ if following is not None:
226
+ end = following
227
+ else:
228
+ while start > 0 and _blank(lines[start - 1][0]):
229
+ start -= 1
230
+ took_bare_end = end == len(lines) and not lines[-1][1]
231
+ del lines[start:end]
232
+ if took_bare_end and lines:
233
+ lines[-1][1] = ""
234
+ return _read_back(doc, _join(lines), i, None, (), lambda j: None if j == i else j - (j > i))
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.5
2
+ Name: blockspec
3
+ Version: 0.1.0
4
+ Summary: A specification and conformance suite for prose documents that must survive version control
5
+ Project-URL: Homepage, https://github.com/kindspec/blockspec
6
+ Project-URL: Source, https://github.com/kindspec/blockspec
7
+ Project-URL: Issues, https://github.com/kindspec/blockspec/issues
8
+ Project-URL: Specification, https://github.com/kindspec/blockspec/blob/main/SPEC.md
9
+ Author: Cameron Brooks
10
+ License-Expression: Apache-2.0 OR MIT
11
+ License-File: LICENSE
12
+ License-File: LICENSES/Apache-2.0.txt
13
+ License-File: LICENSES/CC-BY-4.0.txt
14
+ License-File: LICENSES/CC0-1.0.txt
15
+ License-File: LICENSES/MIT.txt
16
+ License-File: LICENSES/PSF-2.0.txt
17
+ Keywords: conformance,git,markdown,merge,specification
18
+ Classifier: Development Status :: 3 - Alpha
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Topic :: Software Development :: Version Control :: Git
22
+ Classifier: Topic :: Text Processing :: Markup :: Markdown
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+
26
+ # blockspec
27
+
28
+ A file format and test suite for prose documents that must survive version
29
+ control.
30
+
31
+ A blockspec document is a markdown file that renders and edits correctly in
32
+ today's markdown tools. It adds one convention, a marker that lets an author
33
+ name a part of the document. It refuses the markdown constructs that mature
34
+ parsers read differently, or that hide what a merge did.
35
+
36
+ ```markdown
37
+ # Runbook
38
+
39
+ <!-- #restart -->
40
+ ## Restart the service
41
+
42
+ Run `systemctl restart app`, then check the logs.
43
+ ```
44
+
45
+ The marker names the heading after it, and renders as nothing. A comment or a
46
+ transclusion can point at `restart` and keep working when the text around it moves.
47
+
48
+ Unlike a [rowspec](https://github.com/kindspec/rowspec) row, **a block gets no
49
+ minted id**, so nothing has to be written into the prose. Identity is computed
50
+ from content where it can be, and named by an author where it must be.
51
+ [`DESIGN-BRIEF.md`](DESIGN-BRIEF.md) has the measurement behind that.
52
+
53
+ ## Status
54
+
55
+ Draft 0. [`SPEC.md`](SPEC.md) is the format, `conformance/cases/` encodes it,
56
+ and `reference/blockspec/` is the reference. `reference/blockspec_alt/`, written
57
+ from the spec by an author who never read it, passes the same cases. Released on
58
+ [PyPI](https://pypi.org/project/blockspec/).
59
+
60
+ The experiment behind the format found that prose does have a silent wrong
61
+ merge worth a format. That verdict came from a second run under an owner ruling
62
+ made after the first run's result was public, so read
63
+ [the status page](docs/status.md) before relying on it.
64
+
65
+ ## Try it
66
+
67
+ From a clone, with Python 3.11 or newer and no dependencies:
68
+
69
+ ```sh
70
+ git clone https://github.com/kindspec/blockspec
71
+ cd blockspec
72
+ PYTHONPATH=reference python3 -c '
73
+ import blockspec
74
+ doc = blockspec.parse("<!-- #intro -->\nHello.\n")
75
+ print(doc.names)
76
+ '
77
+ ```
78
+
79
+ `parse` raises `Refusal`, with a `SPEC.md` §9 code, on a document it won't
80
+ accept.
81
+
82
+ ## Check documents
83
+
84
+ ```sh
85
+ pip install blockspec
86
+ blockspec check docs/ # refuses a document the profile cannot read safely
87
+ ```
88
+
89
+ A document is refused for what would quietly break under a merge, including a
90
+ link to a section that no longer exists and a marker that takes a name from a
91
+ heading. It exits 0 when every document reads, 1 when one is refused, and 2 when
92
+ nothing was checked or a file could not be read. `--format github` writes annotations. In CI:
93
+
94
+ ```yaml
95
+ - uses: actions/checkout@v7
96
+ - uses: kindspec/blockspec@v0.1.0
97
+ with:
98
+ paths: docs
99
+ ```
100
+
101
+ ## The reference's API
102
+
103
+ `reference/blockspec/` is standard library only, and run from its source
104
+ tree (`pythonpath = ["reference"]`).
105
+
106
+ | function | what it does |
107
+ | --- | --- |
108
+ | `parse(text)` | reads a document, or raises `Refusal` with a `SPEC.md` §9 code; the `Document` has `frontmatter`, `blocks`, `leaves`, `names` and `resolve(name)` |
109
+ | `conform(text, queries)` | `parse` as the conformance runner calls it |
110
+ | `resolve(repo, queries)` | §11's anchors and transclusions, as the runner calls it (`anchor.py`) |
111
+ | `edit.replace_block(text, node, source)` | the text with block `node`'s lines replaced by `source` |
112
+ | `edit.insert_block(text, source, before=, after=)` | the text with `source` inserted as a block before or after a block, or after the last |
113
+ | `edit.delete_block(text, node)` | the text without block `node` |
114
+
115
+ A block is named by its node path, `[i]`. Each `edit` function reads its
116
+ result back and raises `Refusal`, or its subclass `edit.EditRefused` for the
117
+ API's own reasons, rather than return a document whose other blocks or names
118
+ read differently. It never touches a `<doc>.notes/` record.
119
+ [`docs/editing-api.md`](docs/editing-api.md) gives the rules, and `tests/edit-cases/` pins them.
120
+
121
+ ## Develop
122
+
123
+ ```sh
124
+ just setup # install dependencies
125
+ just check # format and lint
126
+ just test # the tests
127
+ just conform # the conformance tree against the reference
128
+ just mutants # break the reference; the suite must notice
129
+ ```
130
+
131
+ ## More
132
+
133
+ - [`DESIGN-BRIEF.md`](DESIGN-BRIEF.md): what was decided and measured before the
134
+ format was written.
135
+ - [`docs/adjudications/`](docs/adjudications/): the decisions that define draft 0.
136
+ - [`spike/`](spike/README.md): the experiment.
137
+ - [kindspec](https://github.com/kindspec): the other formats.
@@ -0,0 +1,16 @@
1
+ blockspec/__init__.py,sha256=KCwI50nca_U9sCHD-StKIQeSalLHhSWtZSogPIXEerA,361
2
+ blockspec/__main__.py,sha256=EP1EUbJ89RQlVwOPA7oUSukFXKaaYux4VRPr6IXKAwU,102
3
+ blockspec/anchor.py,sha256=UjU8dX8tr4m2rH3rLWxV07n2lbNWNyIqq0g_SlfCiK8,47648
4
+ blockspec/cli.py,sha256=wsJY0ilmd4avm8sNucr-1qGF3UDXUerxYBGwlDcBfgw,4928
5
+ blockspec/document.py,sha256=jOm0HLg1JNvobBj5esjnpXBCcu_6yGZ5NtrNv1ei_U8,51250
6
+ blockspec/edit.py,sha256=IaOjQhtEUxIW5_fHoctuVkd3AkVWKfAe0h4dkedLhx4,8837
7
+ blockspec-0.1.0.dist-info/METADATA,sha256=yU4Yn_ZIY8vX8l7kxQObwfAxlQosBvhkIfP3hVeumKU,5279
8
+ blockspec-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
9
+ blockspec-0.1.0.dist-info/entry_points.txt,sha256=SQDY2W0zwVBSPxCmdOXLljUXDoiyAkEHEO0mMnMWjrc,49
10
+ blockspec-0.1.0.dist-info/licenses/LICENSE,sha256=Gekps-Ekbuv0wMGEeeF36-zIr4xHGilFhD75yre8dEU,4347
11
+ blockspec-0.1.0.dist-info/licenses/LICENSES/Apache-2.0.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
12
+ blockspec-0.1.0.dist-info/licenses/LICENSES/CC-BY-4.0.txt,sha256=1VdTnfaOdxzB7tzJHRP3D8qTDlCNEe7cr6SxXbSeN0Q,17023
13
+ blockspec-0.1.0.dist-info/licenses/LICENSES/CC0-1.0.txt,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
14
+ blockspec-0.1.0.dist-info/licenses/LICENSES/MIT.txt,sha256=nfn2VV8K3vVj-0YSVqB3mLrkdWUl0yvlGLbZm0rH8tA,1063
15
+ blockspec-0.1.0.dist-info/licenses/LICENSES/PSF-2.0.txt,sha256=eLEsOoE2CzVwAjNPDnDqDpLuv3qbNYgFwDxISElF87s,13809
16
+ blockspec-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ blockspec = blockspec.cli:main
@@ -0,0 +1,87 @@
1
+ blockspec is licensed per directory, on the same split as rowspec. This is
2
+ deliberate, not an oversight.
3
+
4
+ SPEC.md, docs/ CC-BY-4.0
5
+ conformance/cases/ CC0-1.0
6
+ conformance/*.py MIT
7
+ reference/, tests/,
8
+ tools/ Apache-2.0 OR MIT
9
+ justfile, pyproject.toml,
10
+ uv.lock Apache-2.0 OR MIT
11
+ README.md, AGENTS.md, CHANGELOG.md,
12
+ DESIGN-BRIEF.md CC-BY-4.0
13
+ .editorconfig,
14
+ .gitattributes,
15
+ .gitignore Apache-2.0 OR MIT
16
+ .github/workflows/,
17
+ action.yml Apache-2.0 OR MIT
18
+ LICENSE, NOTICE CC0-1.0
19
+ LICENSES/ each text under its own terms, copied verbatim
20
+ spike/*.md CC-BY-4.0
21
+ spike/harness/ MIT
22
+ spike/harness/plant_cases/ CC0-1.0
23
+ spike/harness3/ MIT
24
+ spike/ruling/ MIT
25
+ spike/results/ CC-BY-4.0, except corpus text (below)
26
+ spike/results/prereg3/ CC-BY-4.0, except corpus text and third-party
27
+ excerpts (below)
28
+
29
+ A path ending in "/" covers everything below it, subdirectories included. A
30
+ "*" matches within one directory. Where two rows cover the same path, the more
31
+ specific one applies: spike/harness/plant_cases/ is CC0-1.0 inside the MIT
32
+ spike/harness/, and spike/results/prereg3/ keeps its own row and its own
33
+ exceptions inside spike/results/.
34
+
35
+ The rows for SPEC.md, docs/, conformance/, reference/ and tests/ are decided
36
+ ahead of the files: those paths may be empty, and the split applies to whatever
37
+ lands there.
38
+
39
+ CORPUS TEXT IN spike/results/
40
+
41
+ The spike measures third-party corpora, and its results carry their text,
42
+ spike/results/prereg3/ included. In spike/results/prereg2/export/packets/ and
43
+ spike/results/prereg3/export/packets/, every .md file in a packet other than
44
+ QUESTIONS.md is a whole file copied from a corpus: before.md and after.md, or
45
+ in a merge packet base.md, leg-a.md, leg-c.md and after.md. Each packet's packet.json
46
+ quotes from them. The exception is the plant packets, whose text the harness
47
+ generates (spike/harness/prereg2_plants.py, spike/harness3/prereg3_plants.py).
48
+ Other result files quote shorter excerpts where they report a block, a quote
49
+ or a target, merge-arm-candidates.jsonl and cheap-arm/anchors-silent-wrongs.txt
50
+ among them. The corpora and their pins are named where each result was
51
+ produced: spike/LOG.md and spike/PRE-REGISTRATION-2.md section 6.2, which
52
+ prereg 3 keeps (spike/PRE-REGISTRATION-3.md section 1).
53
+
54
+ That text is not this project's work and is not offered under CC-BY-4.0. It
55
+ stays under its upstream terms, whatever they are at the pin it was taken
56
+ from. NOTICE lists each corpus, its pins and the licence its tree holds there.
57
+ The CC-BY-4.0 row covers what this project wrote around it: the records,
58
+ figures, prompts, questions and plant texts.
59
+
60
+ THIRD-PARTY EXCERPTS IN spike/results/prereg3/
61
+
62
+ The rehearsal evidence under spike/results/prereg3/rehearsals/, the archives
63
+ included, quotes synthetic test text. That text is taken from the docstrings
64
+ of CPython 3.13 standard-library modules, as rendered by pydoc (the rehearsal
65
+ builder, rehearsals/tools/build.py, lists the modules). The pydoc output links
66
+ to docs.python.org/3.13. A few docstrings link to docs.python.org/3.11 in their
67
+ own text. These excerpts are Copyright (c) the Python Software Foundation and
68
+ contributors, and they keep their own licence, the Python Software Foundation
69
+ License Version 2 (https://docs.python.org/3.13/license.html), whose text is
70
+ in LICENSES/PSF-2.0.txt. That file is the Python 3.13 distribution's own
71
+ licence file, /usr/lib/python3.13/LICENSE.txt from Debian's
72
+ libpython3.13-stdlib 3.13.5-2+deb13u5, copied verbatim. The excerpts are not
73
+ offered under CC-BY-4.0. The builder used no other outside source. The plant
74
+ texts, prompts and harness output are this project's own.
75
+
76
+ Full texts are in LICENSES/.
77
+
78
+ WHY THE SPLIT
79
+
80
+ The point of this project is independent implementations. That makes the
81
+ reusability of the SPEC and the FIXTURES more important than the licence on any
82
+ reference code.
83
+
84
+ CommonMark embeds its conformance examples inside a CC-BY-SA spec document, so
85
+ vendoring the test cases arguably vendors share-alike prose. These fixtures are
86
+ meant to be vendored: copy them into an implementation in any language, under
87
+ any licence, without obligation.
@@ -0,0 +1,73 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
30
+
31
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
32
+
33
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
34
+
35
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
36
+
37
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
38
+
39
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40
+
41
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
42
+
43
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ APPENDIX: How to apply the Apache License to your work.
58
+
59
+ To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
60
+
61
+ Copyright [yyyy] [name of copyright owner]
62
+
63
+ Licensed under the Apache License, Version 2.0 (the "License");
64
+ you may not use this file except in compliance with the License.
65
+ You may obtain a copy of the License at
66
+
67
+ http://www.apache.org/licenses/LICENSE-2.0
68
+
69
+ Unless required by applicable law or agreed to in writing, software
70
+ distributed under the License is distributed on an "AS IS" BASIS,
71
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
72
+ See the License for the specific language governing permissions and
73
+ limitations under the License.