├── tests ├── conftest.py └── test_logging.py ├── pytest_logging ├── __init__.py ├── version.py └── plugin.py ├── tox.ini ├── .travis.yml ├── .gitignore ├── appveyor.yml ├── README.rst ├── setup.py └── LICENSE /tests/conftest.py: -------------------------------------------------------------------------------- 1 | pytest_plugins = 'pytester' 2 | -------------------------------------------------------------------------------- /pytest_logging/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | # For more information about tox, see https://tox.readthedocs.org/en/latest/ 2 | [tox] 3 | envlist = py27,py33,py34,py35,pypy 4 | 5 | [testenv] 6 | deps = pytest 7 | commands = py.test {posargs:tests} 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Config file for automatic testing at travis-ci.org 2 | 3 | sudo: false 4 | language: python 5 | python: 6 | - "2.7" 7 | - "3.3" 8 | - "3.4" 9 | - "3.5" 10 | - "pypy" 11 | 12 | install: 13 | - pip install tox 14 | - "TOX_ENV=${TRAVIS_PYTHON_VERSION/[0-9].[0-9]/py${TRAVIS_PYTHON_VERSION/.}}" 15 | script: tox -e $TOX_ENV 16 | 17 | before_cache: 18 | - rm -rf $HOME/.cache/pip/log 19 | cache: 20 | directories: 21 | - $HOME/.cache/pip 22 | -------------------------------------------------------------------------------- /pytest_logging/version.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ''' 3 | :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` 4 | :copyright: © 2015 by the SaltStack Team, see AUTHORS for more details. 5 | :license: Apache 2.0, see LICENSE for more details. 6 | 7 | 8 | pytest_logging.version 9 | ~~~~~~~~~~~~~~~~~~~~~~ 10 | 11 | pytest logging plugin version information 12 | ''' 13 | 14 | # Import Python Libs 15 | from __future__ import absolute_import 16 | 17 | 18 | __version_info__ = (2015, 11, 4) 19 | __version__ = '{0}.{1}.{2}'.format(*__version_info__) 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # What Python version is installed where: 2 | # http://www.appveyor.com/docs/installed-software#python 3 | 4 | environment: 5 | matrix: 6 | - PYTHON: "C:\\Python27" 7 | TOX_ENV: "py27" 8 | 9 | - PYTHON: "C:\\Python33" 10 | TOX_ENV: "py33" 11 | 12 | - PYTHON: "C:\\Python34" 13 | TOX_ENV: "py34" 14 | 15 | - PYTHON: "C:\\Python35" 16 | TOX_ENV: "py35" 17 | 18 | 19 | init: 20 | - "%PYTHON%/python -V" 21 | - "%PYTHON%/python -c \"import struct;print( 8 * struct.calcsize(\'P\'))\"" 22 | 23 | install: 24 | - "%PYTHON%/Scripts/easy_install -U pip" 25 | - "%PYTHON%/Scripts/pip install tox" 26 | - "%PYTHON%/Scripts/pip install wheel" 27 | 28 | build: false # Not a C# project, build stuff at the test step instead. 29 | 30 | test_script: 31 | - "%PYTHON%/Scripts/tox -e %TOX_ENV%" 32 | 33 | after_test: 34 | - "%PYTHON%/python setup.py bdist_wheel" 35 | - ps: "ls dist" 36 | 37 | artifacts: 38 | - path: dist\* 39 | 40 | #on_success: 41 | # - TODO: upload the content of dist/*.whl to a public wheelhouse 42 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | pytest-logging 2 | ============== 3 | 4 | .. image:: https://travis-ci.org/saltstack/pytest-logging.svg?branch=master 5 | :target: https://travis-ci.org/saltstack/pytest-logging 6 | :alt: See Build Status on Travis CI 7 | 8 | .. image:: https://ci.appveyor.com/api/projects/status/github/saltstack/pytest-logging?branch=master 9 | :target: https://ci.appveyor.com/project/saltstack-public/pytest-logging/branch/master 10 | :alt: See Build Status on AppVeyor 11 | 12 | .. image:: http://img.shields.io/pypi/v/pytest-logging.svg 13 | :target: https://pypi.python.org/pypi/pytest-logging 14 | 15 | Configures logging and allows tweaking the log level with a py.test flag 16 | 17 | ---- 18 | 19 | This `Pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template. 20 | 21 | 22 | Features 23 | -------- 24 | 25 | * Configures python's logging to output log messages to the console(You need to tell `PyTest`_ not to capture output). 26 | * Increases the logging verbosity by lowering the log level by passing `-v` to `PyTest`_ 27 | 28 | 29 | Requirements 30 | ------------ 31 | 32 | * None! 33 | 34 | 35 | Installation 36 | ------------ 37 | 38 | You can install "pytest-logging" via `pip`_ from `PyPI`_:: 39 | 40 | $ pip install pytest-logging 41 | 42 | 43 | Usage 44 | ----- 45 | 46 | * Simply pass one or more `-v` flag(s) to `PyTest`_ to increase logging verbosity 47 | 48 | 49 | Contributing 50 | ------------ 51 | Contributions are very welcome. Tests can be run with `tox`_, please ensure 52 | the coverage at least stays the same before you submit a pull request. 53 | 54 | License 55 | ------- 56 | 57 | Distributed under the terms of the `Apache 2.0`_ license, "pytest-logging" is free and open source software 58 | 59 | 60 | Issues 61 | ------ 62 | 63 | If you encounter any problems, please `file an issue`_ along with a detailed description. 64 | 65 | .. _`Cookiecutter`: https://github.com/audreyr/cookiecutter 66 | .. _`@hackebrot`: https://github.com/hackebrot 67 | .. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin 68 | .. _`file an issue`: https://github.com/saltstack/pytest-logging/issues 69 | .. _`pytest`: https://github.com/pytest-dev/pytest 70 | .. _`tox`: https://tox.readthedocs.org/en/latest/ 71 | .. _`pip`: https://pypi.python.org/pypi/pip/ 72 | .. _`PyPI`: https://pypi.python.org/pypi 73 | .. _`Apache 2.0`: http://www.apache.org/licenses/LICENSE-2.0 74 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from __future__ import absolute_import, with_statement 5 | import os 6 | import sys 7 | import codecs 8 | from setuptools import setup, find_packages 9 | 10 | # Change to source's directory prior to running any command 11 | try: 12 | SETUP_DIRNAME = os.path.dirname(__file__) 13 | except NameError: 14 | # We're most likely being frozen and __file__ triggered this NameError 15 | # Let's work around that 16 | SETUP_DIRNAME = os.path.dirname(sys.argv[0]) 17 | 18 | if SETUP_DIRNAME != '': 19 | os.chdir(SETUP_DIRNAME) 20 | 21 | 22 | def read(fname): 23 | ''' 24 | Read a file from the directory where setup.py resides 25 | ''' 26 | file_path = os.path.join(SETUP_DIRNAME, fname) 27 | with codecs.open(file_path, encoding='utf-8') as rfh: 28 | return rfh.read() 29 | 30 | 31 | # Version info -- read without importing 32 | _LOCALS = {} 33 | with open(os.path.join(SETUP_DIRNAME, 'pytest_logging', 'version.py')) as rfh: 34 | exec(rfh.read(), None, _LOCALS) # pylint: disable=exec-used 35 | 36 | 37 | VERSION = _LOCALS['__version__'] 38 | LONG_DESCRIPTION = read('README.rst') 39 | 40 | setup( 41 | name='pytest-logging', 42 | version=VERSION, 43 | author='Pedro Algarvio', 44 | author_email='pedro@algarvio.me', 45 | maintainer='Pedro Algarvio', 46 | maintainer_email='pedro@algarvio.me', 47 | license='MIT', 48 | url='https://github.com/saltstack/pytest-logging', 49 | description='Configures logging and allows tweaking the log level with a py.test flag', 50 | long_description=LONG_DESCRIPTION, 51 | packages=find_packages(), 52 | install_requires=['pytest>=2.8.1'], 53 | classifiers=[ 54 | 'Development Status :: 4 - Beta', 55 | 'Intended Audience :: Developers', 56 | 'Topic :: Software Development :: Testing', 57 | 'Programming Language :: Python', 58 | 'Programming Language :: Python :: 2', 59 | 'Programming Language :: Python :: 2.7', 60 | 'Programming Language :: Python :: 3', 61 | 'Programming Language :: Python :: 3.3', 62 | 'Programming Language :: Python :: 3.4', 63 | 'Programming Language :: Python :: 3.5', 64 | 'Programming Language :: Python :: Implementation :: CPython', 65 | 'Programming Language :: Python :: Implementation :: PyPy', 66 | 'Operating System :: OS Independent', 67 | 'License :: OSI Approved :: Apache Software License', 68 | ], 69 | entry_points={ 70 | 'pytest11': [ 71 | 'logging = pytest_logging.plugin', 72 | ], 73 | }, 74 | ) 75 | -------------------------------------------------------------------------------- /pytest_logging/plugin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ''' 3 | :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` 4 | :copyright: © 2015 by the SaltStack Team, see AUTHORS for more details. 5 | :license: Apache 2.0, see LICENSE for more details. 6 | 7 | 8 | pytest_logging.plugin 9 | ~~~~~~~~~~~~~~~~~~~~~ 10 | ''' 11 | 12 | # Import python libs 13 | from __future__ import absolute_import 14 | import sys 15 | import logging 16 | 17 | # Import py libs 18 | import py 19 | 20 | if not hasattr(logging, 'TRACE'): 21 | logging.TRACE = 5 22 | logging.addLevelName(logging.TRACE, 'TRACE') 23 | if not hasattr(logging, 'GARBAGE'): 24 | logging.GARBAGE = 1 25 | logging.addLevelName(logging.GARBAGE, 'GARBAGE') 26 | 27 | LOG_FORMAT = '%(asctime)s,%(msecs)04.0f [%(name)-5s:%(lineno)-4d][%(levelname)-8s] %(message)s' 28 | DATE_FORMAT = '%H:%M:%S' 29 | 30 | HANDLED_LEVELS = { 31 | 2: logging.WARN, # -v 32 | 3: logging.INFO, # -vv 33 | 4: logging.DEBUG, # -vvv 34 | 5: logging.TRACE, # -vvvv 35 | 6: logging.GARBAGE # -vvvvv 36 | } 37 | 38 | TERMINAL = py.io.TerminalWriter(sys.stderr) # pylint: disable=no-member 39 | CONSOLEHANDLER = logging.StreamHandler(TERMINAL) 40 | # Add the handler to logging 41 | logging.root.addHandler(CONSOLEHANDLER) 42 | # The root logging should have the lowest logging level to allow all messages 43 | # to be logged 44 | logging.root.setLevel(logging.GARBAGE) 45 | 46 | 47 | def pytest_addoption(parser): 48 | ''' 49 | Add CLI options to py.test 50 | ''' 51 | group = parser.getgroup('logging', 'Logging Configuration') 52 | group.addoption('--logging-format', 53 | dest='logging_format', 54 | default=LOG_FORMAT, 55 | help='log format as used by the logging module') 56 | group.addoption('--logging-date-format', 57 | dest='logging_date_format', 58 | default=DATE_FORMAT, 59 | help='log date format as used by the logging module') 60 | 61 | parser.addini('logging_format', 62 | 'log format as used by the logging module') 63 | parser.addini('logging_date_format', 64 | 'log date format as used by the logging module') 65 | 66 | 67 | def pytest_configure(config): 68 | ''' 69 | Add the formatter to logging 70 | ''' 71 | # Get the format options and add the formatter to the console handler 72 | formatter = logging.Formatter( 73 | config.getini('logging_format') or config.getvalue('logging_format'), 74 | config.getini('logging_date_format') or config.getvalue('logging_date_format')) 75 | CONSOLEHANDLER.setFormatter(formatter) 76 | 77 | 78 | def pytest_cmdline_main(config): 79 | ''' 80 | called for performing the main command line action. The default 81 | implementation will invoke the configure hooks and runtest_mainloop. 82 | ''' 83 | verbosity = config.getoption('-v') 84 | if verbosity > 1: 85 | CONSOLEHANDLER.setLevel( 86 | HANDLED_LEVELS.get(verbosity, 87 | HANDLED_LEVELS.get(verbosity > 6 and 6 or 2))) 88 | else: 89 | # The console handler defaults to the highest logging level 90 | CONSOLEHANDLER.setLevel(logging.FATAL) 91 | -------------------------------------------------------------------------------- /tests/test_logging.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ''' 3 | :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` 4 | :copyright: © 2015 by the SaltStack Team, see AUTHORS for more details. 5 | :license: Apache 2.0, see LICENSE for more details. 6 | 7 | 8 | test_logging.py 9 | ~~~~~~~~~~~~~~~ 10 | ''' 11 | 12 | def test_help_message(testdir): 13 | result = testdir.runpytest( 14 | '--help', 15 | ) 16 | # fnmatch_lines does an assertion internally 17 | result.stdout.fnmatch_lines([ 18 | 'Logging Configuration:', 19 | ]) 20 | 21 | 22 | def test_log_format_ini_setting(testdir): 23 | testdir.makeini(''' 24 | [pytest] 25 | logging_format = %(asctime)s,%(msecs)03.0f [%(name)-5s:%(lineno)-4d][%(levelname)-8s] %(message)s 26 | ''') 27 | 28 | testdir.makepyfile(''' 29 | import pytest 30 | from pytest_logging.plugin import CONSOLEHANDLER 31 | LOG_FORMAT = '%(asctime)s,%(msecs)03.0f [%(name)-5s:%(lineno)-4d][%(levelname)-8s] %(message)s' 32 | 33 | def test_log_format(): 34 | assert CONSOLEHANDLER.formatter._fmt == LOG_FORMAT 35 | ''') 36 | 37 | result = testdir.runpytest('-v') 38 | 39 | # fnmatch_lines does an assertion internally 40 | result.stdout.fnmatch_lines([ 41 | '*::test_log_format PASSED', 42 | ]) 43 | 44 | # make sure that that we get a '0' exit code for the testsuite 45 | assert result.ret == 0 46 | 47 | 48 | def test_log_date_format_ini_setting(testdir): 49 | testdir.makeini(''' 50 | [pytest] 51 | logging_date_format = %H:%S 52 | ''') 53 | 54 | testdir.makepyfile(''' 55 | import pytest 56 | from pytest_logging.plugin import CONSOLEHANDLER 57 | LOG_DATE_FORMAT = '%H:%S' 58 | 59 | def test_log_date_format(): 60 | assert CONSOLEHANDLER.formatter.datefmt == LOG_DATE_FORMAT 61 | ''') 62 | 63 | result = testdir.runpytest('-v') 64 | 65 | # fnmatch_lines does an assertion internally 66 | result.stdout.fnmatch_lines([ 67 | '*::test_log_date_format PASSED', 68 | ]) 69 | 70 | # make sure that that we get a '0' exit code for the testsuite 71 | assert result.ret == 0 72 | 73 | 74 | def test_logging_level_fatal(testdir): 75 | testdir.makepyfile(''' 76 | import pytest 77 | import logging 78 | 79 | def test_logging_level(): 80 | from pytest_logging.plugin import CONSOLEHANDLER 81 | assert CONSOLEHANDLER.level == logging.FATAL 82 | ''') 83 | 84 | result = testdir.runpytest('-v') 85 | 86 | # fnmatch_lines does an assertion internally 87 | result.stdout.fnmatch_lines([ 88 | '*::test_logging_level PASSED', 89 | ]) 90 | 91 | # make sure that that we get a '0' exit code for the testsuite 92 | assert result.ret == 0 93 | 94 | 95 | def test_logging_level_warn(testdir): 96 | testdir.makepyfile(''' 97 | import pytest 98 | import logging 99 | 100 | def test_logging_level(): 101 | from pytest_logging.plugin import CONSOLEHANDLER 102 | assert CONSOLEHANDLER.level == logging.WARN 103 | ''') 104 | 105 | result = testdir.runpytest('-vv') 106 | 107 | # fnmatch_lines does an assertion internally 108 | result.stdout.fnmatch_lines([ 109 | '*::test_logging_level PASSED', 110 | ]) 111 | 112 | # make sure that that we get a '0' exit code for the testsuite 113 | assert result.ret == 0 114 | 115 | 116 | def test_logging_level_info(testdir): 117 | testdir.makepyfile(''' 118 | import pytest 119 | import logging 120 | 121 | def test_logging_level(): 122 | from pytest_logging.plugin import CONSOLEHANDLER 123 | assert CONSOLEHANDLER.level == logging.INFO 124 | ''') 125 | 126 | result = testdir.runpytest('-vv', '-v') 127 | 128 | # fnmatch_lines does an assertion internally 129 | result.stdout.fnmatch_lines([ 130 | '*::test_logging_level PASSED', 131 | ]) 132 | 133 | # make sure that that we get a '0' exit code for the testsuite 134 | assert result.ret == 0 135 | 136 | 137 | def test_logging_level_debug(testdir): 138 | testdir.makepyfile(''' 139 | import pytest 140 | import logging 141 | 142 | def test_logging_level(): 143 | from pytest_logging.plugin import CONSOLEHANDLER 144 | assert CONSOLEHANDLER.level == logging.DEBUG 145 | ''') 146 | 147 | result = testdir.runpytest('-vv', '-vv') 148 | 149 | # fnmatch_lines does an assertion internally 150 | result.stdout.fnmatch_lines([ 151 | '*::test_logging_level PASSED', 152 | ]) 153 | 154 | # make sure that that we get a '0' exit code for the testsuite 155 | assert result.ret == 0 156 | 157 | 158 | def test_logging_level_trace(testdir): 159 | testdir.makepyfile(''' 160 | import pytest 161 | import logging 162 | 163 | def test_logging_level(): 164 | from pytest_logging.plugin import CONSOLEHANDLER 165 | assert CONSOLEHANDLER.level == logging.TRACE 166 | ''') 167 | 168 | result = testdir.runpytest('-vvvvv') 169 | 170 | # fnmatch_lines does an assertion internally 171 | result.stdout.fnmatch_lines([ 172 | '*::test_logging_level PASSED', 173 | ]) 174 | 175 | # make sure that that we get a '0' exit code for the testsuite 176 | assert result.ret == 0 177 | 178 | 179 | def test_logging_level_garbage(testdir): 180 | testdir.makepyfile(''' 181 | import pytest 182 | import logging 183 | 184 | def test_logging_level(): 185 | from pytest_logging.plugin import CONSOLEHANDLER 186 | assert CONSOLEHANDLER.level == logging.GARBAGE 187 | ''') 188 | 189 | for idx in range(6, 10): 190 | result = testdir.runpytest('-' + 'v'*idx) 191 | 192 | # fnmatch_lines does an assertion internally 193 | result.stdout.fnmatch_lines([ 194 | '*::test_logging_level PASSED', 195 | ]) 196 | 197 | # make sure that that we get a '0' exit code for the testsuite 198 | assert result.ret == 0 199 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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. 202 | 203 | --------------------------------------------------------------------------------