documentdriver 0.2.0__py3-none-macosx_11_0_arm64.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.
- documentdriver/__init__.py +72 -0
- documentdriver/_digests.py +7 -0
- documentdriver/_run.py +181 -0
- documentdriver/bin/docx +0 -0
- documentdriver/bin/pptx +0 -0
- documentdriver/bin/xlsx +0 -0
- documentdriver-0.2.0.dist-info/METADATA +45 -0
- documentdriver-0.2.0.dist-info/RECORD +10 -0
- documentdriver-0.2.0.dist-info/WHEEL +4 -0
- documentdriver-0.2.0.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""The documentdriver command-line tools, as static binaries.
|
|
2
|
+
|
|
3
|
+
This wheel carries the docx, pptx and xlsx binaries for one platform.
|
|
4
|
+
Their command line, results and errors follow the agent contract
|
|
5
|
+
(docs/contract.md in the documentdriver repository). run() makes one call
|
|
6
|
+
in a private directory and returns the parsed result, or raises
|
|
7
|
+
EngineError with the contract's errors:
|
|
8
|
+
|
|
9
|
+
import documentdriver
|
|
10
|
+
facts, _ = documentdriver.run("docx", ["read", "in.docx"], {"in.docx": data})
|
|
11
|
+
res, out = documentdriver.run("docx", ["apply", "in.docx", "-", "-o", "out.docx"],
|
|
12
|
+
{"in.docx": data}, stdin=plan, output="out.docx")
|
|
13
|
+
|
|
14
|
+
binary() returns a binary's path, to run it yourself.
|
|
15
|
+
|
|
16
|
+
binary() checks the file against the SHA-256 recorded when the wheel was
|
|
17
|
+
built and raises if it differs, so a damaged or replaced install fails
|
|
18
|
+
loudly instead of running something else.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import hashlib
|
|
22
|
+
import os
|
|
23
|
+
import stat
|
|
24
|
+
|
|
25
|
+
from ._digests import DIGESTS, VERSION
|
|
26
|
+
from ._run import DEFAULT_TIMEOUT, STDERR_CAP, STDOUT_CAP, EngineError, Run, run
|
|
27
|
+
|
|
28
|
+
__all__ = ["binary", "names", "run", "Run", "EngineError", "DEFAULT_TIMEOUT",
|
|
29
|
+
"STDOUT_CAP", "STDERR_CAP", "__version__"]
|
|
30
|
+
|
|
31
|
+
__version__ = VERSION
|
|
32
|
+
|
|
33
|
+
_HERE = os.path.dirname(os.path.abspath(__file__))
|
|
34
|
+
_checked = set()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def names():
|
|
38
|
+
"""Return the names of the binaries this wheel carries, sorted."""
|
|
39
|
+
return sorted(DIGESTS)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def binary(name):
|
|
43
|
+
"""Return the absolute path of the bundled binary `name` ("docx", "pptx", "xlsx").
|
|
44
|
+
|
|
45
|
+
The first call per binary hashes it and compares the digest recorded at
|
|
46
|
+
build time; a mismatch raises RuntimeError. It also restores the
|
|
47
|
+
executable bit if an installer dropped it.
|
|
48
|
+
"""
|
|
49
|
+
want = DIGESTS.get(name)
|
|
50
|
+
if want is None:
|
|
51
|
+
raise ValueError(
|
|
52
|
+
"documentdriver has no binary %r (it has: %s)"
|
|
53
|
+
% (name, ", ".join(names()))
|
|
54
|
+
)
|
|
55
|
+
path = os.path.join(_HERE, "bin", name)
|
|
56
|
+
if path in _checked:
|
|
57
|
+
return path
|
|
58
|
+
h = hashlib.sha256()
|
|
59
|
+
with open(path, "rb") as f:
|
|
60
|
+
for chunk in iter(lambda: f.read(1 << 20), b""):
|
|
61
|
+
h.update(chunk)
|
|
62
|
+
got = h.hexdigest()
|
|
63
|
+
if got != want:
|
|
64
|
+
raise RuntimeError(
|
|
65
|
+
"documentdriver: %s has SHA-256 %s, but this wheel recorded %s; "
|
|
66
|
+
"reinstall documentdriver==%s" % (path, got, want, VERSION)
|
|
67
|
+
)
|
|
68
|
+
mode = os.stat(path).st_mode
|
|
69
|
+
if mode & stat.S_IXUSR == 0:
|
|
70
|
+
os.chmod(path, mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
71
|
+
_checked.add(path)
|
|
72
|
+
return path
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Generated by tools/release when the wheel was built; do not edit.
|
|
2
|
+
VERSION = "0.2.0"
|
|
3
|
+
DIGESTS = {
|
|
4
|
+
"docx": "aae13f12f977a134ddd8182e890c2bfe0f29b3b486d55eba668573d07571f5fe",
|
|
5
|
+
"pptx": "741ac699d617af4ae9adb57b8f4cc751d5b1b692d093b798d479340e803cc3c6",
|
|
6
|
+
"xlsx": "99d1401139f11ff85f37b911a51a24a7c052b6ef871a6aba31abef2cbae6bafd",
|
|
7
|
+
}
|
documentdriver/_run.py
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"""run(): one call of a bundled binary, in a private directory.
|
|
2
|
+
|
|
3
|
+
The binaries follow the agent contract (docs/contract.md): exit 0 with one
|
|
4
|
+
JSON document on stdout, exit 1 or 2 with one errors object on stderr.
|
|
5
|
+
run() turns that into a return value or an EngineError, so callers do not
|
|
6
|
+
each reimplement the subprocess, temp-file and error handling.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import collections
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import subprocess
|
|
13
|
+
import tempfile
|
|
14
|
+
|
|
15
|
+
__all__ = ["run", "Run", "EngineError", "DEFAULT_TIMEOUT", "STDOUT_CAP", "STDERR_CAP"]
|
|
16
|
+
|
|
17
|
+
DEFAULT_TIMEOUT = 60.0 # seconds
|
|
18
|
+
STDOUT_CAP = 64 << 20 # a whole document's markup and an apply's changed units fit
|
|
19
|
+
STDERR_CAP = 1 << 20
|
|
20
|
+
|
|
21
|
+
Run = collections.namedtuple("Run", ["result", "output"])
|
|
22
|
+
Run.__doc__ = """What run() returns: the result (a dict, or str when parse=False)
|
|
23
|
+
and the bytes of the `output` file (None when no output was asked for or
|
|
24
|
+
the tool wrote none, as a no-op apply or a dry run does)."""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class EngineError(ValueError):
|
|
28
|
+
"""A binary refused or failed with the contract's errors object.
|
|
29
|
+
|
|
30
|
+
errors: the list from {"errors": [...]}, each with code and message and
|
|
31
|
+
optionally path, hint, span, matches, detail. exit_code is 1 (refused or
|
|
32
|
+
failed) or 2 (wrong command line, code "usage"). It is a ValueError:
|
|
33
|
+
the input was wrong, not the installation.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, tool, errors, exit_code):
|
|
37
|
+
self.tool = tool
|
|
38
|
+
self.errors = errors
|
|
39
|
+
self.exit_code = exit_code
|
|
40
|
+
super().__init__(_error_text(tool, errors))
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def code(self):
|
|
44
|
+
"""The first error's code, e.g. "not_found"."""
|
|
45
|
+
return self.errors[0].get("code", "")
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def path(self):
|
|
49
|
+
"""The first error's path, or None when it has none."""
|
|
50
|
+
return self.errors[0].get("path")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _error_text(tool, errors):
|
|
54
|
+
"""One line for a reader: '<tool>: <code>[ at <path>]: <message>; ...', at most five errors."""
|
|
55
|
+
parts = []
|
|
56
|
+
for error in errors[:5]:
|
|
57
|
+
path = error.get("path")
|
|
58
|
+
text = "%s at %s: %s" % (error.get("code", ""), path, error.get("message", "")) if path \
|
|
59
|
+
else "%s: %s" % (error.get("code", ""), error.get("message", ""))
|
|
60
|
+
if error.get("hint"):
|
|
61
|
+
text += " Hint: %s" % error["hint"]
|
|
62
|
+
parts.append(text)
|
|
63
|
+
if len(errors) > 5:
|
|
64
|
+
parts.append("and %d more" % (len(errors) - 5))
|
|
65
|
+
return "%s: %s" % (tool, "; ".join(parts))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _check_name(name):
|
|
69
|
+
"""Refuse a file name that is not one plain component, so files and output stay in the run's directory."""
|
|
70
|
+
if (not isinstance(name, str) or name in ("", ".", "..") or "/" in name or "\\" in name
|
|
71
|
+
or "\0" in name or name.startswith("-")):
|
|
72
|
+
raise ValueError("documentdriver.run: file name %r must be a plain file name" % (name,))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _stdin_bytes(stdin):
|
|
76
|
+
"""The bytes to feed on stdin: str as UTF-8, bytes as given, dict or list as compact JSON."""
|
|
77
|
+
if isinstance(stdin, (bytes, bytearray, memoryview)):
|
|
78
|
+
return bytes(stdin)
|
|
79
|
+
if isinstance(stdin, str):
|
|
80
|
+
return stdin.encode("utf-8")
|
|
81
|
+
if isinstance(stdin, (dict, list)):
|
|
82
|
+
return json.dumps(stdin, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
|
|
83
|
+
raise TypeError("documentdriver.run: stdin must be str, bytes, dict or list, not %s" % type(stdin).__name__)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _read_capped(path, cap, tool, stream):
|
|
87
|
+
"""The file's bytes, or RuntimeError when it is larger than cap."""
|
|
88
|
+
if os.path.getsize(path) > cap:
|
|
89
|
+
raise RuntimeError("%s: %s is larger than its %d-byte limit" % (tool, stream, cap))
|
|
90
|
+
with open(path, "rb") as f:
|
|
91
|
+
return f.read()
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _failure(tool, code, stderr):
|
|
95
|
+
"""The exception for a non-zero exit: EngineError when stderr is the contract's errors object."""
|
|
96
|
+
snippet = stderr.decode("utf-8", "replace")[:300]
|
|
97
|
+
if code in (1, 2):
|
|
98
|
+
try:
|
|
99
|
+
payload = json.loads(stderr.decode("utf-8"))
|
|
100
|
+
except ValueError:
|
|
101
|
+
payload = None
|
|
102
|
+
errors = payload.get("errors") if isinstance(payload, dict) else None
|
|
103
|
+
if (isinstance(errors, list) and errors
|
|
104
|
+
and all(isinstance(e, dict) and "code" in e and "message" in e for e in errors)):
|
|
105
|
+
return EngineError(tool, errors, code)
|
|
106
|
+
return RuntimeError("%s: exit %d: %s" % (tool, code, snippet))
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def run(tool, args, files=None, *, stdin=None, output=None, parse=True,
|
|
110
|
+
timeout=DEFAULT_TIMEOUT, stdout_cap=STDOUT_CAP, stderr_cap=STDERR_CAP):
|
|
111
|
+
"""Run the bundled binary `tool` once with `args` and return a Run(result, output).
|
|
112
|
+
|
|
113
|
+
Each call gets a new private directory (mode 0700, removed on every
|
|
114
|
+
path) that is the binary's working directory. `files` maps plain file
|
|
115
|
+
names to bytes (or str, written as UTF-8); they are written there first
|
|
116
|
+
and `args` name them, e.g. run("docx", ["read", "in.docx"], {"in.docx": data}).
|
|
117
|
+
`stdin` (str, bytes, or a dict or list sent as JSON) feeds a `-`
|
|
118
|
+
argument, the way a plan or HTML is given without a file; without it
|
|
119
|
+
stdin is empty. `output` names a file the command writes (its `-o`);
|
|
120
|
+
its bytes come back in Run.output.
|
|
121
|
+
|
|
122
|
+
The binary runs from argv (no shell) with an empty environment; stdout
|
|
123
|
+
and stderr go to files in the directory, so a large result cannot
|
|
124
|
+
deadlock a pipe. With exit 0, Run.result is the parsed JSON object
|
|
125
|
+
(parse=False: the stdout text, for svg, xml and help output).
|
|
126
|
+
|
|
127
|
+
Raises EngineError for the contract's errors object (exit 1 or 2),
|
|
128
|
+
RuntimeError when the binary runs past `timeout` seconds (it is
|
|
129
|
+
killed), writes more than stdout_cap or stderr_cap bytes, prints
|
|
130
|
+
something the contract does not allow, or cannot be started, and
|
|
131
|
+
ValueError for a bad file name or tool name.
|
|
132
|
+
"""
|
|
133
|
+
from . import binary # late: __init__ imports this module
|
|
134
|
+
|
|
135
|
+
exe = binary(tool)
|
|
136
|
+
args = [str(a) for a in args]
|
|
137
|
+
files = files or {}
|
|
138
|
+
for name in files:
|
|
139
|
+
_check_name(name)
|
|
140
|
+
if output is not None:
|
|
141
|
+
_check_name(output)
|
|
142
|
+
data_in = _stdin_bytes(stdin) if stdin is not None else None
|
|
143
|
+
|
|
144
|
+
with tempfile.TemporaryDirectory(prefix="documentdriver-") as private:
|
|
145
|
+
directory = os.path.join(private, "work") # the binary's cwd; stdout and stderr stay outside it
|
|
146
|
+
os.mkdir(directory, 0o700)
|
|
147
|
+
for name, data in files.items():
|
|
148
|
+
with open(os.path.join(directory, name), "wb") as f:
|
|
149
|
+
f.write(data.encode("utf-8") if isinstance(data, str) else bytes(data))
|
|
150
|
+
out_path = os.path.join(private, "stdout")
|
|
151
|
+
err_path = os.path.join(private, "stderr")
|
|
152
|
+
with open(out_path, "wb") as out_f, open(err_path, "wb") as err_f:
|
|
153
|
+
try:
|
|
154
|
+
completed = subprocess.run(
|
|
155
|
+
[exe] + args, cwd=directory, env={},
|
|
156
|
+
input=data_in, stdin=None if data_in is not None else subprocess.DEVNULL,
|
|
157
|
+
stdout=out_f, stderr=err_f, timeout=timeout)
|
|
158
|
+
except subprocess.TimeoutExpired:
|
|
159
|
+
raise RuntimeError("%s: ran past its %g s limit" % (tool, timeout)) from None
|
|
160
|
+
except OSError as error:
|
|
161
|
+
raise RuntimeError("%s: cannot run the binary: %s" % (tool, error)) from None
|
|
162
|
+
stdout = _read_capped(out_path, stdout_cap, tool, "stdout")
|
|
163
|
+
stderr = _read_capped(err_path, stderr_cap, tool, "stderr")
|
|
164
|
+
if completed.returncode != 0:
|
|
165
|
+
raise _failure(tool, completed.returncode, stderr)
|
|
166
|
+
if parse:
|
|
167
|
+
try:
|
|
168
|
+
result = json.loads(stdout.decode("utf-8"))
|
|
169
|
+
except ValueError:
|
|
170
|
+
raise RuntimeError("%s: output is not JSON: %s" % (tool, stdout[:300].decode("utf-8", "replace"))) from None
|
|
171
|
+
if not isinstance(result, dict):
|
|
172
|
+
raise RuntimeError("%s: output is not a JSON object" % tool)
|
|
173
|
+
else:
|
|
174
|
+
result = stdout.decode("utf-8", "replace")
|
|
175
|
+
produced = None
|
|
176
|
+
if output is not None:
|
|
177
|
+
path = os.path.join(directory, output)
|
|
178
|
+
if os.path.isfile(path):
|
|
179
|
+
with open(path, "rb") as f:
|
|
180
|
+
produced = f.read()
|
|
181
|
+
return Run(result, produced)
|
documentdriver/bin/docx
ADDED
|
Binary file
|
documentdriver/bin/pptx
ADDED
|
Binary file
|
documentdriver/bin/xlsx
ADDED
|
Binary file
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: documentdriver
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Read and edit Word, PowerPoint and Excel files from agents: the docx, pptx and xlsx CLIs as static binaries
|
|
5
|
+
Keywords: docx,pptx,xlsx,ooxml,office,agents
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Project-URL: Source, https://github.com/jhnoel/documentdriver
|
|
9
|
+
Project-URL: Contract, https://github.com/jhnoel/documentdriver/blob/main/docs/contract.md
|
|
10
|
+
Project-URL: Releasing, https://github.com/jhnoel/documentdriver/blob/main/RELEASING.md
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: MacOS
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Topic :: Office/Business
|
|
17
|
+
Classifier: Topic :: Text Processing :: Markup :: XML
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# documentdriver
|
|
22
|
+
|
|
23
|
+
The docx, pptx and xlsx command-line tools of documentdriver for one platform:
|
|
24
|
+
static binaries (no cgo, no libc) that read and edit Office documents for
|
|
25
|
+
agents, with one JSON result or one errors object per call. Wheels exist
|
|
26
|
+
for linux x86_64 and aarch64 (glibc and musl) and macOS arm64.
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import documentdriver
|
|
30
|
+
|
|
31
|
+
with open("report.docx", "rb") as f:
|
|
32
|
+
data = f.read()
|
|
33
|
+
facts, _ = documentdriver.run("docx", ["read", "in.docx"], {"in.docx": data})
|
|
34
|
+
plan = {"ops": [...]} # see `docx help ops`
|
|
35
|
+
result, out = documentdriver.run("docx", ["apply", "in.docx", "-", "-o", "out.docx"],
|
|
36
|
+
{"in.docx": data}, stdin=plan, output="out.docx")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`run()` makes one call in a private directory and returns the parsed
|
|
40
|
+
result and the output file's bytes, or raises `EngineError` with the
|
|
41
|
+
contract's errors (`code`, `path`, `message`, `hint`).
|
|
42
|
+
`binary(name)` returns the bundled binary's path after checking it against
|
|
43
|
+
the SHA-256 recorded when the wheel was built, to run it yourself.
|
|
44
|
+
|
|
45
|
+
Commands, plans, results and errors: [the agent contract](https://github.com/jhnoel/documentdriver/blob/main/docs/contract.md).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
documentdriver/__init__.py,sha256=zZp5MCajORhoC3PMdr7bmmC6DNXgmUDYq_6Er_I1q40,2535
|
|
2
|
+
documentdriver/_digests.py,sha256=Mf_AL2KRTHCwEAe4c3yCcASwUPg-WFiKbk-ht4S6Fyo,340
|
|
3
|
+
documentdriver/_run.py,sha256=uVXmSpRc4AResM5xwx7Kqq0hV-J7jYbeGaHj1zgA2js,8100
|
|
4
|
+
documentdriver/bin/docx,sha256=quE_Evl3oTTd2BguiQwr_g8ps7SG1V66ZoVz0HVx9f4,8288146
|
|
5
|
+
documentdriver/bin/pptx,sha256=dBrGmdYXr0rprbV7j0zHUdWxtpLQk7eY1Hk0DoA8w8Y,6782898
|
|
6
|
+
documentdriver/bin/xlsx,sha256=mdFAETnxH_hfN7kRpRokp8BStu-HGmq6MavvLLrmuv0,6468770
|
|
7
|
+
documentdriver-0.2.0.dist-info/METADATA,sha256=mVd-G3gBzycdH2SN95O3f06Hqllc8FXzUEgUW4at46k,2049
|
|
8
|
+
documentdriver-0.2.0.dist-info/WHEEL,sha256=BztZh_kPMG9VFmlZM0XDcKDo4CUCGCehlcy6ftxNeeI,114
|
|
9
|
+
documentdriver-0.2.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
10
|
+
documentdriver-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|