From 3715aa9254f65ae1058290101351a72a6d3a67d4 Mon Sep 17 00:00:00 2001 From: robot-piglet Date: Fri, 1 Dec 2023 16:59:11 +0300 Subject: Intermediate changes --- contrib/python/coverage/plugins/coveragerc.txt | 29 - contrib/python/coverage/plugins/ya.make | 19 - contrib/python/coverage/plugins/yarcadia/plugin.py | 114 -- contrib/python/coverage/py2/.dist-info/METADATA | 190 -- .../coverage/py2/.dist-info/entry_points.txt | 5 - .../python/coverage/py2/.dist-info/top_level.txt | 1 - contrib/python/coverage/py2/LICENSE.txt | 177 -- contrib/python/coverage/py2/NOTICE.txt | 14 - contrib/python/coverage/py2/README.rst | 151 -- contrib/python/coverage/py2/coverage/__init__.py | 36 - contrib/python/coverage/py2/coverage/__main__.py | 8 - contrib/python/coverage/py2/coverage/annotate.py | 108 -- contrib/python/coverage/py2/coverage/backward.py | 267 --- contrib/python/coverage/py2/coverage/bytecode.py | 19 - contrib/python/coverage/py2/coverage/cmdline.py | 910 --------- contrib/python/coverage/py2/coverage/collector.py | 455 ----- contrib/python/coverage/py2/coverage/config.py | 605 ------ contrib/python/coverage/py2/coverage/context.py | 91 - contrib/python/coverage/py2/coverage/control.py | 1162 ----------- .../coverage/py2/coverage/ctracer/datastack.c | 50 - .../coverage/py2/coverage/ctracer/datastack.h | 45 - .../coverage/py2/coverage/ctracer/filedisp.c | 85 - .../coverage/py2/coverage/ctracer/filedisp.h | 26 - .../python/coverage/py2/coverage/ctracer/module.c | 108 -- .../python/coverage/py2/coverage/ctracer/stats.h | 31 - .../python/coverage/py2/coverage/ctracer/tracer.c | 1149 ----------- .../python/coverage/py2/coverage/ctracer/tracer.h | 75 - .../python/coverage/py2/coverage/ctracer/util.h | 67 - contrib/python/coverage/py2/coverage/data.py | 125 -- contrib/python/coverage/py2/coverage/debug.py | 406 ---- .../python/coverage/py2/coverage/disposition.py | 37 - contrib/python/coverage/py2/coverage/env.py | 130 -- contrib/python/coverage/py2/coverage/execfile.py | 362 ---- contrib/python/coverage/py2/coverage/files.py | 441 ----- .../py2/coverage/fullcoverage/encodings.py | 60 - contrib/python/coverage/py2/coverage/html.py | 539 ------ .../py2/coverage/htmlfiles/coverage_html.js | 616 ------ .../coverage/py2/coverage/htmlfiles/favicon_32.png | Bin 1732 -> 0 bytes .../coverage/py2/coverage/htmlfiles/index.html | 119 -- .../htmlfiles/jquery.ba-throttle-debounce.min.js | 9 - .../py2/coverage/htmlfiles/jquery.hotkeys.js | 99 - .../py2/coverage/htmlfiles/jquery.isonscreen.js | 53 - .../coverage/py2/coverage/htmlfiles/jquery.min.js | 4 - .../coverage/htmlfiles/jquery.tablesorter.min.js | 2 - .../py2/coverage/htmlfiles/keybd_closed.png | Bin 112 -> 0 bytes .../coverage/py2/coverage/htmlfiles/keybd_open.png | Bin 112 -> 0 bytes .../coverage/py2/coverage/htmlfiles/pyfile.html | 113 -- .../coverage/py2/coverage/htmlfiles/style.css | 291 --- .../coverage/py2/coverage/htmlfiles/style.scss | 660 ------- contrib/python/coverage/py2/coverage/inorout.py | 513 ----- contrib/python/coverage/py2/coverage/jsonreport.py | 103 - contrib/python/coverage/py2/coverage/misc.py | 361 ---- contrib/python/coverage/py2/coverage/multiproc.py | 117 -- contrib/python/coverage/py2/coverage/numbits.py | 163 -- contrib/python/coverage/py2/coverage/parser.py | 1276 ------------ contrib/python/coverage/py2/coverage/phystokens.py | 297 --- contrib/python/coverage/py2/coverage/plugin.py | 533 ----- .../python/coverage/py2/coverage/plugin_support.py | 281 --- contrib/python/coverage/py2/coverage/python.py | 261 --- contrib/python/coverage/py2/coverage/pytracer.py | 274 --- contrib/python/coverage/py2/coverage/report.py | 86 - contrib/python/coverage/py2/coverage/results.py | 343 ---- contrib/python/coverage/py2/coverage/sqldata.py | 1123 ----------- contrib/python/coverage/py2/coverage/summary.py | 152 -- contrib/python/coverage/py2/coverage/templite.py | 302 --- contrib/python/coverage/py2/coverage/tomlconfig.py | 168 -- contrib/python/coverage/py2/coverage/version.py | 33 - contrib/python/coverage/py2/coverage/xmlreport.py | 234 --- contrib/python/coverage/py2/ya.make | 98 - contrib/python/coverage/py3/.dist-info/METADATA | 190 -- .../coverage/py3/.dist-info/entry_points.txt | 5 - .../python/coverage/py3/.dist-info/top_level.txt | 1 - contrib/python/coverage/py3/LICENSE.txt | 177 -- contrib/python/coverage/py3/NOTICE.txt | 14 - contrib/python/coverage/py3/README.rst | 151 -- contrib/python/coverage/py3/coverage/__init__.py | 36 - contrib/python/coverage/py3/coverage/__main__.py | 8 - contrib/python/coverage/py3/coverage/annotate.py | 108 -- contrib/python/coverage/py3/coverage/backward.py | 267 --- contrib/python/coverage/py3/coverage/bytecode.py | 19 - contrib/python/coverage/py3/coverage/cmdline.py | 910 --------- contrib/python/coverage/py3/coverage/collector.py | 455 ----- contrib/python/coverage/py3/coverage/config.py | 605 ------ contrib/python/coverage/py3/coverage/context.py | 91 - contrib/python/coverage/py3/coverage/control.py | 1162 ----------- .../coverage/py3/coverage/ctracer/datastack.c | 50 - .../coverage/py3/coverage/ctracer/datastack.h | 45 - .../coverage/py3/coverage/ctracer/filedisp.c | 85 - .../coverage/py3/coverage/ctracer/filedisp.h | 26 - .../python/coverage/py3/coverage/ctracer/module.c | 108 -- .../python/coverage/py3/coverage/ctracer/stats.h | 31 - .../python/coverage/py3/coverage/ctracer/tracer.c | 1149 ----------- .../python/coverage/py3/coverage/ctracer/tracer.h | 75 - .../python/coverage/py3/coverage/ctracer/util.h | 103 - contrib/python/coverage/py3/coverage/data.py | 125 -- contrib/python/coverage/py3/coverage/debug.py | 406 ---- .../python/coverage/py3/coverage/disposition.py | 37 - contrib/python/coverage/py3/coverage/env.py | 130 -- contrib/python/coverage/py3/coverage/execfile.py | 362 ---- contrib/python/coverage/py3/coverage/files.py | 441 ----- .../py3/coverage/fullcoverage/encodings.py | 60 - contrib/python/coverage/py3/coverage/html.py | 539 ------ .../py3/coverage/htmlfiles/coverage_html.js | 616 ------ .../coverage/py3/coverage/htmlfiles/favicon_32.png | Bin 1732 -> 0 bytes .../coverage/py3/coverage/htmlfiles/index.html | 119 -- .../htmlfiles/jquery.ba-throttle-debounce.min.js | 9 - .../py3/coverage/htmlfiles/jquery.hotkeys.js | 99 - .../py3/coverage/htmlfiles/jquery.isonscreen.js | 53 - .../coverage/py3/coverage/htmlfiles/jquery.min.js | 4 - .../coverage/htmlfiles/jquery.tablesorter.min.js | 2 - .../py3/coverage/htmlfiles/keybd_closed.png | Bin 112 -> 0 bytes .../coverage/py3/coverage/htmlfiles/keybd_open.png | Bin 112 -> 0 bytes .../coverage/py3/coverage/htmlfiles/pyfile.html | 113 -- .../coverage/py3/coverage/htmlfiles/style.css | 291 --- .../coverage/py3/coverage/htmlfiles/style.scss | 660 ------- contrib/python/coverage/py3/coverage/inorout.py | 513 ----- contrib/python/coverage/py3/coverage/jsonreport.py | 103 - contrib/python/coverage/py3/coverage/misc.py | 361 ---- contrib/python/coverage/py3/coverage/multiproc.py | 117 -- contrib/python/coverage/py3/coverage/numbits.py | 163 -- contrib/python/coverage/py3/coverage/parser.py | 1276 ------------ contrib/python/coverage/py3/coverage/phystokens.py | 297 --- contrib/python/coverage/py3/coverage/plugin.py | 533 ----- .../python/coverage/py3/coverage/plugin_support.py | 281 --- contrib/python/coverage/py3/coverage/python.py | 261 --- contrib/python/coverage/py3/coverage/pytracer.py | 274 --- contrib/python/coverage/py3/coverage/report.py | 86 - contrib/python/coverage/py3/coverage/results.py | 343 ---- contrib/python/coverage/py3/coverage/sqldata.py | 1123 ----------- contrib/python/coverage/py3/coverage/summary.py | 152 -- contrib/python/coverage/py3/coverage/templite.py | 302 --- contrib/python/coverage/py3/coverage/tomlconfig.py | 168 -- contrib/python/coverage/py3/coverage/version.py | 33 - contrib/python/coverage/py3/coverage/xmlreport.py | 234 --- contrib/python/coverage/py3/ya.make | 98 - contrib/python/coverage/ya.make | 19 - .../diff-match-patch/py2/.dist-info/METADATA | 112 -- .../diff-match-patch/py2/.dist-info/top_level.txt | 1 - contrib/python/diff-match-patch/py2/AUTHORS | 10 - contrib/python/diff-match-patch/py2/LICENSE | 202 -- contrib/python/diff-match-patch/py2/README.md | 84 - .../py2/diff_match_patch/__init__.py | 9 - .../py2/diff_match_patch/diff_match_patch_py2.py | 2037 -------------------- contrib/python/diff-match-patch/py2/ya.make | 27 - .../diff-match-patch/py3/.dist-info/METADATA | 108 -- .../diff-match-patch/py3/.dist-info/top_level.txt | 1 - contrib/python/diff-match-patch/py3/AUTHORS | 10 - contrib/python/diff-match-patch/py3/LICENSE | 202 -- contrib/python/diff-match-patch/py3/README.md | 84 - .../py3/diff_match_patch/__init__.py | 10 - .../py3/diff_match_patch/__version__.py | 7 - .../py3/diff_match_patch/diff_match_patch.py | 2019 ------------------- .../py3/diff_match_patch/tests/speedtest1.txt | 230 --- .../py3/diff_match_patch/tests/speedtest2.txt | 188 -- contrib/python/diff-match-patch/py3/ya.make | 28 - contrib/python/diff-match-patch/ya.make | 18 - contrib/python/humanfriendly/py2/LICENSE.txt | 20 - contrib/python/humanfriendly/py2/README.rst | 170 -- .../python/humanfriendly/py3/.dist-info/METADATA | 216 --- .../humanfriendly/py3/.dist-info/entry_points.txt | 3 - .../humanfriendly/py3/.dist-info/top_level.txt | 1 - contrib/python/humanfriendly/py3/LICENSE.txt | 20 - contrib/python/humanfriendly/py3/README.rst | 170 -- .../humanfriendly/py3/humanfriendly/__init__.py | 838 -------- .../python/humanfriendly/py3/humanfriendly/case.py | 157 -- .../python/humanfriendly/py3/humanfriendly/cli.py | 291 --- .../humanfriendly/py3/humanfriendly/compat.py | 146 -- .../humanfriendly/py3/humanfriendly/decorators.py | 43 - .../humanfriendly/py3/humanfriendly/deprecation.py | 251 --- .../humanfriendly/py3/humanfriendly/prompts.py | 376 ---- .../humanfriendly/py3/humanfriendly/sphinx.py | 315 --- .../humanfriendly/py3/humanfriendly/tables.py | 341 ---- .../py3/humanfriendly/terminal/__init__.py | 776 -------- .../py3/humanfriendly/terminal/html.py | 423 ---- .../py3/humanfriendly/terminal/spinners.py | 310 --- .../humanfriendly/py3/humanfriendly/testing.py | 669 ------- .../python/humanfriendly/py3/humanfriendly/text.py | 449 ----- .../humanfriendly/py3/humanfriendly/usage.py | 351 ---- contrib/python/humanfriendly/py3/ya.make | 41 - contrib/python/humanfriendly/ya.make | 18 - contrib/python/marisa-trie/agent.pxd | 22 - contrib/python/marisa-trie/base.pxd | 63 - contrib/python/marisa-trie/iostream.pxd | 7 - contrib/python/marisa-trie/key.pxd | 22 - contrib/python/marisa-trie/keyset.pxd | 30 - contrib/python/marisa-trie/marisa/agent.cc | 51 - contrib/python/marisa-trie/marisa/agent.h | 75 - contrib/python/marisa-trie/marisa/base.h | 196 -- contrib/python/marisa-trie/marisa/exception.h | 84 - .../python/marisa-trie/marisa/grimoire/algorithm.h | 27 - .../marisa-trie/marisa/grimoire/algorithm/sort.h | 197 -- .../python/marisa-trie/marisa/grimoire/intrin.h | 116 -- contrib/python/marisa-trie/marisa/grimoire/io.h | 19 - .../marisa-trie/marisa/grimoire/io/mapper.cc | 163 -- .../python/marisa-trie/marisa/grimoire/io/mapper.h | 68 - .../marisa-trie/marisa/grimoire/io/reader.cc | 147 -- .../python/marisa-trie/marisa/grimoire/io/reader.h | 67 - .../marisa-trie/marisa/grimoire/io/writer.cc | 148 -- .../python/marisa-trie/marisa/grimoire/io/writer.h | 66 - contrib/python/marisa-trie/marisa/grimoire/trie.h | 17 - .../marisa-trie/marisa/grimoire/trie/cache.h | 82 - .../marisa-trie/marisa/grimoire/trie/config.h | 156 -- .../marisa-trie/marisa/grimoire/trie/entry.h | 83 - .../marisa-trie/marisa/grimoire/trie/header.h | 62 - .../marisa-trie/marisa/grimoire/trie/history.h | 66 - .../python/marisa-trie/marisa/grimoire/trie/key.h | 227 --- .../marisa-trie/marisa/grimoire/trie/louds-trie.cc | 877 --------- .../marisa-trie/marisa/grimoire/trie/louds-trie.h | 135 -- .../marisa-trie/marisa/grimoire/trie/range.h | 116 -- .../marisa-trie/marisa/grimoire/trie/state.h | 118 -- .../marisa-trie/marisa/grimoire/trie/tail.cc | 218 --- .../python/marisa-trie/marisa/grimoire/trie/tail.h | 73 - .../python/marisa-trie/marisa/grimoire/vector.h | 19 - .../marisa/grimoire/vector/bit-vector.cc | 825 -------- .../marisa/grimoire/vector/bit-vector.h | 180 -- .../marisa/grimoire/vector/flat-vector.h | 206 -- .../marisa-trie/marisa/grimoire/vector/pop-count.h | 111 -- .../marisa/grimoire/vector/rank-index.h | 83 - .../marisa-trie/marisa/grimoire/vector/vector.h | 257 --- contrib/python/marisa-trie/marisa/iostream.h | 19 - contrib/python/marisa-trie/marisa/key.h | 86 - contrib/python/marisa-trie/marisa/keyset.cc | 181 -- contrib/python/marisa-trie/marisa/keyset.h | 81 - contrib/python/marisa-trie/marisa/query.h | 72 - contrib/python/marisa-trie/marisa/scoped-array.h | 49 - contrib/python/marisa-trie/marisa/scoped-ptr.h | 53 - contrib/python/marisa-trie/marisa/stdio.h | 16 - contrib/python/marisa-trie/marisa/trie.cc | 249 --- contrib/python/marisa-trie/marisa/trie.h | 65 - contrib/python/marisa-trie/marisa_trie.pyx | 763 -------- contrib/python/marisa-trie/query.pxd | 20 - contrib/python/marisa-trie/std_iostream.pxd | 18 - contrib/python/marisa-trie/trie.pxd | 41 - contrib/python/marisa-trie/ya.make | 33 - contrib/python/path.py/py2/LICENSE | 7 - contrib/python/path.py/py2/README.rst | 134 -- contrib/python/path.py/py3/.dist-info/METADATA | 36 - .../python/path.py/py3/.dist-info/top_level.txt | 1 - contrib/python/path.py/py3/LICENSE | 7 - contrib/python/path.py/py3/README.rst | 1 - contrib/python/path.py/py3/ya.make | 21 - contrib/python/path.py/ya.make | 18 - contrib/python/path/.dist-info/METADATA | 201 -- contrib/python/path/.dist-info/top_level.txt | 1 - contrib/python/path/LICENSE | 17 - contrib/python/path/README.rst | 163 -- contrib/python/path/path/__init__.py | 1665 ---------------- contrib/python/path/path/classes.py | 27 - contrib/python/path/path/masks.py | 159 -- contrib/python/path/path/matchers.py | 59 - contrib/python/path/path/py.typed | 0 contrib/python/path/ya.make | 30 - contrib/python/pygtrie/py2/LICENSE | 202 -- contrib/python/pygtrie/py2/README.rst | 66 - contrib/python/pygtrie/py3/.dist-info/METADATA | 220 --- .../python/pygtrie/py3/.dist-info/top_level.txt | 1 - contrib/python/pygtrie/py3/LICENSE | 202 -- contrib/python/pygtrie/py3/README.rst | 66 - contrib/python/pygtrie/py3/pygtrie.py | 1939 ------------------- contrib/python/pygtrie/py3/ya.make | 26 - contrib/python/pygtrie/ya.make | 18 - contrib/python/pyre2/py2/AUTHORS | 12 - contrib/python/pyre2/py2/LICENSE | 9 - contrib/python/pyre2/py2/README.rst | 250 --- .../python/pyre2/py2/tests/test_charliterals.txt | 47 - contrib/python/pyre2/py2/tests/test_count.txt | 40 - .../python/pyre2/py2/tests/test_emptygroups.txt | 36 - contrib/python/pyre2/py2/tests/test_findall.txt | 42 - contrib/python/pyre2/py2/tests/test_finditer.txt | 28 - .../python/pyre2/py2/tests/test_match_expand.txt | 29 - contrib/python/pyre2/py2/tests/test_mmap.txt | 18 - .../python/pyre2/py2/tests/test_namedgroups.txt | 56 - contrib/python/pyre2/py2/tests/test_pattern.txt | 12 - contrib/python/pyre2/py2/tests/test_search.txt | 29 - contrib/python/pyre2/py2/tests/test_split.txt | 17 - contrib/python/pyre2/py2/tests/test_sub.txt | 31 - contrib/python/pyre2/py2/tests/test_unicode.txt | 71 - contrib/python/pyre2/py3/.dist-info/METADATA | 275 --- contrib/python/pyre2/py3/.dist-info/top_level.txt | 1 - contrib/python/pyre2/py3/AUTHORS | 12 - contrib/python/pyre2/py3/LICENSE | 9 - contrib/python/pyre2/py3/README.rst | 250 --- contrib/python/pyre2/py3/src/_re2macros.h | 13 - contrib/python/pyre2/py3/src/compile.pxi | 234 --- contrib/python/pyre2/py3/src/includes.pxi | 109 -- contrib/python/pyre2/py3/src/match.pxi | 280 --- contrib/python/pyre2/py3/src/pattern.pxi | 650 ------- contrib/python/pyre2/py3/src/re2.pyx | 458 ----- .../python/pyre2/py3/tests/test_charliterals.txt | 47 - contrib/python/pyre2/py3/tests/test_count.txt | 40 - .../python/pyre2/py3/tests/test_emptygroups.txt | 36 - contrib/python/pyre2/py3/tests/test_findall.txt | 42 - contrib/python/pyre2/py3/tests/test_finditer.txt | 28 - .../python/pyre2/py3/tests/test_match_expand.txt | 29 - contrib/python/pyre2/py3/tests/test_mmap.txt | 18 - .../python/pyre2/py3/tests/test_namedgroups.txt | 56 - contrib/python/pyre2/py3/tests/test_pattern.txt | 12 - contrib/python/pyre2/py3/tests/test_search.txt | 29 - contrib/python/pyre2/py3/tests/test_split.txt | 17 - contrib/python/pyre2/py3/tests/test_sub.txt | 31 - contrib/python/pyre2/py3/tests/test_unicode.txt | 71 - contrib/python/pyre2/py3/ya.make | 39 - contrib/python/pyre2/ya.make | 18 - contrib/python/python-magic/py2/LICENSE | 58 - contrib/python/python-magic/py2/README.md | 144 -- .../python/python-magic/py3/.dist-info/METADATA | 171 -- .../python-magic/py3/.dist-info/top_level.txt | 1 - contrib/python/python-magic/py3/LICENSE | 58 - contrib/python/python-magic/py3/README.md | 144 -- contrib/python/python-magic/py3/magic/__init__.py | 469 ----- contrib/python/python-magic/py3/magic/compat.py | 287 --- contrib/python/python-magic/py3/magic/loader.py | 50 - contrib/python/python-magic/py3/magic/py.typed | 0 contrib/python/python-magic/py3/ya.make | 31 - contrib/python/python-magic/ya.make | 18 - 315 files changed, 62711 deletions(-) delete mode 100644 contrib/python/coverage/plugins/coveragerc.txt delete mode 100644 contrib/python/coverage/plugins/ya.make delete mode 100644 contrib/python/coverage/plugins/yarcadia/plugin.py delete mode 100644 contrib/python/coverage/py2/.dist-info/METADATA delete mode 100644 contrib/python/coverage/py2/.dist-info/entry_points.txt delete mode 100644 contrib/python/coverage/py2/.dist-info/top_level.txt delete mode 100644 contrib/python/coverage/py2/LICENSE.txt delete mode 100644 contrib/python/coverage/py2/NOTICE.txt delete mode 100644 contrib/python/coverage/py2/README.rst delete mode 100644 contrib/python/coverage/py2/coverage/__init__.py delete mode 100644 contrib/python/coverage/py2/coverage/__main__.py delete mode 100644 contrib/python/coverage/py2/coverage/annotate.py delete mode 100644 contrib/python/coverage/py2/coverage/backward.py delete mode 100644 contrib/python/coverage/py2/coverage/bytecode.py delete mode 100644 contrib/python/coverage/py2/coverage/cmdline.py delete mode 100644 contrib/python/coverage/py2/coverage/collector.py delete mode 100644 contrib/python/coverage/py2/coverage/config.py delete mode 100644 contrib/python/coverage/py2/coverage/context.py delete mode 100644 contrib/python/coverage/py2/coverage/control.py delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/datastack.c delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/datastack.h delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/filedisp.c delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/filedisp.h delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/module.c delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/stats.h delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/tracer.c delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/tracer.h delete mode 100644 contrib/python/coverage/py2/coverage/ctracer/util.h delete mode 100644 contrib/python/coverage/py2/coverage/data.py delete mode 100644 contrib/python/coverage/py2/coverage/debug.py delete mode 100644 contrib/python/coverage/py2/coverage/disposition.py delete mode 100644 contrib/python/coverage/py2/coverage/env.py delete mode 100644 contrib/python/coverage/py2/coverage/execfile.py delete mode 100644 contrib/python/coverage/py2/coverage/files.py delete mode 100644 contrib/python/coverage/py2/coverage/fullcoverage/encodings.py delete mode 100644 contrib/python/coverage/py2/coverage/html.py delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/coverage_html.js delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/favicon_32.png delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/index.html delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/jquery.ba-throttle-debounce.min.js delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/jquery.hotkeys.js delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/jquery.isonscreen.js delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/jquery.min.js delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/jquery.tablesorter.min.js delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/keybd_closed.png delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/keybd_open.png delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/pyfile.html delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/style.css delete mode 100644 contrib/python/coverage/py2/coverage/htmlfiles/style.scss delete mode 100644 contrib/python/coverage/py2/coverage/inorout.py delete mode 100644 contrib/python/coverage/py2/coverage/jsonreport.py delete mode 100644 contrib/python/coverage/py2/coverage/misc.py delete mode 100644 contrib/python/coverage/py2/coverage/multiproc.py delete mode 100644 contrib/python/coverage/py2/coverage/numbits.py delete mode 100644 contrib/python/coverage/py2/coverage/parser.py delete mode 100644 contrib/python/coverage/py2/coverage/phystokens.py delete mode 100644 contrib/python/coverage/py2/coverage/plugin.py delete mode 100644 contrib/python/coverage/py2/coverage/plugin_support.py delete mode 100644 contrib/python/coverage/py2/coverage/python.py delete mode 100644 contrib/python/coverage/py2/coverage/pytracer.py delete mode 100644 contrib/python/coverage/py2/coverage/report.py delete mode 100644 contrib/python/coverage/py2/coverage/results.py delete mode 100644 contrib/python/coverage/py2/coverage/sqldata.py delete mode 100644 contrib/python/coverage/py2/coverage/summary.py delete mode 100644 contrib/python/coverage/py2/coverage/templite.py delete mode 100644 contrib/python/coverage/py2/coverage/tomlconfig.py delete mode 100644 contrib/python/coverage/py2/coverage/version.py delete mode 100644 contrib/python/coverage/py2/coverage/xmlreport.py delete mode 100644 contrib/python/coverage/py2/ya.make delete mode 100644 contrib/python/coverage/py3/.dist-info/METADATA delete mode 100644 contrib/python/coverage/py3/.dist-info/entry_points.txt delete mode 100644 contrib/python/coverage/py3/.dist-info/top_level.txt delete mode 100644 contrib/python/coverage/py3/LICENSE.txt delete mode 100644 contrib/python/coverage/py3/NOTICE.txt delete mode 100644 contrib/python/coverage/py3/README.rst delete mode 100644 contrib/python/coverage/py3/coverage/__init__.py delete mode 100644 contrib/python/coverage/py3/coverage/__main__.py delete mode 100644 contrib/python/coverage/py3/coverage/annotate.py delete mode 100644 contrib/python/coverage/py3/coverage/backward.py delete mode 100644 contrib/python/coverage/py3/coverage/bytecode.py delete mode 100644 contrib/python/coverage/py3/coverage/cmdline.py delete mode 100644 contrib/python/coverage/py3/coverage/collector.py delete mode 100644 contrib/python/coverage/py3/coverage/config.py delete mode 100644 contrib/python/coverage/py3/coverage/context.py delete mode 100644 contrib/python/coverage/py3/coverage/control.py delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/datastack.c delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/datastack.h delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/filedisp.c delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/filedisp.h delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/module.c delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/stats.h delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/tracer.c delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/tracer.h delete mode 100644 contrib/python/coverage/py3/coverage/ctracer/util.h delete mode 100644 contrib/python/coverage/py3/coverage/data.py delete mode 100644 contrib/python/coverage/py3/coverage/debug.py delete mode 100644 contrib/python/coverage/py3/coverage/disposition.py delete mode 100644 contrib/python/coverage/py3/coverage/env.py delete mode 100644 contrib/python/coverage/py3/coverage/execfile.py delete mode 100644 contrib/python/coverage/py3/coverage/files.py delete mode 100644 contrib/python/coverage/py3/coverage/fullcoverage/encodings.py delete mode 100644 contrib/python/coverage/py3/coverage/html.py delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/coverage_html.js delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/favicon_32.png delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/index.html delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/jquery.ba-throttle-debounce.min.js delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/jquery.hotkeys.js delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/jquery.isonscreen.js delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/jquery.min.js delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/jquery.tablesorter.min.js delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/keybd_closed.png delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/keybd_open.png delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/pyfile.html delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/style.css delete mode 100644 contrib/python/coverage/py3/coverage/htmlfiles/style.scss delete mode 100644 contrib/python/coverage/py3/coverage/inorout.py delete mode 100644 contrib/python/coverage/py3/coverage/jsonreport.py delete mode 100644 contrib/python/coverage/py3/coverage/misc.py delete mode 100644 contrib/python/coverage/py3/coverage/multiproc.py delete mode 100644 contrib/python/coverage/py3/coverage/numbits.py delete mode 100644 contrib/python/coverage/py3/coverage/parser.py delete mode 100644 contrib/python/coverage/py3/coverage/phystokens.py delete mode 100644 contrib/python/coverage/py3/coverage/plugin.py delete mode 100644 contrib/python/coverage/py3/coverage/plugin_support.py delete mode 100644 contrib/python/coverage/py3/coverage/python.py delete mode 100644 contrib/python/coverage/py3/coverage/pytracer.py delete mode 100644 contrib/python/coverage/py3/coverage/report.py delete mode 100644 contrib/python/coverage/py3/coverage/results.py delete mode 100644 contrib/python/coverage/py3/coverage/sqldata.py delete mode 100644 contrib/python/coverage/py3/coverage/summary.py delete mode 100644 contrib/python/coverage/py3/coverage/templite.py delete mode 100644 contrib/python/coverage/py3/coverage/tomlconfig.py delete mode 100644 contrib/python/coverage/py3/coverage/version.py delete mode 100644 contrib/python/coverage/py3/coverage/xmlreport.py delete mode 100644 contrib/python/coverage/py3/ya.make delete mode 100644 contrib/python/coverage/ya.make delete mode 100644 contrib/python/diff-match-patch/py2/.dist-info/METADATA delete mode 100644 contrib/python/diff-match-patch/py2/.dist-info/top_level.txt delete mode 100644 contrib/python/diff-match-patch/py2/AUTHORS delete mode 100644 contrib/python/diff-match-patch/py2/LICENSE delete mode 100644 contrib/python/diff-match-patch/py2/README.md delete mode 100644 contrib/python/diff-match-patch/py2/diff_match_patch/__init__.py delete mode 100644 contrib/python/diff-match-patch/py2/diff_match_patch/diff_match_patch_py2.py delete mode 100644 contrib/python/diff-match-patch/py2/ya.make delete mode 100644 contrib/python/diff-match-patch/py3/.dist-info/METADATA delete mode 100644 contrib/python/diff-match-patch/py3/.dist-info/top_level.txt delete mode 100644 contrib/python/diff-match-patch/py3/AUTHORS delete mode 100644 contrib/python/diff-match-patch/py3/LICENSE delete mode 100644 contrib/python/diff-match-patch/py3/README.md delete mode 100644 contrib/python/diff-match-patch/py3/diff_match_patch/__init__.py delete mode 100644 contrib/python/diff-match-patch/py3/diff_match_patch/__version__.py delete mode 100644 contrib/python/diff-match-patch/py3/diff_match_patch/diff_match_patch.py delete mode 100644 contrib/python/diff-match-patch/py3/diff_match_patch/tests/speedtest1.txt delete mode 100644 contrib/python/diff-match-patch/py3/diff_match_patch/tests/speedtest2.txt delete mode 100644 contrib/python/diff-match-patch/py3/ya.make delete mode 100644 contrib/python/diff-match-patch/ya.make delete mode 100644 contrib/python/humanfriendly/py2/LICENSE.txt delete mode 100644 contrib/python/humanfriendly/py2/README.rst delete mode 100644 contrib/python/humanfriendly/py3/.dist-info/METADATA delete mode 100644 contrib/python/humanfriendly/py3/.dist-info/entry_points.txt delete mode 100644 contrib/python/humanfriendly/py3/.dist-info/top_level.txt delete mode 100644 contrib/python/humanfriendly/py3/LICENSE.txt delete mode 100644 contrib/python/humanfriendly/py3/README.rst delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/__init__.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/case.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/cli.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/compat.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/decorators.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/deprecation.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/prompts.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/sphinx.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/tables.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/terminal/__init__.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/terminal/html.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/terminal/spinners.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/testing.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/text.py delete mode 100644 contrib/python/humanfriendly/py3/humanfriendly/usage.py delete mode 100644 contrib/python/humanfriendly/py3/ya.make delete mode 100644 contrib/python/humanfriendly/ya.make delete mode 100644 contrib/python/marisa-trie/agent.pxd delete mode 100644 contrib/python/marisa-trie/base.pxd delete mode 100644 contrib/python/marisa-trie/iostream.pxd delete mode 100644 contrib/python/marisa-trie/key.pxd delete mode 100644 contrib/python/marisa-trie/keyset.pxd delete mode 100644 contrib/python/marisa-trie/marisa/agent.cc delete mode 100644 contrib/python/marisa-trie/marisa/agent.h delete mode 100644 contrib/python/marisa-trie/marisa/base.h delete mode 100644 contrib/python/marisa-trie/marisa/exception.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/algorithm.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/algorithm/sort.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/intrin.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/io.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/io/mapper.cc delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/io/mapper.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/io/reader.cc delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/io/reader.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/io/writer.cc delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/io/writer.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/cache.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/config.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/entry.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/header.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/history.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/key.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/louds-trie.cc delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/louds-trie.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/range.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/state.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/tail.cc delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/trie/tail.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/vector.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/vector/bit-vector.cc delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/vector/bit-vector.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/vector/flat-vector.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/vector/pop-count.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/vector/rank-index.h delete mode 100644 contrib/python/marisa-trie/marisa/grimoire/vector/vector.h delete mode 100644 contrib/python/marisa-trie/marisa/iostream.h delete mode 100644 contrib/python/marisa-trie/marisa/key.h delete mode 100644 contrib/python/marisa-trie/marisa/keyset.cc delete mode 100644 contrib/python/marisa-trie/marisa/keyset.h delete mode 100644 contrib/python/marisa-trie/marisa/query.h delete mode 100644 contrib/python/marisa-trie/marisa/scoped-array.h delete mode 100644 contrib/python/marisa-trie/marisa/scoped-ptr.h delete mode 100644 contrib/python/marisa-trie/marisa/stdio.h delete mode 100644 contrib/python/marisa-trie/marisa/trie.cc delete mode 100644 contrib/python/marisa-trie/marisa/trie.h delete mode 100644 contrib/python/marisa-trie/marisa_trie.pyx delete mode 100644 contrib/python/marisa-trie/query.pxd delete mode 100644 contrib/python/marisa-trie/std_iostream.pxd delete mode 100644 contrib/python/marisa-trie/trie.pxd delete mode 100644 contrib/python/marisa-trie/ya.make delete mode 100644 contrib/python/path.py/py2/LICENSE delete mode 100644 contrib/python/path.py/py2/README.rst delete mode 100644 contrib/python/path.py/py3/.dist-info/METADATA delete mode 100644 contrib/python/path.py/py3/.dist-info/top_level.txt delete mode 100644 contrib/python/path.py/py3/LICENSE delete mode 100644 contrib/python/path.py/py3/README.rst delete mode 100644 contrib/python/path.py/py3/ya.make delete mode 100644 contrib/python/path.py/ya.make delete mode 100644 contrib/python/path/.dist-info/METADATA delete mode 100644 contrib/python/path/.dist-info/top_level.txt delete mode 100644 contrib/python/path/LICENSE delete mode 100644 contrib/python/path/README.rst delete mode 100644 contrib/python/path/path/__init__.py delete mode 100644 contrib/python/path/path/classes.py delete mode 100644 contrib/python/path/path/masks.py delete mode 100644 contrib/python/path/path/matchers.py delete mode 100644 contrib/python/path/path/py.typed delete mode 100644 contrib/python/path/ya.make delete mode 100644 contrib/python/pygtrie/py2/LICENSE delete mode 100644 contrib/python/pygtrie/py2/README.rst delete mode 100644 contrib/python/pygtrie/py3/.dist-info/METADATA delete mode 100644 contrib/python/pygtrie/py3/.dist-info/top_level.txt delete mode 100644 contrib/python/pygtrie/py3/LICENSE delete mode 100644 contrib/python/pygtrie/py3/README.rst delete mode 100644 contrib/python/pygtrie/py3/pygtrie.py delete mode 100644 contrib/python/pygtrie/py3/ya.make delete mode 100644 contrib/python/pygtrie/ya.make delete mode 100644 contrib/python/pyre2/py2/AUTHORS delete mode 100644 contrib/python/pyre2/py2/LICENSE delete mode 100644 contrib/python/pyre2/py2/README.rst delete mode 100644 contrib/python/pyre2/py2/tests/test_charliterals.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_count.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_emptygroups.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_findall.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_finditer.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_match_expand.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_mmap.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_namedgroups.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_pattern.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_search.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_split.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_sub.txt delete mode 100644 contrib/python/pyre2/py2/tests/test_unicode.txt delete mode 100644 contrib/python/pyre2/py3/.dist-info/METADATA delete mode 100644 contrib/python/pyre2/py3/.dist-info/top_level.txt delete mode 100644 contrib/python/pyre2/py3/AUTHORS delete mode 100644 contrib/python/pyre2/py3/LICENSE delete mode 100644 contrib/python/pyre2/py3/README.rst delete mode 100644 contrib/python/pyre2/py3/src/_re2macros.h delete mode 100644 contrib/python/pyre2/py3/src/compile.pxi delete mode 100644 contrib/python/pyre2/py3/src/includes.pxi delete mode 100644 contrib/python/pyre2/py3/src/match.pxi delete mode 100644 contrib/python/pyre2/py3/src/pattern.pxi delete mode 100644 contrib/python/pyre2/py3/src/re2.pyx delete mode 100644 contrib/python/pyre2/py3/tests/test_charliterals.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_count.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_emptygroups.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_findall.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_finditer.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_match_expand.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_mmap.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_namedgroups.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_pattern.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_search.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_split.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_sub.txt delete mode 100644 contrib/python/pyre2/py3/tests/test_unicode.txt delete mode 100644 contrib/python/pyre2/py3/ya.make delete mode 100644 contrib/python/pyre2/ya.make delete mode 100644 contrib/python/python-magic/py2/LICENSE delete mode 100644 contrib/python/python-magic/py2/README.md delete mode 100644 contrib/python/python-magic/py3/.dist-info/METADATA delete mode 100644 contrib/python/python-magic/py3/.dist-info/top_level.txt delete mode 100644 contrib/python/python-magic/py3/LICENSE delete mode 100644 contrib/python/python-magic/py3/README.md delete mode 100644 contrib/python/python-magic/py3/magic/__init__.py delete mode 100644 contrib/python/python-magic/py3/magic/compat.py delete mode 100644 contrib/python/python-magic/py3/magic/loader.py delete mode 100644 contrib/python/python-magic/py3/magic/py.typed delete mode 100644 contrib/python/python-magic/py3/ya.make delete mode 100644 contrib/python/python-magic/ya.make (limited to 'contrib/python') diff --git a/contrib/python/coverage/plugins/coveragerc.txt b/contrib/python/coverage/plugins/coveragerc.txt deleted file mode 100644 index 83bfed86903..00000000000 --- a/contrib/python/coverage/plugins/coveragerc.txt +++ /dev/null @@ -1,29 +0,0 @@ -[report] -skip_empty = True - -exclude_lines = - pragma\s*:\s*no\s*cover - def __repr__ - raise AssertionError - raise NotImplementedError - if 0: - if False: - if __name__ == .__main__.: - if self\.debug: - if settings\.DEBUG - -[run] -suppress_plugin_errors = False -plugins = - contrib.python.coverage.plugins.yarcadia.plugin - contrib.tools.cython.Cython.Coverage - -[contrib.python.coverage.plugins.yarcadia.plugin] -pylib_paths = - # don't trace contrib - contrib/python - contrib/python3 - # don't trace python sources - contrib/tools/python - contrib/tools/python3 - contrib/libs/protobuf diff --git a/contrib/python/coverage/plugins/ya.make b/contrib/python/coverage/plugins/ya.make deleted file mode 100644 index 30be33f72a4..00000000000 --- a/contrib/python/coverage/plugins/ya.make +++ /dev/null @@ -1,19 +0,0 @@ -PY23_LIBRARY() - -LICENSE(Apache-2.0) - -PEERDIR( - build/plugins/lib/test_const - contrib/tools/cython/Cython - library/python/testing/coverage_utils -) - -PY_SRCS( - yarcadia/plugin.py -) - -RESOURCE( - coveragerc.txt /coverage_plugins/coveragerc.txt -) - -END() diff --git a/contrib/python/coverage/plugins/yarcadia/plugin.py b/contrib/python/coverage/plugins/yarcadia/plugin.py deleted file mode 100644 index 44d9b003cae..00000000000 --- a/contrib/python/coverage/plugins/yarcadia/plugin.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -import os - -import coverage.config -import coverage.files -import coverage.misc -import coverage.parser -import coverage.plugin -import coverage.python - -from build.plugins.lib import test_const -from library.python.testing import coverage_utils - - -SKIP_FILENAME = '__SKIP_FILENAME__' - - -class YarcadiaPlugin( - coverage.plugin.CoveragePlugin, - coverage.plugin.FileTracer -): - - def __init__(self, options): - self.config = coverage.config.CoverageConfig() - self.config.from_args(**options) - - dirs = options.get("pylib_paths", "").split("\n") - dirs = [d for d in dirs if d and not d.startswith("#")] - self.pylib_paths = dirs - - self._filename = None - self._exclude = None - - self._setup_file_filter() - - def _setup_file_filter(self): - prefix_filter = os.environ.get('PYTHON_COVERAGE_PREFIX_FILTER', '') - exclude_regexp = os.environ.get('PYTHON_COVERAGE_EXCLUDE_REGEXP', '') - self.file_filter = coverage_utils.make_filter(prefix_filter, exclude_regexp) - - def configure(self, config): - self._exclude = coverage.misc.join_regex(config.get_option('report:exclude_lines')) - - def get_pylib_paths(self): - return self.pylib_paths - - def file_tracer(self, filename): - if not filename.endswith(test_const.COVERAGE_PYTHON_EXTS): - # Catch all generated modules (__file__ without proper extension) - self._filename = SKIP_FILENAME - return self - - if not self.file_filter(filename): - # we need to catch all filtered out files (including cython) to pass them to get_source - self._filename = SKIP_FILENAME - return self - - if filename.endswith(".py"): - self._filename = filename - return self - - # Let cython plugin register it's own file tracer for pyx/pxi files - return None - - def has_dynamic_source_filename(self): - return False - - def source_filename(self): - return self._filename - - def file_reporter(self, morf): - source_root = os.environ.get("PYTHON_COVERAGE_ARCADIA_SOURCE_ROOT") - if source_root: - return FileReporter(morf, source_root, self, self._exclude) - # use default file reporter - return "python" - - -class FileReporter(coverage.python.PythonFileReporter): - - def __init__(self, morf, source_root, coverage=None, exclude=None): - super(FileReporter, self).__init__(morf, coverage) - self._source = get_source(morf, source_root) - # use custom parser to provide proper way to get required source - self._parser = Parser(morf, self._source, exclude) - self._parser.parse_source() - - -class Parser(coverage.parser.PythonParser): - - def __init__(self, morf, source_code, exclude): - # provide source code to avoid default way to get it - super(Parser, self).__init__(text=source_code, filename=morf, exclude=exclude) - - -def get_source(filename, source_root): - assert source_root - - if filename == SKIP_FILENAME: - return '' - - abs_filename = os.path.join(source_root, filename) - if not os.path.isfile(abs_filename): - # it's fake generated package - return u'' - - return coverage.python.get_python_source(abs_filename, force_fs=True) - - -def coverage_init(reg, options): - plugin = YarcadiaPlugin(options) - reg.add_configurer(plugin) - reg.add_file_tracer(plugin) diff --git a/contrib/python/coverage/py2/.dist-info/METADATA b/contrib/python/coverage/py2/.dist-info/METADATA deleted file mode 100644 index 25a6049c45d..00000000000 --- a/contrib/python/coverage/py2/.dist-info/METADATA +++ /dev/null @@ -1,190 +0,0 @@ -Metadata-Version: 2.1 -Name: coverage -Version: 5.5 -Summary: Code coverage measurement for Python -Home-page: https://github.com/nedbat/coveragepy -Author: Ned Batchelder and 142 others -Author-email: ned@nedbatchelder.com -License: Apache 2.0 -Project-URL: Documentation, https://coverage.readthedocs.io -Project-URL: Funding, https://tidelift.com/subscription/pkg/pypi-coverage?utm_source=pypi-coverage&utm_medium=referral&utm_campaign=pypi -Project-URL: Issues, https://github.com/nedbat/coveragepy/issues -Keywords: code coverage testing -Platform: UNKNOWN -Classifier: Environment :: Console -Classifier: Intended Audience :: Developers -Classifier: License :: OSI Approved :: Apache Software License -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 -Classifier: Programming Language :: Python :: 3.6 -Classifier: Programming Language :: Python :: 3.7 -Classifier: Programming Language :: Python :: 3.8 -Classifier: Programming Language :: Python :: 3.9 -Classifier: Programming Language :: Python :: 3.10 -Classifier: Programming Language :: Python :: Implementation :: CPython -Classifier: Programming Language :: Python :: Implementation :: PyPy -Classifier: Topic :: Software Development :: Quality Assurance -Classifier: Topic :: Software Development :: Testing -Classifier: Development Status :: 5 - Production/Stable -Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4 -Description-Content-Type: text/x-rst -Provides-Extra: toml -Requires-Dist: toml ; extra == 'toml' - -.. Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -.. For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -=========== -Coverage.py -=========== - -Code coverage testing for Python. - -| |license| |versions| |status| -| |test-status| |quality-status| |docs| |codecov| -| |kit| |format| |repos| |downloads| -| |stars| |forks| |contributors| -| |tidelift| |twitter-coveragepy| |twitter-nedbat| - -Coverage.py measures code coverage, typically during test execution. It uses -the code analysis tools and tracing hooks provided in the Python standard -library to determine which lines are executable, and which have been executed. - -Coverage.py runs on many versions of Python: - -* CPython 2.7. -* CPython 3.5 through 3.10 alpha. -* PyPy2 7.3.3 and PyPy3 7.3.3. - -Documentation is on `Read the Docs`_. Code repository and issue tracker are on -`GitHub`_. - -.. _Read the Docs: https://coverage.readthedocs.io/ -.. _GitHub: https://github.com/nedbat/coveragepy - - -**New in 5.x:** SQLite data storage, JSON report, contexts, relative filenames, -dropped support for Python 2.6, 3.3 and 3.4. - - -For Enterprise --------------- - -.. |tideliftlogo| image:: https://nedbatchelder.com/pix/Tidelift_Logo_small.png - :alt: Tidelift - :target: https://tidelift.com/subscription/pkg/pypi-coverage?utm_source=pypi-coverage&utm_medium=referral&utm_campaign=readme - -.. list-table:: - :widths: 10 100 - - * - |tideliftlogo| - - `Available as part of the Tidelift Subscription. `_ - Coverage and thousands of other packages are working with - Tidelift to deliver one enterprise subscription that covers all of the open - source you use. If you want the flexibility of open source and the confidence - of commercial-grade software, this is for you. - `Learn more. `_ - - -Getting Started ---------------- - -See the `Quick Start section`_ of the docs. - -.. _Quick Start section: https://coverage.readthedocs.io/#quick-start - - -Change history --------------- - -The complete history of changes is on the `change history page`_. - -.. _change history page: https://coverage.readthedocs.io/en/latest/changes.html - - -Contributing ------------- - -See the `Contributing section`_ of the docs. - -.. _Contributing section: https://coverage.readthedocs.io/en/latest/contributing.html - - -Security --------- - -To report a security vulnerability, please use the `Tidelift security -contact`_. Tidelift will coordinate the fix and disclosure. - -.. _Tidelift security contact: https://tidelift.com/security - - -License -------- - -Licensed under the `Apache 2.0 License`_. For details, see `NOTICE.txt`_. - -.. _Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0 -.. _NOTICE.txt: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - - -.. |test-status| image:: https://github.com/nedbat/coveragepy/actions/workflows/testsuite.yml/badge.svg?branch=master&event=push - :target: https://github.com/nedbat/coveragepy/actions/workflows/testsuite.yml - :alt: Test suite status -.. |quality-status| image:: https://github.com/nedbat/coveragepy/actions/workflows/quality.yml/badge.svg?branch=master&event=push - :target: https://github.com/nedbat/coveragepy/actions/workflows/quality.yml - :alt: Quality check status -.. |docs| image:: https://readthedocs.org/projects/coverage/badge/?version=latest&style=flat - :target: https://coverage.readthedocs.io/ - :alt: Documentation -.. |reqs| image:: https://requires.io/github/nedbat/coveragepy/requirements.svg?branch=master - :target: https://requires.io/github/nedbat/coveragepy/requirements/?branch=master - :alt: Requirements status -.. |kit| image:: https://badge.fury.io/py/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: PyPI status -.. |format| image:: https://img.shields.io/pypi/format/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: Kit format -.. |downloads| image:: https://img.shields.io/pypi/dw/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: Weekly PyPI downloads -.. |versions| image:: https://img.shields.io/pypi/pyversions/coverage.svg?logo=python&logoColor=FBE072 - :target: https://pypi.org/project/coverage/ - :alt: Python versions supported -.. |status| image:: https://img.shields.io/pypi/status/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: Package stability -.. |license| image:: https://img.shields.io/pypi/l/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: License -.. |codecov| image:: https://codecov.io/github/nedbat/coveragepy/coverage.svg?branch=master&precision=2 - :target: https://codecov.io/github/nedbat/coveragepy?branch=master - :alt: Coverage! -.. |repos| image:: https://repology.org/badge/tiny-repos/python:coverage.svg - :target: https://repology.org/metapackage/python:coverage/versions - :alt: Packaging status -.. |tidelift| image:: https://tidelift.com/badges/package/pypi/coverage - :target: https://tidelift.com/subscription/pkg/pypi-coverage?utm_source=pypi-coverage&utm_medium=referral&utm_campaign=readme - :alt: Tidelift -.. |stars| image:: https://img.shields.io/github/stars/nedbat/coveragepy.svg?logo=github - :target: https://github.com/nedbat/coveragepy/stargazers - :alt: Github stars -.. |forks| image:: https://img.shields.io/github/forks/nedbat/coveragepy.svg?logo=github - :target: https://github.com/nedbat/coveragepy/network/members - :alt: Github forks -.. |contributors| image:: https://img.shields.io/github/contributors/nedbat/coveragepy.svg?logo=github - :target: https://github.com/nedbat/coveragepy/graphs/contributors - :alt: Contributors -.. |twitter-coveragepy| image:: https://img.shields.io/twitter/follow/coveragepy.svg?label=coveragepy&style=flat&logo=twitter&logoColor=4FADFF - :target: https://twitter.com/coveragepy - :alt: coverage.py on Twitter -.. |twitter-nedbat| image:: https://img.shields.io/twitter/follow/nedbat.svg?label=nedbat&style=flat&logo=twitter&logoColor=4FADFF - :target: https://twitter.com/nedbat - :alt: nedbat on Twitter - - diff --git a/contrib/python/coverage/py2/.dist-info/entry_points.txt b/contrib/python/coverage/py2/.dist-info/entry_points.txt deleted file mode 100644 index cd083fc1ff6..00000000000 --- a/contrib/python/coverage/py2/.dist-info/entry_points.txt +++ /dev/null @@ -1,5 +0,0 @@ -[console_scripts] -coverage = coverage.cmdline:main -coverage-3.9 = coverage.cmdline:main -coverage3 = coverage.cmdline:main - diff --git a/contrib/python/coverage/py2/.dist-info/top_level.txt b/contrib/python/coverage/py2/.dist-info/top_level.txt deleted file mode 100644 index 4ebc8aea50e..00000000000 --- a/contrib/python/coverage/py2/.dist-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -coverage diff --git a/contrib/python/coverage/py2/LICENSE.txt b/contrib/python/coverage/py2/LICENSE.txt deleted file mode 100644 index f433b1a53f5..00000000000 --- a/contrib/python/coverage/py2/LICENSE.txt +++ /dev/null @@ -1,177 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "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. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "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. - - "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). - - "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. - - "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." - - "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. - - 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. - - 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. - - 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: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (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 - - (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. - - 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. - - 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. - - 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. - - 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. - - 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. - - 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. - - END OF TERMS AND CONDITIONS diff --git a/contrib/python/coverage/py2/NOTICE.txt b/contrib/python/coverage/py2/NOTICE.txt deleted file mode 100644 index 37ded535bf3..00000000000 --- a/contrib/python/coverage/py2/NOTICE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2001 Gareth Rees. All rights reserved. -Copyright 2004-2021 Ned Batchelder. All rights reserved. - -Except where noted otherwise, this software is licensed under the Apache -License, Version 2.0 (the "License"); you may not use this work except in -compliance with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/contrib/python/coverage/py2/README.rst b/contrib/python/coverage/py2/README.rst deleted file mode 100644 index 072f30ffeb3..00000000000 --- a/contrib/python/coverage/py2/README.rst +++ /dev/null @@ -1,151 +0,0 @@ -.. Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -.. For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -=========== -Coverage.py -=========== - -Code coverage testing for Python. - -| |license| |versions| |status| -| |test-status| |quality-status| |docs| |codecov| -| |kit| |format| |repos| |downloads| -| |stars| |forks| |contributors| -| |tidelift| |twitter-coveragepy| |twitter-nedbat| - -Coverage.py measures code coverage, typically during test execution. It uses -the code analysis tools and tracing hooks provided in the Python standard -library to determine which lines are executable, and which have been executed. - -Coverage.py runs on many versions of Python: - -* CPython 2.7. -* CPython 3.5 through 3.10 alpha. -* PyPy2 7.3.3 and PyPy3 7.3.3. - -Documentation is on `Read the Docs`_. Code repository and issue tracker are on -`GitHub`_. - -.. _Read the Docs: https://coverage.readthedocs.io/ -.. _GitHub: https://github.com/nedbat/coveragepy - - -**New in 5.x:** SQLite data storage, JSON report, contexts, relative filenames, -dropped support for Python 2.6, 3.3 and 3.4. - - -For Enterprise --------------- - -.. |tideliftlogo| image:: https://nedbatchelder.com/pix/Tidelift_Logo_small.png - :alt: Tidelift - :target: https://tidelift.com/subscription/pkg/pypi-coverage?utm_source=pypi-coverage&utm_medium=referral&utm_campaign=readme - -.. list-table:: - :widths: 10 100 - - * - |tideliftlogo| - - `Available as part of the Tidelift Subscription. `_ - Coverage and thousands of other packages are working with - Tidelift to deliver one enterprise subscription that covers all of the open - source you use. If you want the flexibility of open source and the confidence - of commercial-grade software, this is for you. - `Learn more. `_ - - -Getting Started ---------------- - -See the `Quick Start section`_ of the docs. - -.. _Quick Start section: https://coverage.readthedocs.io/#quick-start - - -Change history --------------- - -The complete history of changes is on the `change history page`_. - -.. _change history page: https://coverage.readthedocs.io/en/latest/changes.html - - -Contributing ------------- - -See the `Contributing section`_ of the docs. - -.. _Contributing section: https://coverage.readthedocs.io/en/latest/contributing.html - - -Security --------- - -To report a security vulnerability, please use the `Tidelift security -contact`_. Tidelift will coordinate the fix and disclosure. - -.. _Tidelift security contact: https://tidelift.com/security - - -License -------- - -Licensed under the `Apache 2.0 License`_. For details, see `NOTICE.txt`_. - -.. _Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0 -.. _NOTICE.txt: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - - -.. |test-status| image:: https://github.com/nedbat/coveragepy/actions/workflows/testsuite.yml/badge.svg?branch=master&event=push - :target: https://github.com/nedbat/coveragepy/actions/workflows/testsuite.yml - :alt: Test suite status -.. |quality-status| image:: https://github.com/nedbat/coveragepy/actions/workflows/quality.yml/badge.svg?branch=master&event=push - :target: https://github.com/nedbat/coveragepy/actions/workflows/quality.yml - :alt: Quality check status -.. |docs| image:: https://readthedocs.org/projects/coverage/badge/?version=latest&style=flat - :target: https://coverage.readthedocs.io/ - :alt: Documentation -.. |reqs| image:: https://requires.io/github/nedbat/coveragepy/requirements.svg?branch=master - :target: https://requires.io/github/nedbat/coveragepy/requirements/?branch=master - :alt: Requirements status -.. |kit| image:: https://badge.fury.io/py/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: PyPI status -.. |format| image:: https://img.shields.io/pypi/format/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: Kit format -.. |downloads| image:: https://img.shields.io/pypi/dw/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: Weekly PyPI downloads -.. |versions| image:: https://img.shields.io/pypi/pyversions/coverage.svg?logo=python&logoColor=FBE072 - :target: https://pypi.org/project/coverage/ - :alt: Python versions supported -.. |status| image:: https://img.shields.io/pypi/status/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: Package stability -.. |license| image:: https://img.shields.io/pypi/l/coverage.svg - :target: https://pypi.org/project/coverage/ - :alt: License -.. |codecov| image:: https://codecov.io/github/nedbat/coveragepy/coverage.svg?branch=master&precision=2 - :target: https://codecov.io/github/nedbat/coveragepy?branch=master - :alt: Coverage! -.. |repos| image:: https://repology.org/badge/tiny-repos/python:coverage.svg - :target: https://repology.org/metapackage/python:coverage/versions - :alt: Packaging status -.. |tidelift| image:: https://tidelift.com/badges/package/pypi/coverage - :target: https://tidelift.com/subscription/pkg/pypi-coverage?utm_source=pypi-coverage&utm_medium=referral&utm_campaign=readme - :alt: Tidelift -.. |stars| image:: https://img.shields.io/github/stars/nedbat/coveragepy.svg?logo=github - :target: https://github.com/nedbat/coveragepy/stargazers - :alt: Github stars -.. |forks| image:: https://img.shields.io/github/forks/nedbat/coveragepy.svg?logo=github - :target: https://github.com/nedbat/coveragepy/network/members - :alt: Github forks -.. |contributors| image:: https://img.shields.io/github/contributors/nedbat/coveragepy.svg?logo=github - :target: https://github.com/nedbat/coveragepy/graphs/contributors - :alt: Contributors -.. |twitter-coveragepy| image:: https://img.shields.io/twitter/follow/coveragepy.svg?label=coveragepy&style=flat&logo=twitter&logoColor=4FADFF - :target: https://twitter.com/coveragepy - :alt: coverage.py on Twitter -.. |twitter-nedbat| image:: https://img.shields.io/twitter/follow/nedbat.svg?label=nedbat&style=flat&logo=twitter&logoColor=4FADFF - :target: https://twitter.com/nedbat - :alt: nedbat on Twitter diff --git a/contrib/python/coverage/py2/coverage/__init__.py b/contrib/python/coverage/py2/coverage/__init__.py deleted file mode 100644 index 331b304b683..00000000000 --- a/contrib/python/coverage/py2/coverage/__init__.py +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Code coverage measurement for Python. - -Ned Batchelder -https://nedbatchelder.com/code/coverage - -""" - -import sys - -from coverage.version import __version__, __url__, version_info - -from coverage.control import Coverage, process_startup -from coverage.data import CoverageData -from coverage.misc import CoverageException -from coverage.plugin import CoveragePlugin, FileTracer, FileReporter -from coverage.pytracer import PyTracer - -# Backward compatibility. -coverage = Coverage - -# On Windows, we encode and decode deep enough that something goes wrong and -# the encodings.utf_8 module is loaded and then unloaded, I don't know why. -# Adding a reference here prevents it from being unloaded. Yuk. -import encodings.utf_8 # pylint: disable=wrong-import-position, wrong-import-order - -# Because of the "from coverage.control import fooey" lines at the top of the -# file, there's an entry for coverage.coverage in sys.modules, mapped to None. -# This makes some inspection tools (like pydoc) unable to find the class -# coverage.coverage. So remove that entry. -try: - del sys.modules['coverage.coverage'] -except KeyError: - pass diff --git a/contrib/python/coverage/py2/coverage/__main__.py b/contrib/python/coverage/py2/coverage/__main__.py deleted file mode 100644 index 79aa4e2b35d..00000000000 --- a/contrib/python/coverage/py2/coverage/__main__.py +++ /dev/null @@ -1,8 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Coverage.py's main entry point.""" - -import sys -from coverage.cmdline import main -sys.exit(main()) diff --git a/contrib/python/coverage/py2/coverage/annotate.py b/contrib/python/coverage/py2/coverage/annotate.py deleted file mode 100644 index 999ab6e557d..00000000000 --- a/contrib/python/coverage/py2/coverage/annotate.py +++ /dev/null @@ -1,108 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Source file annotation for coverage.py.""" - -import io -import os -import re - -from coverage.files import flat_rootname -from coverage.misc import ensure_dir, isolate_module -from coverage.report import get_analysis_to_report - -os = isolate_module(os) - - -class AnnotateReporter(object): - """Generate annotated source files showing line coverage. - - This reporter creates annotated copies of the measured source files. Each - .py file is copied as a .py,cover file, with a left-hand margin annotating - each line:: - - > def h(x): - - if 0: #pragma: no cover - - pass - > if x == 1: - ! a = 1 - > else: - > a = 2 - - > h(2) - - Executed lines use '>', lines not executed use '!', lines excluded from - consideration use '-'. - - """ - - def __init__(self, coverage): - self.coverage = coverage - self.config = self.coverage.config - self.directory = None - - blank_re = re.compile(r"\s*(#|$)") - else_re = re.compile(r"\s*else\s*:\s*(#|$)") - - def report(self, morfs, directory=None): - """Run the report. - - See `coverage.report()` for arguments. - - """ - self.directory = directory - self.coverage.get_data() - for fr, analysis in get_analysis_to_report(self.coverage, morfs): - self.annotate_file(fr, analysis) - - def annotate_file(self, fr, analysis): - """Annotate a single file. - - `fr` is the FileReporter for the file to annotate. - - """ - statements = sorted(analysis.statements) - missing = sorted(analysis.missing) - excluded = sorted(analysis.excluded) - - if self.directory: - ensure_dir(self.directory) - dest_file = os.path.join(self.directory, flat_rootname(fr.relative_filename())) - if dest_file.endswith("_py"): - dest_file = dest_file[:-3] + ".py" - dest_file += ",cover" - else: - dest_file = fr.filename + ",cover" - - with io.open(dest_file, 'w', encoding='utf8') as dest: - i = 0 - j = 0 - covered = True - source = fr.source() - for lineno, line in enumerate(source.splitlines(True), start=1): - while i < len(statements) and statements[i] < lineno: - i += 1 - while j < len(missing) and missing[j] < lineno: - j += 1 - if i < len(statements) and statements[i] == lineno: - covered = j >= len(missing) or missing[j] > lineno - if self.blank_re.match(line): - dest.write(u' ') - elif self.else_re.match(line): - # Special logic for lines containing only 'else:'. - if i >= len(statements) and j >= len(missing): - dest.write(u'! ') - elif i >= len(statements) or j >= len(missing): - dest.write(u'> ') - elif statements[i] == missing[j]: - dest.write(u'! ') - else: - dest.write(u'> ') - elif lineno in excluded: - dest.write(u'- ') - elif covered: - dest.write(u'> ') - else: - dest.write(u'! ') - - dest.write(line) diff --git a/contrib/python/coverage/py2/coverage/backward.py b/contrib/python/coverage/py2/coverage/backward.py deleted file mode 100644 index ac781ab96a8..00000000000 --- a/contrib/python/coverage/py2/coverage/backward.py +++ /dev/null @@ -1,267 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Add things to old Pythons so I can pretend they are newer.""" - -# This file's purpose is to provide modules to be imported from here. -# pylint: disable=unused-import - -import os -import sys - -from datetime import datetime - -from coverage import env - - -# Pythons 2 and 3 differ on where to get StringIO. -try: - from cStringIO import StringIO -except ImportError: - from io import StringIO - -# In py3, ConfigParser was renamed to the more-standard configparser. -# But there's a py3 backport that installs "configparser" in py2, and I don't -# want it because it has annoying deprecation warnings. So try the real py2 -# import first. -try: - import ConfigParser as configparser -except ImportError: - import configparser - -# What's a string called? -try: - string_class = basestring -except NameError: - string_class = str - -# What's a Unicode string called? -try: - unicode_class = unicode -except NameError: - unicode_class = str - -# range or xrange? -try: - range = xrange # pylint: disable=redefined-builtin -except NameError: - range = range - -try: - from itertools import zip_longest -except ImportError: - from itertools import izip_longest as zip_longest - -# Where do we get the thread id from? -try: - from thread import get_ident as get_thread_id -except ImportError: - from threading import get_ident as get_thread_id - -try: - os.PathLike -except AttributeError: - # This is Python 2 and 3 - path_types = (bytes, string_class, unicode_class) -else: - # 3.6+ - path_types = (bytes, str, os.PathLike) - -# shlex.quote is new, but there's an undocumented implementation in "pipes", -# who knew!? -try: - from shlex import quote as shlex_quote -except ImportError: - # Useful function, available under a different (undocumented) name - # in Python versions earlier than 3.3. - from pipes import quote as shlex_quote - -try: - import reprlib -except ImportError: # pragma: not covered - # We need this on Python 2, but in testing environments, a backport is - # installed, so this import isn't used. - import repr as reprlib - -# A function to iterate listlessly over a dict's items, and one to get the -# items as a list. -try: - {}.iteritems -except AttributeError: - # Python 3 - def iitems(d): - """Produce the items from dict `d`.""" - return d.items() - - def litems(d): - """Return a list of items from dict `d`.""" - return list(d.items()) -else: - # Python 2 - def iitems(d): - """Produce the items from dict `d`.""" - return d.iteritems() - - def litems(d): - """Return a list of items from dict `d`.""" - return d.items() - -# Getting the `next` function from an iterator is different in 2 and 3. -try: - iter([]).next -except AttributeError: - def iternext(seq): - """Get the `next` function for iterating over `seq`.""" - return iter(seq).__next__ -else: - def iternext(seq): - """Get the `next` function for iterating over `seq`.""" - return iter(seq).next - -# Python 3.x is picky about bytes and strings, so provide methods to -# get them right, and make them no-ops in 2.x -if env.PY3: - def to_bytes(s): - """Convert string `s` to bytes.""" - return s.encode('utf8') - - def to_string(b): - """Convert bytes `b` to string.""" - return b.decode('utf8') - - def binary_bytes(byte_values): - """Produce a byte string with the ints from `byte_values`.""" - return bytes(byte_values) - - def byte_to_int(byte): - """Turn a byte indexed from a bytes object into an int.""" - return byte - - def bytes_to_ints(bytes_value): - """Turn a bytes object into a sequence of ints.""" - # In Python 3, iterating bytes gives ints. - return bytes_value - -else: - def to_bytes(s): - """Convert string `s` to bytes (no-op in 2.x).""" - return s - - def to_string(b): - """Convert bytes `b` to string.""" - return b - - def binary_bytes(byte_values): - """Produce a byte string with the ints from `byte_values`.""" - return "".join(chr(b) for b in byte_values) - - def byte_to_int(byte): - """Turn a byte indexed from a bytes object into an int.""" - return ord(byte) - - def bytes_to_ints(bytes_value): - """Turn a bytes object into a sequence of ints.""" - for byte in bytes_value: - yield ord(byte) - - -try: - # In Python 2.x, the builtins were in __builtin__ - BUILTINS = sys.modules['__builtin__'] -except KeyError: - # In Python 3.x, they're in builtins - BUILTINS = sys.modules['builtins'] - - -# imp was deprecated in Python 3.3 -try: - import importlib - import importlib.util - imp = None -except ImportError: - importlib = None - -# We only want to use importlib if it has everything we need. -try: - importlib_util_find_spec = importlib.util.find_spec -except Exception: - import imp - importlib_util_find_spec = None - -# What is the .pyc magic number for this version of Python? -try: - PYC_MAGIC_NUMBER = importlib.util.MAGIC_NUMBER -except AttributeError: - PYC_MAGIC_NUMBER = imp.get_magic() - - -def code_object(fn): - """Get the code object from a function.""" - try: - return fn.func_code - except AttributeError: - return fn.__code__ - - -try: - from types import SimpleNamespace -except ImportError: - # The code from https://docs.python.org/3/library/types.html#types.SimpleNamespace - class SimpleNamespace: - """Python implementation of SimpleNamespace, for Python 2.""" - def __init__(self, **kwargs): - self.__dict__.update(kwargs) - - def __repr__(self): - keys = sorted(self.__dict__) - items = ("{}={!r}".format(k, self.__dict__[k]) for k in keys) - return "{}({})".format(type(self).__name__, ", ".join(items)) - - -def format_local_datetime(dt): - """Return a string with local timezone representing the date. - If python version is lower than 3.6, the time zone is not included. - """ - try: - return dt.astimezone().strftime('%Y-%m-%d %H:%M %z') - except (TypeError, ValueError): - # Datetime.astimezone in Python 3.5 can not handle naive datetime - return dt.strftime('%Y-%m-%d %H:%M') - - -def invalidate_import_caches(): - """Invalidate any import caches that may or may not exist.""" - if importlib and hasattr(importlib, "invalidate_caches"): - importlib.invalidate_caches() - - -def import_local_file(modname, modfile=None): - """Import a local file as a module. - - Opens a file in the current directory named `modname`.py, imports it - as `modname`, and returns the module object. `modfile` is the file to - import if it isn't in the current directory. - - """ - try: - import importlib.util as importlib_util - except ImportError: - importlib_util = None - - if modfile is None: - modfile = modname + '.py' - if importlib_util: - spec = importlib_util.spec_from_file_location(modname, modfile) - mod = importlib_util.module_from_spec(spec) - sys.modules[modname] = mod - spec.loader.exec_module(mod) - else: - for suff in imp.get_suffixes(): # pragma: part covered - if suff[0] == '.py': - break - - with open(modfile, 'r') as f: - # pylint: disable=undefined-loop-variable - mod = imp.load_module(modname, f, modfile, suff) - - return mod diff --git a/contrib/python/coverage/py2/coverage/bytecode.py b/contrib/python/coverage/py2/coverage/bytecode.py deleted file mode 100644 index ceb18cf3740..00000000000 --- a/contrib/python/coverage/py2/coverage/bytecode.py +++ /dev/null @@ -1,19 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Bytecode manipulation for coverage.py""" - -import types - - -def code_objects(code): - """Iterate over all the code objects in `code`.""" - stack = [code] - while stack: - # We're going to return the code object on the stack, but first - # push its children for later returning. - code = stack.pop() - for c in code.co_consts: - if isinstance(c, types.CodeType): - stack.append(c) - yield code diff --git a/contrib/python/coverage/py2/coverage/cmdline.py b/contrib/python/coverage/py2/coverage/cmdline.py deleted file mode 100644 index 0be0cca19f1..00000000000 --- a/contrib/python/coverage/py2/coverage/cmdline.py +++ /dev/null @@ -1,910 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Command-line support for coverage.py.""" - -from __future__ import print_function - -import glob -import optparse -import os.path -import shlex -import sys -import textwrap -import traceback - -import coverage -from coverage import Coverage -from coverage import env -from coverage.collector import CTracer -from coverage.data import line_counts -from coverage.debug import info_formatter, info_header, short_stack -from coverage.execfile import PyRunner -from coverage.misc import BaseCoverageException, ExceptionDuringRun, NoSource, output_encoding -from coverage.results import should_fail_under - - -class Opts(object): - """A namespace class for individual options we'll build parsers from.""" - - append = optparse.make_option( - '-a', '--append', action='store_true', - help="Append coverage data to .coverage, otherwise it starts clean each time.", - ) - keep = optparse.make_option( - '', '--keep', action='store_true', - help="Keep original coverage files, otherwise they are deleted.", - ) - branch = optparse.make_option( - '', '--branch', action='store_true', - help="Measure branch coverage in addition to statement coverage.", - ) - CONCURRENCY_CHOICES = [ - "thread", "gevent", "greenlet", "eventlet", "multiprocessing", - ] - concurrency = optparse.make_option( - '', '--concurrency', action='store', metavar="LIB", - choices=CONCURRENCY_CHOICES, - help=( - "Properly measure code using a concurrency library. " - "Valid values are: %s." - ) % ", ".join(CONCURRENCY_CHOICES), - ) - context = optparse.make_option( - '', '--context', action='store', metavar="LABEL", - help="The context label to record for this coverage run.", - ) - debug = optparse.make_option( - '', '--debug', action='store', metavar="OPTS", - help="Debug options, separated by commas. [env: COVERAGE_DEBUG]", - ) - directory = optparse.make_option( - '-d', '--directory', action='store', metavar="DIR", - help="Write the output files to DIR.", - ) - fail_under = optparse.make_option( - '', '--fail-under', action='store', metavar="MIN", type="float", - help="Exit with a status of 2 if the total coverage is less than MIN.", - ) - help = optparse.make_option( - '-h', '--help', action='store_true', - help="Get help on this command.", - ) - ignore_errors = optparse.make_option( - '-i', '--ignore-errors', action='store_true', - help="Ignore errors while reading source files.", - ) - include = optparse.make_option( - '', '--include', action='store', - metavar="PAT1,PAT2,...", - help=( - "Include only files whose paths match one of these patterns. " - "Accepts shell-style wildcards, which must be quoted." - ), - ) - pylib = optparse.make_option( - '-L', '--pylib', action='store_true', - help=( - "Measure coverage even inside the Python installed library, " - "which isn't done by default." - ), - ) - sort = optparse.make_option( - '--sort', action='store', metavar='COLUMN', - help="Sort the report by the named column: name, stmts, miss, branch, brpart, or cover. " - "Default is name." - ) - show_missing = optparse.make_option( - '-m', '--show-missing', action='store_true', - help="Show line numbers of statements in each module that weren't executed.", - ) - skip_covered = optparse.make_option( - '--skip-covered', action='store_true', - help="Skip files with 100% coverage.", - ) - no_skip_covered = optparse.make_option( - '--no-skip-covered', action='store_false', dest='skip_covered', - help="Disable --skip-covered.", - ) - skip_empty = optparse.make_option( - '--skip-empty', action='store_true', - help="Skip files with no code.", - ) - show_contexts = optparse.make_option( - '--show-contexts', action='store_true', - help="Show contexts for covered lines.", - ) - omit = optparse.make_option( - '', '--omit', action='store', - metavar="PAT1,PAT2,...", - help=( - "Omit files whose paths match one of these patterns. " - "Accepts shell-style wildcards, which must be quoted." - ), - ) - contexts = optparse.make_option( - '', '--contexts', action='store', - metavar="REGEX1,REGEX2,...", - help=( - "Only display data from lines covered in the given contexts. " - "Accepts Python regexes, which must be quoted." - ), - ) - output_xml = optparse.make_option( - '-o', '', action='store', dest="outfile", - metavar="OUTFILE", - help="Write the XML report to this file. Defaults to 'coverage.xml'", - ) - output_json = optparse.make_option( - '-o', '', action='store', dest="outfile", - metavar="OUTFILE", - help="Write the JSON report to this file. Defaults to 'coverage.json'", - ) - json_pretty_print = optparse.make_option( - '', '--pretty-print', action='store_true', - help="Format the JSON for human readers.", - ) - parallel_mode = optparse.make_option( - '-p', '--parallel-mode', action='store_true', - help=( - "Append the machine name, process id and random number to the " - ".coverage data file name to simplify collecting data from " - "many processes." - ), - ) - module = optparse.make_option( - '-m', '--module', action='store_true', - help=( - " is an importable Python module, not a script path, " - "to be run as 'python -m' would run it." - ), - ) - precision = optparse.make_option( - '', '--precision', action='store', metavar='N', type=int, - help=( - "Number of digits after the decimal point to display for " - "reported coverage percentages." - ), - ) - rcfile = optparse.make_option( - '', '--rcfile', action='store', - help=( - "Specify configuration file. " - "By default '.coveragerc', 'setup.cfg', 'tox.ini', and " - "'pyproject.toml' are tried. [env: COVERAGE_RCFILE]" - ), - ) - source = optparse.make_option( - '', '--source', action='store', metavar="SRC1,SRC2,...", - help="A list of packages or directories of code to be measured.", - ) - timid = optparse.make_option( - '', '--timid', action='store_true', - help=( - "Use a simpler but slower trace method. Try this if you get " - "seemingly impossible results!" - ), - ) - title = optparse.make_option( - '', '--title', action='store', metavar="TITLE", - help="A text string to use as the title on the HTML.", - ) - version = optparse.make_option( - '', '--version', action='store_true', - help="Display version information and exit.", - ) - - -class CoverageOptionParser(optparse.OptionParser, object): - """Base OptionParser for coverage.py. - - Problems don't exit the program. - Defaults are initialized for all options. - - """ - - def __init__(self, *args, **kwargs): - super(CoverageOptionParser, self).__init__( - add_help_option=False, *args, **kwargs - ) - self.set_defaults( - action=None, - append=None, - branch=None, - concurrency=None, - context=None, - debug=None, - directory=None, - fail_under=None, - help=None, - ignore_errors=None, - include=None, - keep=None, - module=None, - omit=None, - contexts=None, - parallel_mode=None, - precision=None, - pylib=None, - rcfile=True, - show_missing=None, - skip_covered=None, - skip_empty=None, - show_contexts=None, - sort=None, - source=None, - timid=None, - title=None, - version=None, - ) - - self.disable_interspersed_args() - - class OptionParserError(Exception): - """Used to stop the optparse error handler ending the process.""" - pass - - def parse_args_ok(self, args=None, options=None): - """Call optparse.parse_args, but return a triple: - - (ok, options, args) - - """ - try: - options, args = super(CoverageOptionParser, self).parse_args(args, options) - except self.OptionParserError: - return False, None, None - return True, options, args - - def error(self, msg): - """Override optparse.error so sys.exit doesn't get called.""" - show_help(msg) - raise self.OptionParserError - - -class GlobalOptionParser(CoverageOptionParser): - """Command-line parser for coverage.py global option arguments.""" - - def __init__(self): - super(GlobalOptionParser, self).__init__() - - self.add_options([ - Opts.help, - Opts.version, - ]) - - -class CmdOptionParser(CoverageOptionParser): - """Parse one of the new-style commands for coverage.py.""" - - def __init__(self, action, options, defaults=None, usage=None, description=None): - """Create an OptionParser for a coverage.py command. - - `action` is the slug to put into `options.action`. - `options` is a list of Option's for the command. - `defaults` is a dict of default value for options. - `usage` is the usage string to display in help. - `description` is the description of the command, for the help text. - - """ - if usage: - usage = "%prog " + usage - super(CmdOptionParser, self).__init__( - usage=usage, - description=description, - ) - self.set_defaults(action=action, **(defaults or {})) - self.add_options(options) - self.cmd = action - - def __eq__(self, other): - # A convenience equality, so that I can put strings in unit test - # results, and they will compare equal to objects. - return (other == "" % self.cmd) - - __hash__ = None # This object doesn't need to be hashed. - - def get_prog_name(self): - """Override of an undocumented function in optparse.OptionParser.""" - program_name = super(CmdOptionParser, self).get_prog_name() - - # Include the sub-command for this parser as part of the command. - return "{command} {subcommand}".format(command=program_name, subcommand=self.cmd) - - -GLOBAL_ARGS = [ - Opts.debug, - Opts.help, - Opts.rcfile, - ] - -CMDS = { - 'annotate': CmdOptionParser( - "annotate", - [ - Opts.directory, - Opts.ignore_errors, - Opts.include, - Opts.omit, - ] + GLOBAL_ARGS, - usage="[options] [modules]", - description=( - "Make annotated copies of the given files, marking statements that are executed " - "with > and statements that are missed with !." - ), - ), - - 'combine': CmdOptionParser( - "combine", - [ - Opts.append, - Opts.keep, - ] + GLOBAL_ARGS, - usage="[options] ... ", - description=( - "Combine data from multiple coverage files collected " - "with 'run -p'. The combined results are written to a single " - "file representing the union of the data. The positional " - "arguments are data files or directories containing data files. " - "If no paths are provided, data files in the default data file's " - "directory are combined." - ), - ), - - 'debug': CmdOptionParser( - "debug", GLOBAL_ARGS, - usage="", - description=( - "Display information about the internals of coverage.py, " - "for diagnosing problems. " - "Topics are: " - "'data' to show a summary of the collected data; " - "'sys' to show installation information; " - "'config' to show the configuration; " - "'premain' to show what is calling coverage." - ), - ), - - 'erase': CmdOptionParser( - "erase", GLOBAL_ARGS, - description="Erase previously collected coverage data.", - ), - - 'help': CmdOptionParser( - "help", GLOBAL_ARGS, - usage="[command]", - description="Describe how to use coverage.py", - ), - - 'html': CmdOptionParser( - "html", - [ - Opts.contexts, - Opts.directory, - Opts.fail_under, - Opts.ignore_errors, - Opts.include, - Opts.omit, - Opts.precision, - Opts.show_contexts, - Opts.skip_covered, - Opts.no_skip_covered, - Opts.skip_empty, - Opts.title, - ] + GLOBAL_ARGS, - usage="[options] [modules]", - description=( - "Create an HTML report of the coverage of the files. " - "Each file gets its own page, with the source decorated to show " - "executed, excluded, and missed lines." - ), - ), - - 'json': CmdOptionParser( - "json", - [ - Opts.contexts, - Opts.fail_under, - Opts.ignore_errors, - Opts.include, - Opts.omit, - Opts.output_json, - Opts.json_pretty_print, - Opts.show_contexts, - ] + GLOBAL_ARGS, - usage="[options] [modules]", - description="Generate a JSON report of coverage results." - ), - - 'report': CmdOptionParser( - "report", - [ - Opts.contexts, - Opts.fail_under, - Opts.ignore_errors, - Opts.include, - Opts.omit, - Opts.precision, - Opts.sort, - Opts.show_missing, - Opts.skip_covered, - Opts.no_skip_covered, - Opts.skip_empty, - ] + GLOBAL_ARGS, - usage="[options] [modules]", - description="Report coverage statistics on modules." - ), - - 'run': CmdOptionParser( - "run", - [ - Opts.append, - Opts.branch, - Opts.concurrency, - Opts.context, - Opts.include, - Opts.module, - Opts.omit, - Opts.pylib, - Opts.parallel_mode, - Opts.source, - Opts.timid, - ] + GLOBAL_ARGS, - usage="[options] [program options]", - description="Run a Python program, measuring code execution." - ), - - 'xml': CmdOptionParser( - "xml", - [ - Opts.fail_under, - Opts.ignore_errors, - Opts.include, - Opts.omit, - Opts.output_xml, - Opts.skip_empty, - ] + GLOBAL_ARGS, - usage="[options] [modules]", - description="Generate an XML report of coverage results." - ), -} - - -def show_help(error=None, topic=None, parser=None): - """Display an error message, or the named topic.""" - assert error or topic or parser - - program_path = sys.argv[0] - if program_path.endswith(os.path.sep + '__main__.py'): - # The path is the main module of a package; get that path instead. - program_path = os.path.dirname(program_path) - program_name = os.path.basename(program_path) - if env.WINDOWS: - # entry_points={'console_scripts':...} on Windows makes files - # called coverage.exe, coverage3.exe, and coverage-3.5.exe. These - # invoke coverage-script.py, coverage3-script.py, and - # coverage-3.5-script.py. argv[0] is the .py file, but we want to - # get back to the original form. - auto_suffix = "-script.py" - if program_name.endswith(auto_suffix): - program_name = program_name[:-len(auto_suffix)] - - help_params = dict(coverage.__dict__) - help_params['program_name'] = program_name - if CTracer is not None: - help_params['extension_modifier'] = 'with C extension' - else: - help_params['extension_modifier'] = 'without C extension' - - if error: - print(error, file=sys.stderr) - print("Use '%s help' for help." % (program_name,), file=sys.stderr) - elif parser: - print(parser.format_help().strip()) - print() - else: - help_msg = textwrap.dedent(HELP_TOPICS.get(topic, '')).strip() - if help_msg: - print(help_msg.format(**help_params)) - else: - print("Don't know topic %r" % topic) - print("Full documentation is at {__url__}".format(**help_params)) - - -OK, ERR, FAIL_UNDER = 0, 1, 2 - - -class CoverageScript(object): - """The command-line interface to coverage.py.""" - - def __init__(self): - self.global_option = False - self.coverage = None - - def command_line(self, argv): - """The bulk of the command line interface to coverage.py. - - `argv` is the argument list to process. - - Returns 0 if all is well, 1 if something went wrong. - - """ - # Collect the command-line options. - if not argv: - show_help(topic='minimum_help') - return OK - - # The command syntax we parse depends on the first argument. Global - # switch syntax always starts with an option. - self.global_option = argv[0].startswith('-') - if self.global_option: - parser = GlobalOptionParser() - else: - parser = CMDS.get(argv[0]) - if not parser: - show_help("Unknown command: '%s'" % argv[0]) - return ERR - argv = argv[1:] - - ok, options, args = parser.parse_args_ok(argv) - if not ok: - return ERR - - # Handle help and version. - if self.do_help(options, args, parser): - return OK - - # Listify the list options. - source = unshell_list(options.source) - omit = unshell_list(options.omit) - include = unshell_list(options.include) - debug = unshell_list(options.debug) - contexts = unshell_list(options.contexts) - - # Do something. - self.coverage = Coverage( - data_suffix=options.parallel_mode, - cover_pylib=options.pylib, - timid=options.timid, - branch=options.branch, - config_file=options.rcfile, - source=source, - omit=omit, - include=include, - debug=debug, - concurrency=options.concurrency, - check_preimported=True, - context=options.context, - ) - - if options.action == "debug": - return self.do_debug(args) - - elif options.action == "erase": - self.coverage.erase() - return OK - - elif options.action == "run": - return self.do_run(options, args) - - elif options.action == "combine": - if options.append: - self.coverage.load() - data_dirs = args or None - self.coverage.combine(data_dirs, strict=True, keep=bool(options.keep)) - self.coverage.save() - return OK - - # Remaining actions are reporting, with some common options. - report_args = dict( - morfs=unglob_args(args), - ignore_errors=options.ignore_errors, - omit=omit, - include=include, - contexts=contexts, - ) - - # We need to be able to import from the current directory, because - # plugins may try to, for example, to read Django settings. - sys.path.insert(0, '') - - self.coverage.load() - - total = None - if options.action == "report": - total = self.coverage.report( - show_missing=options.show_missing, - skip_covered=options.skip_covered, - skip_empty=options.skip_empty, - precision=options.precision, - sort=options.sort, - **report_args - ) - elif options.action == "annotate": - self.coverage.annotate(directory=options.directory, **report_args) - elif options.action == "html": - total = self.coverage.html_report( - directory=options.directory, - title=options.title, - skip_covered=options.skip_covered, - skip_empty=options.skip_empty, - show_contexts=options.show_contexts, - precision=options.precision, - **report_args - ) - elif options.action == "xml": - outfile = options.outfile - total = self.coverage.xml_report( - outfile=outfile, skip_empty=options.skip_empty, - **report_args - ) - elif options.action == "json": - outfile = options.outfile - total = self.coverage.json_report( - outfile=outfile, - pretty_print=options.pretty_print, - show_contexts=options.show_contexts, - **report_args - ) - - if total is not None: - # Apply the command line fail-under options, and then use the config - # value, so we can get fail_under from the config file. - if options.fail_under is not None: - self.coverage.set_option("report:fail_under", options.fail_under) - - fail_under = self.coverage.get_option("report:fail_under") - precision = self.coverage.get_option("report:precision") - if should_fail_under(total, fail_under, precision): - msg = "total of {total:.{p}f} is less than fail-under={fail_under:.{p}f}".format( - total=total, fail_under=fail_under, p=precision, - ) - print("Coverage failure:", msg) - return FAIL_UNDER - - return OK - - def do_help(self, options, args, parser): - """Deal with help requests. - - Return True if it handled the request, False if not. - - """ - # Handle help. - if options.help: - if self.global_option: - show_help(topic='help') - else: - show_help(parser=parser) - return True - - if options.action == "help": - if args: - for a in args: - parser = CMDS.get(a) - if parser: - show_help(parser=parser) - else: - show_help(topic=a) - else: - show_help(topic='help') - return True - - # Handle version. - if options.version: - show_help(topic='version') - return True - - return False - - def do_run(self, options, args): - """Implementation of 'coverage run'.""" - - if not args: - if options.module: - # Specified -m with nothing else. - show_help("No module specified for -m") - return ERR - command_line = self.coverage.get_option("run:command_line") - if command_line is not None: - args = shlex.split(command_line) - if args and args[0] == "-m": - options.module = True - args = args[1:] - if not args: - show_help("Nothing to do.") - return ERR - - if options.append and self.coverage.get_option("run:parallel"): - show_help("Can't append to data files in parallel mode.") - return ERR - - if options.concurrency == "multiprocessing": - # Can't set other run-affecting command line options with - # multiprocessing. - for opt_name in ['branch', 'include', 'omit', 'pylib', 'source', 'timid']: - # As it happens, all of these options have no default, meaning - # they will be None if they have not been specified. - if getattr(options, opt_name) is not None: - show_help( - "Options affecting multiprocessing must only be specified " - "in a configuration file.\n" - "Remove --{} from the command line.".format(opt_name) - ) - return ERR - - runner = PyRunner(args, as_module=bool(options.module)) - runner.prepare() - - if options.append: - self.coverage.load() - - # Run the script. - self.coverage.start() - code_ran = True - try: - runner.run() - except NoSource: - code_ran = False - raise - finally: - self.coverage.stop() - if code_ran: - self.coverage.save() - - return OK - - def do_debug(self, args): - """Implementation of 'coverage debug'.""" - - if not args: - show_help("What information would you like: config, data, sys, premain?") - return ERR - - for info in args: - if info == 'sys': - sys_info = self.coverage.sys_info() - print(info_header("sys")) - for line in info_formatter(sys_info): - print(" %s" % line) - elif info == 'data': - self.coverage.load() - data = self.coverage.get_data() - print(info_header("data")) - print("path: %s" % data.data_filename()) - if data: - print("has_arcs: %r" % data.has_arcs()) - summary = line_counts(data, fullpath=True) - filenames = sorted(summary.keys()) - print("\n%d files:" % len(filenames)) - for f in filenames: - line = "%s: %d lines" % (f, summary[f]) - plugin = data.file_tracer(f) - if plugin: - line += " [%s]" % plugin - print(line) - else: - print("No data collected") - elif info == 'config': - print(info_header("config")) - config_info = self.coverage.config.__dict__.items() - for line in info_formatter(config_info): - print(" %s" % line) - elif info == "premain": - print(info_header("premain")) - print(short_stack()) - else: - show_help("Don't know what you mean by %r" % info) - return ERR - - return OK - - -def unshell_list(s): - """Turn a command-line argument into a list.""" - if not s: - return None - if env.WINDOWS: - # When running coverage.py as coverage.exe, some of the behavior - # of the shell is emulated: wildcards are expanded into a list of - # file names. So you have to single-quote patterns on the command - # line, but (not) helpfully, the single quotes are included in the - # argument, so we have to strip them off here. - s = s.strip("'") - return s.split(',') - - -def unglob_args(args): - """Interpret shell wildcards for platforms that need it.""" - if env.WINDOWS: - globbed = [] - for arg in args: - if '?' in arg or '*' in arg: - globbed.extend(glob.glob(arg)) - else: - globbed.append(arg) - args = globbed - return args - - -HELP_TOPICS = { - 'help': """\ - Coverage.py, version {__version__} {extension_modifier} - Measure, collect, and report on code coverage in Python programs. - - usage: {program_name} [options] [args] - - Commands: - annotate Annotate source files with execution information. - combine Combine a number of data files. - debug Display information about the internals of coverage.py - erase Erase previously collected coverage data. - help Get help on using coverage.py. - html Create an HTML report. - json Create a JSON report of coverage results. - report Report coverage stats on modules. - run Run a Python program and measure code execution. - xml Create an XML report of coverage results. - - Use "{program_name} help " for detailed help on any command. - """, - - 'minimum_help': """\ - Code coverage for Python, version {__version__} {extension_modifier}. Use '{program_name} help' for help. - """, - - 'version': """\ - Coverage.py, version {__version__} {extension_modifier} - """, -} - - -def main(argv=None): - """The main entry point to coverage.py. - - This is installed as the script entry point. - - """ - if argv is None: - argv = sys.argv[1:] - try: - status = CoverageScript().command_line(argv) - except ExceptionDuringRun as err: - # An exception was caught while running the product code. The - # sys.exc_info() return tuple is packed into an ExceptionDuringRun - # exception. - traceback.print_exception(*err.args) # pylint: disable=no-value-for-parameter - status = ERR - except BaseCoverageException as err: - # A controlled error inside coverage.py: print the message to the user. - msg = err.args[0] - if env.PY2: - msg = msg.encode(output_encoding()) - print(msg) - status = ERR - except SystemExit as err: - # The user called `sys.exit()`. Exit with their argument, if any. - if err.args: - status = err.args[0] - else: - status = None - return status - -# Profiling using ox_profile. Install it from GitHub: -# pip install git+https://github.com/emin63/ox_profile.git -# -# $set_env.py: COVERAGE_PROFILE - Set to use ox_profile. -_profile = os.environ.get("COVERAGE_PROFILE", "") -if _profile: # pragma: debugging - from ox_profile.core.launchers import SimpleLauncher # pylint: disable=import-error - original_main = main - - def main(argv=None): # pylint: disable=function-redefined - """A wrapper around main that profiles.""" - profiler = SimpleLauncher.launch() - try: - return original_main(argv) - finally: - data, _ = profiler.query(re_filter='coverage', max_records=100) - print(profiler.show(query=data, limit=100, sep='', col='')) - profiler.cancel() diff --git a/contrib/python/coverage/py2/coverage/collector.py b/contrib/python/coverage/py2/coverage/collector.py deleted file mode 100644 index c42d29feec9..00000000000 --- a/contrib/python/coverage/py2/coverage/collector.py +++ /dev/null @@ -1,455 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Raw data collector for coverage.py.""" - -import os -import sys - -from coverage import env -from coverage.backward import litems, range # pylint: disable=redefined-builtin -from coverage.debug import short_stack -from coverage.disposition import FileDisposition -from coverage.misc import CoverageException, isolate_module -from coverage.pytracer import PyTracer - -os = isolate_module(os) - - -try: - # Use the C extension code when we can, for speed. - from coverage.tracer import CTracer, CFileDisposition -except ImportError: - # Couldn't import the C extension, maybe it isn't built. - if os.getenv('COVERAGE_TEST_TRACER') == 'c': - # During testing, we use the COVERAGE_TEST_TRACER environment variable - # to indicate that we've fiddled with the environment to test this - # fallback code. If we thought we had a C tracer, but couldn't import - # it, then exit quickly and clearly instead of dribbling confusing - # errors. I'm using sys.exit here instead of an exception because an - # exception here causes all sorts of other noise in unittest. - sys.stderr.write("*** COVERAGE_TEST_TRACER is 'c' but can't import CTracer!\n") - sys.exit(1) - CTracer = None - - -class Collector(object): - """Collects trace data. - - Creates a Tracer object for each thread, since they track stack - information. Each Tracer points to the same shared data, contributing - traced data points. - - When the Collector is started, it creates a Tracer for the current thread, - and installs a function to create Tracers for each new thread started. - When the Collector is stopped, all active Tracers are stopped. - - Threads started while the Collector is stopped will never have Tracers - associated with them. - - """ - - # The stack of active Collectors. Collectors are added here when started, - # and popped when stopped. Collectors on the stack are paused when not - # the top, and resumed when they become the top again. - _collectors = [] - - # The concurrency settings we support here. - SUPPORTED_CONCURRENCIES = {"greenlet", "eventlet", "gevent", "thread"} - - def __init__( - self, should_trace, check_include, should_start_context, file_mapper, - timid, branch, warn, concurrency, - ): - """Create a collector. - - `should_trace` is a function, taking a file name and a frame, and - returning a `coverage.FileDisposition object`. - - `check_include` is a function taking a file name and a frame. It returns - a boolean: True if the file should be traced, False if not. - - `should_start_context` is a function taking a frame, and returning a - string. If the frame should be the start of a new context, the string - is the new context. If the frame should not be the start of a new - context, return None. - - `file_mapper` is a function taking a filename, and returning a Unicode - filename. The result is the name that will be recorded in the data - file. - - If `timid` is true, then a slower simpler trace function will be - used. This is important for some environments where manipulation of - tracing functions make the faster more sophisticated trace function not - operate properly. - - If `branch` is true, then branches will be measured. This involves - collecting data on which statements followed each other (arcs). Use - `get_arc_data` to get the arc data. - - `warn` is a warning function, taking a single string message argument - and an optional slug argument which will be a string or None, to be - used if a warning needs to be issued. - - `concurrency` is a list of strings indicating the concurrency libraries - in use. Valid values are "greenlet", "eventlet", "gevent", or "thread" - (the default). Of these four values, only one can be supplied. Other - values are ignored. - - """ - self.should_trace = should_trace - self.check_include = check_include - self.should_start_context = should_start_context - self.file_mapper = file_mapper - self.warn = warn - self.branch = branch - self.threading = None - self.covdata = None - - self.static_context = None - - self.origin = short_stack() - - self.concur_id_func = None - self.mapped_file_cache = {} - - # We can handle a few concurrency options here, but only one at a time. - these_concurrencies = self.SUPPORTED_CONCURRENCIES.intersection(concurrency) - if len(these_concurrencies) > 1: - raise CoverageException("Conflicting concurrency settings: %s" % concurrency) - self.concurrency = these_concurrencies.pop() if these_concurrencies else '' - - try: - if self.concurrency == "greenlet": - import greenlet - self.concur_id_func = greenlet.getcurrent - elif self.concurrency == "eventlet": - import eventlet.greenthread # pylint: disable=import-error,useless-suppression - self.concur_id_func = eventlet.greenthread.getcurrent - elif self.concurrency == "gevent": - import gevent # pylint: disable=import-error,useless-suppression - self.concur_id_func = gevent.getcurrent - elif self.concurrency == "thread" or not self.concurrency: - # It's important to import threading only if we need it. If - # it's imported early, and the program being measured uses - # gevent, then gevent's monkey-patching won't work properly. - import threading - self.threading = threading - else: - raise CoverageException("Don't understand concurrency=%s" % concurrency) - except ImportError: - raise CoverageException( - "Couldn't trace with concurrency=%s, the module isn't installed." % ( - self.concurrency, - ) - ) - - self.reset() - - if timid: - # Being timid: use the simple Python trace function. - self._trace_class = PyTracer - else: - # Being fast: use the C Tracer if it is available, else the Python - # trace function. - self._trace_class = CTracer or PyTracer - - if self._trace_class is CTracer: - self.file_disposition_class = CFileDisposition - self.supports_plugins = True - else: - self.file_disposition_class = FileDisposition - self.supports_plugins = False - - def __repr__(self): - return "" % (id(self), self.tracer_name()) - - def use_data(self, covdata, context): - """Use `covdata` for recording data.""" - self.covdata = covdata - self.static_context = context - self.covdata.set_context(self.static_context) - - def tracer_name(self): - """Return the class name of the tracer we're using.""" - return self._trace_class.__name__ - - def _clear_data(self): - """Clear out existing data, but stay ready for more collection.""" - # We used to used self.data.clear(), but that would remove filename - # keys and data values that were still in use higher up the stack - # when we are called as part of switch_context. - for d in self.data.values(): - d.clear() - - for tracer in self.tracers: - tracer.reset_activity() - - def reset(self): - """Clear collected data, and prepare to collect more.""" - # A dictionary mapping file names to dicts with line number keys (if not - # branch coverage), or mapping file names to dicts with line number - # pairs as keys (if branch coverage). - self.data = {} - - # A dictionary mapping file names to file tracer plugin names that will - # handle them. - self.file_tracers = {} - - self.disabled_plugins = set() - - # The .should_trace_cache attribute is a cache from file names to - # coverage.FileDisposition objects, or None. When a file is first - # considered for tracing, a FileDisposition is obtained from - # Coverage.should_trace. Its .trace attribute indicates whether the - # file should be traced or not. If it should be, a plugin with dynamic - # file names can decide not to trace it based on the dynamic file name - # being excluded by the inclusion rules, in which case the - # FileDisposition will be replaced by None in the cache. - if env.PYPY: - import __pypy__ # pylint: disable=import-error - # Alex Gaynor said: - # should_trace_cache is a strictly growing key: once a key is in - # it, it never changes. Further, the keys used to access it are - # generally constant, given sufficient context. That is to say, at - # any given point _trace() is called, pypy is able to know the key. - # This is because the key is determined by the physical source code - # line, and that's invariant with the call site. - # - # This property of a dict with immutable keys, combined with - # call-site-constant keys is a match for PyPy's module dict, - # which is optimized for such workloads. - # - # This gives a 20% benefit on the workload described at - # https://bitbucket.org/pypy/pypy/issue/1871/10x-slower-than-cpython-under-coverage - self.should_trace_cache = __pypy__.newdict("module") - else: - self.should_trace_cache = {} - - # Our active Tracers. - self.tracers = [] - - self._clear_data() - - def _start_tracer(self): - """Start a new Tracer object, and store it in self.tracers.""" - tracer = self._trace_class() - tracer.data = self.data - tracer.trace_arcs = self.branch - tracer.should_trace = self.should_trace - tracer.should_trace_cache = self.should_trace_cache - tracer.warn = self.warn - - if hasattr(tracer, 'concur_id_func'): - tracer.concur_id_func = self.concur_id_func - elif self.concur_id_func: - raise CoverageException( - "Can't support concurrency=%s with %s, only threads are supported" % ( - self.concurrency, self.tracer_name(), - ) - ) - - if hasattr(tracer, 'file_tracers'): - tracer.file_tracers = self.file_tracers - if hasattr(tracer, 'threading'): - tracer.threading = self.threading - if hasattr(tracer, 'check_include'): - tracer.check_include = self.check_include - if hasattr(tracer, 'should_start_context'): - tracer.should_start_context = self.should_start_context - tracer.switch_context = self.switch_context - if hasattr(tracer, 'disable_plugin'): - tracer.disable_plugin = self.disable_plugin - - fn = tracer.start() - self.tracers.append(tracer) - - return fn - - # The trace function has to be set individually on each thread before - # execution begins. Ironically, the only support the threading module has - # for running code before the thread main is the tracing function. So we - # install this as a trace function, and the first time it's called, it does - # the real trace installation. - - def _installation_trace(self, frame, event, arg): - """Called on new threads, installs the real tracer.""" - # Remove ourselves as the trace function. - sys.settrace(None) - # Install the real tracer. - fn = self._start_tracer() - # Invoke the real trace function with the current event, to be sure - # not to lose an event. - if fn: - fn = fn(frame, event, arg) - # Return the new trace function to continue tracing in this scope. - return fn - - def start(self): - """Start collecting trace information.""" - if self._collectors: - self._collectors[-1].pause() - - self.tracers = [] - - # Check to see whether we had a fullcoverage tracer installed. If so, - # get the stack frames it stashed away for us. - traces0 = [] - fn0 = sys.gettrace() - if fn0: - tracer0 = getattr(fn0, '__self__', None) - if tracer0: - traces0 = getattr(tracer0, 'traces', []) - - try: - # Install the tracer on this thread. - fn = self._start_tracer() - except: - if self._collectors: - self._collectors[-1].resume() - raise - - # If _start_tracer succeeded, then we add ourselves to the global - # stack of collectors. - self._collectors.append(self) - - # Replay all the events from fullcoverage into the new trace function. - for args in traces0: - (frame, event, arg), lineno = args - try: - fn(frame, event, arg, lineno=lineno) - except TypeError: - raise Exception("fullcoverage must be run with the C trace function.") - - # Install our installation tracer in threading, to jump-start other - # threads. - if self.threading: - self.threading.settrace(self._installation_trace) - - def stop(self): - """Stop collecting trace information.""" - assert self._collectors - if self._collectors[-1] is not self: - print("self._collectors:") - for c in self._collectors: - print(" {!r}\n{}".format(c, c.origin)) - assert self._collectors[-1] is self, ( - "Expected current collector to be %r, but it's %r" % (self, self._collectors[-1]) - ) - - self.pause() - - # Remove this Collector from the stack, and resume the one underneath - # (if any). - self._collectors.pop() - if self._collectors: - self._collectors[-1].resume() - - def pause(self): - """Pause tracing, but be prepared to `resume`.""" - for tracer in self.tracers: - tracer.stop() - stats = tracer.get_stats() - if stats: - print("\nCoverage.py tracer stats:") - for k in sorted(stats.keys()): - print("%20s: %s" % (k, stats[k])) - if self.threading: - self.threading.settrace(None) - - def resume(self): - """Resume tracing after a `pause`.""" - for tracer in self.tracers: - tracer.start() - if self.threading: - self.threading.settrace(self._installation_trace) - else: - self._start_tracer() - - def _activity(self): - """Has any activity been traced? - - Returns a boolean, True if any trace function was invoked. - - """ - return any(tracer.activity() for tracer in self.tracers) - - def switch_context(self, new_context): - """Switch to a new dynamic context.""" - self.flush_data() - if self.static_context: - context = self.static_context - if new_context: - context += "|" + new_context - else: - context = new_context - self.covdata.set_context(context) - - def disable_plugin(self, disposition): - """Disable the plugin mentioned in `disposition`.""" - file_tracer = disposition.file_tracer - plugin = file_tracer._coverage_plugin - plugin_name = plugin._coverage_plugin_name - self.warn("Disabling plug-in {!r} due to previous exception".format(plugin_name)) - plugin._coverage_enabled = False - disposition.trace = False - - def cached_mapped_file(self, filename): - """A locally cached version of file names mapped through file_mapper.""" - key = (type(filename), filename) - try: - return self.mapped_file_cache[key] - except KeyError: - return self.mapped_file_cache.setdefault(key, self.file_mapper(filename)) - - def mapped_file_dict(self, d): - """Return a dict like d, but with keys modified by file_mapper.""" - # The call to litems() ensures that the GIL protects the dictionary - # iterator against concurrent modifications by tracers running - # in other threads. We try three times in case of concurrent - # access, hoping to get a clean copy. - runtime_err = None - for _ in range(3): - try: - items = litems(d) - except RuntimeError as ex: - runtime_err = ex - else: - break - else: - raise runtime_err - - if getattr(sys, 'is_standalone_binary', False): - # filenames should stay relative to the arcadia root, because files may not exist - return dict((k, v) for k, v in items if v) - - return dict((self.cached_mapped_file(k), v) for k, v in items if v) - - def plugin_was_disabled(self, plugin): - """Record that `plugin` was disabled during the run.""" - self.disabled_plugins.add(plugin._coverage_plugin_name) - - def flush_data(self): - """Save the collected data to our associated `CoverageData`. - - Data may have also been saved along the way. This forces the - last of the data to be saved. - - Returns True if there was data to save, False if not. - """ - if not self._activity(): - return False - - if self.branch: - self.covdata.add_arcs(self.mapped_file_dict(self.data)) - else: - self.covdata.add_lines(self.mapped_file_dict(self.data)) - - file_tracers = { - k: v for k, v in self.file_tracers.items() - if v not in self.disabled_plugins - } - self.covdata.add_file_tracers(self.mapped_file_dict(file_tracers)) - - self._clear_data() - return True diff --git a/contrib/python/coverage/py2/coverage/config.py b/contrib/python/coverage/py2/coverage/config.py deleted file mode 100644 index ceb7201b65f..00000000000 --- a/contrib/python/coverage/py2/coverage/config.py +++ /dev/null @@ -1,605 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Config file for coverage.py""" - -import collections -import copy -import os -import os.path -import re -import sys - -from coverage import env -from coverage.backward import configparser, iitems, string_class -from coverage.misc import contract, CoverageException, isolate_module -from coverage.misc import substitute_variables - -from coverage.tomlconfig import TomlConfigParser, TomlDecodeError - -os = isolate_module(os) - - -class HandyConfigParser(configparser.RawConfigParser): - """Our specialization of ConfigParser.""" - - def __init__(self, our_file): - """Create the HandyConfigParser. - - `our_file` is True if this config file is specifically for coverage, - False if we are examining another config file (tox.ini, setup.cfg) - for possible settings. - """ - - configparser.RawConfigParser.__init__(self) - self.section_prefixes = ["coverage:"] - if our_file: - self.section_prefixes.append("") - - def read(self, filenames, encoding=None): - """Read a file name as UTF-8 configuration data.""" - kwargs = {} - if env.PYVERSION >= (3, 2): - kwargs['encoding'] = encoding or "utf-8" - return configparser.RawConfigParser.read(self, filenames, **kwargs) - - def has_option(self, section, option): - for section_prefix in self.section_prefixes: - real_section = section_prefix + section - has = configparser.RawConfigParser.has_option(self, real_section, option) - if has: - return has - return False - - def has_section(self, section): - for section_prefix in self.section_prefixes: - real_section = section_prefix + section - has = configparser.RawConfigParser.has_section(self, real_section) - if has: - return real_section - return False - - def options(self, section): - for section_prefix in self.section_prefixes: - real_section = section_prefix + section - if configparser.RawConfigParser.has_section(self, real_section): - return configparser.RawConfigParser.options(self, real_section) - raise configparser.NoSectionError(section) - - def get_section(self, section): - """Get the contents of a section, as a dictionary.""" - d = {} - for opt in self.options(section): - d[opt] = self.get(section, opt) - return d - - def get(self, section, option, *args, **kwargs): - """Get a value, replacing environment variables also. - - The arguments are the same as `RawConfigParser.get`, but in the found - value, ``$WORD`` or ``${WORD}`` are replaced by the value of the - environment variable ``WORD``. - - Returns the finished value. - - """ - for section_prefix in self.section_prefixes: - real_section = section_prefix + section - if configparser.RawConfigParser.has_option(self, real_section, option): - break - else: - raise configparser.NoOptionError(option, section) - - v = configparser.RawConfigParser.get(self, real_section, option, *args, **kwargs) - v = substitute_variables(v, os.environ) - return v - - def getlist(self, section, option): - """Read a list of strings. - - The value of `section` and `option` is treated as a comma- and newline- - separated list of strings. Each value is stripped of whitespace. - - Returns the list of strings. - - """ - value_list = self.get(section, option) - values = [] - for value_line in value_list.split('\n'): - for value in value_line.split(','): - value = value.strip() - if value: - values.append(value) - return values - - def getregexlist(self, section, option): - """Read a list of full-line regexes. - - The value of `section` and `option` is treated as a newline-separated - list of regexes. Each value is stripped of whitespace. - - Returns the list of strings. - - """ - line_list = self.get(section, option) - value_list = [] - for value in line_list.splitlines(): - value = value.strip() - try: - re.compile(value) - except re.error as e: - raise CoverageException( - "Invalid [%s].%s value %r: %s" % (section, option, value, e) - ) - if value: - value_list.append(value) - return value_list - - -# The default line exclusion regexes. -DEFAULT_EXCLUDE = [ - r'#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(cover|COVER)', -] - -# The default partial branch regexes, to be modified by the user. -DEFAULT_PARTIAL = [ - r'#\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(branch|BRANCH)', -] - -# The default partial branch regexes, based on Python semantics. -# These are any Python branching constructs that can't actually execute all -# their branches. -DEFAULT_PARTIAL_ALWAYS = [ - 'while (True|1|False|0):', - 'if (True|1|False|0):', -] - - -class CoverageConfig(object): - """Coverage.py configuration. - - The attributes of this class are the various settings that control the - operation of coverage.py. - - """ - # pylint: disable=too-many-instance-attributes - - def __init__(self): - """Initialize the configuration attributes to their defaults.""" - # Metadata about the config. - # We tried to read these config files. - self.attempted_config_files = [] - # We did read these config files, but maybe didn't find any content for us. - self.config_files_read = [] - # The file that gave us our configuration. - self.config_file = None - self._config_contents = None - - # Defaults for [run] and [report] - self._include = None - self._omit = None - - # Defaults for [run] - self.branch = False - self.command_line = None - self.concurrency = None - self.context = None - self.cover_pylib = False - self.data_file = ".coverage" - self.debug = [] - self.disable_warnings = [] - self.dynamic_context = None - self.note = None - self.parallel = False - self.plugins = [] - self.relative_files = False - self.run_include = None - self.run_omit = None - self.source = None - self.source_pkgs = [] - self.timid = False - self._crash = None - - # Defaults for [report] - self.exclude_list = DEFAULT_EXCLUDE[:] - self.fail_under = 0.0 - self.ignore_errors = False - self.report_include = None - self.report_omit = None - self.partial_always_list = DEFAULT_PARTIAL_ALWAYS[:] - self.partial_list = DEFAULT_PARTIAL[:] - self.precision = 0 - self.report_contexts = None - self.show_missing = False - self.skip_covered = False - self.skip_empty = False - self.sort = None - - # Defaults for [html] - self.extra_css = None - self.html_dir = "htmlcov" - self.html_skip_covered = None - self.html_skip_empty = None - self.html_title = "Coverage report" - self.show_contexts = False - - # Defaults for [xml] - self.xml_output = "coverage.xml" - self.xml_package_depth = 99 - - # Defaults for [json] - self.json_output = "coverage.json" - self.json_pretty_print = False - self.json_show_contexts = False - - # Defaults for [paths] - self.paths = collections.OrderedDict() - - # Options for plugins - self.plugin_options = {} - self.suppress_plugin_errors = True - - MUST_BE_LIST = [ - "debug", "concurrency", "plugins", - "report_omit", "report_include", - "run_omit", "run_include", - ] - - def from_args(self, **kwargs): - """Read config values from `kwargs`.""" - for k, v in iitems(kwargs): - if v is not None: - if k in self.MUST_BE_LIST and isinstance(v, string_class): - v = [v] - setattr(self, k, v) - - def from_resource(self, resource_name): - assert getattr(sys, 'is_standalone_binary', False), 'You have used method by mistake in script, not binary' - cp, self._config_contents = _load_config_from_resource(resource_name) - return self._parse_config(cp, resource_name, True) - - @contract(filename=str) - def from_file(self, filename, our_file): - """Read configuration from a .rc file. - - `filename` is a file name to read. - - `our_file` is True if this config file is specifically for coverage, - False if we are examining another config file (tox.ini, setup.cfg) - for possible settings. - - Returns True or False, whether the file could be read, and it had some - coverage.py settings in it. - - """ - _, ext = os.path.splitext(filename) - if ext == '.toml': - cp = TomlConfigParser(our_file) - else: - cp = HandyConfigParser(our_file) - - self.attempted_config_files.append(filename) - - try: - files_read = cp.read(filename) - except (configparser.Error, TomlDecodeError) as err: - raise CoverageException("Couldn't read config file %s: %s" % (filename, err)) - if not files_read: - return False - - self.config_files_read.extend(map(os.path.abspath, files_read)) - - return self._parse_config(cp, filename, our_file) - - def _parse_config(self, cp, filename, our_file): - any_set = False - try: - for option_spec in self.CONFIG_FILE_OPTIONS: - was_set = self._set_attr_from_config_option(cp, *option_spec) - if was_set: - any_set = True - except ValueError as err: - raise CoverageException("Couldn't read config file %s: %s" % (filename, err)) - - # Check that there are no unrecognized options. - all_options = collections.defaultdict(set) - for option_spec in self.CONFIG_FILE_OPTIONS: - section, option = option_spec[1].split(":") - all_options[section].add(option) - - for section, options in iitems(all_options): - real_section = cp.has_section(section) - if real_section: - for unknown in set(cp.options(section)) - options: - raise CoverageException( - "Unrecognized option '[%s] %s=' in config file %s" % ( - real_section, unknown, filename - ) - ) - - # [paths] is special - if cp.has_section('paths'): - for option in cp.options('paths'): - self.paths[option] = cp.getlist('paths', option) - any_set = True - - # plugins can have options - for plugin in self.plugins: - if cp.has_section(plugin): - self.plugin_options[plugin] = cp.get_section(plugin) - any_set = True - - # Was this file used as a config file? If it's specifically our file, - # then it was used. If we're piggybacking on someone else's file, - # then it was only used if we found some settings in it. - if our_file: - used = True - else: - used = any_set - - if used: - self.config_file = os.path.abspath(filename) - if not getattr(sys, 'is_standalone_binary', False): - with open(filename, "rb") as f: - self._config_contents = f.read() - - return used - - def copy(self): - """Return a copy of the configuration.""" - return copy.deepcopy(self) - - CONFIG_FILE_OPTIONS = [ - # These are *args for _set_attr_from_config_option: - # (attr, where, type_="") - # - # attr is the attribute to set on the CoverageConfig object. - # where is the section:name to read from the configuration file. - # type_ is the optional type to apply, by using .getTYPE to read the - # configuration value from the file. - - # [run] - ('branch', 'run:branch', 'boolean'), - ('command_line', 'run:command_line'), - ('concurrency', 'run:concurrency', 'list'), - ('context', 'run:context'), - ('cover_pylib', 'run:cover_pylib', 'boolean'), - ('data_file', 'run:data_file'), - ('debug', 'run:debug', 'list'), - ('disable_warnings', 'run:disable_warnings', 'list'), - ('dynamic_context', 'run:dynamic_context'), - ('note', 'run:note'), - ('parallel', 'run:parallel', 'boolean'), - ('plugins', 'run:plugins', 'list'), - ('relative_files', 'run:relative_files', 'boolean'), - ('run_include', 'run:include', 'list'), - ('run_omit', 'run:omit', 'list'), - ('source', 'run:source', 'list'), - ('source_pkgs', 'run:source_pkgs', 'list'), - ('timid', 'run:timid', 'boolean'), - ('_crash', 'run:_crash'), - ('suppress_plugin_errors', 'run:suppress_plugin_errors', 'boolean'), - - # [report] - ('exclude_list', 'report:exclude_lines', 'regexlist'), - ('fail_under', 'report:fail_under', 'float'), - ('ignore_errors', 'report:ignore_errors', 'boolean'), - ('partial_always_list', 'report:partial_branches_always', 'regexlist'), - ('partial_list', 'report:partial_branches', 'regexlist'), - ('precision', 'report:precision', 'int'), - ('report_contexts', 'report:contexts', 'list'), - ('report_include', 'report:include', 'list'), - ('report_omit', 'report:omit', 'list'), - ('show_missing', 'report:show_missing', 'boolean'), - ('skip_covered', 'report:skip_covered', 'boolean'), - ('skip_empty', 'report:skip_empty', 'boolean'), - ('sort', 'report:sort'), - - # [html] - ('extra_css', 'html:extra_css'), - ('html_dir', 'html:directory'), - ('html_skip_covered', 'html:skip_covered', 'boolean'), - ('html_skip_empty', 'html:skip_empty', 'boolean'), - ('html_title', 'html:title'), - ('show_contexts', 'html:show_contexts', 'boolean'), - - # [xml] - ('xml_output', 'xml:output'), - ('xml_package_depth', 'xml:package_depth', 'int'), - - # [json] - ('json_output', 'json:output'), - ('json_pretty_print', 'json:pretty_print', 'boolean'), - ('json_show_contexts', 'json:show_contexts', 'boolean'), - ] - - def _set_attr_from_config_option(self, cp, attr, where, type_=''): - """Set an attribute on self if it exists in the ConfigParser. - - Returns True if the attribute was set. - - """ - section, option = where.split(":") - if cp.has_option(section, option): - method = getattr(cp, 'get' + type_) - setattr(self, attr, method(section, option)) - return True - return False - - def get_plugin_options(self, plugin): - """Get a dictionary of options for the plugin named `plugin`.""" - return self.plugin_options.get(plugin, {}) - - def set_option(self, option_name, value): - """Set an option in the configuration. - - `option_name` is a colon-separated string indicating the section and - option name. For example, the ``branch`` option in the ``[run]`` - section of the config file would be indicated with `"run:branch"`. - - `value` is the new value for the option. - - """ - # Special-cased options. - if option_name == "paths": - self.paths = value - return - - # Check all the hard-coded options. - for option_spec in self.CONFIG_FILE_OPTIONS: - attr, where = option_spec[:2] - if where == option_name: - setattr(self, attr, value) - return - - # See if it's a plugin option. - plugin_name, _, key = option_name.partition(":") - if key and plugin_name in self.plugins: - self.plugin_options.setdefault(plugin_name, {})[key] = value - return - - # If we get here, we didn't find the option. - raise CoverageException("No such option: %r" % option_name) - - def get_option(self, option_name): - """Get an option from the configuration. - - `option_name` is a colon-separated string indicating the section and - option name. For example, the ``branch`` option in the ``[run]`` - section of the config file would be indicated with `"run:branch"`. - - Returns the value of the option. - - """ - # Special-cased options. - if option_name == "paths": - return self.paths - - # Check all the hard-coded options. - for option_spec in self.CONFIG_FILE_OPTIONS: - attr, where = option_spec[:2] - if where == option_name: - return getattr(self, attr) - - # See if it's a plugin option. - plugin_name, _, key = option_name.partition(":") - if key and plugin_name in self.plugins: - return self.plugin_options.get(plugin_name, {}).get(key) - - # If we get here, we didn't find the option. - raise CoverageException("No such option: %r" % option_name) - - def post_process_file(self, path): - """Make final adjustments to a file path to make it usable.""" - return os.path.expanduser(path) - - def post_process(self): - """Make final adjustments to settings to make them usable.""" - self.data_file = self.post_process_file(self.data_file) - self.html_dir = self.post_process_file(self.html_dir) - self.xml_output = self.post_process_file(self.xml_output) - self.paths = collections.OrderedDict( - (k, [self.post_process_file(f) for f in v]) - for k, v in self.paths.items() - ) - - -def config_files_to_try(config_file): - """What config files should we try to read? - - Returns a list of tuples: - (filename, is_our_file, was_file_specified) - """ - - # Some API users were specifying ".coveragerc" to mean the same as - # True, so make it so. - if config_file == ".coveragerc": - config_file = True - specified_file = (config_file is not True) - if not specified_file: - # No file was specified. Check COVERAGE_RCFILE. - config_file = os.environ.get('COVERAGE_RCFILE') - if config_file: - specified_file = True - if not specified_file: - # Still no file specified. Default to .coveragerc - config_file = ".coveragerc" - files_to_try = [ - (config_file, True, specified_file), - ("setup.cfg", False, False), - ("tox.ini", False, False), - ("pyproject.toml", False, False), - ] - return files_to_try - - -def read_coverage_config(config_file, **kwargs): - """Read the coverage.py configuration. - - Arguments: - config_file: a boolean or string, see the `Coverage` class for the - tricky details. - all others: keyword arguments from the `Coverage` class, used for - setting values in the configuration. - - Returns: - config: - config is a CoverageConfig object read from the appropriate - configuration file. - - """ - # Build the configuration from a number of sources: - # 1) defaults: - config = CoverageConfig() - - # 1.1 built-in config - if getattr(sys, 'is_standalone_binary', False): - config.from_resource("/coverage_plugins/coveragerc.txt") - - # 2) from a file: - if config_file: - files_to_try = config_files_to_try(config_file) - - for fname, our_file, specified_file in files_to_try: - if getattr(sys, 'is_standalone_binary', False) and fname == "/coverage_plugins/coveragerc.txt": - continue - config_read = config.from_file(fname, our_file=our_file) - if config_read: - break - if specified_file: - raise CoverageException("Couldn't read '%s' as a config file" % fname) - - # $set_env.py: COVERAGE_DEBUG - Options for --debug. - # 3) from environment variables: - env_data_file = os.environ.get('COVERAGE_FILE') - if env_data_file: - config.data_file = env_data_file - debugs = os.environ.get('COVERAGE_DEBUG') - if debugs: - config.debug.extend(d.strip() for d in debugs.split(",")) - - # 4) from constructor arguments: - config.from_args(**kwargs) - - # Once all the config has been collected, there's a little post-processing - # to do. - config.post_process() - - return config - - -def _load_config_from_resource(resource_name): - from io import StringIO - from library.python import resource - - config_data = resource.find(resource_name) - if config_data is None: - raise IOError("No such resource: " + resource_name) - - config_data = config_data.decode('utf-8') - cp = HandyConfigParser(True) - try: - cp.readfp(StringIO(config_data)) - except configparser.Error as err: - raise CoverageException("Couldn't read config %s: %s" % (resource_name, err)) - return cp, config_data diff --git a/contrib/python/coverage/py2/coverage/context.py b/contrib/python/coverage/py2/coverage/context.py deleted file mode 100644 index ea13da21edd..00000000000 --- a/contrib/python/coverage/py2/coverage/context.py +++ /dev/null @@ -1,91 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Determine contexts for coverage.py""" - - -def combine_context_switchers(context_switchers): - """Create a single context switcher from multiple switchers. - - `context_switchers` is a list of functions that take a frame as an - argument and return a string to use as the new context label. - - Returns a function that composites `context_switchers` functions, or None - if `context_switchers` is an empty list. - - When invoked, the combined switcher calls `context_switchers` one-by-one - until a string is returned. The combined switcher returns None if all - `context_switchers` return None. - """ - if not context_switchers: - return None - - if len(context_switchers) == 1: - return context_switchers[0] - - def should_start_context(frame): - """The combiner for multiple context switchers.""" - for switcher in context_switchers: - new_context = switcher(frame) - if new_context is not None: - return new_context - return None - - return should_start_context - - -def should_start_context_test_function(frame): - """Is this frame calling a test_* function?""" - co_name = frame.f_code.co_name - if co_name.startswith("test") or co_name == "runTest": - return qualname_from_frame(frame) - return None - - -def qualname_from_frame(frame): - """Get a qualified name for the code running in `frame`.""" - co = frame.f_code - fname = co.co_name - method = None - if co.co_argcount and co.co_varnames[0] == "self": - self = frame.f_locals["self"] - method = getattr(self, fname, None) - - if method is None: - func = frame.f_globals.get(fname) - if func is None: - return None - return func.__module__ + '.' + fname - - func = getattr(method, '__func__', None) - if func is None: - cls = self.__class__ - return cls.__module__ + '.' + cls.__name__ + "." + fname - - if hasattr(func, '__qualname__'): - qname = func.__module__ + '.' + func.__qualname__ - else: - for cls in getattr(self.__class__, '__mro__', ()): - f = cls.__dict__.get(fname, None) - if f is None: - continue - if f is func: - qname = cls.__module__ + '.' + cls.__name__ + "." + fname - break - else: - # Support for old-style classes. - def mro(bases): - for base in bases: - f = base.__dict__.get(fname, None) - if f is func: - return base.__module__ + '.' + base.__name__ + "." + fname - for base in bases: - qname = mro(base.__bases__) - if qname is not None: - return qname - return None - qname = mro([self.__class__]) - if qname is None: - qname = func.__module__ + '.' + fname - - return qname diff --git a/contrib/python/coverage/py2/coverage/control.py b/contrib/python/coverage/py2/coverage/control.py deleted file mode 100644 index 605b50c26b4..00000000000 --- a/contrib/python/coverage/py2/coverage/control.py +++ /dev/null @@ -1,1162 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Core control stuff for coverage.py.""" - -import atexit -import collections -import contextlib -import os -import os.path -import platform -import sys -import time -import json - -from coverage import env -from coverage.annotate import AnnotateReporter -from coverage.backward import string_class, iitems -from coverage.collector import Collector, CTracer -from coverage.config import read_coverage_config -from coverage.context import should_start_context_test_function, combine_context_switchers -from coverage.data import CoverageData, combine_parallel_data -from coverage.debug import DebugControl, short_stack, write_formatted_info -from coverage.disposition import disposition_debug_msg -from coverage.files import PathAliases, abs_file, canonical_filename, relative_filename, set_relative_directory -from coverage.html import HtmlReporter -from coverage.inorout import InOrOut -from coverage.jsonreport import JsonReporter -from coverage.misc import CoverageException, bool_or_none, join_regex -from coverage.misc import DefaultValue, ensure_dir_for_file, isolate_module -from coverage.plugin import FileReporter -from coverage.plugin_support import Plugins -from coverage.python import PythonFileReporter -from coverage.report import render_report -from coverage.results import Analysis, Numbers -from coverage.summary import SummaryReporter -from coverage.xmlreport import XmlReporter - -try: - from coverage.multiproc import patch_multiprocessing -except ImportError: # pragma: only jython - # Jython has no multiprocessing module. - patch_multiprocessing = None - -os = isolate_module(os) - -@contextlib.contextmanager -def override_config(cov, **kwargs): - """Temporarily tweak the configuration of `cov`. - - The arguments are applied to `cov.config` with the `from_args` method. - At the end of the with-statement, the old configuration is restored. - """ - original_config = cov.config - cov.config = cov.config.copy() - try: - cov.config.from_args(**kwargs) - yield - finally: - cov.config = original_config - - -_DEFAULT_DATAFILE = DefaultValue("MISSING") - -class Coverage(object): - """Programmatic access to coverage.py. - - To use:: - - from coverage import Coverage - - cov = Coverage() - cov.start() - #.. call your code .. - cov.stop() - cov.html_report(directory='covhtml') - - Note: in keeping with Python custom, names starting with underscore are - not part of the public API. They might stop working at any point. Please - limit yourself to documented methods to avoid problems. - - """ - - # The stack of started Coverage instances. - _instances = [] - - @classmethod - def current(cls): - """Get the latest started `Coverage` instance, if any. - - Returns: a `Coverage` instance, or None. - - .. versionadded:: 5.0 - - """ - if cls._instances: - return cls._instances[-1] - else: - return None - - def __init__( - self, data_file=_DEFAULT_DATAFILE, data_suffix=None, cover_pylib=None, - auto_data=False, timid=None, branch=None, config_file=True, - source=None, source_pkgs=None, omit=None, include=None, debug=None, - concurrency=None, check_preimported=False, context=None, - ): # pylint: disable=too-many-arguments - """ - Many of these arguments duplicate and override values that can be - provided in a configuration file. Parameters that are missing here - will use values from the config file. - - `data_file` is the base name of the data file to use. The config value - defaults to ".coverage". None can be provided to prevent writing a data - file. `data_suffix` is appended (with a dot) to `data_file` to create - the final file name. If `data_suffix` is simply True, then a suffix is - created with the machine and process identity included. - - `cover_pylib` is a boolean determining whether Python code installed - with the Python interpreter is measured. This includes the Python - standard library and any packages installed with the interpreter. - - If `auto_data` is true, then any existing data file will be read when - coverage measurement starts, and data will be saved automatically when - measurement stops. - - If `timid` is true, then a slower and simpler trace function will be - used. This is important for some environments where manipulation of - tracing functions breaks the faster trace function. - - If `branch` is true, then branch coverage will be measured in addition - to the usual statement coverage. - - `config_file` determines what configuration file to read: - - * If it is ".coveragerc", it is interpreted as if it were True, - for backward compatibility. - - * If it is a string, it is the name of the file to read. If the - file can't be read, it is an error. - - * If it is True, then a few standard files names are tried - (".coveragerc", "setup.cfg", "tox.ini"). It is not an error for - these files to not be found. - - * If it is False, then no configuration file is read. - - `source` is a list of file paths or package names. Only code located - in the trees indicated by the file paths or package names will be - measured. - - `source_pkgs` is a list of package names. It works the same as - `source`, but can be used to name packages where the name can also be - interpreted as a file path. - - `include` and `omit` are lists of file name patterns. Files that match - `include` will be measured, files that match `omit` will not. Each - will also accept a single string argument. - - `debug` is a list of strings indicating what debugging information is - desired. - - `concurrency` is a string indicating the concurrency library being used - in the measured code. Without this, coverage.py will get incorrect - results if these libraries are in use. Valid strings are "greenlet", - "eventlet", "gevent", "multiprocessing", or "thread" (the default). - This can also be a list of these strings. - - If `check_preimported` is true, then when coverage is started, the - already-imported files will be checked to see if they should be - measured by coverage. Importing measured files before coverage is - started can mean that code is missed. - - `context` is a string to use as the :ref:`static context - ` label for collected data. - - .. versionadded:: 4.0 - The `concurrency` parameter. - - .. versionadded:: 4.2 - The `concurrency` parameter can now be a list of strings. - - .. versionadded:: 5.0 - The `check_preimported` and `context` parameters. - - .. versionadded:: 5.3 - The `source_pkgs` parameter. - - """ - # data_file=None means no disk file at all. data_file missing means - # use the value from the config file. - self._no_disk = data_file is None - if data_file is _DEFAULT_DATAFILE: - data_file = None - - # Build our configuration from a number of sources. - self.config = read_coverage_config( - config_file=config_file, - data_file=data_file, cover_pylib=cover_pylib, timid=timid, - branch=branch, parallel=bool_or_none(data_suffix), - source=source, source_pkgs=source_pkgs, run_omit=omit, run_include=include, debug=debug, - report_omit=omit, report_include=include, - concurrency=concurrency, context=context, - ) - - # This is injectable by tests. - self._debug_file = None - - self._auto_load = self._auto_save = auto_data - self._data_suffix_specified = data_suffix - - # Is it ok for no data to be collected? - self._warn_no_data = True - self._warn_unimported_source = True - self._warn_preimported_source = check_preimported - self._no_warn_slugs = None - - # A record of all the warnings that have been issued. - self._warnings = [] - - # Other instance attributes, set later. - self._data = self._collector = None - self._plugins = None - self._inorout = None - self._data_suffix = self._run_suffix = None - self._exclude_re = None - self._debug = None - self._file_mapper = None - - # State machine variables: - # Have we initialized everything? - self._inited = False - self._inited_for_start = False - # Have we started collecting and not stopped it? - self._started = False - # Should we write the debug output? - self._should_write_debug = True - - # If we have sub-process measurement happening automatically, then we - # want any explicit creation of a Coverage object to mean, this process - # is already coverage-aware, so don't auto-measure it. By now, the - # auto-creation of a Coverage object has already happened. But we can - # find it and tell it not to save its data. - if not env.METACOV: - _prevent_sub_process_measurement() - - # Store constructor args to reproduce Coverage object in a subprocess created via multiprocessing.Process - self._dumped_args = json.dumps(dict( - data_file=data_file, data_suffix=data_suffix, cover_pylib=cover_pylib, - auto_data=auto_data, timid=timid, branch=branch, config_file=config_file, - source=source, omit=omit, include=include, debug=debug, - concurrency=concurrency - )) - - def _init(self): - """Set all the initial state. - - This is called by the public methods to initialize state. This lets us - construct a :class:`Coverage` object, then tweak its state before this - function is called. - - """ - if self._inited: - return - - self._inited = True - - # Create and configure the debugging controller. COVERAGE_DEBUG_FILE - # is an environment variable, the name of a file to append debug logs - # to. - self._debug = DebugControl(self.config.debug, self._debug_file) - - if "multiprocessing" in (self.config.concurrency or ()): - # Multi-processing uses parallel for the subprocesses, so also use - # it for the main process. - self.config.parallel = True - - # _exclude_re is a dict that maps exclusion list names to compiled regexes. - self._exclude_re = {} - - set_relative_directory() - - if getattr(sys, 'is_standalone_binary', False): - self._file_mapper = canonical_filename - else: - self._file_mapper = relative_filename if self.config.relative_files else abs_file - - # Load plugins - self._plugins = Plugins.load_plugins(self.config.plugins, self.config, self._debug) - - # Run configuring plugins. - for plugin in self._plugins.configurers: - # We need an object with set_option and get_option. Either self or - # self.config will do. Choosing randomly stops people from doing - # other things with those objects, against the public API. Yes, - # this is a bit childish. :) - plugin.configure([self, self.config][int(time.time()) % 2]) - - def _post_init(self): - """Stuff to do after everything is initialized.""" - if self._should_write_debug: - self._should_write_debug = False - self._write_startup_debug() - - # '[run] _crash' will raise an exception if the value is close by in - # the call stack, for testing error handling. - if self.config._crash and self.config._crash in short_stack(limit=4): - raise Exception("Crashing because called by {}".format(self.config._crash)) - - def _write_startup_debug(self): - """Write out debug info at startup if needed.""" - wrote_any = False - with self._debug.without_callers(): - if self._debug.should('config'): - config_info = sorted(self.config.__dict__.items()) - config_info = [(k, v) for k, v in config_info if not k.startswith('_')] - write_formatted_info(self._debug, "config", config_info) - wrote_any = True - - if self._debug.should('sys'): - write_formatted_info(self._debug, "sys", self.sys_info()) - for plugin in self._plugins: - header = "sys: " + plugin._coverage_plugin_name - info = plugin.sys_info() - write_formatted_info(self._debug, header, info) - wrote_any = True - - if wrote_any: - write_formatted_info(self._debug, "end", ()) - - def _should_trace(self, filename, frame): - """Decide whether to trace execution in `filename`. - - Calls `_should_trace_internal`, and returns the FileDisposition. - - """ - disp = self._inorout.should_trace(filename, frame) - if self._debug.should('trace'): - self._debug.write(disposition_debug_msg(disp)) - return disp - - def _check_include_omit_etc(self, filename, frame): - """Check a file name against the include/omit/etc, rules, verbosely. - - Returns a boolean: True if the file should be traced, False if not. - - """ - reason = self._inorout.check_include_omit_etc(filename, frame) - if self._debug.should('trace'): - if not reason: - msg = "Including %r" % (filename,) - else: - msg = "Not including %r: %s" % (filename, reason) - self._debug.write(msg) - - return not reason - - def _warn(self, msg, slug=None, once=False): - """Use `msg` as a warning. - - For warning suppression, use `slug` as the shorthand. - - If `once` is true, only show this warning once (determined by the - slug.) - - """ - if self._no_warn_slugs is None: - self._no_warn_slugs = list(self.config.disable_warnings) - - if slug in self._no_warn_slugs: - # Don't issue the warning - return - - self._warnings.append(msg) - if slug: - msg = "%s (%s)" % (msg, slug) - if self._debug.should('pid'): - msg = "[%d] %s" % (os.getpid(), msg) - sys.stderr.write("Coverage.py warning: %s\n" % msg) - - if once: - self._no_warn_slugs.append(slug) - - def get_option(self, option_name): - """Get an option from the configuration. - - `option_name` is a colon-separated string indicating the section and - option name. For example, the ``branch`` option in the ``[run]`` - section of the config file would be indicated with `"run:branch"`. - - Returns the value of the option. The type depends on the option - selected. - - As a special case, an `option_name` of ``"paths"`` will return an - OrderedDict with the entire ``[paths]`` section value. - - .. versionadded:: 4.0 - - """ - return self.config.get_option(option_name) - - def set_option(self, option_name, value): - """Set an option in the configuration. - - `option_name` is a colon-separated string indicating the section and - option name. For example, the ``branch`` option in the ``[run]`` - section of the config file would be indicated with ``"run:branch"``. - - `value` is the new value for the option. This should be an - appropriate Python value. For example, use True for booleans, not the - string ``"True"``. - - As an example, calling:: - - cov.set_option("run:branch", True) - - has the same effect as this configuration file:: - - [run] - branch = True - - As a special case, an `option_name` of ``"paths"`` will replace the - entire ``[paths]`` section. The value should be an OrderedDict. - - .. versionadded:: 4.0 - - """ - self.config.set_option(option_name, value) - - def load(self): - """Load previously-collected coverage data from the data file.""" - self._init() - if self._collector: - self._collector.reset() - should_skip = self.config.parallel and not os.path.exists(self.config.data_file) - if not should_skip: - self._init_data(suffix=None) - self._post_init() - if not should_skip: - self._data.read() - - def _init_for_start(self): - """Initialization for start()""" - # Construct the collector. - concurrency = self.config.concurrency or () - if "multiprocessing" in concurrency: - if not patch_multiprocessing: - raise CoverageException( # pragma: only jython - "multiprocessing is not supported on this Python" - ) - patch_multiprocessing(rcfile=self.config.config_file, coverage_args=self._dumped_args) - - dycon = self.config.dynamic_context - if not dycon or dycon == "none": - context_switchers = [] - elif dycon == "test_function": - context_switchers = [should_start_context_test_function] - else: - raise CoverageException( - "Don't understand dynamic_context setting: {!r}".format(dycon) - ) - - context_switchers.extend( - plugin.dynamic_context for plugin in self._plugins.context_switchers - ) - - should_start_context = combine_context_switchers(context_switchers) - - self._collector = Collector( - should_trace=self._should_trace, - check_include=self._check_include_omit_etc, - should_start_context=should_start_context, - file_mapper=self._file_mapper, - timid=self.config.timid, - branch=self.config.branch, - warn=self._warn, - concurrency=concurrency, - ) - - suffix = self._data_suffix_specified - if suffix or self.config.parallel: - if not isinstance(suffix, string_class): - # if data_suffix=True, use .machinename.pid.random - suffix = True - else: - suffix = None - - self._init_data(suffix) - - self._collector.use_data(self._data, self.config.context) - - # Early warning if we aren't going to be able to support plugins. - if self._plugins.file_tracers and not self._collector.supports_plugins: - self._warn( - "Plugin file tracers (%s) aren't supported with %s" % ( - ", ".join( - plugin._coverage_plugin_name - for plugin in self._plugins.file_tracers - ), - self._collector.tracer_name(), - ) - ) - for plugin in self._plugins.file_tracers: - plugin._coverage_enabled = False - - # Create the file classifying substructure. - self._inorout = InOrOut( - warn=self._warn, - debug=(self._debug if self._debug.should('trace') else None), - ) - self._inorout.configure(self.config) - self._inorout.plugins = self._plugins - self._inorout.disp_class = self._collector.file_disposition_class - - # It's useful to write debug info after initing for start. - self._should_write_debug = True - - atexit.register(self._atexit) - - def _init_data(self, suffix): - """Create a data file if we don't have one yet.""" - if self._data is None: - # Create the data file. We do this at construction time so that the - # data file will be written into the directory where the process - # started rather than wherever the process eventually chdir'd to. - ensure_dir_for_file(self.config.data_file) - self._data = CoverageData( - basename=self.config.data_file, - suffix=suffix, - warn=self._warn, - debug=self._debug, - no_disk=self._no_disk, - ) - - def start(self): - """Start measuring code coverage. - - Coverage measurement only occurs in functions called after - :meth:`start` is invoked. Statements in the same scope as - :meth:`start` won't be measured. - - Once you invoke :meth:`start`, you must also call :meth:`stop` - eventually, or your process might not shut down cleanly. - - """ - self._init() - if not self._inited_for_start: - self._inited_for_start = True - self._init_for_start() - self._post_init() - - # Issue warnings for possible problems. - self._inorout.warn_conflicting_settings() - - # See if we think some code that would eventually be measured has - # already been imported. - if self._warn_preimported_source: - self._inorout.warn_already_imported_files() - - if self._auto_load: - self.load() - - self._collector.start() - self._started = True - self._instances.append(self) - - def stop(self): - """Stop measuring code coverage.""" - if self._instances: - if self._instances[-1] is self: - self._instances.pop() - if self._started: - self._collector.stop() - self._started = False - - def _atexit(self): - """Clean up on process shutdown.""" - if self._debug.should("process"): - self._debug.write("atexit: pid: {}, instance: {!r}".format(os.getpid(), self)) - if self._started: - self.stop() - if self._auto_save: - self.save() - - def erase(self): - """Erase previously collected coverage data. - - This removes the in-memory data collected in this session as well as - discarding the data file. - - """ - self._init() - self._post_init() - if self._collector: - self._collector.reset() - self._init_data(suffix=None) - self._data.erase(parallel=self.config.parallel) - self._data = None - self._inited_for_start = False - - def switch_context(self, new_context): - """Switch to a new dynamic context. - - `new_context` is a string to use as the :ref:`dynamic context - ` label for collected data. If a :ref:`static - context ` is in use, the static and dynamic context - labels will be joined together with a pipe character. - - Coverage collection must be started already. - - .. versionadded:: 5.0 - - """ - if not self._started: # pragma: part started - raise CoverageException( - "Cannot switch context, coverage is not started" - ) - - if self._collector.should_start_context: - self._warn("Conflicting dynamic contexts", slug="dynamic-conflict", once=True) - - self._collector.switch_context(new_context) - - def clear_exclude(self, which='exclude'): - """Clear the exclude list.""" - self._init() - setattr(self.config, which + "_list", []) - self._exclude_regex_stale() - - def exclude(self, regex, which='exclude'): - """Exclude source lines from execution consideration. - - A number of lists of regular expressions are maintained. Each list - selects lines that are treated differently during reporting. - - `which` determines which list is modified. The "exclude" list selects - lines that are not considered executable at all. The "partial" list - indicates lines with branches that are not taken. - - `regex` is a regular expression. The regex is added to the specified - list. If any of the regexes in the list is found in a line, the line - is marked for special treatment during reporting. - - """ - self._init() - excl_list = getattr(self.config, which + "_list") - excl_list.append(regex) - self._exclude_regex_stale() - - def _exclude_regex_stale(self): - """Drop all the compiled exclusion regexes, a list was modified.""" - self._exclude_re.clear() - - def _exclude_regex(self, which): - """Return a compiled regex for the given exclusion list.""" - if which not in self._exclude_re: - excl_list = getattr(self.config, which + "_list") - self._exclude_re[which] = join_regex(excl_list) - return self._exclude_re[which] - - def get_exclude_list(self, which='exclude'): - """Return a list of excluded regex patterns. - - `which` indicates which list is desired. See :meth:`exclude` for the - lists that are available, and their meaning. - - """ - self._init() - return getattr(self.config, which + "_list") - - def save(self): - """Save the collected coverage data to the data file.""" - data = self.get_data() - data.write() - - def combine(self, data_paths=None, strict=False, keep=False): - """Combine together a number of similarly-named coverage data files. - - All coverage data files whose name starts with `data_file` (from the - coverage() constructor) will be read, and combined together into the - current measurements. - - `data_paths` is a list of files or directories from which data should - be combined. If no list is passed, then the data files from the - directory indicated by the current data file (probably the current - directory) will be combined. - - If `strict` is true, then it is an error to attempt to combine when - there are no data files to combine. - - If `keep` is true, then original input data files won't be deleted. - - .. versionadded:: 4.0 - The `data_paths` parameter. - - .. versionadded:: 4.3 - The `strict` parameter. - - .. versionadded: 5.5 - The `keep` parameter. - """ - self._init() - self._init_data(suffix=None) - self._post_init() - self.get_data() - - aliases = None - if self.config.paths: - aliases = PathAliases() - for paths in self.config.paths.values(): - result = paths[0] - for pattern in paths[1:]: - aliases.add(pattern, result) - - combine_parallel_data( - self._data, - aliases=aliases, - data_paths=data_paths, - strict=strict, - keep=keep, - ) - - def get_data(self): - """Get the collected data. - - Also warn about various problems collecting data. - - Returns a :class:`coverage.CoverageData`, the collected coverage data. - - .. versionadded:: 4.0 - - """ - self._init() - self._init_data(suffix=None) - self._post_init() - - for plugin in self._plugins: - if not plugin._coverage_enabled: - self._collector.plugin_was_disabled(plugin) - - if self._collector and self._collector.flush_data(): - self._post_save_work() - - return self._data - - def _post_save_work(self): - """After saving data, look for warnings, post-work, etc. - - Warn about things that should have happened but didn't. - Look for unexecuted files. - - """ - # If there are still entries in the source_pkgs_unmatched list, - # then we never encountered those packages. - if self._warn_unimported_source: - self._inorout.warn_unimported_source() - - # Find out if we got any data. - if not self._data and self._warn_no_data: - self._warn("No data was collected.", slug="no-data-collected") - - # Touch all the files that could have executed, so that we can - # mark completely unexecuted files as 0% covered. - if self._data is not None: - file_paths = collections.defaultdict(list) - for file_path, plugin_name in self._inorout.find_possibly_unexecuted_files(): - file_path = self._file_mapper(file_path) - file_paths[plugin_name].append(file_path) - for plugin_name, paths in file_paths.items(): - self._data.touch_files(paths, plugin_name) - - if self.config.note: - self._warn("The '[run] note' setting is no longer supported.") - - # Backward compatibility with version 1. - def analysis(self, morf): - """Like `analysis2` but doesn't return excluded line numbers.""" - f, s, _, m, mf = self.analysis2(morf) - return f, s, m, mf - - def analysis2(self, morf): - """Analyze a module. - - `morf` is a module or a file name. It will be analyzed to determine - its coverage statistics. The return value is a 5-tuple: - - * The file name for the module. - * A list of line numbers of executable statements. - * A list of line numbers of excluded statements. - * A list of line numbers of statements not run (missing from - execution). - * A readable formatted string of the missing line numbers. - - The analysis uses the source file itself and the current measured - coverage data. - - """ - analysis = self._analyze(morf) - return ( - analysis.filename, - sorted(analysis.statements), - sorted(analysis.excluded), - sorted(analysis.missing), - analysis.missing_formatted(), - ) - - def _analyze(self, it): - """Analyze a single morf or code unit. - - Returns an `Analysis` object. - - """ - # All reporting comes through here, so do reporting initialization. - self._init() - Numbers.set_precision(self.config.precision) - self._post_init() - - data = self.get_data() - if not isinstance(it, FileReporter): - it = self._get_file_reporter(it) - - return Analysis(data, it, self._file_mapper) - - def _get_file_reporter(self, morf): - """Get a FileReporter for a module or file name.""" - plugin = None - file_reporter = "python" - - if isinstance(morf, string_class): - if getattr(sys, 'is_standalone_binary', False): - # Leave morf in canonical format - relative to the arcadia root - mapped_morf = morf - else: - mapped_morf = self._file_mapper(morf) - plugin_name = self._data.file_tracer(mapped_morf) - if plugin_name: - plugin = self._plugins.get(plugin_name) - - if plugin: - file_reporter = plugin.file_reporter(mapped_morf) - if file_reporter is None: - raise CoverageException( - "Plugin %r did not provide a file reporter for %r." % ( - plugin._coverage_plugin_name, morf - ) - ) - - if file_reporter == "python": - file_reporter = PythonFileReporter(morf, self) - - return file_reporter - - def _get_file_reporters(self, morfs=None): - """Get a list of FileReporters for a list of modules or file names. - - For each module or file name in `morfs`, find a FileReporter. Return - the list of FileReporters. - - If `morfs` is a single module or file name, this returns a list of one - FileReporter. If `morfs` is empty or None, then the list of all files - measured is used to find the FileReporters. - - """ - if not morfs: - morfs = self._data.measured_files() - - # Be sure we have a collection. - if not isinstance(morfs, (list, tuple, set)): - morfs = [morfs] - - file_reporters = [self._get_file_reporter(morf) for morf in morfs] - return file_reporters - - def report( - self, morfs=None, show_missing=None, ignore_errors=None, - file=None, omit=None, include=None, skip_covered=None, - contexts=None, skip_empty=None, precision=None, sort=None - ): - """Write a textual summary report to `file`. - - Each module in `morfs` is listed, with counts of statements, executed - statements, missing statements, and a list of lines missed. - - If `show_missing` is true, then details of which lines or branches are - missing will be included in the report. If `ignore_errors` is true, - then a failure while reporting a single file will not stop the entire - report. - - `file` is a file-like object, suitable for writing. - - `include` is a list of file name patterns. Files that match will be - included in the report. Files matching `omit` will not be included in - the report. - - If `skip_covered` is true, don't report on files with 100% coverage. - - If `skip_empty` is true, don't report on empty files (those that have - no statements). - - `contexts` is a list of regular expressions. Only data from - :ref:`dynamic contexts ` that match one of those - expressions (using :func:`re.search `) will be - included in the report. - - `precision` is the number of digits to display after the decimal - point for percentages. - - All of the arguments default to the settings read from the - :ref:`configuration file `. - - Returns a float, the total percentage covered. - - .. versionadded:: 4.0 - The `skip_covered` parameter. - - .. versionadded:: 5.0 - The `contexts` and `skip_empty` parameters. - - .. versionadded:: 5.2 - The `precision` parameter. - - """ - with override_config( - self, - ignore_errors=ignore_errors, report_omit=omit, report_include=include, - show_missing=show_missing, skip_covered=skip_covered, - report_contexts=contexts, skip_empty=skip_empty, precision=precision, - sort=sort - ): - reporter = SummaryReporter(self) - return reporter.report(morfs, outfile=file) - - def annotate( - self, morfs=None, directory=None, ignore_errors=None, - omit=None, include=None, contexts=None, - ): - """Annotate a list of modules. - - Each module in `morfs` is annotated. The source is written to a new - file, named with a ",cover" suffix, with each line prefixed with a - marker to indicate the coverage of the line. Covered lines have ">", - excluded lines have "-", and missing lines have "!". - - See :meth:`report` for other arguments. - - """ - with override_config(self, - ignore_errors=ignore_errors, report_omit=omit, - report_include=include, report_contexts=contexts, - ): - reporter = AnnotateReporter(self) - reporter.report(morfs, directory=directory) - - def html_report( - self, morfs=None, directory=None, ignore_errors=None, - omit=None, include=None, extra_css=None, title=None, - skip_covered=None, show_contexts=None, contexts=None, - skip_empty=None, precision=None, - ): - """Generate an HTML report. - - The HTML is written to `directory`. The file "index.html" is the - overview starting point, with links to more detailed pages for - individual modules. - - `extra_css` is a path to a file of other CSS to apply on the page. - It will be copied into the HTML directory. - - `title` is a text string (not HTML) to use as the title of the HTML - report. - - See :meth:`report` for other arguments. - - Returns a float, the total percentage covered. - - .. note:: - The HTML report files are generated incrementally based on the - source files and coverage results. If you modify the report files, - the changes will not be considered. You should be careful about - changing the files in the report folder. - - """ - with override_config(self, - ignore_errors=ignore_errors, report_omit=omit, report_include=include, - html_dir=directory, extra_css=extra_css, html_title=title, - html_skip_covered=skip_covered, show_contexts=show_contexts, report_contexts=contexts, - html_skip_empty=skip_empty, precision=precision, - ): - reporter = HtmlReporter(self) - return reporter.report(morfs) - - def xml_report( - self, morfs=None, outfile=None, ignore_errors=None, - omit=None, include=None, contexts=None, skip_empty=None, - ): - """Generate an XML report of coverage results. - - The report is compatible with Cobertura reports. - - Each module in `morfs` is included in the report. `outfile` is the - path to write the file to, "-" will write to stdout. - - See :meth:`report` for other arguments. - - Returns a float, the total percentage covered. - - """ - with override_config(self, - ignore_errors=ignore_errors, report_omit=omit, report_include=include, - xml_output=outfile, report_contexts=contexts, skip_empty=skip_empty, - ): - return render_report(self.config.xml_output, XmlReporter(self), morfs) - - def json_report( - self, morfs=None, outfile=None, ignore_errors=None, - omit=None, include=None, contexts=None, pretty_print=None, - show_contexts=None - ): - """Generate a JSON report of coverage results. - - Each module in `morfs` is included in the report. `outfile` is the - path to write the file to, "-" will write to stdout. - - See :meth:`report` for other arguments. - - Returns a float, the total percentage covered. - - .. versionadded:: 5.0 - - """ - with override_config(self, - ignore_errors=ignore_errors, report_omit=omit, report_include=include, - json_output=outfile, report_contexts=contexts, json_pretty_print=pretty_print, - json_show_contexts=show_contexts - ): - return render_report(self.config.json_output, JsonReporter(self), morfs) - - def sys_info(self): - """Return a list of (key, value) pairs showing internal information.""" - - import coverage as covmod - - self._init() - self._post_init() - - def plugin_info(plugins): - """Make an entry for the sys_info from a list of plug-ins.""" - entries = [] - for plugin in plugins: - entry = plugin._coverage_plugin_name - if not plugin._coverage_enabled: - entry += " (disabled)" - entries.append(entry) - return entries - - info = [ - ('version', covmod.__version__), - ('coverage', covmod.__file__), - ('tracer', self._collector.tracer_name() if self._collector else "-none-"), - ('CTracer', 'available' if CTracer else "unavailable"), - ('plugins.file_tracers', plugin_info(self._plugins.file_tracers)), - ('plugins.configurers', plugin_info(self._plugins.configurers)), - ('plugins.context_switchers', plugin_info(self._plugins.context_switchers)), - ('configs_attempted', self.config.attempted_config_files), - ('configs_read', self.config.config_files_read), - ('config_file', self.config.config_file), - ('config_contents', - repr(self.config._config_contents) - if self.config._config_contents - else '-none-' - ), - ('data_file', self._data.data_filename() if self._data is not None else "-none-"), - ('python', sys.version.replace('\n', '')), - ('platform', platform.platform()), - ('implementation', platform.python_implementation()), - ('executable', sys.executable), - ('def_encoding', sys.getdefaultencoding()), - ('fs_encoding', sys.getfilesystemencoding()), - ('pid', os.getpid()), - ('cwd', os.getcwd()), - ('path', sys.path), - ('environment', sorted( - ("%s = %s" % (k, v)) - for k, v in iitems(os.environ) - if any(slug in k for slug in ("COV", "PY")) - )), - ('command_line', " ".join(getattr(sys, 'argv', ['-none-']))), - ] - - if self._inorout: - info.extend(self._inorout.sys_info()) - - info.extend(CoverageData.sys_info()) - - return info - - -# Mega debugging... -# $set_env.py: COVERAGE_DEBUG_CALLS - Lots and lots of output about calls to Coverage. -if int(os.environ.get("COVERAGE_DEBUG_CALLS", 0)): # pragma: debugging - from coverage.debug import decorate_methods, show_calls - - Coverage = decorate_methods(show_calls(show_args=True), butnot=['get_data'])(Coverage) - - -def process_startup(): - """Call this at Python start-up to perhaps measure coverage. - - If the environment variable COVERAGE_PROCESS_START is defined, coverage - measurement is started. The value of the variable is the config file - to use. - - There are two ways to configure your Python installation to invoke this - function when Python starts: - - #. Create or append to sitecustomize.py to add these lines:: - - import coverage - coverage.process_startup() - - #. Create a .pth file in your Python installation containing:: - - import coverage; coverage.process_startup() - - Returns the :class:`Coverage` instance that was started, or None if it was - not started by this call. - - """ - cps = os.environ.get("COVERAGE_PROCESS_START") - if not cps: - # No request for coverage, nothing to do. - return None - - # This function can be called more than once in a process. This happens - # because some virtualenv configurations make the same directory visible - # twice in sys.path. This means that the .pth file will be found twice, - # and executed twice, executing this function twice. We set a global - # flag (an attribute on this function) to indicate that coverage.py has - # already been started, so we can avoid doing it twice. - # - # https://github.com/nedbat/coveragepy/issues/340 has more details. - - if hasattr(process_startup, "coverage"): - # We've annotated this function before, so we must have already - # started coverage.py in this process. Nothing to do. - return None - - cov = Coverage(config_file=cps) - process_startup.coverage = cov - cov._warn_no_data = False - cov._warn_unimported_source = False - cov._warn_preimported_source = False - cov._auto_save = True - cov.start() - - return cov - - -def _prevent_sub_process_measurement(): - """Stop any subprocess auto-measurement from writing data.""" - auto_created_coverage = getattr(process_startup, "coverage", None) - if auto_created_coverage is not None: - auto_created_coverage._auto_save = False diff --git a/contrib/python/coverage/py2/coverage/ctracer/datastack.c b/contrib/python/coverage/py2/coverage/ctracer/datastack.c deleted file mode 100644 index a9cfcc2cf2c..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/datastack.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -#include "util.h" -#include "datastack.h" - -#define STACK_DELTA 20 - -int -DataStack_init(Stats *pstats, DataStack *pdata_stack) -{ - pdata_stack->depth = -1; - pdata_stack->stack = NULL; - pdata_stack->alloc = 0; - return RET_OK; -} - -void -DataStack_dealloc(Stats *pstats, DataStack *pdata_stack) -{ - int i; - - for (i = 0; i < pdata_stack->alloc; i++) { - Py_XDECREF(pdata_stack->stack[i].file_data); - } - PyMem_Free(pdata_stack->stack); -} - -int -DataStack_grow(Stats *pstats, DataStack *pdata_stack) -{ - pdata_stack->depth++; - if (pdata_stack->depth >= pdata_stack->alloc) { - /* We've outgrown our data_stack array: make it bigger. */ - int bigger = pdata_stack->alloc + STACK_DELTA; - DataStackEntry * bigger_data_stack = PyMem_Realloc(pdata_stack->stack, bigger * sizeof(DataStackEntry)); - STATS( pstats->stack_reallocs++; ) - if (bigger_data_stack == NULL) { - PyErr_NoMemory(); - pdata_stack->depth--; - return RET_ERROR; - } - /* Zero the new entries. */ - memset(bigger_data_stack + pdata_stack->alloc, 0, STACK_DELTA * sizeof(DataStackEntry)); - - pdata_stack->stack = bigger_data_stack; - pdata_stack->alloc = bigger; - } - return RET_OK; -} diff --git a/contrib/python/coverage/py2/coverage/ctracer/datastack.h b/contrib/python/coverage/py2/coverage/ctracer/datastack.h deleted file mode 100644 index 3b3078ba27a..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/datastack.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -#ifndef _COVERAGE_DATASTACK_H -#define _COVERAGE_DATASTACK_H - -#include "util.h" -#include "stats.h" - -/* An entry on the data stack. For each call frame, we need to record all - * the information needed for CTracer_handle_line to operate as quickly as - * possible. - */ -typedef struct DataStackEntry { - /* The current file_data dictionary. Owned. */ - PyObject * file_data; - - /* The disposition object for this frame. A borrowed instance of CFileDisposition. */ - PyObject * disposition; - - /* The FileTracer handling this frame, or None if it's Python. Borrowed. */ - PyObject * file_tracer; - - /* The line number of the last line recorded, for tracing arcs. - -1 means there was no previous line, as when entering a code object. - */ - int last_line; - - BOOL started_context; -} DataStackEntry; - -/* A data stack is a dynamically allocated vector of DataStackEntry's. */ -typedef struct DataStack { - int depth; /* The index of the last-used entry in stack. */ - int alloc; /* number of entries allocated at stack. */ - /* The file data at each level, or NULL if not recording. */ - DataStackEntry * stack; -} DataStack; - - -int DataStack_init(Stats * pstats, DataStack *pdata_stack); -void DataStack_dealloc(Stats * pstats, DataStack *pdata_stack); -int DataStack_grow(Stats * pstats, DataStack *pdata_stack); - -#endif /* _COVERAGE_DATASTACK_H */ diff --git a/contrib/python/coverage/py2/coverage/ctracer/filedisp.c b/contrib/python/coverage/py2/coverage/ctracer/filedisp.c deleted file mode 100644 index 47782ae0900..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/filedisp.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -#include "util.h" -#include "filedisp.h" - -void -CFileDisposition_dealloc(CFileDisposition *self) -{ - Py_XDECREF(self->original_filename); - Py_XDECREF(self->canonical_filename); - Py_XDECREF(self->source_filename); - Py_XDECREF(self->trace); - Py_XDECREF(self->reason); - Py_XDECREF(self->file_tracer); - Py_XDECREF(self->has_dynamic_filename); -} - -static PyMemberDef -CFileDisposition_members[] = { - { "original_filename", T_OBJECT, offsetof(CFileDisposition, original_filename), 0, - PyDoc_STR("") }, - - { "canonical_filename", T_OBJECT, offsetof(CFileDisposition, canonical_filename), 0, - PyDoc_STR("") }, - - { "source_filename", T_OBJECT, offsetof(CFileDisposition, source_filename), 0, - PyDoc_STR("") }, - - { "trace", T_OBJECT, offsetof(CFileDisposition, trace), 0, - PyDoc_STR("") }, - - { "reason", T_OBJECT, offsetof(CFileDisposition, reason), 0, - PyDoc_STR("") }, - - { "file_tracer", T_OBJECT, offsetof(CFileDisposition, file_tracer), 0, - PyDoc_STR("") }, - - { "has_dynamic_filename", T_OBJECT, offsetof(CFileDisposition, has_dynamic_filename), 0, - PyDoc_STR("") }, - - { NULL } -}; - -PyTypeObject -CFileDispositionType = { - MyType_HEAD_INIT - "coverage.CFileDispositionType", /*tp_name*/ - sizeof(CFileDisposition), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)CFileDisposition_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "CFileDisposition objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - CFileDisposition_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ -}; diff --git a/contrib/python/coverage/py2/coverage/ctracer/filedisp.h b/contrib/python/coverage/py2/coverage/ctracer/filedisp.h deleted file mode 100644 index 860f9a50b1f..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/filedisp.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -#ifndef _COVERAGE_FILEDISP_H -#define _COVERAGE_FILEDISP_H - -#include "util.h" -#include "structmember.h" - -typedef struct CFileDisposition { - PyObject_HEAD - - PyObject * original_filename; - PyObject * canonical_filename; - PyObject * source_filename; - PyObject * trace; - PyObject * reason; - PyObject * file_tracer; - PyObject * has_dynamic_filename; -} CFileDisposition; - -void CFileDisposition_dealloc(CFileDisposition *self); - -extern PyTypeObject CFileDispositionType; - -#endif /* _COVERAGE_FILEDISP_H */ diff --git a/contrib/python/coverage/py2/coverage/ctracer/module.c b/contrib/python/coverage/py2/coverage/ctracer/module.c deleted file mode 100644 index f308902b693..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/module.c +++ /dev/null @@ -1,108 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -#include "util.h" -#include "tracer.h" -#include "filedisp.h" - -/* Module definition */ - -#define MODULE_DOC PyDoc_STR("Fast coverage tracer.") - -#if PY_MAJOR_VERSION >= 3 - -static PyModuleDef -moduledef = { - PyModuleDef_HEAD_INIT, - "coverage.tracer", - MODULE_DOC, - -1, - NULL, /* methods */ - NULL, - NULL, /* traverse */ - NULL, /* clear */ - NULL -}; - - -PyObject * -PyInit_tracer(void) -{ - PyObject * mod = PyModule_Create(&moduledef); - if (mod == NULL) { - return NULL; - } - - if (CTracer_intern_strings() < 0) { - return NULL; - } - - /* Initialize CTracer */ - CTracerType.tp_new = PyType_GenericNew; - if (PyType_Ready(&CTracerType) < 0) { - Py_DECREF(mod); - return NULL; - } - - Py_INCREF(&CTracerType); - if (PyModule_AddObject(mod, "CTracer", (PyObject *)&CTracerType) < 0) { - Py_DECREF(mod); - Py_DECREF(&CTracerType); - return NULL; - } - - /* Initialize CFileDisposition */ - CFileDispositionType.tp_new = PyType_GenericNew; - if (PyType_Ready(&CFileDispositionType) < 0) { - Py_DECREF(mod); - Py_DECREF(&CTracerType); - return NULL; - } - - Py_INCREF(&CFileDispositionType); - if (PyModule_AddObject(mod, "CFileDisposition", (PyObject *)&CFileDispositionType) < 0) { - Py_DECREF(mod); - Py_DECREF(&CTracerType); - Py_DECREF(&CFileDispositionType); - return NULL; - } - - return mod; -} - -#else - -void -inittracer(void) -{ - PyObject * mod; - - mod = Py_InitModule3("coverage.tracer", NULL, MODULE_DOC); - if (mod == NULL) { - return; - } - - if (CTracer_intern_strings() < 0) { - return; - } - - /* Initialize CTracer */ - CTracerType.tp_new = PyType_GenericNew; - if (PyType_Ready(&CTracerType) < 0) { - return; - } - - Py_INCREF(&CTracerType); - PyModule_AddObject(mod, "CTracer", (PyObject *)&CTracerType); - - /* Initialize CFileDisposition */ - CFileDispositionType.tp_new = PyType_GenericNew; - if (PyType_Ready(&CFileDispositionType) < 0) { - return; - } - - Py_INCREF(&CFileDispositionType); - PyModule_AddObject(mod, "CFileDisposition", (PyObject *)&CFileDispositionType); -} - -#endif /* Py3k */ diff --git a/contrib/python/coverage/py2/coverage/ctracer/stats.h b/contrib/python/coverage/py2/coverage/ctracer/stats.h deleted file mode 100644 index 05173369f78..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/stats.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -#ifndef _COVERAGE_STATS_H -#define _COVERAGE_STATS_H - -#include "util.h" - -#if COLLECT_STATS -#define STATS(x) x -#else -#define STATS(x) -#endif - -typedef struct Stats { - unsigned int calls; /* Need at least one member, but the rest only if needed. */ -#if COLLECT_STATS - unsigned int lines; - unsigned int returns; - unsigned int exceptions; - unsigned int others; - unsigned int files; - unsigned int missed_returns; - unsigned int stack_reallocs; - unsigned int errors; - unsigned int pycalls; - unsigned int start_context_calls; -#endif -} Stats; - -#endif /* _COVERAGE_STATS_H */ diff --git a/contrib/python/coverage/py2/coverage/ctracer/tracer.c b/contrib/python/coverage/py2/coverage/ctracer/tracer.c deleted file mode 100644 index 00e4218d8ec..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/tracer.c +++ /dev/null @@ -1,1149 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -/* C-based Tracer for coverage.py. */ - -#include "util.h" -#include "datastack.h" -#include "filedisp.h" -#include "tracer.h" - -/* Python C API helpers. */ - -static int -pyint_as_int(PyObject * pyint, int *pint) -{ - int the_int = MyInt_AsInt(pyint); - if (the_int == -1 && PyErr_Occurred()) { - return RET_ERROR; - } - - *pint = the_int; - return RET_OK; -} - - -/* Interned strings to speed GetAttr etc. */ - -static PyObject *str_trace; -static PyObject *str_file_tracer; -static PyObject *str__coverage_enabled; -static PyObject *str__coverage_plugin; -static PyObject *str__coverage_plugin_name; -static PyObject *str_dynamic_source_filename; -static PyObject *str_line_number_range; - -int -CTracer_intern_strings(void) -{ - int ret = RET_ERROR; - -#define INTERN_STRING(v, s) \ - v = MyText_InternFromString(s); \ - if (v == NULL) { \ - goto error; \ - } - - INTERN_STRING(str_trace, "trace") - INTERN_STRING(str_file_tracer, "file_tracer") - INTERN_STRING(str__coverage_enabled, "_coverage_enabled") - INTERN_STRING(str__coverage_plugin, "_coverage_plugin") - INTERN_STRING(str__coverage_plugin_name, "_coverage_plugin_name") - INTERN_STRING(str_dynamic_source_filename, "dynamic_source_filename") - INTERN_STRING(str_line_number_range, "line_number_range") - - ret = RET_OK; - -error: - return ret; -} - -static void CTracer_disable_plugin(CTracer *self, PyObject * disposition); - -static int -CTracer_init(CTracer *self, PyObject *args_unused, PyObject *kwds_unused) -{ - int ret = RET_ERROR; - - if (DataStack_init(&self->stats, &self->data_stack) < 0) { - goto error; - } - - self->pdata_stack = &self->data_stack; - - self->context = Py_None; - Py_INCREF(self->context); - - ret = RET_OK; - goto ok; - -error: - STATS( self->stats.errors++; ) - -ok: - return ret; -} - -static void -CTracer_dealloc(CTracer *self) -{ - int i; - - if (self->started) { - PyEval_SetTrace(NULL, NULL); - } - - Py_XDECREF(self->should_trace); - Py_XDECREF(self->check_include); - Py_XDECREF(self->warn); - Py_XDECREF(self->concur_id_func); - Py_XDECREF(self->data); - Py_XDECREF(self->file_tracers); - Py_XDECREF(self->should_trace_cache); - Py_XDECREF(self->should_start_context); - Py_XDECREF(self->switch_context); - Py_XDECREF(self->context); - Py_XDECREF(self->disable_plugin); - - DataStack_dealloc(&self->stats, &self->data_stack); - if (self->data_stacks) { - for (i = 0; i < self->data_stacks_used; i++) { - DataStack_dealloc(&self->stats, self->data_stacks + i); - } - PyMem_Free(self->data_stacks); - } - - Py_XDECREF(self->data_stack_index); - - Py_TYPE(self)->tp_free((PyObject*)self); -} - -#if TRACE_LOG -static const char * -indent(int n) -{ - static const char * spaces = - " " - " " - " " - " " - ; - return spaces + strlen(spaces) - n*2; -} - -static BOOL logging = FALSE; -/* Set these constants to be a file substring and line number to start logging. */ -static const char * start_file = "tests/views"; -static int start_line = 27; - -static void -showlog(int depth, int lineno, PyObject * filename, const char * msg) -{ - if (logging) { - printf("%s%3d ", indent(depth), depth); - if (lineno) { - printf("%4d", lineno); - } - else { - printf(" "); - } - if (filename) { - PyObject *ascii = MyText_AS_BYTES(filename); - printf(" %s", MyBytes_AS_STRING(ascii)); - Py_DECREF(ascii); - } - if (msg) { - printf(" %s", msg); - } - printf("\n"); - } -} - -#define SHOWLOG(a,b,c,d) showlog(a,b,c,d) -#else -#define SHOWLOG(a,b,c,d) -#endif /* TRACE_LOG */ - -#if WHAT_LOG -static const char * what_sym[] = {"CALL", "EXC ", "LINE", "RET "}; -#endif - -/* Record a pair of integers in self->pcur_entry->file_data. */ -static int -CTracer_record_pair(CTracer *self, int l1, int l2) -{ - int ret = RET_ERROR; - - PyObject * t = NULL; - - t = Py_BuildValue("(ii)", l1, l2); - if (t == NULL) { - goto error; - } - - if (PyDict_SetItem(self->pcur_entry->file_data, t, Py_None) < 0) { - goto error; - } - - ret = RET_OK; - -error: - Py_XDECREF(t); - - return ret; -} - -/* Set self->pdata_stack to the proper data_stack to use. */ -static int -CTracer_set_pdata_stack(CTracer *self) -{ - int ret = RET_ERROR; - PyObject * co_obj = NULL; - PyObject * stack_index = NULL; - - if (self->concur_id_func != Py_None) { - int the_index = 0; - - if (self->data_stack_index == NULL) { - PyObject * weakref = NULL; - - weakref = PyImport_ImportModule("weakref"); - if (weakref == NULL) { - goto error; - } - STATS( self->stats.pycalls++; ) - self->data_stack_index = PyObject_CallMethod(weakref, "WeakKeyDictionary", NULL); - Py_XDECREF(weakref); - - if (self->data_stack_index == NULL) { - goto error; - } - } - - STATS( self->stats.pycalls++; ) - co_obj = PyObject_CallObject(self->concur_id_func, NULL); - if (co_obj == NULL) { - goto error; - } - stack_index = PyObject_GetItem(self->data_stack_index, co_obj); - if (stack_index == NULL) { - /* PyObject_GetItem sets an exception if it didn't find the thing. */ - PyErr_Clear(); - - /* A new concurrency object. Make a new data stack. */ - the_index = self->data_stacks_used; - stack_index = MyInt_FromInt(the_index); - if (stack_index == NULL) { - goto error; - } - if (PyObject_SetItem(self->data_stack_index, co_obj, stack_index) < 0) { - goto error; - } - self->data_stacks_used++; - if (self->data_stacks_used >= self->data_stacks_alloc) { - int bigger = self->data_stacks_alloc + 10; - DataStack * bigger_stacks = PyMem_Realloc(self->data_stacks, bigger * sizeof(DataStack)); - if (bigger_stacks == NULL) { - PyErr_NoMemory(); - goto error; - } - self->data_stacks = bigger_stacks; - self->data_stacks_alloc = bigger; - } - DataStack_init(&self->stats, &self->data_stacks[the_index]); - } - else { - if (pyint_as_int(stack_index, &the_index) < 0) { - goto error; - } - } - - self->pdata_stack = &self->data_stacks[the_index]; - } - else { - self->pdata_stack = &self->data_stack; - } - - ret = RET_OK; - -error: - - Py_XDECREF(co_obj); - Py_XDECREF(stack_index); - - return ret; -} - -/* - * Parts of the trace function. - */ - -static int -CTracer_check_missing_return(CTracer *self, PyFrameObject *frame) -{ - int ret = RET_ERROR; - - if (self->last_exc_back) { - if (frame == self->last_exc_back) { - /* Looks like someone forgot to send a return event. We'll clear - the exception state and do the RETURN code here. Notice that the - frame we have in hand here is not the correct frame for the RETURN, - that frame is gone. Our handling for RETURN doesn't need the - actual frame, but we do log it, so that will look a little off if - you're looking at the detailed log. - - If someday we need to examine the frame when doing RETURN, then - we'll need to keep more of the missed frame's state. - */ - STATS( self->stats.missed_returns++; ) - if (CTracer_set_pdata_stack(self) < 0) { - goto error; - } - if (self->pdata_stack->depth >= 0) { - if (self->tracing_arcs && self->pcur_entry->file_data) { - if (CTracer_record_pair(self, self->pcur_entry->last_line, -self->last_exc_firstlineno) < 0) { - goto error; - } - } - SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), frame->f_code->co_filename, "missedreturn"); - self->pdata_stack->depth--; - self->pcur_entry = &self->pdata_stack->stack[self->pdata_stack->depth]; - } - } - self->last_exc_back = NULL; - } - - ret = RET_OK; - -error: - - return ret; -} - -static int -CTracer_handle_call(CTracer *self, PyFrameObject *frame) -{ - int ret = RET_ERROR; - int ret2; - - /* Owned references that we clean up at the very end of the function. */ - PyObject * disposition = NULL; - PyObject * plugin = NULL; - PyObject * plugin_name = NULL; - PyObject * next_tracename = NULL; - - /* Borrowed references. */ - PyObject * filename = NULL; - PyObject * disp_trace = NULL; - PyObject * tracename = NULL; - PyObject * file_tracer = NULL; - PyObject * has_dynamic_filename = NULL; - - CFileDisposition * pdisp = NULL; - - STATS( self->stats.calls++; ) - - /* Grow the stack. */ - if (CTracer_set_pdata_stack(self) < 0) { - goto error; - } - if (DataStack_grow(&self->stats, self->pdata_stack) < 0) { - goto error; - } - self->pcur_entry = &self->pdata_stack->stack[self->pdata_stack->depth]; - - /* See if this frame begins a new context. */ - if (self->should_start_context != Py_None && self->context == Py_None) { - PyObject * context; - /* We're looking for our context, ask should_start_context if this is the start. */ - STATS( self->stats.start_context_calls++; ) - STATS( self->stats.pycalls++; ) - context = PyObject_CallFunctionObjArgs(self->should_start_context, frame, NULL); - if (context == NULL) { - goto error; - } - if (context != Py_None) { - PyObject * val; - Py_DECREF(self->context); - self->context = context; - self->pcur_entry->started_context = TRUE; - STATS( self->stats.pycalls++; ) - val = PyObject_CallFunctionObjArgs(self->switch_context, context, NULL); - if (val == NULL) { - goto error; - } - Py_DECREF(val); - } - else { - Py_DECREF(context); - self->pcur_entry->started_context = FALSE; - } - } - else { - self->pcur_entry->started_context = FALSE; - } - - /* Check if we should trace this line. */ - filename = frame->f_code->co_filename; - disposition = PyDict_GetItem(self->should_trace_cache, filename); - if (disposition == NULL) { - if (PyErr_Occurred()) { - goto error; - } - STATS( self->stats.files++; ) - - /* We've never considered this file before. */ - /* Ask should_trace about it. */ - STATS( self->stats.pycalls++; ) - disposition = PyObject_CallFunctionObjArgs(self->should_trace, filename, frame, NULL); - if (disposition == NULL) { - /* An error occurred inside should_trace. */ - goto error; - } - if (PyDict_SetItem(self->should_trace_cache, filename, disposition) < 0) { - goto error; - } - } - else { - Py_INCREF(disposition); - } - - if (disposition == Py_None) { - /* A later check_include returned false, so don't trace it. */ - disp_trace = Py_False; - } - else { - /* The object we got is a CFileDisposition, use it efficiently. */ - pdisp = (CFileDisposition *) disposition; - disp_trace = pdisp->trace; - if (disp_trace == NULL) { - goto error; - } - } - - if (disp_trace == Py_True) { - /* If tracename is a string, then we're supposed to trace. */ - tracename = pdisp->source_filename; - if (tracename == NULL) { - goto error; - } - file_tracer = pdisp->file_tracer; - if (file_tracer == NULL) { - goto error; - } - if (file_tracer != Py_None) { - plugin = PyObject_GetAttr(file_tracer, str__coverage_plugin); - if (plugin == NULL) { - goto error; - } - plugin_name = PyObject_GetAttr(plugin, str__coverage_plugin_name); - if (plugin_name == NULL) { - goto error; - } - } - has_dynamic_filename = pdisp->has_dynamic_filename; - if (has_dynamic_filename == NULL) { - goto error; - } - if (has_dynamic_filename == Py_True) { - STATS( self->stats.pycalls++; ) - next_tracename = PyObject_CallMethodObjArgs( - file_tracer, str_dynamic_source_filename, - tracename, frame, NULL - ); - if (next_tracename == NULL) { - /* An exception from the function. Alert the user with a - * warning and a traceback. - */ - CTracer_disable_plugin(self, disposition); - /* Because we handled the error, goto ok. */ - goto ok; - } - tracename = next_tracename; - - if (tracename != Py_None) { - /* Check the dynamic source filename against the include rules. */ - PyObject * included = NULL; - int should_include; - included = PyDict_GetItem(self->should_trace_cache, tracename); - if (included == NULL) { - PyObject * should_include_bool; - if (PyErr_Occurred()) { - goto error; - } - STATS( self->stats.files++; ) - STATS( self->stats.pycalls++; ) - should_include_bool = PyObject_CallFunctionObjArgs(self->check_include, tracename, frame, NULL); - if (should_include_bool == NULL) { - goto error; - } - should_include = (should_include_bool == Py_True); - Py_DECREF(should_include_bool); - if (PyDict_SetItem(self->should_trace_cache, tracename, should_include ? disposition : Py_None) < 0) { - goto error; - } - } - else { - should_include = (included != Py_None); - } - if (!should_include) { - tracename = Py_None; - } - } - } - } - else { - tracename = Py_None; - } - - if (tracename != Py_None) { - PyObject * file_data = PyDict_GetItem(self->data, tracename); - - if (file_data == NULL) { - if (PyErr_Occurred()) { - goto error; - } - file_data = PyDict_New(); - if (file_data == NULL) { - goto error; - } - ret2 = PyDict_SetItem(self->data, tracename, file_data); - if (ret2 < 0) { - goto error; - } - - /* If the disposition mentions a plugin, record that. */ - if (file_tracer != Py_None) { - ret2 = PyDict_SetItem(self->file_tracers, tracename, plugin_name); - if (ret2 < 0) { - goto error; - } - } - } - else { - /* PyDict_GetItem gives a borrowed reference. Own it. */ - Py_INCREF(file_data); - } - - Py_XDECREF(self->pcur_entry->file_data); - self->pcur_entry->file_data = file_data; - self->pcur_entry->file_tracer = file_tracer; - - SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), filename, "traced"); - } - else { - Py_XDECREF(self->pcur_entry->file_data); - self->pcur_entry->file_data = NULL; - self->pcur_entry->file_tracer = Py_None; - SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), filename, "skipped"); - } - - self->pcur_entry->disposition = disposition; - - /* Make the frame right in case settrace(gettrace()) happens. */ - Py_INCREF(self); - My_XSETREF(frame->f_trace, (PyObject*)self); - - /* A call event is really a "start frame" event, and can happen for - * re-entering a generator also. f_lasti is -1 for a true call, and a - * real byte offset for a generator re-entry. - */ - if (frame->f_lasti < 0) { - self->pcur_entry->last_line = -frame->f_code->co_firstlineno; - } - else { - self->pcur_entry->last_line = PyFrame_GetLineNumber(frame); - } - -ok: - ret = RET_OK; - -error: - Py_XDECREF(next_tracename); - Py_XDECREF(disposition); - Py_XDECREF(plugin); - Py_XDECREF(plugin_name); - - return ret; -} - - -static void -CTracer_disable_plugin(CTracer *self, PyObject * disposition) -{ - PyObject * ret; - PyErr_Print(); - - STATS( self->stats.pycalls++; ) - ret = PyObject_CallFunctionObjArgs(self->disable_plugin, disposition, NULL); - if (ret == NULL) { - goto error; - } - Py_DECREF(ret); - - return; - -error: - /* This function doesn't return a status, so if an error happens, print it, - * but don't interrupt the flow. */ - /* PySys_WriteStderr is nicer, but is not in the public API. */ - fprintf(stderr, "Error occurred while disabling plug-in:\n"); - PyErr_Print(); -} - - -static int -CTracer_unpack_pair(CTracer *self, PyObject *pair, int *p_one, int *p_two) -{ - int ret = RET_ERROR; - int the_int; - PyObject * pyint = NULL; - int index; - - if (!PyTuple_Check(pair) || PyTuple_Size(pair) != 2) { - PyErr_SetString( - PyExc_TypeError, - "line_number_range must return 2-tuple" - ); - goto error; - } - - for (index = 0; index < 2; index++) { - pyint = PyTuple_GetItem(pair, index); - if (pyint == NULL) { - goto error; - } - if (pyint_as_int(pyint, &the_int) < 0) { - goto error; - } - *(index == 0 ? p_one : p_two) = the_int; - } - - ret = RET_OK; - -error: - return ret; -} - -static int -CTracer_handle_line(CTracer *self, PyFrameObject *frame) -{ - int ret = RET_ERROR; - int ret2; - - STATS( self->stats.lines++; ) - if (self->pdata_stack->depth >= 0) { - SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), frame->f_code->co_filename, "line"); - if (self->pcur_entry->file_data) { - int lineno_from = -1; - int lineno_to = -1; - - /* We're tracing in this frame: record something. */ - if (self->pcur_entry->file_tracer != Py_None) { - PyObject * from_to = NULL; - STATS( self->stats.pycalls++; ) - from_to = PyObject_CallMethodObjArgs(self->pcur_entry->file_tracer, str_line_number_range, frame, NULL); - if (from_to == NULL) { - CTracer_disable_plugin(self, self->pcur_entry->disposition); - goto ok; - } - ret2 = CTracer_unpack_pair(self, from_to, &lineno_from, &lineno_to); - Py_DECREF(from_to); - if (ret2 < 0) { - CTracer_disable_plugin(self, self->pcur_entry->disposition); - goto ok; - } - } - else { - lineno_from = lineno_to = PyFrame_GetLineNumber(frame); - } - - if (lineno_from != -1) { - for (; lineno_from <= lineno_to; lineno_from++) { - if (self->tracing_arcs) { - /* Tracing arcs: key is (last_line,this_line). */ - if (CTracer_record_pair(self, self->pcur_entry->last_line, lineno_from) < 0) { - goto error; - } - } - else { - /* Tracing lines: key is simply this_line. */ - PyObject * this_line = MyInt_FromInt(lineno_from); - if (this_line == NULL) { - goto error; - } - - ret2 = PyDict_SetItem(self->pcur_entry->file_data, this_line, Py_None); - Py_DECREF(this_line); - if (ret2 < 0) { - goto error; - } - } - - self->pcur_entry->last_line = lineno_from; - } - } - } - } - -ok: - ret = RET_OK; - -error: - - return ret; -} - -static int -CTracer_handle_return(CTracer *self, PyFrameObject *frame) -{ - int ret = RET_ERROR; - - STATS( self->stats.returns++; ) - /* A near-copy of this code is above in the missing-return handler. */ - if (CTracer_set_pdata_stack(self) < 0) { - goto error; - } - self->pcur_entry = &self->pdata_stack->stack[self->pdata_stack->depth]; - - if (self->pdata_stack->depth >= 0) { - if (self->tracing_arcs && self->pcur_entry->file_data) { - /* Need to distinguish between RETURN_VALUE and YIELD_VALUE. Read - * the current bytecode to see what it is. In unusual circumstances - * (Cython code), co_code can be the empty string, so range-check - * f_lasti before reading the byte. - */ - int bytecode = RETURN_VALUE; - PyObject * pCode = frame->f_code->co_code; - int lasti = frame->f_lasti; - - if (lasti < MyBytes_GET_SIZE(pCode)) { - bytecode = MyBytes_AS_STRING(pCode)[lasti]; - } - if (bytecode != YIELD_VALUE) { - int first = frame->f_code->co_firstlineno; - if (CTracer_record_pair(self, self->pcur_entry->last_line, -first) < 0) { - goto error; - } - } - } - - /* If this frame started a context, then returning from it ends the context. */ - if (self->pcur_entry->started_context) { - PyObject * val; - Py_DECREF(self->context); - self->context = Py_None; - Py_INCREF(self->context); - STATS( self->stats.pycalls++; ) - - val = PyObject_CallFunctionObjArgs(self->switch_context, self->context, NULL); - if (val == NULL) { - goto error; - } - Py_DECREF(val); - } - - /* Pop the stack. */ - SHOWLOG(self->pdata_stack->depth, PyFrame_GetLineNumber(frame), frame->f_code->co_filename, "return"); - self->pdata_stack->depth--; - self->pcur_entry = &self->pdata_stack->stack[self->pdata_stack->depth]; - } - - ret = RET_OK; - -error: - - return ret; -} - -static int -CTracer_handle_exception(CTracer *self, PyFrameObject *frame) -{ - /* Some code (Python 2.3, and pyexpat anywhere) fires an exception event - without a return event. To detect that, we'll keep a copy of the - parent frame for an exception event. If the next event is in that - frame, then we must have returned without a return event. We can - synthesize the missing event then. - - Python itself fixed this problem in 2.4. Pyexpat still has the bug. - I've reported the problem with pyexpat as http://bugs.python.org/issue6359 . - If it gets fixed, this code should still work properly. Maybe some day - the bug will be fixed everywhere coverage.py is supported, and we can - remove this missing-return detection. - - More about this fix: https://nedbatchelder.com/blog/200907/a_nasty_little_bug.html - */ - STATS( self->stats.exceptions++; ) - self->last_exc_back = frame->f_back; - self->last_exc_firstlineno = frame->f_code->co_firstlineno; - - return RET_OK; -} - -/* - * The Trace Function - */ -static int -CTracer_trace(CTracer *self, PyFrameObject *frame, int what, PyObject *arg_unused) -{ - int ret = RET_ERROR; - - #if DO_NOTHING - return RET_OK; - #endif - - if (!self->started) { - /* If CTracer.stop() has been called from another thread, the tracer - is still active in the current thread. Let's deactivate ourselves - now. */ - PyEval_SetTrace(NULL, NULL); - return RET_OK; - } - - #if WHAT_LOG || TRACE_LOG - PyObject * ascii = NULL; - #endif - - #if WHAT_LOG - if (what <= (int)(sizeof(what_sym)/sizeof(const char *))) { - ascii = MyText_AS_BYTES(frame->f_code->co_filename); - printf("trace: %s @ %s %d\n", what_sym[what], MyBytes_AS_STRING(ascii), PyFrame_GetLineNumber(frame)); - Py_DECREF(ascii); - } - #endif - - #if TRACE_LOG - ascii = MyText_AS_BYTES(frame->f_code->co_filename); - if (strstr(MyBytes_AS_STRING(ascii), start_file) && PyFrame_GetLineNumber(frame) == start_line) { - logging = TRUE; - } - Py_DECREF(ascii); - #endif - - /* See below for details on missing-return detection. */ - if (CTracer_check_missing_return(self, frame) < 0) { - goto error; - } - - self->activity = TRUE; - - switch (what) { - case PyTrace_CALL: - if (CTracer_handle_call(self, frame) < 0) { - goto error; - } - break; - - case PyTrace_RETURN: - if (CTracer_handle_return(self, frame) < 0) { - goto error; - } - break; - - case PyTrace_LINE: - if (CTracer_handle_line(self, frame) < 0) { - goto error; - } - break; - - case PyTrace_EXCEPTION: - if (CTracer_handle_exception(self, frame) < 0) { - goto error; - } - break; - - default: - STATS( self->stats.others++; ) - break; - } - - ret = RET_OK; - goto cleanup; - -error: - STATS( self->stats.errors++; ) - -cleanup: - return ret; -} - - -/* - * Python has two ways to set the trace function: sys.settrace(fn), which - * takes a Python callable, and PyEval_SetTrace(func, obj), which takes - * a C function and a Python object. The way these work together is that - * sys.settrace(pyfn) calls PyEval_SetTrace(builtin_func, pyfn), using the - * Python callable as the object in PyEval_SetTrace. So sys.gettrace() - * simply returns the Python object used as the second argument to - * PyEval_SetTrace. So sys.gettrace() will return our self parameter, which - * means it must be callable to be used in sys.settrace(). - * - * So we make ourself callable, equivalent to invoking our trace function. - * - * To help with the process of replaying stored frames, this function has an - * optional keyword argument: - * - * def CTracer_call(frame, event, arg, lineno=0) - * - * If provided, the lineno argument is used as the line number, and the - * frame's f_lineno member is ignored. - */ -static PyObject * -CTracer_call(CTracer *self, PyObject *args, PyObject *kwds) -{ - PyFrameObject *frame; - PyObject *what_str; - PyObject *arg; - int lineno = 0; - int what; - int orig_lineno; - PyObject *ret = NULL; - PyObject * ascii = NULL; - - #if DO_NOTHING - CRASH - #endif - - static char *what_names[] = { - "call", "exception", "line", "return", - "c_call", "c_exception", "c_return", - NULL - }; - - static char *kwlist[] = {"frame", "event", "arg", "lineno", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!O|i:Tracer_call", kwlist, - &PyFrame_Type, &frame, &MyText_Type, &what_str, &arg, &lineno)) { - goto done; - } - - /* In Python, the what argument is a string, we need to find an int - for the C function. */ - for (what = 0; what_names[what]; what++) { - int should_break; - ascii = MyText_AS_BYTES(what_str); - should_break = !strcmp(MyBytes_AS_STRING(ascii), what_names[what]); - Py_DECREF(ascii); - if (should_break) { - break; - } - } - - #if WHAT_LOG - ascii = MyText_AS_BYTES(frame->f_code->co_filename); - printf("pytrace: %s @ %s %d\n", what_sym[what], MyBytes_AS_STRING(ascii), PyFrame_GetLineNumber(frame)); - Py_DECREF(ascii); - #endif - - /* Save off the frame's lineno, and use the forced one, if provided. */ - orig_lineno = frame->f_lineno; - if (lineno > 0) { - frame->f_lineno = lineno; - } - - /* Invoke the C function, and return ourselves. */ - if (CTracer_trace(self, frame, what, arg) == RET_OK) { - Py_INCREF(self); - ret = (PyObject *)self; - } - - /* Clean up. */ - frame->f_lineno = orig_lineno; - - /* For better speed, install ourselves the C way so that future calls go - directly to CTracer_trace, without this intermediate function. - - Only do this if this is a CALL event, since new trace functions only - take effect then. If we don't condition it on CALL, then we'll clobber - the new trace function before it has a chance to get called. To - understand why, there are three internal values to track: frame.f_trace, - c_tracefunc, and c_traceobj. They are explained here: - https://nedbatchelder.com/text/trace-function.html - - Without the conditional on PyTrace_CALL, this is what happens: - - def func(): # f_trace c_tracefunc c_traceobj - # -------------- -------------- -------------- - # CTracer CTracer.trace CTracer - sys.settrace(my_func) - # CTracer trampoline my_func - # Now Python calls trampoline(CTracer), which calls this function - # which calls PyEval_SetTrace below, setting us as the tracer again: - # CTracer CTracer.trace CTracer - # and it's as if the settrace never happened. - */ - if (what == PyTrace_CALL) { - PyEval_SetTrace((Py_tracefunc)CTracer_trace, (PyObject*)self); - } - -done: - return ret; -} - -static PyObject * -CTracer_start(CTracer *self, PyObject *args_unused) -{ - PyEval_SetTrace((Py_tracefunc)CTracer_trace, (PyObject*)self); - self->started = TRUE; - self->tracing_arcs = self->trace_arcs && PyObject_IsTrue(self->trace_arcs); - - /* start() returns a trace function usable with sys.settrace() */ - Py_INCREF(self); - return (PyObject *)self; -} - -static PyObject * -CTracer_stop(CTracer *self, PyObject *args_unused) -{ - if (self->started) { - /* Set the started flag only. The actual call to - PyEval_SetTrace(NULL, NULL) is delegated to the callback - itself to ensure that it called from the right thread. - */ - self->started = FALSE; - } - - Py_RETURN_NONE; -} - -static PyObject * -CTracer_activity(CTracer *self, PyObject *args_unused) -{ - if (self->activity) { - Py_RETURN_TRUE; - } - else { - Py_RETURN_FALSE; - } -} - -static PyObject * -CTracer_reset_activity(CTracer *self, PyObject *args_unused) -{ - self->activity = FALSE; - Py_RETURN_NONE; -} - -static PyObject * -CTracer_get_stats(CTracer *self, PyObject *args_unused) -{ -#if COLLECT_STATS - return Py_BuildValue( - "{sI,sI,sI,sI,sI,sI,sI,sI,si,sI,sI,sI}", - "calls", self->stats.calls, - "lines", self->stats.lines, - "returns", self->stats.returns, - "exceptions", self->stats.exceptions, - "others", self->stats.others, - "files", self->stats.files, - "missed_returns", self->stats.missed_returns, - "stack_reallocs", self->stats.stack_reallocs, - "stack_alloc", self->pdata_stack->alloc, - "errors", self->stats.errors, - "pycalls", self->stats.pycalls, - "start_context_calls", self->stats.start_context_calls - ); -#else - Py_RETURN_NONE; -#endif /* COLLECT_STATS */ -} - -static PyMemberDef -CTracer_members[] = { - { "should_trace", T_OBJECT, offsetof(CTracer, should_trace), 0, - PyDoc_STR("Function indicating whether to trace a file.") }, - - { "check_include", T_OBJECT, offsetof(CTracer, check_include), 0, - PyDoc_STR("Function indicating whether to include a file.") }, - - { "warn", T_OBJECT, offsetof(CTracer, warn), 0, - PyDoc_STR("Function for issuing warnings.") }, - - { "concur_id_func", T_OBJECT, offsetof(CTracer, concur_id_func), 0, - PyDoc_STR("Function for determining concurrency context") }, - - { "data", T_OBJECT, offsetof(CTracer, data), 0, - PyDoc_STR("The raw dictionary of trace data.") }, - - { "file_tracers", T_OBJECT, offsetof(CTracer, file_tracers), 0, - PyDoc_STR("Mapping from file name to plugin name.") }, - - { "should_trace_cache", T_OBJECT, offsetof(CTracer, should_trace_cache), 0, - PyDoc_STR("Dictionary caching should_trace results.") }, - - { "trace_arcs", T_OBJECT, offsetof(CTracer, trace_arcs), 0, - PyDoc_STR("Should we trace arcs, or just lines?") }, - - { "should_start_context", T_OBJECT, offsetof(CTracer, should_start_context), 0, - PyDoc_STR("Function for starting contexts.") }, - - { "switch_context", T_OBJECT, offsetof(CTracer, switch_context), 0, - PyDoc_STR("Function for switching to a new context.") }, - - { "disable_plugin", T_OBJECT, offsetof(CTracer, disable_plugin), 0, - PyDoc_STR("Function for disabling a plugin.") }, - - { NULL } -}; - -static PyMethodDef -CTracer_methods[] = { - { "start", (PyCFunction) CTracer_start, METH_VARARGS, - PyDoc_STR("Start the tracer") }, - - { "stop", (PyCFunction) CTracer_stop, METH_VARARGS, - PyDoc_STR("Stop the tracer") }, - - { "get_stats", (PyCFunction) CTracer_get_stats, METH_VARARGS, - PyDoc_STR("Get statistics about the tracing") }, - - { "activity", (PyCFunction) CTracer_activity, METH_VARARGS, - PyDoc_STR("Has there been any activity?") }, - - { "reset_activity", (PyCFunction) CTracer_reset_activity, METH_VARARGS, - PyDoc_STR("Reset the activity flag") }, - - { NULL } -}; - -PyTypeObject -CTracerType = { - MyType_HEAD_INIT - "coverage.CTracer", /*tp_name*/ - sizeof(CTracer), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)CTracer_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - (ternaryfunc)CTracer_call, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "CTracer objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - CTracer_methods, /* tp_methods */ - CTracer_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)CTracer_init, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ -}; diff --git a/contrib/python/coverage/py2/coverage/ctracer/tracer.h b/contrib/python/coverage/py2/coverage/ctracer/tracer.h deleted file mode 100644 index 8994a9e3d60..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/tracer.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -#ifndef _COVERAGE_TRACER_H -#define _COVERAGE_TRACER_H - -#include "util.h" -#include "structmember.h" -#include "frameobject.h" -#include "opcode.h" - -#include "datastack.h" - -/* The CTracer type. */ - -typedef struct CTracer { - PyObject_HEAD - - /* Python objects manipulated directly by the Collector class. */ - PyObject * should_trace; - PyObject * check_include; - PyObject * warn; - PyObject * concur_id_func; - PyObject * data; - PyObject * file_tracers; - PyObject * should_trace_cache; - PyObject * trace_arcs; - PyObject * should_start_context; - PyObject * switch_context; - PyObject * disable_plugin; - - /* Has the tracer been started? */ - BOOL started; - /* Are we tracing arcs, or just lines? */ - BOOL tracing_arcs; - /* Have we had any activity? */ - BOOL activity; - /* The current dynamic context. */ - PyObject * context; - - /* - The data stack is a stack of dictionaries. Each dictionary collects - data for a single source file. The data stack parallels the call stack: - each call pushes the new frame's file data onto the data stack, and each - return pops file data off. - - The file data is a dictionary whose form depends on the tracing options. - If tracing arcs, the keys are line number pairs. If not tracing arcs, - the keys are line numbers. In both cases, the value is irrelevant - (None). - */ - - DataStack data_stack; /* Used if we aren't doing concurrency. */ - - PyObject * data_stack_index; /* Used if we are doing concurrency. */ - DataStack * data_stacks; - int data_stacks_alloc; - int data_stacks_used; - DataStack * pdata_stack; - - /* The current file's data stack entry. */ - DataStackEntry * pcur_entry; - - /* The parent frame for the last exception event, to fix missing returns. */ - PyFrameObject * last_exc_back; - int last_exc_firstlineno; - - Stats stats; -} CTracer; - -int CTracer_intern_strings(void); - -extern PyTypeObject CTracerType; - -#endif /* _COVERAGE_TRACER_H */ diff --git a/contrib/python/coverage/py2/coverage/ctracer/util.h b/contrib/python/coverage/py2/coverage/ctracer/util.h deleted file mode 100644 index 5cba9b3096b..00000000000 --- a/contrib/python/coverage/py2/coverage/ctracer/util.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 */ -/* For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt */ - -#ifndef _COVERAGE_UTIL_H -#define _COVERAGE_UTIL_H - -#include - -/* Compile-time debugging helpers */ -#undef WHAT_LOG /* Define to log the WHAT params in the trace function. */ -#undef TRACE_LOG /* Define to log our bookkeeping. */ -#undef COLLECT_STATS /* Collect counters: stats are printed when tracer is stopped. */ -#undef DO_NOTHING /* Define this to make the tracer do nothing. */ - -/* Py 2.x and 3.x compatibility */ - -#if PY_MAJOR_VERSION >= 3 - -#define MyText_Type PyUnicode_Type -#define MyText_AS_BYTES(o) PyUnicode_AsASCIIString(o) -#define MyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) -#define MyBytes_AS_STRING(o) PyBytes_AS_STRING(o) -#define MyText_AsString(o) PyUnicode_AsUTF8(o) -#define MyText_FromFormat PyUnicode_FromFormat -#define MyInt_FromInt(i) PyLong_FromLong((long)i) -#define MyInt_AsInt(o) (int)PyLong_AsLong(o) -#define MyText_InternFromString(s) PyUnicode_InternFromString(s) - -#define MyType_HEAD_INIT PyVarObject_HEAD_INIT(NULL, 0) - -#else - -#define MyText_Type PyString_Type -#define MyText_AS_BYTES(o) (Py_INCREF(o), o) -#define MyBytes_GET_SIZE(o) PyString_GET_SIZE(o) -#define MyBytes_AS_STRING(o) PyString_AS_STRING(o) -#define MyText_AsString(o) PyString_AsString(o) -#define MyText_FromFormat PyUnicode_FromFormat -#define MyInt_FromInt(i) PyInt_FromLong((long)i) -#define MyInt_AsInt(o) (int)PyInt_AsLong(o) -#define MyText_InternFromString(s) PyString_InternFromString(s) - -#define MyType_HEAD_INIT PyObject_HEAD_INIT(NULL) 0, - -#endif /* Py3k */ - -// Undocumented, and not in all 2.7.x, so our own copy of it. -#define My_XSETREF(op, op2) \ - do { \ - PyObject *_py_tmp = (PyObject *)(op); \ - (op) = (op2); \ - Py_XDECREF(_py_tmp); \ - } while (0) - -/* The values returned to indicate ok or error. */ -#define RET_OK 0 -#define RET_ERROR -1 - -/* Nicer booleans */ -typedef int BOOL; -#define FALSE 0 -#define TRUE 1 - -/* Only for extreme machete-mode debugging! */ -#define CRASH { printf("*** CRASH! ***\n"); *((int*)1) = 1; } - -#endif /* _COVERAGE_UTIL_H */ diff --git a/contrib/python/coverage/py2/coverage/data.py b/contrib/python/coverage/py2/coverage/data.py deleted file mode 100644 index 5dd1dfe3f04..00000000000 --- a/contrib/python/coverage/py2/coverage/data.py +++ /dev/null @@ -1,125 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Coverage data for coverage.py. - -This file had the 4.x JSON data support, which is now gone. This file still -has storage-agnostic helpers, and is kept to avoid changing too many imports. -CoverageData is now defined in sqldata.py, and imported here to keep the -imports working. - -""" - -import glob -import os.path - -from coverage.misc import CoverageException, file_be_gone -from coverage.sqldata import CoverageData - - -def line_counts(data, fullpath=False): - """Return a dict summarizing the line coverage data. - - Keys are based on the file names, and values are the number of executed - lines. If `fullpath` is true, then the keys are the full pathnames of - the files, otherwise they are the basenames of the files. - - Returns a dict mapping file names to counts of lines. - - """ - summ = {} - if fullpath: - filename_fn = lambda f: f - else: - filename_fn = os.path.basename - for filename in data.measured_files(): - summ[filename_fn(filename)] = len(data.lines(filename)) - return summ - - -def add_data_to_hash(data, filename, hasher): - """Contribute `filename`'s data to the `hasher`. - - `hasher` is a `coverage.misc.Hasher` instance to be updated with - the file's data. It should only get the results data, not the run - data. - - """ - if data.has_arcs(): - hasher.update(sorted(data.arcs(filename) or [])) - else: - hasher.update(sorted(data.lines(filename) or [])) - hasher.update(data.file_tracer(filename)) - - -def combine_parallel_data(data, aliases=None, data_paths=None, strict=False, keep=False): - """Combine a number of data files together. - - Treat `data.filename` as a file prefix, and combine the data from all - of the data files starting with that prefix plus a dot. - - If `aliases` is provided, it's a `PathAliases` object that is used to - re-map paths to match the local machine's. - - If `data_paths` is provided, it is a list of directories or files to - combine. Directories are searched for files that start with - `data.filename` plus dot as a prefix, and those files are combined. - - If `data_paths` is not provided, then the directory portion of - `data.filename` is used as the directory to search for data files. - - Unless `keep` is True every data file found and combined is then deleted from disk. If a file - cannot be read, a warning will be issued, and the file will not be - deleted. - - If `strict` is true, and no files are found to combine, an error is - raised. - - """ - # Because of the os.path.abspath in the constructor, data_dir will - # never be an empty string. - data_dir, local = os.path.split(data.base_filename()) - localdot = local + '.*' - - data_paths = data_paths or [data_dir] - files_to_combine = [] - for p in data_paths: - if os.path.isfile(p): - files_to_combine.append(os.path.abspath(p)) - elif os.path.isdir(p): - pattern = os.path.join(os.path.abspath(p), localdot) - files_to_combine.extend(glob.glob(pattern)) - else: - raise CoverageException("Couldn't combine from non-existent path '%s'" % (p,)) - - if strict and not files_to_combine: - raise CoverageException("No data to combine") - - files_combined = 0 - for f in files_to_combine: - if f == data.data_filename(): - # Sometimes we are combining into a file which is one of the - # parallel files. Skip that file. - if data._debug.should('dataio'): - data._debug.write("Skipping combining ourself: %r" % (f,)) - continue - if data._debug.should('dataio'): - data._debug.write("Combining data file %r" % (f,)) - try: - new_data = CoverageData(f, debug=data._debug) - new_data.read() - except CoverageException as exc: - if data._warn: - # The CoverageException has the file name in it, so just - # use the message as the warning. - data._warn(str(exc)) - else: - data.update(new_data, aliases=aliases) - files_combined += 1 - if not keep: - if data._debug.should('dataio'): - data._debug.write("Deleting combined data file %r" % (f,)) - file_be_gone(f) - - if strict and not files_combined: - raise CoverageException("No usable data files") diff --git a/contrib/python/coverage/py2/coverage/debug.py b/contrib/python/coverage/py2/coverage/debug.py deleted file mode 100644 index 194f16f50db..00000000000 --- a/contrib/python/coverage/py2/coverage/debug.py +++ /dev/null @@ -1,406 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Control of and utilities for debugging.""" - -import contextlib -import functools -import inspect -import itertools -import os -import pprint -import sys -try: - import _thread -except ImportError: - import thread as _thread - -from coverage.backward import reprlib, StringIO -from coverage.misc import isolate_module - -os = isolate_module(os) - - -# When debugging, it can be helpful to force some options, especially when -# debugging the configuration mechanisms you usually use to control debugging! -# This is a list of forced debugging options. -FORCED_DEBUG = [] -FORCED_DEBUG_FILE = None - - -class DebugControl(object): - """Control and output for debugging.""" - - show_repr_attr = False # For SimpleReprMixin - - def __init__(self, options, output): - """Configure the options and output file for debugging.""" - self.options = list(options) + FORCED_DEBUG - self.suppress_callers = False - - filters = [] - if self.should('pid'): - filters.append(add_pid_and_tid) - self.output = DebugOutputFile.get_one( - output, - show_process=self.should('process'), - filters=filters, - ) - self.raw_output = self.output.outfile - - def __repr__(self): - return "" % (self.options, self.raw_output) - - def should(self, option): - """Decide whether to output debug information in category `option`.""" - if option == "callers" and self.suppress_callers: - return False - return (option in self.options) - - @contextlib.contextmanager - def without_callers(self): - """A context manager to prevent call stacks from being logged.""" - old = self.suppress_callers - self.suppress_callers = True - try: - yield - finally: - self.suppress_callers = old - - def write(self, msg): - """Write a line of debug output. - - `msg` is the line to write. A newline will be appended. - - """ - self.output.write(msg+"\n") - if self.should('self'): - caller_self = inspect.stack()[1][0].f_locals.get('self') - if caller_self is not None: - self.output.write("self: {!r}\n".format(caller_self)) - if self.should('callers'): - dump_stack_frames(out=self.output, skip=1) - self.output.flush() - - -class DebugControlString(DebugControl): - """A `DebugControl` that writes to a StringIO, for testing.""" - def __init__(self, options): - super(DebugControlString, self).__init__(options, StringIO()) - - def get_output(self): - """Get the output text from the `DebugControl`.""" - return self.raw_output.getvalue() - - -class NoDebugging(object): - """A replacement for DebugControl that will never try to do anything.""" - def should(self, option): # pylint: disable=unused-argument - """Should we write debug messages? Never.""" - return False - - -def info_header(label): - """Make a nice header string.""" - return "--{:-<60s}".format(" "+label+" ") - - -def info_formatter(info): - """Produce a sequence of formatted lines from info. - - `info` is a sequence of pairs (label, data). The produced lines are - nicely formatted, ready to print. - - """ - info = list(info) - if not info: - return - label_len = 30 - assert all(len(l) < label_len for l, _ in info) - for label, data in info: - if data == []: - data = "-none-" - if isinstance(data, (list, set, tuple)): - prefix = "%*s:" % (label_len, label) - for e in data: - yield "%*s %s" % (label_len+1, prefix, e) - prefix = "" - else: - yield "%*s: %s" % (label_len, label, data) - - -def write_formatted_info(writer, header, info): - """Write a sequence of (label,data) pairs nicely.""" - writer.write(info_header(header)) - for line in info_formatter(info): - writer.write(" %s" % line) - - -def short_stack(limit=None, skip=0): - """Return a string summarizing the call stack. - - The string is multi-line, with one line per stack frame. Each line shows - the function name, the file name, and the line number: - - ... - start_import_stop : /Users/ned/coverage/trunk/tests/coveragetest.py @95 - import_local_file : /Users/ned/coverage/trunk/tests/coveragetest.py @81 - import_local_file : /Users/ned/coverage/trunk/coverage/backward.py @159 - ... - - `limit` is the number of frames to include, defaulting to all of them. - - `skip` is the number of frames to skip, so that debugging functions can - call this and not be included in the result. - - """ - stack = inspect.stack()[limit:skip:-1] - return "\n".join("%30s : %s:%d" % (t[3], t[1], t[2]) for t in stack) - - -def dump_stack_frames(limit=None, out=None, skip=0): - """Print a summary of the stack to stdout, or someplace else.""" - out = out or sys.stdout - out.write(short_stack(limit=limit, skip=skip+1)) - out.write("\n") - - -def clipped_repr(text, numchars=50): - """`repr(text)`, but limited to `numchars`.""" - r = reprlib.Repr() - r.maxstring = numchars - return r.repr(text) - - -def short_id(id64): - """Given a 64-bit id, make a shorter 16-bit one.""" - id16 = 0 - for offset in range(0, 64, 16): - id16 ^= id64 >> offset - return id16 & 0xFFFF - - -def add_pid_and_tid(text): - """A filter to add pid and tid to debug messages.""" - # Thread ids are useful, but too long. Make a shorter one. - tid = "{:04x}".format(short_id(_thread.get_ident())) - text = "{:5d}.{}: {}".format(os.getpid(), tid, text) - return text - - -class SimpleReprMixin(object): - """A mixin implementing a simple __repr__.""" - simple_repr_ignore = ['simple_repr_ignore', '$coverage.object_id'] - - def __repr__(self): - show_attrs = ( - (k, v) for k, v in self.__dict__.items() - if getattr(v, "show_repr_attr", True) - and not callable(v) - and k not in self.simple_repr_ignore - ) - return "<{klass} @0x{id:x} {attrs}>".format( - klass=self.__class__.__name__, - id=id(self), - attrs=" ".join("{}={!r}".format(k, v) for k, v in show_attrs), - ) - - -def simplify(v): # pragma: debugging - """Turn things which are nearly dict/list/etc into dict/list/etc.""" - if isinstance(v, dict): - return {k:simplify(vv) for k, vv in v.items()} - elif isinstance(v, (list, tuple)): - return type(v)(simplify(vv) for vv in v) - elif hasattr(v, "__dict__"): - return simplify({'.'+k: v for k, v in v.__dict__.items()}) - else: - return v - - -def pp(v): # pragma: debugging - """Debug helper to pretty-print data, including SimpleNamespace objects.""" - # Might not be needed in 3.9+ - pprint.pprint(simplify(v)) - - -def filter_text(text, filters): - """Run `text` through a series of filters. - - `filters` is a list of functions. Each takes a string and returns a - string. Each is run in turn. - - Returns: the final string that results after all of the filters have - run. - - """ - clean_text = text.rstrip() - ending = text[len(clean_text):] - text = clean_text - for fn in filters: - lines = [] - for line in text.splitlines(): - lines.extend(fn(line).splitlines()) - text = "\n".join(lines) - return text + ending - - -class CwdTracker(object): # pragma: debugging - """A class to add cwd info to debug messages.""" - def __init__(self): - self.cwd = None - - def filter(self, text): - """Add a cwd message for each new cwd.""" - cwd = os.getcwd() - if cwd != self.cwd: - text = "cwd is now {!r}\n".format(cwd) + text - self.cwd = cwd - return text - - -class DebugOutputFile(object): # pragma: debugging - """A file-like object that includes pid and cwd information.""" - def __init__(self, outfile, show_process, filters): - self.outfile = outfile - self.show_process = show_process - self.filters = list(filters) - - if self.show_process: - self.filters.insert(0, CwdTracker().filter) - self.write("New process: executable: %r\n" % (sys.executable,)) - self.write("New process: cmd: %r\n" % (getattr(sys, 'argv', None),)) - if hasattr(os, 'getppid'): - self.write("New process: pid: %r, parent pid: %r\n" % (os.getpid(), os.getppid())) - - SYS_MOD_NAME = '$coverage.debug.DebugOutputFile.the_one' - - @classmethod - def get_one(cls, fileobj=None, show_process=True, filters=(), interim=False): - """Get a DebugOutputFile. - - If `fileobj` is provided, then a new DebugOutputFile is made with it. - - If `fileobj` isn't provided, then a file is chosen - (COVERAGE_DEBUG_FILE, or stderr), and a process-wide singleton - DebugOutputFile is made. - - `show_process` controls whether the debug file adds process-level - information, and filters is a list of other message filters to apply. - - `filters` are the text filters to apply to the stream to annotate with - pids, etc. - - If `interim` is true, then a future `get_one` can replace this one. - - """ - if fileobj is not None: - # Make DebugOutputFile around the fileobj passed. - return cls(fileobj, show_process, filters) - - # Because of the way igor.py deletes and re-imports modules, - # this class can be defined more than once. But we really want - # a process-wide singleton. So stash it in sys.modules instead of - # on a class attribute. Yes, this is aggressively gross. - the_one, is_interim = sys.modules.get(cls.SYS_MOD_NAME, (None, True)) - if the_one is None or is_interim: - if fileobj is None: - debug_file_name = os.environ.get("COVERAGE_DEBUG_FILE", FORCED_DEBUG_FILE) - if debug_file_name: - fileobj = open(debug_file_name, "a") - else: - fileobj = sys.stderr - the_one = cls(fileobj, show_process, filters) - sys.modules[cls.SYS_MOD_NAME] = (the_one, interim) - return the_one - - def write(self, text): - """Just like file.write, but filter through all our filters.""" - self.outfile.write(filter_text(text, self.filters)) - self.outfile.flush() - - def flush(self): - """Flush our file.""" - self.outfile.flush() - - -def log(msg, stack=False): # pragma: debugging - """Write a log message as forcefully as possible.""" - out = DebugOutputFile.get_one(interim=True) - out.write(msg+"\n") - if stack: - dump_stack_frames(out=out, skip=1) - - -def decorate_methods(decorator, butnot=(), private=False): # pragma: debugging - """A class decorator to apply a decorator to methods.""" - def _decorator(cls): - for name, meth in inspect.getmembers(cls, inspect.isroutine): - if name not in cls.__dict__: - continue - if name != "__init__": - if not private and name.startswith("_"): - continue - if name in butnot: - continue - setattr(cls, name, decorator(meth)) - return cls - return _decorator - - -def break_in_pudb(func): # pragma: debugging - """A function decorator to stop in the debugger for each call.""" - @functools.wraps(func) - def _wrapper(*args, **kwargs): - import pudb - sys.stdout = sys.__stdout__ - pudb.set_trace() - return func(*args, **kwargs) - return _wrapper - - -OBJ_IDS = itertools.count() -CALLS = itertools.count() -OBJ_ID_ATTR = "$coverage.object_id" - -def show_calls(show_args=True, show_stack=False, show_return=False): # pragma: debugging - """A method decorator to debug-log each call to the function.""" - def _decorator(func): - @functools.wraps(func) - def _wrapper(self, *args, **kwargs): - oid = getattr(self, OBJ_ID_ATTR, None) - if oid is None: - oid = "{:08d} {:04d}".format(os.getpid(), next(OBJ_IDS)) - setattr(self, OBJ_ID_ATTR, oid) - extra = "" - if show_args: - eargs = ", ".join(map(repr, args)) - ekwargs = ", ".join("{}={!r}".format(*item) for item in kwargs.items()) - extra += "(" - extra += eargs - if eargs and ekwargs: - extra += ", " - extra += ekwargs - extra += ")" - if show_stack: - extra += " @ " - extra += "; ".join(_clean_stack_line(l) for l in short_stack().splitlines()) - callid = next(CALLS) - msg = "{} {:04d} {}{}\n".format(oid, callid, func.__name__, extra) - DebugOutputFile.get_one(interim=True).write(msg) - ret = func(self, *args, **kwargs) - if show_return: - msg = "{} {:04d} {} return {!r}\n".format(oid, callid, func.__name__, ret) - DebugOutputFile.get_one(interim=True).write(msg) - return ret - return _wrapper - return _decorator - - -def _clean_stack_line(s): # pragma: debugging - """Simplify some paths in a stack trace, for compactness.""" - s = s.strip() - s = s.replace(os.path.dirname(__file__) + '/', '') - s = s.replace(os.path.dirname(os.__file__) + '/', '') - s = s.replace(sys.prefix + '/', '') - return s diff --git a/contrib/python/coverage/py2/coverage/disposition.py b/contrib/python/coverage/py2/coverage/disposition.py deleted file mode 100644 index 9b9a997d8ae..00000000000 --- a/contrib/python/coverage/py2/coverage/disposition.py +++ /dev/null @@ -1,37 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Simple value objects for tracking what to do with files.""" - - -class FileDisposition(object): - """A simple value type for recording what to do with a file.""" - pass - - -# FileDisposition "methods": FileDisposition is a pure value object, so it can -# be implemented in either C or Python. Acting on them is done with these -# functions. - -def disposition_init(cls, original_filename): - """Construct and initialize a new FileDisposition object.""" - disp = cls() - disp.original_filename = original_filename - disp.canonical_filename = original_filename - disp.source_filename = None - disp.trace = False - disp.reason = "" - disp.file_tracer = None - disp.has_dynamic_filename = False - return disp - - -def disposition_debug_msg(disp): - """Make a nice debug message of what the FileDisposition is doing.""" - if disp.trace: - msg = "Tracing %r" % (disp.original_filename,) - if disp.file_tracer: - msg += ": will be traced by %r" % disp.file_tracer - else: - msg = "Not tracing %r: %s" % (disp.original_filename, disp.reason) - return msg diff --git a/contrib/python/coverage/py2/coverage/env.py b/contrib/python/coverage/py2/coverage/env.py deleted file mode 100644 index ea78a5be89b..00000000000 --- a/contrib/python/coverage/py2/coverage/env.py +++ /dev/null @@ -1,130 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Determine facts about the environment.""" - -import os -import platform -import sys - -# Operating systems. -WINDOWS = sys.platform == "win32" -LINUX = sys.platform.startswith("linux") - -# Python implementations. -CPYTHON = (platform.python_implementation() == "CPython") -PYPY = (platform.python_implementation() == "PyPy") -JYTHON = (platform.python_implementation() == "Jython") -IRONPYTHON = (platform.python_implementation() == "IronPython") - -# Python versions. We amend version_info with one more value, a zero if an -# official version, or 1 if built from source beyond an official version. -PYVERSION = sys.version_info + (int(platform.python_version()[-1] == "+"),) -PY2 = PYVERSION < (3, 0) -PY3 = PYVERSION >= (3, 0) - -if PYPY: - PYPYVERSION = sys.pypy_version_info - -PYPY2 = PYPY and PY2 -PYPY3 = PYPY and PY3 - -# Python behavior. -class PYBEHAVIOR(object): - """Flags indicating this Python's behavior.""" - - pep626 = CPYTHON and (PYVERSION > (3, 10, 0, 'alpha', 4)) - - # Is "if __debug__" optimized away? - if PYPY3: - optimize_if_debug = True - elif PYPY2: - optimize_if_debug = False - else: - optimize_if_debug = not pep626 - - # Is "if not __debug__" optimized away? - optimize_if_not_debug = (not PYPY) and (PYVERSION >= (3, 7, 0, 'alpha', 4)) - if pep626: - optimize_if_not_debug = False - if PYPY3: - optimize_if_not_debug = True - - # Is "if not __debug__" optimized away even better? - optimize_if_not_debug2 = (not PYPY) and (PYVERSION >= (3, 8, 0, 'beta', 1)) - if pep626: - optimize_if_not_debug2 = False - - # Do we have yield-from? - yield_from = (PYVERSION >= (3, 3)) - - # Do we have PEP 420 namespace packages? - namespaces_pep420 = (PYVERSION >= (3, 3)) - - # Do .pyc files have the source file size recorded in them? - size_in_pyc = (PYVERSION >= (3, 3)) - - # Do we have async and await syntax? - async_syntax = (PYVERSION >= (3, 5)) - - # PEP 448 defined additional unpacking generalizations - unpackings_pep448 = (PYVERSION >= (3, 5)) - - # Can co_lnotab have negative deltas? - negative_lnotab = (PYVERSION >= (3, 6)) and not (PYPY and PYPYVERSION < (7, 2)) - - # Do .pyc files conform to PEP 552? Hash-based pyc's. - hashed_pyc_pep552 = (PYVERSION >= (3, 7, 0, 'alpha', 4)) - - # Python 3.7.0b3 changed the behavior of the sys.path[0] entry for -m. It - # used to be an empty string (meaning the current directory). It changed - # to be the actual path to the current directory, so that os.chdir wouldn't - # affect the outcome. - actual_syspath0_dash_m = CPYTHON and (PYVERSION >= (3, 7, 0, 'beta', 3)) - - # 3.7 changed how functions with only docstrings are numbered. - docstring_only_function = (not PYPY) and ((3, 7, 0, 'beta', 5) <= PYVERSION <= (3, 10)) - - # When a break/continue/return statement in a try block jumps to a finally - # block, does the finally block do the break/continue/return (pre-3.8), or - # does the finally jump back to the break/continue/return (3.8) to do the - # work? - finally_jumps_back = ((3, 8) <= PYVERSION < (3, 10)) - - # When a function is decorated, does the trace function get called for the - # @-line and also the def-line (new behavior in 3.8)? Or just the @-line - # (old behavior)? - trace_decorated_def = (PYVERSION >= (3, 8)) - - # Are while-true loops optimized into absolute jumps with no loop setup? - nix_while_true = (PYVERSION >= (3, 8)) - - # Python 3.9a1 made sys.argv[0] and other reported files absolute paths. - report_absolute_files = (PYVERSION >= (3, 9)) - - # Lines after break/continue/return/raise are no longer compiled into the - # bytecode. They used to be marked as missing, now they aren't executable. - omit_after_jump = pep626 - - # PyPy has always omitted statements after return. - omit_after_return = omit_after_jump or PYPY - - # Modules used to have firstlineno equal to the line number of the first - # real line of code. Now they always start at 1. - module_firstline_1 = pep626 - - # Are "if 0:" lines (and similar) kept in the compiled code? - keep_constant_test = pep626 - -# Coverage.py specifics. - -# Are we using the C-implemented trace function? -C_TRACER = os.getenv('COVERAGE_TEST_TRACER', 'c') == 'c' - -# Are we coverage-measuring ourselves? -METACOV = os.getenv('COVERAGE_COVERAGE', '') != '' - -# Are we running our test suite? -# Even when running tests, you can use COVERAGE_TESTING=0 to disable the -# test-specific behavior like contracts. -TESTING = os.getenv('COVERAGE_TESTING', '') == 'True' diff --git a/contrib/python/coverage/py2/coverage/execfile.py b/contrib/python/coverage/py2/coverage/execfile.py deleted file mode 100644 index 29409d517a2..00000000000 --- a/contrib/python/coverage/py2/coverage/execfile.py +++ /dev/null @@ -1,362 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Execute files of Python code.""" - -import inspect -import marshal -import os -import struct -import sys -import types - -from coverage import env -from coverage.backward import BUILTINS -from coverage.backward import PYC_MAGIC_NUMBER, imp, importlib_util_find_spec -from coverage.files import canonical_filename, python_reported_file -from coverage.misc import CoverageException, ExceptionDuringRun, NoCode, NoSource, isolate_module -from coverage.phystokens import compile_unicode -from coverage.python import get_python_source - -os = isolate_module(os) - - -class DummyLoader(object): - """A shim for the pep302 __loader__, emulating pkgutil.ImpLoader. - - Currently only implements the .fullname attribute - """ - def __init__(self, fullname, *_args): - self.fullname = fullname - - -if importlib_util_find_spec: - def find_module(modulename): - """Find the module named `modulename`. - - Returns the file path of the module, the name of the enclosing - package, and the spec. - """ - try: - spec = importlib_util_find_spec(modulename) - except ImportError as err: - raise NoSource(str(err)) - if not spec: - raise NoSource("No module named %r" % (modulename,)) - pathname = spec.origin - packagename = spec.name - if spec.submodule_search_locations: - mod_main = modulename + ".__main__" - spec = importlib_util_find_spec(mod_main) - if not spec: - raise NoSource( - "No module named %s; " - "%r is a package and cannot be directly executed" - % (mod_main, modulename) - ) - pathname = spec.origin - packagename = spec.name - packagename = packagename.rpartition(".")[0] - return pathname, packagename, spec -else: - def find_module(modulename): - """Find the module named `modulename`. - - Returns the file path of the module, the name of the enclosing - package, and None (where a spec would have been). - """ - openfile = None - glo, loc = globals(), locals() - try: - # Search for the module - inside its parent package, if any - using - # standard import mechanics. - if '.' in modulename: - packagename, name = modulename.rsplit('.', 1) - package = __import__(packagename, glo, loc, ['__path__']) - searchpath = package.__path__ - else: - packagename, name = None, modulename - searchpath = None # "top-level search" in imp.find_module() - openfile, pathname, _ = imp.find_module(name, searchpath) - - # Complain if this is a magic non-file module. - if openfile is None and pathname is None: - raise NoSource( - "module does not live in a file: %r" % modulename - ) - - # If `modulename` is actually a package, not a mere module, then we - # pretend to be Python 2.7 and try running its __main__.py script. - if openfile is None: - packagename = modulename - name = '__main__' - package = __import__(packagename, glo, loc, ['__path__']) - searchpath = package.__path__ - openfile, pathname, _ = imp.find_module(name, searchpath) - except ImportError as err: - raise NoSource(str(err)) - finally: - if openfile: - openfile.close() - - return pathname, packagename, None - - -class PyRunner(object): - """Multi-stage execution of Python code. - - This is meant to emulate real Python execution as closely as possible. - - """ - def __init__(self, args, as_module=False): - self.args = args - self.as_module = as_module - - self.arg0 = args[0] - self.package = self.modulename = self.pathname = self.loader = self.spec = None - - def prepare(self): - """Set sys.path properly. - - This needs to happen before any importing, and without importing anything. - """ - if self.as_module: - if env.PYBEHAVIOR.actual_syspath0_dash_m: - path0 = os.getcwd() - else: - path0 = "" - elif os.path.isdir(self.arg0): - # Running a directory means running the __main__.py file in that - # directory. - path0 = self.arg0 - else: - path0 = os.path.abspath(os.path.dirname(self.arg0)) - - if os.path.isdir(sys.path[0]): - # sys.path fakery. If we are being run as a command, then sys.path[0] - # is the directory of the "coverage" script. If this is so, replace - # sys.path[0] with the directory of the file we're running, or the - # current directory when running modules. If it isn't so, then we - # don't know what's going on, and just leave it alone. - top_file = inspect.stack()[-1][0].f_code.co_filename - sys_path_0_abs = os.path.abspath(sys.path[0]) - top_file_dir_abs = os.path.abspath(os.path.dirname(top_file)) - sys_path_0_abs = canonical_filename(sys_path_0_abs) - top_file_dir_abs = canonical_filename(top_file_dir_abs) - if sys_path_0_abs != top_file_dir_abs: - path0 = None - - else: - # sys.path[0] is a file. Is the next entry the directory containing - # that file? - if sys.path[1] == os.path.dirname(sys.path[0]): - # Can it be right to always remove that? - del sys.path[1] - - if path0 is not None: - sys.path[0] = python_reported_file(path0) - - def _prepare2(self): - """Do more preparation to run Python code. - - Includes finding the module to run and adjusting sys.argv[0]. - This method is allowed to import code. - - """ - if self.as_module: - self.modulename = self.arg0 - pathname, self.package, self.spec = find_module(self.modulename) - if self.spec is not None: - self.modulename = self.spec.name - self.loader = DummyLoader(self.modulename) - self.pathname = os.path.abspath(pathname) - self.args[0] = self.arg0 = self.pathname - elif os.path.isdir(self.arg0): - # Running a directory means running the __main__.py file in that - # directory. - for ext in [".py", ".pyc", ".pyo"]: - try_filename = os.path.join(self.arg0, "__main__" + ext) - if os.path.exists(try_filename): - self.arg0 = try_filename - break - else: - raise NoSource("Can't find '__main__' module in '%s'" % self.arg0) - - if env.PY2: - self.arg0 = os.path.abspath(self.arg0) - - # Make a spec. I don't know if this is the right way to do it. - try: - import importlib.machinery - except ImportError: - pass - else: - try_filename = python_reported_file(try_filename) - self.spec = importlib.machinery.ModuleSpec("__main__", None, origin=try_filename) - self.spec.has_location = True - self.package = "" - self.loader = DummyLoader("__main__") - else: - if env.PY3: - self.loader = DummyLoader("__main__") - - self.arg0 = python_reported_file(self.arg0) - - def run(self): - """Run the Python code!""" - - self._prepare2() - - # Create a module to serve as __main__ - main_mod = types.ModuleType('__main__') - - from_pyc = self.arg0.endswith((".pyc", ".pyo")) - main_mod.__file__ = self.arg0 - if from_pyc: - main_mod.__file__ = main_mod.__file__[:-1] - if self.package is not None: - main_mod.__package__ = self.package - main_mod.__loader__ = self.loader - if self.spec is not None: - main_mod.__spec__ = self.spec - - main_mod.__builtins__ = BUILTINS - - sys.modules['__main__'] = main_mod - - # Set sys.argv properly. - sys.argv = self.args - - try: - # Make a code object somehow. - if from_pyc: - code = make_code_from_pyc(self.arg0) - else: - code = make_code_from_py(self.arg0) - except CoverageException: - raise - except Exception as exc: - msg = "Couldn't run '{filename}' as Python code: {exc.__class__.__name__}: {exc}" - raise CoverageException(msg.format(filename=self.arg0, exc=exc)) - - # Execute the code object. - # Return to the original directory in case the test code exits in - # a non-existent directory. - cwd = os.getcwd() - try: - exec(code, main_mod.__dict__) - except SystemExit: # pylint: disable=try-except-raise - # The user called sys.exit(). Just pass it along to the upper - # layers, where it will be handled. - raise - except Exception: - # Something went wrong while executing the user code. - # Get the exc_info, and pack them into an exception that we can - # throw up to the outer loop. We peel one layer off the traceback - # so that the coverage.py code doesn't appear in the final printed - # traceback. - typ, err, tb = sys.exc_info() - - # PyPy3 weirdness. If I don't access __context__, then somehow it - # is non-None when the exception is reported at the upper layer, - # and a nested exception is shown to the user. This getattr fixes - # it somehow? https://bitbucket.org/pypy/pypy/issue/1903 - getattr(err, '__context__', None) - - # Call the excepthook. - try: - if hasattr(err, "__traceback__"): - err.__traceback__ = err.__traceback__.tb_next - sys.excepthook(typ, err, tb.tb_next) - except SystemExit: # pylint: disable=try-except-raise - raise - except Exception: - # Getting the output right in the case of excepthook - # shenanigans is kind of involved. - sys.stderr.write("Error in sys.excepthook:\n") - typ2, err2, tb2 = sys.exc_info() - err2.__suppress_context__ = True - if hasattr(err2, "__traceback__"): - err2.__traceback__ = err2.__traceback__.tb_next - sys.__excepthook__(typ2, err2, tb2.tb_next) - sys.stderr.write("\nOriginal exception was:\n") - raise ExceptionDuringRun(typ, err, tb.tb_next) - else: - sys.exit(1) - finally: - os.chdir(cwd) - - -def run_python_module(args): - """Run a Python module, as though with ``python -m name args...``. - - `args` is the argument array to present as sys.argv, including the first - element naming the module being executed. - - This is a helper for tests, to encapsulate how to use PyRunner. - - """ - runner = PyRunner(args, as_module=True) - runner.prepare() - runner.run() - - -def run_python_file(args): - """Run a Python file as if it were the main program on the command line. - - `args` is the argument array to present as sys.argv, including the first - element naming the file being executed. `package` is the name of the - enclosing package, if any. - - This is a helper for tests, to encapsulate how to use PyRunner. - - """ - runner = PyRunner(args, as_module=False) - runner.prepare() - runner.run() - - -def make_code_from_py(filename): - """Get source from `filename` and make a code object of it.""" - # Open the source file. - try: - source = get_python_source(filename) - except (IOError, NoSource): - raise NoSource("No file to run: '%s'" % filename) - - code = compile_unicode(source, filename, "exec") - return code - - -def make_code_from_pyc(filename): - """Get a code object from a .pyc file.""" - try: - fpyc = open(filename, "rb") - except IOError: - raise NoCode("No file to run: '%s'" % filename) - - with fpyc: - # First four bytes are a version-specific magic number. It has to - # match or we won't run the file. - magic = fpyc.read(4) - if magic != PYC_MAGIC_NUMBER: - raise NoCode("Bad magic number in .pyc file: {} != {}".format(magic, PYC_MAGIC_NUMBER)) - - date_based = True - if env.PYBEHAVIOR.hashed_pyc_pep552: - flags = struct.unpack(' MAX_FLAT: - h = hashlib.sha1(name.encode('UTF-8')).hexdigest() - name = name[-(MAX_FLAT-len(h)-1):] + '_' + h - return name - - -if env.WINDOWS: - - _ACTUAL_PATH_CACHE = {} - _ACTUAL_PATH_LIST_CACHE = {} - - def actual_path(path): - """Get the actual path of `path`, including the correct case.""" - if env.PY2 and isinstance(path, unicode_class): - path = path.encode(sys.getfilesystemencoding()) - if path in _ACTUAL_PATH_CACHE: - return _ACTUAL_PATH_CACHE[path] - - head, tail = os.path.split(path) - if not tail: - # This means head is the drive spec: normalize it. - actpath = head.upper() - elif not head: - actpath = tail - else: - head = actual_path(head) - if head in _ACTUAL_PATH_LIST_CACHE: - files = _ACTUAL_PATH_LIST_CACHE[head] - else: - try: - files = os.listdir(head) - except Exception: - # This will raise OSError, or this bizarre TypeError: - # https://bugs.python.org/issue1776160 - files = [] - _ACTUAL_PATH_LIST_CACHE[head] = files - normtail = os.path.normcase(tail) - for f in files: - if os.path.normcase(f) == normtail: - tail = f - break - actpath = os.path.join(head, tail) - _ACTUAL_PATH_CACHE[path] = actpath - return actpath - -else: - def actual_path(filename): - """The actual path for non-Windows platforms.""" - return filename - - -if env.PY2: - @contract(returns='unicode') - def unicode_filename(filename): - """Return a Unicode version of `filename`.""" - if isinstance(filename, str): - encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() - filename = filename.decode(encoding, "replace") - return filename -else: - @contract(filename='unicode', returns='unicode') - def unicode_filename(filename): - """Return a Unicode version of `filename`.""" - return filename - - -@contract(returns='unicode') -def abs_file(path): - """Return the absolute normalized form of `path`.""" - try: - path = os.path.realpath(path) - except UnicodeError: - pass - path = os.path.abspath(path) - path = actual_path(path) - path = unicode_filename(path) - return path - - -def python_reported_file(filename): - """Return the string as Python would describe this file name.""" - if env.PYBEHAVIOR.report_absolute_files: - filename = os.path.abspath(filename) - return filename - - -RELATIVE_DIR = None -CANONICAL_FILENAME_CACHE = None -set_relative_directory() - - -def isabs_anywhere(filename): - """Is `filename` an absolute path on any OS?""" - return ntpath.isabs(filename) or posixpath.isabs(filename) - - -def prep_patterns(patterns): - """Prepare the file patterns for use in a `FnmatchMatcher`. - - If a pattern starts with a wildcard, it is used as a pattern - as-is. If it does not start with a wildcard, then it is made - absolute with the current directory. - - If `patterns` is None, an empty list is returned. - - """ - prepped = [] - for p in patterns or []: - if p.startswith(("*", "?")): - prepped.append(p) - else: - prepped.append(abs_file(p)) - return prepped - - -class TreeMatcher(object): - """A matcher for files in a tree. - - Construct with a list of paths, either files or directories. Paths match - with the `match` method if they are one of the files, or if they are - somewhere in a subtree rooted at one of the directories. - - """ - def __init__(self, paths): - self.paths = list(paths) - - def __repr__(self): - return "" % self.paths - - def info(self): - """A list of strings for displaying when dumping state.""" - return self.paths - - def match(self, fpath): - """Does `fpath` indicate a file in one of our trees?""" - for p in self.paths: - if fpath.startswith(p): - if fpath == p: - # This is the same file! - return True - if fpath[len(p)] == os.sep: - # This is a file in the directory - return True - return False - - -class ModuleMatcher(object): - """A matcher for modules in a tree.""" - def __init__(self, module_names): - self.modules = list(module_names) - - def __repr__(self): - return "" % (self.modules) - - def info(self): - """A list of strings for displaying when dumping state.""" - return self.modules - - def match(self, module_name): - """Does `module_name` indicate a module in one of our packages?""" - if not module_name: - return False - - for m in self.modules: - if module_name.startswith(m): - if module_name == m: - return True - if module_name[len(m)] == '.': - # This is a module in the package - return True - - return False - - -class FnmatchMatcher(object): - """A matcher for files by file name pattern.""" - def __init__(self, pats): - self.pats = list(pats) - self.re = fnmatches_to_regex(self.pats, case_insensitive=env.WINDOWS) - - def __repr__(self): - return "" % self.pats - - def info(self): - """A list of strings for displaying when dumping state.""" - return self.pats - - def match(self, fpath): - """Does `fpath` match one of our file name patterns?""" - return self.re.match(fpath) is not None - - -def sep(s): - """Find the path separator used in this string, or os.sep if none.""" - sep_match = re.search(r"[\\/]", s) - if sep_match: - the_sep = sep_match.group(0) - else: - the_sep = os.sep - return the_sep - - -def fnmatches_to_regex(patterns, case_insensitive=False, partial=False): - """Convert fnmatch patterns to a compiled regex that matches any of them. - - Slashes are always converted to match either slash or backslash, for - Windows support, even when running elsewhere. - - If `partial` is true, then the pattern will match if the target string - starts with the pattern. Otherwise, it must match the entire string. - - Returns: a compiled regex object. Use the .match method to compare target - strings. - - """ - regexes = (fnmatch.translate(pattern) for pattern in patterns) - # Python3.7 fnmatch translates "/" as "/". Before that, it translates as "\/", - # so we have to deal with maybe a backslash. - regexes = (re.sub(r"\\?/", r"[\\\\/]", regex) for regex in regexes) - - if partial: - # fnmatch always adds a \Z to match the whole string, which we don't - # want, so we remove the \Z. While removing it, we only replace \Z if - # followed by paren (introducing flags), or at end, to keep from - # destroying a literal \Z in the pattern. - regexes = (re.sub(r'\\Z(\(\?|$)', r'\1', regex) for regex in regexes) - - flags = 0 - if case_insensitive: - flags |= re.IGNORECASE - compiled = re.compile(join_regex(regexes), flags=flags) - - return compiled - - -class PathAliases(object): - """A collection of aliases for paths. - - When combining data files from remote machines, often the paths to source - code are different, for example, due to OS differences, or because of - serialized checkouts on continuous integration machines. - - A `PathAliases` object tracks a list of pattern/result pairs, and can - map a path through those aliases to produce a unified path. - - """ - def __init__(self): - self.aliases = [] - - def pprint(self): # pragma: debugging - """Dump the important parts of the PathAliases, for debugging.""" - for regex, result in self.aliases: - print("{!r} --> {!r}".format(regex.pattern, result)) - - def add(self, pattern, result): - """Add the `pattern`/`result` pair to the list of aliases. - - `pattern` is an `fnmatch`-style pattern. `result` is a simple - string. When mapping paths, if a path starts with a match against - `pattern`, then that match is replaced with `result`. This models - isomorphic source trees being rooted at different places on two - different machines. - - `pattern` can't end with a wildcard component, since that would - match an entire tree, and not just its root. - - """ - pattern_sep = sep(pattern) - - if len(pattern) > 1: - pattern = pattern.rstrip(r"\/") - - # The pattern can't end with a wildcard component. - if pattern.endswith("*"): - raise CoverageException("Pattern must not end with wildcards.") - - # The pattern is meant to match a filepath. Let's make it absolute - # unless it already is, or is meant to match any prefix. - if not pattern.startswith('*') and not isabs_anywhere(pattern + - pattern_sep): - pattern = abs_file(pattern) - if not pattern.endswith(pattern_sep): - pattern += pattern_sep - - # Make a regex from the pattern. - regex = fnmatches_to_regex([pattern], case_insensitive=True, partial=True) - - # Normalize the result: it must end with a path separator. - result_sep = sep(result) - result = result.rstrip(r"\/") + result_sep - self.aliases.append((regex, result)) - - def map(self, path): - """Map `path` through the aliases. - - `path` is checked against all of the patterns. The first pattern to - match is used to replace the root of the path with the result root. - Only one pattern is ever used. If no patterns match, `path` is - returned unchanged. - - The separator style in the result is made to match that of the result - in the alias. - - Returns the mapped path. If a mapping has happened, this is a - canonical path. If no mapping has happened, it is the original value - of `path` unchanged. - - """ - for regex, result in self.aliases: - m = regex.match(path) - if m: - new = path.replace(m.group(0), result) - new = new.replace(sep(path), sep(result)) - new = canonical_filename(new) - return new - return path - - -def find_python_files(dirname): - """Yield all of the importable Python files in `dirname`, recursively. - - To be importable, the files have to be in a directory with a __init__.py, - except for `dirname` itself, which isn't required to have one. The - assumption is that `dirname` was specified directly, so the user knows - best, but sub-directories are checked for a __init__.py to be sure we only - find the importable files. - - """ - for i, (dirpath, dirnames, filenames) in enumerate(os.walk(dirname)): - if i > 0 and '__init__.py' not in filenames: - # If a directory doesn't have __init__.py, then it isn't - # importable and neither are its files - del dirnames[:] - continue - for filename in filenames: - # We're only interested in files that look like reasonable Python - # files: Must end with .py or .pyw, and must not have certain funny - # characters that probably mean they are editor junk. - if re.match(r"^[^.#~!$@%^&*()+=,]+\.pyw?$", filename): - yield os.path.join(dirpath, filename) diff --git a/contrib/python/coverage/py2/coverage/fullcoverage/encodings.py b/contrib/python/coverage/py2/coverage/fullcoverage/encodings.py deleted file mode 100644 index aeb416e4060..00000000000 --- a/contrib/python/coverage/py2/coverage/fullcoverage/encodings.py +++ /dev/null @@ -1,60 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""Imposter encodings module that installs a coverage-style tracer. - -This is NOT the encodings module; it is an imposter that sets up tracing -instrumentation and then replaces itself with the real encodings module. - -If the directory that holds this file is placed first in the PYTHONPATH when -using "coverage" to run Python's tests, then this file will become the very -first module imported by the internals of Python 3. It installs a -coverage.py-compatible trace function that can watch Standard Library modules -execute from the very earliest stages of Python's own boot process. This fixes -a problem with coverage.py - that it starts too late to trace the coverage of -many of the most fundamental modules in the Standard Library. - -""" - -import sys - -class FullCoverageTracer(object): - def __init__(self): - # `traces` is a list of trace events. Frames are tricky: the same - # frame object is used for a whole scope, with new line numbers - # written into it. So in one scope, all the frame objects are the - # same object, and will eventually all will point to the last line - # executed. So we keep the line numbers alongside the frames. - # The list looks like: - # - # traces = [ - # ((frame, event, arg), lineno), ... - # ] - # - self.traces = [] - - def fullcoverage_trace(self, *args): - frame, event, arg = args - self.traces.append((args, frame.f_lineno)) - return self.fullcoverage_trace - -sys.settrace(FullCoverageTracer().fullcoverage_trace) - -# In coverage/files.py is actual_filename(), which uses glob.glob. I don't -# understand why, but that use of glob borks everything if fullcoverage is in -# effect. So here we make an ugly hail-mary pass to switch off glob.glob over -# there. This means when using fullcoverage, Windows path names will not be -# their actual case. - -#sys.fullcoverage = True - -# Finally, remove our own directory from sys.path; remove ourselves from -# sys.modules; and re-import "encodings", which will be the real package -# this time. Note that the delete from sys.modules dictionary has to -# happen last, since all of the symbols in this module will become None -# at that exact moment, including "sys". - -parentdir = max(filter(__file__.startswith, sys.path), key=len) -sys.path.remove(parentdir) -del sys.modules['encodings'] -import encodings diff --git a/contrib/python/coverage/py2/coverage/html.py b/contrib/python/coverage/py2/coverage/html.py deleted file mode 100644 index 9d8e342716e..00000000000 --- a/contrib/python/coverage/py2/coverage/html.py +++ /dev/null @@ -1,539 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -"""HTML reporting for coverage.py.""" - -import datetime -import json -import os -import re -import shutil -import sys - -import coverage -from coverage import env -from coverage.backward import iitems, SimpleNamespace, format_local_datetime -from coverage.data import add_data_to_hash -from coverage.files import flat_rootname -from coverage.misc import CoverageException, ensure_dir, file_be_gone, Hasher, isolate_module -from coverage.report import get_analysis_to_report -from coverage.results import Numbers -from coverage.templite import Templite - -os = isolate_module(os) - - -# Static files are looked for in a list of places. -STATIC_PATH = [ - # The place Debian puts system Javascript libraries. - "/usr/share/javascript", - - # Our htmlfiles directory. - os.path.join(os.path.dirname(__file__), "htmlfiles"), -] - - -def data_filename(fname, pkgdir=""): - """Return the path to a data file of ours. - - The file is searched for on `STATIC_PATH`, and the first place it's found, - is returned. - - Each directory in `STATIC_PATH` is searched as-is, and also, if `pkgdir` - is provided, at that sub-directory. - - """ - tried = [] - for static_dir in STATIC_PATH: - static_filename = os.path.join(static_dir, fname) - if os.path.exists(static_filename): - return static_filename - else: - tried.append(static_filename) - if pkgdir: - static_filename = os.path.join(static_dir, pkgdir, fname) - if os.path.exists(static_filename): - return static_filename - else: - tried.append(static_filename) - raise CoverageException( - "Couldn't find static file %r from %r, tried: %r" % (fname, os.getcwd(), tried) - ) - - -def get_htmlfiles_resource(name): - import pkgutil - return pkgutil.get_data(__package__, 'htmlfiles/' + name) - - -def read_data(fname): - """Return the contents of a data file of ours.""" - if getattr(sys, 'is_standalone_binary', False): - res_buf = get_htmlfiles_resource(fname).decode() - if res_buf is not None: - return res_buf - - with open(data_filename(fname)) as data_file: - return data_file.read() - - -def write_html(fname, html): - """Write `html` to `fname`, properly encoded.""" - html = re.sub(r"(\A\s+)|(\s+$)", "", html, flags=re.MULTILINE) + "\n" - with open(fname, "wb") as fout: - fout.write(html.encode('ascii', 'xmlcharrefreplace')) - - -class HtmlDataGeneration(object): - """Generate structured data to be turned into HTML reports.""" - - EMPTY = "(empty)" - - def __init__(self, cov): - self.coverage = cov - self.config = self.coverage.config - data = self.coverage.get_data() - self.has_arcs = data.has_arcs() - if self.config.show_contexts: - if data.measured_contexts() == {""}: - self.coverage._warn("No contexts were measured") - data.set_query_contexts(self.config.report_contexts) - - def data_for_file(self, fr, analysis): - """Produce the data needed for one file's report.""" - if self.has_arcs: - missing_branch_arcs = analysis.missing_branch_arcs() - arcs_executed = analysis.arcs_executed() - - if self.config.show_contexts: - contexts_by_lineno = analysis.data.contexts_by_lineno(analysis.filename) - - lines = [] - - for lineno, tokens in enumerate(fr.source_token_lines(), start=1): - # Figure out how to mark this line. - category = None - short_annotations = [] - long_annotations = [] - - if lineno in analysis.excluded: - category = 'exc' - elif lineno in analysis.missing: - category = 'mis' - elif self.has_arcs and lineno in missing_branch_arcs: - category = 'par' - for b in missing_branch_arcs[lineno]: - if b < 0: - short_annotations.append("exit") - else: - short_annotations.append(b) - long_annotations.append(fr.missing_arc_description(lineno, b, arcs_executed)) - elif lineno in analysis.statements: - category = 'run' - - contexts = contexts_label = None - context_list = None - if category and self.config.show_contexts: - contexts = sorted(c or self.EMPTY for c in contexts_by_lineno[lineno]) - if contexts == [self.EMPTY]: - contexts_label = self.EMPTY - else: - contexts_label = "{} ctx".format(len(contexts)) - context_list = contexts - - lines.append(SimpleNamespace( - tokens=tokens, - number=lineno, - category=category, - statement=(lineno in analysis.statements), - contexts=contexts, - contexts_label=contexts_label, - context_list=context_list, - short_annotations=short_annotations, - long_annotations=long_annotations, - )) - - file_data = SimpleNamespace( - relative_filename=fr.relative_filename(), - nums=analysis.numbers, - lines=lines, - ) - - return file_data - - -class HtmlReporter(object): - """HTML reporting.""" - - # These files will be copied from the htmlfiles directory to the output - # directory. - STATIC_FILES = [ - ("style.css", ""), - ("jquery.min.js", "jquery"), - ("jquery.ba-throttle-debounce.min.js", "jquery-throttle-debounce"), - ("jquery.hotkeys.js", "jquery-hotkeys"), - ("jquery.isonscreen.js", "jquery-isonscreen"), - ("jquery.tablesorter.min.js", "jquery-tablesorter"), - ("coverage_html.js", ""), - ("keybd_closed.png", ""), - ("keybd_open.png", ""), - ("favicon_32.png", ""), - ] - - def __init__(self, cov): - self.coverage = cov - self.config = self.coverage.config - self.directory = self.config.html_dir - - self.skip_covered = self.config.html_skip_covered - if self.skip_covered is None: - self.skip_covered = self.config.skip_covered - self.skip_empty = self.config.html_skip_empty - if self.skip_empty is None: - self.skip_empty= self.config.skip_empty - - title = self.config.html_title - if env.PY2: - title = title.decode("utf8") - - if self.config.extra_css: - self.extra_css = os.path.basename(self.config.extra_css) - else: - self.extra_css = None - - self.data = self.coverage.get_data() - self.has_arcs = self.data.has_arcs() - - self.file_summaries = [] - self.all_files_nums = [] - self.incr = IncrementalChecker(self.directory) - self.datagen = HtmlDataGeneration(self.coverage) - self.totals = Numbers() - - self.template_globals = { - # Functions available in the templates. - 'escape': escape, - 'pair': pair, - 'len': len, - - # Constants for this report. - '__url__': coverage.__url__, - '__version__': coverage.__version__, - 'title': title, - 'time_stamp': format_local_datetime(datetime.datetime.now()), - 'extra_css': self.extra_css, - 'has_arcs': self.has_arcs, - 'show_contexts': self.config.show_contexts, - - # Constants for all reports. - # These css classes determine which lines are highlighted by default. - 'category': { - 'exc': 'exc show_exc', - 'mis': 'mis show_mis', - 'par': 'par run show_par', - 'run': 'run', - } - } - self.pyfile_html_source = read_data("pyfile.html") - self.source_tmpl = Templite(self.pyfile_html_source, self.template_globals) - - def report(self, morfs): - """Generate an HTML report for `morfs`. - - `morfs` is a list of modules or file names. - - """ - # Read the status data and check that this run used the same - # global data as the last run. - self.incr.read() - self.incr.check_global_data(self.config, self.pyfile_html_source) - - # Process all the files. - for fr, analysis in get_analysis_to_report(self.coverage, morfs): - self.html_file(fr, analysis) - - if not self.all_files_nums: - raise CoverageException("No data to report.") - - self.totals = sum(self.all_files_nums) - - # Write the index file. - self.index_file() - - self.make_local_static_report_files() - return self.totals.n_statements and self.totals.pc_covered - - def make_local_static_report_files(self): - """Make local instances of static files for HTML report.""" - # The files we provide must always be copied. - for static, pkgdir in self.STATIC_FILES: - if getattr(sys, 'is_standalone_binary', False): - data = get_htmlfiles_resource(static) - if data is None: - raise IOError("No such resource: " + static) - - with open(os.path.join(self.directory, static), "wb") as afile: - afile.write(data) - else: - shutil.copyfile( - data_filename(static, pkgdir), - os.path.join(self.directory, static) - ) - - # The user may have extra CSS they want copied. - if self.extra_css: - shutil.copyfile( - self.config.extra_css, - os.path.join(self.directory, self.extra_css) - ) - - def html_file(self, fr, analysis): - """Generate an HTML file for one source file.""" - rootname = flat_rootname(fr.relative_filename()) - html_filename = rootname + ".html" - ensure_dir(self.directory) - html_path = os.path.join(self.directory, html_filename) - - # Get the numbers for this file. - nums = analysis.numbers - self.all_files_nums.append(nums) - - if self.skip_covered: - # Don't report on 100% files. - no_missing_lines = (nums.n_missing == 0) - no_missing_branches = (nums.n_partial_branches == 0) - if no_missing_lines and no_missing_branches: - # If there's an existing file, remove it. - file_be_gone(html_path) - return - - if self.skip_empty: - # Don't report on empty files. - if nums.n_statements == 0: - file_be_gone(html_path) - return - - # Find out if the file on disk is already correct. - if self.incr.can_skip_file(self.data, fr, rootname): - self.file_summaries.append(self.incr.index_info(rootname)) - return - - # Write the HTML page for this file. - file_data = self.datagen.data_for_file(fr, analysis) - for ldata in file_data.lines: - # Build the HTML for the line. - html = [] - for tok_type, tok_text in ldata.tokens: - if tok_type == "ws": - html.append(escape(tok_text)) - else: - tok_html = escape(tok_text) or ' ' - html.append( - u'{}'.format(tok_type, tok_html) - ) - ldata.html = ''.join(html) - - if ldata.short_annotations: - # 202F is NARROW NO-BREAK SPACE. - # 219B is RIGHTWARDS ARROW WITH STROKE. - ldata.annotate = u",   ".join( - u"{} ↛ {}".format(ldata.number, d) - for d in ldata.short_annotations - ) - else: - ldata.annotate = None - - if ldata.long_annotations: - longs = ldata.long_annotations - if len(longs) == 1: - ldata.annotate_long = longs[0] - else: - ldata.annotate_long = u"{:d} missed branches: {}".format( - len(longs), - u", ".join( - u"{:d}) {}".format(num, ann_long) - for num, ann_long in enumerate(longs, start=1) - ), - ) - else: - ldata.annotate_long = None - - css_classes = [] - if ldata.category: - css_classes.append(self.template_globals['category'][ldata.category]) - ldata.css_class = ' '.join(css_classes) or "pln" - - html = self.source_tmpl.render(file_data.__dict__) - write_html(html_path, html) - - # Save this file's information for the index file. - index_info = { - 'nums': nums, - 'html_filename': html_filename, - 'relative_filename': fr.relative_filename(), - } - self.file_summaries.append(index_info) - self.incr.set_index_info(rootname, index_info) - - def index_file(self): - """Write the index.html file for this report.""" - index_tmpl = Templite(read_data("index.html"), self.template_globals) - - html = index_tmpl.render({ - 'files': self.file_summaries, - 'totals': self.totals, - }) - - write_html(os.path.join(self.directory, "index.html"), html) - - # Write the latest hashes for next time. - self.incr.write() - - -class IncrementalChecker(object): - """Logic and data to support incremental reporting.""" - - STATUS_FILE = "status.json" - STATUS_FORMAT = 2 - - # pylint: disable=wrong-spelling-in-comment,useless-suppression - # The data looks like: - # - # { - # "format": 2, - # "globals": "540ee119c15d52a68a53fe6f0897346d", - # "version": "4.0a1", - # "files": { - # "cogapp___init__": { - # "hash": "e45581a5b48f879f301c0f30bf77a50c", - # "index": { - # "html_filename": "cogapp___init__.html", - # "relative_filename": "cogapp/__init__", - # "nums": [ 1, 14, 0, 0, 0, 0, 0 ] - # } - # }, - # ... - # "cogapp_whiteutils": { - # "hash": "8504bb427fc488c4176809ded0277d51", - # "index": { - # "html_filename": "cogapp_whiteutils.html", - # "relative_filename": "cogapp/whiteutils", - # "nums": [ 1, 59, 0, 1, 28, 2, 2 ] - # } - # } - # } - # } - - def __init__(self, directory): - self.directory = directory - self.reset() - - def reset(self): - """Initialize to empty. Causes all files to be reported.""" - self.globals = '' - self.files = {} - - def read(self): - """Read the information we stored last time.""" - usable = False - try: - status_file = os.path.join(self.directory, self.STATUS_FILE) - with open(status_file) as fstatus: - status = json.load(fstatus) - except (IOError, ValueError): - usable = False - else: - usable = True - if status['format'] != self.STATUS_FORMAT: - usable = False - elif status['version'] != coverage.__version__: - usable = False - - if usable: - self.files = {} - for filename, fileinfo in iitems(status['files']): - fileinfo['index']['nums'] = Numbers(*fileinfo['index']['nums']) - self.files[filename] = fileinfo - self.globals = status['globals'] - else: - self.reset() - - def write(self): - """Write the current status.""" - status_file = os.path.join(self.directory, self.STATUS_FILE) - files = {} - for filename, fileinfo in iitems(self.files): - fileinfo['index']['nums'] = fileinfo['index']['nums'].init_args() - files[filename] = fileinfo - - status = { - 'format': self.STATUS_FORMAT, - 'version': coverage.__version__, - 'globals': self.globals, - 'files': files, - } - with open(status_file, "w") as fout: - json.dump(status, fout, separators=(',', ':')) - - def check_global_data(self, *data): - """Check the global data that can affect incremental reporting.""" - m = Hasher() - for d in data: - m.update(d) - these_globals = m.hexdigest() - if self.globals != these_globals: - self.reset() - self.globals = these_globals - - def can_skip_file(self, data, fr, rootname): - """Can we skip reporting this file? - - `data` is a CoverageData object, `fr` is a `FileReporter`, and - `rootname` is the name being used for the file. - """ - m = Hasher() - m.update(fr.source().encode('utf-8')) - add_data_to_hash(data, fr.filename, m) - this_hash = m.hexdigest() - - that_hash = self.file_hash(rootname) - - if this_hash == that_hash: - # Nothing has changed to require the file to be reported again. - return True - else: - self.set_file_hash(rootname, this_hash) - return False - - def file_hash(self, fname): - """Get the hash of `fname`'s contents.""" - return self.files.get(fname, {}).get('hash', '') - - def set_file_hash(self, fname, val): - """Set the hash of `fname`'s contents.""" - self.files.setdefault(fname, {})['hash'] = val - - def index_info(self, fname): - """Get the information for index.html for `fname`.""" - return self.files.get(fname, {}).get('index', {}) - - def set_index_info(self, fname, info): - """Set the information for index.html for `fname`.""" - self.files.setdefault(fname, {})['index'] = info - - -# Helpers for templates and generating HTML - -def escape(t): - """HTML-escape the text in `t`. - - This is only suitable for HTML text, not attributes. - - """ - # Convert HTML special chars into HTML entities. - return t.replace("&", "&").replace("<", "<") - - -def pair(ratio): - """Format a pair of numbers so JavaScript can read them in an attribute.""" - return "%s %s" % ratio diff --git a/contrib/python/coverage/py2/coverage/htmlfiles/coverage_html.js b/contrib/python/coverage/py2/coverage/htmlfiles/coverage_html.js deleted file mode 100644 index 27b49b36f96..00000000000 --- a/contrib/python/coverage/py2/coverage/htmlfiles/coverage_html.js +++ /dev/null @@ -1,616 +0,0 @@ -// Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -// For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -// Coverage.py HTML report browser code. -/*jslint browser: true, sloppy: true, vars: true, plusplus: true, maxerr: 50, indent: 4 */ -/*global coverage: true, document, window, $ */ - -coverage = {}; - -// Find all the elements with shortkey_* class, and use them to assign a shortcut key. -coverage.assign_shortkeys = function () { - $("*[class*='shortkey_']").each(function (i, e) { - $.each($(e).attr("class").split(" "), function (i, c) { - if (/^shortkey_/.test(c)) { - $(document).bind('keydown', c.substr(9), function () { - $(e).click(); - }); - } - }); - }); -}; - -// Create the events for the help panel. -coverage.wire_up_help_panel = function () { - $("#keyboard_icon").click(function () { - // Show the help panel, and position it so the keyboard icon in the - // panel is in the same place as the keyboard icon in the header. - $(".help_panel").show(); - var koff = $("#keyboard_icon").offset(); - var poff = $("#panel_icon").position(); - $(".help_panel").offset({ - top: koff.top-poff.top, - left: koff.left-poff.left - }); - }); - $("#panel_icon").click(function () { - $(".help_panel").hide(); - }); -}; - -// Create the events for the filter box. -coverage.wire_up_filter = function () { - // Cache elements. - var table = $("table.index"); - var table_rows = table.find("tbody tr"); - var table_row_names = table_rows.find("td.name a"); - var no_rows = $("#no_rows"); - - // Create a duplicate table footer that we can modify with dynamic summed values. - var table_footer = $("table.index tfoot tr"); - var table_dynamic_footer = table_footer.clone(); - table_dynamic_footer.attr('class', 'total_dynamic hidden'); - table_footer.after(table_dynamic_footer); - - // Observe filter keyevents. - $("#filter").on("keyup change", $.debounce(150, function (event) { - var filter_value = $(this).val(); - - if (filter_value === "") { - // Filter box is empty, remove all filtering. - table_rows.removeClass("hidden"); - - // Show standard footer, hide dynamic footer. - table_footer.removeClass("hidden"); - table_dynamic_footer.addClass("hidden"); - - // Hide placeholder, show table. - if (no_rows.length > 0) { - no_rows.hide(); - } - table.show(); - - } - else { - // Filter table items by value. - var hidden = 0; - var shown = 0; - - // Hide / show elements. - $.each(table_row_names, function () { - var element = $(this).parents("tr"); - - if ($(this).text().indexOf(filter_value) === -1) { - // hide - element.addClass("hidden"); - hidden++; - } - else { - // show - element.removeClass("hidden"); - shown++; - } - }); - - // Show placeholder if no rows will be displayed. - if (no_rows.length > 0) { - if (shown === 0) { - // Show placeholder, hide table. - no_rows.show(); - table.hide(); - } - else { - // Hide placeholder, show table. - no_rows.hide(); - table.show(); - } - } - - // Manage dynamic header: - if (hidden > 0) { - // Calculate new dynamic sum values based on visible rows. - for (var column = 2; column < 20; column++) { - // Calculate summed value. - var cells = table_rows.find('td:nth-child(' + column + ')'); - if (!cells.length) { - // No more columns...! - break; - } - - var sum = 0, numer = 0, denom = 0; - $.each(cells.filter(':visible'), function () { - var ratio = $(this).data("ratio"); - if (ratio) { - var splitted = ratio.split(" "); - numer += parseInt(splitted[0], 10); - denom += parseInt(splitted[1], 10); - } - else { - sum += parseInt(this.innerHTML, 10); - } - }); - - // Get footer cell element. - var footer_cell = table_dynamic_footer.find('td:nth-child(' + column + ')'); - - // Set value into dynamic footer cell element. - if (cells[0].innerHTML.indexOf('%') > -1) { - // Percentage columns use the numerator and denominator, - // and adapt to the number of decimal places. - var match = /\.([0-9]+)/.exec(cells[0].innerHTML); - var places = 0; - if (match) { - places = match[1].length; - } - var pct = numer * 100 / denom; - footer_cell.text(pct.toFixed(places) + '%'); - } - else { - footer_cell.text(sum); - } - } - - // Hide standard footer, show dynamic footer. - table_footer.addClass("hidden"); - table_dynamic_footer.removeClass("hidden"); - } - else { - // Show standard footer, hide dynamic footer. - table_footer.removeClass("hidden"); - table_dynamic_footer.addClass("hidden"); - } - } - })); - - // Trigger change event on setup, to force filter on page refresh - // (filter value may still be present). - $("#filter").trigger("change"); -}; - -// Loaded on index.html -coverage.index_ready = function ($) { - // Look for a localStorage item containing previous sort settings: - var sort_list = []; - var storage_name = "COVERAGE_INDEX_SORT"; - var stored_list = undefined; - try { - stored_list = localStorage.getItem(storage_name); - } catch(err) {} - - if (stored_list) { - sort_list = JSON.parse('[[' + stored_list + ']]'); - } - - // Create a new widget which exists only to save and restore - // the sort order: - $.tablesorter.addWidget({ - id: "persistentSort", - - // Format is called by the widget before displaying: - format: function (table) { - if (table.config.sortList.length === 0 && sort_list.length > 0) { - // This table hasn't been sorted before - we'll use - // our stored settings: - $(table).trigger('sorton', [sort_list]); - } - else { - // This is not the first load - something has - // already defined sorting so we'll just update - // our stored value to match: - sort_list = table.config.sortList; - } - } - }); - - // Configure our tablesorter to handle the variable number of - // columns produced depending on report options: - var headers = []; - var col_count = $("table.index > thead > tr > th").length; - - headers[0] = { sorter: 'text' }; - for (i = 1; i < col_count-1; i++) { - headers[i] = { sorter: 'digit' }; - } - headers[col_count-1] = { sorter: 'percent' }; - - // Enable the table sorter: - $("table.index").tablesorter({ - widgets: ['persistentSort'], - headers: headers - }); - - coverage.assign_shortkeys(); - coverage.wire_up_help_panel(); - coverage.wire_up_filter(); - - // Watch for page unload events so we can save the final sort settings: - $(window).on("unload", function () { - try { - localStorage.setItem(storage_name, sort_list.toString()) - } catch(err) {} - }); -}; - -// -- pyfile stuff -- - -coverage.LINE_FILTERS_STORAGE = "COVERAGE_LINE_FILTERS"; - -coverage.pyfile_ready = function ($) { - // If we're directed to a particular line number, highlight the line. - var frag = location.hash; - if (frag.length > 2 && frag[1] === 't') { - $(frag).addClass('highlight'); - coverage.set_sel(parseInt(frag.substr(2), 10)); - } - else { - coverage.set_sel(0); - } - - $(document) - .bind('keydown', 'j', coverage.to_next_chunk_nicely) - .bind('keydown', 'k', coverage.to_prev_chunk_nicely) - .bind('keydown', '0', coverage.to_top) - .bind('keydown', '1', coverage.to_first_chunk) - ; - - $(".button_toggle_run").click(function (evt) {coverage.toggle_lines(evt.target, "run");}); - $(".button_toggle_exc").click(function (evt) {coverage.toggle_lines(evt.target, "exc");}); - $(".button_toggle_mis").click(function (evt) {coverage.toggle_lines(evt.target, "mis");}); - $(".button_toggle_par").click(function (evt) {coverage.toggle_lines(evt.target, "par");}); - - coverage.filters = undefined; - try { - coverage.filters = localStorage.getItem(coverage.LINE_FILTERS_STORAGE); - } catch(err) {} - - if (coverage.filters) { - coverage.filters = JSON.parse(coverage.filters); - } - else { - coverage.filters = {run: false, exc: true, mis: true, par: true}; - } - - for (cls in coverage.filters) { - coverage.set_line_visibilty(cls, coverage.filters[cls]); - } - - coverage.assign_shortkeys(); - coverage.wire_up_help_panel(); - - coverage.init_scroll_markers(); - - // Rebuild scroll markers when the window height changes. - $(window).resize(coverage.build_scroll_markers); -}; - -coverage.toggle_lines = function (btn, cls) { - var onoff = !$(btn).hasClass("show_" + cls); - coverage.set_line_visibilty(cls, onoff); - coverage.build_scroll_markers(); - coverage.filters[cls] = onoff; - try { - localStorage.setItem(coverage.LINE_FILTERS_STORAGE, JSON.stringify(coverage.filters)); - } catch(err) {} -}; - -coverage.set_line_visibilty = function (cls, onoff) { - var show = "show_" + cls; - var btn = $(".button_toggle_" + cls); - if (onoff) { - $("#source ." + cls).addClass(show); - btn.addClass(show); - } - else { - $("#source ." + cls).removeClass(show); - btn.removeClass(show); - } -}; - -// Return the nth line div. -coverage.line_elt = function (n) { - return $("#t" + n); -}; - -// Return the nth line number div. -coverage.num_elt = function (n) { - return $("#n" + n); -}; - -// Set the selection. b and e are line numbers. -coverage.set_sel = function (b, e) { - // The first line selected. - coverage.sel_begin = b; - // The next line not selected. - coverage.sel_end = (e === undefined) ? b+1 : e; -}; - -coverage.to_top = function () { - coverage.set_sel(0, 1); - coverage.scroll_window(0); -}; - -coverage.to_first_chunk = function () { - coverage.set_sel(0, 1); - coverage.to_next_chunk(); -}; - -// Return a string indicating what kind of chunk this line belongs to, -// or null if not a chunk. -coverage.chunk_indicator = function (line_elt) { - var klass = line_elt.attr('class'); - if (klass) { - var m = klass.match(/\bshow_\w+\b/); - if (m) { - return m[0]; - } - } - return null; -}; - -coverage.to_next_chunk = function () { - var c = coverage; - - // Find the start of the next colored chunk. - var probe = c.sel_end; - var chunk_indicator, probe_line; - while (true) { - probe_line = c.line_elt(probe); - if (probe_line.length === 0) { - return; - } - chunk_indicator = c.chunk_indicator(probe_line); - if (chunk_indicator) { - break; - } - probe++; - } - - // There's a next chunk, `probe` points to it. - var begin = probe; - - // Find the end of this chunk. - var next_indicator = chunk_indicator; - while (next_indicator === chunk_indicator) { - probe++; - probe_line = c.line_elt(probe); - next_indicator = c.chunk_indicator(probe_line); - } - c.set_sel(begin, probe); - c.show_selection(); -}; - -coverage.to_prev_chunk = function () { - var c = coverage; - - // Find the end of the prev colored chunk. - var probe = c.sel_begin-1; - var probe_line = c.line_elt(probe); - if (probe_line.length === 0) { - return; - } - var chunk_indicator = c.chunk_indicator(probe_line); - while (probe > 0 && !chunk_indicator) { - probe--; - probe_line = c.line_elt(probe); - if (probe_line.length === 0) { - return; - } - chunk_indicator = c.chunk_indicator(probe_line); - } - - // There's a prev chunk, `probe` points to its last line. - var end = probe+1; - - // Find the beginning of this chunk. - var prev_indicator = chunk_indicator; - while (prev_indicator === chunk_indicator) { - probe--; - probe_line = c.line_elt(probe); - prev_indicator = c.chunk_indicator(probe_line); - } - c.set_sel(probe+1, end); - c.show_selection(); -}; - -// Return the line number of the line nearest pixel position pos -coverage.line_at_pos = function (pos) { - var l1 = coverage.line_elt(1), - l2 = coverage.line_elt(2), - result; - if (l1.length && l2.length) { - var l1_top = l1.offset().top, - line_height = l2.offset().top - l1_top, - nlines = (pos - l1_top) / line_height; - if (nlines < 1) { - result = 1; - } - else { - result = Math.ceil(nlines); - } - } - else { - result = 1; - } - return result; -}; - -// Returns 0, 1, or 2: how many of the two ends of the selection are on -// the screen right now? -coverage.selection_ends_on_screen = function () { - if (coverage.sel_begin === 0) { - return 0; - } - - var top = coverage.line_elt(coverage.sel_begin); - var next = coverage.line_elt(coverage.sel_end-1); - - return ( - (top.isOnScreen() ? 1 : 0) + - (next.isOnScreen() ? 1 : 0) - ); -}; - -coverage.to_next_chunk_nicely = function () { - coverage.finish_scrolling(); - if (coverage.selection_ends_on_screen() === 0) { - // The selection is entirely off the screen: select the top line on - // the screen. - var win = $(window); - coverage.select_line_or_chunk(coverage.line_at_pos(win.scrollTop())); - } - coverage.to_next_chunk(); -}; - -coverage.to_prev_chunk_nicely = function () { - coverage.finish_scrolling(); - if (coverage.selection_ends_on_screen() === 0) { - var win = $(window); - coverage.select_line_or_chunk(coverage.line_at_pos(win.scrollTop() + win.height())); - } - coverage.to_prev_chunk(); -}; - -// Select line number lineno, or if it is in a colored chunk, select the -// entire chunk -coverage.select_line_or_chunk = function (lineno) { - var c = coverage; - var probe_line = c.line_elt(lineno); - if (probe_line.length === 0) { - return; - } - var the_indicator = c.chunk_indicator(probe_line); - if (the_indicator) { - // The line is in a highlighted chunk. - // Search backward for the first line. - var probe = lineno; - var indicator = the_indicator; - while (probe > 0 && indicator === the_indicator) { - probe--; - probe_line = c.line_elt(probe); - if (probe_line.length === 0) { - break; - } - indicator = c.chunk_indicator(probe_line); - } - var begin = probe + 1; - - // Search forward for the last line. - probe = lineno; - indicator = the_indicator; - while (indicator === the_indicator) { - probe++; - probe_line = c.line_elt(probe); - indicator = c.chunk_indicator(probe_line); - } - - coverage.set_sel(begin, probe); - } - else { - coverage.set_sel(lineno); - } -}; - -coverage.show_selection = function () { - var c = coverage; - - // Highlight the lines in the chunk - $(".linenos .highlight").removeClass("highlight"); - for (var probe = c.sel_begin; probe > 0 && probe < c.sel_end; probe++) { - c.num_elt(probe).addClass("highlight"); - } - - c.scroll_to_selection(); -}; - -coverage.scroll_to_selection = function () { - // Scroll the page if the chunk isn't fully visible. - if (coverage.selection_ends_on_screen() < 2) { - // Need to move the page. The html,body trick makes it scroll in all - // browsers, got it from http://stackoverflow.com/questions/3042651 - var top = coverage.line_elt(coverage.sel_begin); - var top_pos = parseInt(top.offset().top, 10); - coverage.scroll_window(top_pos - 30); - } -}; - -coverage.scroll_window = function (to_pos) { - $("html,body").animate({scrollTop: to_pos}, 200); -}; - -coverage.finish_scrolling = function () { - $("html,body").stop(true, true); -}; - -coverage.init_scroll_markers = function () { - var c = coverage; - // Init some variables - c.lines_len = $('#source p').length; - c.body_h = $('body').height(); - c.header_h = $('div#header').height(); - - // Build html - c.build_scroll_markers(); -}; - -coverage.build_scroll_markers = function () { - var c = coverage, - min_line_height = 3, - max_line_height = 10, - visible_window_h = $(window).height(); - - c.lines_to_mark = $('#source').find('p.show_run, p.show_mis, p.show_exc, p.show_exc, p.show_par'); - $('#scroll_marker').remove(); - // Don't build markers if the window has no scroll bar. - if (c.body_h <= visible_window_h) { - return; - } - - $("body").append("
 
"); - var scroll_marker = $('#scroll_marker'), - marker_scale = scroll_marker.height() / c.body_h, - line_height = scroll_marker.height() / c.lines_len; - - // Line height must be between the extremes. - if (line_height > min_line_height) { - if (line_height > max_line_height) { - line_height = max_line_height; - } - } - else { - line_height = min_line_height; - } - - var previous_line = -99, - last_mark, - last_top, - offsets = {}; - - // Calculate line offsets outside loop to prevent relayouts - c.lines_to_mark.each(function() { - offsets[this.id] = $(this).offset().top; - }); - c.lines_to_mark.each(function () { - var id_name = $(this).attr('id'), - line_top = Math.round(offsets[id_name] * marker_scale), - line_number = parseInt(id_name.substring(1, id_name.length)); - - if (line_number === previous_line + 1) { - // If this solid missed block just make previous mark higher. - last_mark.css({ - 'height': line_top + line_height - last_top - }); - } - else { - // Add colored line in scroll_marker block. - scroll_marker.append('
'); - last_mark = $('#m' + line_number); - last_mark.css({ - 'height': line_height, - 'top': line_top - }); - last_top = line_top; - } - - previous_line = line_number; - }); -}; diff --git a/contrib/python/coverage/py2/coverage/htmlfiles/favicon_32.png b/contrib/python/coverage/py2/coverage/htmlfiles/favicon_32.png deleted file mode 100644 index 8649f0475d8..00000000000 Binary files a/contrib/python/coverage/py2/coverage/htmlfiles/favicon_32.png and /dev/null differ diff --git a/contrib/python/coverage/py2/coverage/htmlfiles/index.html b/contrib/python/coverage/py2/coverage/htmlfiles/index.html deleted file mode 100644 index 983db06125e..00000000000 --- a/contrib/python/coverage/py2/coverage/htmlfiles/index.html +++ /dev/null @@ -1,119 +0,0 @@ -{# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 #} -{# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt #} - - - - - - {{ title|escape }} - - - {% if extra_css %} - - {% endif %} - - - - - - - - - - - -
- Hide keyboard shortcuts -

Hot-keys on this page

-
-

- n - s - m - x - {% if has_arcs %} - b - p - {% endif %} - c   change column sorting -

-
-
- -
- - - {# The title="" attr doesn"t work in Safari. #} - - - - - - {% if has_arcs %} - - - {% endif %} - - - - {# HTML syntax requires thead, tfoot, tbody #} - - - - - - - {% if has_arcs %} - - - {% endif %} - - - - - {% for file in files %} - - - - - - {% if has_arcs %} - - - {% endif %} - - - {% endfor %} - -
Modulestatementsmissingexcludedbranchespartialcoverage
Total{{totals.n_statements}}{{totals.n_missing}}{{totals.n_excluded}}{{totals.n_branches}}{{totals.n_partial_branches}}{{totals.pc_covered_str}}%
{{file.relative_filename}}{{file.nums.n_statements}}{{file.nums.n_missing}}{{file.nums.n_excluded}}{{file.nums.n_branches}}{{file.nums.n_partial_branches}}{{file.nums.pc_covered_str}}%
- -

- No items found using the specified filter. -

-
- - - - - diff --git a/contrib/python/coverage/py2/coverage/htmlfiles/jquery.ba-throttle-debounce.min.js b/contrib/python/coverage/py2/coverage/htmlfiles/jquery.ba-throttle-debounce.min.js deleted file mode 100644 index 648fe5d3c22..00000000000 --- a/contrib/python/coverage/py2/coverage/htmlfiles/jquery.ba-throttle-debounce.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * jQuery throttle / debounce - v1.1 - 3/7/2010 - * http://benalman.com/projects/jquery-throttle-debounce-plugin/ - * - * Copyright (c) 2010 "Cowboy" Ben Alman - * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ - */ -(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this); diff --git a/contrib/python/coverage/py2/coverage/htmlfiles/jquery.hotkeys.js b/contrib/python/coverage/py2/coverage/htmlfiles/jquery.hotkeys.js deleted file mode 100644 index 09b21e03c7f..00000000000 --- a/contrib/python/coverage/py2/coverage/htmlfiles/jquery.hotkeys.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * jQuery Hotkeys Plugin - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * - * Based upon the plugin by Tzury Bar Yochay: - * http://github.com/tzuryby/hotkeys - * - * Original idea by: - * Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/ -*/ - -(function(jQuery){ - - jQuery.hotkeys = { - version: "0.8", - - specialKeys: { - 8: "backspace", 9: "tab", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause", - 20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home", - 37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del", - 96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7", - 104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/", - 112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8", - 120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 191: "/", 224: "meta" - }, - - shiftNums: { - "`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&", - "8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<", - ".": ">", "/": "?", "\\": "|" - } - }; - - function keyHandler( handleObj ) { - // Only care when a possible input has been specified - if ( typeof handleObj.data !== "string" ) { - return; - } - - var origHandler = handleObj.handler, - keys = handleObj.data.toLowerCase().split(" "); - - handleObj.handler = function( event ) { - // Don't fire in text-accepting inputs that we didn't directly bind to - if ( this !== event.target && (/textarea|select/i.test( event.target.nodeName ) || - event.target.type === "text") ) { - return; - } - - // Keypress represents characters, not special keys - var special = event.type !== "keypress" && jQuery.hotkeys.specialKeys[ event.which ], - character = String.fromCharCode( event.which ).toLowerCase(), - key, modif = "", possible = {}; - - // check combinations (alt|ctrl|shift+anything) - if ( event.altKey && special !== "alt" ) { - modif += "alt+"; - } - - if ( event.ctrlKey && special !== "ctrl" ) { - modif += "ctrl+"; - } - - // TODO: Need to make sure this works consistently across platforms - if ( event.metaKey && !event.ctrlKey && special !== "meta" ) { - modif += "meta+"; - } - - if ( event.shiftKey && special !== "shift" ) { - modif += "shift+"; - } - - if ( special ) { - possible[ modif + special ] = true; - - } else { - possible[ modif + character ] = true; - possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true; - - // "$" can be triggered as "Shift+4" or "Shift+$" or just "$" - if ( modif === "shift+" ) { - possible[ jQuery.hotkeys.shiftNums[ character ] ] = true; - } - } - - for ( var i = 0, l = keys.length; i < l; i++ ) { - if ( possible[ keys[i] ] ) { - return origHandler.apply( this, arguments ); - } - } - }; - } - - jQuery.each([ "keydown", "keyup", "keypress" ], function() { - jQuery.event.special[ this ] = { add: keyHandler }; - }); - -})( jQuery ); diff --git a/contrib/python/coverage/py2/coverage/htmlfiles/jquery.isonscreen.js b/contrib/python/coverage/py2/coverage/htmlfiles/jquery.isonscreen.js deleted file mode 100644 index 0182ebd2137..00000000000 --- a/contrib/python/coverage/py2/coverage/htmlfiles/jquery.isonscreen.js +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) 2010 - * @author Laurence Wheway - * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) - * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. - * - * @version 1.2.0 - */ -(function($) { - jQuery.extend({ - isOnScreen: function(box, container) { - //ensure numbers come in as intgers (not strings) and remove 'px' is it's there - for(var i in box){box[i] = parseFloat(box[i])}; - for(var i in container){container[i] = parseFloat(container[i])}; - - if(!container){ - container = { - left: $(window).scrollLeft(), - top: $(window).scrollTop(), - width: $(window).width(), - height: $(window).height() - } - } - - if( box.left+box.width-container.left > 0 && - box.left < container.width+container.left && - box.top+box.height-container.top > 0 && - box.top < container.height+container.top - ) return true; - return false; - } - }) - - - jQuery.fn.isOnScreen = function (container) { - for(var i in container){container[i] = parseFloat(container[i])}; - - if(!container){ - container = { - left: $(window).scrollLeft(), - top: $(window).scrollTop(), - width: $(window).width(), - height: $(window).height() - } - } - - if( $(this).offset().left+$(this).width()-container.left > 0 && - $(this).offset().left < container.width+container.left && - $(this).offset().top+$(this).height()-container.top > 0 && - $(this).offset().top < container.height+container.top - ) return true; - return false; - } -})(jQuery); diff --git a/contrib/python/coverage/py2/coverage/htmlfiles/jquery.min.js b/contrib/python/coverage/py2/coverage/htmlfiles/jquery.min.js deleted file mode 100644 index d1608e37ffa..00000000000 --- a/contrib/python/coverage/py2/coverage/htmlfiles/jquery.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h; -if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML="
a",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/\s*$/g,rb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:k.htmlSerialize?[0,"",""]:[1,"X
","
"]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?""!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("