Datasets:
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908324/1908324.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908308/1908309.tif +3 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__init__.py +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_backgroundjobs.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_clipboard.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_deepreload.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_display.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_editorhooks.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_imports.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_latextools.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_lexers.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pretty.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pygments.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_deepreload.py +57 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_display.py +272 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_editorhooks.py +32 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_imports.py +14 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_latextools.py +192 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_pretty.py +540 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_pygments.py +26 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/converters.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/exceptions.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/filters.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/setters.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/validators.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/setters.py +3 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/INSTALLER +1 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/LICENSE +49 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/METADATA +978 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/RECORD +28 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/WHEEL +6 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/top_level.txt +1 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/distutils-precedence.pth +3 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/docs/__pycache__/conf.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/docs/conf.py +384 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/keras-2.15.0.dist-info/INSTALLER +1 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/keras-2.15.0.dist-info/METADATA +51 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/keras-2.15.0.dist-info/RECORD +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/__init__.py +42 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/__pycache__/exceptions.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/_cext.pyi +228 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/exceptions.py +51 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/requests_oauthlib/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth1_auth.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth1_session.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth2_auth.cpython-310.pyc +0 -0
.gitattributes
CHANGED
|
@@ -421,3 +421,5 @@ material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:
|
|
| 421 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908278/1908279.tif filter=lfs diff=lfs merge=lfs -text
|
| 422 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_Manual_4connected/1908280_m.tif filter=lfs diff=lfs merge=lfs -text
|
| 423 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_Manual_4connected/1908316_m.tif filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 421 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908278/1908279.tif filter=lfs diff=lfs merge=lfs -text
|
| 422 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_Manual_4connected/1908280_m.tif filter=lfs diff=lfs merge=lfs -text
|
| 423 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_Manual_4connected/1908316_m.tif filter=lfs diff=lfs merge=lfs -text
|
| 424 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908308/1908309.tif filter=lfs diff=lfs merge=lfs -text
|
| 425 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908324/1908324.tif filter=lfs diff=lfs merge=lfs -text
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908324/1908324.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908308/1908309.tif
ADDED
|
|
Git LFS Details
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__init__.py
ADDED
|
File without changes
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (240 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_backgroundjobs.cpython-310.pyc
ADDED
|
Binary file (1.91 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_clipboard.cpython-310.pyc
ADDED
|
Binary file (683 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_deepreload.cpython-310.pyc
ADDED
|
Binary file (1.97 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_display.cpython-310.pyc
ADDED
|
Binary file (9.83 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_editorhooks.cpython-310.pyc
ADDED
|
Binary file (1.27 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_imports.cpython-310.pyc
ADDED
|
Binary file (732 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_latextools.cpython-310.pyc
ADDED
|
Binary file (5.88 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_lexers.cpython-310.pyc
ADDED
|
Binary file (3.65 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pretty.cpython-310.pyc
ADDED
|
Binary file (17.4 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/__pycache__/test_pygments.cpython-310.pyc
ADDED
|
Binary file (1.33 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_deepreload.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
"""Test suite for the deepreload module."""
|
| 3 |
+
|
| 4 |
+
# Copyright (c) IPython Development Team.
|
| 5 |
+
# Distributed under the terms of the Modified BSD License.
|
| 6 |
+
|
| 7 |
+
import types
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
import pytest
|
| 11 |
+
from tempfile import TemporaryDirectory
|
| 12 |
+
|
| 13 |
+
from IPython.lib.deepreload import modules_reloading
|
| 14 |
+
from IPython.lib.deepreload import reload as dreload
|
| 15 |
+
from IPython.utils.syspathcontext import prepended_to_syspath
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def test_deepreload():
|
| 19 |
+
"Test that dreload does deep reloads and skips excluded modules."
|
| 20 |
+
with TemporaryDirectory() as tmpdir:
|
| 21 |
+
with prepended_to_syspath(tmpdir):
|
| 22 |
+
tmpdirpath = Path(tmpdir)
|
| 23 |
+
with open(tmpdirpath / "A.py", "w", encoding="utf-8") as f:
|
| 24 |
+
f.write("class Object:\n pass\nok = True\n")
|
| 25 |
+
with open(tmpdirpath / "B.py", "w", encoding="utf-8") as f:
|
| 26 |
+
f.write("import A\nassert A.ok, 'we are fine'\n")
|
| 27 |
+
import A
|
| 28 |
+
import B
|
| 29 |
+
|
| 30 |
+
# Test that A is not reloaded.
|
| 31 |
+
obj = A.Object()
|
| 32 |
+
dreload(B, exclude=["A"])
|
| 33 |
+
assert isinstance(obj, A.Object) is True
|
| 34 |
+
|
| 35 |
+
# Test that an import failure will not blow-up us.
|
| 36 |
+
A.ok = False
|
| 37 |
+
with pytest.raises(AssertionError, match="we are fine"):
|
| 38 |
+
dreload(B, exclude=["A"])
|
| 39 |
+
assert len(modules_reloading) == 0
|
| 40 |
+
assert not A.ok
|
| 41 |
+
|
| 42 |
+
# Test that A is reloaded.
|
| 43 |
+
obj = A.Object()
|
| 44 |
+
A.ok = False
|
| 45 |
+
dreload(B)
|
| 46 |
+
assert A.ok
|
| 47 |
+
assert isinstance(obj, A.Object) is False
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def test_not_module():
|
| 51 |
+
pytest.raises(TypeError, dreload, "modulename")
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def test_not_in_sys_modules():
|
| 55 |
+
fake_module = types.ModuleType("fake_module")
|
| 56 |
+
with pytest.raises(ImportError, match="not in sys.modules"):
|
| 57 |
+
dreload(fake_module)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_display.py
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tests for IPython.lib.display.
|
| 2 |
+
|
| 3 |
+
"""
|
| 4 |
+
#-----------------------------------------------------------------------------
|
| 5 |
+
# Copyright (c) 2012, the IPython Development Team.
|
| 6 |
+
#
|
| 7 |
+
# Distributed under the terms of the Modified BSD License.
|
| 8 |
+
#
|
| 9 |
+
# The full license is in the file COPYING.txt, distributed with this software.
|
| 10 |
+
#-----------------------------------------------------------------------------
|
| 11 |
+
|
| 12 |
+
#-----------------------------------------------------------------------------
|
| 13 |
+
# Imports
|
| 14 |
+
#-----------------------------------------------------------------------------
|
| 15 |
+
from tempfile import NamedTemporaryFile, mkdtemp
|
| 16 |
+
from os.path import split, join as pjoin, dirname
|
| 17 |
+
import pathlib
|
| 18 |
+
from unittest import TestCase, mock
|
| 19 |
+
import struct
|
| 20 |
+
import wave
|
| 21 |
+
from io import BytesIO
|
| 22 |
+
|
| 23 |
+
# Third-party imports
|
| 24 |
+
import pytest
|
| 25 |
+
|
| 26 |
+
try:
|
| 27 |
+
import numpy
|
| 28 |
+
except ImportError:
|
| 29 |
+
pass
|
| 30 |
+
|
| 31 |
+
# Our own imports
|
| 32 |
+
from IPython.lib import display
|
| 33 |
+
|
| 34 |
+
from IPython.testing.decorators import skipif_not_numpy
|
| 35 |
+
|
| 36 |
+
#-----------------------------------------------------------------------------
|
| 37 |
+
# Classes and functions
|
| 38 |
+
#-----------------------------------------------------------------------------
|
| 39 |
+
|
| 40 |
+
#--------------------------
|
| 41 |
+
# FileLink tests
|
| 42 |
+
#--------------------------
|
| 43 |
+
|
| 44 |
+
def test_instantiation_FileLink():
|
| 45 |
+
"""FileLink: Test class can be instantiated"""
|
| 46 |
+
fl = display.FileLink('example.txt')
|
| 47 |
+
# TODO: remove if when only Python >= 3.6 is supported
|
| 48 |
+
fl = display.FileLink(pathlib.PurePath('example.txt'))
|
| 49 |
+
|
| 50 |
+
def test_warning_on_non_existent_path_FileLink():
|
| 51 |
+
"""FileLink: Calling _repr_html_ on non-existent files returns a warning"""
|
| 52 |
+
fl = display.FileLink("example.txt")
|
| 53 |
+
assert fl._repr_html_().startswith("Path (<tt>example.txt</tt>)")
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def test_existing_path_FileLink():
|
| 57 |
+
"""FileLink: Calling _repr_html_ functions as expected on existing filepath
|
| 58 |
+
"""
|
| 59 |
+
tf = NamedTemporaryFile()
|
| 60 |
+
fl = display.FileLink(tf.name)
|
| 61 |
+
actual = fl._repr_html_()
|
| 62 |
+
expected = "<a href='%s' target='_blank'>%s</a><br>" % (tf.name, tf.name)
|
| 63 |
+
assert actual == expected
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def test_existing_path_FileLink_repr():
|
| 67 |
+
"""FileLink: Calling repr() functions as expected on existing filepath
|
| 68 |
+
"""
|
| 69 |
+
tf = NamedTemporaryFile()
|
| 70 |
+
fl = display.FileLink(tf.name)
|
| 71 |
+
actual = repr(fl)
|
| 72 |
+
expected = tf.name
|
| 73 |
+
assert actual == expected
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def test_error_on_directory_to_FileLink():
|
| 77 |
+
"""FileLink: Raises error when passed directory
|
| 78 |
+
"""
|
| 79 |
+
td = mkdtemp()
|
| 80 |
+
pytest.raises(ValueError, display.FileLink, td)
|
| 81 |
+
|
| 82 |
+
#--------------------------
|
| 83 |
+
# FileLinks tests
|
| 84 |
+
#--------------------------
|
| 85 |
+
|
| 86 |
+
def test_instantiation_FileLinks():
|
| 87 |
+
"""FileLinks: Test class can be instantiated
|
| 88 |
+
"""
|
| 89 |
+
fls = display.FileLinks('example')
|
| 90 |
+
|
| 91 |
+
def test_warning_on_non_existent_path_FileLinks():
|
| 92 |
+
"""FileLinks: Calling _repr_html_ on non-existent files returns a warning"""
|
| 93 |
+
fls = display.FileLinks("example")
|
| 94 |
+
assert fls._repr_html_().startswith("Path (<tt>example</tt>)")
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def test_existing_path_FileLinks():
|
| 98 |
+
"""FileLinks: Calling _repr_html_ functions as expected on existing dir
|
| 99 |
+
"""
|
| 100 |
+
td = mkdtemp()
|
| 101 |
+
tf1 = NamedTemporaryFile(dir=td)
|
| 102 |
+
tf2 = NamedTemporaryFile(dir=td)
|
| 103 |
+
fl = display.FileLinks(td)
|
| 104 |
+
actual = fl._repr_html_()
|
| 105 |
+
actual = actual.split('\n')
|
| 106 |
+
actual.sort()
|
| 107 |
+
# the links should always have forward slashes, even on windows, so replace
|
| 108 |
+
# backslashes with forward slashes here
|
| 109 |
+
expected = ["%s/<br>" % td,
|
| 110 |
+
" <a href='%s' target='_blank'>%s</a><br>" %\
|
| 111 |
+
(tf2.name.replace("\\","/"),split(tf2.name)[1]),
|
| 112 |
+
" <a href='%s' target='_blank'>%s</a><br>" %\
|
| 113 |
+
(tf1.name.replace("\\","/"),split(tf1.name)[1])]
|
| 114 |
+
expected.sort()
|
| 115 |
+
# We compare the sorted list of links here as that's more reliable
|
| 116 |
+
assert actual == expected
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def test_existing_path_FileLinks_alt_formatter():
|
| 120 |
+
"""FileLinks: Calling _repr_html_ functions as expected w/ an alt formatter
|
| 121 |
+
"""
|
| 122 |
+
td = mkdtemp()
|
| 123 |
+
tf1 = NamedTemporaryFile(dir=td)
|
| 124 |
+
tf2 = NamedTemporaryFile(dir=td)
|
| 125 |
+
def fake_formatter(dirname,fnames,included_suffixes):
|
| 126 |
+
return ["hello","world"]
|
| 127 |
+
fl = display.FileLinks(td,notebook_display_formatter=fake_formatter)
|
| 128 |
+
actual = fl._repr_html_()
|
| 129 |
+
actual = actual.split('\n')
|
| 130 |
+
actual.sort()
|
| 131 |
+
expected = ["hello","world"]
|
| 132 |
+
expected.sort()
|
| 133 |
+
# We compare the sorted list of links here as that's more reliable
|
| 134 |
+
assert actual == expected
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def test_existing_path_FileLinks_repr():
|
| 138 |
+
"""FileLinks: Calling repr() functions as expected on existing directory """
|
| 139 |
+
td = mkdtemp()
|
| 140 |
+
tf1 = NamedTemporaryFile(dir=td)
|
| 141 |
+
tf2 = NamedTemporaryFile(dir=td)
|
| 142 |
+
fl = display.FileLinks(td)
|
| 143 |
+
actual = repr(fl)
|
| 144 |
+
actual = actual.split('\n')
|
| 145 |
+
actual.sort()
|
| 146 |
+
expected = ['%s/' % td, ' %s' % split(tf1.name)[1],' %s' % split(tf2.name)[1]]
|
| 147 |
+
expected.sort()
|
| 148 |
+
# We compare the sorted list of links here as that's more reliable
|
| 149 |
+
assert actual == expected
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def test_existing_path_FileLinks_repr_alt_formatter():
|
| 153 |
+
"""FileLinks: Calling repr() functions as expected w/ alt formatter
|
| 154 |
+
"""
|
| 155 |
+
td = mkdtemp()
|
| 156 |
+
tf1 = NamedTemporaryFile(dir=td)
|
| 157 |
+
tf2 = NamedTemporaryFile(dir=td)
|
| 158 |
+
def fake_formatter(dirname,fnames,included_suffixes):
|
| 159 |
+
return ["hello","world"]
|
| 160 |
+
fl = display.FileLinks(td,terminal_display_formatter=fake_formatter)
|
| 161 |
+
actual = repr(fl)
|
| 162 |
+
actual = actual.split('\n')
|
| 163 |
+
actual.sort()
|
| 164 |
+
expected = ["hello","world"]
|
| 165 |
+
expected.sort()
|
| 166 |
+
# We compare the sorted list of links here as that's more reliable
|
| 167 |
+
assert actual == expected
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def test_error_on_file_to_FileLinks():
|
| 171 |
+
"""FileLinks: Raises error when passed file
|
| 172 |
+
"""
|
| 173 |
+
td = mkdtemp()
|
| 174 |
+
tf1 = NamedTemporaryFile(dir=td)
|
| 175 |
+
pytest.raises(ValueError, display.FileLinks, tf1.name)
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def test_recursive_FileLinks():
|
| 179 |
+
"""FileLinks: Does not recurse when recursive=False
|
| 180 |
+
"""
|
| 181 |
+
td = mkdtemp()
|
| 182 |
+
tf = NamedTemporaryFile(dir=td)
|
| 183 |
+
subtd = mkdtemp(dir=td)
|
| 184 |
+
subtf = NamedTemporaryFile(dir=subtd)
|
| 185 |
+
fl = display.FileLinks(td)
|
| 186 |
+
actual = str(fl)
|
| 187 |
+
actual = actual.split('\n')
|
| 188 |
+
assert len(actual) == 4, actual
|
| 189 |
+
fl = display.FileLinks(td, recursive=False)
|
| 190 |
+
actual = str(fl)
|
| 191 |
+
actual = actual.split('\n')
|
| 192 |
+
assert len(actual) == 2, actual
|
| 193 |
+
|
| 194 |
+
def test_audio_from_file():
|
| 195 |
+
path = pjoin(dirname(__file__), 'test.wav')
|
| 196 |
+
display.Audio(filename=path)
|
| 197 |
+
|
| 198 |
+
class TestAudioDataWithNumpy(TestCase):
|
| 199 |
+
|
| 200 |
+
@skipif_not_numpy
|
| 201 |
+
def test_audio_from_numpy_array(self):
|
| 202 |
+
test_tone = get_test_tone()
|
| 203 |
+
audio = display.Audio(test_tone, rate=44100)
|
| 204 |
+
assert len(read_wav(audio.data)) == len(test_tone)
|
| 205 |
+
|
| 206 |
+
@skipif_not_numpy
|
| 207 |
+
def test_audio_from_list(self):
|
| 208 |
+
test_tone = get_test_tone()
|
| 209 |
+
audio = display.Audio(list(test_tone), rate=44100)
|
| 210 |
+
assert len(read_wav(audio.data)) == len(test_tone)
|
| 211 |
+
|
| 212 |
+
@skipif_not_numpy
|
| 213 |
+
def test_audio_from_numpy_array_without_rate_raises(self):
|
| 214 |
+
self.assertRaises(ValueError, display.Audio, get_test_tone())
|
| 215 |
+
|
| 216 |
+
@skipif_not_numpy
|
| 217 |
+
def test_audio_data_normalization(self):
|
| 218 |
+
expected_max_value = numpy.iinfo(numpy.int16).max
|
| 219 |
+
for scale in [1, 0.5, 2]:
|
| 220 |
+
audio = display.Audio(get_test_tone(scale), rate=44100)
|
| 221 |
+
actual_max_value = numpy.max(numpy.abs(read_wav(audio.data)))
|
| 222 |
+
assert actual_max_value == expected_max_value
|
| 223 |
+
|
| 224 |
+
@skipif_not_numpy
|
| 225 |
+
def test_audio_data_without_normalization(self):
|
| 226 |
+
max_int16 = numpy.iinfo(numpy.int16).max
|
| 227 |
+
for scale in [1, 0.5, 0.2]:
|
| 228 |
+
test_tone = get_test_tone(scale)
|
| 229 |
+
test_tone_max_abs = numpy.max(numpy.abs(test_tone))
|
| 230 |
+
expected_max_value = int(max_int16 * test_tone_max_abs)
|
| 231 |
+
audio = display.Audio(test_tone, rate=44100, normalize=False)
|
| 232 |
+
actual_max_value = numpy.max(numpy.abs(read_wav(audio.data)))
|
| 233 |
+
assert actual_max_value == expected_max_value
|
| 234 |
+
|
| 235 |
+
def test_audio_data_without_normalization_raises_for_invalid_data(self):
|
| 236 |
+
self.assertRaises(
|
| 237 |
+
ValueError,
|
| 238 |
+
lambda: display.Audio([1.001], rate=44100, normalize=False))
|
| 239 |
+
self.assertRaises(
|
| 240 |
+
ValueError,
|
| 241 |
+
lambda: display.Audio([-1.001], rate=44100, normalize=False))
|
| 242 |
+
|
| 243 |
+
def simulate_numpy_not_installed():
|
| 244 |
+
try:
|
| 245 |
+
import numpy
|
| 246 |
+
return mock.patch('numpy.array', mock.MagicMock(side_effect=ImportError))
|
| 247 |
+
except ModuleNotFoundError:
|
| 248 |
+
return lambda x:x
|
| 249 |
+
|
| 250 |
+
@simulate_numpy_not_installed()
|
| 251 |
+
class TestAudioDataWithoutNumpy(TestAudioDataWithNumpy):
|
| 252 |
+
# All tests from `TestAudioDataWithNumpy` are inherited.
|
| 253 |
+
|
| 254 |
+
@skipif_not_numpy
|
| 255 |
+
def test_audio_raises_for_nested_list(self):
|
| 256 |
+
stereo_signal = [list(get_test_tone())] * 2
|
| 257 |
+
self.assertRaises(TypeError, lambda: display.Audio(stereo_signal, rate=44100))
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
@skipif_not_numpy
|
| 261 |
+
def get_test_tone(scale=1):
|
| 262 |
+
return numpy.sin(2 * numpy.pi * 440 * numpy.linspace(0, 1, 44100)) * scale
|
| 263 |
+
|
| 264 |
+
def read_wav(data):
|
| 265 |
+
with wave.open(BytesIO(data)) as wave_file:
|
| 266 |
+
wave_data = wave_file.readframes(wave_file.getnframes())
|
| 267 |
+
num_samples = wave_file.getnframes() * wave_file.getnchannels()
|
| 268 |
+
return struct.unpack('<%sh' % num_samples, wave_data)
|
| 269 |
+
|
| 270 |
+
def test_code_from_file():
|
| 271 |
+
c = display.Code(filename=__file__)
|
| 272 |
+
assert c._repr_html_().startswith('<style>')
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_editorhooks.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Test installing editor hooks"""
|
| 2 |
+
import sys
|
| 3 |
+
from unittest import mock
|
| 4 |
+
|
| 5 |
+
from IPython import get_ipython
|
| 6 |
+
from IPython.lib import editorhooks
|
| 7 |
+
|
| 8 |
+
def test_install_editor():
|
| 9 |
+
called = []
|
| 10 |
+
def fake_popen(*args, **kwargs):
|
| 11 |
+
called.append({
|
| 12 |
+
'args': args,
|
| 13 |
+
'kwargs': kwargs,
|
| 14 |
+
})
|
| 15 |
+
return mock.MagicMock(**{'wait.return_value': 0})
|
| 16 |
+
editorhooks.install_editor('foo -l {line} -f {filename}', wait=False)
|
| 17 |
+
|
| 18 |
+
with mock.patch('subprocess.Popen', fake_popen):
|
| 19 |
+
get_ipython().hooks.editor('the file', 64)
|
| 20 |
+
|
| 21 |
+
assert len(called) == 1
|
| 22 |
+
args = called[0]["args"]
|
| 23 |
+
kwargs = called[0]["kwargs"]
|
| 24 |
+
|
| 25 |
+
assert kwargs == {"shell": True}
|
| 26 |
+
|
| 27 |
+
if sys.platform.startswith("win"):
|
| 28 |
+
expected = ["foo", "-l", "64", "-f", "the file"]
|
| 29 |
+
else:
|
| 30 |
+
expected = "foo -l 64 -f 'the file'"
|
| 31 |
+
cmd = args[0]
|
| 32 |
+
assert cmd == expected
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_imports.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# encoding: utf-8
|
| 2 |
+
from IPython.testing import decorators as dec
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def test_import_backgroundjobs():
|
| 6 |
+
from IPython.lib import backgroundjobs
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def test_import_deepreload():
|
| 10 |
+
from IPython.lib import deepreload
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def test_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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tests for IPython.utils.path.py"""
|
| 2 |
+
# Copyright (c) IPython Development Team.
|
| 3 |
+
# Distributed under the terms of the Modified BSD License.
|
| 4 |
+
|
| 5 |
+
from contextlib import contextmanager
|
| 6 |
+
from unittest.mock import patch
|
| 7 |
+
|
| 8 |
+
import pytest
|
| 9 |
+
|
| 10 |
+
from IPython.lib import latextools
|
| 11 |
+
from IPython.testing.decorators import (
|
| 12 |
+
onlyif_cmds_exist,
|
| 13 |
+
skipif_not_matplotlib,
|
| 14 |
+
)
|
| 15 |
+
from IPython.utils.process import FindCmdError
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
@pytest.mark.parametrize('command', ['latex', 'dvipng'])
|
| 19 |
+
def test_check_latex_to_png_dvipng_fails_when_no_cmd(command):
|
| 20 |
+
def mock_find_cmd(arg):
|
| 21 |
+
if arg == command:
|
| 22 |
+
raise FindCmdError
|
| 23 |
+
|
| 24 |
+
with patch.object(latextools, "find_cmd", mock_find_cmd):
|
| 25 |
+
assert latextools.latex_to_png_dvipng("whatever", True) is None
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
@contextmanager
|
| 29 |
+
def no_op(*args, **kwargs):
|
| 30 |
+
yield
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@onlyif_cmds_exist("latex", "dvipng")
|
| 34 |
+
@pytest.mark.parametrize("s, wrap", [("$$x^2$$", False), ("x^2", True)])
|
| 35 |
+
def test_latex_to_png_dvipng_runs(s, wrap):
|
| 36 |
+
"""
|
| 37 |
+
Test that latex_to_png_dvipng just runs without error.
|
| 38 |
+
"""
|
| 39 |
+
def mock_kpsewhich(filename):
|
| 40 |
+
assert filename == "breqn.sty"
|
| 41 |
+
return None
|
| 42 |
+
|
| 43 |
+
latextools.latex_to_png_dvipng(s, wrap)
|
| 44 |
+
|
| 45 |
+
with patch_latextool(mock_kpsewhich):
|
| 46 |
+
latextools.latex_to_png_dvipng(s, wrap)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def mock_kpsewhich(filename):
|
| 50 |
+
assert filename == "breqn.sty"
|
| 51 |
+
return None
|
| 52 |
+
|
| 53 |
+
@contextmanager
|
| 54 |
+
def patch_latextool(mock=mock_kpsewhich):
|
| 55 |
+
with patch.object(latextools, "kpsewhich", mock):
|
| 56 |
+
yield
|
| 57 |
+
|
| 58 |
+
@pytest.mark.parametrize('context', [no_op, patch_latextool])
|
| 59 |
+
@pytest.mark.parametrize('s_wrap', [("$x^2$", False), ("x^2", True)])
|
| 60 |
+
def test_latex_to_png_mpl_runs(s_wrap, context):
|
| 61 |
+
"""
|
| 62 |
+
Test that latex_to_png_mpl just runs without error.
|
| 63 |
+
"""
|
| 64 |
+
try:
|
| 65 |
+
import matplotlib
|
| 66 |
+
except ImportError:
|
| 67 |
+
pytest.skip("This needs matplotlib to be available")
|
| 68 |
+
return
|
| 69 |
+
s, wrap = s_wrap
|
| 70 |
+
with context():
|
| 71 |
+
latextools.latex_to_png_mpl(s, wrap)
|
| 72 |
+
|
| 73 |
+
@skipif_not_matplotlib
|
| 74 |
+
def test_latex_to_html():
|
| 75 |
+
img = latextools.latex_to_html("$x^2$")
|
| 76 |
+
assert "data:image/png;base64,iVBOR" in img
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def test_genelatex_no_wrap():
|
| 80 |
+
"""
|
| 81 |
+
Test genelatex with wrap=False.
|
| 82 |
+
"""
|
| 83 |
+
def mock_kpsewhich(filename):
|
| 84 |
+
assert False, ("kpsewhich should not be called "
|
| 85 |
+
"(called with {0})".format(filename))
|
| 86 |
+
|
| 87 |
+
with patch_latextool(mock_kpsewhich):
|
| 88 |
+
assert '\n'.join(latextools.genelatex("body text", False)) == r'''\documentclass{article}
|
| 89 |
+
\usepackage{amsmath}
|
| 90 |
+
\usepackage{amsthm}
|
| 91 |
+
\usepackage{amssymb}
|
| 92 |
+
\usepackage{bm}
|
| 93 |
+
\pagestyle{empty}
|
| 94 |
+
\begin{document}
|
| 95 |
+
body text
|
| 96 |
+
\end{document}'''
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def test_genelatex_wrap_with_breqn():
|
| 100 |
+
"""
|
| 101 |
+
Test genelatex with wrap=True for the case breqn.sty is installed.
|
| 102 |
+
"""
|
| 103 |
+
def mock_kpsewhich(filename):
|
| 104 |
+
assert filename == "breqn.sty"
|
| 105 |
+
return "path/to/breqn.sty"
|
| 106 |
+
|
| 107 |
+
with patch_latextool(mock_kpsewhich):
|
| 108 |
+
assert '\n'.join(latextools.genelatex("x^2", True)) == r'''\documentclass{article}
|
| 109 |
+
\usepackage{amsmath}
|
| 110 |
+
\usepackage{amsthm}
|
| 111 |
+
\usepackage{amssymb}
|
| 112 |
+
\usepackage{bm}
|
| 113 |
+
\usepackage{breqn}
|
| 114 |
+
\pagestyle{empty}
|
| 115 |
+
\begin{document}
|
| 116 |
+
\begin{dmath*}
|
| 117 |
+
x^2
|
| 118 |
+
\end{dmath*}
|
| 119 |
+
\end{document}'''
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def test_genelatex_wrap_without_breqn():
|
| 123 |
+
"""
|
| 124 |
+
Test genelatex with wrap=True for the case breqn.sty is not installed.
|
| 125 |
+
"""
|
| 126 |
+
def mock_kpsewhich(filename):
|
| 127 |
+
assert filename == "breqn.sty"
|
| 128 |
+
return None
|
| 129 |
+
|
| 130 |
+
with patch_latextool(mock_kpsewhich):
|
| 131 |
+
assert '\n'.join(latextools.genelatex("x^2", True)) == r'''\documentclass{article}
|
| 132 |
+
\usepackage{amsmath}
|
| 133 |
+
\usepackage{amsthm}
|
| 134 |
+
\usepackage{amssymb}
|
| 135 |
+
\usepackage{bm}
|
| 136 |
+
\pagestyle{empty}
|
| 137 |
+
\begin{document}
|
| 138 |
+
$$x^2$$
|
| 139 |
+
\end{document}'''
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
@skipif_not_matplotlib
|
| 143 |
+
@onlyif_cmds_exist('latex', 'dvipng')
|
| 144 |
+
def test_latex_to_png_color():
|
| 145 |
+
"""
|
| 146 |
+
Test color settings for latex_to_png.
|
| 147 |
+
"""
|
| 148 |
+
latex_string = "$x^2$"
|
| 149 |
+
default_value = latextools.latex_to_png(latex_string, wrap=False)
|
| 150 |
+
default_hexblack = latextools.latex_to_png(latex_string, wrap=False,
|
| 151 |
+
color='#000000')
|
| 152 |
+
dvipng_default = latextools.latex_to_png_dvipng(latex_string, False)
|
| 153 |
+
dvipng_black = latextools.latex_to_png_dvipng(latex_string, False, 'Black')
|
| 154 |
+
assert dvipng_default == dvipng_black
|
| 155 |
+
mpl_default = latextools.latex_to_png_mpl(latex_string, False)
|
| 156 |
+
mpl_black = latextools.latex_to_png_mpl(latex_string, False, 'Black')
|
| 157 |
+
assert mpl_default == mpl_black
|
| 158 |
+
assert default_value in [dvipng_black, mpl_black]
|
| 159 |
+
assert default_hexblack in [dvipng_black, mpl_black]
|
| 160 |
+
|
| 161 |
+
# Test that dvips name colors can be used without error
|
| 162 |
+
dvipng_maroon = latextools.latex_to_png_dvipng(latex_string, False,
|
| 163 |
+
'Maroon')
|
| 164 |
+
# And that it doesn't return the black one
|
| 165 |
+
assert dvipng_black != dvipng_maroon
|
| 166 |
+
|
| 167 |
+
mpl_maroon = latextools.latex_to_png_mpl(latex_string, False, 'Maroon')
|
| 168 |
+
assert mpl_black != mpl_maroon
|
| 169 |
+
mpl_white = latextools.latex_to_png_mpl(latex_string, False, 'White')
|
| 170 |
+
mpl_hexwhite = latextools.latex_to_png_mpl(latex_string, False, '#FFFFFF')
|
| 171 |
+
assert mpl_white == mpl_hexwhite
|
| 172 |
+
|
| 173 |
+
mpl_white_scale = latextools.latex_to_png_mpl(latex_string, False,
|
| 174 |
+
'White', 1.2)
|
| 175 |
+
assert mpl_white != mpl_white_scale
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def test_latex_to_png_invalid_hex_colors():
|
| 179 |
+
"""
|
| 180 |
+
Test that invalid hex colors provided to dvipng gives an exception.
|
| 181 |
+
"""
|
| 182 |
+
latex_string = "$x^2$"
|
| 183 |
+
pytest.raises(
|
| 184 |
+
ValueError,
|
| 185 |
+
lambda: latextools.latex_to_png(
|
| 186 |
+
latex_string, backend="dvipng", color="#f00bar"
|
| 187 |
+
),
|
| 188 |
+
)
|
| 189 |
+
pytest.raises(
|
| 190 |
+
ValueError,
|
| 191 |
+
lambda: latextools.latex_to_png(latex_string, backend="dvipng", color="#f00"),
|
| 192 |
+
)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_pretty.py
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding: utf-8
|
| 2 |
+
"""Tests for IPython.lib.pretty."""
|
| 3 |
+
|
| 4 |
+
# Copyright (c) IPython Development Team.
|
| 5 |
+
# Distributed under the terms of the Modified BSD License.
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
from collections import Counter, defaultdict, deque, OrderedDict, UserList
|
| 9 |
+
import os
|
| 10 |
+
import pytest
|
| 11 |
+
import types
|
| 12 |
+
import string
|
| 13 |
+
import sys
|
| 14 |
+
import unittest
|
| 15 |
+
|
| 16 |
+
import pytest
|
| 17 |
+
|
| 18 |
+
from IPython.lib import pretty
|
| 19 |
+
|
| 20 |
+
from io import StringIO
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class MyList(object):
|
| 24 |
+
def __init__(self, content):
|
| 25 |
+
self.content = content
|
| 26 |
+
def _repr_pretty_(self, p, cycle):
|
| 27 |
+
if cycle:
|
| 28 |
+
p.text("MyList(...)")
|
| 29 |
+
else:
|
| 30 |
+
with p.group(3, "MyList(", ")"):
|
| 31 |
+
for (i, child) in enumerate(self.content):
|
| 32 |
+
if i:
|
| 33 |
+
p.text(",")
|
| 34 |
+
p.breakable()
|
| 35 |
+
else:
|
| 36 |
+
p.breakable("")
|
| 37 |
+
p.pretty(child)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class MyDict(dict):
|
| 41 |
+
def _repr_pretty_(self, p, cycle):
|
| 42 |
+
p.text("MyDict(...)")
|
| 43 |
+
|
| 44 |
+
class MyObj(object):
|
| 45 |
+
def somemethod(self):
|
| 46 |
+
pass
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class Dummy1(object):
|
| 50 |
+
def _repr_pretty_(self, p, cycle):
|
| 51 |
+
p.text("Dummy1(...)")
|
| 52 |
+
|
| 53 |
+
class Dummy2(Dummy1):
|
| 54 |
+
_repr_pretty_ = None
|
| 55 |
+
|
| 56 |
+
class NoModule(object):
|
| 57 |
+
pass
|
| 58 |
+
|
| 59 |
+
NoModule.__module__ = None
|
| 60 |
+
|
| 61 |
+
class Breaking(object):
|
| 62 |
+
def _repr_pretty_(self, p, cycle):
|
| 63 |
+
with p.group(4,"TG: ",":"):
|
| 64 |
+
p.text("Breaking(")
|
| 65 |
+
p.break_()
|
| 66 |
+
p.text(")")
|
| 67 |
+
|
| 68 |
+
class BreakingRepr(object):
|
| 69 |
+
def __repr__(self):
|
| 70 |
+
return "Breaking(\n)"
|
| 71 |
+
|
| 72 |
+
class BadRepr(object):
|
| 73 |
+
def __repr__(self):
|
| 74 |
+
return 1/0
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def test_indentation():
|
| 78 |
+
"""Test correct indentation in groups"""
|
| 79 |
+
count = 40
|
| 80 |
+
gotoutput = pretty.pretty(MyList(range(count)))
|
| 81 |
+
expectedoutput = "MyList(\n" + ",\n".join(" %d" % i for i in range(count)) + ")"
|
| 82 |
+
|
| 83 |
+
assert gotoutput == expectedoutput
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def test_dispatch():
|
| 87 |
+
"""
|
| 88 |
+
Test correct dispatching: The _repr_pretty_ method for MyDict
|
| 89 |
+
must be found before the registered printer for dict.
|
| 90 |
+
"""
|
| 91 |
+
gotoutput = pretty.pretty(MyDict())
|
| 92 |
+
expectedoutput = "MyDict(...)"
|
| 93 |
+
|
| 94 |
+
assert gotoutput == expectedoutput
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def test_callability_checking():
|
| 98 |
+
"""
|
| 99 |
+
Test that the _repr_pretty_ method is tested for callability and skipped if
|
| 100 |
+
not.
|
| 101 |
+
"""
|
| 102 |
+
gotoutput = pretty.pretty(Dummy2())
|
| 103 |
+
expectedoutput = "Dummy1(...)"
|
| 104 |
+
|
| 105 |
+
assert gotoutput == expectedoutput
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
@pytest.mark.parametrize(
|
| 109 |
+
"obj,expected_output",
|
| 110 |
+
zip(
|
| 111 |
+
[
|
| 112 |
+
set(),
|
| 113 |
+
frozenset(),
|
| 114 |
+
set([1]),
|
| 115 |
+
frozenset([1]),
|
| 116 |
+
set([1, 2]),
|
| 117 |
+
frozenset([1, 2]),
|
| 118 |
+
set([-1, -2, -3]),
|
| 119 |
+
],
|
| 120 |
+
[
|
| 121 |
+
"set()",
|
| 122 |
+
"frozenset()",
|
| 123 |
+
"{1}",
|
| 124 |
+
"frozenset({1})",
|
| 125 |
+
"{1, 2}",
|
| 126 |
+
"frozenset({1, 2})",
|
| 127 |
+
"{-3, -2, -1}",
|
| 128 |
+
],
|
| 129 |
+
),
|
| 130 |
+
)
|
| 131 |
+
def test_sets(obj, expected_output):
|
| 132 |
+
"""
|
| 133 |
+
Test that set and frozenset use Python 3 formatting.
|
| 134 |
+
"""
|
| 135 |
+
got_output = pretty.pretty(obj)
|
| 136 |
+
assert got_output == expected_output
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def test_pprint_heap_allocated_type():
|
| 140 |
+
"""
|
| 141 |
+
Test that pprint works for heap allocated types.
|
| 142 |
+
"""
|
| 143 |
+
module_name = "xxlimited_35"
|
| 144 |
+
expected_output = (
|
| 145 |
+
"xxlimited.Null" if sys.version_info < (3, 10, 6) else "xxlimited_35.Null"
|
| 146 |
+
)
|
| 147 |
+
xxlimited = pytest.importorskip(module_name)
|
| 148 |
+
output = pretty.pretty(xxlimited.Null)
|
| 149 |
+
assert output == expected_output
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def test_pprint_nomod():
|
| 153 |
+
"""
|
| 154 |
+
Test that pprint works for classes with no __module__.
|
| 155 |
+
"""
|
| 156 |
+
output = pretty.pretty(NoModule)
|
| 157 |
+
assert output == "NoModule"
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def test_pprint_break():
|
| 161 |
+
"""
|
| 162 |
+
Test that p.break_ produces expected output
|
| 163 |
+
"""
|
| 164 |
+
output = pretty.pretty(Breaking())
|
| 165 |
+
expected = "TG: Breaking(\n ):"
|
| 166 |
+
assert output == expected
|
| 167 |
+
|
| 168 |
+
def test_pprint_break_repr():
|
| 169 |
+
"""
|
| 170 |
+
Test that p.break_ is used in repr
|
| 171 |
+
"""
|
| 172 |
+
output = pretty.pretty([[BreakingRepr()]])
|
| 173 |
+
expected = "[[Breaking(\n )]]"
|
| 174 |
+
assert output == expected
|
| 175 |
+
|
| 176 |
+
output = pretty.pretty([[BreakingRepr()]*2])
|
| 177 |
+
expected = "[[Breaking(\n ),\n Breaking(\n )]]"
|
| 178 |
+
assert output == expected
|
| 179 |
+
|
| 180 |
+
def test_bad_repr():
|
| 181 |
+
"""Don't catch bad repr errors"""
|
| 182 |
+
with pytest.raises(ZeroDivisionError):
|
| 183 |
+
pretty.pretty(BadRepr())
|
| 184 |
+
|
| 185 |
+
class BadException(Exception):
|
| 186 |
+
def __str__(self):
|
| 187 |
+
return -1
|
| 188 |
+
|
| 189 |
+
class ReallyBadRepr(object):
|
| 190 |
+
__module__ = 1
|
| 191 |
+
@property
|
| 192 |
+
def __class__(self):
|
| 193 |
+
raise ValueError("I am horrible")
|
| 194 |
+
|
| 195 |
+
def __repr__(self):
|
| 196 |
+
raise BadException()
|
| 197 |
+
|
| 198 |
+
def test_really_bad_repr():
|
| 199 |
+
with pytest.raises(BadException):
|
| 200 |
+
pretty.pretty(ReallyBadRepr())
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
class SA(object):
|
| 204 |
+
pass
|
| 205 |
+
|
| 206 |
+
class SB(SA):
|
| 207 |
+
pass
|
| 208 |
+
|
| 209 |
+
class TestsPretty(unittest.TestCase):
|
| 210 |
+
|
| 211 |
+
def test_super_repr(self):
|
| 212 |
+
# "<super: module_name.SA, None>"
|
| 213 |
+
output = pretty.pretty(super(SA))
|
| 214 |
+
self.assertRegex(output, r"<super: \S+.SA, None>")
|
| 215 |
+
|
| 216 |
+
# "<super: module_name.SA, <module_name.SB at 0x...>>"
|
| 217 |
+
sb = SB()
|
| 218 |
+
output = pretty.pretty(super(SA, sb))
|
| 219 |
+
self.assertRegex(output, r"<super: \S+.SA,\s+<\S+.SB at 0x\S+>>")
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
def test_long_list(self):
|
| 223 |
+
lis = list(range(10000))
|
| 224 |
+
p = pretty.pretty(lis)
|
| 225 |
+
last2 = p.rsplit('\n', 2)[-2:]
|
| 226 |
+
self.assertEqual(last2, [' 999,', ' ...]'])
|
| 227 |
+
|
| 228 |
+
def test_long_set(self):
|
| 229 |
+
s = set(range(10000))
|
| 230 |
+
p = pretty.pretty(s)
|
| 231 |
+
last2 = p.rsplit('\n', 2)[-2:]
|
| 232 |
+
self.assertEqual(last2, [' 999,', ' ...}'])
|
| 233 |
+
|
| 234 |
+
def test_long_tuple(self):
|
| 235 |
+
tup = tuple(range(10000))
|
| 236 |
+
p = pretty.pretty(tup)
|
| 237 |
+
last2 = p.rsplit('\n', 2)[-2:]
|
| 238 |
+
self.assertEqual(last2, [' 999,', ' ...)'])
|
| 239 |
+
|
| 240 |
+
def test_long_dict(self):
|
| 241 |
+
d = { n:n for n in range(10000) }
|
| 242 |
+
p = pretty.pretty(d)
|
| 243 |
+
last2 = p.rsplit('\n', 2)[-2:]
|
| 244 |
+
self.assertEqual(last2, [' 999: 999,', ' ...}'])
|
| 245 |
+
|
| 246 |
+
def test_unbound_method(self):
|
| 247 |
+
output = pretty.pretty(MyObj.somemethod)
|
| 248 |
+
self.assertIn('MyObj.somemethod', output)
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
class MetaClass(type):
|
| 252 |
+
def __new__(cls, name):
|
| 253 |
+
return type.__new__(cls, name, (object,), {'name': name})
|
| 254 |
+
|
| 255 |
+
def __repr__(self):
|
| 256 |
+
return "[CUSTOM REPR FOR CLASS %s]" % self.name
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
ClassWithMeta = MetaClass('ClassWithMeta')
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def test_metaclass_repr():
|
| 263 |
+
output = pretty.pretty(ClassWithMeta)
|
| 264 |
+
assert output == "[CUSTOM REPR FOR CLASS ClassWithMeta]"
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def test_unicode_repr():
|
| 268 |
+
u = u"üniçodé"
|
| 269 |
+
ustr = u
|
| 270 |
+
|
| 271 |
+
class C(object):
|
| 272 |
+
def __repr__(self):
|
| 273 |
+
return ustr
|
| 274 |
+
|
| 275 |
+
c = C()
|
| 276 |
+
p = pretty.pretty(c)
|
| 277 |
+
assert p == u
|
| 278 |
+
p = pretty.pretty([c])
|
| 279 |
+
assert p == "[%s]" % u
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
def test_basic_class():
|
| 283 |
+
def type_pprint_wrapper(obj, p, cycle):
|
| 284 |
+
if obj is MyObj:
|
| 285 |
+
type_pprint_wrapper.called = True
|
| 286 |
+
return pretty._type_pprint(obj, p, cycle)
|
| 287 |
+
type_pprint_wrapper.called = False
|
| 288 |
+
|
| 289 |
+
stream = StringIO()
|
| 290 |
+
printer = pretty.RepresentationPrinter(stream)
|
| 291 |
+
printer.type_pprinters[type] = type_pprint_wrapper
|
| 292 |
+
printer.pretty(MyObj)
|
| 293 |
+
printer.flush()
|
| 294 |
+
output = stream.getvalue()
|
| 295 |
+
|
| 296 |
+
assert output == "%s.MyObj" % __name__
|
| 297 |
+
assert type_pprint_wrapper.called is True
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def test_collections_userlist():
|
| 301 |
+
# Create userlist with cycle
|
| 302 |
+
a = UserList()
|
| 303 |
+
a.append(a)
|
| 304 |
+
|
| 305 |
+
cases = [
|
| 306 |
+
(UserList(), "UserList([])"),
|
| 307 |
+
(
|
| 308 |
+
UserList(i for i in range(1000, 1020)),
|
| 309 |
+
"UserList([1000,\n"
|
| 310 |
+
" 1001,\n"
|
| 311 |
+
" 1002,\n"
|
| 312 |
+
" 1003,\n"
|
| 313 |
+
" 1004,\n"
|
| 314 |
+
" 1005,\n"
|
| 315 |
+
" 1006,\n"
|
| 316 |
+
" 1007,\n"
|
| 317 |
+
" 1008,\n"
|
| 318 |
+
" 1009,\n"
|
| 319 |
+
" 1010,\n"
|
| 320 |
+
" 1011,\n"
|
| 321 |
+
" 1012,\n"
|
| 322 |
+
" 1013,\n"
|
| 323 |
+
" 1014,\n"
|
| 324 |
+
" 1015,\n"
|
| 325 |
+
" 1016,\n"
|
| 326 |
+
" 1017,\n"
|
| 327 |
+
" 1018,\n"
|
| 328 |
+
" 1019])",
|
| 329 |
+
),
|
| 330 |
+
(a, "UserList([UserList(...)])"),
|
| 331 |
+
]
|
| 332 |
+
for obj, expected in cases:
|
| 333 |
+
assert pretty.pretty(obj) == expected
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
# TODO : pytest.mark.parametrise once nose is gone.
|
| 337 |
+
def test_collections_defaultdict():
|
| 338 |
+
# Create defaultdicts with cycles
|
| 339 |
+
a = defaultdict()
|
| 340 |
+
a.default_factory = a
|
| 341 |
+
b = defaultdict(list)
|
| 342 |
+
b['key'] = b
|
| 343 |
+
|
| 344 |
+
# Dictionary order cannot be relied on, test against single keys.
|
| 345 |
+
cases = [
|
| 346 |
+
(defaultdict(list), 'defaultdict(list, {})'),
|
| 347 |
+
(defaultdict(list, {'key': '-' * 50}),
|
| 348 |
+
"defaultdict(list,\n"
|
| 349 |
+
" {'key': '--------------------------------------------------'})"),
|
| 350 |
+
(a, 'defaultdict(defaultdict(...), {})'),
|
| 351 |
+
(b, "defaultdict(list, {'key': defaultdict(...)})"),
|
| 352 |
+
]
|
| 353 |
+
for obj, expected in cases:
|
| 354 |
+
assert pretty.pretty(obj) == expected
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
# TODO : pytest.mark.parametrise once nose is gone.
|
| 358 |
+
def test_collections_ordereddict():
|
| 359 |
+
# Create OrderedDict with cycle
|
| 360 |
+
a = OrderedDict()
|
| 361 |
+
a['key'] = a
|
| 362 |
+
|
| 363 |
+
cases = [
|
| 364 |
+
(OrderedDict(), 'OrderedDict()'),
|
| 365 |
+
(OrderedDict((i, i) for i in range(1000, 1010)),
|
| 366 |
+
'OrderedDict([(1000, 1000),\n'
|
| 367 |
+
' (1001, 1001),\n'
|
| 368 |
+
' (1002, 1002),\n'
|
| 369 |
+
' (1003, 1003),\n'
|
| 370 |
+
' (1004, 1004),\n'
|
| 371 |
+
' (1005, 1005),\n'
|
| 372 |
+
' (1006, 1006),\n'
|
| 373 |
+
' (1007, 1007),\n'
|
| 374 |
+
' (1008, 1008),\n'
|
| 375 |
+
' (1009, 1009)])'),
|
| 376 |
+
(a, "OrderedDict([('key', OrderedDict(...))])"),
|
| 377 |
+
]
|
| 378 |
+
for obj, expected in cases:
|
| 379 |
+
assert pretty.pretty(obj) == expected
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
# TODO : pytest.mark.parametrise once nose is gone.
|
| 383 |
+
def test_collections_deque():
|
| 384 |
+
# Create deque with cycle
|
| 385 |
+
a = deque()
|
| 386 |
+
a.append(a)
|
| 387 |
+
|
| 388 |
+
cases = [
|
| 389 |
+
(deque(), 'deque([])'),
|
| 390 |
+
(deque(i for i in range(1000, 1020)),
|
| 391 |
+
'deque([1000,\n'
|
| 392 |
+
' 1001,\n'
|
| 393 |
+
' 1002,\n'
|
| 394 |
+
' 1003,\n'
|
| 395 |
+
' 1004,\n'
|
| 396 |
+
' 1005,\n'
|
| 397 |
+
' 1006,\n'
|
| 398 |
+
' 1007,\n'
|
| 399 |
+
' 1008,\n'
|
| 400 |
+
' 1009,\n'
|
| 401 |
+
' 1010,\n'
|
| 402 |
+
' 1011,\n'
|
| 403 |
+
' 1012,\n'
|
| 404 |
+
' 1013,\n'
|
| 405 |
+
' 1014,\n'
|
| 406 |
+
' 1015,\n'
|
| 407 |
+
' 1016,\n'
|
| 408 |
+
' 1017,\n'
|
| 409 |
+
' 1018,\n'
|
| 410 |
+
' 1019])'),
|
| 411 |
+
(a, 'deque([deque(...)])'),
|
| 412 |
+
]
|
| 413 |
+
for obj, expected in cases:
|
| 414 |
+
assert pretty.pretty(obj) == expected
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
# TODO : pytest.mark.parametrise once nose is gone.
|
| 418 |
+
def test_collections_counter():
|
| 419 |
+
class MyCounter(Counter):
|
| 420 |
+
pass
|
| 421 |
+
cases = [
|
| 422 |
+
(Counter(), 'Counter()'),
|
| 423 |
+
(Counter(a=1), "Counter({'a': 1})"),
|
| 424 |
+
(MyCounter(a=1), "MyCounter({'a': 1})"),
|
| 425 |
+
(Counter(a=1, c=22), "Counter({'c': 22, 'a': 1})"),
|
| 426 |
+
]
|
| 427 |
+
for obj, expected in cases:
|
| 428 |
+
assert pretty.pretty(obj) == expected
|
| 429 |
+
|
| 430 |
+
# TODO : pytest.mark.parametrise once nose is gone.
|
| 431 |
+
def test_mappingproxy():
|
| 432 |
+
MP = types.MappingProxyType
|
| 433 |
+
underlying_dict = {}
|
| 434 |
+
mp_recursive = MP(underlying_dict)
|
| 435 |
+
underlying_dict[2] = mp_recursive
|
| 436 |
+
underlying_dict[3] = underlying_dict
|
| 437 |
+
|
| 438 |
+
cases = [
|
| 439 |
+
(MP({}), "mappingproxy({})"),
|
| 440 |
+
(MP({None: MP({})}), "mappingproxy({None: mappingproxy({})})"),
|
| 441 |
+
(MP({k: k.upper() for k in string.ascii_lowercase}),
|
| 442 |
+
"mappingproxy({'a': 'A',\n"
|
| 443 |
+
" 'b': 'B',\n"
|
| 444 |
+
" 'c': 'C',\n"
|
| 445 |
+
" 'd': 'D',\n"
|
| 446 |
+
" 'e': 'E',\n"
|
| 447 |
+
" 'f': 'F',\n"
|
| 448 |
+
" 'g': 'G',\n"
|
| 449 |
+
" 'h': 'H',\n"
|
| 450 |
+
" 'i': 'I',\n"
|
| 451 |
+
" 'j': 'J',\n"
|
| 452 |
+
" 'k': 'K',\n"
|
| 453 |
+
" 'l': 'L',\n"
|
| 454 |
+
" 'm': 'M',\n"
|
| 455 |
+
" 'n': 'N',\n"
|
| 456 |
+
" 'o': 'O',\n"
|
| 457 |
+
" 'p': 'P',\n"
|
| 458 |
+
" 'q': 'Q',\n"
|
| 459 |
+
" 'r': 'R',\n"
|
| 460 |
+
" 's': 'S',\n"
|
| 461 |
+
" 't': 'T',\n"
|
| 462 |
+
" 'u': 'U',\n"
|
| 463 |
+
" 'v': 'V',\n"
|
| 464 |
+
" 'w': 'W',\n"
|
| 465 |
+
" 'x': 'X',\n"
|
| 466 |
+
" 'y': 'Y',\n"
|
| 467 |
+
" 'z': 'Z'})"),
|
| 468 |
+
(mp_recursive, "mappingproxy({2: {...}, 3: {2: {...}, 3: {...}}})"),
|
| 469 |
+
(underlying_dict,
|
| 470 |
+
"{2: mappingproxy({2: {...}, 3: {...}}), 3: {...}}"),
|
| 471 |
+
]
|
| 472 |
+
for obj, expected in cases:
|
| 473 |
+
assert pretty.pretty(obj) == expected
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
# TODO : pytest.mark.parametrise once nose is gone.
|
| 477 |
+
def test_simplenamespace():
|
| 478 |
+
SN = types.SimpleNamespace
|
| 479 |
+
|
| 480 |
+
sn_recursive = SN()
|
| 481 |
+
sn_recursive.first = sn_recursive
|
| 482 |
+
sn_recursive.second = sn_recursive
|
| 483 |
+
cases = [
|
| 484 |
+
(SN(), "namespace()"),
|
| 485 |
+
(SN(x=SN()), "namespace(x=namespace())"),
|
| 486 |
+
(SN(a_long_name=[SN(s=string.ascii_lowercase)]*3, a_short_name=None),
|
| 487 |
+
"namespace(a_long_name=[namespace(s='abcdefghijklmnopqrstuvwxyz'),\n"
|
| 488 |
+
" namespace(s='abcdefghijklmnopqrstuvwxyz'),\n"
|
| 489 |
+
" namespace(s='abcdefghijklmnopqrstuvwxyz')],\n"
|
| 490 |
+
" a_short_name=None)"),
|
| 491 |
+
(sn_recursive, "namespace(first=namespace(...), second=namespace(...))"),
|
| 492 |
+
]
|
| 493 |
+
for obj, expected in cases:
|
| 494 |
+
assert pretty.pretty(obj) == expected
|
| 495 |
+
|
| 496 |
+
|
| 497 |
+
def test_pretty_environ():
|
| 498 |
+
dict_repr = pretty.pretty(dict(os.environ))
|
| 499 |
+
# reindent to align with 'environ' prefix
|
| 500 |
+
dict_indented = dict_repr.replace('\n', '\n' + (' ' * len('environ')))
|
| 501 |
+
env_repr = pretty.pretty(os.environ)
|
| 502 |
+
assert env_repr == "environ" + dict_indented
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
def test_function_pretty():
|
| 506 |
+
"Test pretty print of function"
|
| 507 |
+
# posixpath is a pure python module, its interface is consistent
|
| 508 |
+
# across Python distributions
|
| 509 |
+
import posixpath
|
| 510 |
+
|
| 511 |
+
assert pretty.pretty(posixpath.join) == "<function posixpath.join(a, *p)>"
|
| 512 |
+
|
| 513 |
+
# custom function
|
| 514 |
+
def meaning_of_life(question=None):
|
| 515 |
+
if question:
|
| 516 |
+
return 42
|
| 517 |
+
return "Don't panic"
|
| 518 |
+
|
| 519 |
+
assert "meaning_of_life(question=None)" in pretty.pretty(meaning_of_life)
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
class OrderedCounter(Counter, OrderedDict):
|
| 523 |
+
'Counter that remembers the order elements are first encountered'
|
| 524 |
+
|
| 525 |
+
def __repr__(self):
|
| 526 |
+
return '%s(%r)' % (self.__class__.__name__, OrderedDict(self))
|
| 527 |
+
|
| 528 |
+
def __reduce__(self):
|
| 529 |
+
return self.__class__, (OrderedDict(self),)
|
| 530 |
+
|
| 531 |
+
class MySet(set): # Override repr of a basic type
|
| 532 |
+
def __repr__(self):
|
| 533 |
+
return 'mine'
|
| 534 |
+
|
| 535 |
+
def test_custom_repr():
|
| 536 |
+
"""A custom repr should override a pretty printer for a parent type"""
|
| 537 |
+
oc = OrderedCounter("abracadabra")
|
| 538 |
+
assert "OrderedCounter(OrderedDict" in pretty.pretty(oc)
|
| 539 |
+
|
| 540 |
+
assert pretty.pretty(MySet()) == "mine"
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/IPython/lib/tests/test_pygments.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
import pygments.lexers
|
| 5 |
+
import pygments.lexer
|
| 6 |
+
|
| 7 |
+
from IPython.lib.lexers import IPythonConsoleLexer, IPythonLexer, IPython3Lexer
|
| 8 |
+
|
| 9 |
+
#: the human-readable names of the IPython lexers with ``entry_points``
|
| 10 |
+
EXPECTED_LEXER_NAMES = [
|
| 11 |
+
cls.name for cls in [IPythonConsoleLexer, IPythonLexer, IPython3Lexer]
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@pytest.fixture
|
| 16 |
+
def all_pygments_lexer_names() -> List[str]:
|
| 17 |
+
"""Get all lexer names registered in pygments."""
|
| 18 |
+
return {l[0] for l in pygments.lexers.get_all_lexers()}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@pytest.mark.parametrize("expected_lexer", EXPECTED_LEXER_NAMES)
|
| 22 |
+
def test_pygments_entry_points(
|
| 23 |
+
expected_lexer: str, all_pygments_lexer_names: List[str]
|
| 24 |
+
) -> None:
|
| 25 |
+
"""Check whether the ``entry_points`` for ``pygments.lexers`` are correct."""
|
| 26 |
+
assert expected_lexer in all_pygments_lexer_names
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.12 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/converters.cpython-310.pyc
ADDED
|
Binary file (262 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/exceptions.cpython-310.pyc
ADDED
|
Binary file (262 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/filters.cpython-310.pyc
ADDED
|
Binary file (256 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/setters.cpython-310.pyc
ADDED
|
Binary file (256 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/__pycache__/validators.cpython-310.pyc
ADDED
|
Binary file (262 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/attrs/setters.py
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SPDX-License-Identifier: MIT
|
| 2 |
+
|
| 3 |
+
from attr.setters import * # noqa: F403
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/LICENSE
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
| 2 |
+
--------------------------------------------
|
| 3 |
+
|
| 4 |
+
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
| 5 |
+
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
| 6 |
+
otherwise using this software ("Python") in source or binary form and
|
| 7 |
+
its associated documentation.
|
| 8 |
+
|
| 9 |
+
2. Subject to the terms and conditions of this License Agreement, PSF
|
| 10 |
+
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
| 11 |
+
license to reproduce, analyze, test, perform and/or display publicly,
|
| 12 |
+
prepare derivative works, distribute, and otherwise use Python
|
| 13 |
+
alone or in any derivative version, provided, however, that PSF's
|
| 14 |
+
License Agreement and PSF's notice of copyright, i.e., "Copyright (c)
|
| 15 |
+
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Python Software Foundation;
|
| 16 |
+
All Rights Reserved" are retained in Python alone or in any derivative
|
| 17 |
+
version prepared by Licensee.
|
| 18 |
+
|
| 19 |
+
3. In the event Licensee prepares a derivative work that is based on
|
| 20 |
+
or incorporates Python or any part thereof, and wants to make
|
| 21 |
+
the derivative work available to others as provided herein, then
|
| 22 |
+
Licensee hereby agrees to include in any such work a brief summary of
|
| 23 |
+
the changes made to Python.
|
| 24 |
+
|
| 25 |
+
4. PSF is making Python available to Licensee on an "AS IS"
|
| 26 |
+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
| 27 |
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
| 28 |
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
| 29 |
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
| 30 |
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
| 31 |
+
|
| 32 |
+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
| 33 |
+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
| 34 |
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
| 35 |
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
| 36 |
+
|
| 37 |
+
6. This License Agreement will automatically terminate upon a material
|
| 38 |
+
breach of its terms and conditions.
|
| 39 |
+
|
| 40 |
+
7. Nothing in this License Agreement shall be deemed to create any
|
| 41 |
+
relationship of agency, partnership, or joint venture between PSF and
|
| 42 |
+
Licensee. This License Agreement does not grant permission to use PSF
|
| 43 |
+
trademarks or trade name in a trademark sense to endorse or promote
|
| 44 |
+
products or services of Licensee, or any third party.
|
| 45 |
+
|
| 46 |
+
8. By copying, installing or otherwise using Python, Licensee
|
| 47 |
+
agrees to be bound by the terms and conditions of this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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: defusedxml
|
| 3 |
+
Version: 0.7.1
|
| 4 |
+
Summary: XML bomb protection for Python stdlib modules
|
| 5 |
+
Home-page: https://github.com/tiran/defusedxml
|
| 6 |
+
Author: Christian Heimes
|
| 7 |
+
Author-email: christian@python.org
|
| 8 |
+
Maintainer: Christian Heimes
|
| 9 |
+
Maintainer-email: christian@python.org
|
| 10 |
+
License: PSFL
|
| 11 |
+
Download-URL: https://pypi.python.org/pypi/defusedxml
|
| 12 |
+
Keywords: xml bomb DoS
|
| 13 |
+
Platform: all
|
| 14 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 15 |
+
Classifier: Intended Audience :: Developers
|
| 16 |
+
Classifier: License :: OSI Approved :: Python Software Foundation License
|
| 17 |
+
Classifier: Natural Language :: English
|
| 18 |
+
Classifier: Programming Language :: Python
|
| 19 |
+
Classifier: Programming Language :: Python :: 2
|
| 20 |
+
Classifier: Programming Language :: Python :: 2.7
|
| 21 |
+
Classifier: Programming Language :: Python :: 3
|
| 22 |
+
Classifier: Programming Language :: Python :: 3.5
|
| 23 |
+
Classifier: Programming Language :: Python :: 3.6
|
| 24 |
+
Classifier: Programming Language :: Python :: 3.7
|
| 25 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 26 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 27 |
+
Classifier: Topic :: Text Processing :: Markup :: XML
|
| 28 |
+
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
|
| 29 |
+
|
| 30 |
+
===================================================
|
| 31 |
+
defusedxml -- defusing XML bombs and other exploits
|
| 32 |
+
===================================================
|
| 33 |
+
|
| 34 |
+
.. image:: https://img.shields.io/pypi/v/defusedxml.svg
|
| 35 |
+
:target: https://pypi.org/project/defusedxml/
|
| 36 |
+
:alt: Latest Version
|
| 37 |
+
|
| 38 |
+
.. image:: https://img.shields.io/pypi/pyversions/defusedxml.svg
|
| 39 |
+
:target: https://pypi.org/project/defusedxml/
|
| 40 |
+
:alt: Supported Python versions
|
| 41 |
+
|
| 42 |
+
.. image:: https://travis-ci.org/tiran/defusedxml.svg?branch=master
|
| 43 |
+
:target: https://travis-ci.org/tiran/defusedxml
|
| 44 |
+
:alt: Travis CI
|
| 45 |
+
|
| 46 |
+
.. image:: https://codecov.io/github/tiran/defusedxml/coverage.svg?branch=master
|
| 47 |
+
:target: https://codecov.io/github/tiran/defusedxml?branch=master
|
| 48 |
+
:alt: codecov
|
| 49 |
+
|
| 50 |
+
.. image:: https://img.shields.io/pypi/dm/defusedxml.svg
|
| 51 |
+
:target: https://pypistats.org/packages/defusedxml
|
| 52 |
+
:alt: PyPI downloads
|
| 53 |
+
|
| 54 |
+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
| 55 |
+
:target: https://github.com/psf/black
|
| 56 |
+
:alt: Code style: black
|
| 57 |
+
|
| 58 |
+
..
|
| 59 |
+
|
| 60 |
+
"It's just XML, what could probably go wrong?"
|
| 61 |
+
|
| 62 |
+
Christian Heimes <christian@python.org>
|
| 63 |
+
|
| 64 |
+
Synopsis
|
| 65 |
+
========
|
| 66 |
+
|
| 67 |
+
The results of an attack on a vulnerable XML library can be fairly dramatic.
|
| 68 |
+
With just a few hundred **Bytes** of XML data an attacker can occupy several
|
| 69 |
+
**Gigabytes** of memory within **seconds**. An attacker can also keep
|
| 70 |
+
CPUs busy for a long time with a small to medium size request. Under some
|
| 71 |
+
circumstances it is even possible to access local files on your
|
| 72 |
+
server, to circumvent a firewall, or to abuse services to rebound attacks to
|
| 73 |
+
third parties.
|
| 74 |
+
|
| 75 |
+
The attacks use and abuse less common features of XML and its parsers. The
|
| 76 |
+
majority of developers are unacquainted with features such as processing
|
| 77 |
+
instructions and entity expansions that XML inherited from SGML. At best
|
| 78 |
+
they know about ``<!DOCTYPE>`` from experience with HTML but they are not
|
| 79 |
+
aware that a document type definition (DTD) can generate an HTTP request
|
| 80 |
+
or load a file from the file system.
|
| 81 |
+
|
| 82 |
+
None of the issues is new. They have been known for a long time. Billion
|
| 83 |
+
laughs was first reported in 2003. Nevertheless some XML libraries and
|
| 84 |
+
applications are still vulnerable and even heavy users of XML are
|
| 85 |
+
surprised by these features. It's hard to say whom to blame for the
|
| 86 |
+
situation. It's too short sighted to shift all blame on XML parsers and
|
| 87 |
+
XML libraries for using insecure default settings. After all they
|
| 88 |
+
properly implement XML specifications. Application developers must not rely
|
| 89 |
+
that a library is always configured for security and potential harmful data
|
| 90 |
+
by default.
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
.. contents:: Table of Contents
|
| 94 |
+
:depth: 2
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
Attack vectors
|
| 98 |
+
==============
|
| 99 |
+
|
| 100 |
+
billion laughs / exponential entity expansion
|
| 101 |
+
---------------------------------------------
|
| 102 |
+
|
| 103 |
+
The `Billion Laughs`_ attack -- also known as exponential entity expansion --
|
| 104 |
+
uses multiple levels of nested entities. The original example uses 9 levels
|
| 105 |
+
of 10 expansions in each level to expand the string ``lol`` to a string of
|
| 106 |
+
3 * 10 :sup:`9` bytes, hence the name "billion laughs". The resulting string
|
| 107 |
+
occupies 3 GB (2.79 GiB) of memory; intermediate strings require additional
|
| 108 |
+
memory. Because most parsers don't cache the intermediate step for every
|
| 109 |
+
expansion it is repeated over and over again. It increases the CPU load even
|
| 110 |
+
more.
|
| 111 |
+
|
| 112 |
+
An XML document of just a few hundred bytes can disrupt all services on a
|
| 113 |
+
machine within seconds.
|
| 114 |
+
|
| 115 |
+
Example XML::
|
| 116 |
+
|
| 117 |
+
<!DOCTYPE xmlbomb [
|
| 118 |
+
<!ENTITY a "1234567890" >
|
| 119 |
+
<!ENTITY b "&a;&a;&a;&a;&a;&a;&a;&a;">
|
| 120 |
+
<!ENTITY c "&b;&b;&b;&b;&b;&b;&b;&b;">
|
| 121 |
+
<!ENTITY d "&c;&c;&c;&c;&c;&c;&c;&c;">
|
| 122 |
+
]>
|
| 123 |
+
<bomb>&d;</bomb>
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
quadratic blowup entity expansion
|
| 127 |
+
---------------------------------
|
| 128 |
+
|
| 129 |
+
A quadratic blowup attack is similar to a `Billion Laughs`_ attack; it abuses
|
| 130 |
+
entity expansion, too. Instead of nested entities it repeats one large entity
|
| 131 |
+
with a couple of thousand chars over and over again. The attack isn't as
|
| 132 |
+
efficient as the exponential case but it avoids triggering countermeasures of
|
| 133 |
+
parsers against heavily nested entities. Some parsers limit the depth and
|
| 134 |
+
breadth of a single entity but not the total amount of expanded text
|
| 135 |
+
throughout an entire XML document.
|
| 136 |
+
|
| 137 |
+
A medium-sized XML document with a couple of hundred kilobytes can require a
|
| 138 |
+
couple of hundred MB to several GB of memory. When the attack is combined
|
| 139 |
+
with some level of nested expansion an attacker is able to achieve a higher
|
| 140 |
+
ratio of success.
|
| 141 |
+
|
| 142 |
+
::
|
| 143 |
+
|
| 144 |
+
<!DOCTYPE bomb [
|
| 145 |
+
<!ENTITY a "xxxxxxx... a couple of ten thousand chars">
|
| 146 |
+
]>
|
| 147 |
+
<bomb>&a;&a;&a;... repeat</bomb>
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
external entity expansion (remote)
|
| 151 |
+
----------------------------------
|
| 152 |
+
|
| 153 |
+
Entity declarations can contain more than just text for replacement. They can
|
| 154 |
+
also point to external resources by public identifiers or system identifiers.
|
| 155 |
+
System identifiers are standard URIs. When the URI is a URL (e.g. a
|
| 156 |
+
``http://`` locator) some parsers download the resource from the remote
|
| 157 |
+
location and embed them into the XML document verbatim.
|
| 158 |
+
|
| 159 |
+
Simple example of a parsed external entity::
|
| 160 |
+
|
| 161 |
+
<!DOCTYPE external [
|
| 162 |
+
<!ENTITY ee SYSTEM "http://www.python.org/some.xml">
|
| 163 |
+
]>
|
| 164 |
+
<root>ⅇ</root>
|
| 165 |
+
|
| 166 |
+
The case of parsed external entities works only for valid XML content. The
|
| 167 |
+
XML standard also supports unparsed external entities with a
|
| 168 |
+
``NData declaration``.
|
| 169 |
+
|
| 170 |
+
External entity expansion opens the door to plenty of exploits. An attacker
|
| 171 |
+
can abuse a vulnerable XML library and application to rebound and forward
|
| 172 |
+
network requests with the IP address of the server. It highly depends
|
| 173 |
+
on the parser and the application what kind of exploit is possible. For
|
| 174 |
+
example:
|
| 175 |
+
|
| 176 |
+
* An attacker can circumvent firewalls and gain access to restricted
|
| 177 |
+
resources as all the requests are made from an internal and trustworthy
|
| 178 |
+
IP address, not from the outside.
|
| 179 |
+
* An attacker can abuse a service to attack, spy on or DoS your servers but
|
| 180 |
+
also third party services. The attack is disguised with the IP address of
|
| 181 |
+
the server and the attacker is able to utilize the high bandwidth of a big
|
| 182 |
+
machine.
|
| 183 |
+
* An attacker can exhaust additional resources on the machine, e.g. with
|
| 184 |
+
requests to a service that doesn't respond or responds with very large
|
| 185 |
+
files.
|
| 186 |
+
* An attacker may gain knowledge, when, how often and from which IP address
|
| 187 |
+
an XML document is accessed.
|
| 188 |
+
* An attacker could send mail from inside your network if the URL handler
|
| 189 |
+
supports ``smtp://`` URIs.
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
external entity expansion (local file)
|
| 193 |
+
--------------------------------------
|
| 194 |
+
|
| 195 |
+
External entities with references to local files are a sub-case of external
|
| 196 |
+
entity expansion. It's listed as an extra attack because it deserves extra
|
| 197 |
+
attention. Some XML libraries such as lxml disable network access by default
|
| 198 |
+
but still allow entity expansion with local file access by default. Local
|
| 199 |
+
files are either referenced with a ``file://`` URL or by a file path (either
|
| 200 |
+
relative or absolute).
|
| 201 |
+
|
| 202 |
+
An attacker may be able to access and download all files that can be read by
|
| 203 |
+
the application process. This may include critical configuration files, too.
|
| 204 |
+
|
| 205 |
+
::
|
| 206 |
+
|
| 207 |
+
<!DOCTYPE external [
|
| 208 |
+
<!ENTITY ee SYSTEM "file:///PATH/TO/simple.xml">
|
| 209 |
+
]>
|
| 210 |
+
<root>ⅇ</root>
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
DTD retrieval
|
| 214 |
+
-------------
|
| 215 |
+
|
| 216 |
+
This case is similar to external entity expansion, too. Some XML libraries
|
| 217 |
+
like Python's xml.dom.pulldom retrieve document type definitions from remote
|
| 218 |
+
or local locations. Several attack scenarios from the external entity case
|
| 219 |
+
apply to this issue as well.
|
| 220 |
+
|
| 221 |
+
::
|
| 222 |
+
|
| 223 |
+
<?xml version="1.0" encoding="utf-8"?>
|
| 224 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
| 225 |
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
| 226 |
+
<html>
|
| 227 |
+
<head/>
|
| 228 |
+
<body>text</body>
|
| 229 |
+
</html>
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
Python XML Libraries
|
| 233 |
+
====================
|
| 234 |
+
|
| 235 |
+
.. csv-table:: vulnerabilities and features
|
| 236 |
+
:header: "kind", "sax", "etree", "minidom", "pulldom", "xmlrpc", "lxml", "genshi"
|
| 237 |
+
:widths: 24, 7, 8, 8, 7, 8, 8, 8
|
| 238 |
+
:stub-columns: 0
|
| 239 |
+
|
| 240 |
+
"billion laughs", "**True**", "**True**", "**True**", "**True**", "**True**", "False (1)", "False (5)"
|
| 241 |
+
"quadratic blowup", "**True**", "**True**", "**True**", "**True**", "**True**", "**True**", "False (5)"
|
| 242 |
+
"external entity expansion (remote)", "**True**", "False (3)", "False (4)", "**True**", "false", "False (1)", "False (5)"
|
| 243 |
+
"external entity expansion (local file)", "**True**", "False (3)", "False (4)", "**True**", "false", "**True**", "False (5)"
|
| 244 |
+
"DTD retrieval", "**True**", "False", "False", "**True**", "false", "False (1)", "False"
|
| 245 |
+
"gzip bomb", "False", "False", "False", "False", "**True**", "**partly** (2)", "False"
|
| 246 |
+
"xpath support (7)", "False", "False", "False", "False", "False", "**True**", "False"
|
| 247 |
+
"xsl(t) support (7)", "False", "False", "False", "False", "False", "**True**", "False"
|
| 248 |
+
"xinclude support (7)", "False", "**True** (6)", "False", "False", "False", "**True** (6)", "**True**"
|
| 249 |
+
"C library", "expat", "expat", "expat", "expat", "expat", "libxml2", "expat"
|
| 250 |
+
|
| 251 |
+
1. Lxml is protected against billion laughs attacks and doesn't do network
|
| 252 |
+
lookups by default.
|
| 253 |
+
2. libxml2 and lxml are not directly vulnerable to gzip decompression bombs
|
| 254 |
+
but they don't protect you against them either.
|
| 255 |
+
3. xml.etree doesn't expand entities and raises a ParserError when an entity
|
| 256 |
+
occurs.
|
| 257 |
+
4. minidom doesn't expand entities and simply returns the unexpanded entity
|
| 258 |
+
verbatim.
|
| 259 |
+
5. genshi.input of genshi 0.6 doesn't support entity expansion and raises a
|
| 260 |
+
ParserError when an entity occurs.
|
| 261 |
+
6. Library has (limited) XInclude support but requires an additional step to
|
| 262 |
+
process inclusion.
|
| 263 |
+
7. These are features but they may introduce exploitable holes, see
|
| 264 |
+
`Other things to consider`_
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
Settings in standard library
|
| 268 |
+
----------------------------
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
xml.sax.handler Features
|
| 272 |
+
........................
|
| 273 |
+
|
| 274 |
+
feature_external_ges (http://xml.org/sax/features/external-general-entities)
|
| 275 |
+
disables external entity expansion
|
| 276 |
+
|
| 277 |
+
feature_external_pes (http://xml.org/sax/features/external-parameter-entities)
|
| 278 |
+
the option is ignored and doesn't modify any functionality
|
| 279 |
+
|
| 280 |
+
DOM xml.dom.xmlbuilder.Options
|
| 281 |
+
..............................
|
| 282 |
+
|
| 283 |
+
external_parameter_entities
|
| 284 |
+
ignored
|
| 285 |
+
|
| 286 |
+
external_general_entities
|
| 287 |
+
ignored
|
| 288 |
+
|
| 289 |
+
external_dtd_subset
|
| 290 |
+
ignored
|
| 291 |
+
|
| 292 |
+
entities
|
| 293 |
+
unsure
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
defusedxml
|
| 297 |
+
==========
|
| 298 |
+
|
| 299 |
+
The `defusedxml package`_ (`defusedxml on PyPI`_)
|
| 300 |
+
contains several Python-only workarounds and fixes
|
| 301 |
+
for denial of service and other vulnerabilities in Python's XML libraries.
|
| 302 |
+
In order to benefit from the protection you just have to import and use the
|
| 303 |
+
listed functions / classes from the right defusedxml module instead of the
|
| 304 |
+
original module. Merely `defusedxml.xmlrpc`_ is implemented as monkey patch.
|
| 305 |
+
|
| 306 |
+
Instead of::
|
| 307 |
+
|
| 308 |
+
>>> from xml.etree.ElementTree import parse
|
| 309 |
+
>>> et = parse(xmlfile)
|
| 310 |
+
|
| 311 |
+
alter code to::
|
| 312 |
+
|
| 313 |
+
>>> from defusedxml.ElementTree import parse
|
| 314 |
+
>>> et = parse(xmlfile)
|
| 315 |
+
|
| 316 |
+
Additionally the package has an **untested** function to monkey patch
|
| 317 |
+
all stdlib modules with ``defusedxml.defuse_stdlib()``.
|
| 318 |
+
|
| 319 |
+
All functions and parser classes accept three additional keyword arguments.
|
| 320 |
+
They return either the same objects as the original functions or compatible
|
| 321 |
+
subclasses.
|
| 322 |
+
|
| 323 |
+
forbid_dtd (default: False)
|
| 324 |
+
disallow XML with a ``<!DOCTYPE>`` processing instruction and raise a
|
| 325 |
+
*DTDForbidden* exception when a DTD processing instruction is found.
|
| 326 |
+
|
| 327 |
+
forbid_entities (default: True)
|
| 328 |
+
disallow XML with ``<!ENTITY>`` declarations inside the DTD and raise an
|
| 329 |
+
*EntitiesForbidden* exception when an entity is declared.
|
| 330 |
+
|
| 331 |
+
forbid_external (default: True)
|
| 332 |
+
disallow any access to remote or local resources in external entities
|
| 333 |
+
or DTD and raising an *ExternalReferenceForbidden* exception when a DTD
|
| 334 |
+
or entity references an external resource.
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
defusedxml (package)
|
| 338 |
+
--------------------
|
| 339 |
+
|
| 340 |
+
DefusedXmlException, DTDForbidden, EntitiesForbidden,
|
| 341 |
+
ExternalReferenceForbidden, NotSupportedError
|
| 342 |
+
|
| 343 |
+
defuse_stdlib() (*experimental*)
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
defusedxml.cElementTree
|
| 347 |
+
-----------------------
|
| 348 |
+
|
| 349 |
+
**NOTE** ``defusedxml.cElementTree`` is deprecated and will be removed in a
|
| 350 |
+
future release. Import from ``defusedxml.ElementTree`` instead.
|
| 351 |
+
|
| 352 |
+
parse(), iterparse(), fromstring(), XMLParser
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
defusedxml.ElementTree
|
| 356 |
+
-----------------------
|
| 357 |
+
|
| 358 |
+
parse(), iterparse(), fromstring(), XMLParser
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
defusedxml.expatreader
|
| 362 |
+
----------------------
|
| 363 |
+
|
| 364 |
+
create_parser(), DefusedExpatParser
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
defusedxml.sax
|
| 368 |
+
--------------
|
| 369 |
+
|
| 370 |
+
parse(), parseString(), make_parser()
|
| 371 |
+
|
| 372 |
+
|
| 373 |
+
defusedxml.expatbuilder
|
| 374 |
+
-----------------------
|
| 375 |
+
|
| 376 |
+
parse(), parseString(), DefusedExpatBuilder, DefusedExpatBuilderNS
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
defusedxml.minidom
|
| 380 |
+
------------------
|
| 381 |
+
|
| 382 |
+
parse(), parseString()
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
defusedxml.pulldom
|
| 386 |
+
------------------
|
| 387 |
+
|
| 388 |
+
parse(), parseString()
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
defusedxml.xmlrpc
|
| 392 |
+
-----------------
|
| 393 |
+
|
| 394 |
+
The fix is implemented as monkey patch for the stdlib's xmlrpc package (3.x)
|
| 395 |
+
or xmlrpclib module (2.x). The function `monkey_patch()` enables the fixes,
|
| 396 |
+
`unmonkey_patch()` removes the patch and puts the code in its former state.
|
| 397 |
+
|
| 398 |
+
The monkey patch protects against XML related attacks as well as
|
| 399 |
+
decompression bombs and excessively large requests or responses. The default
|
| 400 |
+
setting is 30 MB for requests, responses and gzip decompression. You can
|
| 401 |
+
modify the default by changing the module variable `MAX_DATA`. A value of
|
| 402 |
+
`-1` disables the limit.
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
defusedxml.lxml
|
| 406 |
+
---------------
|
| 407 |
+
|
| 408 |
+
**DEPRECATED** The module is deprecated and will be removed in a future
|
| 409 |
+
release.
|
| 410 |
+
|
| 411 |
+
The module acts as an *example* how you could protect code that uses
|
| 412 |
+
lxml.etree. It implements a custom Element class that filters out
|
| 413 |
+
Entity instances, a custom parser factory and a thread local storage for
|
| 414 |
+
parser instances. It also has a check_docinfo() function which inspects
|
| 415 |
+
a tree for internal or external DTDs and entity declarations. In order to
|
| 416 |
+
check for entities lxml > 3.0 is required.
|
| 417 |
+
|
| 418 |
+
parse(), fromstring()
|
| 419 |
+
RestrictedElement, GlobalParserTLS, getDefaultParser(), check_docinfo()
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
defusedexpat
|
| 423 |
+
============
|
| 424 |
+
|
| 425 |
+
The `defusedexpat package`_ (`defusedexpat on PyPI`_)
|
| 426 |
+
comes with binary extensions and a
|
| 427 |
+
`modified expat`_ library instead of the standard `expat parser`_. It's
|
| 428 |
+
basically a stand-alone version of the patches for Python's standard
|
| 429 |
+
library C extensions.
|
| 430 |
+
|
| 431 |
+
Modifications in expat
|
| 432 |
+
----------------------
|
| 433 |
+
|
| 434 |
+
new definitions::
|
| 435 |
+
|
| 436 |
+
XML_BOMB_PROTECTION
|
| 437 |
+
XML_DEFAULT_MAX_ENTITY_INDIRECTIONS
|
| 438 |
+
XML_DEFAULT_MAX_ENTITY_EXPANSIONS
|
| 439 |
+
XML_DEFAULT_RESET_DTD
|
| 440 |
+
|
| 441 |
+
new XML_FeatureEnum members::
|
| 442 |
+
|
| 443 |
+
XML_FEATURE_MAX_ENTITY_INDIRECTIONS
|
| 444 |
+
XML_FEATURE_MAX_ENTITY_EXPANSIONS
|
| 445 |
+
XML_FEATURE_IGNORE_DTD
|
| 446 |
+
|
| 447 |
+
new XML_Error members::
|
| 448 |
+
|
| 449 |
+
XML_ERROR_ENTITY_INDIRECTIONS
|
| 450 |
+
XML_ERROR_ENTITY_EXPANSION
|
| 451 |
+
|
| 452 |
+
new API functions::
|
| 453 |
+
|
| 454 |
+
int XML_GetFeature(XML_Parser parser,
|
| 455 |
+
enum XML_FeatureEnum feature,
|
| 456 |
+
long *value);
|
| 457 |
+
int XML_SetFeature(XML_Parser parser,
|
| 458 |
+
enum XML_FeatureEnum feature,
|
| 459 |
+
long value);
|
| 460 |
+
int XML_GetFeatureDefault(enum XML_FeatureEnum feature,
|
| 461 |
+
long *value);
|
| 462 |
+
int XML_SetFeatureDefault(enum XML_FeatureEnum feature,
|
| 463 |
+
long value);
|
| 464 |
+
|
| 465 |
+
XML_FEATURE_MAX_ENTITY_INDIRECTIONS
|
| 466 |
+
Limit the amount of indirections that are allowed to occur during the
|
| 467 |
+
expansion of a nested entity. A counter starts when an entity reference
|
| 468 |
+
is encountered. It resets after the entity is fully expanded. The limit
|
| 469 |
+
protects the parser against exponential entity expansion attacks (aka
|
| 470 |
+
billion laughs attack). When the limit is exceeded the parser stops and
|
| 471 |
+
fails with `XML_ERROR_ENTITY_INDIRECTIONS`.
|
| 472 |
+
A value of 0 disables the protection.
|
| 473 |
+
|
| 474 |
+
Supported range
|
| 475 |
+
0 .. UINT_MAX
|
| 476 |
+
Default
|
| 477 |
+
40
|
| 478 |
+
|
| 479 |
+
XML_FEATURE_MAX_ENTITY_EXPANSIONS
|
| 480 |
+
Limit the total length of all entity expansions throughout the entire
|
| 481 |
+
document. The lengths of all entities are accumulated in a parser variable.
|
| 482 |
+
The setting protects against quadratic blowup attacks (lots of expansions
|
| 483 |
+
of a large entity declaration). When the sum of all entities exceeds
|
| 484 |
+
the limit, the parser stops and fails with `XML_ERROR_ENTITY_EXPANSION`.
|
| 485 |
+
A value of 0 disables the protection.
|
| 486 |
+
|
| 487 |
+
Supported range
|
| 488 |
+
0 .. UINT_MAX
|
| 489 |
+
Default
|
| 490 |
+
8 MiB
|
| 491 |
+
|
| 492 |
+
XML_FEATURE_RESET_DTD
|
| 493 |
+
Reset all DTD information after the <!DOCTYPE> block has been parsed. When
|
| 494 |
+
the flag is set (default: false) all DTD information after the
|
| 495 |
+
endDoctypeDeclHandler has been called. The flag can be set inside the
|
| 496 |
+
endDoctypeDeclHandler. Without DTD information any entity reference in
|
| 497 |
+
the document body leads to `XML_ERROR_UNDEFINED_ENTITY`.
|
| 498 |
+
|
| 499 |
+
Supported range
|
| 500 |
+
0, 1
|
| 501 |
+
Default
|
| 502 |
+
0
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
How to avoid XML vulnerabilities
|
| 506 |
+
================================
|
| 507 |
+
|
| 508 |
+
Best practices
|
| 509 |
+
--------------
|
| 510 |
+
|
| 511 |
+
* Don't allow DTDs
|
| 512 |
+
* Don't expand entities
|
| 513 |
+
* Don't resolve externals
|
| 514 |
+
* Limit parse depth
|
| 515 |
+
* Limit total input size
|
| 516 |
+
* Limit parse time
|
| 517 |
+
* Favor a SAX or iterparse-like parser for potential large data
|
| 518 |
+
* Validate and properly quote arguments to XSL transformations and
|
| 519 |
+
XPath queries
|
| 520 |
+
* Don't use XPath expression from untrusted sources
|
| 521 |
+
* Don't apply XSL transformations that come untrusted sources
|
| 522 |
+
|
| 523 |
+
(based on Brad Hill's `Attacking XML Security`_)
|
| 524 |
+
|
| 525 |
+
|
| 526 |
+
Other things to consider
|
| 527 |
+
========================
|
| 528 |
+
|
| 529 |
+
XML, XML parsers and processing libraries have more features and possible
|
| 530 |
+
issue that could lead to DoS vulnerabilities or security exploits in
|
| 531 |
+
applications. I have compiled an incomplete list of theoretical issues that
|
| 532 |
+
need further research and more attention. The list is deliberately pessimistic
|
| 533 |
+
and a bit paranoid, too. It contains things that might go wrong under daffy
|
| 534 |
+
circumstances.
|
| 535 |
+
|
| 536 |
+
|
| 537 |
+
attribute blowup / hash collision attack
|
| 538 |
+
----------------------------------------
|
| 539 |
+
|
| 540 |
+
XML parsers may use an algorithm with quadratic runtime O(n :sup:`2`) to
|
| 541 |
+
handle attributes and namespaces. If it uses hash tables (dictionaries) to
|
| 542 |
+
store attributes and namespaces the implementation may be vulnerable to
|
| 543 |
+
hash collision attacks, thus reducing the performance to O(n :sup:`2`) again.
|
| 544 |
+
In either case an attacker is able to forge a denial of service attack with
|
| 545 |
+
an XML document that contains thousands upon thousands of attributes in
|
| 546 |
+
a single node.
|
| 547 |
+
|
| 548 |
+
I haven't researched yet if expat, pyexpat or libxml2 are vulnerable.
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
decompression bomb
|
| 552 |
+
------------------
|
| 553 |
+
|
| 554 |
+
The issue of decompression bombs (aka `ZIP bomb`_) apply to all XML libraries
|
| 555 |
+
that can parse compressed XML stream like gzipped HTTP streams or LZMA-ed
|
| 556 |
+
files. For an attacker it can reduce the amount of transmitted data by three
|
| 557 |
+
magnitudes or more. Gzip is able to compress 1 GiB zeros to roughly 1 MB,
|
| 558 |
+
lzma is even better::
|
| 559 |
+
|
| 560 |
+
$ dd if=/dev/zero bs=1M count=1024 | gzip > zeros.gz
|
| 561 |
+
$ dd if=/dev/zero bs=1M count=1024 | lzma -z > zeros.xy
|
| 562 |
+
$ ls -sh zeros.*
|
| 563 |
+
1020K zeros.gz
|
| 564 |
+
148K zeros.xy
|
| 565 |
+
|
| 566 |
+
None of Python's standard XML libraries decompress streams except for
|
| 567 |
+
``xmlrpclib``. The module is vulnerable <https://bugs.python.org/issue16043>
|
| 568 |
+
to decompression bombs.
|
| 569 |
+
|
| 570 |
+
lxml can load and process compressed data through libxml2 transparently.
|
| 571 |
+
libxml2 can handle even very large blobs of compressed data efficiently
|
| 572 |
+
without using too much memory. But it doesn't protect applications from
|
| 573 |
+
decompression bombs. A carefully written SAX or iterparse-like approach can
|
| 574 |
+
be safe.
|
| 575 |
+
|
| 576 |
+
|
| 577 |
+
Processing Instruction
|
| 578 |
+
----------------------
|
| 579 |
+
|
| 580 |
+
`PI`_'s like::
|
| 581 |
+
|
| 582 |
+
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
|
| 583 |
+
|
| 584 |
+
may impose more threats for XML processing. It depends if and how a
|
| 585 |
+
processor handles processing instructions. The issue of URL retrieval with
|
| 586 |
+
network or local file access apply to processing instructions, too.
|
| 587 |
+
|
| 588 |
+
|
| 589 |
+
Other DTD features
|
| 590 |
+
------------------
|
| 591 |
+
|
| 592 |
+
`DTD`_ has more features like ``<!NOTATION>``. I haven't researched how
|
| 593 |
+
these features may be a security threat.
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
XPath
|
| 597 |
+
-----
|
| 598 |
+
|
| 599 |
+
XPath statements may introduce DoS vulnerabilities. Code should never execute
|
| 600 |
+
queries from untrusted sources. An attacker may also be able to create an XML
|
| 601 |
+
document that makes certain XPath queries costly or resource hungry.
|
| 602 |
+
|
| 603 |
+
|
| 604 |
+
XPath injection attacks
|
| 605 |
+
-----------------------
|
| 606 |
+
|
| 607 |
+
XPath injeciton attacks pretty much work like SQL injection attacks.
|
| 608 |
+
Arguments to XPath queries must be quoted and validated properly, especially
|
| 609 |
+
when they are taken from the user. The page `Avoid the dangers of XPath injection`_
|
| 610 |
+
list some ramifications of XPath injections.
|
| 611 |
+
|
| 612 |
+
Python's standard library doesn't have XPath support. Lxml supports
|
| 613 |
+
parameterized XPath queries which does proper quoting. You just have to use
|
| 614 |
+
its xpath() method correctly::
|
| 615 |
+
|
| 616 |
+
# DON'T
|
| 617 |
+
>>> tree.xpath("/tag[@id='%s']" % value)
|
| 618 |
+
|
| 619 |
+
# instead do
|
| 620 |
+
>>> tree.xpath("/tag[@id=$tagid]", tagid=name)
|
| 621 |
+
|
| 622 |
+
|
| 623 |
+
XInclude
|
| 624 |
+
--------
|
| 625 |
+
|
| 626 |
+
`XML Inclusion`_ is another way to load and include external files::
|
| 627 |
+
|
| 628 |
+
<root xmlns:xi="http://www.w3.org/2001/XInclude">
|
| 629 |
+
<xi:include href="filename.txt" parse="text" />
|
| 630 |
+
</root>
|
| 631 |
+
|
| 632 |
+
This feature should be disabled when XML files from an untrusted source are
|
| 633 |
+
processed. Some Python XML libraries and libxml2 support XInclude but don't
|
| 634 |
+
have an option to sandbox inclusion and limit it to allowed directories.
|
| 635 |
+
|
| 636 |
+
|
| 637 |
+
XMLSchema location
|
| 638 |
+
------------------
|
| 639 |
+
|
| 640 |
+
A validating XML parser may download schema files from the information in a
|
| 641 |
+
``xsi:schemaLocation`` attribute.
|
| 642 |
+
|
| 643 |
+
::
|
| 644 |
+
|
| 645 |
+
<ead xmlns="urn:isbn:1-931666-22-9"
|
| 646 |
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
| 647 |
+
xsi:schemaLocation="urn:isbn:1-931666-22-9 http://www.loc.gov/ead/ead.xsd">
|
| 648 |
+
</ead>
|
| 649 |
+
|
| 650 |
+
|
| 651 |
+
XSL Transformation
|
| 652 |
+
------------------
|
| 653 |
+
|
| 654 |
+
You should keep in mind that XSLT is a Turing complete language. Never
|
| 655 |
+
process XSLT code from unknown or untrusted source! XSLT processors may
|
| 656 |
+
allow you to interact with external resources in ways you can't even imagine.
|
| 657 |
+
Some processors even support extensions that allow read/write access to file
|
| 658 |
+
system, access to JRE objects or scripting with Jython.
|
| 659 |
+
|
| 660 |
+
Example from `Attacking XML Security`_ for Xalan-J::
|
| 661 |
+
|
| 662 |
+
<xsl:stylesheet version="1.0"
|
| 663 |
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
| 664 |
+
xmlns:rt="http://xml.apache.org/xalan/java/java.lang.Runtime"
|
| 665 |
+
xmlns:ob="http://xml.apache.org/xalan/java/java.lang.Object"
|
| 666 |
+
exclude-result-prefixes= "rt ob">
|
| 667 |
+
<xsl:template match="/">
|
| 668 |
+
<xsl:variable name="runtimeObject" select="rt:getRuntime()"/>
|
| 669 |
+
<xsl:variable name="command"
|
| 670 |
+
select="rt:exec($runtimeObject, 'c:\Windows\system32\cmd.exe')"/>
|
| 671 |
+
<xsl:variable name="commandAsString" select="ob:toString($command)"/>
|
| 672 |
+
<xsl:value-of select="$commandAsString"/>
|
| 673 |
+
</xsl:template>
|
| 674 |
+
</xsl:stylesheet>
|
| 675 |
+
|
| 676 |
+
|
| 677 |
+
Related CVEs
|
| 678 |
+
============
|
| 679 |
+
|
| 680 |
+
CVE-2013-1664
|
| 681 |
+
Unrestricted entity expansion induces DoS vulnerabilities in Python XML
|
| 682 |
+
libraries (XML bomb)
|
| 683 |
+
|
| 684 |
+
CVE-2013-1665
|
| 685 |
+
External entity expansion in Python XML libraries inflicts potential
|
| 686 |
+
security flaws and DoS vulnerabilities
|
| 687 |
+
|
| 688 |
+
|
| 689 |
+
Other languages / frameworks
|
| 690 |
+
=============================
|
| 691 |
+
|
| 692 |
+
Several other programming languages and frameworks are vulnerable as well. A
|
| 693 |
+
couple of them are affected by the fact that libxml2 up to 2.9.0 has no
|
| 694 |
+
protection against quadratic blowup attacks. Most of them have potential
|
| 695 |
+
dangerous default settings for entity expansion and external entities, too.
|
| 696 |
+
|
| 697 |
+
Perl
|
| 698 |
+
----
|
| 699 |
+
|
| 700 |
+
Perl's XML::Simple is vulnerable to quadratic entity expansion and external
|
| 701 |
+
entity expansion (both local and remote).
|
| 702 |
+
|
| 703 |
+
|
| 704 |
+
Ruby
|
| 705 |
+
----
|
| 706 |
+
|
| 707 |
+
Ruby's REXML document parser is vulnerable to entity expansion attacks
|
| 708 |
+
(both quadratic and exponential) but it doesn't do external entity
|
| 709 |
+
expansion by default. In order to counteract entity expansion you have to
|
| 710 |
+
disable the feature::
|
| 711 |
+
|
| 712 |
+
REXML::Document.entity_expansion_limit = 0
|
| 713 |
+
|
| 714 |
+
libxml-ruby and hpricot don't expand entities in their default configuration.
|
| 715 |
+
|
| 716 |
+
|
| 717 |
+
PHP
|
| 718 |
+
---
|
| 719 |
+
|
| 720 |
+
PHP's SimpleXML API is vulnerable to quadratic entity expansion and loads
|
| 721 |
+
entities from local and remote resources. The option ``LIBXML_NONET`` disables
|
| 722 |
+
network access but still allows local file access. ``LIBXML_NOENT`` seems to
|
| 723 |
+
have no effect on entity expansion in PHP 5.4.6.
|
| 724 |
+
|
| 725 |
+
|
| 726 |
+
C# / .NET / Mono
|
| 727 |
+
----------------
|
| 728 |
+
|
| 729 |
+
Information in `XML DoS and Defenses (MSDN)`_ suggest that .NET is
|
| 730 |
+
vulnerable with its default settings. The article contains code snippets
|
| 731 |
+
how to create a secure XML reader::
|
| 732 |
+
|
| 733 |
+
XmlReaderSettings settings = new XmlReaderSettings();
|
| 734 |
+
settings.ProhibitDtd = false;
|
| 735 |
+
settings.MaxCharactersFromEntities = 1024;
|
| 736 |
+
settings.XmlResolver = null;
|
| 737 |
+
XmlReader reader = XmlReader.Create(stream, settings);
|
| 738 |
+
|
| 739 |
+
|
| 740 |
+
Java
|
| 741 |
+
----
|
| 742 |
+
|
| 743 |
+
Untested. The documentation of Xerces and its `Xerces SecurityMananger`_
|
| 744 |
+
sounds like Xerces is also vulnerable to billion laugh attacks with its
|
| 745 |
+
default settings. It also does entity resolving when an
|
| 746 |
+
``org.xml.sax.EntityResolver`` is configured. I'm not yet sure about the
|
| 747 |
+
default setting here.
|
| 748 |
+
|
| 749 |
+
Java specialists suggest to have a custom builder factory::
|
| 750 |
+
|
| 751 |
+
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
| 752 |
+
builderFactory.setXIncludeAware(False);
|
| 753 |
+
builderFactory.setExpandEntityReferences(False);
|
| 754 |
+
builderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, True);
|
| 755 |
+
# either
|
| 756 |
+
builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", True);
|
| 757 |
+
# or if you need DTDs
|
| 758 |
+
builderFactory.setFeature("http://xml.org/sax/features/external-general-entities", False);
|
| 759 |
+
builderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", False);
|
| 760 |
+
builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", False);
|
| 761 |
+
builderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", False);
|
| 762 |
+
|
| 763 |
+
|
| 764 |
+
TODO
|
| 765 |
+
====
|
| 766 |
+
|
| 767 |
+
* DOM: Use xml.dom.xmlbuilder options for entity handling
|
| 768 |
+
* SAX: take feature_external_ges and feature_external_pes (?) into account
|
| 769 |
+
* test experimental monkey patching of stdlib modules
|
| 770 |
+
* improve documentation
|
| 771 |
+
|
| 772 |
+
|
| 773 |
+
License
|
| 774 |
+
=======
|
| 775 |
+
|
| 776 |
+
Copyright (c) 2013-2017 by Christian Heimes <christian@python.org>
|
| 777 |
+
|
| 778 |
+
Licensed to PSF under a Contributor Agreement.
|
| 779 |
+
|
| 780 |
+
See https://www.python.org/psf/license for licensing details.
|
| 781 |
+
|
| 782 |
+
|
| 783 |
+
Acknowledgements
|
| 784 |
+
================
|
| 785 |
+
|
| 786 |
+
Brett Cannon (Python Core developer)
|
| 787 |
+
review and code cleanup
|
| 788 |
+
|
| 789 |
+
Antoine Pitrou (Python Core developer)
|
| 790 |
+
code review
|
| 791 |
+
|
| 792 |
+
Aaron Patterson, Ben Murphy and Michael Koziarski (Ruby community)
|
| 793 |
+
Many thanks to Aaron, Ben and Michael from the Ruby community for their
|
| 794 |
+
report and assistance.
|
| 795 |
+
|
| 796 |
+
Thierry Carrez (OpenStack)
|
| 797 |
+
Many thanks to Thierry for his report to the Python Security Response
|
| 798 |
+
Team on behalf of the OpenStack security team.
|
| 799 |
+
|
| 800 |
+
Carl Meyer (Django)
|
| 801 |
+
Many thanks to Carl for his report to PSRT on behalf of the Django security
|
| 802 |
+
team.
|
| 803 |
+
|
| 804 |
+
Daniel Veillard (libxml2)
|
| 805 |
+
Many thanks to Daniel for his insight and assistance with libxml2.
|
| 806 |
+
|
| 807 |
+
semantics GmbH (https://www.semantics.de/)
|
| 808 |
+
Many thanks to my employer semantics for letting me work on the issue
|
| 809 |
+
during working hours as part of semantics's open source initiative.
|
| 810 |
+
|
| 811 |
+
|
| 812 |
+
References
|
| 813 |
+
==========
|
| 814 |
+
|
| 815 |
+
* `XML DoS and Defenses (MSDN)`_
|
| 816 |
+
* `Billion Laughs`_ on Wikipedia
|
| 817 |
+
* `ZIP bomb`_ on Wikipedia
|
| 818 |
+
* `Configure SAX parsers for secure processing`_
|
| 819 |
+
* `Testing for XML Injection`_
|
| 820 |
+
|
| 821 |
+
.. _defusedxml package: https://github.com/tiran/defusedxml
|
| 822 |
+
.. _defusedxml on PyPI: https://pypi.python.org/pypi/defusedxml
|
| 823 |
+
.. _defusedexpat package: https://github.com/tiran/defusedexpat
|
| 824 |
+
.. _defusedexpat on PyPI: https://pypi.python.org/pypi/defusedexpat
|
| 825 |
+
.. _modified expat: https://github.com/tiran/expat
|
| 826 |
+
.. _expat parser: http://expat.sourceforge.net/
|
| 827 |
+
.. _Attacking XML Security: https://www.isecpartners.com/media/12976/iSEC-HILL-Attacking-XML-Security-bh07.pdf
|
| 828 |
+
.. _Billion Laughs: https://en.wikipedia.org/wiki/Billion_laughs
|
| 829 |
+
.. _XML DoS and Defenses (MSDN): https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
|
| 830 |
+
.. _ZIP bomb: https://en.wikipedia.org/wiki/Zip_bomb
|
| 831 |
+
.. _DTD: https://en.wikipedia.org/wiki/Document_Type_Definition
|
| 832 |
+
.. _PI: https://en.wikipedia.org/wiki/Processing_Instruction
|
| 833 |
+
.. _Avoid the dangers of XPath injection: http://www.ibm.com/developerworks/xml/library/x-xpathinjection/index.html
|
| 834 |
+
.. _Configure SAX parsers for secure processing: http://www.ibm.com/developerworks/xml/library/x-tipcfsx/index.html
|
| 835 |
+
.. _Testing for XML Injection: https://www.owasp.org/index.php/Testing_for_XML_Injection_(OWASP-DV-008)
|
| 836 |
+
.. _Xerces SecurityMananger: https://xerces.apache.org/xerces2-j/javadocs/xerces2/org/apache/xerces/util/SecurityManager.html
|
| 837 |
+
.. _XML Inclusion: https://www.w3.org/TR/xinclude/#include_element
|
| 838 |
+
|
| 839 |
+
Changelog
|
| 840 |
+
=========
|
| 841 |
+
|
| 842 |
+
defusedxml 0.7.1
|
| 843 |
+
---------------------
|
| 844 |
+
|
| 845 |
+
*Release date: 08-Mar-2021*
|
| 846 |
+
|
| 847 |
+
- Fix regression ``defusedxml.ElementTree.ParseError`` (#63)
|
| 848 |
+
The ``ParseError`` exception is now the same class object as
|
| 849 |
+
``xml.etree.ElementTree.ParseError`` again.
|
| 850 |
+
|
| 851 |
+
|
| 852 |
+
defusedxml 0.7.0
|
| 853 |
+
----------------
|
| 854 |
+
|
| 855 |
+
*Release date: 4-Mar-2021*
|
| 856 |
+
|
| 857 |
+
- No changes
|
| 858 |
+
|
| 859 |
+
|
| 860 |
+
defusedxml 0.7.0rc2
|
| 861 |
+
-------------------
|
| 862 |
+
|
| 863 |
+
*Release date: 12-Jan-2021*
|
| 864 |
+
|
| 865 |
+
- Re-add and deprecate ``defusedxml.cElementTree``
|
| 866 |
+
- Use GitHub Actions instead of TravisCI
|
| 867 |
+
- Restore ``ElementTree`` attribute of ``xml.etree`` module after patching
|
| 868 |
+
|
| 869 |
+
defusedxml 0.7.0rc1
|
| 870 |
+
-------------------
|
| 871 |
+
|
| 872 |
+
*Release date: 04-May-2020*
|
| 873 |
+
|
| 874 |
+
- Add support for Python 3.9
|
| 875 |
+
- ``defusedxml.cElementTree`` is not available with Python 3.9.
|
| 876 |
+
- Python 2 is deprecate. Support for Python 2 will be removed in 0.8.0.
|
| 877 |
+
|
| 878 |
+
|
| 879 |
+
defusedxml 0.6.0
|
| 880 |
+
----------------
|
| 881 |
+
|
| 882 |
+
*Release date: 17-Apr-2019*
|
| 883 |
+
|
| 884 |
+
- Increase test coverage.
|
| 885 |
+
- Add badges to README.
|
| 886 |
+
|
| 887 |
+
|
| 888 |
+
defusedxml 0.6.0rc1
|
| 889 |
+
-------------------
|
| 890 |
+
|
| 891 |
+
*Release date: 14-Apr-2019*
|
| 892 |
+
|
| 893 |
+
- Test on Python 3.7 stable and 3.8-dev
|
| 894 |
+
- Drop support for Python 3.4
|
| 895 |
+
- No longer pass *html* argument to XMLParse. It has been deprecated and
|
| 896 |
+
ignored for a long time. The DefusedXMLParser still takes a html argument.
|
| 897 |
+
A deprecation warning is issued when the argument is False and a TypeError
|
| 898 |
+
when it's True.
|
| 899 |
+
- defusedxml now fails early when pyexpat stdlib module is not available or
|
| 900 |
+
broken.
|
| 901 |
+
- defusedxml.ElementTree.__all__ now lists ParseError as public attribute.
|
| 902 |
+
- The defusedxml.ElementTree and defusedxml.cElementTree modules had a typo
|
| 903 |
+
and used XMLParse instead of XMLParser as an alias for DefusedXMLParser.
|
| 904 |
+
Both the old and fixed name are now available.
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
defusedxml 0.5.0
|
| 908 |
+
----------------
|
| 909 |
+
|
| 910 |
+
*Release date: 07-Feb-2017*
|
| 911 |
+
|
| 912 |
+
- No changes
|
| 913 |
+
|
| 914 |
+
|
| 915 |
+
defusedxml 0.5.0.rc1
|
| 916 |
+
--------------------
|
| 917 |
+
|
| 918 |
+
*Release date: 28-Jan-2017*
|
| 919 |
+
|
| 920 |
+
- Add compatibility with Python 3.6
|
| 921 |
+
- Drop support for Python 2.6, 3.1, 3.2, 3.3
|
| 922 |
+
- Fix lxml tests (XMLSyntaxError: Detected an entity reference loop)
|
| 923 |
+
|
| 924 |
+
|
| 925 |
+
defusedxml 0.4.1
|
| 926 |
+
----------------
|
| 927 |
+
|
| 928 |
+
*Release date: 28-Mar-2013*
|
| 929 |
+
|
| 930 |
+
- Add more demo exploits, e.g. python_external.py and Xalan XSLT demos.
|
| 931 |
+
- Improved documentation.
|
| 932 |
+
|
| 933 |
+
|
| 934 |
+
defusedxml 0.4
|
| 935 |
+
--------------
|
| 936 |
+
|
| 937 |
+
*Release date: 25-Feb-2013*
|
| 938 |
+
|
| 939 |
+
- As per http://seclists.org/oss-sec/2013/q1/340 please REJECT
|
| 940 |
+
CVE-2013-0278, CVE-2013-0279 and CVE-2013-0280 and use CVE-2013-1664,
|
| 941 |
+
CVE-2013-1665 for OpenStack/etc.
|
| 942 |
+
- Add missing parser_list argument to sax.make_parser(). The argument is
|
| 943 |
+
ignored, though. (thanks to Florian Apolloner)
|
| 944 |
+
- Add demo exploit for external entity attack on Python's SAX parser, XML-RPC
|
| 945 |
+
and WebDAV.
|
| 946 |
+
|
| 947 |
+
|
| 948 |
+
defusedxml 0.3
|
| 949 |
+
--------------
|
| 950 |
+
|
| 951 |
+
*Release date: 19-Feb-2013*
|
| 952 |
+
|
| 953 |
+
- Improve documentation
|
| 954 |
+
|
| 955 |
+
|
| 956 |
+
defusedxml 0.2
|
| 957 |
+
--------------
|
| 958 |
+
|
| 959 |
+
*Release date: 15-Feb-2013*
|
| 960 |
+
|
| 961 |
+
- Rename ExternalEntitiesForbidden to ExternalReferenceForbidden
|
| 962 |
+
- Rename defusedxml.lxml.check_dtd() to check_docinfo()
|
| 963 |
+
- Unify argument names in callbacks
|
| 964 |
+
- Add arguments and formatted representation to exceptions
|
| 965 |
+
- Add forbid_external argument to all functions and classes
|
| 966 |
+
- More tests
|
| 967 |
+
- LOTS of documentation
|
| 968 |
+
- Add example code for other languages (Ruby, Perl, PHP) and parsers (Genshi)
|
| 969 |
+
- Add protection against XML and gzip attacks to xmlrpclib
|
| 970 |
+
|
| 971 |
+
defusedxml 0.1
|
| 972 |
+
--------------
|
| 973 |
+
|
| 974 |
+
*Release date: 08-Feb-2013*
|
| 975 |
+
|
| 976 |
+
- Initial and internal release for PSRT review
|
| 977 |
+
|
| 978 |
+
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/RECORD
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defusedxml-0.7.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
| 2 |
+
defusedxml-0.7.1.dist-info/LICENSE,sha256=uAzp2oxCofkQeWJ_u-K_JyEK4Qig_-Xwd9WwjgdsJMg,2409
|
| 3 |
+
defusedxml-0.7.1.dist-info/METADATA,sha256=Np0872SHDa-En7pxHLjQWn7-PI2asPdjrcNAef43i7E,32518
|
| 4 |
+
defusedxml-0.7.1.dist-info/RECORD,,
|
| 5 |
+
defusedxml-0.7.1.dist-info/WHEEL,sha256=kGT74LWyRUZrL4VgLh6_g12IeVl_9u9ZVhadrgXZUEY,110
|
| 6 |
+
defusedxml-0.7.1.dist-info/top_level.txt,sha256=QGHa90F50pVKhWSFlERI0jtSKtqDiGyfeZX7dQNZAAw,11
|
| 7 |
+
defusedxml/ElementTree.py,sha256=GLSqpCz58oXGPGyzf_HylsPS9_dcGVP5SN4dK7yvyPw,4640
|
| 8 |
+
defusedxml/__init__.py,sha256=RczeaVJG64p2Fgy1jlCzbuRdchEPnEaCBrxgk8JJ_pM,1444
|
| 9 |
+
defusedxml/__pycache__/ElementTree.cpython-310.pyc,,
|
| 10 |
+
defusedxml/__pycache__/__init__.cpython-310.pyc,,
|
| 11 |
+
defusedxml/__pycache__/cElementTree.cpython-310.pyc,,
|
| 12 |
+
defusedxml/__pycache__/common.cpython-310.pyc,,
|
| 13 |
+
defusedxml/__pycache__/expatbuilder.cpython-310.pyc,,
|
| 14 |
+
defusedxml/__pycache__/expatreader.cpython-310.pyc,,
|
| 15 |
+
defusedxml/__pycache__/lxml.cpython-310.pyc,,
|
| 16 |
+
defusedxml/__pycache__/minidom.cpython-310.pyc,,
|
| 17 |
+
defusedxml/__pycache__/pulldom.cpython-310.pyc,,
|
| 18 |
+
defusedxml/__pycache__/sax.cpython-310.pyc,,
|
| 19 |
+
defusedxml/__pycache__/xmlrpc.cpython-310.pyc,,
|
| 20 |
+
defusedxml/cElementTree.py,sha256=PpaKMh3rU29sY8amAK4fzHQKl8gcAYD0h1LCoW62Rtk,1449
|
| 21 |
+
defusedxml/common.py,sha256=3d26jNW4fNXzgjWhvUfs83Afiz5EVxFDupQbugkSMZc,4036
|
| 22 |
+
defusedxml/expatbuilder.py,sha256=b4Q05vsBMJ5StkiTFf4my2rGGo1gZyEl_hC5MeFTOAA,3732
|
| 23 |
+
defusedxml/expatreader.py,sha256=KOpSrwkSvj5SGOY9pTXOM26Dnz00rsJt33WueVvzpvc,2196
|
| 24 |
+
defusedxml/lxml.py,sha256=HW-LFKdrfMRzHdi0Vcucq4-n8yz7v_OQwEQWFg1JQYA,4940
|
| 25 |
+
defusedxml/minidom.py,sha256=3QcgygVwJqcWDQ3IZ2iol8zsH4cx3BRX70SPcd0bG2g,1884
|
| 26 |
+
defusedxml/pulldom.py,sha256=DYj2D2lc7xoxZ38gfzujXmdznd8ovzDqGFXqyXbtxjk,1170
|
| 27 |
+
defusedxml/sax.py,sha256=-SF08Msc2mWEYAMw62pJ5FMwWccOctFSnQwDLYLLlVE,1477
|
| 28 |
+
defusedxml/xmlrpc.py,sha256=7rZQey3tqXcc1hrrM3RprOICU6fiFny9B9l4nmTioxA,5364
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: bdist_wheel (0.34.2)
|
| 3 |
+
Root-Is-Purelib: true
|
| 4 |
+
Tag: py2-none-any
|
| 5 |
+
Tag: py3-none-any
|
| 6 |
+
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/defusedxml-0.7.1.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
defusedxml
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/distutils-precedence.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7ea7ffef3fe2a117ee12c68ed6553617f0d7fd2f0590257c25c484959a3b7373
|
| 3 |
+
size 152
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/docs/__pycache__/conf.cpython-310.pyc
ADDED
|
Binary file (2.74 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/docs/conf.py
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright 2024 Google LLC
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
#
|
| 16 |
+
# google-auth-oauthlib documentation build configuration file
|
| 17 |
+
#
|
| 18 |
+
# This file is execfile()d with the current directory set to its
|
| 19 |
+
# containing dir.
|
| 20 |
+
#
|
| 21 |
+
# Note that not all possible configuration values are present in this
|
| 22 |
+
# autogenerated file.
|
| 23 |
+
#
|
| 24 |
+
# All configuration values have a default; values that are commented out
|
| 25 |
+
# serve to show the default.
|
| 26 |
+
|
| 27 |
+
import sys
|
| 28 |
+
import os
|
| 29 |
+
import shlex
|
| 30 |
+
|
| 31 |
+
# If extensions (or modules to document with autodoc) are in another directory,
|
| 32 |
+
# add these directories to sys.path here. If the directory is relative to the
|
| 33 |
+
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
| 34 |
+
sys.path.insert(0, os.path.abspath(".."))
|
| 35 |
+
|
| 36 |
+
# For plugins that can not read conf.py.
|
| 37 |
+
# See also: https://github.com/docascode/sphinx-docfx-yaml/issues/85
|
| 38 |
+
sys.path.insert(0, os.path.abspath("."))
|
| 39 |
+
|
| 40 |
+
__version__ = ""
|
| 41 |
+
|
| 42 |
+
# -- General configuration ------------------------------------------------
|
| 43 |
+
|
| 44 |
+
# If your documentation needs a minimal Sphinx version, state it here.
|
| 45 |
+
needs_sphinx = "1.5.5"
|
| 46 |
+
|
| 47 |
+
# Add any Sphinx extension module names here, as strings. They can be
|
| 48 |
+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
| 49 |
+
# ones.
|
| 50 |
+
extensions = [
|
| 51 |
+
"sphinx.ext.autodoc",
|
| 52 |
+
"sphinx.ext.autosummary",
|
| 53 |
+
"sphinx.ext.intersphinx",
|
| 54 |
+
"sphinx.ext.coverage",
|
| 55 |
+
"sphinx.ext.doctest",
|
| 56 |
+
"sphinx.ext.napoleon",
|
| 57 |
+
"sphinx.ext.todo",
|
| 58 |
+
"sphinx.ext.viewcode",
|
| 59 |
+
"recommonmark",
|
| 60 |
+
]
|
| 61 |
+
|
| 62 |
+
# autodoc/autosummary flags
|
| 63 |
+
autoclass_content = "both"
|
| 64 |
+
autodoc_default_options = {"members": True}
|
| 65 |
+
autosummary_generate = True
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# Add any paths that contain templates here, relative to this directory.
|
| 69 |
+
templates_path = ["_templates"]
|
| 70 |
+
|
| 71 |
+
# The suffix(es) of source filenames.
|
| 72 |
+
# You can specify multiple suffix as a list of string:
|
| 73 |
+
# source_suffix = ['.rst', '.md']
|
| 74 |
+
source_suffix = [".rst", ".md"]
|
| 75 |
+
|
| 76 |
+
# The encoding of source files.
|
| 77 |
+
# source_encoding = 'utf-8-sig'
|
| 78 |
+
|
| 79 |
+
# The root toctree document.
|
| 80 |
+
root_doc = "index"
|
| 81 |
+
|
| 82 |
+
# General information about the project.
|
| 83 |
+
project = "google-auth-oauthlib"
|
| 84 |
+
copyright = "2019, Google"
|
| 85 |
+
author = "Google APIs"
|
| 86 |
+
|
| 87 |
+
# The version info for the project you're documenting, acts as replacement for
|
| 88 |
+
# |version| and |release|, also used in various other places throughout the
|
| 89 |
+
# built documents.
|
| 90 |
+
#
|
| 91 |
+
# The full version, including alpha/beta/rc tags.
|
| 92 |
+
release = __version__
|
| 93 |
+
# The short X.Y version.
|
| 94 |
+
version = ".".join(release.split(".")[0:2])
|
| 95 |
+
|
| 96 |
+
# The language for content autogenerated by Sphinx. Refer to documentation
|
| 97 |
+
# for a list of supported languages.
|
| 98 |
+
#
|
| 99 |
+
# This is also used if you do content translation via gettext catalogs.
|
| 100 |
+
# Usually you set "language" from the command line for these cases.
|
| 101 |
+
language = None
|
| 102 |
+
|
| 103 |
+
# There are two options for replacing |today|: either, you set today to some
|
| 104 |
+
# non-false value, then it is used:
|
| 105 |
+
# today = ''
|
| 106 |
+
# Else, today_fmt is used as the format for a strftime call.
|
| 107 |
+
# today_fmt = '%B %d, %Y'
|
| 108 |
+
|
| 109 |
+
# List of patterns, relative to source directory, that match files and
|
| 110 |
+
# directories to ignore when looking for source files.
|
| 111 |
+
exclude_patterns = [
|
| 112 |
+
"_build",
|
| 113 |
+
"**/.nox/**/*",
|
| 114 |
+
"samples/AUTHORING_GUIDE.md",
|
| 115 |
+
"samples/CONTRIBUTING.md",
|
| 116 |
+
"samples/snippets/README.rst",
|
| 117 |
+
]
|
| 118 |
+
|
| 119 |
+
# The reST default role (used for this markup: `text`) to use for all
|
| 120 |
+
# documents.
|
| 121 |
+
# default_role = None
|
| 122 |
+
|
| 123 |
+
# If true, '()' will be appended to :func: etc. cross-reference text.
|
| 124 |
+
# add_function_parentheses = True
|
| 125 |
+
|
| 126 |
+
# If true, the current module name will be prepended to all description
|
| 127 |
+
# unit titles (such as .. function::).
|
| 128 |
+
# add_module_names = True
|
| 129 |
+
|
| 130 |
+
# If true, sectionauthor and moduleauthor directives will be shown in the
|
| 131 |
+
# output. They are ignored by default.
|
| 132 |
+
# show_authors = False
|
| 133 |
+
|
| 134 |
+
# The name of the Pygments (syntax highlighting) style to use.
|
| 135 |
+
pygments_style = "sphinx"
|
| 136 |
+
|
| 137 |
+
# A list of ignored prefixes for module index sorting.
|
| 138 |
+
# modindex_common_prefix = []
|
| 139 |
+
|
| 140 |
+
# If true, keep warnings as "system message" paragraphs in the built documents.
|
| 141 |
+
# keep_warnings = False
|
| 142 |
+
|
| 143 |
+
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
| 144 |
+
todo_include_todos = True
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
# -- Options for HTML output ----------------------------------------------
|
| 148 |
+
|
| 149 |
+
# The theme to use for HTML and HTML Help pages. See the documentation for
|
| 150 |
+
# a list of builtin themes.
|
| 151 |
+
html_theme = "alabaster"
|
| 152 |
+
|
| 153 |
+
# Theme options are theme-specific and customize the look and feel of a theme
|
| 154 |
+
# further. For a list of options available for each theme, see the
|
| 155 |
+
# documentation.
|
| 156 |
+
html_theme_options = {
|
| 157 |
+
"description": "Google Cloud Client Libraries for google-auth-oauthlib",
|
| 158 |
+
"github_user": "googleapis",
|
| 159 |
+
"github_repo": "google-auth-library-python-oauthlib",
|
| 160 |
+
"github_banner": True,
|
| 161 |
+
"font_family": "'Roboto', Georgia, sans",
|
| 162 |
+
"head_font_family": "'Roboto', Georgia, serif",
|
| 163 |
+
"code_font_family": "'Roboto Mono', 'Consolas', monospace",
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
# Add any paths that contain custom themes here, relative to this directory.
|
| 167 |
+
# html_theme_path = []
|
| 168 |
+
|
| 169 |
+
# The name for this set of Sphinx documents. If None, it defaults to
|
| 170 |
+
# "<project> v<release> documentation".
|
| 171 |
+
# html_title = None
|
| 172 |
+
|
| 173 |
+
# A shorter title for the navigation bar. Default is the same as html_title.
|
| 174 |
+
# html_short_title = None
|
| 175 |
+
|
| 176 |
+
# The name of an image file (relative to this directory) to place at the top
|
| 177 |
+
# of the sidebar.
|
| 178 |
+
# html_logo = None
|
| 179 |
+
|
| 180 |
+
# The name of an image file (within the static path) to use as favicon of the
|
| 181 |
+
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
| 182 |
+
# pixels large.
|
| 183 |
+
# html_favicon = None
|
| 184 |
+
|
| 185 |
+
# Add any paths that contain custom static files (such as style sheets) here,
|
| 186 |
+
# relative to this directory. They are copied after the builtin static files,
|
| 187 |
+
# so a file named "default.css" will overwrite the builtin "default.css".
|
| 188 |
+
html_static_path = ["_static"]
|
| 189 |
+
|
| 190 |
+
# Add any extra paths that contain custom files (such as robots.txt or
|
| 191 |
+
# .htaccess) here, relative to this directory. These files are copied
|
| 192 |
+
# directly to the root of the documentation.
|
| 193 |
+
# html_extra_path = []
|
| 194 |
+
|
| 195 |
+
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
| 196 |
+
# using the given strftime format.
|
| 197 |
+
# html_last_updated_fmt = '%b %d, %Y'
|
| 198 |
+
|
| 199 |
+
# If true, SmartyPants will be used to convert quotes and dashes to
|
| 200 |
+
# typographically correct entities.
|
| 201 |
+
# html_use_smartypants = True
|
| 202 |
+
|
| 203 |
+
# Custom sidebar templates, maps document names to template names.
|
| 204 |
+
# html_sidebars = {}
|
| 205 |
+
|
| 206 |
+
# Additional templates that should be rendered to pages, maps page names to
|
| 207 |
+
# template names.
|
| 208 |
+
# html_additional_pages = {}
|
| 209 |
+
|
| 210 |
+
# If false, no module index is generated.
|
| 211 |
+
# html_domain_indices = True
|
| 212 |
+
|
| 213 |
+
# If false, no index is generated.
|
| 214 |
+
# html_use_index = True
|
| 215 |
+
|
| 216 |
+
# If true, the index is split into individual pages for each letter.
|
| 217 |
+
# html_split_index = False
|
| 218 |
+
|
| 219 |
+
# If true, links to the reST sources are added to the pages.
|
| 220 |
+
# html_show_sourcelink = True
|
| 221 |
+
|
| 222 |
+
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
| 223 |
+
# html_show_sphinx = True
|
| 224 |
+
|
| 225 |
+
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
| 226 |
+
# html_show_copyright = True
|
| 227 |
+
|
| 228 |
+
# If true, an OpenSearch description file will be output, and all pages will
|
| 229 |
+
# contain a <link> tag referring to it. The value of this option must be the
|
| 230 |
+
# base URL from which the finished HTML is served.
|
| 231 |
+
# html_use_opensearch = ''
|
| 232 |
+
|
| 233 |
+
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
| 234 |
+
# html_file_suffix = None
|
| 235 |
+
|
| 236 |
+
# Language to be used for generating the HTML full-text search index.
|
| 237 |
+
# Sphinx supports the following languages:
|
| 238 |
+
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
|
| 239 |
+
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
|
| 240 |
+
# html_search_language = 'en'
|
| 241 |
+
|
| 242 |
+
# A dictionary with options for the search language support, empty by default.
|
| 243 |
+
# Now only 'ja' uses this config value
|
| 244 |
+
# html_search_options = {'type': 'default'}
|
| 245 |
+
|
| 246 |
+
# The name of a javascript file (relative to the configuration directory) that
|
| 247 |
+
# implements a search results scorer. If empty, the default will be used.
|
| 248 |
+
# html_search_scorer = 'scorer.js'
|
| 249 |
+
|
| 250 |
+
# Output file base name for HTML help builder.
|
| 251 |
+
htmlhelp_basename = "google-auth-oauthlib-doc"
|
| 252 |
+
|
| 253 |
+
# -- Options for warnings ------------------------------------------------------
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
suppress_warnings = [
|
| 257 |
+
# Temporarily suppress this to avoid "more than one target found for
|
| 258 |
+
# cross-reference" warning, which are intractable for us to avoid while in
|
| 259 |
+
# a mono-repo.
|
| 260 |
+
# See https://github.com/sphinx-doc/sphinx/blob
|
| 261 |
+
# /2a65ffeef5c107c19084fabdd706cdff3f52d93c/sphinx/domains/python.py#L843
|
| 262 |
+
"ref.python"
|
| 263 |
+
]
|
| 264 |
+
|
| 265 |
+
# -- Options for LaTeX output ---------------------------------------------
|
| 266 |
+
|
| 267 |
+
latex_elements = {
|
| 268 |
+
# The paper size ('letterpaper' or 'a4paper').
|
| 269 |
+
#'papersize': 'letterpaper',
|
| 270 |
+
# The font size ('10pt', '11pt' or '12pt').
|
| 271 |
+
#'pointsize': '10pt',
|
| 272 |
+
# Additional stuff for the LaTeX preamble.
|
| 273 |
+
#'preamble': '',
|
| 274 |
+
# Latex figure (float) alignment
|
| 275 |
+
#'figure_align': 'htbp',
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
# Grouping the document tree into LaTeX files. List of tuples
|
| 279 |
+
# (source start file, target name, title,
|
| 280 |
+
# author, documentclass [howto, manual, or own class]).
|
| 281 |
+
latex_documents = [
|
| 282 |
+
(
|
| 283 |
+
root_doc,
|
| 284 |
+
"google-auth-oauthlib.tex",
|
| 285 |
+
"google-auth-oauthlib Documentation",
|
| 286 |
+
author,
|
| 287 |
+
"manual",
|
| 288 |
+
)
|
| 289 |
+
]
|
| 290 |
+
|
| 291 |
+
# The name of an image file (relative to this directory) to place at the top of
|
| 292 |
+
# the title page.
|
| 293 |
+
# latex_logo = None
|
| 294 |
+
|
| 295 |
+
# For "manual" documents, if this is true, then toplevel headings are parts,
|
| 296 |
+
# not chapters.
|
| 297 |
+
# latex_use_parts = False
|
| 298 |
+
|
| 299 |
+
# If true, show page references after internal links.
|
| 300 |
+
# latex_show_pagerefs = False
|
| 301 |
+
|
| 302 |
+
# If true, show URL addresses after external links.
|
| 303 |
+
# latex_show_urls = False
|
| 304 |
+
|
| 305 |
+
# Documents to append as an appendix to all manuals.
|
| 306 |
+
# latex_appendices = []
|
| 307 |
+
|
| 308 |
+
# If false, no module index is generated.
|
| 309 |
+
# latex_domain_indices = True
|
| 310 |
+
|
| 311 |
+
|
| 312 |
+
# -- Options for manual page output ---------------------------------------
|
| 313 |
+
|
| 314 |
+
# One entry per manual page. List of tuples
|
| 315 |
+
# (source start file, name, description, authors, manual section).
|
| 316 |
+
man_pages = [
|
| 317 |
+
(
|
| 318 |
+
root_doc,
|
| 319 |
+
"google-auth-oauthlib",
|
| 320 |
+
"google-auth-oauthlib Documentation",
|
| 321 |
+
[author],
|
| 322 |
+
1,
|
| 323 |
+
)
|
| 324 |
+
]
|
| 325 |
+
|
| 326 |
+
# If true, show URL addresses after external links.
|
| 327 |
+
# man_show_urls = False
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
# -- Options for Texinfo output -------------------------------------------
|
| 331 |
+
|
| 332 |
+
# Grouping the document tree into Texinfo files. List of tuples
|
| 333 |
+
# (source start file, target name, title, author,
|
| 334 |
+
# dir menu entry, description, category)
|
| 335 |
+
texinfo_documents = [
|
| 336 |
+
(
|
| 337 |
+
root_doc,
|
| 338 |
+
"google-auth-oauthlib",
|
| 339 |
+
"google-auth-oauthlib Documentation",
|
| 340 |
+
author,
|
| 341 |
+
"google-auth-oauthlib",
|
| 342 |
+
"google-auth-oauthlib Library",
|
| 343 |
+
"APIs",
|
| 344 |
+
)
|
| 345 |
+
]
|
| 346 |
+
|
| 347 |
+
# Documents to append as an appendix to all manuals.
|
| 348 |
+
# texinfo_appendices = []
|
| 349 |
+
|
| 350 |
+
# If false, no module index is generated.
|
| 351 |
+
# texinfo_domain_indices = True
|
| 352 |
+
|
| 353 |
+
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
| 354 |
+
# texinfo_show_urls = 'footnote'
|
| 355 |
+
|
| 356 |
+
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
| 357 |
+
# texinfo_no_detailmenu = False
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
# Example configuration for intersphinx: refer to the Python standard library.
|
| 361 |
+
intersphinx_mapping = {
|
| 362 |
+
"python": ("https://python.readthedocs.org/en/latest/", None),
|
| 363 |
+
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
|
| 364 |
+
"google.api_core": (
|
| 365 |
+
"https://googleapis.dev/python/google-api-core/latest/",
|
| 366 |
+
None,
|
| 367 |
+
),
|
| 368 |
+
"grpc": ("https://grpc.github.io/grpc/python/", None),
|
| 369 |
+
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
|
| 370 |
+
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
# Napoleon settings
|
| 375 |
+
napoleon_google_docstring = True
|
| 376 |
+
napoleon_numpy_docstring = True
|
| 377 |
+
napoleon_include_private_with_doc = False
|
| 378 |
+
napoleon_include_special_with_doc = True
|
| 379 |
+
napoleon_use_admonition_for_examples = False
|
| 380 |
+
napoleon_use_admonition_for_notes = False
|
| 381 |
+
napoleon_use_admonition_for_references = False
|
| 382 |
+
napoleon_use_ivar = False
|
| 383 |
+
napoleon_use_param = True
|
| 384 |
+
napoleon_use_rtype = True
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/keras-2.15.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/keras-2.15.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.1
|
| 2 |
+
Name: keras
|
| 3 |
+
Version: 2.15.0
|
| 4 |
+
Summary: Deep learning for humans.
|
| 5 |
+
Home-page: https://keras.io/
|
| 6 |
+
Download-URL: https://github.com/keras-team/keras/tags
|
| 7 |
+
Author: Keras team
|
| 8 |
+
Author-email: keras-users@googlegroups.com
|
| 9 |
+
License: Apache 2.0
|
| 10 |
+
Keywords: keras,tensorflow,machine learning,deep learning
|
| 11 |
+
Classifier: Development Status :: 5 - Production/Stable
|
| 12 |
+
Classifier: Intended Audience :: Developers
|
| 13 |
+
Classifier: Intended Audience :: Education
|
| 14 |
+
Classifier: Intended Audience :: Science/Research
|
| 15 |
+
Classifier: License :: OSI Approved :: Apache Software License
|
| 16 |
+
Classifier: Programming Language :: Python :: 3
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.8
|
| 18 |
+
Classifier: Programming Language :: Python :: 3.9
|
| 19 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 20 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 21 |
+
Classifier: Programming Language :: Python :: 3 :: Only
|
| 22 |
+
Classifier: Topic :: Scientific/Engineering
|
| 23 |
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
| 24 |
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
| 25 |
+
Classifier: Topic :: Software Development
|
| 26 |
+
Classifier: Topic :: Software Development :: Libraries
|
| 27 |
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
| 28 |
+
Requires-Python: >=3.8
|
| 29 |
+
|
| 30 |
+
Keras is a deep learning API written in Python,
|
| 31 |
+
running on top of the machine learning platform TensorFlow.
|
| 32 |
+
|
| 33 |
+
It was developed with a focus on enabling fast experimentation and
|
| 34 |
+
providing a delightful developer experience.
|
| 35 |
+
The purpose of Keras is to give an *unfair advantage* to any developer
|
| 36 |
+
looking to ship ML-powered apps.
|
| 37 |
+
|
| 38 |
+
Keras is:
|
| 39 |
+
|
| 40 |
+
- **Simple** -- but not simplistic. Keras reduces developer *cognitive load*
|
| 41 |
+
to free you to focus on the parts of the problem that really matter.
|
| 42 |
+
Keras focuses on ease of use, debugging speed, code elegance & conciseness,
|
| 43 |
+
maintainability, and deployability (via TFServing, TFLite, TF.js).
|
| 44 |
+
- **Flexible** -- Keras adopts the principle of *progressive disclosure of
|
| 45 |
+
complexity*: simple workflows should be quick and easy, while arbitrarily
|
| 46 |
+
advanced workflows should be *possible* via a clear path that builds upon
|
| 47 |
+
what you've already learned.
|
| 48 |
+
- **Powerful** -- Keras provides industry-strength performance and
|
| 49 |
+
scalability: it is used by organizations and companies including NASA,
|
| 50 |
+
YouTube, and Waymo. That's right -- your YouTube recommendations are
|
| 51 |
+
powered by Keras, and so is the world's most advanced driverless vehicle.
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/keras-2.15.0.dist-info/RECORD
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/__init__.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --------------------------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2013-2024, Nucleic Development Team.
|
| 3 |
+
#
|
| 4 |
+
# Distributed under the terms of the Modified BSD License.
|
| 5 |
+
#
|
| 6 |
+
# The full license is in the file LICENSE, distributed with this software.
|
| 7 |
+
# --------------------------------------------------------------------------------------
|
| 8 |
+
from ._cext import (
|
| 9 |
+
Constraint,
|
| 10 |
+
Expression,
|
| 11 |
+
Solver,
|
| 12 |
+
Term,
|
| 13 |
+
Variable,
|
| 14 |
+
__kiwi_version__,
|
| 15 |
+
__version__,
|
| 16 |
+
strength,
|
| 17 |
+
)
|
| 18 |
+
from .exceptions import (
|
| 19 |
+
BadRequiredStrength,
|
| 20 |
+
DuplicateConstraint,
|
| 21 |
+
DuplicateEditVariable,
|
| 22 |
+
UnknownConstraint,
|
| 23 |
+
UnknownEditVariable,
|
| 24 |
+
UnsatisfiableConstraint,
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
__all__ = [
|
| 28 |
+
"BadRequiredStrength",
|
| 29 |
+
"Constraint",
|
| 30 |
+
"DuplicateConstraint",
|
| 31 |
+
"DuplicateEditVariable",
|
| 32 |
+
"Expression",
|
| 33 |
+
"Solver",
|
| 34 |
+
"Term",
|
| 35 |
+
"UnknownConstraint",
|
| 36 |
+
"UnknownEditVariable",
|
| 37 |
+
"UnsatisfiableConstraint",
|
| 38 |
+
"Variable",
|
| 39 |
+
"__kiwi_version__",
|
| 40 |
+
"__version__",
|
| 41 |
+
"strength",
|
| 42 |
+
]
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (712 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/__pycache__/exceptions.cpython-310.pyc
ADDED
|
Binary file (1.75 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/_cext.pyi
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --------------------------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2021-2024, Nucleic Development Team.
|
| 3 |
+
#
|
| 4 |
+
# Distributed under the terms of the Modified BSD License.
|
| 5 |
+
#
|
| 6 |
+
# The full license is in the file LICENSE, distributed with this software.
|
| 7 |
+
# --------------------------------------------------------------------------------------
|
| 8 |
+
|
| 9 |
+
from typing import Any, Iterable, NoReturn, Tuple, type_check_only
|
| 10 |
+
|
| 11 |
+
try:
|
| 12 |
+
from typing import Literal
|
| 13 |
+
except ImportError:
|
| 14 |
+
from typing_extensions import Literal # type: ignore
|
| 15 |
+
|
| 16 |
+
__version__: str
|
| 17 |
+
__kiwi_version__: str
|
| 18 |
+
|
| 19 |
+
# Types
|
| 20 |
+
@type_check_only
|
| 21 |
+
class Strength:
|
| 22 |
+
@property
|
| 23 |
+
def weak(self) -> float: ...
|
| 24 |
+
@property
|
| 25 |
+
def medium(self) -> float: ...
|
| 26 |
+
@property
|
| 27 |
+
def strong(self) -> float: ...
|
| 28 |
+
@property
|
| 29 |
+
def required(self) -> float: ...
|
| 30 |
+
def create(
|
| 31 |
+
self,
|
| 32 |
+
a: int | float,
|
| 33 |
+
b: int | float,
|
| 34 |
+
c: int | float,
|
| 35 |
+
weight: int | float = 1.0,
|
| 36 |
+
/,
|
| 37 |
+
) -> float: ...
|
| 38 |
+
|
| 39 |
+
# This is meant as a singleton and users should not access the Strength type.
|
| 40 |
+
strength: Strength
|
| 41 |
+
|
| 42 |
+
class Variable:
|
| 43 |
+
"""Variable to express a constraint in a solver."""
|
| 44 |
+
|
| 45 |
+
__hash__: None # type: ignore
|
| 46 |
+
def __init__(self, name: str = "", context: Any = None, /) -> None: ...
|
| 47 |
+
def name(self) -> str:
|
| 48 |
+
"""Get the name of the variable."""
|
| 49 |
+
...
|
| 50 |
+
def setName(self, name: str, /) -> Any:
|
| 51 |
+
"""Set the name of the variable."""
|
| 52 |
+
...
|
| 53 |
+
def value(self) -> float:
|
| 54 |
+
"""Get the current value of the variable."""
|
| 55 |
+
...
|
| 56 |
+
def context(self) -> Any:
|
| 57 |
+
"""Get the context object associated with the variable."""
|
| 58 |
+
...
|
| 59 |
+
def setContext(self, context: Any, /) -> Any:
|
| 60 |
+
"""Set the context object associated with the variable."""
|
| 61 |
+
...
|
| 62 |
+
def __neg__(self) -> Term: ...
|
| 63 |
+
def __add__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 64 |
+
def __radd__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 65 |
+
def __sub__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 66 |
+
def __rsub__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 67 |
+
def __mul__(self, other: float) -> Term: ...
|
| 68 |
+
def __rmul__(self, other: float) -> Term: ...
|
| 69 |
+
def __truediv__(self, other: float) -> Term: ...
|
| 70 |
+
def __rtruediv__(self, other: float) -> Term: ...
|
| 71 |
+
def __eq__(self, other: float | Variable | Term | Expression) -> Constraint: ... # type: ignore
|
| 72 |
+
def __ge__(self, other: float | Variable | Term | Expression) -> Constraint: ...
|
| 73 |
+
def __le__(self, other: float | Variable | Term | Expression) -> Constraint: ...
|
| 74 |
+
def __ne__(self, other: Any) -> NoReturn: ...
|
| 75 |
+
def __gt__(self, other: Any) -> NoReturn: ...
|
| 76 |
+
def __lt__(self, other: Any) -> NoReturn: ...
|
| 77 |
+
|
| 78 |
+
class Term:
|
| 79 |
+
"""Product of a variable by a constant pre-factor."""
|
| 80 |
+
|
| 81 |
+
__hash__: None # type: ignore
|
| 82 |
+
def __init__(
|
| 83 |
+
self, variable: Variable, coefficient: int | float = 1.0, /
|
| 84 |
+
) -> None: ...
|
| 85 |
+
def coefficient(self) -> float:
|
| 86 |
+
"""Get the coefficient for the term."""
|
| 87 |
+
...
|
| 88 |
+
def variable(self) -> Variable:
|
| 89 |
+
"""Get the variable for the term."""
|
| 90 |
+
...
|
| 91 |
+
def value(self) -> float:
|
| 92 |
+
"""Get the value for the term."""
|
| 93 |
+
...
|
| 94 |
+
def __neg__(self) -> Term: ...
|
| 95 |
+
def __add__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 96 |
+
def __radd__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 97 |
+
def __sub__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 98 |
+
def __rsub__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 99 |
+
def __mul__(self, other: float) -> Term: ...
|
| 100 |
+
def __rmul__(self, other: float) -> Term: ...
|
| 101 |
+
def __truediv__(self, other: float) -> Term: ...
|
| 102 |
+
def __rtruediv__(self, other: float) -> Term: ...
|
| 103 |
+
def __eq__(self, other: float | Variable | Term | Expression) -> Constraint: ... # type: ignore
|
| 104 |
+
def __ge__(self, other: float | Variable | Term | Expression) -> Constraint: ...
|
| 105 |
+
def __le__(self, other: float | Variable | Term | Expression) -> Constraint: ...
|
| 106 |
+
def __ne__(self, other: Any) -> NoReturn: ...
|
| 107 |
+
def __gt__(self, other: Any) -> NoReturn: ...
|
| 108 |
+
def __lt__(self, other: Any) -> NoReturn: ...
|
| 109 |
+
|
| 110 |
+
class Expression:
|
| 111 |
+
"""Sum of terms and an additional constant."""
|
| 112 |
+
|
| 113 |
+
__hash__: None # type: ignore
|
| 114 |
+
def __init__(
|
| 115 |
+
self, terms: Iterable[Term], constant: int | float = 0.0, /
|
| 116 |
+
) -> None: ...
|
| 117 |
+
def constant(self) -> float:
|
| 118 |
+
"" "Get the constant for the expression." ""
|
| 119 |
+
...
|
| 120 |
+
def terms(self) -> Tuple[Term, ...]:
|
| 121 |
+
"""Get the tuple of terms for the expression."""
|
| 122 |
+
...
|
| 123 |
+
def value(self) -> float:
|
| 124 |
+
"""Get the value for the expression."""
|
| 125 |
+
...
|
| 126 |
+
def __neg__(self) -> Expression: ...
|
| 127 |
+
def __add__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 128 |
+
def __radd__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 129 |
+
def __sub__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 130 |
+
def __rsub__(self, other: float | Variable | Term | Expression) -> Expression: ...
|
| 131 |
+
def __mul__(self, other: float) -> Expression: ...
|
| 132 |
+
def __rmul__(self, other: float) -> Expression: ...
|
| 133 |
+
def __truediv__(self, other: float) -> Expression: ...
|
| 134 |
+
def __rtruediv__(self, other: float) -> Expression: ...
|
| 135 |
+
def __eq__(self, other: float | Variable | Term | Expression) -> Constraint: ... # type: ignore
|
| 136 |
+
def __ge__(self, other: float | Variable | Term | Expression) -> Constraint: ...
|
| 137 |
+
def __le__(self, other: float | Variable | Term | Expression) -> Constraint: ...
|
| 138 |
+
def __ne__(self, other: Any) -> NoReturn: ...
|
| 139 |
+
def __gt__(self, other: Any) -> NoReturn: ...
|
| 140 |
+
def __lt__(self, other: Any) -> NoReturn: ...
|
| 141 |
+
|
| 142 |
+
class Constraint:
|
| 143 |
+
def __init__(
|
| 144 |
+
self,
|
| 145 |
+
expression: Expression,
|
| 146 |
+
op: Literal["=="] | Literal["<="] | Literal[">="],
|
| 147 |
+
strength: float
|
| 148 |
+
| Literal["weak"]
|
| 149 |
+
| Literal["medium"]
|
| 150 |
+
| Literal["strong"]
|
| 151 |
+
| Literal["required"] = "required",
|
| 152 |
+
/,
|
| 153 |
+
) -> None: ...
|
| 154 |
+
def expression(self) -> Expression:
|
| 155 |
+
"""Get the expression object for the constraint."""
|
| 156 |
+
...
|
| 157 |
+
def op(self) -> Literal["=="] | Literal["<="] | Literal[">="]:
|
| 158 |
+
"""Get the relational operator for the constraint."""
|
| 159 |
+
...
|
| 160 |
+
def strength(self) -> float:
|
| 161 |
+
"""Get the strength for the constraint."""
|
| 162 |
+
...
|
| 163 |
+
def violated(self) -> bool:
|
| 164 |
+
"""Indicate if the constraint is violated in teh current state of the solver."""
|
| 165 |
+
...
|
| 166 |
+
def __or__(
|
| 167 |
+
self,
|
| 168 |
+
other: float
|
| 169 |
+
| Literal["weak"]
|
| 170 |
+
| Literal["medium"]
|
| 171 |
+
| Literal["strong"]
|
| 172 |
+
| Literal["required"],
|
| 173 |
+
) -> Constraint: ...
|
| 174 |
+
def __ror__(
|
| 175 |
+
self,
|
| 176 |
+
other: float
|
| 177 |
+
| Literal["weak"]
|
| 178 |
+
| Literal["medium"]
|
| 179 |
+
| Literal["strong"]
|
| 180 |
+
| Literal["required"],
|
| 181 |
+
) -> Constraint: ...
|
| 182 |
+
|
| 183 |
+
class Solver:
|
| 184 |
+
"""Kiwi solver class."""
|
| 185 |
+
|
| 186 |
+
def __init__(self) -> None: ...
|
| 187 |
+
def addConstraint(self, constraint: Constraint, /) -> None:
|
| 188 |
+
"""Add a constraint to the solver."""
|
| 189 |
+
...
|
| 190 |
+
def removeConstraint(self, constraint: Constraint, /) -> None:
|
| 191 |
+
"""Remove a constraint from the solver."""
|
| 192 |
+
...
|
| 193 |
+
def hasConstraint(self, constraint: Constraint, /) -> bool:
|
| 194 |
+
"""Check whether the solver contains a constraint."""
|
| 195 |
+
...
|
| 196 |
+
def addEditVariable(
|
| 197 |
+
self,
|
| 198 |
+
variable: Variable,
|
| 199 |
+
strength: float
|
| 200 |
+
| Literal["weak"]
|
| 201 |
+
| Literal["medium"]
|
| 202 |
+
| Literal["strong"]
|
| 203 |
+
| Literal["required"],
|
| 204 |
+
/,
|
| 205 |
+
) -> None:
|
| 206 |
+
"""Add an edit variable to the solver."""
|
| 207 |
+
...
|
| 208 |
+
def removeEditVariable(self, variable: Variable, /) -> None:
|
| 209 |
+
"""Remove an edit variable from the solver."""
|
| 210 |
+
...
|
| 211 |
+
def hasEditVariable(self, variable: Variable, /) -> bool:
|
| 212 |
+
"""Check whether the solver contains an edit variable."""
|
| 213 |
+
...
|
| 214 |
+
def suggestValue(self, variable: Variable, value: int | float, /) -> None:
|
| 215 |
+
"""Suggest a desired value for an edit variable."""
|
| 216 |
+
...
|
| 217 |
+
def updateVariables(self) -> None:
|
| 218 |
+
"""Update the values of the solver variables."""
|
| 219 |
+
...
|
| 220 |
+
def reset(self) -> None:
|
| 221 |
+
"""Reset the solver to the initial empty starting condition."""
|
| 222 |
+
...
|
| 223 |
+
def dump(self) -> None:
|
| 224 |
+
"""Dump a representation of the solver internals to stdout."""
|
| 225 |
+
...
|
| 226 |
+
def dumps(self) -> str:
|
| 227 |
+
"""Dump a representation of the solver internals to a string."""
|
| 228 |
+
...
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/kiwisolver/exceptions.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# --------------------------------------------------------------------------------------
|
| 2 |
+
# Copyright (c) 2023-2024, Nucleic Development Team.
|
| 3 |
+
#
|
| 4 |
+
# Distributed under the terms of the Modified BSD License.
|
| 5 |
+
#
|
| 6 |
+
# The full license is in the file LICENSE, distributed with this software.
|
| 7 |
+
# --------------------------------------------------------------------------------------
|
| 8 |
+
"""Kiwi exceptions.
|
| 9 |
+
|
| 10 |
+
Imported by the kiwisolver C extension.
|
| 11 |
+
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class BadRequiredStrength(Exception):
|
| 16 |
+
pass
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class DuplicateConstraint(Exception):
|
| 20 |
+
__slots__ = ("constraint",)
|
| 21 |
+
|
| 22 |
+
def __init__(self, constraint):
|
| 23 |
+
self.constraint = constraint
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class DuplicateEditVariable(Exception):
|
| 27 |
+
__slots__ = ("edit_variable",)
|
| 28 |
+
|
| 29 |
+
def __init__(self, edit_variable):
|
| 30 |
+
self.edit_variable = edit_variable
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
class UnknownConstraint(Exception):
|
| 34 |
+
__slots__ = ("constraint",)
|
| 35 |
+
|
| 36 |
+
def __init__(self, constraint):
|
| 37 |
+
self.constraint = constraint
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class UnknownEditVariable(Exception):
|
| 41 |
+
__slots__ = ("edit_variable",)
|
| 42 |
+
|
| 43 |
+
def __init__(self, edit_variable):
|
| 44 |
+
self.edit_variable = edit_variable
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
class UnsatisfiableConstraint(Exception):
|
| 48 |
+
__slots__ = ("constraint",)
|
| 49 |
+
|
| 50 |
+
def __init__(self, constraint):
|
| 51 |
+
self.constraint = constraint
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/requests_oauthlib/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (765 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth1_auth.cpython-310.pyc
ADDED
|
Binary file (2.5 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth1_session.cpython-310.pyc
ADDED
|
Binary file (16.4 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth2_auth.cpython-310.pyc
ADDED
|
Binary file (1.89 kB). View file
|
|
|