robotcode-repl 0.93.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,3 @@
1
+ from .repl import Repl
2
+
3
+ __all__ = ["Repl"]
@@ -0,0 +1,18 @@
1
+ import sys
2
+ from typing import List
3
+
4
+ from ..__version__ import __version__
5
+
6
+
7
+ class Repl:
8
+ ROBOT_LIBRARY_SCOPE = "GLOBAL"
9
+ ROBOT_LIBRARY_VERSION = __version__
10
+
11
+ def repl(self) -> None:
12
+ pass
13
+
14
+ def exit(self, exit_code: int = 0) -> None:
15
+ sys.exit(exit_code)
16
+
17
+ def keywords(self) -> List[str]:
18
+ return ["repl", "exit"]
File without changes
@@ -0,0 +1 @@
1
+ __version__ = "0.93.0"
@@ -0,0 +1,3 @@
1
+ from .repl import repl
2
+
3
+ __all__ = ["repl"]
@@ -0,0 +1,169 @@
1
+ import io
2
+ import sys
3
+ from pathlib import Path
4
+ from typing import Optional, Tuple
5
+
6
+ import click
7
+ from robot.api import TestSuite, get_model
8
+ from robot.conf import RobotSettings
9
+ from robot.errors import DATA_ERROR, INFO_PRINTED, DataError, Information
10
+ from robot.output import LOGGER
11
+
12
+ from robotcode.plugin import (
13
+ Application,
14
+ pass_application,
15
+ )
16
+ from robotcode.plugin.click_helper.aliases import AliasedCommand
17
+ from robotcode.robot.utils import get_robot_version
18
+ from robotcode.runner.cli.robot import RobotFrameworkEx, handle_robot_options
19
+
20
+ from ..interpreter import Interpreter
21
+ from ..repl_listener import ReplListener
22
+
23
+ REPL_SUITE = """\
24
+ *** Settings ***
25
+ Library robotcode.repl.Repl
26
+ *** Test Cases ***
27
+ RobotCode REPL
28
+ repl
29
+ """
30
+
31
+
32
+ def run_repl(
33
+ app: Application,
34
+ inspect: bool,
35
+ variable: Tuple[str, ...],
36
+ variablefile: Tuple[str, ...],
37
+ pythonpath: Tuple[str, ...],
38
+ outputdir: Optional[str],
39
+ paths: Tuple[Path, ...],
40
+ ) -> None:
41
+ robot_options_and_args: Tuple[str, ...] = ()
42
+
43
+ for var in variable:
44
+ robot_options_and_args += ("--variable", var)
45
+ for varfile in variablefile:
46
+ robot_options_and_args += ("--variablefile", varfile)
47
+ for pypath in pythonpath:
48
+ robot_options_and_args += ("--pythonpath", pypath)
49
+ if outputdir:
50
+ robot_options_and_args += ("--outputdir", outputdir)
51
+
52
+ root_folder, profile, cmd_options = handle_robot_options(app, robot_options_and_args)
53
+
54
+ try:
55
+
56
+ options, arguments = RobotFrameworkEx(
57
+ app,
58
+ (
59
+ [*(app.config.default_paths if app.config.default_paths else ())]
60
+ if profile.paths is None
61
+ else profile.paths if isinstance(profile.paths, list) else [profile.paths]
62
+ ),
63
+ app.config.dry,
64
+ root_folder,
65
+ ).parse_arguments((*cmd_options, *robot_options_and_args))
66
+
67
+ settings = RobotSettings(
68
+ options,
69
+ output=None,
70
+ log=None,
71
+ report=None,
72
+ quiet=True,
73
+ listener=[
74
+ ReplListener(app, Interpreter(app, files=list(paths), inspect=inspect)),
75
+ ],
76
+ )
77
+
78
+ if app.show_diagnostics:
79
+ LOGGER.register_console_logger(**settings.console_output_config)
80
+ else:
81
+ LOGGER.unregister_console_logger()
82
+
83
+ LOGGER.unregister_console_logger()
84
+
85
+ if get_robot_version() >= (5, 0):
86
+ if settings.pythonpath:
87
+ sys.path = settings.pythonpath + sys.path
88
+
89
+ with io.StringIO(REPL_SUITE) as output:
90
+ model = get_model(output)
91
+
92
+ suite = TestSuite.from_model(model)
93
+ suite.configure(**settings.suite_config)
94
+ suite.run(settings)
95
+
96
+ except Information as err:
97
+ app.echo(str(err))
98
+ app.exit(INFO_PRINTED)
99
+ except DataError as err:
100
+ app.error(str(err))
101
+ app.exit(DATA_ERROR)
102
+
103
+
104
+ @click.command(
105
+ cls=AliasedCommand,
106
+ aliases=["shell"],
107
+ context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
108
+ add_help_option=True,
109
+ )
110
+ @click.option(
111
+ "-v",
112
+ "--variable",
113
+ metavar="name:value",
114
+ type=str,
115
+ multiple=True,
116
+ help="Set variables in the test data. see `robot --variable` option.",
117
+ )
118
+ @click.option(
119
+ "-V",
120
+ "--variablefile",
121
+ metavar="path",
122
+ type=str,
123
+ multiple=True,
124
+ help="Python or YAML file file to read variables from. see `robot --variablefile` option.",
125
+ )
126
+ @click.option(
127
+ "-P",
128
+ "--pythonpath",
129
+ metavar="path",
130
+ type=str,
131
+ multiple=True,
132
+ help="Additional locations (directories, ZIPs, JARs) where to search test libraries"
133
+ " and other extensions when they are imported. see `robot --pythonpath` option.",
134
+ )
135
+ @click.option(
136
+ "-d",
137
+ "--outputdir",
138
+ metavar="dir",
139
+ type=str,
140
+ help="Where to create output files. see `robot --outputdir` option.",
141
+ )
142
+ @click.option(
143
+ "-i",
144
+ "--inspect",
145
+ is_flag=True,
146
+ default=False,
147
+ help="Activate inspection mode. This forces a prompt to appear after the REPL script is executed.",
148
+ )
149
+ @click.argument(
150
+ "paths",
151
+ type=click.Path(exists=True, path_type=Path),
152
+ nargs=-1,
153
+ required=False,
154
+ )
155
+ @pass_application
156
+ def repl(
157
+ app: Application,
158
+ variable: Tuple[str, ...],
159
+ variablefile: Tuple[str, ...],
160
+ pythonpath: Tuple[str, ...],
161
+ outputdir: Optional[str],
162
+ inspect: bool,
163
+ paths: Tuple[Path, ...],
164
+ ) -> None:
165
+ """\
166
+ Run Robot Framework interactively.
167
+ """
168
+
169
+ run_repl(app, inspect, variable, variablefile, pythonpath, outputdir, paths)
@@ -0,0 +1,12 @@
1
+ from typing import List
2
+
3
+ import click
4
+
5
+ from robotcode.plugin import hookimpl
6
+
7
+ from .cli import repl
8
+
9
+
10
+ @hookimpl
11
+ def register_cli_commands() -> List[click.Command]:
12
+ return [repl]
@@ -0,0 +1,210 @@
1
+ import sys
2
+ from pathlib import Path
3
+ from typing import Any, Iterator, List, Optional, Tuple, Union, cast
4
+
5
+ import click
6
+ from robot.api import get_model
7
+ from robot.output import LOGGER
8
+ from robot.output import Message as OutputMessage
9
+ from robot.running import Keyword, TestCase, TestSuite
10
+ from robot.running.context import EXECUTION_CONTEXTS
11
+ from robot.running.signalhandler import _StopSignalMonitor
12
+
13
+ from robotcode.plugin import Application
14
+ from robotcode.robot.utils import get_robot_version
15
+ from robotcode.robot.utils.ast import iter_nodes
16
+
17
+
18
+ def _register_signal_handler(self: Any, exsignum: Any) -> None:
19
+ pass
20
+
21
+
22
+ # Monkey patching the _register_signal_handler method to disable robot's signal handling
23
+ _StopSignalMonitor._register_signal_handler = _register_signal_handler
24
+
25
+
26
+ if get_robot_version() >= (7, 0):
27
+
28
+ def _run_keyword(kw: Keyword, context: Any) -> Any:
29
+ return kw.run(context.steps[-1][1], context)
30
+
31
+ else:
32
+
33
+ def _run_keyword(kw: Keyword, context: Any) -> Any:
34
+ return kw.run(context)
35
+
36
+
37
+ TRUE_STRINGS = {"TRUE", "YES", "ON", "1"}
38
+
39
+
40
+ def is_true(value: Union[str, bool]) -> bool:
41
+ if isinstance(value, str):
42
+ return value.upper() in TRUE_STRINGS
43
+ return bool(value)
44
+
45
+
46
+ class Interpreter:
47
+ def __init__(self, app: Application, files: Optional[List[Path]] = None, inspect: Optional[bool] = False) -> None:
48
+ self.app = app
49
+ self.files = files
50
+ self.inspect = inspect
51
+
52
+ self.executed_files: List[Path] = []
53
+
54
+ def check_for_errors(self, node: Any) -> List[str]:
55
+ if hasattr(node, "tokens"):
56
+ for token in node.tokens:
57
+ if hasattr(token, "error") and token.error:
58
+ raise SyntaxError(token.error)
59
+
60
+ if hasattr(node, "error") and node.error:
61
+ return [node.error]
62
+
63
+ if hasattr(node, "errors") and node.errors:
64
+ return list(node.errors)
65
+
66
+ return []
67
+
68
+ def get_test_body_from_string(self, command: str) -> Tuple[TestCase, List[str]]:
69
+ suite_str = (
70
+ "*** Test Cases ***\nDummyTestCase423141592653589793\n "
71
+ + ("\n ".join(command.split("\n")) if "\n" in command else command)
72
+ ) + "\n"
73
+
74
+ model = get_model(suite_str)
75
+ suite: TestSuite = TestSuite.from_model(model)
76
+
77
+ errors: List[str] = []
78
+
79
+ for node in iter_nodes(model):
80
+ errors.extend(self.check_for_errors(node))
81
+
82
+ return cast(TestCase, suite.tests[0]), errors
83
+
84
+ def get_input(self) -> Iterator[Optional[Keyword]]:
85
+ if self.executed_files and not self.files and not self.inspect:
86
+ yield None
87
+ return
88
+
89
+ if self.files:
90
+ file = self.files.pop(0)
91
+
92
+ self.executed_files.append(file)
93
+
94
+ text = file.read_text(encoding="utf-8")
95
+
96
+ test, errors = self.get_test_body_from_string(text)
97
+ if errors:
98
+ return
99
+
100
+ for kw in test.body:
101
+ yield kw
102
+ else:
103
+
104
+ lines: List[str] = []
105
+ last_one = False
106
+ while True:
107
+
108
+ prompt = ""
109
+ if sys.stdin.isatty():
110
+ prompt = ">>> " if not lines else "... "
111
+
112
+ try:
113
+ text = input(prompt)
114
+ if len(lines) == 0 and text == "":
115
+ break
116
+ except KeyboardInterrupt:
117
+ print()
118
+ if len(lines) > 0:
119
+ lines = []
120
+ last_one = False
121
+ continue
122
+ raise
123
+
124
+ lines.append(text)
125
+
126
+ test, errors = self.get_test_body_from_string("\n".join(lines))
127
+
128
+ if len(lines) > 1 and lines[-1] == "" and text == "":
129
+ last_one = True
130
+
131
+ if errors:
132
+ if not last_one:
133
+ continue
134
+
135
+ for kw in test.body:
136
+ yield kw
137
+
138
+ break
139
+
140
+ def run_keyword(self, kw: Keyword) -> Any:
141
+ with LOGGER.delayed_logging:
142
+ kw_result = None
143
+ try:
144
+ context = EXECUTION_CONTEXTS.current
145
+ kw_result = _run_keyword(kw, context)
146
+ except (SystemExit, KeyboardInterrupt):
147
+ raise
148
+ except BaseException:
149
+ pass
150
+ finally:
151
+ messages: List[OutputMessage] = LOGGER._log_message_cache or []
152
+ for msg in messages or ():
153
+ # hack to get and evaluate log level
154
+ listener: Any = next(iter(LOGGER), None)
155
+ if listener is None or listener._is_logged(msg.level):
156
+ self.log_message(msg.message, msg.level, msg.html, msg.timestamp)
157
+ LOGGER._log_message_cache = []
158
+
159
+ return kw_result
160
+
161
+ def run(self) -> Any:
162
+ has_input = True
163
+ while has_input:
164
+ try:
165
+ for kw in self.get_input():
166
+ if kw is None:
167
+ has_input = False
168
+ break
169
+ self.set_last_result(self.run_keyword(kw))
170
+ except EOFError:
171
+ break
172
+ except (SystemExit, KeyboardInterrupt):
173
+ break
174
+ except BaseException as e:
175
+ self.log_message(str(e), "ERROR")
176
+ break
177
+
178
+ def set_last_result(self, result: Any) -> None:
179
+ if result is None:
180
+ return
181
+ self.app.echo_via_pager(f"{result}")
182
+
183
+ def log_message(
184
+ self, message: str, level: str, html: Union[str, bool] = False, timestamp: Optional[str] = None
185
+ ) -> None:
186
+ level_msg = None
187
+
188
+ if level == "INFO":
189
+ level_msg = click.style("INFO", fg="green")
190
+ elif level == "WARN":
191
+ level_msg = click.style("WARN", fg="yellow")
192
+ elif level == "ERROR":
193
+ level_msg = click.style("ERROR", fg="red")
194
+ elif level == "FAIL":
195
+ level_msg = click.style("FAIL", fg="red", bold=True)
196
+ elif level == "SKIP":
197
+ level_msg = click.style("SKIP", dim=True)
198
+ elif level == "DEBUG":
199
+ level_msg = click.style("DEBUG", fg="bright_black")
200
+ elif level == "TRACE":
201
+ level_msg = click.style("TRACE", fg="bright_black", dim=True)
202
+
203
+ msg = message if not is_true(html) else f"*HTML*{message}"
204
+ self.app.echo_via_pager(f"[ {level_msg} ] {msg}" if level_msg else msg)
205
+
206
+ def message(
207
+ self, message: str, level: str, html: Union[str, bool] = False, timestamp: Optional[str] = None
208
+ ) -> None:
209
+ if self.app.config.verbose:
210
+ self.log_message(message, level, html, timestamp)
@@ -0,0 +1 @@
1
+ # Marker file for PEP 561.
@@ -0,0 +1,27 @@
1
+ from typing import Any, ClassVar, Dict, Optional
2
+
3
+ from robotcode.plugin import Application
4
+
5
+ from .interpreter import Interpreter
6
+
7
+
8
+ class ReplListener:
9
+ ROBOT_LISTENER_API_VERSION = 2
10
+ instance: ClassVar["ReplListener"]
11
+
12
+ def __init__(self, app: Application, interpreter: Optional[Interpreter] = None) -> None:
13
+ ReplListener.instance = self
14
+ self.app = app
15
+ self.interpreter = interpreter or Interpreter(app)
16
+
17
+ def start_keyword(self, name: str, _attributes: Dict[str, Any]) -> None:
18
+ if name != "robotcode.repl.Repl.Repl":
19
+ return
20
+
21
+ self.interpreter.run()
22
+
23
+ def log_message(self, message: Dict[str, Any]) -> None:
24
+ self.interpreter.log_message(message["message"], message["level"], message["html"], message.get("timestamp"))
25
+
26
+ def message(self, message: Dict[str, Any]) -> None:
27
+ self.interpreter.message(message["message"], message["level"], message["html"], message.get("timestamp"))
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.3
2
+ Name: robotcode-repl
3
+ Version: 0.93.0
4
+ Summary: RobotCode REPL for Robot Framework
5
+ Project-URL: Homepage, https://robotcode.io
6
+ Project-URL: Donate, https://opencollective.com/robotcode
7
+ Project-URL: Documentation, https://github.com/robotcodedev/robotcode#readme
8
+ Project-URL: Changelog, https://github.com/robotcodedev/robotcode/blob/main/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/robotcodedev/robotcode/issues
10
+ Project-URL: Source, https://github.com/robotcodedev/robotcode
11
+ Author-email: Daniel Biehl <dbiehl@live.de>
12
+ License: Apache-2.0
13
+ License-File: LICENSE.txt
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Framework :: Robot Framework
16
+ Classifier: Framework :: Robot Framework :: Tool
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: Implementation :: CPython
24
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
25
+ Classifier: Topic :: Utilities
26
+ Classifier: Typing :: Typed
27
+ Requires-Python: >=3.8
28
+ Requires-Dist: robotcode-jsonrpc2==0.93.0
29
+ Requires-Dist: robotcode-runner==0.93.0
30
+ Description-Content-Type: text/markdown
31
+
32
+ # robotcode-repl
33
+
34
+ [![PyPI - Version](https://img.shields.io/pypi/v/robotcode-repl.svg)](https://pypi.org/project/robotcode-repl)
35
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/robotcode-repl.svg)](https://pypi.org/project/robotcode-repl)
36
+ [![License](https://img.shields.io/github/license/robotcodedev/robotcode?style=flat&logo=apache)](https://github.com/robotcodedev/robotcode/blob/master/LICENSE.txt)
37
+
38
+ -----
39
+
40
+ ## Introduction
41
+
42
+ Some classes for [RobotCode](https://robotcode.io) plugin management
43
+
44
+ ## Installation
45
+
46
+ ```console
47
+ pip install robotcode-repl
48
+ ```
49
+
50
+ ## License
51
+
52
+ `robotcode-repl` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.
@@ -0,0 +1,15 @@
1
+ robotcode/repl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ robotcode/repl/__version__.py,sha256=W-KEJT0wpRrG8XJ2aDG4NSyzaUucgZR9y6mwfCTlku4,23
3
+ robotcode/repl/hooks.py,sha256=L52rYgu4SnQUpacd_f-clVILqWVhrDBy0h7YyQtz-bQ,182
4
+ robotcode/repl/interpreter.py,sha256=R5RkCmihNisghCkXrltnA-vkADdPhCru8AJJfAkPsjE,6745
5
+ robotcode/repl/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
6
+ robotcode/repl/repl_listener.py,sha256=QY1maLvKhj7DmGphq6ACq7xukohMNjCJqnaPifJR-Vw,964
7
+ robotcode/repl/Repl/__init__.py,sha256=-j2WxY3MzdLfsMvpa2wMs6WVF_eeJygdshtMN50r67U,43
8
+ robotcode/repl/Repl/repl.py,sha256=nup9IBVmd9s5GGra2vKMrfmdQUrffIRWeAruxioOhCY,352
9
+ robotcode/repl/cli/__init__.py,sha256=Ql2UdzX6GnJEXXovXVT4vfY-EyDpGGZIkKgLRn4Md6E,43
10
+ robotcode/repl/cli/repl.py,sha256=2FzmxcrNKgTmk0PeL05Y_e2e6mkgus8DWMO-Mxj2gL8,4583
11
+ robotcode_repl-0.93.0.dist-info/METADATA,sha256=dv9JHo3ImI97yGXp1DRXItXU1Vz5uJ00Xskj4jDWD8Y,2086
12
+ robotcode_repl-0.93.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
13
+ robotcode_repl-0.93.0.dist-info/entry_points.txt,sha256=lI4idVOEmSWxmmioejg-_QvHXTLySK6ZxJ13R_v8ykU,40
14
+ robotcode_repl-0.93.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
15
+ robotcode_repl-0.93.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.25.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [robotcode]
2
+ repl = robotcode.repl.hooks
@@ -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.