rbx.cp 0.5.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.
Files changed (164) hide show
  1. rbx/__init__.py +0 -0
  2. rbx/annotations.py +127 -0
  3. rbx/autoenum.py +333 -0
  4. rbx/box/__init__.py +0 -0
  5. rbx/box/builder.py +77 -0
  6. rbx/box/cd.py +37 -0
  7. rbx/box/checkers.py +134 -0
  8. rbx/box/code.py +185 -0
  9. rbx/box/compile.py +56 -0
  10. rbx/box/conftest.py +42 -0
  11. rbx/box/contest/__init__.py +0 -0
  12. rbx/box/contest/build_contest_statements.py +347 -0
  13. rbx/box/contest/contest_package.py +76 -0
  14. rbx/box/contest/contest_utils.py +20 -0
  15. rbx/box/contest/main.py +179 -0
  16. rbx/box/contest/schema.py +155 -0
  17. rbx/box/contest/statements.py +82 -0
  18. rbx/box/creation.py +72 -0
  19. rbx/box/download.py +64 -0
  20. rbx/box/environment.py +345 -0
  21. rbx/box/extensions.py +26 -0
  22. rbx/box/generators.py +478 -0
  23. rbx/box/generators_test.py +63 -0
  24. rbx/box/main.py +449 -0
  25. rbx/box/package.py +316 -0
  26. rbx/box/packaging/boca/extension.py +27 -0
  27. rbx/box/packaging/boca/packager.py +245 -0
  28. rbx/box/packaging/contest_main.py +82 -0
  29. rbx/box/packaging/main.py +68 -0
  30. rbx/box/packaging/packager.py +117 -0
  31. rbx/box/packaging/polygon/packager.py +320 -0
  32. rbx/box/packaging/polygon/test.py +81 -0
  33. rbx/box/packaging/polygon/xml_schema.py +106 -0
  34. rbx/box/presets/__init__.py +503 -0
  35. rbx/box/presets/fetch.py +70 -0
  36. rbx/box/presets/lock_schema.py +20 -0
  37. rbx/box/presets/schema.py +59 -0
  38. rbx/box/schema.py +394 -0
  39. rbx/box/solutions.py +792 -0
  40. rbx/box/solutions_test.py +41 -0
  41. rbx/box/statements/__init__.py +0 -0
  42. rbx/box/statements/build_statements.py +359 -0
  43. rbx/box/statements/builders.py +375 -0
  44. rbx/box/statements/joiners.py +113 -0
  45. rbx/box/statements/latex.py +47 -0
  46. rbx/box/statements/latex_jinja.py +214 -0
  47. rbx/box/statements/schema.py +138 -0
  48. rbx/box/stresses.py +292 -0
  49. rbx/box/stressing/__init__.py +0 -0
  50. rbx/box/stressing/finder_parser.py +359 -0
  51. rbx/box/stressing/generator_parser.py +258 -0
  52. rbx/box/testcases.py +54 -0
  53. rbx/box/ui/__init__.py +0 -0
  54. rbx/box/ui/captured_log.py +372 -0
  55. rbx/box/ui/css/app.tcss +48 -0
  56. rbx/box/ui/main.py +38 -0
  57. rbx/box/ui/run.py +209 -0
  58. rbx/box/validators.py +245 -0
  59. rbx/box/validators_test.py +15 -0
  60. rbx/checker.py +128 -0
  61. rbx/clone.py +197 -0
  62. rbx/config.py +271 -0
  63. rbx/conftest.py +38 -0
  64. rbx/console.py +27 -0
  65. rbx/create.py +37 -0
  66. rbx/edit.py +24 -0
  67. rbx/grading/__init__.py +0 -0
  68. rbx/grading/caching.py +356 -0
  69. rbx/grading/conftest.py +33 -0
  70. rbx/grading/judge/__init__.py +0 -0
  71. rbx/grading/judge/cacher.py +503 -0
  72. rbx/grading/judge/digester.py +35 -0
  73. rbx/grading/judge/sandbox.py +748 -0
  74. rbx/grading/judge/sandboxes/__init__.py +0 -0
  75. rbx/grading/judge/sandboxes/isolate.py +683 -0
  76. rbx/grading/judge/sandboxes/stupid_sandbox.py +310 -0
  77. rbx/grading/judge/sandboxes/timeit.py +217 -0
  78. rbx/grading/judge/storage.py +284 -0
  79. rbx/grading/judge/test.py +38 -0
  80. rbx/grading/judge/testiso.py +54 -0
  81. rbx/grading/steps.py +522 -0
  82. rbx/grading/steps_with_caching.py +59 -0
  83. rbx/grading/steps_with_caching_run_test.py +429 -0
  84. rbx/grading_utils.py +148 -0
  85. rbx/hydration.py +101 -0
  86. rbx/main.py +122 -0
  87. rbx/metadata.py +105 -0
  88. rbx/providers/__init__.py +43 -0
  89. rbx/providers/codeforces.py +73 -0
  90. rbx/providers/provider.py +26 -0
  91. rbx/resources/checkers/boilerplate.cpp +20 -0
  92. rbx/resources/default_config.json +48 -0
  93. rbx/resources/envs/default.rbx.yml +37 -0
  94. rbx/resources/envs/isolate.rbx.yml +37 -0
  95. rbx/resources/packagers/boca/checker.sh +43 -0
  96. rbx/resources/packagers/boca/compare +53 -0
  97. rbx/resources/packagers/boca/compile/c +172 -0
  98. rbx/resources/packagers/boca/compile/cc +173 -0
  99. rbx/resources/packagers/boca/compile/cpp +172 -0
  100. rbx/resources/packagers/boca/compile/java +194 -0
  101. rbx/resources/packagers/boca/compile/kt +155 -0
  102. rbx/resources/packagers/boca/compile/pas +172 -0
  103. rbx/resources/packagers/boca/compile/py2 +173 -0
  104. rbx/resources/packagers/boca/compile/py3 +173 -0
  105. rbx/resources/packagers/boca/run/c +128 -0
  106. rbx/resources/packagers/boca/run/cc +128 -0
  107. rbx/resources/packagers/boca/run/cpp +128 -0
  108. rbx/resources/packagers/boca/run/java +194 -0
  109. rbx/resources/packagers/boca/run/kt +159 -0
  110. rbx/resources/packagers/boca/run/py2 +166 -0
  111. rbx/resources/packagers/boca/run/py3 +166 -0
  112. rbx/resources/presets/default/contest/contest.rbx.yml +14 -0
  113. rbx/resources/presets/default/contest/statement/contest.rbx.tex +97 -0
  114. rbx/resources/presets/default/contest/statement/olymp.sty +250 -0
  115. rbx/resources/presets/default/contest/statement/template.rbx.tex +42 -0
  116. rbx/resources/presets/default/preset.rbx.yml +12 -0
  117. rbx/resources/presets/default/problem/.gitignore +6 -0
  118. rbx/resources/presets/default/problem/gen.cpp +9 -0
  119. rbx/resources/presets/default/problem/problem.rbx.yml +44 -0
  120. rbx/resources/presets/default/problem/random.py +3 -0
  121. rbx/resources/presets/default/problem/random.txt +2 -0
  122. rbx/resources/presets/default/problem/sols/main.cpp +9 -0
  123. rbx/resources/presets/default/problem/sols/slow.cpp +15 -0
  124. rbx/resources/presets/default/problem/sols/wa.cpp +9 -0
  125. rbx/resources/presets/default/problem/statement/olymp.sty +250 -0
  126. rbx/resources/presets/default/problem/statement/projecao.png +0 -0
  127. rbx/resources/presets/default/problem/statement/statement.rbx.tex +18 -0
  128. rbx/resources/presets/default/problem/statement/template.rbx.tex +89 -0
  129. rbx/resources/presets/default/problem/tests/samples/000.in +1 -0
  130. rbx/resources/presets/default/problem/tests/samples/001.in +1 -0
  131. rbx/resources/presets/default/problem/validator.cpp +16 -0
  132. rbx/resources/presets/default/problem/wcmp.cpp +34 -0
  133. rbx/resources/templates/template.cpp +19 -0
  134. rbx/run.py +45 -0
  135. rbx/schema.py +64 -0
  136. rbx/submit.py +61 -0
  137. rbx/submitors/__init__.py +18 -0
  138. rbx/submitors/codeforces.py +120 -0
  139. rbx/submitors/submitor.py +25 -0
  140. rbx/test.py +347 -0
  141. rbx/testcase.py +70 -0
  142. rbx/testcase_rendering.py +79 -0
  143. rbx/testdata/box1/gen1.cpp +7 -0
  144. rbx/testdata/box1/gen2.cpp +9 -0
  145. rbx/testdata/box1/genScript.py +2 -0
  146. rbx/testdata/box1/hard-tle.sol.cpp +26 -0
  147. rbx/testdata/box1/ole.cpp +17 -0
  148. rbx/testdata/box1/problem.rbx.yml +39 -0
  149. rbx/testdata/box1/re.sol.cpp +23 -0
  150. rbx/testdata/box1/sol.cpp +22 -0
  151. rbx/testdata/box1/tests/1.in +1 -0
  152. rbx/testdata/box1/tle-and-incorrect.sol.cpp +33 -0
  153. rbx/testdata/box1/tle.sol.cpp +35 -0
  154. rbx/testdata/box1/validator.cpp +11 -0
  155. rbx/testdata/box1/wa.sol.cpp +22 -0
  156. rbx/testdata/caching/executable.py +1 -0
  157. rbx/testdata/compatible +0 -0
  158. rbx/testing_utils.py +65 -0
  159. rbx/utils.py +162 -0
  160. rbx_cp-0.5.0.dist-info/LICENSE +201 -0
  161. rbx_cp-0.5.0.dist-info/METADATA +89 -0
  162. rbx_cp-0.5.0.dist-info/RECORD +164 -0
  163. rbx_cp-0.5.0.dist-info/WHEEL +4 -0
  164. rbx_cp-0.5.0.dist-info/entry_points.txt +4 -0
@@ -0,0 +1,17 @@
1
+
2
+ #include <bits/stdc++.h>
3
+
4
+ using namespace std;
5
+
6
+ int32_t main() {
7
+ ios::sync_with_stdio(false);
8
+ cin.tie(0);
9
+
10
+ int n;
11
+ cin >> n;
12
+
13
+ for (int i = 1; i <= 100000; i++) { // more than output limit of 100kb
14
+ cout << 123456 << "\n";
15
+ }
16
+ return 0;
17
+ }
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: "test-problem"
3
+ timeLimit: 1000
4
+ memoryLimit: 256
5
+ outputLimit: 100 # 100 kb
6
+ generators:
7
+ - name: "gen1"
8
+ path: "gen1.cpp"
9
+ - name: "gen2"
10
+ path: "gen2.cpp"
11
+ validator:
12
+ path: "validator.cpp"
13
+ testcases:
14
+ - name: "gen1"
15
+ testcaseGlob: "tests/*.in"
16
+ subgroups:
17
+ - name: "gen"
18
+ generators:
19
+ - name: "gen1"
20
+ - name: "gen2"
21
+ args: "424242"
22
+ - name: "genScript"
23
+ generatorScript:
24
+ path: "genScript.py"
25
+ solutions:
26
+ - path: "sol.cpp"
27
+ outcome: "ac"
28
+ - path: "wa.sol.cpp"
29
+ outcome: "fail"
30
+ - path: "re.sol.cpp"
31
+ outcome: "rte"
32
+ - path: "tle.sol.cpp"
33
+ outcome: "tle"
34
+ - path: "tle-and-incorrect.sol.cpp"
35
+ outcome: "tle"
36
+ - path: "hard-tle.sol.cpp"
37
+ outcome: "tle"
38
+ - path: "ole.cpp"
39
+ outcome: "ole"
@@ -0,0 +1,23 @@
1
+ #include <bits/stdc++.h>
2
+
3
+ using namespace std;
4
+
5
+ int32_t main() {
6
+ ios::sync_with_stdio(false);
7
+ cin.tie(0);
8
+
9
+ int n; cin >> n;
10
+
11
+ vector<int> divisors;
12
+ assert(false);
13
+ for(int i = 0; i*i <= n; i++) {
14
+ if (n % i == 0) {
15
+ divisors.push_back(i);
16
+ divisors.push_back(n/i);
17
+ }
18
+ }
19
+
20
+ sort(divisors.begin(), divisors.end());
21
+ for (int x : divisors) cout << x << '\n';
22
+ return 0;
23
+ }
@@ -0,0 +1,22 @@
1
+ #include <bits/stdc++.h>
2
+
3
+ using namespace std;
4
+
5
+ int32_t main() {
6
+ ios::sync_with_stdio(false);
7
+ cin.tie(0);
8
+
9
+ int n; cin >> n;
10
+
11
+ vector<int> divisors;
12
+ for(int i = 1; i*i <= n; i++) {
13
+ if (n % i == 0) {
14
+ divisors.push_back(i);
15
+ if (i != n/i) divisors.push_back(n/i);
16
+ }
17
+ }
18
+
19
+ sort(divisors.begin(), divisors.end());
20
+ for (int x : divisors) cout << x << '\n';
21
+ return 0;
22
+ }
@@ -0,0 +1 @@
1
+ 777
@@ -0,0 +1,33 @@
1
+ #include <bits/stdc++.h>
2
+ #include <ctime>
3
+
4
+ using namespace std;
5
+
6
+ void busy_loop() {
7
+ double wait = 1.0;
8
+ int start = clock();
9
+ int end = clock();
10
+ while (((double) (end - start)) / CLOCKS_PER_SEC < wait)
11
+ {
12
+ end = clock();
13
+ }
14
+ }
15
+
16
+ int32_t main() {
17
+ ios::sync_with_stdio(false);
18
+ cin.tie(0);
19
+
20
+ int n; cin >> n;
21
+ busy_loop();
22
+
23
+ vector<int> divisors;
24
+ for(int i = 1; i*i <= n; i++) {
25
+ if (n % i == 0) {
26
+ divisors.push_back(i);
27
+ }
28
+ }
29
+
30
+ sort(divisors.begin(), divisors.end());
31
+ for (int x : divisors) cout << x << '\n';
32
+ return 0;
33
+ }
@@ -0,0 +1,35 @@
1
+ #include <bits/stdc++.h>
2
+ #include <ctime>
3
+
4
+ using namespace std;
5
+
6
+ void busy_loop() {
7
+ double wait = 1.0;
8
+ int start = clock();
9
+ int end = clock();
10
+ while (((double) (end - start)) / CLOCKS_PER_SEC < wait)
11
+ {
12
+ end = clock();
13
+ }
14
+ }
15
+
16
+ int32_t main() {
17
+ ios::sync_with_stdio(false);
18
+ cin.tie(0);
19
+
20
+ int n; cin >> n;
21
+
22
+ busy_loop();
23
+
24
+ vector<int> divisors;
25
+ for(int i = 1; i*i <= n; i++) {
26
+ if (n % i == 0) {
27
+ divisors.push_back(i);
28
+ if (i != n/i) divisors.push_back(n/i);
29
+ }
30
+ }
31
+
32
+ sort(divisors.begin(), divisors.end());
33
+ for (int x : divisors) cout << x << '\n';
34
+ return 0;
35
+ }
@@ -0,0 +1,11 @@
1
+ #include "testlib.h"
2
+
3
+ using namespace std;
4
+
5
+ int main(int argc, char *argv[]) {
6
+ registerValidation(argc, argv);
7
+
8
+ inf.readInt(1, 1'000'000'000, "n");
9
+ inf.readEoln();
10
+ inf.readEof();
11
+ }
@@ -0,0 +1,22 @@
1
+ #include <bits/stdc++.h>
2
+
3
+ using namespace std;
4
+
5
+ int32_t main() {
6
+ ios::sync_with_stdio(false);
7
+ cin.tie(0);
8
+
9
+ int n; cin >> n;
10
+
11
+ vector<int> divisors;
12
+ for(int i = 1; i*i <= n; i++) {
13
+ if (n % i == 0) {
14
+ divisors.push_back(i);
15
+ divisors.push_back(n/i);
16
+ }
17
+ }
18
+
19
+ sort(divisors.begin(), divisors.end());
20
+ for (int x : divisors) cout << x << '\n';
21
+ return 0;
22
+ }
@@ -0,0 +1 @@
1
+ print(42)
File without changes
rbx/testing_utils.py ADDED
@@ -0,0 +1,65 @@
1
+ import importlib
2
+ import importlib.resources
3
+ import pathlib
4
+
5
+ import rich.markup
6
+ import rich.text
7
+ import rich.tree
8
+ from rich.filesize import decimal
9
+
10
+ from rbx import console
11
+
12
+
13
+ def get_testdata_path() -> pathlib.Path:
14
+ with importlib.resources.as_file(
15
+ importlib.resources.files('rbx') / 'testdata' / 'compatible'
16
+ ) as file:
17
+ return file.parent
18
+
19
+
20
+ def clear_all_functools_cache():
21
+ from rbx.box import environment, package
22
+
23
+ pkgs = [environment, package]
24
+
25
+ for pkg in pkgs:
26
+ for fn in pkg.__dict__.values():
27
+ if hasattr(fn, 'cache_clear'):
28
+ fn.cache_clear()
29
+
30
+
31
+ def walk_directory(
32
+ directory: pathlib.Path, tree: rich.tree.Tree, show_hidden: bool = False
33
+ ) -> None:
34
+ """Recursively build a Tree with directory contents."""
35
+ # Sort dirs first then by filename
36
+ paths = sorted(
37
+ pathlib.Path(directory).iterdir(),
38
+ key=lambda path: (path.is_file(), path.name.lower()),
39
+ )
40
+ for path in paths:
41
+ # Remove hidden files
42
+ if path.name.startswith('.') and not show_hidden:
43
+ continue
44
+ if path.is_dir():
45
+ style = 'dim' if path.name.startswith('__') else ''
46
+ branch = tree.add(
47
+ f'[bold magenta]:open_file_folder: [link file://{path}]{rich.markup.escape(path.name)}',
48
+ style=style,
49
+ guide_style=style,
50
+ )
51
+ walk_directory(path, branch)
52
+ else:
53
+ text_filename = rich.text.Text(path.name, 'green')
54
+ text_filename.highlight_regex(r'\..*$', 'bold red')
55
+ text_filename.stylize(f'link file://{path}')
56
+ file_size = path.stat().st_size
57
+ text_filename.append(f' ({decimal(file_size)})', 'blue')
58
+ icon = '🐍 ' if path.suffix == '.py' else '📄 '
59
+ tree.add(rich.text.Text(icon) + text_filename)
60
+
61
+
62
+ def print_directory_tree(directory: pathlib.Path, show_hidden: bool = False):
63
+ tree = rich.tree.Tree(directory.name)
64
+ walk_directory(directory, tree, show_hidden=show_hidden)
65
+ console.console.print(tree)
rbx/utils.py ADDED
@@ -0,0 +1,162 @@
1
+ import contextlib
2
+ import fcntl
3
+ import json
4
+ import os
5
+ import pathlib
6
+ import resource
7
+ from typing import Any, Optional, Type, TypeVar
8
+
9
+ import rich
10
+ import rich.prompt
11
+ import rich.status
12
+ import typer
13
+ import yaml
14
+ from fastapi.encoders import jsonable_encoder
15
+ from pydantic import BaseModel
16
+ from rich import text
17
+ from rich.highlighter import JSONHighlighter
18
+
19
+ from rbx.console import console
20
+
21
+ T = TypeVar('T', bound=BaseModel)
22
+ APP_NAME = 'rbx'
23
+
24
+
25
+ def create_and_write(path: pathlib.Path, *args, **kwargs):
26
+ path.parent.mkdir(parents=True, exist_ok=True)
27
+ path.write_text(*args, **kwargs)
28
+
29
+
30
+ def highlight_str(s: str) -> text.Text:
31
+ txt = text.Text(s)
32
+ JSONHighlighter().highlight(txt)
33
+ return txt
34
+
35
+
36
+ def highlight_json_obj(obj: Any) -> text.Text:
37
+ js = json.dumps(obj)
38
+ return highlight_str(js)
39
+
40
+
41
+ def normalize_with_underscores(s: str) -> str:
42
+ res = s.replace(' ', '_').replace('.', '_').strip('_')
43
+ final = []
44
+
45
+ last = ''
46
+ for c in res:
47
+ if c == '_' and last == c:
48
+ continue
49
+ last = c
50
+ final.append(c)
51
+ return ''.join(final)
52
+
53
+
54
+ def get_app_path() -> pathlib.Path:
55
+ app_dir = typer.get_app_dir(APP_NAME)
56
+ return pathlib.Path(app_dir)
57
+
58
+
59
+ def ensure_schema(model: Type[BaseModel]) -> pathlib.Path:
60
+ path = get_app_path() / 'schemas' / f'{model.__name__}.json'
61
+ path.parent.mkdir(parents=True, exist_ok=True)
62
+ schema = json.dumps(model.model_json_schema(), indent=4)
63
+ path.write_text(schema)
64
+ return path.resolve()
65
+
66
+
67
+ def model_json(model: BaseModel) -> str:
68
+ ensure_schema(model.__class__)
69
+ return model.model_dump_json(indent=4, exclude_unset=True, exclude_none=True)
70
+
71
+
72
+ def model_to_yaml(model: BaseModel) -> str:
73
+ path = ensure_schema(model.__class__)
74
+ return f'# yaml-language-server: $schema={path}\n\n' + yaml.dump(
75
+ jsonable_encoder(
76
+ model.model_dump(mode='json', exclude_unset=True, exclude_none=True)
77
+ ),
78
+ sort_keys=False,
79
+ )
80
+
81
+
82
+ def model_from_yaml(model: Type[T], s: str) -> T:
83
+ ensure_schema(model)
84
+ return model(**yaml.safe_load(s))
85
+
86
+
87
+ def validate_field(model: Type[T], field: str, value: Any):
88
+ model.__pydantic_validator__.validate_assignment(
89
+ model.model_construct(), field, value
90
+ )
91
+
92
+
93
+ def confirm_on_status(status: Optional[rich.status.Status], *args, **kwargs) -> bool:
94
+ if status:
95
+ status.stop()
96
+ res = rich.prompt.Confirm.ask(*args, **kwargs, console=console)
97
+ if status:
98
+ status.start()
99
+ return res
100
+
101
+
102
+ def get_open_fds():
103
+ fds = []
104
+ soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
105
+ for fd in range(0, soft):
106
+ try:
107
+ fcntl.fcntl(fd, fcntl.F_GETFD)
108
+ except IOError:
109
+ continue
110
+ fds.append(fd)
111
+ return fds
112
+
113
+
114
+ @contextlib.contextmanager
115
+ def new_cd(x):
116
+ d = os.getcwd()
117
+
118
+ # This could raise an exception, but it's probably
119
+ # best to let it propagate and let the caller
120
+ # deal with it, since they requested x
121
+ os.chdir(x)
122
+
123
+ try:
124
+ yield
125
+
126
+ finally:
127
+ # This could also raise an exception, but you *really*
128
+ # aren't equipped to figure out what went wrong if the
129
+ # old working directory can't be restored.
130
+ os.chdir(d)
131
+
132
+
133
+ class StatusProgress(rich.status.Status):
134
+ _message: str
135
+ processed: int
136
+ keep: bool
137
+
138
+ def __init__(
139
+ self, message: str, formatted_message: Optional[str] = None, keep: bool = False
140
+ ):
141
+ self._message = formatted_message or message
142
+ self.keep = keep
143
+ self.processed = 0
144
+ super().__init__(message.format(processed=0), console=console)
145
+ self.start()
146
+
147
+ def __enter__(self):
148
+ super().__enter__()
149
+ return self
150
+
151
+ def __exit__(self, *args, **kwargs):
152
+ super().__exit__(*args, **kwargs)
153
+ if self.keep:
154
+ console.print(self._message.format(processed=self.processed))
155
+
156
+ def update_with_progress(self, processed: int):
157
+ self.processed = processed
158
+ self.update(self._message.format(processed=processed))
159
+
160
+ def step(self, delta: int = 1):
161
+ self.processed += delta
162
+ self.update_with_progress(self.processed)
@@ -0,0 +1,201 @@
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,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.