Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_betweenness_centrality_subset.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_current_flow_betweenness_centrality.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_dispersion.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_group.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_harmonic_centrality.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_laplacian_centrality.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_load_centrality.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_percolation_centrality.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_second_order_centrality.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_trophic.cpython-310.pyc +0 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality.py +197 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_current_flow_closeness.py +43 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_second_order_centrality.py +82 -0
- llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_trophic.py +302 -0
- vlmpy310/lib/python3.10/site-packages/anyio/_core/__pycache__/_eventloop.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/__init__.py +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/__init__.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/buffered.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/file.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/memory.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/stapled.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/text.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/tls.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/buffered.py +119 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/file.py +148 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/memory.py +317 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/stapled.py +141 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/text.py +147 -0
- vlmpy310/lib/python3.10/site-packages/anyio/streams/tls.py +337 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/1601.4154c4f9ed460feae33b.js.map +1 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/221.21b91ccc95eefd849fa5.js +136 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/2323.af9daee5d184a74db8a4.js +0 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/2913.274b19d8f201991f4a69.js +0 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/32792104b5ef69eded90.woff +0 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/6521.95f93bd416d53955c700.js +12 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/72bc573386dd1d48c5bb.woff +0 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/8979.cafa00ee6b2e82b39a17.js +250 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/899.5a5d6e7bd36baebe76af.js +277 -0
- vlmpy310/lib/python3.10/site-packages/notebook/static/9239.7bc21a4d374e6777cceb.js.map +1 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/__init__.py +100 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/__init__.pyi +1238 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/__pycache__/__init__.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/decoders/__init__.py +15 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/decoders/__init__.pyi +279 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/decoders/__pycache__/__init__.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__init__.py +6 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__pycache__/__init__.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__pycache__/base_tokenizer.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__pycache__/bert_wordpiece.cpython-310.pyc +0 -0
- vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__pycache__/byte_level_bpe.cpython-310.pyc +0 -0
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_betweenness_centrality_subset.cpython-310.pyc
ADDED
|
Binary file (10.9 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_current_flow_betweenness_centrality.cpython-310.pyc
ADDED
|
Binary file (7.97 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_dispersion.cpython-310.pyc
ADDED
|
Binary file (2.26 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_group.cpython-310.pyc
ADDED
|
Binary file (10.1 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_harmonic_centrality.cpython-310.pyc
ADDED
|
Binary file (5.34 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_laplacian_centrality.cpython-310.pyc
ADDED
|
Binary file (6.05 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_load_centrality.cpython-310.pyc
ADDED
|
Binary file (9.54 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_percolation_centrality.cpython-310.pyc
ADDED
|
Binary file (2.74 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_second_order_centrality.cpython-310.pyc
ADDED
|
Binary file (2.78 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/__pycache__/test_trophic.cpython-310.pyc
ADDED
|
Binary file (7.14 kB). View file
|
|
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_current_flow_betweenness_centrality.py
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
import networkx as nx
|
| 4 |
+
from networkx import approximate_current_flow_betweenness_centrality as approximate_cfbc
|
| 5 |
+
from networkx import edge_current_flow_betweenness_centrality as edge_current_flow
|
| 6 |
+
|
| 7 |
+
np = pytest.importorskip("numpy")
|
| 8 |
+
pytest.importorskip("scipy")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class TestFlowBetweennessCentrality:
|
| 12 |
+
def test_K4_normalized(self):
|
| 13 |
+
"""Betweenness centrality: K4"""
|
| 14 |
+
G = nx.complete_graph(4)
|
| 15 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True)
|
| 16 |
+
b_answer = {0: 0.25, 1: 0.25, 2: 0.25, 3: 0.25}
|
| 17 |
+
for n in sorted(G):
|
| 18 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 19 |
+
G.add_edge(0, 1, weight=0.5, other=0.3)
|
| 20 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True, weight=None)
|
| 21 |
+
for n in sorted(G):
|
| 22 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 23 |
+
wb_answer = {0: 0.2222222, 1: 0.2222222, 2: 0.30555555, 3: 0.30555555}
|
| 24 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True, weight="weight")
|
| 25 |
+
for n in sorted(G):
|
| 26 |
+
assert b[n] == pytest.approx(wb_answer[n], abs=1e-7)
|
| 27 |
+
wb_answer = {0: 0.2051282, 1: 0.2051282, 2: 0.33974358, 3: 0.33974358}
|
| 28 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True, weight="other")
|
| 29 |
+
for n in sorted(G):
|
| 30 |
+
assert b[n] == pytest.approx(wb_answer[n], abs=1e-7)
|
| 31 |
+
|
| 32 |
+
def test_K4(self):
|
| 33 |
+
"""Betweenness centrality: K4"""
|
| 34 |
+
G = nx.complete_graph(4)
|
| 35 |
+
for solver in ["full", "lu", "cg"]:
|
| 36 |
+
b = nx.current_flow_betweenness_centrality(
|
| 37 |
+
G, normalized=False, solver=solver
|
| 38 |
+
)
|
| 39 |
+
b_answer = {0: 0.75, 1: 0.75, 2: 0.75, 3: 0.75}
|
| 40 |
+
for n in sorted(G):
|
| 41 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 42 |
+
|
| 43 |
+
def test_P4_normalized(self):
|
| 44 |
+
"""Betweenness centrality: P4 normalized"""
|
| 45 |
+
G = nx.path_graph(4)
|
| 46 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True)
|
| 47 |
+
b_answer = {0: 0, 1: 2.0 / 3, 2: 2.0 / 3, 3: 0}
|
| 48 |
+
for n in sorted(G):
|
| 49 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 50 |
+
|
| 51 |
+
def test_P4(self):
|
| 52 |
+
"""Betweenness centrality: P4"""
|
| 53 |
+
G = nx.path_graph(4)
|
| 54 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=False)
|
| 55 |
+
b_answer = {0: 0, 1: 2, 2: 2, 3: 0}
|
| 56 |
+
for n in sorted(G):
|
| 57 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 58 |
+
|
| 59 |
+
def test_star(self):
|
| 60 |
+
"""Betweenness centrality: star"""
|
| 61 |
+
G = nx.Graph()
|
| 62 |
+
nx.add_star(G, ["a", "b", "c", "d"])
|
| 63 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True)
|
| 64 |
+
b_answer = {"a": 1.0, "b": 0.0, "c": 0.0, "d": 0.0}
|
| 65 |
+
for n in sorted(G):
|
| 66 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 67 |
+
|
| 68 |
+
def test_solvers2(self):
|
| 69 |
+
"""Betweenness centrality: alternate solvers"""
|
| 70 |
+
G = nx.complete_graph(4)
|
| 71 |
+
for solver in ["full", "lu", "cg"]:
|
| 72 |
+
b = nx.current_flow_betweenness_centrality(
|
| 73 |
+
G, normalized=False, solver=solver
|
| 74 |
+
)
|
| 75 |
+
b_answer = {0: 0.75, 1: 0.75, 2: 0.75, 3: 0.75}
|
| 76 |
+
for n in sorted(G):
|
| 77 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class TestApproximateFlowBetweennessCentrality:
|
| 81 |
+
def test_K4_normalized(self):
|
| 82 |
+
"Approximate current-flow betweenness centrality: K4 normalized"
|
| 83 |
+
G = nx.complete_graph(4)
|
| 84 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True)
|
| 85 |
+
epsilon = 0.1
|
| 86 |
+
ba = approximate_cfbc(G, normalized=True, epsilon=0.5 * epsilon)
|
| 87 |
+
for n in sorted(G):
|
| 88 |
+
np.testing.assert_allclose(b[n], ba[n], atol=epsilon)
|
| 89 |
+
|
| 90 |
+
def test_K4(self):
|
| 91 |
+
"Approximate current-flow betweenness centrality: K4"
|
| 92 |
+
G = nx.complete_graph(4)
|
| 93 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=False)
|
| 94 |
+
epsilon = 0.1
|
| 95 |
+
ba = approximate_cfbc(G, normalized=False, epsilon=0.5 * epsilon)
|
| 96 |
+
for n in sorted(G):
|
| 97 |
+
np.testing.assert_allclose(b[n], ba[n], atol=epsilon * len(G) ** 2)
|
| 98 |
+
|
| 99 |
+
def test_star(self):
|
| 100 |
+
"Approximate current-flow betweenness centrality: star"
|
| 101 |
+
G = nx.Graph()
|
| 102 |
+
nx.add_star(G, ["a", "b", "c", "d"])
|
| 103 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True)
|
| 104 |
+
epsilon = 0.1
|
| 105 |
+
ba = approximate_cfbc(G, normalized=True, epsilon=0.5 * epsilon)
|
| 106 |
+
for n in sorted(G):
|
| 107 |
+
np.testing.assert_allclose(b[n], ba[n], atol=epsilon)
|
| 108 |
+
|
| 109 |
+
def test_grid(self):
|
| 110 |
+
"Approximate current-flow betweenness centrality: 2d grid"
|
| 111 |
+
G = nx.grid_2d_graph(4, 4)
|
| 112 |
+
b = nx.current_flow_betweenness_centrality(G, normalized=True)
|
| 113 |
+
epsilon = 0.1
|
| 114 |
+
ba = approximate_cfbc(G, normalized=True, epsilon=0.5 * epsilon)
|
| 115 |
+
for n in sorted(G):
|
| 116 |
+
np.testing.assert_allclose(b[n], ba[n], atol=epsilon)
|
| 117 |
+
|
| 118 |
+
def test_seed(self):
|
| 119 |
+
G = nx.complete_graph(4)
|
| 120 |
+
b = approximate_cfbc(G, normalized=False, epsilon=0.05, seed=1)
|
| 121 |
+
b_answer = {0: 0.75, 1: 0.75, 2: 0.75, 3: 0.75}
|
| 122 |
+
for n in sorted(G):
|
| 123 |
+
np.testing.assert_allclose(b[n], b_answer[n], atol=0.1)
|
| 124 |
+
|
| 125 |
+
def test_solvers(self):
|
| 126 |
+
"Approximate current-flow betweenness centrality: solvers"
|
| 127 |
+
G = nx.complete_graph(4)
|
| 128 |
+
epsilon = 0.1
|
| 129 |
+
for solver in ["full", "lu", "cg"]:
|
| 130 |
+
b = approximate_cfbc(
|
| 131 |
+
G, normalized=False, solver=solver, epsilon=0.5 * epsilon
|
| 132 |
+
)
|
| 133 |
+
b_answer = {0: 0.75, 1: 0.75, 2: 0.75, 3: 0.75}
|
| 134 |
+
for n in sorted(G):
|
| 135 |
+
np.testing.assert_allclose(b[n], b_answer[n], atol=epsilon)
|
| 136 |
+
|
| 137 |
+
def test_lower_kmax(self):
|
| 138 |
+
G = nx.complete_graph(4)
|
| 139 |
+
with pytest.raises(nx.NetworkXError, match="Increase kmax or epsilon"):
|
| 140 |
+
nx.approximate_current_flow_betweenness_centrality(G, kmax=4)
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
class TestWeightedFlowBetweennessCentrality:
|
| 144 |
+
pass
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class TestEdgeFlowBetweennessCentrality:
|
| 148 |
+
def test_K4(self):
|
| 149 |
+
"""Edge flow betweenness centrality: K4"""
|
| 150 |
+
G = nx.complete_graph(4)
|
| 151 |
+
b = edge_current_flow(G, normalized=True)
|
| 152 |
+
b_answer = dict.fromkeys(G.edges(), 0.25)
|
| 153 |
+
for (s, t), v1 in b_answer.items():
|
| 154 |
+
v2 = b.get((s, t), b.get((t, s)))
|
| 155 |
+
assert v1 == pytest.approx(v2, abs=1e-7)
|
| 156 |
+
|
| 157 |
+
def test_K4_normalized(self):
|
| 158 |
+
"""Edge flow betweenness centrality: K4"""
|
| 159 |
+
G = nx.complete_graph(4)
|
| 160 |
+
b = edge_current_flow(G, normalized=False)
|
| 161 |
+
b_answer = dict.fromkeys(G.edges(), 0.75)
|
| 162 |
+
for (s, t), v1 in b_answer.items():
|
| 163 |
+
v2 = b.get((s, t), b.get((t, s)))
|
| 164 |
+
assert v1 == pytest.approx(v2, abs=1e-7)
|
| 165 |
+
|
| 166 |
+
def test_C4(self):
|
| 167 |
+
"""Edge flow betweenness centrality: C4"""
|
| 168 |
+
G = nx.cycle_graph(4)
|
| 169 |
+
b = edge_current_flow(G, normalized=False)
|
| 170 |
+
b_answer = {(0, 1): 1.25, (0, 3): 1.25, (1, 2): 1.25, (2, 3): 1.25}
|
| 171 |
+
for (s, t), v1 in b_answer.items():
|
| 172 |
+
v2 = b.get((s, t), b.get((t, s)))
|
| 173 |
+
assert v1 == pytest.approx(v2, abs=1e-7)
|
| 174 |
+
|
| 175 |
+
def test_P4(self):
|
| 176 |
+
"""Edge betweenness centrality: P4"""
|
| 177 |
+
G = nx.path_graph(4)
|
| 178 |
+
b = edge_current_flow(G, normalized=False)
|
| 179 |
+
b_answer = {(0, 1): 1.5, (1, 2): 2.0, (2, 3): 1.5}
|
| 180 |
+
for (s, t), v1 in b_answer.items():
|
| 181 |
+
v2 = b.get((s, t), b.get((t, s)))
|
| 182 |
+
assert v1 == pytest.approx(v2, abs=1e-7)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
@pytest.mark.parametrize(
|
| 186 |
+
"centrality_func",
|
| 187 |
+
(
|
| 188 |
+
nx.current_flow_betweenness_centrality,
|
| 189 |
+
nx.edge_current_flow_betweenness_centrality,
|
| 190 |
+
nx.approximate_current_flow_betweenness_centrality,
|
| 191 |
+
),
|
| 192 |
+
)
|
| 193 |
+
def test_unconnected_graphs_betweenness_centrality(centrality_func):
|
| 194 |
+
G = nx.Graph([(1, 2), (3, 4)])
|
| 195 |
+
G.add_node(5)
|
| 196 |
+
with pytest.raises(nx.NetworkXError, match="Graph not connected"):
|
| 197 |
+
centrality_func(G)
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_current_flow_closeness.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
|
| 3 |
+
pytest.importorskip("numpy")
|
| 4 |
+
pytest.importorskip("scipy")
|
| 5 |
+
|
| 6 |
+
import networkx as nx
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class TestFlowClosenessCentrality:
|
| 10 |
+
def test_K4(self):
|
| 11 |
+
"""Closeness centrality: K4"""
|
| 12 |
+
G = nx.complete_graph(4)
|
| 13 |
+
b = nx.current_flow_closeness_centrality(G)
|
| 14 |
+
b_answer = {0: 2.0 / 3, 1: 2.0 / 3, 2: 2.0 / 3, 3: 2.0 / 3}
|
| 15 |
+
for n in sorted(G):
|
| 16 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 17 |
+
|
| 18 |
+
def test_P4(self):
|
| 19 |
+
"""Closeness centrality: P4"""
|
| 20 |
+
G = nx.path_graph(4)
|
| 21 |
+
b = nx.current_flow_closeness_centrality(G)
|
| 22 |
+
b_answer = {0: 1.0 / 6, 1: 1.0 / 4, 2: 1.0 / 4, 3: 1.0 / 6}
|
| 23 |
+
for n in sorted(G):
|
| 24 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 25 |
+
|
| 26 |
+
def test_star(self):
|
| 27 |
+
"""Closeness centrality: star"""
|
| 28 |
+
G = nx.Graph()
|
| 29 |
+
nx.add_star(G, ["a", "b", "c", "d"])
|
| 30 |
+
b = nx.current_flow_closeness_centrality(G)
|
| 31 |
+
b_answer = {"a": 1.0 / 3, "b": 0.6 / 3, "c": 0.6 / 3, "d": 0.6 / 3}
|
| 32 |
+
for n in sorted(G):
|
| 33 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-7)
|
| 34 |
+
|
| 35 |
+
def test_current_flow_closeness_centrality_not_connected(self):
|
| 36 |
+
G = nx.Graph()
|
| 37 |
+
G.add_nodes_from([1, 2, 3])
|
| 38 |
+
with pytest.raises(nx.NetworkXError):
|
| 39 |
+
nx.current_flow_closeness_centrality(G)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class TestWeightedFlowClosenessCentrality:
|
| 43 |
+
pass
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_second_order_centrality.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Tests for second order centrality.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import pytest
|
| 6 |
+
|
| 7 |
+
pytest.importorskip("numpy")
|
| 8 |
+
pytest.importorskip("scipy")
|
| 9 |
+
|
| 10 |
+
import networkx as nx
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def test_empty():
|
| 14 |
+
with pytest.raises(nx.NetworkXException):
|
| 15 |
+
G = nx.empty_graph()
|
| 16 |
+
nx.second_order_centrality(G)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def test_non_connected():
|
| 20 |
+
with pytest.raises(nx.NetworkXException):
|
| 21 |
+
G = nx.Graph()
|
| 22 |
+
G.add_node(0)
|
| 23 |
+
G.add_node(1)
|
| 24 |
+
nx.second_order_centrality(G)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def test_non_negative_edge_weights():
|
| 28 |
+
with pytest.raises(nx.NetworkXException):
|
| 29 |
+
G = nx.path_graph(2)
|
| 30 |
+
G.add_edge(0, 1, weight=-1)
|
| 31 |
+
nx.second_order_centrality(G)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def test_weight_attribute():
|
| 35 |
+
G = nx.Graph()
|
| 36 |
+
G.add_weighted_edges_from([(0, 1, 1.0), (1, 2, 3.5)], weight="w")
|
| 37 |
+
expected = {0: 3.431, 1: 3.082, 2: 5.612}
|
| 38 |
+
b = nx.second_order_centrality(G, weight="w")
|
| 39 |
+
|
| 40 |
+
for n in sorted(G):
|
| 41 |
+
assert b[n] == pytest.approx(expected[n], abs=1e-2)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def test_one_node_graph():
|
| 45 |
+
"""Second order centrality: single node"""
|
| 46 |
+
G = nx.Graph()
|
| 47 |
+
G.add_node(0)
|
| 48 |
+
G.add_edge(0, 0)
|
| 49 |
+
assert nx.second_order_centrality(G)[0] == 0
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def test_P3():
|
| 53 |
+
"""Second order centrality: line graph, as defined in paper"""
|
| 54 |
+
G = nx.path_graph(3)
|
| 55 |
+
b_answer = {0: 3.741, 1: 1.414, 2: 3.741}
|
| 56 |
+
|
| 57 |
+
b = nx.second_order_centrality(G)
|
| 58 |
+
|
| 59 |
+
for n in sorted(G):
|
| 60 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-2)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def test_K3():
|
| 64 |
+
"""Second order centrality: complete graph, as defined in paper"""
|
| 65 |
+
G = nx.complete_graph(3)
|
| 66 |
+
b_answer = {0: 1.414, 1: 1.414, 2: 1.414}
|
| 67 |
+
|
| 68 |
+
b = nx.second_order_centrality(G)
|
| 69 |
+
|
| 70 |
+
for n in sorted(G):
|
| 71 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-2)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def test_ring_graph():
|
| 75 |
+
"""Second order centrality: ring graph, as defined in paper"""
|
| 76 |
+
G = nx.cycle_graph(5)
|
| 77 |
+
b_answer = {0: 4.472, 1: 4.472, 2: 4.472, 3: 4.472, 4: 4.472}
|
| 78 |
+
|
| 79 |
+
b = nx.second_order_centrality(G)
|
| 80 |
+
|
| 81 |
+
for n in sorted(G):
|
| 82 |
+
assert b[n] == pytest.approx(b_answer[n], abs=1e-2)
|
llava_next/lib/python3.10/site-packages/networkx/algorithms/centrality/tests/test_trophic.py
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Test trophic levels, trophic differences and trophic coherence"""
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
|
| 5 |
+
np = pytest.importorskip("numpy")
|
| 6 |
+
pytest.importorskip("scipy")
|
| 7 |
+
|
| 8 |
+
import networkx as nx
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def test_trophic_levels():
|
| 12 |
+
"""Trivial example"""
|
| 13 |
+
G = nx.DiGraph()
|
| 14 |
+
G.add_edge("a", "b")
|
| 15 |
+
G.add_edge("b", "c")
|
| 16 |
+
|
| 17 |
+
d = nx.trophic_levels(G)
|
| 18 |
+
assert d == {"a": 1, "b": 2, "c": 3}
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def test_trophic_levels_levine():
|
| 22 |
+
"""Example from Figure 5 in Stephen Levine (1980) J. theor. Biol. 83,
|
| 23 |
+
195-207
|
| 24 |
+
"""
|
| 25 |
+
S = nx.DiGraph()
|
| 26 |
+
S.add_edge(1, 2, weight=1.0)
|
| 27 |
+
S.add_edge(1, 3, weight=0.2)
|
| 28 |
+
S.add_edge(1, 4, weight=0.8)
|
| 29 |
+
S.add_edge(2, 3, weight=0.2)
|
| 30 |
+
S.add_edge(2, 5, weight=0.3)
|
| 31 |
+
S.add_edge(4, 3, weight=0.6)
|
| 32 |
+
S.add_edge(4, 5, weight=0.7)
|
| 33 |
+
S.add_edge(5, 4, weight=0.2)
|
| 34 |
+
|
| 35 |
+
# save copy for later, test intermediate implementation details first
|
| 36 |
+
S2 = S.copy()
|
| 37 |
+
|
| 38 |
+
# drop nodes of in-degree zero
|
| 39 |
+
z = [nid for nid, d in S.in_degree if d == 0]
|
| 40 |
+
for nid in z:
|
| 41 |
+
S.remove_node(nid)
|
| 42 |
+
|
| 43 |
+
# find adjacency matrix
|
| 44 |
+
q = nx.linalg.graphmatrix.adjacency_matrix(S).T
|
| 45 |
+
|
| 46 |
+
# fmt: off
|
| 47 |
+
expected_q = np.array([
|
| 48 |
+
[0, 0, 0., 0],
|
| 49 |
+
[0.2, 0, 0.6, 0],
|
| 50 |
+
[0, 0, 0, 0.2],
|
| 51 |
+
[0.3, 0, 0.7, 0]
|
| 52 |
+
])
|
| 53 |
+
# fmt: on
|
| 54 |
+
assert np.array_equal(q.todense(), expected_q)
|
| 55 |
+
|
| 56 |
+
# must be square, size of number of nodes
|
| 57 |
+
assert len(q.shape) == 2
|
| 58 |
+
assert q.shape[0] == q.shape[1]
|
| 59 |
+
assert q.shape[0] == len(S)
|
| 60 |
+
|
| 61 |
+
nn = q.shape[0]
|
| 62 |
+
|
| 63 |
+
i = np.eye(nn)
|
| 64 |
+
n = np.linalg.inv(i - q)
|
| 65 |
+
y = np.asarray(n) @ np.ones(nn)
|
| 66 |
+
|
| 67 |
+
expected_y = np.array([1, 2.07906977, 1.46511628, 2.3255814])
|
| 68 |
+
assert np.allclose(y, expected_y)
|
| 69 |
+
|
| 70 |
+
expected_d = {1: 1, 2: 2, 3: 3.07906977, 4: 2.46511628, 5: 3.3255814}
|
| 71 |
+
|
| 72 |
+
d = nx.trophic_levels(S2)
|
| 73 |
+
|
| 74 |
+
for nid, level in d.items():
|
| 75 |
+
expected_level = expected_d[nid]
|
| 76 |
+
assert expected_level == pytest.approx(level, abs=1e-7)
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def test_trophic_levels_simple():
|
| 80 |
+
matrix_a = np.array([[0, 0], [1, 0]])
|
| 81 |
+
G = nx.from_numpy_array(matrix_a, create_using=nx.DiGraph)
|
| 82 |
+
d = nx.trophic_levels(G)
|
| 83 |
+
assert d[0] == pytest.approx(2, abs=1e-7)
|
| 84 |
+
assert d[1] == pytest.approx(1, abs=1e-7)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def test_trophic_levels_more_complex():
|
| 88 |
+
# fmt: off
|
| 89 |
+
matrix = np.array([
|
| 90 |
+
[0, 1, 0, 0],
|
| 91 |
+
[0, 0, 1, 0],
|
| 92 |
+
[0, 0, 0, 1],
|
| 93 |
+
[0, 0, 0, 0]
|
| 94 |
+
])
|
| 95 |
+
# fmt: on
|
| 96 |
+
G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
|
| 97 |
+
d = nx.trophic_levels(G)
|
| 98 |
+
expected_result = [1, 2, 3, 4]
|
| 99 |
+
for ind in range(4):
|
| 100 |
+
assert d[ind] == pytest.approx(expected_result[ind], abs=1e-7)
|
| 101 |
+
|
| 102 |
+
# fmt: off
|
| 103 |
+
matrix = np.array([
|
| 104 |
+
[0, 1, 1, 0],
|
| 105 |
+
[0, 0, 1, 1],
|
| 106 |
+
[0, 0, 0, 1],
|
| 107 |
+
[0, 0, 0, 0]
|
| 108 |
+
])
|
| 109 |
+
# fmt: on
|
| 110 |
+
G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
|
| 111 |
+
d = nx.trophic_levels(G)
|
| 112 |
+
|
| 113 |
+
expected_result = [1, 2, 2.5, 3.25]
|
| 114 |
+
print("Calculated result: ", d)
|
| 115 |
+
print("Expected Result: ", expected_result)
|
| 116 |
+
|
| 117 |
+
for ind in range(4):
|
| 118 |
+
assert d[ind] == pytest.approx(expected_result[ind], abs=1e-7)
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def test_trophic_levels_even_more_complex():
|
| 122 |
+
# fmt: off
|
| 123 |
+
# Another, bigger matrix
|
| 124 |
+
matrix = np.array([
|
| 125 |
+
[0, 0, 0, 0, 0],
|
| 126 |
+
[0, 1, 0, 1, 0],
|
| 127 |
+
[1, 0, 0, 0, 0],
|
| 128 |
+
[0, 1, 0, 0, 0],
|
| 129 |
+
[0, 0, 0, 1, 0]
|
| 130 |
+
])
|
| 131 |
+
# Generated this linear system using pen and paper:
|
| 132 |
+
K = np.array([
|
| 133 |
+
[1, 0, -1, 0, 0],
|
| 134 |
+
[0, 0.5, 0, -0.5, 0],
|
| 135 |
+
[0, 0, 1, 0, 0],
|
| 136 |
+
[0, -0.5, 0, 1, -0.5],
|
| 137 |
+
[0, 0, 0, 0, 1],
|
| 138 |
+
])
|
| 139 |
+
# fmt: on
|
| 140 |
+
result_1 = np.ravel(np.linalg.inv(K) @ np.ones(5))
|
| 141 |
+
G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
|
| 142 |
+
result_2 = nx.trophic_levels(G)
|
| 143 |
+
|
| 144 |
+
for ind in range(5):
|
| 145 |
+
assert result_1[ind] == pytest.approx(result_2[ind], abs=1e-7)
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def test_trophic_levels_singular_matrix():
|
| 149 |
+
"""Should raise an error with graphs with only non-basal nodes"""
|
| 150 |
+
matrix = np.identity(4)
|
| 151 |
+
G = nx.from_numpy_array(matrix, create_using=nx.DiGraph)
|
| 152 |
+
with pytest.raises(nx.NetworkXError) as e:
|
| 153 |
+
nx.trophic_levels(G)
|
| 154 |
+
msg = (
|
| 155 |
+
"Trophic levels are only defined for graphs where every node "
|
| 156 |
+
+ "has a path from a basal node (basal nodes are nodes with no "
|
| 157 |
+
+ "incoming edges)."
|
| 158 |
+
)
|
| 159 |
+
assert msg in str(e.value)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def test_trophic_levels_singular_with_basal():
|
| 163 |
+
"""Should fail to compute if there are any parts of the graph which are not
|
| 164 |
+
reachable from any basal node (with in-degree zero).
|
| 165 |
+
"""
|
| 166 |
+
G = nx.DiGraph()
|
| 167 |
+
# a has in-degree zero
|
| 168 |
+
G.add_edge("a", "b")
|
| 169 |
+
|
| 170 |
+
# b is one level above a, c and d
|
| 171 |
+
G.add_edge("c", "b")
|
| 172 |
+
G.add_edge("d", "b")
|
| 173 |
+
|
| 174 |
+
# c and d form a loop, neither are reachable from a
|
| 175 |
+
G.add_edge("c", "d")
|
| 176 |
+
G.add_edge("d", "c")
|
| 177 |
+
|
| 178 |
+
with pytest.raises(nx.NetworkXError) as e:
|
| 179 |
+
nx.trophic_levels(G)
|
| 180 |
+
msg = (
|
| 181 |
+
"Trophic levels are only defined for graphs where every node "
|
| 182 |
+
+ "has a path from a basal node (basal nodes are nodes with no "
|
| 183 |
+
+ "incoming edges)."
|
| 184 |
+
)
|
| 185 |
+
assert msg in str(e.value)
|
| 186 |
+
|
| 187 |
+
# if self-loops are allowed, smaller example:
|
| 188 |
+
G = nx.DiGraph()
|
| 189 |
+
G.add_edge("a", "b") # a has in-degree zero
|
| 190 |
+
G.add_edge("c", "b") # b is one level above a and c
|
| 191 |
+
G.add_edge("c", "c") # c has a self-loop
|
| 192 |
+
with pytest.raises(nx.NetworkXError) as e:
|
| 193 |
+
nx.trophic_levels(G)
|
| 194 |
+
msg = (
|
| 195 |
+
"Trophic levels are only defined for graphs where every node "
|
| 196 |
+
+ "has a path from a basal node (basal nodes are nodes with no "
|
| 197 |
+
+ "incoming edges)."
|
| 198 |
+
)
|
| 199 |
+
assert msg in str(e.value)
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
def test_trophic_differences():
|
| 203 |
+
matrix_a = np.array([[0, 1], [0, 0]])
|
| 204 |
+
G = nx.from_numpy_array(matrix_a, create_using=nx.DiGraph)
|
| 205 |
+
diffs = nx.trophic_differences(G)
|
| 206 |
+
assert diffs[(0, 1)] == pytest.approx(1, abs=1e-7)
|
| 207 |
+
|
| 208 |
+
# fmt: off
|
| 209 |
+
matrix_b = np.array([
|
| 210 |
+
[0, 1, 1, 0],
|
| 211 |
+
[0, 0, 1, 1],
|
| 212 |
+
[0, 0, 0, 1],
|
| 213 |
+
[0, 0, 0, 0]
|
| 214 |
+
])
|
| 215 |
+
# fmt: on
|
| 216 |
+
G = nx.from_numpy_array(matrix_b, create_using=nx.DiGraph)
|
| 217 |
+
diffs = nx.trophic_differences(G)
|
| 218 |
+
|
| 219 |
+
assert diffs[(0, 1)] == pytest.approx(1, abs=1e-7)
|
| 220 |
+
assert diffs[(0, 2)] == pytest.approx(1.5, abs=1e-7)
|
| 221 |
+
assert diffs[(1, 2)] == pytest.approx(0.5, abs=1e-7)
|
| 222 |
+
assert diffs[(1, 3)] == pytest.approx(1.25, abs=1e-7)
|
| 223 |
+
assert diffs[(2, 3)] == pytest.approx(0.75, abs=1e-7)
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
def test_trophic_incoherence_parameter_no_cannibalism():
|
| 227 |
+
matrix_a = np.array([[0, 1], [0, 0]])
|
| 228 |
+
G = nx.from_numpy_array(matrix_a, create_using=nx.DiGraph)
|
| 229 |
+
q = nx.trophic_incoherence_parameter(G, cannibalism=False)
|
| 230 |
+
assert q == pytest.approx(0, abs=1e-7)
|
| 231 |
+
|
| 232 |
+
# fmt: off
|
| 233 |
+
matrix_b = np.array([
|
| 234 |
+
[0, 1, 1, 0],
|
| 235 |
+
[0, 0, 1, 1],
|
| 236 |
+
[0, 0, 0, 1],
|
| 237 |
+
[0, 0, 0, 0]
|
| 238 |
+
])
|
| 239 |
+
# fmt: on
|
| 240 |
+
G = nx.from_numpy_array(matrix_b, create_using=nx.DiGraph)
|
| 241 |
+
q = nx.trophic_incoherence_parameter(G, cannibalism=False)
|
| 242 |
+
assert q == pytest.approx(np.std([1, 1.5, 0.5, 0.75, 1.25]), abs=1e-7)
|
| 243 |
+
|
| 244 |
+
# fmt: off
|
| 245 |
+
matrix_c = np.array([
|
| 246 |
+
[0, 1, 1, 0],
|
| 247 |
+
[0, 1, 1, 1],
|
| 248 |
+
[0, 0, 0, 1],
|
| 249 |
+
[0, 0, 0, 1]
|
| 250 |
+
])
|
| 251 |
+
# fmt: on
|
| 252 |
+
G = nx.from_numpy_array(matrix_c, create_using=nx.DiGraph)
|
| 253 |
+
q = nx.trophic_incoherence_parameter(G, cannibalism=False)
|
| 254 |
+
# Ignore the -link
|
| 255 |
+
assert q == pytest.approx(np.std([1, 1.5, 0.5, 0.75, 1.25]), abs=1e-7)
|
| 256 |
+
|
| 257 |
+
# no self-loops case
|
| 258 |
+
# fmt: off
|
| 259 |
+
matrix_d = np.array([
|
| 260 |
+
[0, 1, 1, 0],
|
| 261 |
+
[0, 0, 1, 1],
|
| 262 |
+
[0, 0, 0, 1],
|
| 263 |
+
[0, 0, 0, 0]
|
| 264 |
+
])
|
| 265 |
+
# fmt: on
|
| 266 |
+
G = nx.from_numpy_array(matrix_d, create_using=nx.DiGraph)
|
| 267 |
+
q = nx.trophic_incoherence_parameter(G, cannibalism=False)
|
| 268 |
+
# Ignore the -link
|
| 269 |
+
assert q == pytest.approx(np.std([1, 1.5, 0.5, 0.75, 1.25]), abs=1e-7)
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
def test_trophic_incoherence_parameter_cannibalism():
|
| 273 |
+
matrix_a = np.array([[0, 1], [0, 0]])
|
| 274 |
+
G = nx.from_numpy_array(matrix_a, create_using=nx.DiGraph)
|
| 275 |
+
q = nx.trophic_incoherence_parameter(G, cannibalism=True)
|
| 276 |
+
assert q == pytest.approx(0, abs=1e-7)
|
| 277 |
+
|
| 278 |
+
# fmt: off
|
| 279 |
+
matrix_b = np.array([
|
| 280 |
+
[0, 0, 0, 0, 0],
|
| 281 |
+
[0, 1, 0, 1, 0],
|
| 282 |
+
[1, 0, 0, 0, 0],
|
| 283 |
+
[0, 1, 0, 0, 0],
|
| 284 |
+
[0, 0, 0, 1, 0]
|
| 285 |
+
])
|
| 286 |
+
# fmt: on
|
| 287 |
+
G = nx.from_numpy_array(matrix_b, create_using=nx.DiGraph)
|
| 288 |
+
q = nx.trophic_incoherence_parameter(G, cannibalism=True)
|
| 289 |
+
assert q == pytest.approx(2, abs=1e-7)
|
| 290 |
+
|
| 291 |
+
# fmt: off
|
| 292 |
+
matrix_c = np.array([
|
| 293 |
+
[0, 1, 1, 0],
|
| 294 |
+
[0, 0, 1, 1],
|
| 295 |
+
[0, 0, 0, 1],
|
| 296 |
+
[0, 0, 0, 0]
|
| 297 |
+
])
|
| 298 |
+
# fmt: on
|
| 299 |
+
G = nx.from_numpy_array(matrix_c, create_using=nx.DiGraph)
|
| 300 |
+
q = nx.trophic_incoherence_parameter(G, cannibalism=True)
|
| 301 |
+
# Ignore the -link
|
| 302 |
+
assert q == pytest.approx(np.std([1, 1.5, 0.5, 0.75, 1.25]), abs=1e-7)
|
vlmpy310/lib/python3.10/site-packages/anyio/_core/__pycache__/_eventloop.cpython-310.pyc
ADDED
|
Binary file (4.77 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/__init__.py
ADDED
|
File without changes
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (167 Bytes). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/buffered.cpython-310.pyc
ADDED
|
Binary file (4.08 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/file.cpython-310.pyc
ADDED
|
Binary file (5.52 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/memory.cpython-310.pyc
ADDED
|
Binary file (10 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/stapled.cpython-310.pyc
ADDED
|
Binary file (5.37 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/text.cpython-310.pyc
ADDED
|
Binary file (6.3 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/__pycache__/tls.cpython-310.pyc
ADDED
|
Binary file (10.9 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/buffered.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from collections.abc import Callable, Mapping
|
| 4 |
+
from dataclasses import dataclass, field
|
| 5 |
+
from typing import Any
|
| 6 |
+
|
| 7 |
+
from .. import ClosedResourceError, DelimiterNotFound, EndOfStream, IncompleteRead
|
| 8 |
+
from ..abc import AnyByteReceiveStream, ByteReceiveStream
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
@dataclass(eq=False)
|
| 12 |
+
class BufferedByteReceiveStream(ByteReceiveStream):
|
| 13 |
+
"""
|
| 14 |
+
Wraps any bytes-based receive stream and uses a buffer to provide sophisticated
|
| 15 |
+
receiving capabilities in the form of a byte stream.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
receive_stream: AnyByteReceiveStream
|
| 19 |
+
_buffer: bytearray = field(init=False, default_factory=bytearray)
|
| 20 |
+
_closed: bool = field(init=False, default=False)
|
| 21 |
+
|
| 22 |
+
async def aclose(self) -> None:
|
| 23 |
+
await self.receive_stream.aclose()
|
| 24 |
+
self._closed = True
|
| 25 |
+
|
| 26 |
+
@property
|
| 27 |
+
def buffer(self) -> bytes:
|
| 28 |
+
"""The bytes currently in the buffer."""
|
| 29 |
+
return bytes(self._buffer)
|
| 30 |
+
|
| 31 |
+
@property
|
| 32 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 33 |
+
return self.receive_stream.extra_attributes
|
| 34 |
+
|
| 35 |
+
async def receive(self, max_bytes: int = 65536) -> bytes:
|
| 36 |
+
if self._closed:
|
| 37 |
+
raise ClosedResourceError
|
| 38 |
+
|
| 39 |
+
if self._buffer:
|
| 40 |
+
chunk = bytes(self._buffer[:max_bytes])
|
| 41 |
+
del self._buffer[:max_bytes]
|
| 42 |
+
return chunk
|
| 43 |
+
elif isinstance(self.receive_stream, ByteReceiveStream):
|
| 44 |
+
return await self.receive_stream.receive(max_bytes)
|
| 45 |
+
else:
|
| 46 |
+
# With a bytes-oriented object stream, we need to handle any surplus bytes
|
| 47 |
+
# we get from the receive() call
|
| 48 |
+
chunk = await self.receive_stream.receive()
|
| 49 |
+
if len(chunk) > max_bytes:
|
| 50 |
+
# Save the surplus bytes in the buffer
|
| 51 |
+
self._buffer.extend(chunk[max_bytes:])
|
| 52 |
+
return chunk[:max_bytes]
|
| 53 |
+
else:
|
| 54 |
+
return chunk
|
| 55 |
+
|
| 56 |
+
async def receive_exactly(self, nbytes: int) -> bytes:
|
| 57 |
+
"""
|
| 58 |
+
Read exactly the given amount of bytes from the stream.
|
| 59 |
+
|
| 60 |
+
:param nbytes: the number of bytes to read
|
| 61 |
+
:return: the bytes read
|
| 62 |
+
:raises ~anyio.IncompleteRead: if the stream was closed before the requested
|
| 63 |
+
amount of bytes could be read from the stream
|
| 64 |
+
|
| 65 |
+
"""
|
| 66 |
+
while True:
|
| 67 |
+
remaining = nbytes - len(self._buffer)
|
| 68 |
+
if remaining <= 0:
|
| 69 |
+
retval = self._buffer[:nbytes]
|
| 70 |
+
del self._buffer[:nbytes]
|
| 71 |
+
return bytes(retval)
|
| 72 |
+
|
| 73 |
+
try:
|
| 74 |
+
if isinstance(self.receive_stream, ByteReceiveStream):
|
| 75 |
+
chunk = await self.receive_stream.receive(remaining)
|
| 76 |
+
else:
|
| 77 |
+
chunk = await self.receive_stream.receive()
|
| 78 |
+
except EndOfStream as exc:
|
| 79 |
+
raise IncompleteRead from exc
|
| 80 |
+
|
| 81 |
+
self._buffer.extend(chunk)
|
| 82 |
+
|
| 83 |
+
async def receive_until(self, delimiter: bytes, max_bytes: int) -> bytes:
|
| 84 |
+
"""
|
| 85 |
+
Read from the stream until the delimiter is found or max_bytes have been read.
|
| 86 |
+
|
| 87 |
+
:param delimiter: the marker to look for in the stream
|
| 88 |
+
:param max_bytes: maximum number of bytes that will be read before raising
|
| 89 |
+
:exc:`~anyio.DelimiterNotFound`
|
| 90 |
+
:return: the bytes read (not including the delimiter)
|
| 91 |
+
:raises ~anyio.IncompleteRead: if the stream was closed before the delimiter
|
| 92 |
+
was found
|
| 93 |
+
:raises ~anyio.DelimiterNotFound: if the delimiter is not found within the
|
| 94 |
+
bytes read up to the maximum allowed
|
| 95 |
+
|
| 96 |
+
"""
|
| 97 |
+
delimiter_size = len(delimiter)
|
| 98 |
+
offset = 0
|
| 99 |
+
while True:
|
| 100 |
+
# Check if the delimiter can be found in the current buffer
|
| 101 |
+
index = self._buffer.find(delimiter, offset)
|
| 102 |
+
if index >= 0:
|
| 103 |
+
found = self._buffer[:index]
|
| 104 |
+
del self._buffer[: index + len(delimiter) :]
|
| 105 |
+
return bytes(found)
|
| 106 |
+
|
| 107 |
+
# Check if the buffer is already at or over the limit
|
| 108 |
+
if len(self._buffer) >= max_bytes:
|
| 109 |
+
raise DelimiterNotFound(max_bytes)
|
| 110 |
+
|
| 111 |
+
# Read more data into the buffer from the socket
|
| 112 |
+
try:
|
| 113 |
+
data = await self.receive_stream.receive()
|
| 114 |
+
except EndOfStream as exc:
|
| 115 |
+
raise IncompleteRead from exc
|
| 116 |
+
|
| 117 |
+
# Move the offset forward and add the new data to the buffer
|
| 118 |
+
offset = max(len(self._buffer) - delimiter_size + 1, 0)
|
| 119 |
+
self._buffer.extend(data)
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/file.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from collections.abc import Callable, Mapping
|
| 4 |
+
from io import SEEK_SET, UnsupportedOperation
|
| 5 |
+
from os import PathLike
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Any, BinaryIO, cast
|
| 8 |
+
|
| 9 |
+
from .. import (
|
| 10 |
+
BrokenResourceError,
|
| 11 |
+
ClosedResourceError,
|
| 12 |
+
EndOfStream,
|
| 13 |
+
TypedAttributeSet,
|
| 14 |
+
to_thread,
|
| 15 |
+
typed_attribute,
|
| 16 |
+
)
|
| 17 |
+
from ..abc import ByteReceiveStream, ByteSendStream
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class FileStreamAttribute(TypedAttributeSet):
|
| 21 |
+
#: the open file descriptor
|
| 22 |
+
file: BinaryIO = typed_attribute()
|
| 23 |
+
#: the path of the file on the file system, if available (file must be a real file)
|
| 24 |
+
path: Path = typed_attribute()
|
| 25 |
+
#: the file number, if available (file must be a real file or a TTY)
|
| 26 |
+
fileno: int = typed_attribute()
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class _BaseFileStream:
|
| 30 |
+
def __init__(self, file: BinaryIO):
|
| 31 |
+
self._file = file
|
| 32 |
+
|
| 33 |
+
async def aclose(self) -> None:
|
| 34 |
+
await to_thread.run_sync(self._file.close)
|
| 35 |
+
|
| 36 |
+
@property
|
| 37 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 38 |
+
attributes: dict[Any, Callable[[], Any]] = {
|
| 39 |
+
FileStreamAttribute.file: lambda: self._file,
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if hasattr(self._file, "name"):
|
| 43 |
+
attributes[FileStreamAttribute.path] = lambda: Path(self._file.name)
|
| 44 |
+
|
| 45 |
+
try:
|
| 46 |
+
self._file.fileno()
|
| 47 |
+
except UnsupportedOperation:
|
| 48 |
+
pass
|
| 49 |
+
else:
|
| 50 |
+
attributes[FileStreamAttribute.fileno] = lambda: self._file.fileno()
|
| 51 |
+
|
| 52 |
+
return attributes
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
class FileReadStream(_BaseFileStream, ByteReceiveStream):
|
| 56 |
+
"""
|
| 57 |
+
A byte stream that reads from a file in the file system.
|
| 58 |
+
|
| 59 |
+
:param file: a file that has been opened for reading in binary mode
|
| 60 |
+
|
| 61 |
+
.. versionadded:: 3.0
|
| 62 |
+
"""
|
| 63 |
+
|
| 64 |
+
@classmethod
|
| 65 |
+
async def from_path(cls, path: str | PathLike[str]) -> FileReadStream:
|
| 66 |
+
"""
|
| 67 |
+
Create a file read stream by opening the given file.
|
| 68 |
+
|
| 69 |
+
:param path: path of the file to read from
|
| 70 |
+
|
| 71 |
+
"""
|
| 72 |
+
file = await to_thread.run_sync(Path(path).open, "rb")
|
| 73 |
+
return cls(cast(BinaryIO, file))
|
| 74 |
+
|
| 75 |
+
async def receive(self, max_bytes: int = 65536) -> bytes:
|
| 76 |
+
try:
|
| 77 |
+
data = await to_thread.run_sync(self._file.read, max_bytes)
|
| 78 |
+
except ValueError:
|
| 79 |
+
raise ClosedResourceError from None
|
| 80 |
+
except OSError as exc:
|
| 81 |
+
raise BrokenResourceError from exc
|
| 82 |
+
|
| 83 |
+
if data:
|
| 84 |
+
return data
|
| 85 |
+
else:
|
| 86 |
+
raise EndOfStream
|
| 87 |
+
|
| 88 |
+
async def seek(self, position: int, whence: int = SEEK_SET) -> int:
|
| 89 |
+
"""
|
| 90 |
+
Seek the file to the given position.
|
| 91 |
+
|
| 92 |
+
.. seealso:: :meth:`io.IOBase.seek`
|
| 93 |
+
|
| 94 |
+
.. note:: Not all file descriptors are seekable.
|
| 95 |
+
|
| 96 |
+
:param position: position to seek the file to
|
| 97 |
+
:param whence: controls how ``position`` is interpreted
|
| 98 |
+
:return: the new absolute position
|
| 99 |
+
:raises OSError: if the file is not seekable
|
| 100 |
+
|
| 101 |
+
"""
|
| 102 |
+
return await to_thread.run_sync(self._file.seek, position, whence)
|
| 103 |
+
|
| 104 |
+
async def tell(self) -> int:
|
| 105 |
+
"""
|
| 106 |
+
Return the current stream position.
|
| 107 |
+
|
| 108 |
+
.. note:: Not all file descriptors are seekable.
|
| 109 |
+
|
| 110 |
+
:return: the current absolute position
|
| 111 |
+
:raises OSError: if the file is not seekable
|
| 112 |
+
|
| 113 |
+
"""
|
| 114 |
+
return await to_thread.run_sync(self._file.tell)
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
class FileWriteStream(_BaseFileStream, ByteSendStream):
|
| 118 |
+
"""
|
| 119 |
+
A byte stream that writes to a file in the file system.
|
| 120 |
+
|
| 121 |
+
:param file: a file that has been opened for writing in binary mode
|
| 122 |
+
|
| 123 |
+
.. versionadded:: 3.0
|
| 124 |
+
"""
|
| 125 |
+
|
| 126 |
+
@classmethod
|
| 127 |
+
async def from_path(
|
| 128 |
+
cls, path: str | PathLike[str], append: bool = False
|
| 129 |
+
) -> FileWriteStream:
|
| 130 |
+
"""
|
| 131 |
+
Create a file write stream by opening the given file for writing.
|
| 132 |
+
|
| 133 |
+
:param path: path of the file to write to
|
| 134 |
+
:param append: if ``True``, open the file for appending; if ``False``, any
|
| 135 |
+
existing file at the given path will be truncated
|
| 136 |
+
|
| 137 |
+
"""
|
| 138 |
+
mode = "ab" if append else "wb"
|
| 139 |
+
file = await to_thread.run_sync(Path(path).open, mode)
|
| 140 |
+
return cls(cast(BinaryIO, file))
|
| 141 |
+
|
| 142 |
+
async def send(self, item: bytes) -> None:
|
| 143 |
+
try:
|
| 144 |
+
await to_thread.run_sync(self._file.write, item)
|
| 145 |
+
except ValueError:
|
| 146 |
+
raise ClosedResourceError from None
|
| 147 |
+
except OSError as exc:
|
| 148 |
+
raise BrokenResourceError from exc
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/memory.py
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import warnings
|
| 4 |
+
from collections import OrderedDict, deque
|
| 5 |
+
from dataclasses import dataclass, field
|
| 6 |
+
from types import TracebackType
|
| 7 |
+
from typing import Generic, NamedTuple, TypeVar
|
| 8 |
+
|
| 9 |
+
from .. import (
|
| 10 |
+
BrokenResourceError,
|
| 11 |
+
ClosedResourceError,
|
| 12 |
+
EndOfStream,
|
| 13 |
+
WouldBlock,
|
| 14 |
+
)
|
| 15 |
+
from .._core._testing import TaskInfo, get_current_task
|
| 16 |
+
from ..abc import Event, ObjectReceiveStream, ObjectSendStream
|
| 17 |
+
from ..lowlevel import checkpoint
|
| 18 |
+
|
| 19 |
+
T_Item = TypeVar("T_Item")
|
| 20 |
+
T_co = TypeVar("T_co", covariant=True)
|
| 21 |
+
T_contra = TypeVar("T_contra", contravariant=True)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class MemoryObjectStreamStatistics(NamedTuple):
|
| 25 |
+
current_buffer_used: int #: number of items stored in the buffer
|
| 26 |
+
#: maximum number of items that can be stored on this stream (or :data:`math.inf`)
|
| 27 |
+
max_buffer_size: float
|
| 28 |
+
open_send_streams: int #: number of unclosed clones of the send stream
|
| 29 |
+
open_receive_streams: int #: number of unclosed clones of the receive stream
|
| 30 |
+
#: number of tasks blocked on :meth:`MemoryObjectSendStream.send`
|
| 31 |
+
tasks_waiting_send: int
|
| 32 |
+
#: number of tasks blocked on :meth:`MemoryObjectReceiveStream.receive`
|
| 33 |
+
tasks_waiting_receive: int
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
@dataclass(eq=False)
|
| 37 |
+
class MemoryObjectItemReceiver(Generic[T_Item]):
|
| 38 |
+
task_info: TaskInfo = field(init=False, default_factory=get_current_task)
|
| 39 |
+
item: T_Item = field(init=False)
|
| 40 |
+
|
| 41 |
+
def __repr__(self) -> str:
|
| 42 |
+
# When item is not defined, we get following error with default __repr__:
|
| 43 |
+
# AttributeError: 'MemoryObjectItemReceiver' object has no attribute 'item'
|
| 44 |
+
item = getattr(self, "item", None)
|
| 45 |
+
return f"{self.__class__.__name__}(task_info={self.task_info}, item={item!r})"
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
@dataclass(eq=False)
|
| 49 |
+
class MemoryObjectStreamState(Generic[T_Item]):
|
| 50 |
+
max_buffer_size: float = field()
|
| 51 |
+
buffer: deque[T_Item] = field(init=False, default_factory=deque)
|
| 52 |
+
open_send_channels: int = field(init=False, default=0)
|
| 53 |
+
open_receive_channels: int = field(init=False, default=0)
|
| 54 |
+
waiting_receivers: OrderedDict[Event, MemoryObjectItemReceiver[T_Item]] = field(
|
| 55 |
+
init=False, default_factory=OrderedDict
|
| 56 |
+
)
|
| 57 |
+
waiting_senders: OrderedDict[Event, T_Item] = field(
|
| 58 |
+
init=False, default_factory=OrderedDict
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
def statistics(self) -> MemoryObjectStreamStatistics:
|
| 62 |
+
return MemoryObjectStreamStatistics(
|
| 63 |
+
len(self.buffer),
|
| 64 |
+
self.max_buffer_size,
|
| 65 |
+
self.open_send_channels,
|
| 66 |
+
self.open_receive_channels,
|
| 67 |
+
len(self.waiting_senders),
|
| 68 |
+
len(self.waiting_receivers),
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
@dataclass(eq=False)
|
| 73 |
+
class MemoryObjectReceiveStream(Generic[T_co], ObjectReceiveStream[T_co]):
|
| 74 |
+
_state: MemoryObjectStreamState[T_co]
|
| 75 |
+
_closed: bool = field(init=False, default=False)
|
| 76 |
+
|
| 77 |
+
def __post_init__(self) -> None:
|
| 78 |
+
self._state.open_receive_channels += 1
|
| 79 |
+
|
| 80 |
+
def receive_nowait(self) -> T_co:
|
| 81 |
+
"""
|
| 82 |
+
Receive the next item if it can be done without waiting.
|
| 83 |
+
|
| 84 |
+
:return: the received item
|
| 85 |
+
:raises ~anyio.ClosedResourceError: if this send stream has been closed
|
| 86 |
+
:raises ~anyio.EndOfStream: if the buffer is empty and this stream has been
|
| 87 |
+
closed from the sending end
|
| 88 |
+
:raises ~anyio.WouldBlock: if there are no items in the buffer and no tasks
|
| 89 |
+
waiting to send
|
| 90 |
+
|
| 91 |
+
"""
|
| 92 |
+
if self._closed:
|
| 93 |
+
raise ClosedResourceError
|
| 94 |
+
|
| 95 |
+
if self._state.waiting_senders:
|
| 96 |
+
# Get the item from the next sender
|
| 97 |
+
send_event, item = self._state.waiting_senders.popitem(last=False)
|
| 98 |
+
self._state.buffer.append(item)
|
| 99 |
+
send_event.set()
|
| 100 |
+
|
| 101 |
+
if self._state.buffer:
|
| 102 |
+
return self._state.buffer.popleft()
|
| 103 |
+
elif not self._state.open_send_channels:
|
| 104 |
+
raise EndOfStream
|
| 105 |
+
|
| 106 |
+
raise WouldBlock
|
| 107 |
+
|
| 108 |
+
async def receive(self) -> T_co:
|
| 109 |
+
await checkpoint()
|
| 110 |
+
try:
|
| 111 |
+
return self.receive_nowait()
|
| 112 |
+
except WouldBlock:
|
| 113 |
+
# Add ourselves in the queue
|
| 114 |
+
receive_event = Event()
|
| 115 |
+
receiver = MemoryObjectItemReceiver[T_co]()
|
| 116 |
+
self._state.waiting_receivers[receive_event] = receiver
|
| 117 |
+
|
| 118 |
+
try:
|
| 119 |
+
await receive_event.wait()
|
| 120 |
+
finally:
|
| 121 |
+
self._state.waiting_receivers.pop(receive_event, None)
|
| 122 |
+
|
| 123 |
+
try:
|
| 124 |
+
return receiver.item
|
| 125 |
+
except AttributeError:
|
| 126 |
+
raise EndOfStream
|
| 127 |
+
|
| 128 |
+
def clone(self) -> MemoryObjectReceiveStream[T_co]:
|
| 129 |
+
"""
|
| 130 |
+
Create a clone of this receive stream.
|
| 131 |
+
|
| 132 |
+
Each clone can be closed separately. Only when all clones have been closed will
|
| 133 |
+
the receiving end of the memory stream be considered closed by the sending ends.
|
| 134 |
+
|
| 135 |
+
:return: the cloned stream
|
| 136 |
+
|
| 137 |
+
"""
|
| 138 |
+
if self._closed:
|
| 139 |
+
raise ClosedResourceError
|
| 140 |
+
|
| 141 |
+
return MemoryObjectReceiveStream(_state=self._state)
|
| 142 |
+
|
| 143 |
+
def close(self) -> None:
|
| 144 |
+
"""
|
| 145 |
+
Close the stream.
|
| 146 |
+
|
| 147 |
+
This works the exact same way as :meth:`aclose`, but is provided as a special
|
| 148 |
+
case for the benefit of synchronous callbacks.
|
| 149 |
+
|
| 150 |
+
"""
|
| 151 |
+
if not self._closed:
|
| 152 |
+
self._closed = True
|
| 153 |
+
self._state.open_receive_channels -= 1
|
| 154 |
+
if self._state.open_receive_channels == 0:
|
| 155 |
+
send_events = list(self._state.waiting_senders.keys())
|
| 156 |
+
for event in send_events:
|
| 157 |
+
event.set()
|
| 158 |
+
|
| 159 |
+
async def aclose(self) -> None:
|
| 160 |
+
self.close()
|
| 161 |
+
|
| 162 |
+
def statistics(self) -> MemoryObjectStreamStatistics:
|
| 163 |
+
"""
|
| 164 |
+
Return statistics about the current state of this stream.
|
| 165 |
+
|
| 166 |
+
.. versionadded:: 3.0
|
| 167 |
+
"""
|
| 168 |
+
return self._state.statistics()
|
| 169 |
+
|
| 170 |
+
def __enter__(self) -> MemoryObjectReceiveStream[T_co]:
|
| 171 |
+
return self
|
| 172 |
+
|
| 173 |
+
def __exit__(
|
| 174 |
+
self,
|
| 175 |
+
exc_type: type[BaseException] | None,
|
| 176 |
+
exc_val: BaseException | None,
|
| 177 |
+
exc_tb: TracebackType | None,
|
| 178 |
+
) -> None:
|
| 179 |
+
self.close()
|
| 180 |
+
|
| 181 |
+
def __del__(self) -> None:
|
| 182 |
+
if not self._closed:
|
| 183 |
+
warnings.warn(
|
| 184 |
+
f"Unclosed <{self.__class__.__name__} at {id(self):x}>",
|
| 185 |
+
ResourceWarning,
|
| 186 |
+
source=self,
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
@dataclass(eq=False)
|
| 191 |
+
class MemoryObjectSendStream(Generic[T_contra], ObjectSendStream[T_contra]):
|
| 192 |
+
_state: MemoryObjectStreamState[T_contra]
|
| 193 |
+
_closed: bool = field(init=False, default=False)
|
| 194 |
+
|
| 195 |
+
def __post_init__(self) -> None:
|
| 196 |
+
self._state.open_send_channels += 1
|
| 197 |
+
|
| 198 |
+
def send_nowait(self, item: T_contra) -> None:
|
| 199 |
+
"""
|
| 200 |
+
Send an item immediately if it can be done without waiting.
|
| 201 |
+
|
| 202 |
+
:param item: the item to send
|
| 203 |
+
:raises ~anyio.ClosedResourceError: if this send stream has been closed
|
| 204 |
+
:raises ~anyio.BrokenResourceError: if the stream has been closed from the
|
| 205 |
+
receiving end
|
| 206 |
+
:raises ~anyio.WouldBlock: if the buffer is full and there are no tasks waiting
|
| 207 |
+
to receive
|
| 208 |
+
|
| 209 |
+
"""
|
| 210 |
+
if self._closed:
|
| 211 |
+
raise ClosedResourceError
|
| 212 |
+
if not self._state.open_receive_channels:
|
| 213 |
+
raise BrokenResourceError
|
| 214 |
+
|
| 215 |
+
while self._state.waiting_receivers:
|
| 216 |
+
receive_event, receiver = self._state.waiting_receivers.popitem(last=False)
|
| 217 |
+
if not receiver.task_info.has_pending_cancellation():
|
| 218 |
+
receiver.item = item
|
| 219 |
+
receive_event.set()
|
| 220 |
+
return
|
| 221 |
+
|
| 222 |
+
if len(self._state.buffer) < self._state.max_buffer_size:
|
| 223 |
+
self._state.buffer.append(item)
|
| 224 |
+
else:
|
| 225 |
+
raise WouldBlock
|
| 226 |
+
|
| 227 |
+
async def send(self, item: T_contra) -> None:
|
| 228 |
+
"""
|
| 229 |
+
Send an item to the stream.
|
| 230 |
+
|
| 231 |
+
If the buffer is full, this method blocks until there is again room in the
|
| 232 |
+
buffer or the item can be sent directly to a receiver.
|
| 233 |
+
|
| 234 |
+
:param item: the item to send
|
| 235 |
+
:raises ~anyio.ClosedResourceError: if this send stream has been closed
|
| 236 |
+
:raises ~anyio.BrokenResourceError: if the stream has been closed from the
|
| 237 |
+
receiving end
|
| 238 |
+
|
| 239 |
+
"""
|
| 240 |
+
await checkpoint()
|
| 241 |
+
try:
|
| 242 |
+
self.send_nowait(item)
|
| 243 |
+
except WouldBlock:
|
| 244 |
+
# Wait until there's someone on the receiving end
|
| 245 |
+
send_event = Event()
|
| 246 |
+
self._state.waiting_senders[send_event] = item
|
| 247 |
+
try:
|
| 248 |
+
await send_event.wait()
|
| 249 |
+
except BaseException:
|
| 250 |
+
self._state.waiting_senders.pop(send_event, None)
|
| 251 |
+
raise
|
| 252 |
+
|
| 253 |
+
if send_event in self._state.waiting_senders:
|
| 254 |
+
del self._state.waiting_senders[send_event]
|
| 255 |
+
raise BrokenResourceError from None
|
| 256 |
+
|
| 257 |
+
def clone(self) -> MemoryObjectSendStream[T_contra]:
|
| 258 |
+
"""
|
| 259 |
+
Create a clone of this send stream.
|
| 260 |
+
|
| 261 |
+
Each clone can be closed separately. Only when all clones have been closed will
|
| 262 |
+
the sending end of the memory stream be considered closed by the receiving ends.
|
| 263 |
+
|
| 264 |
+
:return: the cloned stream
|
| 265 |
+
|
| 266 |
+
"""
|
| 267 |
+
if self._closed:
|
| 268 |
+
raise ClosedResourceError
|
| 269 |
+
|
| 270 |
+
return MemoryObjectSendStream(_state=self._state)
|
| 271 |
+
|
| 272 |
+
def close(self) -> None:
|
| 273 |
+
"""
|
| 274 |
+
Close the stream.
|
| 275 |
+
|
| 276 |
+
This works the exact same way as :meth:`aclose`, but is provided as a special
|
| 277 |
+
case for the benefit of synchronous callbacks.
|
| 278 |
+
|
| 279 |
+
"""
|
| 280 |
+
if not self._closed:
|
| 281 |
+
self._closed = True
|
| 282 |
+
self._state.open_send_channels -= 1
|
| 283 |
+
if self._state.open_send_channels == 0:
|
| 284 |
+
receive_events = list(self._state.waiting_receivers.keys())
|
| 285 |
+
self._state.waiting_receivers.clear()
|
| 286 |
+
for event in receive_events:
|
| 287 |
+
event.set()
|
| 288 |
+
|
| 289 |
+
async def aclose(self) -> None:
|
| 290 |
+
self.close()
|
| 291 |
+
|
| 292 |
+
def statistics(self) -> MemoryObjectStreamStatistics:
|
| 293 |
+
"""
|
| 294 |
+
Return statistics about the current state of this stream.
|
| 295 |
+
|
| 296 |
+
.. versionadded:: 3.0
|
| 297 |
+
"""
|
| 298 |
+
return self._state.statistics()
|
| 299 |
+
|
| 300 |
+
def __enter__(self) -> MemoryObjectSendStream[T_contra]:
|
| 301 |
+
return self
|
| 302 |
+
|
| 303 |
+
def __exit__(
|
| 304 |
+
self,
|
| 305 |
+
exc_type: type[BaseException] | None,
|
| 306 |
+
exc_val: BaseException | None,
|
| 307 |
+
exc_tb: TracebackType | None,
|
| 308 |
+
) -> None:
|
| 309 |
+
self.close()
|
| 310 |
+
|
| 311 |
+
def __del__(self) -> None:
|
| 312 |
+
if not self._closed:
|
| 313 |
+
warnings.warn(
|
| 314 |
+
f"Unclosed <{self.__class__.__name__} at {id(self):x}>",
|
| 315 |
+
ResourceWarning,
|
| 316 |
+
source=self,
|
| 317 |
+
)
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/stapled.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from collections.abc import Callable, Mapping, Sequence
|
| 4 |
+
from dataclasses import dataclass
|
| 5 |
+
from typing import Any, Generic, TypeVar
|
| 6 |
+
|
| 7 |
+
from ..abc import (
|
| 8 |
+
ByteReceiveStream,
|
| 9 |
+
ByteSendStream,
|
| 10 |
+
ByteStream,
|
| 11 |
+
Listener,
|
| 12 |
+
ObjectReceiveStream,
|
| 13 |
+
ObjectSendStream,
|
| 14 |
+
ObjectStream,
|
| 15 |
+
TaskGroup,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
T_Item = TypeVar("T_Item")
|
| 19 |
+
T_Stream = TypeVar("T_Stream")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
@dataclass(eq=False)
|
| 23 |
+
class StapledByteStream(ByteStream):
|
| 24 |
+
"""
|
| 25 |
+
Combines two byte streams into a single, bidirectional byte stream.
|
| 26 |
+
|
| 27 |
+
Extra attributes will be provided from both streams, with the receive stream
|
| 28 |
+
providing the values in case of a conflict.
|
| 29 |
+
|
| 30 |
+
:param ByteSendStream send_stream: the sending byte stream
|
| 31 |
+
:param ByteReceiveStream receive_stream: the receiving byte stream
|
| 32 |
+
"""
|
| 33 |
+
|
| 34 |
+
send_stream: ByteSendStream
|
| 35 |
+
receive_stream: ByteReceiveStream
|
| 36 |
+
|
| 37 |
+
async def receive(self, max_bytes: int = 65536) -> bytes:
|
| 38 |
+
return await self.receive_stream.receive(max_bytes)
|
| 39 |
+
|
| 40 |
+
async def send(self, item: bytes) -> None:
|
| 41 |
+
await self.send_stream.send(item)
|
| 42 |
+
|
| 43 |
+
async def send_eof(self) -> None:
|
| 44 |
+
await self.send_stream.aclose()
|
| 45 |
+
|
| 46 |
+
async def aclose(self) -> None:
|
| 47 |
+
await self.send_stream.aclose()
|
| 48 |
+
await self.receive_stream.aclose()
|
| 49 |
+
|
| 50 |
+
@property
|
| 51 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 52 |
+
return {
|
| 53 |
+
**self.send_stream.extra_attributes,
|
| 54 |
+
**self.receive_stream.extra_attributes,
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
@dataclass(eq=False)
|
| 59 |
+
class StapledObjectStream(Generic[T_Item], ObjectStream[T_Item]):
|
| 60 |
+
"""
|
| 61 |
+
Combines two object streams into a single, bidirectional object stream.
|
| 62 |
+
|
| 63 |
+
Extra attributes will be provided from both streams, with the receive stream
|
| 64 |
+
providing the values in case of a conflict.
|
| 65 |
+
|
| 66 |
+
:param ObjectSendStream send_stream: the sending object stream
|
| 67 |
+
:param ObjectReceiveStream receive_stream: the receiving object stream
|
| 68 |
+
"""
|
| 69 |
+
|
| 70 |
+
send_stream: ObjectSendStream[T_Item]
|
| 71 |
+
receive_stream: ObjectReceiveStream[T_Item]
|
| 72 |
+
|
| 73 |
+
async def receive(self) -> T_Item:
|
| 74 |
+
return await self.receive_stream.receive()
|
| 75 |
+
|
| 76 |
+
async def send(self, item: T_Item) -> None:
|
| 77 |
+
await self.send_stream.send(item)
|
| 78 |
+
|
| 79 |
+
async def send_eof(self) -> None:
|
| 80 |
+
await self.send_stream.aclose()
|
| 81 |
+
|
| 82 |
+
async def aclose(self) -> None:
|
| 83 |
+
await self.send_stream.aclose()
|
| 84 |
+
await self.receive_stream.aclose()
|
| 85 |
+
|
| 86 |
+
@property
|
| 87 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 88 |
+
return {
|
| 89 |
+
**self.send_stream.extra_attributes,
|
| 90 |
+
**self.receive_stream.extra_attributes,
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
@dataclass(eq=False)
|
| 95 |
+
class MultiListener(Generic[T_Stream], Listener[T_Stream]):
|
| 96 |
+
"""
|
| 97 |
+
Combines multiple listeners into one, serving connections from all of them at once.
|
| 98 |
+
|
| 99 |
+
Any MultiListeners in the given collection of listeners will have their listeners
|
| 100 |
+
moved into this one.
|
| 101 |
+
|
| 102 |
+
Extra attributes are provided from each listener, with each successive listener
|
| 103 |
+
overriding any conflicting attributes from the previous one.
|
| 104 |
+
|
| 105 |
+
:param listeners: listeners to serve
|
| 106 |
+
:type listeners: Sequence[Listener[T_Stream]]
|
| 107 |
+
"""
|
| 108 |
+
|
| 109 |
+
listeners: Sequence[Listener[T_Stream]]
|
| 110 |
+
|
| 111 |
+
def __post_init__(self) -> None:
|
| 112 |
+
listeners: list[Listener[T_Stream]] = []
|
| 113 |
+
for listener in self.listeners:
|
| 114 |
+
if isinstance(listener, MultiListener):
|
| 115 |
+
listeners.extend(listener.listeners)
|
| 116 |
+
del listener.listeners[:] # type: ignore[attr-defined]
|
| 117 |
+
else:
|
| 118 |
+
listeners.append(listener)
|
| 119 |
+
|
| 120 |
+
self.listeners = listeners
|
| 121 |
+
|
| 122 |
+
async def serve(
|
| 123 |
+
self, handler: Callable[[T_Stream], Any], task_group: TaskGroup | None = None
|
| 124 |
+
) -> None:
|
| 125 |
+
from .. import create_task_group
|
| 126 |
+
|
| 127 |
+
async with create_task_group() as tg:
|
| 128 |
+
for listener in self.listeners:
|
| 129 |
+
tg.start_soon(listener.serve, handler, task_group)
|
| 130 |
+
|
| 131 |
+
async def aclose(self) -> None:
|
| 132 |
+
for listener in self.listeners:
|
| 133 |
+
await listener.aclose()
|
| 134 |
+
|
| 135 |
+
@property
|
| 136 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 137 |
+
attributes: dict = {}
|
| 138 |
+
for listener in self.listeners:
|
| 139 |
+
attributes.update(listener.extra_attributes)
|
| 140 |
+
|
| 141 |
+
return attributes
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/text.py
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import codecs
|
| 4 |
+
from collections.abc import Callable, Mapping
|
| 5 |
+
from dataclasses import InitVar, dataclass, field
|
| 6 |
+
from typing import Any
|
| 7 |
+
|
| 8 |
+
from ..abc import (
|
| 9 |
+
AnyByteReceiveStream,
|
| 10 |
+
AnyByteSendStream,
|
| 11 |
+
AnyByteStream,
|
| 12 |
+
ObjectReceiveStream,
|
| 13 |
+
ObjectSendStream,
|
| 14 |
+
ObjectStream,
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
@dataclass(eq=False)
|
| 19 |
+
class TextReceiveStream(ObjectReceiveStream[str]):
|
| 20 |
+
"""
|
| 21 |
+
Stream wrapper that decodes bytes to strings using the given encoding.
|
| 22 |
+
|
| 23 |
+
Decoding is done using :class:`~codecs.IncrementalDecoder` which returns any
|
| 24 |
+
completely received unicode characters as soon as they come in.
|
| 25 |
+
|
| 26 |
+
:param transport_stream: any bytes-based receive stream
|
| 27 |
+
:param encoding: character encoding to use for decoding bytes to strings (defaults
|
| 28 |
+
to ``utf-8``)
|
| 29 |
+
:param errors: handling scheme for decoding errors (defaults to ``strict``; see the
|
| 30 |
+
`codecs module documentation`_ for a comprehensive list of options)
|
| 31 |
+
|
| 32 |
+
.. _codecs module documentation:
|
| 33 |
+
https://docs.python.org/3/library/codecs.html#codec-objects
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
transport_stream: AnyByteReceiveStream
|
| 37 |
+
encoding: InitVar[str] = "utf-8"
|
| 38 |
+
errors: InitVar[str] = "strict"
|
| 39 |
+
_decoder: codecs.IncrementalDecoder = field(init=False)
|
| 40 |
+
|
| 41 |
+
def __post_init__(self, encoding: str, errors: str) -> None:
|
| 42 |
+
decoder_class = codecs.getincrementaldecoder(encoding)
|
| 43 |
+
self._decoder = decoder_class(errors=errors)
|
| 44 |
+
|
| 45 |
+
async def receive(self) -> str:
|
| 46 |
+
while True:
|
| 47 |
+
chunk = await self.transport_stream.receive()
|
| 48 |
+
decoded = self._decoder.decode(chunk)
|
| 49 |
+
if decoded:
|
| 50 |
+
return decoded
|
| 51 |
+
|
| 52 |
+
async def aclose(self) -> None:
|
| 53 |
+
await self.transport_stream.aclose()
|
| 54 |
+
self._decoder.reset()
|
| 55 |
+
|
| 56 |
+
@property
|
| 57 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 58 |
+
return self.transport_stream.extra_attributes
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
@dataclass(eq=False)
|
| 62 |
+
class TextSendStream(ObjectSendStream[str]):
|
| 63 |
+
"""
|
| 64 |
+
Sends strings to the wrapped stream as bytes using the given encoding.
|
| 65 |
+
|
| 66 |
+
:param AnyByteSendStream transport_stream: any bytes-based send stream
|
| 67 |
+
:param str encoding: character encoding to use for encoding strings to bytes
|
| 68 |
+
(defaults to ``utf-8``)
|
| 69 |
+
:param str errors: handling scheme for encoding errors (defaults to ``strict``; see
|
| 70 |
+
the `codecs module documentation`_ for a comprehensive list of options)
|
| 71 |
+
|
| 72 |
+
.. _codecs module documentation:
|
| 73 |
+
https://docs.python.org/3/library/codecs.html#codec-objects
|
| 74 |
+
"""
|
| 75 |
+
|
| 76 |
+
transport_stream: AnyByteSendStream
|
| 77 |
+
encoding: InitVar[str] = "utf-8"
|
| 78 |
+
errors: str = "strict"
|
| 79 |
+
_encoder: Callable[..., tuple[bytes, int]] = field(init=False)
|
| 80 |
+
|
| 81 |
+
def __post_init__(self, encoding: str) -> None:
|
| 82 |
+
self._encoder = codecs.getencoder(encoding)
|
| 83 |
+
|
| 84 |
+
async def send(self, item: str) -> None:
|
| 85 |
+
encoded = self._encoder(item, self.errors)[0]
|
| 86 |
+
await self.transport_stream.send(encoded)
|
| 87 |
+
|
| 88 |
+
async def aclose(self) -> None:
|
| 89 |
+
await self.transport_stream.aclose()
|
| 90 |
+
|
| 91 |
+
@property
|
| 92 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 93 |
+
return self.transport_stream.extra_attributes
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
@dataclass(eq=False)
|
| 97 |
+
class TextStream(ObjectStream[str]):
|
| 98 |
+
"""
|
| 99 |
+
A bidirectional stream that decodes bytes to strings on receive and encodes strings
|
| 100 |
+
to bytes on send.
|
| 101 |
+
|
| 102 |
+
Extra attributes will be provided from both streams, with the receive stream
|
| 103 |
+
providing the values in case of a conflict.
|
| 104 |
+
|
| 105 |
+
:param AnyByteStream transport_stream: any bytes-based stream
|
| 106 |
+
:param str encoding: character encoding to use for encoding/decoding strings to/from
|
| 107 |
+
bytes (defaults to ``utf-8``)
|
| 108 |
+
:param str errors: handling scheme for encoding errors (defaults to ``strict``; see
|
| 109 |
+
the `codecs module documentation`_ for a comprehensive list of options)
|
| 110 |
+
|
| 111 |
+
.. _codecs module documentation:
|
| 112 |
+
https://docs.python.org/3/library/codecs.html#codec-objects
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
transport_stream: AnyByteStream
|
| 116 |
+
encoding: InitVar[str] = "utf-8"
|
| 117 |
+
errors: InitVar[str] = "strict"
|
| 118 |
+
_receive_stream: TextReceiveStream = field(init=False)
|
| 119 |
+
_send_stream: TextSendStream = field(init=False)
|
| 120 |
+
|
| 121 |
+
def __post_init__(self, encoding: str, errors: str) -> None:
|
| 122 |
+
self._receive_stream = TextReceiveStream(
|
| 123 |
+
self.transport_stream, encoding=encoding, errors=errors
|
| 124 |
+
)
|
| 125 |
+
self._send_stream = TextSendStream(
|
| 126 |
+
self.transport_stream, encoding=encoding, errors=errors
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
async def receive(self) -> str:
|
| 130 |
+
return await self._receive_stream.receive()
|
| 131 |
+
|
| 132 |
+
async def send(self, item: str) -> None:
|
| 133 |
+
await self._send_stream.send(item)
|
| 134 |
+
|
| 135 |
+
async def send_eof(self) -> None:
|
| 136 |
+
await self.transport_stream.send_eof()
|
| 137 |
+
|
| 138 |
+
async def aclose(self) -> None:
|
| 139 |
+
await self._send_stream.aclose()
|
| 140 |
+
await self._receive_stream.aclose()
|
| 141 |
+
|
| 142 |
+
@property
|
| 143 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 144 |
+
return {
|
| 145 |
+
**self._send_stream.extra_attributes,
|
| 146 |
+
**self._receive_stream.extra_attributes,
|
| 147 |
+
}
|
vlmpy310/lib/python3.10/site-packages/anyio/streams/tls.py
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import logging
|
| 4 |
+
import re
|
| 5 |
+
import ssl
|
| 6 |
+
import sys
|
| 7 |
+
from collections.abc import Callable, Mapping
|
| 8 |
+
from dataclasses import dataclass
|
| 9 |
+
from functools import wraps
|
| 10 |
+
from typing import Any, TypeVar
|
| 11 |
+
|
| 12 |
+
from .. import (
|
| 13 |
+
BrokenResourceError,
|
| 14 |
+
EndOfStream,
|
| 15 |
+
aclose_forcefully,
|
| 16 |
+
get_cancelled_exc_class,
|
| 17 |
+
)
|
| 18 |
+
from .._core._typedattr import TypedAttributeSet, typed_attribute
|
| 19 |
+
from ..abc import AnyByteStream, ByteStream, Listener, TaskGroup
|
| 20 |
+
|
| 21 |
+
if sys.version_info >= (3, 11):
|
| 22 |
+
from typing import TypeVarTuple, Unpack
|
| 23 |
+
else:
|
| 24 |
+
from typing_extensions import TypeVarTuple, Unpack
|
| 25 |
+
|
| 26 |
+
T_Retval = TypeVar("T_Retval")
|
| 27 |
+
PosArgsT = TypeVarTuple("PosArgsT")
|
| 28 |
+
_PCTRTT = tuple[tuple[str, str], ...]
|
| 29 |
+
_PCTRTTT = tuple[_PCTRTT, ...]
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class TLSAttribute(TypedAttributeSet):
|
| 33 |
+
"""Contains Transport Layer Security related attributes."""
|
| 34 |
+
|
| 35 |
+
#: the selected ALPN protocol
|
| 36 |
+
alpn_protocol: str | None = typed_attribute()
|
| 37 |
+
#: the channel binding for type ``tls-unique``
|
| 38 |
+
channel_binding_tls_unique: bytes = typed_attribute()
|
| 39 |
+
#: the selected cipher
|
| 40 |
+
cipher: tuple[str, str, int] = typed_attribute()
|
| 41 |
+
#: the peer certificate in dictionary form (see :meth:`ssl.SSLSocket.getpeercert`
|
| 42 |
+
# for more information)
|
| 43 |
+
peer_certificate: None | (dict[str, str | _PCTRTTT | _PCTRTT]) = typed_attribute()
|
| 44 |
+
#: the peer certificate in binary form
|
| 45 |
+
peer_certificate_binary: bytes | None = typed_attribute()
|
| 46 |
+
#: ``True`` if this is the server side of the connection
|
| 47 |
+
server_side: bool = typed_attribute()
|
| 48 |
+
#: ciphers shared by the client during the TLS handshake (``None`` if this is the
|
| 49 |
+
#: client side)
|
| 50 |
+
shared_ciphers: list[tuple[str, str, int]] | None = typed_attribute()
|
| 51 |
+
#: the :class:`~ssl.SSLObject` used for encryption
|
| 52 |
+
ssl_object: ssl.SSLObject = typed_attribute()
|
| 53 |
+
#: ``True`` if this stream does (and expects) a closing TLS handshake when the
|
| 54 |
+
#: stream is being closed
|
| 55 |
+
standard_compatible: bool = typed_attribute()
|
| 56 |
+
#: the TLS protocol version (e.g. ``TLSv1.2``)
|
| 57 |
+
tls_version: str = typed_attribute()
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
@dataclass(eq=False)
|
| 61 |
+
class TLSStream(ByteStream):
|
| 62 |
+
"""
|
| 63 |
+
A stream wrapper that encrypts all sent data and decrypts received data.
|
| 64 |
+
|
| 65 |
+
This class has no public initializer; use :meth:`wrap` instead.
|
| 66 |
+
All extra attributes from :class:`~TLSAttribute` are supported.
|
| 67 |
+
|
| 68 |
+
:var AnyByteStream transport_stream: the wrapped stream
|
| 69 |
+
|
| 70 |
+
"""
|
| 71 |
+
|
| 72 |
+
transport_stream: AnyByteStream
|
| 73 |
+
standard_compatible: bool
|
| 74 |
+
_ssl_object: ssl.SSLObject
|
| 75 |
+
_read_bio: ssl.MemoryBIO
|
| 76 |
+
_write_bio: ssl.MemoryBIO
|
| 77 |
+
|
| 78 |
+
@classmethod
|
| 79 |
+
async def wrap(
|
| 80 |
+
cls,
|
| 81 |
+
transport_stream: AnyByteStream,
|
| 82 |
+
*,
|
| 83 |
+
server_side: bool | None = None,
|
| 84 |
+
hostname: str | None = None,
|
| 85 |
+
ssl_context: ssl.SSLContext | None = None,
|
| 86 |
+
standard_compatible: bool = True,
|
| 87 |
+
) -> TLSStream:
|
| 88 |
+
"""
|
| 89 |
+
Wrap an existing stream with Transport Layer Security.
|
| 90 |
+
|
| 91 |
+
This performs a TLS handshake with the peer.
|
| 92 |
+
|
| 93 |
+
:param transport_stream: a bytes-transporting stream to wrap
|
| 94 |
+
:param server_side: ``True`` if this is the server side of the connection,
|
| 95 |
+
``False`` if this is the client side (if omitted, will be set to ``False``
|
| 96 |
+
if ``hostname`` has been provided, ``False`` otherwise). Used only to create
|
| 97 |
+
a default context when an explicit context has not been provided.
|
| 98 |
+
:param hostname: host name of the peer (if host name checking is desired)
|
| 99 |
+
:param ssl_context: the SSLContext object to use (if not provided, a secure
|
| 100 |
+
default will be created)
|
| 101 |
+
:param standard_compatible: if ``False``, skip the closing handshake when
|
| 102 |
+
closing the connection, and don't raise an exception if the peer does the
|
| 103 |
+
same
|
| 104 |
+
:raises ~ssl.SSLError: if the TLS handshake fails
|
| 105 |
+
|
| 106 |
+
"""
|
| 107 |
+
if server_side is None:
|
| 108 |
+
server_side = not hostname
|
| 109 |
+
|
| 110 |
+
if not ssl_context:
|
| 111 |
+
purpose = (
|
| 112 |
+
ssl.Purpose.CLIENT_AUTH if server_side else ssl.Purpose.SERVER_AUTH
|
| 113 |
+
)
|
| 114 |
+
ssl_context = ssl.create_default_context(purpose)
|
| 115 |
+
|
| 116 |
+
# Re-enable detection of unexpected EOFs if it was disabled by Python
|
| 117 |
+
if hasattr(ssl, "OP_IGNORE_UNEXPECTED_EOF"):
|
| 118 |
+
ssl_context.options &= ~ssl.OP_IGNORE_UNEXPECTED_EOF
|
| 119 |
+
|
| 120 |
+
bio_in = ssl.MemoryBIO()
|
| 121 |
+
bio_out = ssl.MemoryBIO()
|
| 122 |
+
ssl_object = ssl_context.wrap_bio(
|
| 123 |
+
bio_in, bio_out, server_side=server_side, server_hostname=hostname
|
| 124 |
+
)
|
| 125 |
+
wrapper = cls(
|
| 126 |
+
transport_stream=transport_stream,
|
| 127 |
+
standard_compatible=standard_compatible,
|
| 128 |
+
_ssl_object=ssl_object,
|
| 129 |
+
_read_bio=bio_in,
|
| 130 |
+
_write_bio=bio_out,
|
| 131 |
+
)
|
| 132 |
+
await wrapper._call_sslobject_method(ssl_object.do_handshake)
|
| 133 |
+
return wrapper
|
| 134 |
+
|
| 135 |
+
async def _call_sslobject_method(
|
| 136 |
+
self, func: Callable[[Unpack[PosArgsT]], T_Retval], *args: Unpack[PosArgsT]
|
| 137 |
+
) -> T_Retval:
|
| 138 |
+
while True:
|
| 139 |
+
try:
|
| 140 |
+
result = func(*args)
|
| 141 |
+
except ssl.SSLWantReadError:
|
| 142 |
+
try:
|
| 143 |
+
# Flush any pending writes first
|
| 144 |
+
if self._write_bio.pending:
|
| 145 |
+
await self.transport_stream.send(self._write_bio.read())
|
| 146 |
+
|
| 147 |
+
data = await self.transport_stream.receive()
|
| 148 |
+
except EndOfStream:
|
| 149 |
+
self._read_bio.write_eof()
|
| 150 |
+
except OSError as exc:
|
| 151 |
+
self._read_bio.write_eof()
|
| 152 |
+
self._write_bio.write_eof()
|
| 153 |
+
raise BrokenResourceError from exc
|
| 154 |
+
else:
|
| 155 |
+
self._read_bio.write(data)
|
| 156 |
+
except ssl.SSLWantWriteError:
|
| 157 |
+
await self.transport_stream.send(self._write_bio.read())
|
| 158 |
+
except ssl.SSLSyscallError as exc:
|
| 159 |
+
self._read_bio.write_eof()
|
| 160 |
+
self._write_bio.write_eof()
|
| 161 |
+
raise BrokenResourceError from exc
|
| 162 |
+
except ssl.SSLError as exc:
|
| 163 |
+
self._read_bio.write_eof()
|
| 164 |
+
self._write_bio.write_eof()
|
| 165 |
+
if isinstance(exc, ssl.SSLEOFError) or (
|
| 166 |
+
exc.strerror and "UNEXPECTED_EOF_WHILE_READING" in exc.strerror
|
| 167 |
+
):
|
| 168 |
+
if self.standard_compatible:
|
| 169 |
+
raise BrokenResourceError from exc
|
| 170 |
+
else:
|
| 171 |
+
raise EndOfStream from None
|
| 172 |
+
|
| 173 |
+
raise
|
| 174 |
+
else:
|
| 175 |
+
# Flush any pending writes first
|
| 176 |
+
if self._write_bio.pending:
|
| 177 |
+
await self.transport_stream.send(self._write_bio.read())
|
| 178 |
+
|
| 179 |
+
return result
|
| 180 |
+
|
| 181 |
+
async def unwrap(self) -> tuple[AnyByteStream, bytes]:
|
| 182 |
+
"""
|
| 183 |
+
Does the TLS closing handshake.
|
| 184 |
+
|
| 185 |
+
:return: a tuple of (wrapped byte stream, bytes left in the read buffer)
|
| 186 |
+
|
| 187 |
+
"""
|
| 188 |
+
await self._call_sslobject_method(self._ssl_object.unwrap)
|
| 189 |
+
self._read_bio.write_eof()
|
| 190 |
+
self._write_bio.write_eof()
|
| 191 |
+
return self.transport_stream, self._read_bio.read()
|
| 192 |
+
|
| 193 |
+
async def aclose(self) -> None:
|
| 194 |
+
if self.standard_compatible:
|
| 195 |
+
try:
|
| 196 |
+
await self.unwrap()
|
| 197 |
+
except BaseException:
|
| 198 |
+
await aclose_forcefully(self.transport_stream)
|
| 199 |
+
raise
|
| 200 |
+
|
| 201 |
+
await self.transport_stream.aclose()
|
| 202 |
+
|
| 203 |
+
async def receive(self, max_bytes: int = 65536) -> bytes:
|
| 204 |
+
data = await self._call_sslobject_method(self._ssl_object.read, max_bytes)
|
| 205 |
+
if not data:
|
| 206 |
+
raise EndOfStream
|
| 207 |
+
|
| 208 |
+
return data
|
| 209 |
+
|
| 210 |
+
async def send(self, item: bytes) -> None:
|
| 211 |
+
await self._call_sslobject_method(self._ssl_object.write, item)
|
| 212 |
+
|
| 213 |
+
async def send_eof(self) -> None:
|
| 214 |
+
tls_version = self.extra(TLSAttribute.tls_version)
|
| 215 |
+
match = re.match(r"TLSv(\d+)(?:\.(\d+))?", tls_version)
|
| 216 |
+
if match:
|
| 217 |
+
major, minor = int(match.group(1)), int(match.group(2) or 0)
|
| 218 |
+
if (major, minor) < (1, 3):
|
| 219 |
+
raise NotImplementedError(
|
| 220 |
+
f"send_eof() requires at least TLSv1.3; current "
|
| 221 |
+
f"session uses {tls_version}"
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
raise NotImplementedError(
|
| 225 |
+
"send_eof() has not yet been implemented for TLS streams"
|
| 226 |
+
)
|
| 227 |
+
|
| 228 |
+
@property
|
| 229 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 230 |
+
return {
|
| 231 |
+
**self.transport_stream.extra_attributes,
|
| 232 |
+
TLSAttribute.alpn_protocol: self._ssl_object.selected_alpn_protocol,
|
| 233 |
+
TLSAttribute.channel_binding_tls_unique: (
|
| 234 |
+
self._ssl_object.get_channel_binding
|
| 235 |
+
),
|
| 236 |
+
TLSAttribute.cipher: self._ssl_object.cipher,
|
| 237 |
+
TLSAttribute.peer_certificate: lambda: self._ssl_object.getpeercert(False),
|
| 238 |
+
TLSAttribute.peer_certificate_binary: lambda: self._ssl_object.getpeercert(
|
| 239 |
+
True
|
| 240 |
+
),
|
| 241 |
+
TLSAttribute.server_side: lambda: self._ssl_object.server_side,
|
| 242 |
+
TLSAttribute.shared_ciphers: lambda: self._ssl_object.shared_ciphers()
|
| 243 |
+
if self._ssl_object.server_side
|
| 244 |
+
else None,
|
| 245 |
+
TLSAttribute.standard_compatible: lambda: self.standard_compatible,
|
| 246 |
+
TLSAttribute.ssl_object: lambda: self._ssl_object,
|
| 247 |
+
TLSAttribute.tls_version: self._ssl_object.version,
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
@dataclass(eq=False)
|
| 252 |
+
class TLSListener(Listener[TLSStream]):
|
| 253 |
+
"""
|
| 254 |
+
A convenience listener that wraps another listener and auto-negotiates a TLS session
|
| 255 |
+
on every accepted connection.
|
| 256 |
+
|
| 257 |
+
If the TLS handshake times out or raises an exception,
|
| 258 |
+
:meth:`handle_handshake_error` is called to do whatever post-mortem processing is
|
| 259 |
+
deemed necessary.
|
| 260 |
+
|
| 261 |
+
Supports only the :attr:`~TLSAttribute.standard_compatible` extra attribute.
|
| 262 |
+
|
| 263 |
+
:param Listener listener: the listener to wrap
|
| 264 |
+
:param ssl_context: the SSL context object
|
| 265 |
+
:param standard_compatible: a flag passed through to :meth:`TLSStream.wrap`
|
| 266 |
+
:param handshake_timeout: time limit for the TLS handshake
|
| 267 |
+
(passed to :func:`~anyio.fail_after`)
|
| 268 |
+
"""
|
| 269 |
+
|
| 270 |
+
listener: Listener[Any]
|
| 271 |
+
ssl_context: ssl.SSLContext
|
| 272 |
+
standard_compatible: bool = True
|
| 273 |
+
handshake_timeout: float = 30
|
| 274 |
+
|
| 275 |
+
@staticmethod
|
| 276 |
+
async def handle_handshake_error(exc: BaseException, stream: AnyByteStream) -> None:
|
| 277 |
+
"""
|
| 278 |
+
Handle an exception raised during the TLS handshake.
|
| 279 |
+
|
| 280 |
+
This method does 3 things:
|
| 281 |
+
|
| 282 |
+
#. Forcefully closes the original stream
|
| 283 |
+
#. Logs the exception (unless it was a cancellation exception) using the
|
| 284 |
+
``anyio.streams.tls`` logger
|
| 285 |
+
#. Reraises the exception if it was a base exception or a cancellation exception
|
| 286 |
+
|
| 287 |
+
:param exc: the exception
|
| 288 |
+
:param stream: the original stream
|
| 289 |
+
|
| 290 |
+
"""
|
| 291 |
+
await aclose_forcefully(stream)
|
| 292 |
+
|
| 293 |
+
# Log all except cancellation exceptions
|
| 294 |
+
if not isinstance(exc, get_cancelled_exc_class()):
|
| 295 |
+
# CPython (as of 3.11.5) returns incorrect `sys.exc_info()` here when using
|
| 296 |
+
# any asyncio implementation, so we explicitly pass the exception to log
|
| 297 |
+
# (https://github.com/python/cpython/issues/108668). Trio does not have this
|
| 298 |
+
# issue because it works around the CPython bug.
|
| 299 |
+
logging.getLogger(__name__).exception(
|
| 300 |
+
"Error during TLS handshake", exc_info=exc
|
| 301 |
+
)
|
| 302 |
+
|
| 303 |
+
# Only reraise base exceptions and cancellation exceptions
|
| 304 |
+
if not isinstance(exc, Exception) or isinstance(exc, get_cancelled_exc_class()):
|
| 305 |
+
raise
|
| 306 |
+
|
| 307 |
+
async def serve(
|
| 308 |
+
self,
|
| 309 |
+
handler: Callable[[TLSStream], Any],
|
| 310 |
+
task_group: TaskGroup | None = None,
|
| 311 |
+
) -> None:
|
| 312 |
+
@wraps(handler)
|
| 313 |
+
async def handler_wrapper(stream: AnyByteStream) -> None:
|
| 314 |
+
from .. import fail_after
|
| 315 |
+
|
| 316 |
+
try:
|
| 317 |
+
with fail_after(self.handshake_timeout):
|
| 318 |
+
wrapped_stream = await TLSStream.wrap(
|
| 319 |
+
stream,
|
| 320 |
+
ssl_context=self.ssl_context,
|
| 321 |
+
standard_compatible=self.standard_compatible,
|
| 322 |
+
)
|
| 323 |
+
except BaseException as exc:
|
| 324 |
+
await self.handle_handshake_error(exc, stream)
|
| 325 |
+
else:
|
| 326 |
+
await handler(wrapped_stream)
|
| 327 |
+
|
| 328 |
+
await self.listener.serve(handler_wrapper, task_group)
|
| 329 |
+
|
| 330 |
+
async def aclose(self) -> None:
|
| 331 |
+
await self.listener.aclose()
|
| 332 |
+
|
| 333 |
+
@property
|
| 334 |
+
def extra_attributes(self) -> Mapping[Any, Callable[[], Any]]:
|
| 335 |
+
return {
|
| 336 |
+
TLSAttribute.standard_compatible: lambda: self.standard_compatible,
|
| 337 |
+
}
|
vlmpy310/lib/python3.10/site-packages/notebook/static/1601.4154c4f9ed460feae33b.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"1601.4154c4f9ed460feae33b.js?v=4154c4f9ed460feae33b","mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,uBAAuB,QAAQ;AAC/B;AACA,2CAA2C;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA,MAAM,iBAAiB,MAAM;AAC7B;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,kEAAkE;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,gBAAgB;AAChB,6CAA6C,GAAG,IAAI;AACpD;AACA;;AAEA;AACA,8BAA8B,UAAU;AACxC;AACA;AACA;AACA,sBAAsB,OAAO;AAC7B,4BAA4B,oCAAoC;AAChE,QAAQ;AACR;AACA,QAAQ;AACR;AACA,QAAQ;AACR,gBAAgB;AAChB;AACA;AACA,qEAAqE,OAAO;AAC5E;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,qBAAqB;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,kCAAkC,GAAG;AACrC;AACA,iCAAiC,IAAI;AACrC,4BAA4B,GAAG;AAC/B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,sBAAsB,oBAAoB,kBAAkB,YAAY;;AAExE;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,YAAY;AACZ;AACA,uCAAuC,QAAQ;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,GAAG;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA,wCAAwC,kBAAkB,kBAAkB;AAC5E,6BAA6B,kBAAkB;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,2CAA2C;AACtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,2BAA2B,eAAe;AAC1C;AACA;AACA;AACA;;AAEA;AACA,8EAA8E;AAC9E;AACA;AACA,+HAA+H;AAC/H,iDAAiD;AACjD,kBAAkB,yBAAyB;AAC3C,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA,+FAA+F;AAC/F,4DAA4D,cAAc;AAC1E,QAAQ;AACR;AACA;AACA,QAAQ;AACR;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,2EAA2E,cAAc;AACzF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,6DAA6D,uBAAuB;AACpF;AACA;AACA;AACA;AACA,kBAAkB,kCAAkC;AACpD;AACA;AACA;AACA;AACA;AACA,sBAAsB,EAAE;AACxB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B,kBAAkB;AAClB;AACA;AACA;AACA,iCAAiC,uBAAuB;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C;AAC5C;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA,0BAA0B;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,uBAAuB;AACpD;AACA;AACA,6BAA6B,uBAAuB;AACpD;AACA;AACA;AACA,6CAA6C;AAC7C;AACA;AACA,6BAA6B,wBAAwB;AACrD;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA,+BAA+B;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,sBAAsB;AAC1C;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,yBAAyB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB,iCAAiC;AACjC;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA,MAAM,wBAAwB,EAAE;AAChC;AACA;AACA;AACA;AACA;AACA,4CAA4C;AAC5C;AACA;AACA;AACA,iBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uDAAuD,uBAAuB;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,uBAAuB;AACjD;AACA;AACA;AACA,qCAAqC,uBAAuB;AAC5D,8BAA8B,iBAAiB;AAC/C;AACA;AACA,kBAAkB,sCAAsC;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,0CAA0C,uBAAuB;AACjE;AACA;AACA;AACA,uBAAuB,uBAAuB;AAC9C,6BAA6B,iBAAiB;AAC9C;AACA;AACA;AACA;AACA,uBAAuB,uBAAuB;AAC9C,6BAA6B,iBAAiB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,uBAAuB;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6BAA6B,iBAAiB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,yBAAyB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,uBAAuB,gCAAgC;AAC/E,8BAA8B,uBAAuB,iCAAiC;AACtF,kBAAkB,uCAAuC,wBAAwB;AACjF;AACA;AACA;AACA,yBAAyB,uBAAuB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,qCAAqC;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,uBAAuB;AAChD;AACA;AACA,2BAA2B,uBAAuB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,cAAc,2BAA2B;AAC5F;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,0EAA0E,IAAI;AAC9E,uCAAuC;AACvC;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,2EAA2E,QAAQ;AACnF;AACA;AACA;AACA;AACA;AACA,6BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,gDAAgD;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA,kDAAkD,GAAG;AACrD,6CAA6C,oBAAoB,yBAAyB;AAC1F,sBAAsB,uBAAuB,kBAAkB;AAC/D;AACA;AACA;AACA;;AAEO,iCAAiC,mBAAmB;AACpD,2BAA2B,yBAAyB;AACpD,6BAA6B,2BAA2B;AACxD,iCAAiC,qCAAqC;;;;;;;;;;;;;ACz5BnC;;AAE1C;AACA,IAAI,KAAK;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA,mBAAmB,sDAAU;;AAE7B;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,sDAAU;;AAE7B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,sDAAU;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,sDAAU;AACxB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,sBAAsB;AACtB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,4BAA4B;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,6BAA6B;AACnC;AACA;AACA,WAAW,sDAAU;AACrB;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,sDAAU;AAClC;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;;AAEA,cAAc,sDAAU;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEO;AACP;AACA;AACA;AACA","sources":["webpack://_JUPYTERLAB.CORE_OUTPUT/../node_modules/@codemirror/legacy-modes/mode/javascript.js","webpack://_JUPYTERLAB.CORE_OUTPUT/../node_modules/@codemirror/legacy-modes/mode/pug.js"],"sourcesContent":["function mkJavaScript(parserConfig) {\n var statementIndent = parserConfig.statementIndent;\n var jsonldMode = parserConfig.jsonld;\n var jsonMode = parserConfig.json || jsonldMode;\n var isTS = parserConfig.typescript;\n var wordRE = parserConfig.wordCharacters || /[\\w$\\xa1-\\uffff]/;\n\n // Tokenizer\n\n var keywords = function(){\n function kw(type) {return {type: type, style: \"keyword\"};}\n var A = kw(\"keyword a\"), B = kw(\"keyword b\"), C = kw(\"keyword c\"), D = kw(\"keyword d\");\n var operator = kw(\"operator\"), atom = {type: \"atom\", style: \"atom\"};\n\n return {\n \"if\": kw(\"if\"), \"while\": A, \"with\": A, \"else\": B, \"do\": B, \"try\": B, \"finally\": B,\n \"return\": D, \"break\": D, \"continue\": D, \"new\": kw(\"new\"), \"delete\": C, \"void\": C, \"throw\": C,\n \"debugger\": kw(\"debugger\"), \"var\": kw(\"var\"), \"const\": kw(\"var\"), \"let\": kw(\"var\"),\n \"function\": kw(\"function\"), \"catch\": kw(\"catch\"),\n \"for\": kw(\"for\"), \"switch\": kw(\"switch\"), \"case\": kw(\"case\"), \"default\": kw(\"default\"),\n \"in\": operator, \"typeof\": operator, \"instanceof\": operator,\n \"true\": atom, \"false\": atom, \"null\": atom, \"undefined\": atom, \"NaN\": atom, \"Infinity\": atom,\n \"this\": kw(\"this\"), \"class\": kw(\"class\"), \"super\": kw(\"atom\"),\n \"yield\": C, \"export\": kw(\"export\"), \"import\": kw(\"import\"), \"extends\": C,\n \"await\": C\n };\n }();\n\n var isOperatorChar = /[+\\-*&%=<>!?|~^@]/;\n var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)\"/;\n\n function readRegexp(stream) {\n var escaped = false, next, inSet = false;\n while ((next = stream.next()) != null) {\n if (!escaped) {\n if (next == \"/\" && !inSet) return;\n if (next == \"[\") inSet = true;\n else if (inSet && next == \"]\") inSet = false;\n }\n escaped = !escaped && next == \"\\\\\";\n }\n }\n\n // Used as scratch variables to communicate multiple values without\n // consing up tons of objects.\n var type, content;\n function ret(tp, style, cont) {\n type = tp; content = cont;\n return style;\n }\n function tokenBase(stream, state) {\n var ch = stream.next();\n if (ch == '\"' || ch == \"'\") {\n state.tokenize = tokenString(ch);\n return state.tokenize(stream, state);\n } else if (ch == \".\" && stream.match(/^\\d[\\d_]*(?:[eE][+\\-]?[\\d_]+)?/)) {\n return ret(\"number\", \"number\");\n } else if (ch == \".\" && stream.match(\"..\")) {\n return ret(\"spread\", \"meta\");\n } else if (/[\\[\\]{}\\(\\),;\\:\\.]/.test(ch)) {\n return ret(ch);\n } else if (ch == \"=\" && stream.eat(\">\")) {\n return ret(\"=>\", \"operator\");\n } else if (ch == \"0\" && stream.match(/^(?:x[\\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {\n return ret(\"number\", \"number\");\n } else if (/\\d/.test(ch)) {\n stream.match(/^[\\d_]*(?:n|(?:\\.[\\d_]*)?(?:[eE][+\\-]?[\\d_]+)?)?/);\n return ret(\"number\", \"number\");\n } else if (ch == \"/\") {\n if (stream.eat(\"*\")) {\n state.tokenize = tokenComment;\n return tokenComment(stream, state);\n } else if (stream.eat(\"/\")) {\n stream.skipToEnd();\n return ret(\"comment\", \"comment\");\n } else if (expressionAllowed(stream, state, 1)) {\n readRegexp(stream);\n stream.match(/^\\b(([gimyus])(?![gimyus]*\\2))+\\b/);\n return ret(\"regexp\", \"string.special\");\n } else {\n stream.eat(\"=\");\n return ret(\"operator\", \"operator\", stream.current());\n }\n } else if (ch == \"`\") {\n state.tokenize = tokenQuasi;\n return tokenQuasi(stream, state);\n } else if (ch == \"#\" && stream.peek() == \"!\") {\n stream.skipToEnd();\n return ret(\"meta\", \"meta\");\n } else if (ch == \"#\" && stream.eatWhile(wordRE)) {\n return ret(\"variable\", \"property\")\n } else if (ch == \"<\" && stream.match(\"!--\") ||\n (ch == \"-\" && stream.match(\"->\") && !/\\S/.test(stream.string.slice(0, stream.start)))) {\n stream.skipToEnd()\n return ret(\"comment\", \"comment\")\n } else if (isOperatorChar.test(ch)) {\n if (ch != \">\" || !state.lexical || state.lexical.type != \">\") {\n if (stream.eat(\"=\")) {\n if (ch == \"!\" || ch == \"=\") stream.eat(\"=\")\n } else if (/[<>*+\\-|&?]/.test(ch)) {\n stream.eat(ch)\n if (ch == \">\") stream.eat(ch)\n }\n }\n if (ch == \"?\" && stream.eat(\".\")) return ret(\".\")\n return ret(\"operator\", \"operator\", stream.current());\n } else if (wordRE.test(ch)) {\n stream.eatWhile(wordRE);\n var word = stream.current()\n if (state.lastType != \".\") {\n if (keywords.propertyIsEnumerable(word)) {\n var kw = keywords[word]\n return ret(kw.type, kw.style, word)\n }\n if (word == \"async\" && stream.match(/^(\\s|\\/\\*([^*]|\\*(?!\\/))*?\\*\\/)*[\\[\\(\\w]/, false))\n return ret(\"async\", \"keyword\", word)\n }\n return ret(\"variable\", \"variable\", word)\n }\n }\n\n function tokenString(quote) {\n return function(stream, state) {\n var escaped = false, next;\n if (jsonldMode && stream.peek() == \"@\" && stream.match(isJsonldKeyword)){\n state.tokenize = tokenBase;\n return ret(\"jsonld-keyword\", \"meta\");\n }\n while ((next = stream.next()) != null) {\n if (next == quote && !escaped) break;\n escaped = !escaped && next == \"\\\\\";\n }\n if (!escaped) state.tokenize = tokenBase;\n return ret(\"string\", \"string\");\n };\n }\n\n function tokenComment(stream, state) {\n var maybeEnd = false, ch;\n while (ch = stream.next()) {\n if (ch == \"/\" && maybeEnd) {\n state.tokenize = tokenBase;\n break;\n }\n maybeEnd = (ch == \"*\");\n }\n return ret(\"comment\", \"comment\");\n }\n\n function tokenQuasi(stream, state) {\n var escaped = false, next;\n while ((next = stream.next()) != null) {\n if (!escaped && (next == \"`\" || next == \"$\" && stream.eat(\"{\"))) {\n state.tokenize = tokenBase;\n break;\n }\n escaped = !escaped && next == \"\\\\\";\n }\n return ret(\"quasi\", \"string.special\", stream.current());\n }\n\n var brackets = \"([{}])\";\n // This is a crude lookahead trick to try and notice that we're\n // parsing the argument patterns for a fat-arrow function before we\n // actually hit the arrow token. It only works if the arrow is on\n // the same line as the arguments and there's no strange noise\n // (comments) in between. Fallback is to only notice when we hit the\n // arrow, and not declare the arguments as locals for the arrow\n // body.\n function findFatArrow(stream, state) {\n if (state.fatArrowAt) state.fatArrowAt = null;\n var arrow = stream.string.indexOf(\"=>\", stream.start);\n if (arrow < 0) return;\n\n if (isTS) { // Try to skip TypeScript return type declarations after the arguments\n var m = /:\\s*(?:\\w+(?:<[^>]*>|\\[\\])?|\\{[^}]*\\})\\s*$/.exec(stream.string.slice(stream.start, arrow))\n if (m) arrow = m.index\n }\n\n var depth = 0, sawSomething = false;\n for (var pos = arrow - 1; pos >= 0; --pos) {\n var ch = stream.string.charAt(pos);\n var bracket = brackets.indexOf(ch);\n if (bracket >= 0 && bracket < 3) {\n if (!depth) { ++pos; break; }\n if (--depth == 0) { if (ch == \"(\") sawSomething = true; break; }\n } else if (bracket >= 3 && bracket < 6) {\n ++depth;\n } else if (wordRE.test(ch)) {\n sawSomething = true;\n } else if (/[\"'\\/`]/.test(ch)) {\n for (;; --pos) {\n if (pos == 0) return\n var next = stream.string.charAt(pos - 1)\n if (next == ch && stream.string.charAt(pos - 2) != \"\\\\\") { pos--; break }\n }\n } else if (sawSomething && !depth) {\n ++pos;\n break;\n }\n }\n if (sawSomething && !depth) state.fatArrowAt = pos;\n }\n\n // Parser\n\n var atomicTypes = {\"atom\": true, \"number\": true, \"variable\": true, \"string\": true,\n \"regexp\": true, \"this\": true, \"import\": true, \"jsonld-keyword\": true};\n\n function JSLexical(indented, column, type, align, prev, info) {\n this.indented = indented;\n this.column = column;\n this.type = type;\n this.prev = prev;\n this.info = info;\n if (align != null) this.align = align;\n }\n\n function inScope(state, varname) {\n for (var v = state.localVars; v; v = v.next)\n if (v.name == varname) return true;\n for (var cx = state.context; cx; cx = cx.prev) {\n for (var v = cx.vars; v; v = v.next)\n if (v.name == varname) return true;\n }\n }\n\n function parseJS(state, style, type, content, stream) {\n var cc = state.cc;\n // Communicate our context to the combinators.\n // (Less wasteful than consing up a hundred closures on every call.)\n cx.state = state; cx.stream = stream; cx.marked = null; cx.cc = cc; cx.style = style;\n\n if (!state.lexical.hasOwnProperty(\"align\"))\n state.lexical.align = true;\n\n while(true) {\n var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;\n if (combinator(type, content)) {\n while(cc.length && cc[cc.length - 1].lex)\n cc.pop()();\n if (cx.marked) return cx.marked;\n if (type == \"variable\" && inScope(state, content)) return \"variableName.local\";\n return style;\n }\n }\n }\n\n // Combinator utils\n\n var cx = {state: null, column: null, marked: null, cc: null};\n function pass() {\n for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);\n }\n function cont() {\n pass.apply(null, arguments);\n return true;\n }\n function inList(name, list) {\n for (var v = list; v; v = v.next) if (v.name == name) return true\n return false;\n }\n function register(varname) {\n var state = cx.state;\n cx.marked = \"def\";\n if (state.context) {\n if (state.lexical.info == \"var\" && state.context && state.context.block) {\n // FIXME function decls are also not block scoped\n var newContext = registerVarScoped(varname, state.context)\n if (newContext != null) {\n state.context = newContext\n return\n }\n } else if (!inList(varname, state.localVars)) {\n state.localVars = new Var(varname, state.localVars)\n return\n }\n }\n // Fall through means this is global\n if (parserConfig.globalVars && !inList(varname, state.globalVars))\n state.globalVars = new Var(varname, state.globalVars)\n }\n function registerVarScoped(varname, context) {\n if (!context) {\n return null\n } else if (context.block) {\n var inner = registerVarScoped(varname, context.prev)\n if (!inner) return null\n if (inner == context.prev) return context\n return new Context(inner, context.vars, true)\n } else if (inList(varname, context.vars)) {\n return context\n } else {\n return new Context(context.prev, new Var(varname, context.vars), false)\n }\n }\n\n function isModifier(name) {\n return name == \"public\" || name == \"private\" || name == \"protected\" || name == \"abstract\" || name == \"readonly\"\n }\n\n // Combinators\n\n function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }\n function Var(name, next) { this.name = name; this.next = next }\n\n var defaultVars = new Var(\"this\", new Var(\"arguments\", null))\n function pushcontext() {\n cx.state.context = new Context(cx.state.context, cx.state.localVars, false)\n cx.state.localVars = defaultVars\n }\n function pushblockcontext() {\n cx.state.context = new Context(cx.state.context, cx.state.localVars, true)\n cx.state.localVars = null\n }\n pushcontext.lex = pushblockcontext.lex = true\n function popcontext() {\n cx.state.localVars = cx.state.context.vars\n cx.state.context = cx.state.context.prev\n }\n popcontext.lex = true\n function pushlex(type, info) {\n var result = function() {\n var state = cx.state, indent = state.indented;\n if (state.lexical.type == \"stat\") indent = state.lexical.indented;\n else for (var outer = state.lexical; outer && outer.type == \")\" && outer.align; outer = outer.prev)\n indent = outer.indented;\n state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);\n };\n result.lex = true;\n return result;\n }\n function poplex() {\n var state = cx.state;\n if (state.lexical.prev) {\n if (state.lexical.type == \")\")\n state.indented = state.lexical.indented;\n state.lexical = state.lexical.prev;\n }\n }\n poplex.lex = true;\n\n function expect(wanted) {\n function exp(type) {\n if (type == wanted) return cont();\n else if (wanted == \";\" || type == \"}\" || type == \")\" || type == \"]\") return pass();\n else return cont(exp);\n };\n return exp;\n }\n\n function statement(type, value) {\n if (type == \"var\") return cont(pushlex(\"vardef\", value), vardef, expect(\";\"), poplex);\n if (type == \"keyword a\") return cont(pushlex(\"form\"), parenExpr, statement, poplex);\n if (type == \"keyword b\") return cont(pushlex(\"form\"), statement, poplex);\n if (type == \"keyword d\") return cx.stream.match(/^\\s*$/, false) ? cont() : cont(pushlex(\"stat\"), maybeexpression, expect(\";\"), poplex);\n if (type == \"debugger\") return cont(expect(\";\"));\n if (type == \"{\") return cont(pushlex(\"}\"), pushblockcontext, block, poplex, popcontext);\n if (type == \";\") return cont();\n if (type == \"if\") {\n if (cx.state.lexical.info == \"else\" && cx.state.cc[cx.state.cc.length - 1] == poplex)\n cx.state.cc.pop()();\n return cont(pushlex(\"form\"), parenExpr, statement, poplex, maybeelse);\n }\n if (type == \"function\") return cont(functiondef);\n if (type == \"for\") return cont(pushlex(\"form\"), pushblockcontext, forspec, statement, popcontext, poplex);\n if (type == \"class\" || (isTS && value == \"interface\")) {\n cx.marked = \"keyword\"\n return cont(pushlex(\"form\", type == \"class\" ? type : value), className, poplex)\n }\n if (type == \"variable\") {\n if (isTS && value == \"declare\") {\n cx.marked = \"keyword\"\n return cont(statement)\n } else if (isTS && (value == \"module\" || value == \"enum\" || value == \"type\") && cx.stream.match(/^\\s*\\w/, false)) {\n cx.marked = \"keyword\"\n if (value == \"enum\") return cont(enumdef);\n else if (value == \"type\") return cont(typename, expect(\"operator\"), typeexpr, expect(\";\"));\n else return cont(pushlex(\"form\"), pattern, expect(\"{\"), pushlex(\"}\"), block, poplex, poplex)\n } else if (isTS && value == \"namespace\") {\n cx.marked = \"keyword\"\n return cont(pushlex(\"form\"), expression, statement, poplex)\n } else if (isTS && value == \"abstract\") {\n cx.marked = \"keyword\"\n return cont(statement)\n } else {\n return cont(pushlex(\"stat\"), maybelabel);\n }\n }\n if (type == \"switch\") return cont(pushlex(\"form\"), parenExpr, expect(\"{\"), pushlex(\"}\", \"switch\"), pushblockcontext,\n block, poplex, poplex, popcontext);\n if (type == \"case\") return cont(expression, expect(\":\"));\n if (type == \"default\") return cont(expect(\":\"));\n if (type == \"catch\") return cont(pushlex(\"form\"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);\n if (type == \"export\") return cont(pushlex(\"stat\"), afterExport, poplex);\n if (type == \"import\") return cont(pushlex(\"stat\"), afterImport, poplex);\n if (type == \"async\") return cont(statement)\n if (value == \"@\") return cont(expression, statement)\n return pass(pushlex(\"stat\"), expression, expect(\";\"), poplex);\n }\n function maybeCatchBinding(type) {\n if (type == \"(\") return cont(funarg, expect(\")\"))\n }\n function expression(type, value) {\n return expressionInner(type, value, false);\n }\n function expressionNoComma(type, value) {\n return expressionInner(type, value, true);\n }\n function parenExpr(type) {\n if (type != \"(\") return pass()\n return cont(pushlex(\")\"), maybeexpression, expect(\")\"), poplex)\n }\n function expressionInner(type, value, noComma) {\n if (cx.state.fatArrowAt == cx.stream.start) {\n var body = noComma ? arrowBodyNoComma : arrowBody;\n if (type == \"(\") return cont(pushcontext, pushlex(\")\"), commasep(funarg, \")\"), poplex, expect(\"=>\"), body, popcontext);\n else if (type == \"variable\") return pass(pushcontext, pattern, expect(\"=>\"), body, popcontext);\n }\n\n var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;\n if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);\n if (type == \"function\") return cont(functiondef, maybeop);\n if (type == \"class\" || (isTS && value == \"interface\")) { cx.marked = \"keyword\"; return cont(pushlex(\"form\"), classExpression, poplex); }\n if (type == \"keyword c\" || type == \"async\") return cont(noComma ? expressionNoComma : expression);\n if (type == \"(\") return cont(pushlex(\")\"), maybeexpression, expect(\")\"), poplex, maybeop);\n if (type == \"operator\" || type == \"spread\") return cont(noComma ? expressionNoComma : expression);\n if (type == \"[\") return cont(pushlex(\"]\"), arrayLiteral, poplex, maybeop);\n if (type == \"{\") return contCommasep(objprop, \"}\", null, maybeop);\n if (type == \"quasi\") return pass(quasi, maybeop);\n if (type == \"new\") return cont(maybeTarget(noComma));\n return cont();\n }\n function maybeexpression(type) {\n if (type.match(/[;\\}\\)\\],]/)) return pass();\n return pass(expression);\n }\n\n function maybeoperatorComma(type, value) {\n if (type == \",\") return cont(maybeexpression);\n return maybeoperatorNoComma(type, value, false);\n }\n function maybeoperatorNoComma(type, value, noComma) {\n var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;\n var expr = noComma == false ? expression : expressionNoComma;\n if (type == \"=>\") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);\n if (type == \"operator\") {\n if (/\\+\\+|--/.test(value) || isTS && value == \"!\") return cont(me);\n if (isTS && value == \"<\" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\\s*\\(/, false))\n return cont(pushlex(\">\"), commasep(typeexpr, \">\"), poplex, me);\n if (value == \"?\") return cont(expression, expect(\":\"), expr);\n return cont(expr);\n }\n if (type == \"quasi\") { return pass(quasi, me); }\n if (type == \";\") return;\n if (type == \"(\") return contCommasep(expressionNoComma, \")\", \"call\", me);\n if (type == \".\") return cont(property, me);\n if (type == \"[\") return cont(pushlex(\"]\"), maybeexpression, expect(\"]\"), poplex, me);\n if (isTS && value == \"as\") { cx.marked = \"keyword\"; return cont(typeexpr, me) }\n if (type == \"regexp\") {\n cx.state.lastType = cx.marked = \"operator\"\n cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)\n return cont(expr)\n }\n }\n function quasi(type, value) {\n if (type != \"quasi\") return pass();\n if (value.slice(value.length - 2) != \"${\") return cont(quasi);\n return cont(maybeexpression, continueQuasi);\n }\n function continueQuasi(type) {\n if (type == \"}\") {\n cx.marked = \"string.special\";\n cx.state.tokenize = tokenQuasi;\n return cont(quasi);\n }\n }\n function arrowBody(type) {\n findFatArrow(cx.stream, cx.state);\n return pass(type == \"{\" ? statement : expression);\n }\n function arrowBodyNoComma(type) {\n findFatArrow(cx.stream, cx.state);\n return pass(type == \"{\" ? statement : expressionNoComma);\n }\n function maybeTarget(noComma) {\n return function(type) {\n if (type == \".\") return cont(noComma ? targetNoComma : target);\n else if (type == \"variable\" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)\n else return pass(noComma ? expressionNoComma : expression);\n };\n }\n function target(_, value) {\n if (value == \"target\") { cx.marked = \"keyword\"; return cont(maybeoperatorComma); }\n }\n function targetNoComma(_, value) {\n if (value == \"target\") { cx.marked = \"keyword\"; return cont(maybeoperatorNoComma); }\n }\n function maybelabel(type) {\n if (type == \":\") return cont(poplex, statement);\n return pass(maybeoperatorComma, expect(\";\"), poplex);\n }\n function property(type) {\n if (type == \"variable\") {cx.marked = \"property\"; return cont();}\n }\n function objprop(type, value) {\n if (type == \"async\") {\n cx.marked = \"property\";\n return cont(objprop);\n } else if (type == \"variable\" || cx.style == \"keyword\") {\n cx.marked = \"property\";\n if (value == \"get\" || value == \"set\") return cont(getterSetter);\n var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params\n if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\\s*:\\s*/, false)))\n cx.state.fatArrowAt = cx.stream.pos + m[0].length\n return cont(afterprop);\n } else if (type == \"number\" || type == \"string\") {\n cx.marked = jsonldMode ? \"property\" : (cx.style + \" property\");\n return cont(afterprop);\n } else if (type == \"jsonld-keyword\") {\n return cont(afterprop);\n } else if (isTS && isModifier(value)) {\n cx.marked = \"keyword\"\n return cont(objprop)\n } else if (type == \"[\") {\n return cont(expression, maybetype, expect(\"]\"), afterprop);\n } else if (type == \"spread\") {\n return cont(expressionNoComma, afterprop);\n } else if (value == \"*\") {\n cx.marked = \"keyword\";\n return cont(objprop);\n } else if (type == \":\") {\n return pass(afterprop)\n }\n }\n function getterSetter(type) {\n if (type != \"variable\") return pass(afterprop);\n cx.marked = \"property\";\n return cont(functiondef);\n }\n function afterprop(type) {\n if (type == \":\") return cont(expressionNoComma);\n if (type == \"(\") return pass(functiondef);\n }\n function commasep(what, end, sep) {\n function proceed(type, value) {\n if (sep ? sep.indexOf(type) > -1 : type == \",\") {\n var lex = cx.state.lexical;\n if (lex.info == \"call\") lex.pos = (lex.pos || 0) + 1;\n return cont(function(type, value) {\n if (type == end || value == end) return pass()\n return pass(what)\n }, proceed);\n }\n if (type == end || value == end) return cont();\n if (sep && sep.indexOf(\";\") > -1) return pass(what)\n return cont(expect(end));\n }\n return function(type, value) {\n if (type == end || value == end) return cont();\n return pass(what, proceed);\n };\n }\n function contCommasep(what, end, info) {\n for (var i = 3; i < arguments.length; i++)\n cx.cc.push(arguments[i]);\n return cont(pushlex(end, info), commasep(what, end), poplex);\n }\n function block(type) {\n if (type == \"}\") return cont();\n return pass(statement, block);\n }\n function maybetype(type, value) {\n if (isTS) {\n if (type == \":\") return cont(typeexpr);\n if (value == \"?\") return cont(maybetype);\n }\n }\n function maybetypeOrIn(type, value) {\n if (isTS && (type == \":\" || value == \"in\")) return cont(typeexpr)\n }\n function mayberettype(type) {\n if (isTS && type == \":\") {\n if (cx.stream.match(/^\\s*\\w+\\s+is\\b/, false)) return cont(expression, isKW, typeexpr)\n else return cont(typeexpr)\n }\n }\n function isKW(_, value) {\n if (value == \"is\") {\n cx.marked = \"keyword\"\n return cont()\n }\n }\n function typeexpr(type, value) {\n if (value == \"keyof\" || value == \"typeof\" || value == \"infer\" || value == \"readonly\") {\n cx.marked = \"keyword\"\n return cont(value == \"typeof\" ? expressionNoComma : typeexpr)\n }\n if (type == \"variable\" || value == \"void\") {\n cx.marked = \"type\"\n return cont(afterType)\n }\n if (value == \"|\" || value == \"&\") return cont(typeexpr)\n if (type == \"string\" || type == \"number\" || type == \"atom\") return cont(afterType);\n if (type == \"[\") return cont(pushlex(\"]\"), commasep(typeexpr, \"]\", \",\"), poplex, afterType)\n if (type == \"{\") return cont(pushlex(\"}\"), typeprops, poplex, afterType)\n if (type == \"(\") return cont(commasep(typearg, \")\"), maybeReturnType, afterType)\n if (type == \"<\") return cont(commasep(typeexpr, \">\"), typeexpr)\n if (type == \"quasi\") return pass(quasiType, afterType)\n }\n function maybeReturnType(type) {\n if (type == \"=>\") return cont(typeexpr)\n }\n function typeprops(type) {\n if (type.match(/[\\}\\)\\]]/)) return cont()\n if (type == \",\" || type == \";\") return cont(typeprops)\n return pass(typeprop, typeprops)\n }\n function typeprop(type, value) {\n if (type == \"variable\" || cx.style == \"keyword\") {\n cx.marked = \"property\"\n return cont(typeprop)\n } else if (value == \"?\" || type == \"number\" || type == \"string\") {\n return cont(typeprop)\n } else if (type == \":\") {\n return cont(typeexpr)\n } else if (type == \"[\") {\n return cont(expect(\"variable\"), maybetypeOrIn, expect(\"]\"), typeprop)\n } else if (type == \"(\") {\n return pass(functiondecl, typeprop)\n } else if (!type.match(/[;\\}\\)\\],]/)) {\n return cont()\n }\n }\n function quasiType(type, value) {\n if (type != \"quasi\") return pass();\n if (value.slice(value.length - 2) != \"${\") return cont(quasiType);\n return cont(typeexpr, continueQuasiType);\n }\n function continueQuasiType(type) {\n if (type == \"}\") {\n cx.marked = \"string.special\";\n cx.state.tokenize = tokenQuasi;\n return cont(quasiType);\n }\n }\n function typearg(type, value) {\n if (type == \"variable\" && cx.stream.match(/^\\s*[?:]/, false) || value == \"?\") return cont(typearg)\n if (type == \":\") return cont(typeexpr)\n if (type == \"spread\") return cont(typearg)\n return pass(typeexpr)\n }\n function afterType(type, value) {\n if (value == \"<\") return cont(pushlex(\">\"), commasep(typeexpr, \">\"), poplex, afterType)\n if (value == \"|\" || type == \".\" || value == \"&\") return cont(typeexpr)\n if (type == \"[\") return cont(typeexpr, expect(\"]\"), afterType)\n if (value == \"extends\" || value == \"implements\") { cx.marked = \"keyword\"; return cont(typeexpr) }\n if (value == \"?\") return cont(typeexpr, expect(\":\"), typeexpr)\n }\n function maybeTypeArgs(_, value) {\n if (value == \"<\") return cont(pushlex(\">\"), commasep(typeexpr, \">\"), poplex, afterType)\n }\n function typeparam() {\n return pass(typeexpr, maybeTypeDefault)\n }\n function maybeTypeDefault(_, value) {\n if (value == \"=\") return cont(typeexpr)\n }\n function vardef(_, value) {\n if (value == \"enum\") {cx.marked = \"keyword\"; return cont(enumdef)}\n return pass(pattern, maybetype, maybeAssign, vardefCont);\n }\n function pattern(type, value) {\n if (isTS && isModifier(value)) { cx.marked = \"keyword\"; return cont(pattern) }\n if (type == \"variable\") { register(value); return cont(); }\n if (type == \"spread\") return cont(pattern);\n if (type == \"[\") return contCommasep(eltpattern, \"]\");\n if (type == \"{\") return contCommasep(proppattern, \"}\");\n }\n function proppattern(type, value) {\n if (type == \"variable\" && !cx.stream.match(/^\\s*:/, false)) {\n register(value);\n return cont(maybeAssign);\n }\n if (type == \"variable\") cx.marked = \"property\";\n if (type == \"spread\") return cont(pattern);\n if (type == \"}\") return pass();\n if (type == \"[\") return cont(expression, expect(']'), expect(':'), proppattern);\n return cont(expect(\":\"), pattern, maybeAssign);\n }\n function eltpattern() {\n return pass(pattern, maybeAssign)\n }\n function maybeAssign(_type, value) {\n if (value == \"=\") return cont(expressionNoComma);\n }\n function vardefCont(type) {\n if (type == \",\") return cont(vardef);\n }\n function maybeelse(type, value) {\n if (type == \"keyword b\" && value == \"else\") return cont(pushlex(\"form\", \"else\"), statement, poplex);\n }\n function forspec(type, value) {\n if (value == \"await\") return cont(forspec);\n if (type == \"(\") return cont(pushlex(\")\"), forspec1, poplex);\n }\n function forspec1(type) {\n if (type == \"var\") return cont(vardef, forspec2);\n if (type == \"variable\") return cont(forspec2);\n return pass(forspec2)\n }\n function forspec2(type, value) {\n if (type == \")\") return cont()\n if (type == \";\") return cont(forspec2)\n if (value == \"in\" || value == \"of\") { cx.marked = \"keyword\"; return cont(expression, forspec2) }\n return pass(expression, forspec2)\n }\n function functiondef(type, value) {\n if (value == \"*\") {cx.marked = \"keyword\"; return cont(functiondef);}\n if (type == \"variable\") {register(value); return cont(functiondef);}\n if (type == \"(\") return cont(pushcontext, pushlex(\")\"), commasep(funarg, \")\"), poplex, mayberettype, statement, popcontext);\n if (isTS && value == \"<\") return cont(pushlex(\">\"), commasep(typeparam, \">\"), poplex, functiondef)\n }\n function functiondecl(type, value) {\n if (value == \"*\") {cx.marked = \"keyword\"; return cont(functiondecl);}\n if (type == \"variable\") {register(value); return cont(functiondecl);}\n if (type == \"(\") return cont(pushcontext, pushlex(\")\"), commasep(funarg, \")\"), poplex, mayberettype, popcontext);\n if (isTS && value == \"<\") return cont(pushlex(\">\"), commasep(typeparam, \">\"), poplex, functiondecl)\n }\n function typename(type, value) {\n if (type == \"keyword\" || type == \"variable\") {\n cx.marked = \"type\"\n return cont(typename)\n } else if (value == \"<\") {\n return cont(pushlex(\">\"), commasep(typeparam, \">\"), poplex)\n }\n }\n function funarg(type, value) {\n if (value == \"@\") cont(expression, funarg)\n if (type == \"spread\") return cont(funarg);\n if (isTS && isModifier(value)) { cx.marked = \"keyword\"; return cont(funarg); }\n if (isTS && type == \"this\") return cont(maybetype, maybeAssign)\n return pass(pattern, maybetype, maybeAssign);\n }\n function classExpression(type, value) {\n // Class expressions may have an optional name.\n if (type == \"variable\") return className(type, value);\n return classNameAfter(type, value);\n }\n function className(type, value) {\n if (type == \"variable\") {register(value); return cont(classNameAfter);}\n }\n function classNameAfter(type, value) {\n if (value == \"<\") return cont(pushlex(\">\"), commasep(typeparam, \">\"), poplex, classNameAfter)\n if (value == \"extends\" || value == \"implements\" || (isTS && type == \",\")) {\n if (value == \"implements\") cx.marked = \"keyword\";\n return cont(isTS ? typeexpr : expression, classNameAfter);\n }\n if (type == \"{\") return cont(pushlex(\"}\"), classBody, poplex);\n }\n function classBody(type, value) {\n if (type == \"async\" ||\n (type == \"variable\" &&\n (value == \"static\" || value == \"get\" || value == \"set\" || (isTS && isModifier(value))) &&\n cx.stream.match(/^\\s+#?[\\w$\\xa1-\\uffff]/, false))) {\n cx.marked = \"keyword\";\n return cont(classBody);\n }\n if (type == \"variable\" || cx.style == \"keyword\") {\n cx.marked = \"property\";\n return cont(classfield, classBody);\n }\n if (type == \"number\" || type == \"string\") return cont(classfield, classBody);\n if (type == \"[\")\n return cont(expression, maybetype, expect(\"]\"), classfield, classBody)\n if (value == \"*\") {\n cx.marked = \"keyword\";\n return cont(classBody);\n }\n if (isTS && type == \"(\") return pass(functiondecl, classBody)\n if (type == \";\" || type == \",\") return cont(classBody);\n if (type == \"}\") return cont();\n if (value == \"@\") return cont(expression, classBody)\n }\n function classfield(type, value) {\n if (value == \"!\" || value == \"?\") return cont(classfield)\n if (type == \":\") return cont(typeexpr, maybeAssign)\n if (value == \"=\") return cont(expressionNoComma)\n var context = cx.state.lexical.prev, isInterface = context && context.info == \"interface\"\n return pass(isInterface ? functiondecl : functiondef)\n }\n function afterExport(type, value) {\n if (value == \"*\") { cx.marked = \"keyword\"; return cont(maybeFrom, expect(\";\")); }\n if (value == \"default\") { cx.marked = \"keyword\"; return cont(expression, expect(\";\")); }\n if (type == \"{\") return cont(commasep(exportField, \"}\"), maybeFrom, expect(\";\"));\n return pass(statement);\n }\n function exportField(type, value) {\n if (value == \"as\") { cx.marked = \"keyword\"; return cont(expect(\"variable\")); }\n if (type == \"variable\") return pass(expressionNoComma, exportField);\n }\n function afterImport(type) {\n if (type == \"string\") return cont();\n if (type == \"(\") return pass(expression);\n if (type == \".\") return pass(maybeoperatorComma);\n return pass(importSpec, maybeMoreImports, maybeFrom);\n }\n function importSpec(type, value) {\n if (type == \"{\") return contCommasep(importSpec, \"}\");\n if (type == \"variable\") register(value);\n if (value == \"*\") cx.marked = \"keyword\";\n return cont(maybeAs);\n }\n function maybeMoreImports(type) {\n if (type == \",\") return cont(importSpec, maybeMoreImports)\n }\n function maybeAs(_type, value) {\n if (value == \"as\") { cx.marked = \"keyword\"; return cont(importSpec); }\n }\n function maybeFrom(_type, value) {\n if (value == \"from\") { cx.marked = \"keyword\"; return cont(expression); }\n }\n function arrayLiteral(type) {\n if (type == \"]\") return cont();\n return pass(commasep(expressionNoComma, \"]\"));\n }\n function enumdef() {\n return pass(pushlex(\"form\"), pattern, expect(\"{\"), pushlex(\"}\"), commasep(enummember, \"}\"), poplex, poplex)\n }\n function enummember() {\n return pass(pattern, maybeAssign);\n }\n\n function isContinuedStatement(state, textAfter) {\n return state.lastType == \"operator\" || state.lastType == \",\" ||\n isOperatorChar.test(textAfter.charAt(0)) ||\n /[,.]/.test(textAfter.charAt(0));\n }\n\n function expressionAllowed(stream, state, backUp) {\n return state.tokenize == tokenBase &&\n /^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\\[{}\\(,;:]|=>)$/.test(state.lastType) ||\n (state.lastType == \"quasi\" && /\\{\\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))\n }\n\n // Interface\n\n return {\n name: parserConfig.name,\n\n startState: function(indentUnit) {\n var state = {\n tokenize: tokenBase,\n lastType: \"sof\",\n cc: [],\n lexical: new JSLexical(-indentUnit, 0, \"block\", false),\n localVars: parserConfig.localVars,\n context: parserConfig.localVars && new Context(null, null, false),\n indented: 0\n };\n if (parserConfig.globalVars && typeof parserConfig.globalVars == \"object\")\n state.globalVars = parserConfig.globalVars;\n return state;\n },\n\n token: function(stream, state) {\n if (stream.sol()) {\n if (!state.lexical.hasOwnProperty(\"align\"))\n state.lexical.align = false;\n state.indented = stream.indentation();\n findFatArrow(stream, state);\n }\n if (state.tokenize != tokenComment && stream.eatSpace()) return null;\n var style = state.tokenize(stream, state);\n if (type == \"comment\") return style;\n state.lastType = type == \"operator\" && (content == \"++\" || content == \"--\") ? \"incdec\" : type;\n return parseJS(state, style, type, content, stream);\n },\n\n indent: function(state, textAfter, cx) {\n if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return null;\n if (state.tokenize != tokenBase) return 0;\n var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top\n // Kludge to prevent 'maybelse' from blocking lexical scope pops\n if (!/^\\s*else\\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {\n var c = state.cc[i];\n if (c == poplex) lexical = lexical.prev;\n else if (c != maybeelse && c != popcontext) break;\n }\n while ((lexical.type == \"stat\" || lexical.type == \"form\") &&\n (firstChar == \"}\" || ((top = state.cc[state.cc.length - 1]) &&\n (top == maybeoperatorComma || top == maybeoperatorNoComma) &&\n !/^[,\\.=+\\-*:?[\\(]/.test(textAfter))))\n lexical = lexical.prev;\n if (statementIndent && lexical.type == \")\" && lexical.prev.type == \"stat\")\n lexical = lexical.prev;\n var type = lexical.type, closing = firstChar == type;\n\n if (type == \"vardef\") return lexical.indented + (state.lastType == \"operator\" || state.lastType == \",\" ? lexical.info.length + 1 : 0);\n else if (type == \"form\" && firstChar == \"{\") return lexical.indented;\n else if (type == \"form\") return lexical.indented + cx.unit;\n else if (type == \"stat\")\n return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || cx.unit : 0);\n else if (lexical.info == \"switch\" && !closing && parserConfig.doubleIndentSwitch != false)\n return lexical.indented + (/^(?:case|default)\\b/.test(textAfter) ? cx.unit : 2 * cx.unit);\n else if (lexical.align) return lexical.column + (closing ? 0 : 1);\n else return lexical.indented + (closing ? 0 : cx.unit);\n },\n\n languageData: {\n indentOnInput: /^\\s*(?:case .*?:|default:|\\{|\\})$/,\n commentTokens: jsonMode ? undefined : {line: \"//\", block: {open: \"/*\", close: \"*/\"}},\n closeBrackets: {brackets: [\"(\", \"[\", \"{\", \"'\", '\"', \"`\"]},\n wordChars: \"$\"\n }\n };\n};\n\nexport const javascript = mkJavaScript({name: \"javascript\"})\nexport const json = mkJavaScript({name: \"json\", json: true})\nexport const jsonld = mkJavaScript({name: \"json\", jsonld: true})\nexport const typescript = mkJavaScript({name: \"typescript\", typescript: true})\n","import {javascript} from \"./javascript.js\"\n\nvar ATTRS_NEST = {\n '{': '}',\n '(': ')',\n '[': ']'\n}\n\nfunction defaultCopyState(state) {\n if (typeof state != \"object\") return state\n let newState = {}\n for (let prop in state) {\n let val = state[prop]\n newState[prop] = val instanceof Array ? val.slice() : val\n }\n return newState\n}\n\nclass State {\n constructor(indentUnit) {\n this.indentUnit = indentUnit\n\n this.javaScriptLine = false\n this.javaScriptLineExcludesColon = false\n\n this.javaScriptArguments = false\n this.javaScriptArgumentsDepth = 0\n\n this.isInterpolating = false\n this.interpolationNesting = 0\n\n this.jsState = javascript.startState(indentUnit)\n\n this.restOfLine = ''\n\n this.isIncludeFiltered = false\n this.isEach = false\n\n this.lastTag = ''\n\n // Attributes Mode\n this.isAttrs = false\n this.attrsNest = []\n this.inAttributeName = true\n this.attributeIsType = false\n this.attrValue = ''\n\n // Indented Mode\n this.indentOf = Infinity\n this.indentToken = ''\n }\n\n copy() {\n var res = new State(this.indentUnit)\n res.javaScriptLine = this.javaScriptLine\n res.javaScriptLineExcludesColon = this.javaScriptLineExcludesColon\n res.javaScriptArguments = this.javaScriptArguments\n res.javaScriptArgumentsDepth = this.javaScriptArgumentsDepth\n res.isInterpolating = this.isInterpolating\n res.interpolationNesting = this.interpolationNesting\n\n res.jsState = (javascript.copyState || defaultCopyState)(this.jsState)\n\n res.restOfLine = this.restOfLine\n\n res.isIncludeFiltered = this.isIncludeFiltered\n res.isEach = this.isEach\n res.lastTag = this.lastTag\n res.isAttrs = this.isAttrs\n res.attrsNest = this.attrsNest.slice()\n res.inAttributeName = this.inAttributeName\n res.attributeIsType = this.attributeIsType\n res.attrValue = this.attrValue\n res.indentOf = this.indentOf\n res.indentToken = this.indentToken\n\n return res\n }\n}\n\nfunction javaScript(stream, state) {\n if (stream.sol()) {\n // if javaScriptLine was set at end of line, ignore it\n state.javaScriptLine = false\n state.javaScriptLineExcludesColon = false\n }\n if (state.javaScriptLine) {\n if (state.javaScriptLineExcludesColon && stream.peek() === ':') {\n state.javaScriptLine = false\n state.javaScriptLineExcludesColon = false\n return\n }\n var tok = javascript.token(stream, state.jsState)\n if (stream.eol()) state.javaScriptLine = false\n return tok || true\n }\n}\nfunction javaScriptArguments(stream, state) {\n if (state.javaScriptArguments) {\n if (state.javaScriptArgumentsDepth === 0 && stream.peek() !== '(') {\n state.javaScriptArguments = false\n return\n }\n if (stream.peek() === '(') {\n state.javaScriptArgumentsDepth++\n } else if (stream.peek() === ')') {\n state.javaScriptArgumentsDepth--\n }\n if (state.javaScriptArgumentsDepth === 0) {\n state.javaScriptArguments = false\n return\n }\n\n var tok = javascript.token(stream, state.jsState)\n return tok || true\n }\n}\n\nfunction yieldStatement(stream) {\n if (stream.match(/^yield\\b/)) {\n return 'keyword'\n }\n}\n\nfunction doctype(stream) {\n if (stream.match(/^(?:doctype) *([^\\n]+)?/)) return 'meta'\n}\n\nfunction interpolation(stream, state) {\n if (stream.match('#{')) {\n state.isInterpolating = true\n state.interpolationNesting = 0\n return 'punctuation'\n }\n}\n\nfunction interpolationContinued(stream, state) {\n if (state.isInterpolating) {\n if (stream.peek() === '}') {\n state.interpolationNesting--\n if (state.interpolationNesting < 0) {\n stream.next()\n state.isInterpolating = false\n return 'punctuation'\n }\n } else if (stream.peek() === '{') {\n state.interpolationNesting++\n }\n return javascript.token(stream, state.jsState) || true\n }\n}\n\nfunction caseStatement(stream, state) {\n if (stream.match(/^case\\b/)) {\n state.javaScriptLine = true\n return 'keyword'\n }\n}\n\nfunction when(stream, state) {\n if (stream.match(/^when\\b/)) {\n state.javaScriptLine = true\n state.javaScriptLineExcludesColon = true\n return 'keyword'\n }\n}\n\nfunction defaultStatement(stream) {\n if (stream.match(/^default\\b/)) {\n return 'keyword'\n }\n}\n\nfunction extendsStatement(stream, state) {\n if (stream.match(/^extends?\\b/)) {\n state.restOfLine = 'string'\n return 'keyword'\n }\n}\n\nfunction append(stream, state) {\n if (stream.match(/^append\\b/)) {\n state.restOfLine = 'variable'\n return 'keyword'\n }\n}\nfunction prepend(stream, state) {\n if (stream.match(/^prepend\\b/)) {\n state.restOfLine = 'variable'\n return 'keyword'\n }\n}\nfunction block(stream, state) {\n if (stream.match(/^block\\b *(?:(prepend|append)\\b)?/)) {\n state.restOfLine = 'variable'\n return 'keyword'\n }\n}\n\nfunction include(stream, state) {\n if (stream.match(/^include\\b/)) {\n state.restOfLine = 'string'\n return 'keyword'\n }\n}\n\nfunction includeFiltered(stream, state) {\n if (stream.match(/^include:([a-zA-Z0-9\\-]+)/, false) && stream.match('include')) {\n state.isIncludeFiltered = true\n return 'keyword'\n }\n}\n\nfunction includeFilteredContinued(stream, state) {\n if (state.isIncludeFiltered) {\n var tok = filter(stream, state)\n state.isIncludeFiltered = false\n state.restOfLine = 'string'\n return tok\n }\n}\n\nfunction mixin(stream, state) {\n if (stream.match(/^mixin\\b/)) {\n state.javaScriptLine = true\n return 'keyword'\n }\n}\n\nfunction call(stream, state) {\n if (stream.match(/^\\+([-\\w]+)/)) {\n if (!stream.match(/^\\( *[-\\w]+ *=/, false)) {\n state.javaScriptArguments = true\n state.javaScriptArgumentsDepth = 0\n }\n return 'variable'\n }\n if (stream.match('+#{', false)) {\n stream.next()\n state.mixinCallAfter = true\n return interpolation(stream, state)\n }\n}\nfunction callArguments(stream, state) {\n if (state.mixinCallAfter) {\n state.mixinCallAfter = false\n if (!stream.match(/^\\( *[-\\w]+ *=/, false)) {\n state.javaScriptArguments = true\n state.javaScriptArgumentsDepth = 0\n }\n return true\n }\n}\n\nfunction conditional(stream, state) {\n if (stream.match(/^(if|unless|else if|else)\\b/)) {\n state.javaScriptLine = true\n return 'keyword'\n }\n}\n\nfunction each(stream, state) {\n if (stream.match(/^(- *)?(each|for)\\b/)) {\n state.isEach = true\n return 'keyword'\n }\n}\nfunction eachContinued(stream, state) {\n if (state.isEach) {\n if (stream.match(/^ in\\b/)) {\n state.javaScriptLine = true\n state.isEach = false\n return 'keyword'\n } else if (stream.sol() || stream.eol()) {\n state.isEach = false\n } else if (stream.next()) {\n while (!stream.match(/^ in\\b/, false) && stream.next()) {}\n return 'variable'\n }\n }\n}\n\nfunction whileStatement(stream, state) {\n if (stream.match(/^while\\b/)) {\n state.javaScriptLine = true\n return 'keyword'\n }\n}\n\nfunction tag(stream, state) {\n var captures\n if (captures = stream.match(/^(\\w(?:[-:\\w]*\\w)?)\\/?/)) {\n state.lastTag = captures[1].toLowerCase()\n return 'tag'\n }\n}\n\nfunction filter(stream, state) {\n if (stream.match(/^:([\\w\\-]+)/)) {\n setStringMode(stream, state)\n return 'atom'\n }\n}\n\nfunction code(stream, state) {\n if (stream.match(/^(!?=|-)/)) {\n state.javaScriptLine = true\n return 'punctuation'\n }\n}\n\nfunction id(stream) {\n if (stream.match(/^#([\\w-]+)/)) {\n return 'builtin'\n }\n}\n\nfunction className(stream) {\n if (stream.match(/^\\.([\\w-]+)/)) {\n return 'className'\n }\n}\n\nfunction attrs(stream, state) {\n if (stream.peek() == '(') {\n stream.next()\n state.isAttrs = true\n state.attrsNest = []\n state.inAttributeName = true\n state.attrValue = ''\n state.attributeIsType = false\n return 'punctuation'\n }\n}\n\nfunction attrsContinued(stream, state) {\n if (state.isAttrs) {\n if (ATTRS_NEST[stream.peek()]) {\n state.attrsNest.push(ATTRS_NEST[stream.peek()])\n }\n if (state.attrsNest[state.attrsNest.length - 1] === stream.peek()) {\n state.attrsNest.pop()\n } else if (stream.eat(')')) {\n state.isAttrs = false\n return 'punctuation'\n }\n if (state.inAttributeName && stream.match(/^[^=,\\)!]+/)) {\n if (stream.peek() === '=' || stream.peek() === '!') {\n state.inAttributeName = false\n state.jsState = javascript.startState(2)\n if (state.lastTag === 'script' && stream.current().trim().toLowerCase() === 'type') {\n state.attributeIsType = true\n } else {\n state.attributeIsType = false\n }\n }\n return 'attribute'\n }\n\n var tok = javascript.token(stream, state.jsState)\n if (state.attrsNest.length === 0 && (tok === 'string' || tok === 'variable' || tok === 'keyword')) {\n try {\n Function('', 'var x ' + state.attrValue.replace(/,\\s*$/, '').replace(/^!/, ''))\n state.inAttributeName = true\n state.attrValue = ''\n stream.backUp(stream.current().length)\n return attrsContinued(stream, state)\n } catch (ex) {\n //not the end of an attribute\n }\n }\n state.attrValue += stream.current()\n return tok || true\n }\n}\n\nfunction attributesBlock(stream, state) {\n if (stream.match(/^&attributes\\b/)) {\n state.javaScriptArguments = true\n state.javaScriptArgumentsDepth = 0\n return 'keyword'\n }\n}\n\nfunction indent(stream) {\n if (stream.sol() && stream.eatSpace()) {\n return 'indent'\n }\n}\n\nfunction comment(stream, state) {\n if (stream.match(/^ *\\/\\/(-)?([^\\n]*)/)) {\n state.indentOf = stream.indentation()\n state.indentToken = 'comment'\n return 'comment'\n }\n}\n\nfunction colon(stream) {\n if (stream.match(/^: */)) {\n return 'colon'\n }\n}\n\nfunction text(stream, state) {\n if (stream.match(/^(?:\\| ?| )([^\\n]+)/)) {\n return 'string'\n }\n if (stream.match(/^(<[^\\n]*)/, false)) {\n // html string\n setStringMode(stream, state)\n stream.skipToEnd()\n return state.indentToken\n }\n}\n\nfunction dot(stream, state) {\n if (stream.eat('.')) {\n setStringMode(stream, state)\n return 'dot'\n }\n}\n\nfunction fail(stream) {\n stream.next()\n return null\n}\n\n\nfunction setStringMode(stream, state) {\n state.indentOf = stream.indentation()\n state.indentToken = 'string'\n}\nfunction restOfLine(stream, state) {\n if (stream.sol()) {\n // if restOfLine was set at end of line, ignore it\n state.restOfLine = ''\n }\n if (state.restOfLine) {\n stream.skipToEnd()\n var tok = state.restOfLine\n state.restOfLine = ''\n return tok\n }\n}\n\n\nfunction startState(indentUnit) {\n return new State(indentUnit)\n}\nfunction copyState(state) {\n return state.copy()\n}\nfunction nextToken(stream, state) {\n var tok = restOfLine(stream, state)\n || interpolationContinued(stream, state)\n || includeFilteredContinued(stream, state)\n || eachContinued(stream, state)\n || attrsContinued(stream, state)\n || javaScript(stream, state)\n || javaScriptArguments(stream, state)\n || callArguments(stream, state)\n\n || yieldStatement(stream)\n || doctype(stream)\n || interpolation(stream, state)\n || caseStatement(stream, state)\n || when(stream, state)\n || defaultStatement(stream)\n || extendsStatement(stream, state)\n || append(stream, state)\n || prepend(stream, state)\n || block(stream, state)\n || include(stream, state)\n || includeFiltered(stream, state)\n || mixin(stream, state)\n || call(stream, state)\n || conditional(stream, state)\n || each(stream, state)\n || whileStatement(stream, state)\n || tag(stream, state)\n || filter(stream, state)\n || code(stream, state)\n || id(stream)\n || className(stream)\n || attrs(stream, state)\n || attributesBlock(stream, state)\n || indent(stream)\n || text(stream, state)\n || comment(stream, state)\n || colon(stream)\n || dot(stream, state)\n || fail(stream)\n\n return tok === true ? null : tok\n}\n\nexport const pug = {\n startState: startState,\n copyState: copyState,\n token: nextToken\n}\n"],"names":[],"sourceRoot":""}
|
vlmpy310/lib/python3.10/site-packages/notebook/static/221.21b91ccc95eefd849fa5.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
(self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] = self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] || []).push([[221],{
|
| 3 |
+
|
| 4 |
+
/***/ 30221:
|
| 5 |
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
| 6 |
+
|
| 7 |
+
__webpack_require__.r(__webpack_exports__);
|
| 8 |
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
| 9 |
+
/* harmony export */ dtd: () => (/* binding */ dtd)
|
| 10 |
+
/* harmony export */ });
|
| 11 |
+
var type;
|
| 12 |
+
function ret(style, tp) {type = tp; return style;}
|
| 13 |
+
|
| 14 |
+
function tokenBase(stream, state) {
|
| 15 |
+
var ch = stream.next();
|
| 16 |
+
|
| 17 |
+
if (ch == "<" && stream.eat("!") ) {
|
| 18 |
+
if (stream.eatWhile(/[\-]/)) {
|
| 19 |
+
state.tokenize = tokenSGMLComment;
|
| 20 |
+
return tokenSGMLComment(stream, state);
|
| 21 |
+
} else if (stream.eatWhile(/[\w]/)) return ret("keyword", "doindent");
|
| 22 |
+
} else if (ch == "<" && stream.eat("?")) { //xml declaration
|
| 23 |
+
state.tokenize = inBlock("meta", "?>");
|
| 24 |
+
return ret("meta", ch);
|
| 25 |
+
} else if (ch == "#" && stream.eatWhile(/[\w]/)) return ret("atom", "tag");
|
| 26 |
+
else if (ch == "|") return ret("keyword", "separator");
|
| 27 |
+
else if (ch.match(/[\(\)\[\]\-\.,\+\?>]/)) return ret(null, ch);//if(ch === ">") return ret(null, "endtag"); else
|
| 28 |
+
else if (ch.match(/[\[\]]/)) return ret("rule", ch);
|
| 29 |
+
else if (ch == "\"" || ch == "'") {
|
| 30 |
+
state.tokenize = tokenString(ch);
|
| 31 |
+
return state.tokenize(stream, state);
|
| 32 |
+
} else if (stream.eatWhile(/[a-zA-Z\?\+\d]/)) {
|
| 33 |
+
var sc = stream.current();
|
| 34 |
+
if( sc.substr(sc.length-1,sc.length).match(/\?|\+/) !== null )stream.backUp(1);
|
| 35 |
+
return ret("tag", "tag");
|
| 36 |
+
} else if (ch == "%" || ch == "*" ) return ret("number", "number");
|
| 37 |
+
else {
|
| 38 |
+
stream.eatWhile(/[\w\\\-_%.{,]/);
|
| 39 |
+
return ret(null, null);
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
function tokenSGMLComment(stream, state) {
|
| 44 |
+
var dashes = 0, ch;
|
| 45 |
+
while ((ch = stream.next()) != null) {
|
| 46 |
+
if (dashes >= 2 && ch == ">") {
|
| 47 |
+
state.tokenize = tokenBase;
|
| 48 |
+
break;
|
| 49 |
+
}
|
| 50 |
+
dashes = (ch == "-") ? dashes + 1 : 0;
|
| 51 |
+
}
|
| 52 |
+
return ret("comment", "comment");
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function tokenString(quote) {
|
| 56 |
+
return function(stream, state) {
|
| 57 |
+
var escaped = false, ch;
|
| 58 |
+
while ((ch = stream.next()) != null) {
|
| 59 |
+
if (ch == quote && !escaped) {
|
| 60 |
+
state.tokenize = tokenBase;
|
| 61 |
+
break;
|
| 62 |
+
}
|
| 63 |
+
escaped = !escaped && ch == "\\";
|
| 64 |
+
}
|
| 65 |
+
return ret("string", "tag");
|
| 66 |
+
};
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
function inBlock(style, terminator) {
|
| 70 |
+
return function(stream, state) {
|
| 71 |
+
while (!stream.eol()) {
|
| 72 |
+
if (stream.match(terminator)) {
|
| 73 |
+
state.tokenize = tokenBase;
|
| 74 |
+
break;
|
| 75 |
+
}
|
| 76 |
+
stream.next();
|
| 77 |
+
}
|
| 78 |
+
return style;
|
| 79 |
+
};
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
const dtd = {
|
| 83 |
+
name: "dtd",
|
| 84 |
+
startState: function() {
|
| 85 |
+
return {tokenize: tokenBase,
|
| 86 |
+
baseIndent: 0,
|
| 87 |
+
stack: []};
|
| 88 |
+
},
|
| 89 |
+
|
| 90 |
+
token: function(stream, state) {
|
| 91 |
+
if (stream.eatSpace()) return null;
|
| 92 |
+
var style = state.tokenize(stream, state);
|
| 93 |
+
|
| 94 |
+
var context = state.stack[state.stack.length-1];
|
| 95 |
+
if (stream.current() == "[" || type === "doindent" || type == "[") state.stack.push("rule");
|
| 96 |
+
else if (type === "endtag") state.stack[state.stack.length-1] = "endtag";
|
| 97 |
+
else if (stream.current() == "]" || type == "]" || (type == ">" && context == "rule")) state.stack.pop();
|
| 98 |
+
else if (type == "[") state.stack.push("[");
|
| 99 |
+
return style;
|
| 100 |
+
},
|
| 101 |
+
|
| 102 |
+
indent: function(state, textAfter, cx) {
|
| 103 |
+
var n = state.stack.length;
|
| 104 |
+
|
| 105 |
+
if( textAfter.charAt(0) === ']' )n--;
|
| 106 |
+
else if(textAfter.substr(textAfter.length-1, textAfter.length) === ">"){
|
| 107 |
+
if(textAfter.substr(0,1) === "<") {}
|
| 108 |
+
else if( type == "doindent" && textAfter.length > 1 ) {}
|
| 109 |
+
else if( type == "doindent")n--;
|
| 110 |
+
else if( type == ">" && textAfter.length > 1) {}
|
| 111 |
+
else if( type == "tag" && textAfter !== ">") {}
|
| 112 |
+
else if( type == "tag" && state.stack[state.stack.length-1] == "rule")n--;
|
| 113 |
+
else if( type == "tag")n++;
|
| 114 |
+
else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule" && type === ">")n--;
|
| 115 |
+
else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule") {}
|
| 116 |
+
else if( textAfter.substr(0,1) !== "<" && textAfter.substr(0,1) === ">" )n=n-1;
|
| 117 |
+
else if( textAfter === ">") {}
|
| 118 |
+
else n=n-1;
|
| 119 |
+
//over rule them all
|
| 120 |
+
if(type == null || type == "]")n--;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
return state.baseIndent + n * cx.unit;
|
| 124 |
+
},
|
| 125 |
+
|
| 126 |
+
languageData: {
|
| 127 |
+
indentOnInput: /^\s*[\]>]$/
|
| 128 |
+
}
|
| 129 |
+
};
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
/***/ })
|
| 134 |
+
|
| 135 |
+
}]);
|
| 136 |
+
//# sourceMappingURL=221.21b91ccc95eefd849fa5.js.map?v=21b91ccc95eefd849fa5
|
vlmpy310/lib/python3.10/site-packages/notebook/static/2323.af9daee5d184a74db8a4.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vlmpy310/lib/python3.10/site-packages/notebook/static/2913.274b19d8f201991f4a69.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
vlmpy310/lib/python3.10/site-packages/notebook/static/32792104b5ef69eded90.woff
ADDED
|
Binary file (15.9 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/notebook/static/6521.95f93bd416d53955c700.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] = self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] || []).push([[6521],{
|
| 2 |
+
|
| 3 |
+
/***/ 86521:
|
| 4 |
+
/***/ ((module) => {
|
| 5 |
+
|
| 6 |
+
!function(e,t){ true?module.exports=t():0}(self,(()=>(()=>{"use strict";var e={6:(e,t)=>{function n(e){try{const t=new URL(e),n=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch(e){return!1}}Object.defineProperty(t,"__esModule",{value:!0}),t.LinkComputer=t.WebLinkProvider=void 0,t.WebLinkProvider=class{constructor(e,t,n,o={}){this._terminal=e,this._regex=t,this._handler=n,this._options=o}provideLinks(e,t){const n=o.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(n))}_addCallbacks(e){return e.map((e=>(e.leave=this._options.leave,e.hover=(t,n)=>{if(this._options.hover){const{range:o}=e;this._options.hover(t,n,o)}},e)))}};class o{static computeLink(e,t,r,i){const s=new RegExp(t.source,(t.flags||"")+"g"),[a,c]=o._getWindowedLineStrings(e-1,r),l=a.join("");let d;const p=[];for(;d=s.exec(l);){const e=d[0];if(!n(e))continue;const[t,s]=o._mapStrIdx(r,c,0,d.index),[a,l]=o._mapStrIdx(r,t,s,e.length);if(-1===t||-1===s||-1===a||-1===l)continue;const h={start:{x:s+1,y:t+1},end:{x:l,y:a+1}};p.push({range:h,text:e,activate:i})}return p}static _getWindowedLineStrings(e,t){let n,o=e,r=e,i=0,s="";const a=[];if(n=t.buffer.active.getLine(e)){const e=n.translateToString(!0);if(n.isWrapped&&" "!==e[0]){for(i=0;(n=t.buffer.active.getLine(--o))&&i<2048&&(s=n.translateToString(!0),i+=s.length,a.push(s),n.isWrapped&&-1===s.indexOf(" ")););a.reverse()}for(a.push(e),i=0;(n=t.buffer.active.getLine(++r))&&n.isWrapped&&i<2048&&(s=n.translateToString(!0),i+=s.length,a.push(s),-1===s.indexOf(" ")););}return[a,o]}static _mapStrIdx(e,t,n,o){const r=e.buffer.active,i=r.getNullCell();let s=n;for(;o;){const e=r.getLine(t);if(!e)return[-1,-1];for(let n=s;n<e.length;++n){e.getCell(n,i);const s=i.getChars();if(i.getWidth()&&(o-=s.length||1,n===e.length-1&&""===s)){const e=r.getLine(t+1);e&&e.isWrapped&&(e.getCell(0,i),2===i.getWidth()&&(o+=1))}if(o<0)return[t,n]}t++,s=0}return[t,s]}}t.LinkComputer=o}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}var o={};return(()=>{var e=o;Object.defineProperty(e,"__esModule",{value:!0}),e.WebLinksAddon=void 0;const t=n(6),r=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function i(e,t){const n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}e.WebLinksAddon=class{constructor(e=i,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;const n=this._options,o=n.urlRegex||r;this._linkProvider=this._terminal.registerLinkProvider(new t.WebLinkProvider(this._terminal,o,this._handler,n))}dispose(){this._linkProvider?.dispose()}}})(),o})()));
|
| 7 |
+
//# sourceMappingURL=addon-web-links.js.map
|
| 8 |
+
|
| 9 |
+
/***/ })
|
| 10 |
+
|
| 11 |
+
}]);
|
| 12 |
+
//# sourceMappingURL=6521.95f93bd416d53955c700.js.map?v=95f93bd416d53955c700
|
vlmpy310/lib/python3.10/site-packages/notebook/static/72bc573386dd1d48c5bb.woff
ADDED
|
Binary file (1.14 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/notebook/static/8979.cafa00ee6b2e82b39a17.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 38979:
|
| 5 |
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
| 6 |
+
|
| 7 |
+
__webpack_require__.r(__webpack_exports__);
|
| 8 |
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
| 9 |
+
/* harmony export */ cobol: () => (/* binding */ cobol)
|
| 10 |
+
/* harmony export */ });
|
| 11 |
+
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
| 12 |
+
ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",
|
| 13 |
+
COBOLLINENUM = "def", PERIOD = "link";
|
| 14 |
+
function makeKeywords(str) {
|
| 15 |
+
var obj = {}, words = str.split(" ");
|
| 16 |
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
| 17 |
+
return obj;
|
| 18 |
+
}
|
| 19 |
+
var atoms = makeKeywords("TRUE FALSE ZEROES ZEROS ZERO SPACES SPACE LOW-VALUE LOW-VALUES ");
|
| 20 |
+
var keywords = makeKeywords(
|
| 21 |
+
"ACCEPT ACCESS ACQUIRE ADD ADDRESS " +
|
| 22 |
+
"ADVANCING AFTER ALIAS ALL ALPHABET " +
|
| 23 |
+
"ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER ALPHANUMERIC ALPHANUMERIC-EDITED " +
|
| 24 |
+
"ALSO ALTER ALTERNATE AND ANY " +
|
| 25 |
+
"ARE AREA AREAS ARITHMETIC ASCENDING " +
|
| 26 |
+
"ASSIGN AT ATTRIBUTE AUTHOR AUTO " +
|
| 27 |
+
"AUTO-SKIP AUTOMATIC B-AND B-EXOR B-LESS " +
|
| 28 |
+
"B-NOT B-OR BACKGROUND-COLOR BACKGROUND-COLOUR BEEP " +
|
| 29 |
+
"BEFORE BELL BINARY BIT BITS " +
|
| 30 |
+
"BLANK BLINK BLOCK BOOLEAN BOTTOM " +
|
| 31 |
+
"BY CALL CANCEL CD CF " +
|
| 32 |
+
"CH CHARACTER CHARACTERS CLASS CLOCK-UNITS " +
|
| 33 |
+
"CLOSE COBOL CODE CODE-SET COL " +
|
| 34 |
+
"COLLATING COLUMN COMMA COMMIT COMMITMENT " +
|
| 35 |
+
"COMMON COMMUNICATION COMP COMP-0 COMP-1 " +
|
| 36 |
+
"COMP-2 COMP-3 COMP-4 COMP-5 COMP-6 " +
|
| 37 |
+
"COMP-7 COMP-8 COMP-9 COMPUTATIONAL COMPUTATIONAL-0 " +
|
| 38 |
+
"COMPUTATIONAL-1 COMPUTATIONAL-2 COMPUTATIONAL-3 COMPUTATIONAL-4 COMPUTATIONAL-5 " +
|
| 39 |
+
"COMPUTATIONAL-6 COMPUTATIONAL-7 COMPUTATIONAL-8 COMPUTATIONAL-9 COMPUTE " +
|
| 40 |
+
"CONFIGURATION CONNECT CONSOLE CONTAINED CONTAINS " +
|
| 41 |
+
"CONTENT CONTINUE CONTROL CONTROL-AREA CONTROLS " +
|
| 42 |
+
"CONVERTING COPY CORR CORRESPONDING COUNT " +
|
| 43 |
+
"CRT CRT-UNDER CURRENCY CURRENT CURSOR " +
|
| 44 |
+
"DATA DATE DATE-COMPILED DATE-WRITTEN DAY " +
|
| 45 |
+
"DAY-OF-WEEK DB DB-ACCESS-CONTROL-KEY DB-DATA-NAME DB-EXCEPTION " +
|
| 46 |
+
"DB-FORMAT-NAME DB-RECORD-NAME DB-SET-NAME DB-STATUS DBCS " +
|
| 47 |
+
"DBCS-EDITED DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE " +
|
| 48 |
+
"DEBUG-NAME DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING " +
|
| 49 |
+
"DECIMAL-POINT DECLARATIVES DEFAULT DELETE DELIMITED " +
|
| 50 |
+
"DELIMITER DEPENDING DESCENDING DESCRIBED DESTINATION " +
|
| 51 |
+
"DETAIL DISABLE DISCONNECT DISPLAY DISPLAY-1 " +
|
| 52 |
+
"DISPLAY-2 DISPLAY-3 DISPLAY-4 DISPLAY-5 DISPLAY-6 " +
|
| 53 |
+
"DISPLAY-7 DISPLAY-8 DISPLAY-9 DIVIDE DIVISION " +
|
| 54 |
+
"DOWN DROP DUPLICATE DUPLICATES DYNAMIC " +
|
| 55 |
+
"EBCDIC EGI EJECT ELSE EMI " +
|
| 56 |
+
"EMPTY EMPTY-CHECK ENABLE END END. END-ACCEPT END-ACCEPT. " +
|
| 57 |
+
"END-ADD END-CALL END-COMPUTE END-DELETE END-DISPLAY " +
|
| 58 |
+
"END-DIVIDE END-EVALUATE END-IF END-INVOKE END-MULTIPLY " +
|
| 59 |
+
"END-OF-PAGE END-PERFORM END-READ END-RECEIVE END-RETURN " +
|
| 60 |
+
"END-REWRITE END-SEARCH END-START END-STRING END-SUBTRACT " +
|
| 61 |
+
"END-UNSTRING END-WRITE END-XML ENTER ENTRY " +
|
| 62 |
+
"ENVIRONMENT EOP EQUAL EQUALS ERASE " +
|
| 63 |
+
"ERROR ESI EVALUATE EVERY EXCEEDS " +
|
| 64 |
+
"EXCEPTION EXCLUSIVE EXIT EXTEND EXTERNAL " +
|
| 65 |
+
"EXTERNALLY-DESCRIBED-KEY FD FETCH FILE FILE-CONTROL " +
|
| 66 |
+
"FILE-STREAM FILES FILLER FINAL FIND " +
|
| 67 |
+
"FINISH FIRST FOOTING FOR FOREGROUND-COLOR " +
|
| 68 |
+
"FOREGROUND-COLOUR FORMAT FREE FROM FULL " +
|
| 69 |
+
"FUNCTION GENERATE GET GIVING GLOBAL " +
|
| 70 |
+
"GO GOBACK GREATER GROUP HEADING " +
|
| 71 |
+
"HIGH-VALUE HIGH-VALUES HIGHLIGHT I-O I-O-CONTROL " +
|
| 72 |
+
"ID IDENTIFICATION IF IN INDEX " +
|
| 73 |
+
"INDEX-1 INDEX-2 INDEX-3 INDEX-4 INDEX-5 " +
|
| 74 |
+
"INDEX-6 INDEX-7 INDEX-8 INDEX-9 INDEXED " +
|
| 75 |
+
"INDIC INDICATE INDICATOR INDICATORS INITIAL " +
|
| 76 |
+
"INITIALIZE INITIATE INPUT INPUT-OUTPUT INSPECT " +
|
| 77 |
+
"INSTALLATION INTO INVALID INVOKE IS " +
|
| 78 |
+
"JUST JUSTIFIED KANJI KEEP KEY " +
|
| 79 |
+
"LABEL LAST LD LEADING LEFT " +
|
| 80 |
+
"LEFT-JUSTIFY LENGTH LENGTH-CHECK LESS LIBRARY " +
|
| 81 |
+
"LIKE LIMIT LIMITS LINAGE LINAGE-COUNTER " +
|
| 82 |
+
"LINE LINE-COUNTER LINES LINKAGE LOCAL-STORAGE " +
|
| 83 |
+
"LOCALE LOCALLY LOCK " +
|
| 84 |
+
"MEMBER MEMORY MERGE MESSAGE METACLASS " +
|
| 85 |
+
"MODE MODIFIED MODIFY MODULES MOVE " +
|
| 86 |
+
"MULTIPLE MULTIPLY NATIONAL NATIVE NEGATIVE " +
|
| 87 |
+
"NEXT NO NO-ECHO NONE NOT " +
|
| 88 |
+
"NULL NULL-KEY-MAP NULL-MAP NULLS NUMBER " +
|
| 89 |
+
"NUMERIC NUMERIC-EDITED OBJECT OBJECT-COMPUTER OCCURS " +
|
| 90 |
+
"OF OFF OMITTED ON ONLY " +
|
| 91 |
+
"OPEN OPTIONAL OR ORDER ORGANIZATION " +
|
| 92 |
+
"OTHER OUTPUT OVERFLOW OWNER PACKED-DECIMAL " +
|
| 93 |
+
"PADDING PAGE PAGE-COUNTER PARSE PERFORM " +
|
| 94 |
+
"PF PH PIC PICTURE PLUS " +
|
| 95 |
+
"POINTER POSITION POSITIVE PREFIX PRESENT " +
|
| 96 |
+
"PRINTING PRIOR PROCEDURE PROCEDURE-POINTER PROCEDURES " +
|
| 97 |
+
"PROCEED PROCESS PROCESSING PROGRAM PROGRAM-ID " +
|
| 98 |
+
"PROMPT PROTECTED PURGE QUEUE QUOTE " +
|
| 99 |
+
"QUOTES RANDOM RD READ READY " +
|
| 100 |
+
"REALM RECEIVE RECONNECT RECORD RECORD-NAME " +
|
| 101 |
+
"RECORDS RECURSIVE REDEFINES REEL REFERENCE " +
|
| 102 |
+
"REFERENCE-MONITOR REFERENCES RELATION RELATIVE RELEASE " +
|
| 103 |
+
"REMAINDER REMOVAL RENAMES REPEATED REPLACE " +
|
| 104 |
+
"REPLACING REPORT REPORTING REPORTS REPOSITORY " +
|
| 105 |
+
"REQUIRED RERUN RESERVE RESET RETAINING " +
|
| 106 |
+
"RETRIEVAL RETURN RETURN-CODE RETURNING REVERSE-VIDEO " +
|
| 107 |
+
"REVERSED REWIND REWRITE RF RH " +
|
| 108 |
+
"RIGHT RIGHT-JUSTIFY ROLLBACK ROLLING ROUNDED " +
|
| 109 |
+
"RUN SAME SCREEN SD SEARCH " +
|
| 110 |
+
"SECTION SECURE SECURITY SEGMENT SEGMENT-LIMIT " +
|
| 111 |
+
"SELECT SEND SENTENCE SEPARATE SEQUENCE " +
|
| 112 |
+
"SEQUENTIAL SET SHARED SIGN SIZE " +
|
| 113 |
+
"SKIP1 SKIP2 SKIP3 SORT SORT-MERGE " +
|
| 114 |
+
"SORT-RETURN SOURCE SOURCE-COMPUTER SPACE-FILL " +
|
| 115 |
+
"SPECIAL-NAMES STANDARD STANDARD-1 STANDARD-2 " +
|
| 116 |
+
"START STARTING STATUS STOP STORE " +
|
| 117 |
+
"STRING SUB-QUEUE-1 SUB-QUEUE-2 SUB-QUEUE-3 SUB-SCHEMA " +
|
| 118 |
+
"SUBFILE SUBSTITUTE SUBTRACT SUM SUPPRESS " +
|
| 119 |
+
"SYMBOLIC SYNC SYNCHRONIZED SYSIN SYSOUT " +
|
| 120 |
+
"TABLE TALLYING TAPE TENANT TERMINAL " +
|
| 121 |
+
"TERMINATE TEST TEXT THAN THEN " +
|
| 122 |
+
"THROUGH THRU TIME TIMES TITLE " +
|
| 123 |
+
"TO TOP TRAILING TRAILING-SIGN TRANSACTION " +
|
| 124 |
+
"TYPE TYPEDEF UNDERLINE UNEQUAL UNIT " +
|
| 125 |
+
"UNSTRING UNTIL UP UPDATE UPON " +
|
| 126 |
+
"USAGE USAGE-MODE USE USING VALID " +
|
| 127 |
+
"VALIDATE VALUE VALUES VARYING VLR " +
|
| 128 |
+
"WAIT WHEN WHEN-COMPILED WITH WITHIN " +
|
| 129 |
+
"WORDS WORKING-STORAGE WRITE XML XML-CODE " +
|
| 130 |
+
"XML-EVENT XML-NTEXT XML-TEXT ZERO ZERO-FILL " );
|
| 131 |
+
|
| 132 |
+
var builtins = makeKeywords("- * ** / + < <= = > >= ");
|
| 133 |
+
var tests = {
|
| 134 |
+
digit: /\d/,
|
| 135 |
+
digit_or_colon: /[\d:]/,
|
| 136 |
+
hex: /[0-9a-f]/i,
|
| 137 |
+
sign: /[+-]/,
|
| 138 |
+
exponent: /e/i,
|
| 139 |
+
keyword_char: /[^\s\(\[\;\)\]]/,
|
| 140 |
+
symbol: /[\w*+\-]/
|
| 141 |
+
};
|
| 142 |
+
function isNumber(ch, stream){
|
| 143 |
+
// hex
|
| 144 |
+
if ( ch === '0' && stream.eat(/x/i) ) {
|
| 145 |
+
stream.eatWhile(tests.hex);
|
| 146 |
+
return true;
|
| 147 |
+
}
|
| 148 |
+
// leading sign
|
| 149 |
+
if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {
|
| 150 |
+
stream.eat(tests.sign);
|
| 151 |
+
ch = stream.next();
|
| 152 |
+
}
|
| 153 |
+
if ( tests.digit.test(ch) ) {
|
| 154 |
+
stream.eat(ch);
|
| 155 |
+
stream.eatWhile(tests.digit);
|
| 156 |
+
if ( '.' == stream.peek()) {
|
| 157 |
+
stream.eat('.');
|
| 158 |
+
stream.eatWhile(tests.digit);
|
| 159 |
+
}
|
| 160 |
+
if ( stream.eat(tests.exponent) ) {
|
| 161 |
+
stream.eat(tests.sign);
|
| 162 |
+
stream.eatWhile(tests.digit);
|
| 163 |
+
}
|
| 164 |
+
return true;
|
| 165 |
+
}
|
| 166 |
+
return false;
|
| 167 |
+
}
|
| 168 |
+
const cobol = {
|
| 169 |
+
name: "cobol",
|
| 170 |
+
startState: function () {
|
| 171 |
+
return {
|
| 172 |
+
indentStack: null,
|
| 173 |
+
indentation: 0,
|
| 174 |
+
mode: false
|
| 175 |
+
};
|
| 176 |
+
},
|
| 177 |
+
token: function (stream, state) {
|
| 178 |
+
if (state.indentStack == null && stream.sol()) {
|
| 179 |
+
// update indentation, but only if indentStack is empty
|
| 180 |
+
state.indentation = 6 ; //stream.indentation();
|
| 181 |
+
}
|
| 182 |
+
// skip spaces
|
| 183 |
+
if (stream.eatSpace()) {
|
| 184 |
+
return null;
|
| 185 |
+
}
|
| 186 |
+
var returnType = null;
|
| 187 |
+
switch(state.mode){
|
| 188 |
+
case "string": // multi-line string parsing mode
|
| 189 |
+
var next = false;
|
| 190 |
+
while ((next = stream.next()) != null) {
|
| 191 |
+
if ((next == "\"" || next == "\'") && !stream.match(/['"]/, false)) {
|
| 192 |
+
state.mode = false;
|
| 193 |
+
break;
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
returnType = STRING; // continue on in string mode
|
| 197 |
+
break;
|
| 198 |
+
default: // default parsing mode
|
| 199 |
+
var ch = stream.next();
|
| 200 |
+
var col = stream.column();
|
| 201 |
+
if (col >= 0 && col <= 5) {
|
| 202 |
+
returnType = COBOLLINENUM;
|
| 203 |
+
} else if (col >= 72 && col <= 79) {
|
| 204 |
+
stream.skipToEnd();
|
| 205 |
+
returnType = MODTAG;
|
| 206 |
+
} else if (ch == "*" && col == 6) { // comment
|
| 207 |
+
stream.skipToEnd(); // rest of the line is a comment
|
| 208 |
+
returnType = COMMENT;
|
| 209 |
+
} else if (ch == "\"" || ch == "\'") {
|
| 210 |
+
state.mode = "string";
|
| 211 |
+
returnType = STRING;
|
| 212 |
+
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
|
| 213 |
+
returnType = ATOM;
|
| 214 |
+
} else if (ch == ".") {
|
| 215 |
+
returnType = PERIOD;
|
| 216 |
+
} else if (isNumber(ch,stream)){
|
| 217 |
+
returnType = NUMBER;
|
| 218 |
+
} else {
|
| 219 |
+
if (stream.current().match(tests.symbol)) {
|
| 220 |
+
while (col < 71) {
|
| 221 |
+
if (stream.eat(tests.symbol) === undefined) {
|
| 222 |
+
break;
|
| 223 |
+
} else {
|
| 224 |
+
col++;
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
|
| 229 |
+
returnType = KEYWORD;
|
| 230 |
+
} else if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase())) {
|
| 231 |
+
returnType = BUILTIN;
|
| 232 |
+
} else if (atoms && atoms.propertyIsEnumerable(stream.current().toUpperCase())) {
|
| 233 |
+
returnType = ATOM;
|
| 234 |
+
} else returnType = null;
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
return returnType;
|
| 238 |
+
},
|
| 239 |
+
indent: function (state) {
|
| 240 |
+
if (state.indentStack == null) return state.indentation;
|
| 241 |
+
return state.indentStack.indent;
|
| 242 |
+
}
|
| 243 |
+
};
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
/***/ })
|
| 248 |
+
|
| 249 |
+
}]);
|
| 250 |
+
//# sourceMappingURL=8979.cafa00ee6b2e82b39a17.js.map?v=cafa00ee6b2e82b39a17
|
vlmpy310/lib/python3.10/site-packages/notebook/static/899.5a5d6e7bd36baebe76af.js
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
(self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] = self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] || []).push([[899],{
|
| 3 |
+
|
| 4 |
+
/***/ 20899:
|
| 5 |
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
| 6 |
+
|
| 7 |
+
__webpack_require__.r(__webpack_exports__);
|
| 8 |
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
| 9 |
+
/* harmony export */ scheme: () => (/* binding */ scheme)
|
| 10 |
+
/* harmony export */ });
|
| 11 |
+
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
| 12 |
+
SYMBOL = "symbol", ATOM = "atom", NUMBER = "number", BRACKET = "bracket";
|
| 13 |
+
var INDENT_WORD_SKIP = 2;
|
| 14 |
+
|
| 15 |
+
function makeKeywords(str) {
|
| 16 |
+
var obj = {}, words = str.split(" ");
|
| 17 |
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
| 18 |
+
return obj;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
var keywords = makeKeywords("λ case-lambda call/cc class cond-expand define-class define-values exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax define-macro defmacro delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?");
|
| 22 |
+
var indentKeys = makeKeywords("define let letrec let* lambda define-macro defmacro let-syntax letrec-syntax let-values let*-values define-syntax syntax-rules define-values when unless");
|
| 23 |
+
|
| 24 |
+
function stateStack(indent, type, prev) { // represents a state stack object
|
| 25 |
+
this.indent = indent;
|
| 26 |
+
this.type = type;
|
| 27 |
+
this.prev = prev;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
function pushStack(state, indent, type) {
|
| 31 |
+
state.indentStack = new stateStack(indent, type, state.indentStack);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function popStack(state) {
|
| 35 |
+
state.indentStack = state.indentStack.prev;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
var binaryMatcher = new RegExp(/^(?:[-+]i|[-+][01]+#*(?:\/[01]+#*)?i|[-+]?[01]+#*(?:\/[01]+#*)?@[-+]?[01]+#*(?:\/[01]+#*)?|[-+]?[01]+#*(?:\/[01]+#*)?[-+](?:[01]+#*(?:\/[01]+#*)?)?i|[-+]?[01]+#*(?:\/[01]+#*)?)(?=[()\s;"]|$)/i);
|
| 39 |
+
var octalMatcher = new RegExp(/^(?:[-+]i|[-+][0-7]+#*(?:\/[0-7]+#*)?i|[-+]?[0-7]+#*(?:\/[0-7]+#*)?@[-+]?[0-7]+#*(?:\/[0-7]+#*)?|[-+]?[0-7]+#*(?:\/[0-7]+#*)?[-+](?:[0-7]+#*(?:\/[0-7]+#*)?)?i|[-+]?[0-7]+#*(?:\/[0-7]+#*)?)(?=[()\s;"]|$)/i);
|
| 40 |
+
var hexMatcher = new RegExp(/^(?:[-+]i|[-+][\da-f]+#*(?:\/[\da-f]+#*)?i|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?@[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?[-+](?:[\da-f]+#*(?:\/[\da-f]+#*)?)?i|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?)(?=[()\s;"]|$)/i);
|
| 41 |
+
var decimalMatcher = new RegExp(/^(?:[-+]i|[-+](?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)i|[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)@[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)|[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)[-+](?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)?i|(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*))(?=[()\s;"]|$)/i);
|
| 42 |
+
|
| 43 |
+
function isBinaryNumber (stream) {
|
| 44 |
+
return stream.match(binaryMatcher);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function isOctalNumber (stream) {
|
| 48 |
+
return stream.match(octalMatcher);
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
function isDecimalNumber (stream, backup) {
|
| 52 |
+
if (backup === true) {
|
| 53 |
+
stream.backUp(1);
|
| 54 |
+
}
|
| 55 |
+
return stream.match(decimalMatcher);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
function isHexNumber (stream) {
|
| 59 |
+
return stream.match(hexMatcher);
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
function processEscapedSequence(stream, options) {
|
| 63 |
+
var next, escaped = false;
|
| 64 |
+
while ((next = stream.next()) != null) {
|
| 65 |
+
if (next == options.token && !escaped) {
|
| 66 |
+
options.state.mode = false;
|
| 67 |
+
break;
|
| 68 |
+
}
|
| 69 |
+
escaped = !escaped && next == "\\";
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
const scheme = {
|
| 74 |
+
name: "scheme",
|
| 75 |
+
startState: function () {
|
| 76 |
+
return {
|
| 77 |
+
indentStack: null,
|
| 78 |
+
indentation: 0,
|
| 79 |
+
mode: false,
|
| 80 |
+
sExprComment: false,
|
| 81 |
+
sExprQuote: false
|
| 82 |
+
};
|
| 83 |
+
},
|
| 84 |
+
|
| 85 |
+
token: function (stream, state) {
|
| 86 |
+
if (state.indentStack == null && stream.sol()) {
|
| 87 |
+
// update indentation, but only if indentStack is empty
|
| 88 |
+
state.indentation = stream.indentation();
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
// skip spaces
|
| 92 |
+
if (stream.eatSpace()) {
|
| 93 |
+
return null;
|
| 94 |
+
}
|
| 95 |
+
var returnType = null;
|
| 96 |
+
|
| 97 |
+
switch(state.mode){
|
| 98 |
+
case "string": // multi-line string parsing mode
|
| 99 |
+
processEscapedSequence(stream, {
|
| 100 |
+
token: "\"",
|
| 101 |
+
state: state
|
| 102 |
+
});
|
| 103 |
+
returnType = STRING; // continue on in scheme-string mode
|
| 104 |
+
break;
|
| 105 |
+
case "symbol": // escape symbol
|
| 106 |
+
processEscapedSequence(stream, {
|
| 107 |
+
token: "|",
|
| 108 |
+
state: state
|
| 109 |
+
});
|
| 110 |
+
returnType = SYMBOL; // continue on in scheme-symbol mode
|
| 111 |
+
break;
|
| 112 |
+
case "comment": // comment parsing mode
|
| 113 |
+
var next, maybeEnd = false;
|
| 114 |
+
while ((next = stream.next()) != null) {
|
| 115 |
+
if (next == "#" && maybeEnd) {
|
| 116 |
+
|
| 117 |
+
state.mode = false;
|
| 118 |
+
break;
|
| 119 |
+
}
|
| 120 |
+
maybeEnd = (next == "|");
|
| 121 |
+
}
|
| 122 |
+
returnType = COMMENT;
|
| 123 |
+
break;
|
| 124 |
+
case "s-expr-comment": // s-expr commenting mode
|
| 125 |
+
state.mode = false;
|
| 126 |
+
if(stream.peek() == "(" || stream.peek() == "["){
|
| 127 |
+
// actually start scheme s-expr commenting mode
|
| 128 |
+
state.sExprComment = 0;
|
| 129 |
+
}else{
|
| 130 |
+
// if not we just comment the entire of the next token
|
| 131 |
+
stream.eatWhile(/[^\s\(\)\[\]]/); // eat symbol atom
|
| 132 |
+
returnType = COMMENT;
|
| 133 |
+
break;
|
| 134 |
+
}
|
| 135 |
+
default: // default parsing mode
|
| 136 |
+
var ch = stream.next();
|
| 137 |
+
|
| 138 |
+
if (ch == "\"") {
|
| 139 |
+
state.mode = "string";
|
| 140 |
+
returnType = STRING;
|
| 141 |
+
|
| 142 |
+
} else if (ch == "'") {
|
| 143 |
+
if (stream.peek() == "(" || stream.peek() == "["){
|
| 144 |
+
if (typeof state.sExprQuote != "number") {
|
| 145 |
+
state.sExprQuote = 0;
|
| 146 |
+
} // else already in a quoted expression
|
| 147 |
+
returnType = ATOM;
|
| 148 |
+
} else {
|
| 149 |
+
stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/);
|
| 150 |
+
returnType = ATOM;
|
| 151 |
+
}
|
| 152 |
+
} else if (ch == '|') {
|
| 153 |
+
state.mode = "symbol";
|
| 154 |
+
returnType = SYMBOL;
|
| 155 |
+
} else if (ch == '#') {
|
| 156 |
+
if (stream.eat("|")) { // Multi-line comment
|
| 157 |
+
state.mode = "comment"; // toggle to comment mode
|
| 158 |
+
returnType = COMMENT;
|
| 159 |
+
} else if (stream.eat(/[tf]/i)) { // #t/#f (atom)
|
| 160 |
+
returnType = ATOM;
|
| 161 |
+
} else if (stream.eat(';')) { // S-Expr comment
|
| 162 |
+
state.mode = "s-expr-comment";
|
| 163 |
+
returnType = COMMENT;
|
| 164 |
+
} else {
|
| 165 |
+
var numTest = null, hasExactness = false, hasRadix = true;
|
| 166 |
+
if (stream.eat(/[ei]/i)) {
|
| 167 |
+
hasExactness = true;
|
| 168 |
+
} else {
|
| 169 |
+
stream.backUp(1); // must be radix specifier
|
| 170 |
+
}
|
| 171 |
+
if (stream.match(/^#b/i)) {
|
| 172 |
+
numTest = isBinaryNumber;
|
| 173 |
+
} else if (stream.match(/^#o/i)) {
|
| 174 |
+
numTest = isOctalNumber;
|
| 175 |
+
} else if (stream.match(/^#x/i)) {
|
| 176 |
+
numTest = isHexNumber;
|
| 177 |
+
} else if (stream.match(/^#d/i)) {
|
| 178 |
+
numTest = isDecimalNumber;
|
| 179 |
+
} else if (stream.match(/^[-+0-9.]/, false)) {
|
| 180 |
+
hasRadix = false;
|
| 181 |
+
numTest = isDecimalNumber;
|
| 182 |
+
// re-consume the initial # if all matches failed
|
| 183 |
+
} else if (!hasExactness) {
|
| 184 |
+
stream.eat('#');
|
| 185 |
+
}
|
| 186 |
+
if (numTest != null) {
|
| 187 |
+
if (hasRadix && !hasExactness) {
|
| 188 |
+
// consume optional exactness after radix
|
| 189 |
+
stream.match(/^#[ei]/i);
|
| 190 |
+
}
|
| 191 |
+
if (numTest(stream))
|
| 192 |
+
returnType = NUMBER;
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
} else if (/^[-+0-9.]/.test(ch) && isDecimalNumber(stream, true)) { // match non-prefixed number, must be decimal
|
| 196 |
+
returnType = NUMBER;
|
| 197 |
+
} else if (ch == ";") { // comment
|
| 198 |
+
stream.skipToEnd(); // rest of the line is a comment
|
| 199 |
+
returnType = COMMENT;
|
| 200 |
+
} else if (ch == "(" || ch == "[") {
|
| 201 |
+
var keyWord = ''; var indentTemp = stream.column(), letter;
|
| 202 |
+
/**
|
| 203 |
+
Either
|
| 204 |
+
(indent-word ..
|
| 205 |
+
(non-indent-word ..
|
| 206 |
+
(;something else, bracket, etc.
|
| 207 |
+
*/
|
| 208 |
+
|
| 209 |
+
while ((letter = stream.eat(/[^\s\(\[\;\)\]]/)) != null) {
|
| 210 |
+
keyWord += letter;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
|
| 214 |
+
|
| 215 |
+
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
|
| 216 |
+
} else { // non-indent word
|
| 217 |
+
// we continue eating the spaces
|
| 218 |
+
stream.eatSpace();
|
| 219 |
+
if (stream.eol() || stream.peek() == ";") {
|
| 220 |
+
// nothing significant after
|
| 221 |
+
// we restart indentation 1 space after
|
| 222 |
+
pushStack(state, indentTemp + 1, ch);
|
| 223 |
+
} else {
|
| 224 |
+
pushStack(state, indentTemp + stream.current().length, ch); // else we match
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
stream.backUp(stream.current().length - 1); // undo all the eating
|
| 228 |
+
|
| 229 |
+
if(typeof state.sExprComment == "number") state.sExprComment++;
|
| 230 |
+
if(typeof state.sExprQuote == "number") state.sExprQuote++;
|
| 231 |
+
|
| 232 |
+
returnType = BRACKET;
|
| 233 |
+
} else if (ch == ")" || ch == "]") {
|
| 234 |
+
returnType = BRACKET;
|
| 235 |
+
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
|
| 236 |
+
popStack(state);
|
| 237 |
+
|
| 238 |
+
if(typeof state.sExprComment == "number"){
|
| 239 |
+
if(--state.sExprComment == 0){
|
| 240 |
+
returnType = COMMENT; // final closing bracket
|
| 241 |
+
state.sExprComment = false; // turn off s-expr commenting mode
|
| 242 |
+
}
|
| 243 |
+
}
|
| 244 |
+
if(typeof state.sExprQuote == "number"){
|
| 245 |
+
if(--state.sExprQuote == 0){
|
| 246 |
+
returnType = ATOM; // final closing bracket
|
| 247 |
+
state.sExprQuote = false; // turn off s-expr quote mode
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
} else {
|
| 252 |
+
stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/);
|
| 253 |
+
|
| 254 |
+
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
|
| 255 |
+
returnType = BUILTIN;
|
| 256 |
+
} else returnType = "variable";
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
return (typeof state.sExprComment == "number") ? COMMENT : ((typeof state.sExprQuote == "number") ? ATOM : returnType);
|
| 260 |
+
},
|
| 261 |
+
|
| 262 |
+
indent: function (state) {
|
| 263 |
+
if (state.indentStack == null) return state.indentation;
|
| 264 |
+
return state.indentStack.indent;
|
| 265 |
+
},
|
| 266 |
+
|
| 267 |
+
languageData: {
|
| 268 |
+
closeBrackets: {brackets: ["(", "[", "{", '"']},
|
| 269 |
+
commentTokens: {line: ";;"}
|
| 270 |
+
}
|
| 271 |
+
};
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
/***/ })
|
| 275 |
+
|
| 276 |
+
}]);
|
| 277 |
+
//# sourceMappingURL=899.5a5d6e7bd36baebe76af.js.map?v=5a5d6e7bd36baebe76af
|
vlmpy310/lib/python3.10/site-packages/notebook/static/9239.7bc21a4d374e6777cceb.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"file":"9239.7bc21a4d374e6777cceb.js?v=7bc21a4d374e6777cceb","mappings":";;;;;;;;;;;;;;;;;;;;;;AAAyE;AACtB;;AAEnD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,uBAAuB;;AAEvB,uBAAuB;;AAEvB,wBAAwB,8BAAiB;AACzC,+CAA+C;AAC/C,SAAS,MAAM;AACf;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED,uBAAuB,8BAAiB;AACxC;AACA,SAAS,MAAM;AACf;AACA;AACA;AACA;AACA,CAAC;;AAED,sBAAsB,8BAAiB;AACvC;AACA,SAAS,MAAM;AACf,2BAA2B,iBAAiB;AAC5C;AACA,WAAW,mBAAmB;AAC9B;AACA;AACA;AACA,CAAC;;AAED,wBAAwB,uBAAS;AACjC,iEAAiE,cAAI;AACrE,sBAAsB,cAAI;AAC1B,iBAAiB,cAAI;AACrB,gBAAgB,cAAI;AACpB,qBAAqB,cAAI;AACzB,WAAW,cAAI;AACf,aAAa,cAAI;AACjB,mBAAmB,cAAI,UAAU,cAAI;AACrC,UAAU,cAAI;AACd,8BAA8B,cAAI;AAClC,iBAAiB,cAAI;AACrB,iBAAiB,cAAI;AACrB,gBAAgB,cAAI;AACpB,gBAAgB,cAAI;AACpB,uBAAuB,cAAI;AAC3B,gBAAgB,cAAI;AACpB,UAAU,cAAI;AACd,QAAQ,cAAI;AACZ,uCAAuC,cAAI;AAC3C,WAAW,cAAI;AACf,gCAAgC,cAAI;AACpC,SAAS,cAAI;AACb,aAAa,cAAI;AACjB,W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,aAAa,KAAK,GAAG,sBAAsB,KAAK,GAAG,sBAAsB,KAAK,GAAG,gCAAgC,KAAK,GAAG,kCAAkC,KAAK,GAAG,yBAAyB,KAAK,GAAG,gCAAgC,KAAK,GAAG,uBAAuB,KAAK,GAAG,uBAAuB,KAAK,GAAG,mCAAmC,KAAK,GAAG,eAAe,OAAO;AAC5+G,mEAAmE,4BAAe,WAAW;AAC7F,aAAa,mCAAmC;AAChD,iBAAiB,iDAAiD,EAAE,oDAAoD,EAAE,qDAAqD;AAC/K;AACA,CAAC;;AAEiB;;;;;;;ACrHkB;AACsG;AACpF;;AAEtD;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,+BAA+B;AACjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,4BAA4B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,8BAA8B;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,+BAA+B;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,2BAA2B;AAC5C,MAAM,eAAU;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,iCAAW;AACpD;AACA;AACA,yBAAyB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D,8BAAQ;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,+BAA+B;AACjE;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU,aAAa,kBAAkB,6BAAU;AACnD;AACA;AACA;AACA,iBAAiB,kDAAkD,eAAU;AAC7E;AACA,iBAAiB,4CAA4C,eAAU;AACvE;AACA,iBAAiB,mDAAmD,eAAU;AAC9E;AACA,iBAAiB;AACjB;AACA;AACA;AACA,mBAAmB,SAAS,QAAQ,QAAQ;AAC5C;AACA,yBAAyB,kDAAkD,eAAU;AACrF,iBAAiB,0CAA0C,eAAU;AACrE;AACA;AACA;AACA;AACA;AACA,iBAAiB,6CAA6C,eAAU;AACxE;AACA,iBAAiB,sCAAsC,eAAU;AACjE;AACA,iBAAiB,4CAA4C,eAAU;AACvE;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,iCAAiC,yBAAU;AAC3C;AACA,yBAAyB,MAAM;AAC/B;AACA,yBAAyB,6BAAc;AACvC,0CAA0C,kCAAe;AACzD,aAAa;AACb,yBAAyB,2BAAY;AACrC,sCAAsC,yBAAU;AAChD,aAAa;AACb;AACA,KAAK;AACL;AACA,yBAAyB,SAAS,2BAA2B;AAC7D,8BAA8B;AAC9B;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA,eAAe,8BAAe,oCAAoC,mCAAmC;AACrG;;AAE4E","sources":["webpack://_JUPYTERLAB.CORE_OUTPUT/../node_modules/@lezer/css/dist/index.js","webpack://_JUPYTERLAB.CORE_OUTPUT/../node_modules/@codemirror/lang-css/dist/index.js"],"sourcesContent":["import { ExternalTokenizer, LRParser, LocalTokenGroup } from '@lezer/lr';\nimport { styleTags, tags } from '@lezer/highlight';\n\n// This file was generated by lezer-generator. You probably shouldn't edit it.\nconst descendantOp = 96,\n Unit = 1,\n callee = 97,\n identifier = 98,\n VariableName = 2;\n\n/* Hand-written tokenizers for CSS tokens that can't be\n expressed by Lezer's built-in tokenizer. */\n\nconst space = [9, 10, 11, 12, 13, 32, 133, 160, 5760, 8192, 8193, 8194, 8195, 8196, 8197,\n 8198, 8199, 8200, 8201, 8202, 8232, 8233, 8239, 8287, 12288];\nconst colon = 58, parenL = 40, underscore = 95, bracketL = 91, dash = 45, period = 46,\n hash = 35, percent = 37;\n\nfunction isAlpha(ch) { return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 || ch >= 161 }\n\nfunction isDigit(ch) { return ch >= 48 && ch <= 57 }\n\nconst identifiers = new ExternalTokenizer((input, stack) => {\n for (let inside = false, dashes = 0, i = 0;; i++) {\n let {next} = input;\n if (isAlpha(next) || next == dash || next == underscore || (inside && isDigit(next))) {\n if (!inside && (next != dash || i > 0)) inside = true;\n if (dashes === i && next == dash) dashes++;\n input.advance();\n } else {\n if (inside)\n input.acceptToken(next == parenL ? callee : dashes == 2 && stack.canShift(VariableName) ? VariableName : identifier);\n break\n }\n }\n});\n\nconst descendant = new ExternalTokenizer(input => {\n if (space.includes(input.peek(-1))) {\n let {next} = input;\n if (isAlpha(next) || next == underscore || next == hash || next == period ||\n next == bracketL || next == colon || next == dash)\n input.acceptToken(descendantOp);\n }\n});\n\nconst unitToken = new ExternalTokenizer(input => {\n if (!space.includes(input.peek(-1))) {\n let {next} = input;\n if (next == percent) { input.advance(); input.acceptToken(Unit); }\n if (isAlpha(next)) {\n do { input.advance(); } while (isAlpha(input.next))\n input.acceptToken(Unit);\n }\n }\n});\n\nconst cssHighlighting = styleTags({\n \"AtKeyword import charset namespace keyframes media supports\": tags.definitionKeyword,\n \"from to selector\": tags.keyword,\n NamespaceName: tags.namespace,\n KeyframeName: tags.labelName,\n KeyframeRangeName: tags.operatorKeyword,\n TagName: tags.tagName,\n ClassName: tags.className,\n PseudoClassName: tags.constant(tags.className),\n IdName: tags.labelName,\n \"FeatureName PropertyName\": tags.propertyName,\n AttributeName: tags.attributeName,\n NumberLiteral: tags.number,\n KeywordQuery: tags.keyword,\n UnaryQueryOp: tags.operatorKeyword,\n \"CallTag ValueName\": tags.atom,\n VariableName: tags.variableName,\n Callee: tags.operatorKeyword,\n Unit: tags.unit,\n \"UniversalSelector NestingSelector\": tags.definitionOperator,\n MatchOp: tags.compareOperator,\n \"ChildOp SiblingOp, LogicOp\": tags.logicOperator,\n BinOp: tags.arithmeticOperator,\n Important: tags.modifier,\n Comment: tags.blockComment,\n ColorLiteral: tags.color,\n \"ParenthesizedContent StringLiteral\": tags.string,\n \":\": tags.punctuation,\n \"PseudoOp #\": tags.derefOperator,\n \"; ,\": tags.separator,\n \"( )\": tags.paren,\n \"[ ]\": tags.squareBracket,\n \"{ }\": tags.brace\n});\n\n// This file was generated by lezer-generator. You probably shouldn't edit it.\nconst spec_callee = {__proto__:null,lang:32, \"nth-child\":32, \"nth-last-child\":32, \"nth-of-type\":32, \"nth-last-of-type\":32, dir:32, \"host-context\":32, url:60, \"url-prefix\":60, domain:60, regexp:60, selector:134};\nconst spec_AtKeyword = {__proto__:null,\"@import\":114, \"@media\":138, \"@charset\":142, \"@namespace\":146, \"@keyframes\":152, \"@supports\":164};\nconst spec_identifier = {__proto__:null,not:128, only:128};\nconst parser = LRParser.deserialize({\n version: 14,\n states: \"9bQYQ[OOO#_Q[OOP#fOWOOOOQP'#Cd'#CdOOQP'#Cc'#CcO#kQ[O'#CfO$_QXO'#CaO$fQ[O'#ChO$qQ[O'#DPO$vQ[O'#DTOOQP'#Ej'#EjO${QdO'#DeO%gQ[O'#DrO${QdO'#DtO%xQ[O'#DvO&TQ[O'#DyO&]Q[O'#EPO&kQ[O'#EROOQS'#Ei'#EiOOQS'#EU'#EUQYQ[OOO&rQXO'#CdO'gQWO'#DaO'lQWO'#EpO'wQ[O'#EpQOQWOOP(RO#tO'#C_POOO)C@X)C@XOOQP'#Cg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dhw!m#n^UOPdhw!m#nQ!toQ!|tQ!}uQ#OvQ#w#QR$W#cR#{#RQ!VZQ!c]Q#U!TQ#l!l[#y#R#z$R$j$o${Q#|#TQ$O#WS$a#l$cQ$f#uR$w$bR#x#QQiPR#PwQ!b[Q!jaR#X!VU!^[a!VQ!i`Q#^!]Q#b!_Q$T#_R$U#`\",\n nodeNames: \"⚠ Unit VariableName Comment StyleSheet RuleSet UniversalSelector TagSelector TagName NestingSelector ClassSelector ClassName PseudoClassSelector : :: PseudoClassName PseudoClassName ) ( ArgList ValueName ParenthesizedValue ColorLiteral NumberLiteral StringLiteral BinaryExpression BinOp CallExpression Callee CallLiteral CallTag ParenthesizedContent , PseudoClassName ArgList IdSelector # IdName ] AttributeSelector [ AttributeName MatchOp ChildSelector ChildOp DescendantSelector SiblingSelector SiblingOp } { Block Declaration PropertyName Important ; ImportStatement AtKeyword import KeywordQuery FeatureQuery FeatureName BinaryQuery LogicOp UnaryQuery UnaryQueryOp ParenthesizedQuery SelectorQuery selector MediaStatement media CharsetStatement charset NamespaceStatement namespace NamespaceName KeyframesStatement keyframes KeyframeName KeyframeList KeyframeSelector KeyframeRangeName SupportsStatement supports AtRule Styles\",\n maxTerm: 114,\n nodeProps: [\n [\"openedBy\", 17,\"(\",48,\"{\"],\n [\"closedBy\", 18,\")\",49,\"}\"]\n ],\n propSources: [cssHighlighting],\n skippedNodes: [0,3,85],\n repeatNodeCount: 10,\n tokenData: \"J^~R!^OX$}X^%u^p$}pq%uqr)Xrs.Rst/utu6duv$}vw7^wx7oxy9^yz9oz{9t{|:_|}?Q}!O?c!O!P@Q!P!Q@i!Q![Ab![!]B]!]!^CX!^!_$}!_!`Cj!`!aC{!a!b$}!b!cDw!c!}$}!}#OFa#O#P$}#P#QFr#Q#R6d#R#T$}#T#UGT#U#c$}#c#dHf#d#o$}#o#pH{#p#q6d#q#rI^#r#sIo#s#y$}#y#z%u#z$f$}$f$g%u$g#BY$}#BY#BZ%u#BZ$IS$}$IS$I_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%^bGWUOy%^z#b%^#b#cGj#c;'S%^;'S;=`%o<%lO%^bGoUo`Oy%^z#W%^#W#XHR#X;'S%^;'S;=`%o<%lO%^bHYS!`Qo`Oy%^z;'S%^;'S;=`%o<%lO%^bHiUOy%^z#f%^#f#gHR#g;'S%^;'S;=`%o<%lO%^fIQS!RUOy%^z;'S%^;'S;=`%o<%lO%^nIcS!Q^Oy%^z;'S%^;'S;=`%o<%lO%^fItU!PQOy%^z!_%^!_!`6y!`;'S%^;'S;=`%o<%lO%^`JZP;=`<%l$}\",\n tokenizers: [descendant, unitToken, identifiers, 1, 2, 3, 4, new LocalTokenGroup(\"m~RRYZ[z{a~~g~aO#Z~~dP!P!Qg~lO#[~~\", 28, 102)],\n topRules: {\"StyleSheet\":[0,4],\"Styles\":[1,84]},\n specialized: [{term: 97, get: value => spec_callee[value] || -1},{term: 56, get: value => spec_AtKeyword[value] || -1},{term: 98, get: value => spec_identifier[value] || -1}],\n tokenPrec: 1169\n});\n\nexport { parser };\n","import { parser } from '@lezer/css';\nimport { syntaxTree, LRLanguage, indentNodeProp, continuedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';\nimport { NodeWeakMap, IterMode } from '@lezer/common';\n\nlet _properties = null;\nfunction properties() {\n if (!_properties && typeof document == \"object\" && document.body) {\n let { style } = document.body, names = [], seen = new Set;\n for (let prop in style)\n if (prop != \"cssText\" && prop != \"cssFloat\") {\n if (typeof style[prop] == \"string\") {\n if (/[A-Z]/.test(prop))\n prop = prop.replace(/[A-Z]/g, ch => \"-\" + ch.toLowerCase());\n if (!seen.has(prop)) {\n names.push(prop);\n seen.add(prop);\n }\n }\n }\n _properties = names.sort().map(name => ({ type: \"property\", label: name }));\n }\n return _properties || [];\n}\nconst pseudoClasses = /*@__PURE__*/[\n \"active\", \"after\", \"any-link\", \"autofill\", \"backdrop\", \"before\",\n \"checked\", \"cue\", \"default\", \"defined\", \"disabled\", \"empty\",\n \"enabled\", \"file-selector-button\", \"first\", \"first-child\",\n \"first-letter\", \"first-line\", \"first-of-type\", \"focus\",\n \"focus-visible\", \"focus-within\", \"fullscreen\", \"has\", \"host\",\n \"host-context\", \"hover\", \"in-range\", \"indeterminate\", \"invalid\",\n \"is\", \"lang\", \"last-child\", \"last-of-type\", \"left\", \"link\", \"marker\",\n \"modal\", \"not\", \"nth-child\", \"nth-last-child\", \"nth-last-of-type\",\n \"nth-of-type\", \"only-child\", \"only-of-type\", \"optional\", \"out-of-range\",\n \"part\", \"placeholder\", \"placeholder-shown\", \"read-only\", \"read-write\",\n \"required\", \"right\", \"root\", \"scope\", \"selection\", \"slotted\", \"target\",\n \"target-text\", \"valid\", \"visited\", \"where\"\n].map(name => ({ type: \"class\", label: name }));\nconst values = /*@__PURE__*/[\n \"above\", \"absolute\", \"activeborder\", \"additive\", \"activecaption\", \"after-white-space\",\n \"ahead\", \"alias\", \"all\", \"all-scroll\", \"alphabetic\", \"alternate\", \"always\",\n \"antialiased\", \"appworkspace\", \"asterisks\", \"attr\", \"auto\", \"auto-flow\", \"avoid\", \"avoid-column\",\n \"avoid-page\", \"avoid-region\", \"axis-pan\", \"background\", \"backwards\", \"baseline\", \"below\",\n \"bidi-override\", \"blink\", \"block\", \"block-axis\", \"bold\", \"bolder\", \"border\", \"border-box\",\n \"both\", \"bottom\", \"break\", \"break-all\", \"break-word\", \"bullets\", \"button\", \"button-bevel\",\n \"buttonface\", \"buttonhighlight\", \"buttonshadow\", \"buttontext\", \"calc\", \"capitalize\",\n \"caps-lock-indicator\", \"caption\", \"captiontext\", \"caret\", \"cell\", \"center\", \"checkbox\", \"circle\",\n \"cjk-decimal\", \"clear\", \"clip\", \"close-quote\", \"col-resize\", \"collapse\", \"color\", \"color-burn\",\n \"color-dodge\", \"column\", \"column-reverse\", \"compact\", \"condensed\", \"contain\", \"content\",\n \"contents\", \"content-box\", \"context-menu\", \"continuous\", \"copy\", \"counter\", \"counters\", \"cover\",\n \"crop\", \"cross\", \"crosshair\", \"currentcolor\", \"cursive\", \"cyclic\", \"darken\", \"dashed\", \"decimal\",\n \"decimal-leading-zero\", \"default\", \"default-button\", \"dense\", \"destination-atop\", \"destination-in\",\n \"destination-out\", \"destination-over\", \"difference\", \"disc\", \"discard\", \"disclosure-closed\",\n \"disclosure-open\", \"document\", \"dot-dash\", \"dot-dot-dash\", \"dotted\", \"double\", \"down\", \"e-resize\",\n \"ease\", \"ease-in\", \"ease-in-out\", \"ease-out\", \"element\", \"ellipse\", \"ellipsis\", \"embed\", \"end\",\n \"ethiopic-abegede-gez\", \"ethiopic-halehame-aa-er\", \"ethiopic-halehame-gez\", \"ew-resize\", \"exclusion\",\n \"expanded\", \"extends\", \"extra-condensed\", \"extra-expanded\", \"fantasy\", \"fast\", \"fill\", \"fill-box\",\n \"fixed\", \"flat\", \"flex\", \"flex-end\", \"flex-start\", \"footnotes\", \"forwards\", \"from\",\n \"geometricPrecision\", \"graytext\", \"grid\", \"groove\", \"hand\", \"hard-light\", \"help\", \"hidden\", \"hide\",\n \"higher\", \"highlight\", \"highlighttext\", \"horizontal\", \"hsl\", \"hsla\", \"hue\", \"icon\", \"ignore\",\n \"inactiveborder\", \"inactivecaption\", \"inactivecaptiontext\", \"infinite\", \"infobackground\", \"infotext\",\n \"inherit\", \"initial\", \"inline\", \"inline-axis\", \"inline-block\", \"inline-flex\", \"inline-grid\",\n \"inline-table\", \"inset\", \"inside\", \"intrinsic\", \"invert\", \"italic\", \"justify\", \"keep-all\",\n \"landscape\", \"large\", \"larger\", \"left\", \"level\", \"lighter\", \"lighten\", \"line-through\", \"linear\",\n \"linear-gradient\", \"lines\", \"list-item\", \"listbox\", \"listitem\", \"local\", \"logical\", \"loud\", \"lower\",\n \"lower-hexadecimal\", \"lower-latin\", \"lower-norwegian\", \"lowercase\", \"ltr\", \"luminosity\", \"manipulation\",\n \"match\", \"matrix\", \"matrix3d\", \"medium\", \"menu\", \"menutext\", \"message-box\", \"middle\", \"min-intrinsic\",\n \"mix\", \"monospace\", \"move\", \"multiple\", \"multiple_mask_images\", \"multiply\", \"n-resize\", \"narrower\",\n \"ne-resize\", \"nesw-resize\", \"no-close-quote\", \"no-drop\", \"no-open-quote\", \"no-repeat\", \"none\",\n \"normal\", \"not-allowed\", \"nowrap\", \"ns-resize\", \"numbers\", \"numeric\", \"nw-resize\", \"nwse-resize\",\n \"oblique\", \"opacity\", \"open-quote\", \"optimizeLegibility\", \"optimizeSpeed\", \"outset\", \"outside\",\n \"outside-shape\", \"overlay\", \"overline\", \"padding\", \"padding-box\", \"painted\", \"page\", \"paused\",\n \"perspective\", \"pinch-zoom\", \"plus-darker\", \"plus-lighter\", \"pointer\", \"polygon\", \"portrait\",\n \"pre\", \"pre-line\", \"pre-wrap\", \"preserve-3d\", \"progress\", \"push-button\", \"radial-gradient\", \"radio\",\n \"read-only\", \"read-write\", \"read-write-plaintext-only\", \"rectangle\", \"region\", \"relative\", \"repeat\",\n \"repeating-linear-gradient\", \"repeating-radial-gradient\", \"repeat-x\", \"repeat-y\", \"reset\", \"reverse\",\n \"rgb\", \"rgba\", \"ridge\", \"right\", \"rotate\", \"rotate3d\", \"rotateX\", \"rotateY\", \"rotateZ\", \"round\",\n \"row\", \"row-resize\", \"row-reverse\", \"rtl\", \"run-in\", \"running\", \"s-resize\", \"sans-serif\", \"saturation\",\n \"scale\", \"scale3d\", \"scaleX\", \"scaleY\", \"scaleZ\", \"screen\", \"scroll\", \"scrollbar\", \"scroll-position\",\n \"se-resize\", \"self-start\", \"self-end\", \"semi-condensed\", \"semi-expanded\", \"separate\", \"serif\", \"show\",\n \"single\", \"skew\", \"skewX\", \"skewY\", \"skip-white-space\", \"slide\", \"slider-horizontal\",\n \"slider-vertical\", \"sliderthumb-horizontal\", \"sliderthumb-vertical\", \"slow\", \"small\", \"small-caps\",\n \"small-caption\", \"smaller\", \"soft-light\", \"solid\", \"source-atop\", \"source-in\", \"source-out\",\n \"source-over\", \"space\", \"space-around\", \"space-between\", \"space-evenly\", \"spell-out\", \"square\", \"start\",\n \"static\", \"status-bar\", \"stretch\", \"stroke\", \"stroke-box\", \"sub\", \"subpixel-antialiased\", \"svg_masks\",\n \"super\", \"sw-resize\", \"symbolic\", \"symbols\", \"system-ui\", \"table\", \"table-caption\", \"table-cell\",\n \"table-column\", \"table-column-group\", \"table-footer-group\", \"table-header-group\", \"table-row\",\n \"table-row-group\", \"text\", \"text-bottom\", \"text-top\", \"textarea\", \"textfield\", \"thick\", \"thin\",\n \"threeddarkshadow\", \"threedface\", \"threedhighlight\", \"threedlightshadow\", \"threedshadow\", \"to\", \"top\",\n \"transform\", \"translate\", \"translate3d\", \"translateX\", \"translateY\", \"translateZ\", \"transparent\",\n \"ultra-condensed\", \"ultra-expanded\", \"underline\", \"unidirectional-pan\", \"unset\", \"up\", \"upper-latin\",\n \"uppercase\", \"url\", \"var\", \"vertical\", \"vertical-text\", \"view-box\", \"visible\", \"visibleFill\",\n \"visiblePainted\", \"visibleStroke\", \"visual\", \"w-resize\", \"wait\", \"wave\", \"wider\", \"window\", \"windowframe\",\n \"windowtext\", \"words\", \"wrap\", \"wrap-reverse\", \"x-large\", \"x-small\", \"xor\", \"xx-large\", \"xx-small\"\n].map(name => ({ type: \"keyword\", label: name })).concat(/*@__PURE__*/[\n \"aliceblue\", \"antiquewhite\", \"aqua\", \"aquamarine\", \"azure\", \"beige\",\n \"bisque\", \"black\", \"blanchedalmond\", \"blue\", \"blueviolet\", \"brown\",\n \"burlywood\", \"cadetblue\", \"chartreuse\", \"chocolate\", \"coral\", \"cornflowerblue\",\n \"cornsilk\", \"crimson\", \"cyan\", \"darkblue\", \"darkcyan\", \"darkgoldenrod\",\n \"darkgray\", \"darkgreen\", \"darkkhaki\", \"darkmagenta\", \"darkolivegreen\",\n \"darkorange\", \"darkorchid\", \"darkred\", \"darksalmon\", \"darkseagreen\",\n \"darkslateblue\", \"darkslategray\", \"darkturquoise\", \"darkviolet\",\n \"deeppink\", \"deepskyblue\", \"dimgray\", \"dodgerblue\", \"firebrick\",\n \"floralwhite\", \"forestgreen\", \"fuchsia\", \"gainsboro\", \"ghostwhite\",\n \"gold\", \"goldenrod\", \"gray\", \"grey\", \"green\", \"greenyellow\", \"honeydew\",\n \"hotpink\", \"indianred\", \"indigo\", \"ivory\", \"khaki\", \"lavender\",\n \"lavenderblush\", \"lawngreen\", \"lemonchiffon\", \"lightblue\", \"lightcoral\",\n \"lightcyan\", \"lightgoldenrodyellow\", \"lightgray\", \"lightgreen\", \"lightpink\",\n \"lightsalmon\", \"lightseagreen\", \"lightskyblue\", \"lightslategray\",\n \"lightsteelblue\", \"lightyellow\", \"lime\", \"limegreen\", \"linen\", \"magenta\",\n \"maroon\", \"mediumaquamarine\", \"mediumblue\", \"mediumorchid\", \"mediumpurple\",\n \"mediumseagreen\", \"mediumslateblue\", \"mediumspringgreen\", \"mediumturquoise\",\n \"mediumvioletred\", \"midnightblue\", \"mintcream\", \"mistyrose\", \"moccasin\",\n \"navajowhite\", \"navy\", \"oldlace\", \"olive\", \"olivedrab\", \"orange\", \"orangered\",\n \"orchid\", \"palegoldenrod\", \"palegreen\", \"paleturquoise\", \"palevioletred\",\n \"papayawhip\", \"peachpuff\", \"peru\", \"pink\", \"plum\", \"powderblue\",\n \"purple\", \"rebeccapurple\", \"red\", \"rosybrown\", \"royalblue\", \"saddlebrown\",\n \"salmon\", \"sandybrown\", \"seagreen\", \"seashell\", \"sienna\", \"silver\", \"skyblue\",\n \"slateblue\", \"slategray\", \"snow\", \"springgreen\", \"steelblue\", \"tan\",\n \"teal\", \"thistle\", \"tomato\", \"turquoise\", \"violet\", \"wheat\", \"white\",\n \"whitesmoke\", \"yellow\", \"yellowgreen\"\n].map(name => ({ type: \"constant\", label: name })));\nconst tags = /*@__PURE__*/[\n \"a\", \"abbr\", \"address\", \"article\", \"aside\", \"b\", \"bdi\", \"bdo\", \"blockquote\", \"body\",\n \"br\", \"button\", \"canvas\", \"caption\", \"cite\", \"code\", \"col\", \"colgroup\", \"dd\", \"del\",\n \"details\", \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\", \"em\", \"figcaption\", \"figure\", \"footer\",\n \"form\", \"header\", \"hgroup\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"hr\", \"html\", \"i\", \"iframe\",\n \"img\", \"input\", \"ins\", \"kbd\", \"label\", \"legend\", \"li\", \"main\", \"meter\", \"nav\", \"ol\", \"output\",\n \"p\", \"pre\", \"ruby\", \"section\", \"select\", \"small\", \"source\", \"span\", \"strong\", \"sub\", \"summary\",\n \"sup\", \"table\", \"tbody\", \"td\", \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"tr\", \"u\", \"ul\"\n].map(name => ({ type: \"type\", label: name }));\nconst identifier = /^(\\w[\\w-]*|-\\w[\\w-]*|)$/, variable = /^-(-[\\w-]*)?$/;\nfunction isVarArg(node, doc) {\n var _a;\n if (node.name == \"(\" || node.type.isError)\n node = node.parent || node;\n if (node.name != \"ArgList\")\n return false;\n let callee = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.firstChild;\n if ((callee === null || callee === void 0 ? void 0 : callee.name) != \"Callee\")\n return false;\n return doc.sliceString(callee.from, callee.to) == \"var\";\n}\nconst VariablesByNode = /*@__PURE__*/new NodeWeakMap();\nconst declSelector = [\"Declaration\"];\nfunction astTop(node) {\n for (let cur = node;;) {\n if (cur.type.isTop)\n return cur;\n if (!(cur = cur.parent))\n return node;\n }\n}\nfunction variableNames(doc, node, isVariable) {\n if (node.to - node.from > 4096) {\n let known = VariablesByNode.get(node);\n if (known)\n return known;\n let result = [], seen = new Set, cursor = node.cursor(IterMode.IncludeAnonymous);\n if (cursor.firstChild())\n do {\n for (let option of variableNames(doc, cursor.node, isVariable))\n if (!seen.has(option.label)) {\n seen.add(option.label);\n result.push(option);\n }\n } while (cursor.nextSibling());\n VariablesByNode.set(node, result);\n return result;\n }\n else {\n let result = [], seen = new Set;\n node.cursor().iterate(node => {\n var _a;\n if (isVariable(node) && node.matchContext(declSelector) && ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == \":\") {\n let name = doc.sliceString(node.from, node.to);\n if (!seen.has(name)) {\n seen.add(name);\n result.push({ label: name, type: \"variable\" });\n }\n }\n });\n return result;\n }\n}\n/**\nCreate a completion source for a CSS dialect, providing a\npredicate for determining what kind of syntax node can act as a\ncompletable variable. This is used by language modes like Sass and\nLess to reuse this package's completion logic.\n*/\nconst defineCSSCompletionSource = (isVariable) => context => {\n let { state, pos } = context, node = syntaxTree(state).resolveInner(pos, -1);\n let isDash = node.type.isError && node.from == node.to - 1 && state.doc.sliceString(node.from, node.to) == \"-\";\n if (node.name == \"PropertyName\" ||\n (isDash || node.name == \"TagName\") && /^(Block|Styles)$/.test(node.resolve(node.to).name))\n return { from: node.from, options: properties(), validFor: identifier };\n if (node.name == \"ValueName\")\n return { from: node.from, options: values, validFor: identifier };\n if (node.name == \"PseudoClassName\")\n return { from: node.from, options: pseudoClasses, validFor: identifier };\n if (isVariable(node) || (context.explicit || isDash) && isVarArg(node, state.doc))\n return { from: isVariable(node) || isDash ? node.from : pos,\n options: variableNames(state.doc, astTop(node), isVariable),\n validFor: variable };\n if (node.name == \"TagName\") {\n for (let { parent } = node; parent; parent = parent.parent)\n if (parent.name == \"Block\")\n return { from: node.from, options: properties(), validFor: identifier };\n return { from: node.from, options: tags, validFor: identifier };\n }\n if (!context.explicit)\n return null;\n let above = node.resolve(pos), before = above.childBefore(pos);\n if (before && before.name == \":\" && above.name == \"PseudoClassSelector\")\n return { from: pos, options: pseudoClasses, validFor: identifier };\n if (before && before.name == \":\" && above.name == \"Declaration\" || above.name == \"ArgList\")\n return { from: pos, options: values, validFor: identifier };\n if (above.name == \"Block\" || above.name == \"Styles\")\n return { from: pos, options: properties(), validFor: identifier };\n return null;\n};\n/**\nCSS property, variable, and value keyword completion source.\n*/\nconst cssCompletionSource = /*@__PURE__*/defineCSSCompletionSource(n => n.name == \"VariableName\");\n\n/**\nA language provider based on the [Lezer CSS\nparser](https://github.com/lezer-parser/css), extended with\nhighlighting and indentation information.\n*/\nconst cssLanguage = /*@__PURE__*/LRLanguage.define({\n name: \"css\",\n parser: /*@__PURE__*/parser.configure({\n props: [\n /*@__PURE__*/indentNodeProp.add({\n Declaration: /*@__PURE__*/continuedIndent()\n }),\n /*@__PURE__*/foldNodeProp.add({\n \"Block KeyframeList\": foldInside\n })\n ]\n }),\n languageData: {\n commentTokens: { block: { open: \"/*\", close: \"*/\" } },\n indentOnInput: /^\\s*\\}$/,\n wordChars: \"-\"\n }\n});\n/**\nLanguage support for CSS.\n*/\nfunction css() {\n return new LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource }));\n}\n\nexport { css, cssCompletionSource, cssLanguage, defineCSSCompletionSource };\n"],"names":[],"sourceRoot":""}
|
vlmpy310/lib/python3.10/site-packages/tokenizers/__init__.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from enum import Enum
|
| 2 |
+
from typing import List, Tuple, Union
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
Offsets = Tuple[int, int]
|
| 6 |
+
|
| 7 |
+
TextInputSequence = str
|
| 8 |
+
"""A :obj:`str` that represents an input sequence """
|
| 9 |
+
|
| 10 |
+
PreTokenizedInputSequence = Union[List[str], Tuple[str]]
|
| 11 |
+
"""A pre-tokenized input sequence. Can be one of:
|
| 12 |
+
|
| 13 |
+
- A :obj:`List` of :obj:`str`
|
| 14 |
+
- A :obj:`Tuple` of :obj:`str`
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
TextEncodeInput = Union[
|
| 18 |
+
TextInputSequence,
|
| 19 |
+
Tuple[TextInputSequence, TextInputSequence],
|
| 20 |
+
List[TextInputSequence],
|
| 21 |
+
]
|
| 22 |
+
"""Represents a textual input for encoding. Can be either:
|
| 23 |
+
|
| 24 |
+
- A single sequence: :data:`~tokenizers.TextInputSequence`
|
| 25 |
+
- A pair of sequences:
|
| 26 |
+
|
| 27 |
+
- A :obj:`Tuple` of :data:`~tokenizers.TextInputSequence`
|
| 28 |
+
- Or a :obj:`List` of :data:`~tokenizers.TextInputSequence` of size 2
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
PreTokenizedEncodeInput = Union[
|
| 32 |
+
PreTokenizedInputSequence,
|
| 33 |
+
Tuple[PreTokenizedInputSequence, PreTokenizedInputSequence],
|
| 34 |
+
List[PreTokenizedInputSequence],
|
| 35 |
+
]
|
| 36 |
+
"""Represents a pre-tokenized input for encoding. Can be either:
|
| 37 |
+
|
| 38 |
+
- A single sequence: :data:`~tokenizers.PreTokenizedInputSequence`
|
| 39 |
+
- A pair of sequences:
|
| 40 |
+
|
| 41 |
+
- A :obj:`Tuple` of :data:`~tokenizers.PreTokenizedInputSequence`
|
| 42 |
+
- Or a :obj:`List` of :data:`~tokenizers.PreTokenizedInputSequence` of size 2
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
InputSequence = Union[TextInputSequence, PreTokenizedInputSequence]
|
| 46 |
+
"""Represents all the possible types of input sequences for encoding. Can be:
|
| 47 |
+
|
| 48 |
+
- When ``is_pretokenized=False``: :data:`~TextInputSequence`
|
| 49 |
+
- When ``is_pretokenized=True``: :data:`~PreTokenizedInputSequence`
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
EncodeInput = Union[TextEncodeInput, PreTokenizedEncodeInput]
|
| 53 |
+
"""Represents all the possible types of input for encoding. Can be:
|
| 54 |
+
|
| 55 |
+
- When ``is_pretokenized=False``: :data:`~TextEncodeInput`
|
| 56 |
+
- When ``is_pretokenized=True``: :data:`~PreTokenizedEncodeInput`
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
class OffsetReferential(Enum):
|
| 61 |
+
ORIGINAL = "original"
|
| 62 |
+
NORMALIZED = "normalized"
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
class OffsetType(Enum):
|
| 66 |
+
BYTE = "byte"
|
| 67 |
+
CHAR = "char"
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
class SplitDelimiterBehavior(Enum):
|
| 71 |
+
REMOVED = "removed"
|
| 72 |
+
ISOLATED = "isolated"
|
| 73 |
+
MERGED_WITH_PREVIOUS = "merged_with_previous"
|
| 74 |
+
MERGED_WITH_NEXT = "merged_with_next"
|
| 75 |
+
CONTIGUOUS = "contiguous"
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
from .tokenizers import (
|
| 79 |
+
AddedToken,
|
| 80 |
+
Encoding,
|
| 81 |
+
NormalizedString,
|
| 82 |
+
PreTokenizedString,
|
| 83 |
+
Regex,
|
| 84 |
+
Token,
|
| 85 |
+
Tokenizer,
|
| 86 |
+
decoders,
|
| 87 |
+
models,
|
| 88 |
+
normalizers,
|
| 89 |
+
pre_tokenizers,
|
| 90 |
+
processors,
|
| 91 |
+
trainers,
|
| 92 |
+
__version__,
|
| 93 |
+
)
|
| 94 |
+
from .implementations import (
|
| 95 |
+
BertWordPieceTokenizer,
|
| 96 |
+
ByteLevelBPETokenizer,
|
| 97 |
+
CharBPETokenizer,
|
| 98 |
+
SentencePieceBPETokenizer,
|
| 99 |
+
SentencePieceUnigramTokenizer,
|
| 100 |
+
)
|
vlmpy310/lib/python3.10/site-packages/tokenizers/__init__.pyi
ADDED
|
@@ -0,0 +1,1238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generated content DO NOT EDIT
|
| 2 |
+
class AddedToken:
|
| 3 |
+
"""
|
| 4 |
+
Represents a token that can be be added to a :class:`~tokenizers.Tokenizer`.
|
| 5 |
+
It can have special options that defines the way it should behave.
|
| 6 |
+
|
| 7 |
+
Args:
|
| 8 |
+
content (:obj:`str`): The content of the token
|
| 9 |
+
|
| 10 |
+
single_word (:obj:`bool`, defaults to :obj:`False`):
|
| 11 |
+
Defines whether this token should only match single words. If :obj:`True`, this
|
| 12 |
+
token will never match inside of a word. For example the token ``ing`` would match
|
| 13 |
+
on ``tokenizing`` if this option is :obj:`False`, but not if it is :obj:`True`.
|
| 14 |
+
The notion of "`inside of a word`" is defined by the word boundaries pattern in
|
| 15 |
+
regular expressions (ie. the token should start and end with word boundaries).
|
| 16 |
+
|
| 17 |
+
lstrip (:obj:`bool`, defaults to :obj:`False`):
|
| 18 |
+
Defines whether this token should strip all potential whitespaces on its left side.
|
| 19 |
+
If :obj:`True`, this token will greedily match any whitespace on its left. For
|
| 20 |
+
example if we try to match the token ``[MASK]`` with ``lstrip=True``, in the text
|
| 21 |
+
``"I saw a [MASK]"``, we would match on ``" [MASK]"``. (Note the space on the left).
|
| 22 |
+
|
| 23 |
+
rstrip (:obj:`bool`, defaults to :obj:`False`):
|
| 24 |
+
Defines whether this token should strip all potential whitespaces on its right
|
| 25 |
+
side. If :obj:`True`, this token will greedily match any whitespace on its right.
|
| 26 |
+
It works just like :obj:`lstrip` but on the right.
|
| 27 |
+
|
| 28 |
+
normalized (:obj:`bool`, defaults to :obj:`True` with :meth:`~tokenizers.Tokenizer.add_tokens` and :obj:`False` with :meth:`~tokenizers.Tokenizer.add_special_tokens`):
|
| 29 |
+
Defines whether this token should match against the normalized version of the input
|
| 30 |
+
text. For example, with the added token ``"yesterday"``, and a normalizer in charge of
|
| 31 |
+
lowercasing the text, the token could be extract from the input ``"I saw a lion
|
| 32 |
+
Yesterday"``.
|
| 33 |
+
special (:obj:`bool`, defaults to :obj:`False` with :meth:`~tokenizers.Tokenizer.add_tokens` and :obj:`False` with :meth:`~tokenizers.Tokenizer.add_special_tokens`):
|
| 34 |
+
Defines whether this token should be skipped when decoding.
|
| 35 |
+
|
| 36 |
+
"""
|
| 37 |
+
def __init__(self, content, single_word=False, lstrip=False, rstrip=False, normalized=True, special=False):
|
| 38 |
+
pass
|
| 39 |
+
|
| 40 |
+
@property
|
| 41 |
+
def content(self):
|
| 42 |
+
"""
|
| 43 |
+
Get the content of this :obj:`AddedToken`
|
| 44 |
+
"""
|
| 45 |
+
pass
|
| 46 |
+
|
| 47 |
+
@property
|
| 48 |
+
def lstrip(self):
|
| 49 |
+
"""
|
| 50 |
+
Get the value of the :obj:`lstrip` option
|
| 51 |
+
"""
|
| 52 |
+
pass
|
| 53 |
+
|
| 54 |
+
@property
|
| 55 |
+
def normalized(self):
|
| 56 |
+
"""
|
| 57 |
+
Get the value of the :obj:`normalized` option
|
| 58 |
+
"""
|
| 59 |
+
pass
|
| 60 |
+
|
| 61 |
+
@property
|
| 62 |
+
def rstrip(self):
|
| 63 |
+
"""
|
| 64 |
+
Get the value of the :obj:`rstrip` option
|
| 65 |
+
"""
|
| 66 |
+
pass
|
| 67 |
+
|
| 68 |
+
@property
|
| 69 |
+
def single_word(self):
|
| 70 |
+
"""
|
| 71 |
+
Get the value of the :obj:`single_word` option
|
| 72 |
+
"""
|
| 73 |
+
pass
|
| 74 |
+
|
| 75 |
+
@property
|
| 76 |
+
def special(self):
|
| 77 |
+
"""
|
| 78 |
+
Get the value of the :obj:`special` option
|
| 79 |
+
"""
|
| 80 |
+
pass
|
| 81 |
+
|
| 82 |
+
class Encoding:
|
| 83 |
+
"""
|
| 84 |
+
The :class:`~tokenizers.Encoding` represents the output of a :class:`~tokenizers.Tokenizer`.
|
| 85 |
+
"""
|
| 86 |
+
@property
|
| 87 |
+
def attention_mask(self):
|
| 88 |
+
"""
|
| 89 |
+
The attention mask
|
| 90 |
+
|
| 91 |
+
This indicates to the LM which tokens should be attended to, and which should not.
|
| 92 |
+
This is especially important when batching sequences, where we need to applying
|
| 93 |
+
padding.
|
| 94 |
+
|
| 95 |
+
Returns:
|
| 96 |
+
:obj:`List[int]`: The attention mask
|
| 97 |
+
"""
|
| 98 |
+
pass
|
| 99 |
+
|
| 100 |
+
def char_to_token(self, char_pos, sequence_index=0):
|
| 101 |
+
"""
|
| 102 |
+
Get the token that contains the char at the given position in the input sequence.
|
| 103 |
+
|
| 104 |
+
Args:
|
| 105 |
+
char_pos (:obj:`int`):
|
| 106 |
+
The position of a char in the input string
|
| 107 |
+
sequence_index (:obj:`int`, defaults to :obj:`0`):
|
| 108 |
+
The index of the sequence that contains the target char
|
| 109 |
+
|
| 110 |
+
Returns:
|
| 111 |
+
:obj:`int`: The index of the token that contains this char in the encoded sequence
|
| 112 |
+
"""
|
| 113 |
+
pass
|
| 114 |
+
|
| 115 |
+
def char_to_word(self, char_pos, sequence_index=0):
|
| 116 |
+
"""
|
| 117 |
+
Get the word that contains the char at the given position in the input sequence.
|
| 118 |
+
|
| 119 |
+
Args:
|
| 120 |
+
char_pos (:obj:`int`):
|
| 121 |
+
The position of a char in the input string
|
| 122 |
+
sequence_index (:obj:`int`, defaults to :obj:`0`):
|
| 123 |
+
The index of the sequence that contains the target char
|
| 124 |
+
|
| 125 |
+
Returns:
|
| 126 |
+
:obj:`int`: The index of the word that contains this char in the input sequence
|
| 127 |
+
"""
|
| 128 |
+
pass
|
| 129 |
+
|
| 130 |
+
@property
|
| 131 |
+
def ids(self):
|
| 132 |
+
"""
|
| 133 |
+
The generated IDs
|
| 134 |
+
|
| 135 |
+
The IDs are the main input to a Language Model. They are the token indices,
|
| 136 |
+
the numerical representations that a LM understands.
|
| 137 |
+
|
| 138 |
+
Returns:
|
| 139 |
+
:obj:`List[int]`: The list of IDs
|
| 140 |
+
"""
|
| 141 |
+
pass
|
| 142 |
+
|
| 143 |
+
@staticmethod
|
| 144 |
+
def merge(encodings, growing_offsets=True):
|
| 145 |
+
"""
|
| 146 |
+
Merge the list of encodings into one final :class:`~tokenizers.Encoding`
|
| 147 |
+
|
| 148 |
+
Args:
|
| 149 |
+
encodings (A :obj:`List` of :class:`~tokenizers.Encoding`):
|
| 150 |
+
The list of encodings that should be merged in one
|
| 151 |
+
|
| 152 |
+
growing_offsets (:obj:`bool`, defaults to :obj:`True`):
|
| 153 |
+
Whether the offsets should accumulate while merging
|
| 154 |
+
|
| 155 |
+
Returns:
|
| 156 |
+
:class:`~tokenizers.Encoding`: The resulting Encoding
|
| 157 |
+
"""
|
| 158 |
+
pass
|
| 159 |
+
|
| 160 |
+
@property
|
| 161 |
+
def n_sequences(self):
|
| 162 |
+
"""
|
| 163 |
+
The number of sequences represented
|
| 164 |
+
|
| 165 |
+
Returns:
|
| 166 |
+
:obj:`int`: The number of sequences in this :class:`~tokenizers.Encoding`
|
| 167 |
+
"""
|
| 168 |
+
pass
|
| 169 |
+
|
| 170 |
+
@property
|
| 171 |
+
def offsets(self):
|
| 172 |
+
"""
|
| 173 |
+
The offsets associated to each token
|
| 174 |
+
|
| 175 |
+
These offsets let's you slice the input string, and thus retrieve the original
|
| 176 |
+
part that led to producing the corresponding token.
|
| 177 |
+
|
| 178 |
+
Returns:
|
| 179 |
+
A :obj:`List` of :obj:`Tuple[int, int]`: The list of offsets
|
| 180 |
+
"""
|
| 181 |
+
pass
|
| 182 |
+
|
| 183 |
+
@property
|
| 184 |
+
def overflowing(self):
|
| 185 |
+
"""
|
| 186 |
+
A :obj:`List` of overflowing :class:`~tokenizers.Encoding`
|
| 187 |
+
|
| 188 |
+
When using truncation, the :class:`~tokenizers.Tokenizer` takes care of splitting
|
| 189 |
+
the output into as many pieces as required to match the specified maximum length.
|
| 190 |
+
This field lets you retrieve all the subsequent pieces.
|
| 191 |
+
|
| 192 |
+
When you use pairs of sequences, the overflowing pieces will contain enough
|
| 193 |
+
variations to cover all the possible combinations, while respecting the provided
|
| 194 |
+
maximum length.
|
| 195 |
+
"""
|
| 196 |
+
pass
|
| 197 |
+
|
| 198 |
+
def pad(self, length, direction="right", pad_id=0, pad_type_id=0, pad_token="[PAD]"):
|
| 199 |
+
"""
|
| 200 |
+
Pad the :class:`~tokenizers.Encoding` at the given length
|
| 201 |
+
|
| 202 |
+
Args:
|
| 203 |
+
length (:obj:`int`):
|
| 204 |
+
The desired length
|
| 205 |
+
|
| 206 |
+
direction: (:obj:`str`, defaults to :obj:`right`):
|
| 207 |
+
The expected padding direction. Can be either :obj:`right` or :obj:`left`
|
| 208 |
+
|
| 209 |
+
pad_id (:obj:`int`, defaults to :obj:`0`):
|
| 210 |
+
The ID corresponding to the padding token
|
| 211 |
+
|
| 212 |
+
pad_type_id (:obj:`int`, defaults to :obj:`0`):
|
| 213 |
+
The type ID corresponding to the padding token
|
| 214 |
+
|
| 215 |
+
pad_token (:obj:`str`, defaults to `[PAD]`):
|
| 216 |
+
The pad token to use
|
| 217 |
+
"""
|
| 218 |
+
pass
|
| 219 |
+
|
| 220 |
+
@property
|
| 221 |
+
def sequence_ids(self):
|
| 222 |
+
"""
|
| 223 |
+
The generated sequence indices.
|
| 224 |
+
|
| 225 |
+
They represent the index of the input sequence associated to each token.
|
| 226 |
+
The sequence id can be None if the token is not related to any input sequence,
|
| 227 |
+
like for example with special tokens.
|
| 228 |
+
|
| 229 |
+
Returns:
|
| 230 |
+
A :obj:`List` of :obj:`Optional[int]`: A list of optional sequence index.
|
| 231 |
+
"""
|
| 232 |
+
pass
|
| 233 |
+
|
| 234 |
+
def set_sequence_id(self, sequence_id):
|
| 235 |
+
"""
|
| 236 |
+
Set the given sequence index
|
| 237 |
+
|
| 238 |
+
Set the given sequence index for the whole range of tokens contained in this
|
| 239 |
+
:class:`~tokenizers.Encoding`.
|
| 240 |
+
"""
|
| 241 |
+
pass
|
| 242 |
+
|
| 243 |
+
@property
|
| 244 |
+
def special_tokens_mask(self):
|
| 245 |
+
"""
|
| 246 |
+
The special token mask
|
| 247 |
+
|
| 248 |
+
This indicates which tokens are special tokens, and which are not.
|
| 249 |
+
|
| 250 |
+
Returns:
|
| 251 |
+
:obj:`List[int]`: The special tokens mask
|
| 252 |
+
"""
|
| 253 |
+
pass
|
| 254 |
+
|
| 255 |
+
def token_to_chars(self, token_index):
|
| 256 |
+
"""
|
| 257 |
+
Get the offsets of the token at the given index.
|
| 258 |
+
|
| 259 |
+
The returned offsets are related to the input sequence that contains the
|
| 260 |
+
token. In order to determine in which input sequence it belongs, you
|
| 261 |
+
must call :meth:`~tokenizers.Encoding.token_to_sequence()`.
|
| 262 |
+
|
| 263 |
+
Args:
|
| 264 |
+
token_index (:obj:`int`):
|
| 265 |
+
The index of a token in the encoded sequence.
|
| 266 |
+
|
| 267 |
+
Returns:
|
| 268 |
+
:obj:`Tuple[int, int]`: The token offsets :obj:`(first, last + 1)`
|
| 269 |
+
"""
|
| 270 |
+
pass
|
| 271 |
+
|
| 272 |
+
def token_to_sequence(self, token_index):
|
| 273 |
+
"""
|
| 274 |
+
Get the index of the sequence represented by the given token.
|
| 275 |
+
|
| 276 |
+
In the general use case, this method returns :obj:`0` for a single sequence or
|
| 277 |
+
the first sequence of a pair, and :obj:`1` for the second sequence of a pair
|
| 278 |
+
|
| 279 |
+
Args:
|
| 280 |
+
token_index (:obj:`int`):
|
| 281 |
+
The index of a token in the encoded sequence.
|
| 282 |
+
|
| 283 |
+
Returns:
|
| 284 |
+
:obj:`int`: The sequence id of the given token
|
| 285 |
+
"""
|
| 286 |
+
pass
|
| 287 |
+
|
| 288 |
+
def token_to_word(self, token_index):
|
| 289 |
+
"""
|
| 290 |
+
Get the index of the word that contains the token in one of the input sequences.
|
| 291 |
+
|
| 292 |
+
The returned word index is related to the input sequence that contains
|
| 293 |
+
the token. In order to determine in which input sequence it belongs, you
|
| 294 |
+
must call :meth:`~tokenizers.Encoding.token_to_sequence()`.
|
| 295 |
+
|
| 296 |
+
Args:
|
| 297 |
+
token_index (:obj:`int`):
|
| 298 |
+
The index of a token in the encoded sequence.
|
| 299 |
+
|
| 300 |
+
Returns:
|
| 301 |
+
:obj:`int`: The index of the word in the relevant input sequence.
|
| 302 |
+
"""
|
| 303 |
+
pass
|
| 304 |
+
|
| 305 |
+
@property
|
| 306 |
+
def tokens(self):
|
| 307 |
+
"""
|
| 308 |
+
The generated tokens
|
| 309 |
+
|
| 310 |
+
They are the string representation of the IDs.
|
| 311 |
+
|
| 312 |
+
Returns:
|
| 313 |
+
:obj:`List[str]`: The list of tokens
|
| 314 |
+
"""
|
| 315 |
+
pass
|
| 316 |
+
|
| 317 |
+
def truncate(self, max_length, stride=0, direction="right"):
|
| 318 |
+
"""
|
| 319 |
+
Truncate the :class:`~tokenizers.Encoding` at the given length
|
| 320 |
+
|
| 321 |
+
If this :class:`~tokenizers.Encoding` represents multiple sequences, when truncating
|
| 322 |
+
this information is lost. It will be considered as representing a single sequence.
|
| 323 |
+
|
| 324 |
+
Args:
|
| 325 |
+
max_length (:obj:`int`):
|
| 326 |
+
The desired length
|
| 327 |
+
|
| 328 |
+
stride (:obj:`int`, defaults to :obj:`0`):
|
| 329 |
+
The length of previous content to be included in each overflowing piece
|
| 330 |
+
|
| 331 |
+
direction (:obj:`str`, defaults to :obj:`right`):
|
| 332 |
+
Truncate direction
|
| 333 |
+
"""
|
| 334 |
+
pass
|
| 335 |
+
|
| 336 |
+
@property
|
| 337 |
+
def type_ids(self):
|
| 338 |
+
"""
|
| 339 |
+
The generated type IDs
|
| 340 |
+
|
| 341 |
+
Generally used for tasks like sequence classification or question answering,
|
| 342 |
+
these tokens let the LM know which input sequence corresponds to each tokens.
|
| 343 |
+
|
| 344 |
+
Returns:
|
| 345 |
+
:obj:`List[int]`: The list of type ids
|
| 346 |
+
"""
|
| 347 |
+
pass
|
| 348 |
+
|
| 349 |
+
@property
|
| 350 |
+
def word_ids(self):
|
| 351 |
+
"""
|
| 352 |
+
The generated word indices.
|
| 353 |
+
|
| 354 |
+
They represent the index of the word associated to each token.
|
| 355 |
+
When the input is pre-tokenized, they correspond to the ID of the given input label,
|
| 356 |
+
otherwise they correspond to the words indices as defined by the
|
| 357 |
+
:class:`~tokenizers.pre_tokenizers.PreTokenizer` that was used.
|
| 358 |
+
|
| 359 |
+
For special tokens and such (any token that was generated from something that was
|
| 360 |
+
not part of the input), the output is :obj:`None`
|
| 361 |
+
|
| 362 |
+
Returns:
|
| 363 |
+
A :obj:`List` of :obj:`Optional[int]`: A list of optional word index.
|
| 364 |
+
"""
|
| 365 |
+
pass
|
| 366 |
+
|
| 367 |
+
def word_to_chars(self, word_index, sequence_index=0):
|
| 368 |
+
"""
|
| 369 |
+
Get the offsets of the word at the given index in one of the input sequences.
|
| 370 |
+
|
| 371 |
+
Args:
|
| 372 |
+
word_index (:obj:`int`):
|
| 373 |
+
The index of a word in one of the input sequences.
|
| 374 |
+
sequence_index (:obj:`int`, defaults to :obj:`0`):
|
| 375 |
+
The index of the sequence that contains the target word
|
| 376 |
+
|
| 377 |
+
Returns:
|
| 378 |
+
:obj:`Tuple[int, int]`: The range of characters (span) :obj:`(first, last + 1)`
|
| 379 |
+
"""
|
| 380 |
+
pass
|
| 381 |
+
|
| 382 |
+
def word_to_tokens(self, word_index, sequence_index=0):
|
| 383 |
+
"""
|
| 384 |
+
Get the encoded tokens corresponding to the word at the given index
|
| 385 |
+
in one of the input sequences.
|
| 386 |
+
|
| 387 |
+
Args:
|
| 388 |
+
word_index (:obj:`int`):
|
| 389 |
+
The index of a word in one of the input sequences.
|
| 390 |
+
sequence_index (:obj:`int`, defaults to :obj:`0`):
|
| 391 |
+
The index of the sequence that contains the target word
|
| 392 |
+
|
| 393 |
+
Returns:
|
| 394 |
+
:obj:`Tuple[int, int]`: The range of tokens: :obj:`(first, last + 1)`
|
| 395 |
+
"""
|
| 396 |
+
pass
|
| 397 |
+
|
| 398 |
+
@property
|
| 399 |
+
def words(self):
|
| 400 |
+
"""
|
| 401 |
+
The generated word indices.
|
| 402 |
+
|
| 403 |
+
.. warning::
|
| 404 |
+
This is deprecated and will be removed in a future version.
|
| 405 |
+
Please use :obj:`~tokenizers.Encoding.word_ids` instead.
|
| 406 |
+
|
| 407 |
+
They represent the index of the word associated to each token.
|
| 408 |
+
When the input is pre-tokenized, they correspond to the ID of the given input label,
|
| 409 |
+
otherwise they correspond to the words indices as defined by the
|
| 410 |
+
:class:`~tokenizers.pre_tokenizers.PreTokenizer` that was used.
|
| 411 |
+
|
| 412 |
+
For special tokens and such (any token that was generated from something that was
|
| 413 |
+
not part of the input), the output is :obj:`None`
|
| 414 |
+
|
| 415 |
+
Returns:
|
| 416 |
+
A :obj:`List` of :obj:`Optional[int]`: A list of optional word index.
|
| 417 |
+
"""
|
| 418 |
+
pass
|
| 419 |
+
|
| 420 |
+
class NormalizedString:
|
| 421 |
+
"""
|
| 422 |
+
NormalizedString
|
| 423 |
+
|
| 424 |
+
A NormalizedString takes care of modifying an "original" string, to obtain a "normalized" one.
|
| 425 |
+
While making all the requested modifications, it keeps track of the alignment information
|
| 426 |
+
between the two versions of the string.
|
| 427 |
+
|
| 428 |
+
Args:
|
| 429 |
+
sequence: str:
|
| 430 |
+
The string sequence used to initialize this NormalizedString
|
| 431 |
+
"""
|
| 432 |
+
def append(self, s):
|
| 433 |
+
"""
|
| 434 |
+
Append the given sequence to the string
|
| 435 |
+
"""
|
| 436 |
+
pass
|
| 437 |
+
|
| 438 |
+
def clear(self):
|
| 439 |
+
"""
|
| 440 |
+
Clears the string
|
| 441 |
+
"""
|
| 442 |
+
pass
|
| 443 |
+
|
| 444 |
+
def filter(self, func):
|
| 445 |
+
"""
|
| 446 |
+
Filter each character of the string using the given func
|
| 447 |
+
"""
|
| 448 |
+
pass
|
| 449 |
+
|
| 450 |
+
def for_each(self, func):
|
| 451 |
+
"""
|
| 452 |
+
Calls the given function for each character of the string
|
| 453 |
+
"""
|
| 454 |
+
pass
|
| 455 |
+
|
| 456 |
+
def lowercase(self):
|
| 457 |
+
"""
|
| 458 |
+
Lowercase the string
|
| 459 |
+
"""
|
| 460 |
+
pass
|
| 461 |
+
|
| 462 |
+
def lstrip(self):
|
| 463 |
+
"""
|
| 464 |
+
Strip the left of the string
|
| 465 |
+
"""
|
| 466 |
+
pass
|
| 467 |
+
|
| 468 |
+
def map(self, func):
|
| 469 |
+
"""
|
| 470 |
+
Calls the given function for each character of the string
|
| 471 |
+
|
| 472 |
+
Replaces each character of the string using the returned value. Each
|
| 473 |
+
returned value **must** be a str of length 1 (ie a character).
|
| 474 |
+
"""
|
| 475 |
+
pass
|
| 476 |
+
|
| 477 |
+
def nfc(self):
|
| 478 |
+
"""
|
| 479 |
+
Runs the NFC normalization
|
| 480 |
+
"""
|
| 481 |
+
pass
|
| 482 |
+
|
| 483 |
+
def nfd(self):
|
| 484 |
+
"""
|
| 485 |
+
Runs the NFD normalization
|
| 486 |
+
"""
|
| 487 |
+
pass
|
| 488 |
+
|
| 489 |
+
def nfkc(self):
|
| 490 |
+
"""
|
| 491 |
+
Runs the NFKC normalization
|
| 492 |
+
"""
|
| 493 |
+
pass
|
| 494 |
+
|
| 495 |
+
def nfkd(self):
|
| 496 |
+
"""
|
| 497 |
+
Runs the NFKD normalization
|
| 498 |
+
"""
|
| 499 |
+
pass
|
| 500 |
+
|
| 501 |
+
@property
|
| 502 |
+
def normalized(self):
|
| 503 |
+
"""
|
| 504 |
+
The normalized part of the string
|
| 505 |
+
"""
|
| 506 |
+
pass
|
| 507 |
+
|
| 508 |
+
def prepend(self, s):
|
| 509 |
+
"""
|
| 510 |
+
Prepend the given sequence to the string
|
| 511 |
+
"""
|
| 512 |
+
pass
|
| 513 |
+
|
| 514 |
+
def replace(self, pattern, content):
|
| 515 |
+
"""
|
| 516 |
+
Replace the content of the given pattern with the provided content
|
| 517 |
+
|
| 518 |
+
Args:
|
| 519 |
+
pattern: Pattern:
|
| 520 |
+
A pattern used to match the string. Usually a string or a Regex
|
| 521 |
+
|
| 522 |
+
content: str:
|
| 523 |
+
The content to be used as replacement
|
| 524 |
+
"""
|
| 525 |
+
pass
|
| 526 |
+
|
| 527 |
+
def rstrip(self):
|
| 528 |
+
"""
|
| 529 |
+
Strip the right of the string
|
| 530 |
+
"""
|
| 531 |
+
pass
|
| 532 |
+
|
| 533 |
+
def slice(self, range):
|
| 534 |
+
"""
|
| 535 |
+
Slice the string using the given range
|
| 536 |
+
"""
|
| 537 |
+
pass
|
| 538 |
+
|
| 539 |
+
def split(self, pattern, behavior):
|
| 540 |
+
"""
|
| 541 |
+
Split the NormalizedString using the given pattern and the specified behavior
|
| 542 |
+
|
| 543 |
+
Args:
|
| 544 |
+
pattern: Pattern:
|
| 545 |
+
A pattern used to split the string. Usually a string or a regex built with `tokenizers.Regex`
|
| 546 |
+
|
| 547 |
+
behavior: SplitDelimiterBehavior:
|
| 548 |
+
The behavior to use when splitting.
|
| 549 |
+
Choices: "removed", "isolated", "merged_with_previous", "merged_with_next",
|
| 550 |
+
"contiguous"
|
| 551 |
+
|
| 552 |
+
Returns:
|
| 553 |
+
A list of NormalizedString, representing each split
|
| 554 |
+
"""
|
| 555 |
+
pass
|
| 556 |
+
|
| 557 |
+
def strip(self):
|
| 558 |
+
"""
|
| 559 |
+
Strip both ends of the string
|
| 560 |
+
"""
|
| 561 |
+
pass
|
| 562 |
+
|
| 563 |
+
def uppercase(self):
|
| 564 |
+
"""
|
| 565 |
+
Uppercase the string
|
| 566 |
+
"""
|
| 567 |
+
pass
|
| 568 |
+
|
| 569 |
+
class PreTokenizedString:
|
| 570 |
+
"""
|
| 571 |
+
PreTokenizedString
|
| 572 |
+
|
| 573 |
+
Wrapper over a string, that provides a way to normalize, pre-tokenize, tokenize the
|
| 574 |
+
underlying string, while keeping track of the alignment information (offsets).
|
| 575 |
+
|
| 576 |
+
The PreTokenizedString manages what we call `splits`. Each split represents a substring
|
| 577 |
+
which is a subpart of the original string, with the relevant offsets and tokens.
|
| 578 |
+
|
| 579 |
+
When calling one of the methods used to modify the PreTokenizedString (namely one of
|
| 580 |
+
`split`, `normalize` or `tokenize), only the `splits` that don't have any associated
|
| 581 |
+
tokens will get modified.
|
| 582 |
+
|
| 583 |
+
Args:
|
| 584 |
+
sequence: str:
|
| 585 |
+
The string sequence used to initialize this PreTokenizedString
|
| 586 |
+
"""
|
| 587 |
+
def __init__(self, sequence):
|
| 588 |
+
pass
|
| 589 |
+
|
| 590 |
+
def get_splits(self, offset_referential="original", offset_type="char"):
|
| 591 |
+
"""
|
| 592 |
+
Get the splits currently managed by the PreTokenizedString
|
| 593 |
+
|
| 594 |
+
Args:
|
| 595 |
+
offset_referential: :obj:`str`
|
| 596 |
+
Whether the returned splits should have offsets expressed relative
|
| 597 |
+
to the original string, or the normalized one. choices: "original", "normalized".
|
| 598 |
+
|
| 599 |
+
offset_type: :obj:`str`
|
| 600 |
+
Whether the returned splits should have offsets expressed in bytes or chars.
|
| 601 |
+
When slicing an str, we usually want to use chars, which is the default value.
|
| 602 |
+
Now in some cases it might be interesting to get these offsets expressed in bytes,
|
| 603 |
+
so it is possible to change this here.
|
| 604 |
+
choices: "char", "bytes"
|
| 605 |
+
|
| 606 |
+
Returns
|
| 607 |
+
A list of splits
|
| 608 |
+
"""
|
| 609 |
+
pass
|
| 610 |
+
|
| 611 |
+
def normalize(self, func):
|
| 612 |
+
"""
|
| 613 |
+
Normalize each split of the `PreTokenizedString` using the given `func`
|
| 614 |
+
|
| 615 |
+
Args:
|
| 616 |
+
func: Callable[[NormalizedString], None]:
|
| 617 |
+
The function used to normalize each underlying split. This function
|
| 618 |
+
does not need to return anything, just calling the methods on the provided
|
| 619 |
+
NormalizedString allow its modification.
|
| 620 |
+
"""
|
| 621 |
+
pass
|
| 622 |
+
|
| 623 |
+
def split(self, func):
|
| 624 |
+
"""
|
| 625 |
+
Split the PreTokenizedString using the given `func`
|
| 626 |
+
|
| 627 |
+
Args:
|
| 628 |
+
func: Callable[[index, NormalizedString], List[NormalizedString]]:
|
| 629 |
+
The function used to split each underlying split.
|
| 630 |
+
It is expected to return a list of `NormalizedString`, that represent the new
|
| 631 |
+
splits. If the given `NormalizedString` does not need any splitting, we can
|
| 632 |
+
just return it directly.
|
| 633 |
+
In order for the offsets to be tracked accurately, any returned `NormalizedString`
|
| 634 |
+
should come from calling either `.split` or `.slice` on the received one.
|
| 635 |
+
"""
|
| 636 |
+
pass
|
| 637 |
+
|
| 638 |
+
def to_encoding(self, type_id=0, word_idx=None):
|
| 639 |
+
"""
|
| 640 |
+
Return an Encoding generated from this PreTokenizedString
|
| 641 |
+
|
| 642 |
+
Args:
|
| 643 |
+
type_id: int = 0:
|
| 644 |
+
The type_id to be used on the generated Encoding.
|
| 645 |
+
|
| 646 |
+
word_idx: Optional[int] = None:
|
| 647 |
+
An optional word index to be used for each token of this Encoding. If provided,
|
| 648 |
+
all the word indices in the generated Encoding will use this value, instead
|
| 649 |
+
of the one automatically tracked during pre-tokenization.
|
| 650 |
+
|
| 651 |
+
Returns:
|
| 652 |
+
An Encoding
|
| 653 |
+
"""
|
| 654 |
+
pass
|
| 655 |
+
|
| 656 |
+
def tokenize(self, func):
|
| 657 |
+
"""
|
| 658 |
+
Tokenize each split of the `PreTokenizedString` using the given `func`
|
| 659 |
+
|
| 660 |
+
Args:
|
| 661 |
+
func: Callable[[str], List[Token]]:
|
| 662 |
+
The function used to tokenize each underlying split. This function must return
|
| 663 |
+
a list of Token generated from the input str.
|
| 664 |
+
"""
|
| 665 |
+
pass
|
| 666 |
+
|
| 667 |
+
class Regex:
|
| 668 |
+
"""
|
| 669 |
+
Instantiate a new Regex with the given pattern
|
| 670 |
+
"""
|
| 671 |
+
def __init__(self, pattern):
|
| 672 |
+
pass
|
| 673 |
+
|
| 674 |
+
class Token:
|
| 675 |
+
pass
|
| 676 |
+
|
| 677 |
+
class Tokenizer:
|
| 678 |
+
"""
|
| 679 |
+
A :obj:`Tokenizer` works as a pipeline. It processes some raw text as input
|
| 680 |
+
and outputs an :class:`~tokenizers.Encoding`.
|
| 681 |
+
|
| 682 |
+
Args:
|
| 683 |
+
model (:class:`~tokenizers.models.Model`):
|
| 684 |
+
The core algorithm that this :obj:`Tokenizer` should be using.
|
| 685 |
+
|
| 686 |
+
"""
|
| 687 |
+
def __init__(self, model):
|
| 688 |
+
pass
|
| 689 |
+
|
| 690 |
+
def add_special_tokens(self, tokens):
|
| 691 |
+
"""
|
| 692 |
+
Add the given special tokens to the Tokenizer.
|
| 693 |
+
|
| 694 |
+
If these tokens are already part of the vocabulary, it just let the Tokenizer know about
|
| 695 |
+
them. If they don't exist, the Tokenizer creates them, giving them a new id.
|
| 696 |
+
|
| 697 |
+
These special tokens will never be processed by the model (ie won't be split into
|
| 698 |
+
multiple tokens), and they can be removed from the output when decoding.
|
| 699 |
+
|
| 700 |
+
Args:
|
| 701 |
+
tokens (A :obj:`List` of :class:`~tokenizers.AddedToken` or :obj:`str`):
|
| 702 |
+
The list of special tokens we want to add to the vocabulary. Each token can either
|
| 703 |
+
be a string or an instance of :class:`~tokenizers.AddedToken` for more
|
| 704 |
+
customization.
|
| 705 |
+
|
| 706 |
+
Returns:
|
| 707 |
+
:obj:`int`: The number of tokens that were created in the vocabulary
|
| 708 |
+
"""
|
| 709 |
+
pass
|
| 710 |
+
|
| 711 |
+
def add_tokens(self, tokens):
|
| 712 |
+
"""
|
| 713 |
+
Add the given tokens to the vocabulary
|
| 714 |
+
|
| 715 |
+
The given tokens are added only if they don't already exist in the vocabulary.
|
| 716 |
+
Each token then gets a new attributed id.
|
| 717 |
+
|
| 718 |
+
Args:
|
| 719 |
+
tokens (A :obj:`List` of :class:`~tokenizers.AddedToken` or :obj:`str`):
|
| 720 |
+
The list of tokens we want to add to the vocabulary. Each token can be either a
|
| 721 |
+
string or an instance of :class:`~tokenizers.AddedToken` for more customization.
|
| 722 |
+
|
| 723 |
+
Returns:
|
| 724 |
+
:obj:`int`: The number of tokens that were created in the vocabulary
|
| 725 |
+
"""
|
| 726 |
+
pass
|
| 727 |
+
|
| 728 |
+
def decode(self, ids, skip_special_tokens=True):
|
| 729 |
+
"""
|
| 730 |
+
Decode the given list of ids back to a string
|
| 731 |
+
|
| 732 |
+
This is used to decode anything coming back from a Language Model
|
| 733 |
+
|
| 734 |
+
Args:
|
| 735 |
+
ids (A :obj:`List/Tuple` of :obj:`int`):
|
| 736 |
+
The list of ids that we want to decode
|
| 737 |
+
|
| 738 |
+
skip_special_tokens (:obj:`bool`, defaults to :obj:`True`):
|
| 739 |
+
Whether the special tokens should be removed from the decoded string
|
| 740 |
+
|
| 741 |
+
Returns:
|
| 742 |
+
:obj:`str`: The decoded string
|
| 743 |
+
"""
|
| 744 |
+
pass
|
| 745 |
+
|
| 746 |
+
def decode_batch(self, sequences, skip_special_tokens=True):
|
| 747 |
+
"""
|
| 748 |
+
Decode a batch of ids back to their corresponding string
|
| 749 |
+
|
| 750 |
+
Args:
|
| 751 |
+
sequences (:obj:`List` of :obj:`List[int]`):
|
| 752 |
+
The batch of sequences we want to decode
|
| 753 |
+
|
| 754 |
+
skip_special_tokens (:obj:`bool`, defaults to :obj:`True`):
|
| 755 |
+
Whether the special tokens should be removed from the decoded strings
|
| 756 |
+
|
| 757 |
+
Returns:
|
| 758 |
+
:obj:`List[str]`: A list of decoded strings
|
| 759 |
+
"""
|
| 760 |
+
pass
|
| 761 |
+
|
| 762 |
+
@property
|
| 763 |
+
def decoder(self):
|
| 764 |
+
"""
|
| 765 |
+
The `optional` :class:`~tokenizers.decoders.Decoder` in use by the Tokenizer
|
| 766 |
+
"""
|
| 767 |
+
pass
|
| 768 |
+
|
| 769 |
+
def enable_padding(
|
| 770 |
+
self, direction="right", pad_id=0, pad_type_id=0, pad_token="[PAD]", length=None, pad_to_multiple_of=None
|
| 771 |
+
):
|
| 772 |
+
"""
|
| 773 |
+
Enable the padding
|
| 774 |
+
|
| 775 |
+
Args:
|
| 776 |
+
direction (:obj:`str`, `optional`, defaults to :obj:`right`):
|
| 777 |
+
The direction in which to pad. Can be either ``right`` or ``left``
|
| 778 |
+
|
| 779 |
+
pad_to_multiple_of (:obj:`int`, `optional`):
|
| 780 |
+
If specified, the padding length should always snap to the next multiple of the
|
| 781 |
+
given value. For example if we were going to pad witha length of 250 but
|
| 782 |
+
``pad_to_multiple_of=8`` then we will pad to 256.
|
| 783 |
+
|
| 784 |
+
pad_id (:obj:`int`, defaults to 0):
|
| 785 |
+
The id to be used when padding
|
| 786 |
+
|
| 787 |
+
pad_type_id (:obj:`int`, defaults to 0):
|
| 788 |
+
The type id to be used when padding
|
| 789 |
+
|
| 790 |
+
pad_token (:obj:`str`, defaults to :obj:`[PAD]`):
|
| 791 |
+
The pad token to be used when padding
|
| 792 |
+
|
| 793 |
+
length (:obj:`int`, `optional`):
|
| 794 |
+
If specified, the length at which to pad. If not specified we pad using the size of
|
| 795 |
+
the longest sequence in a batch.
|
| 796 |
+
"""
|
| 797 |
+
pass
|
| 798 |
+
|
| 799 |
+
def enable_truncation(self, max_length, stride=0, strategy="longest_first", direction="right"):
|
| 800 |
+
"""
|
| 801 |
+
Enable truncation
|
| 802 |
+
|
| 803 |
+
Args:
|
| 804 |
+
max_length (:obj:`int`):
|
| 805 |
+
The max length at which to truncate
|
| 806 |
+
|
| 807 |
+
stride (:obj:`int`, `optional`):
|
| 808 |
+
The length of the previous first sequence to be included in the overflowing
|
| 809 |
+
sequence
|
| 810 |
+
|
| 811 |
+
strategy (:obj:`str`, `optional`, defaults to :obj:`longest_first`):
|
| 812 |
+
The strategy used to truncation. Can be one of ``longest_first``, ``only_first`` or
|
| 813 |
+
``only_second``.
|
| 814 |
+
|
| 815 |
+
direction (:obj:`str`, defaults to :obj:`right`):
|
| 816 |
+
Truncate direction
|
| 817 |
+
"""
|
| 818 |
+
pass
|
| 819 |
+
|
| 820 |
+
def encode(self, sequence, pair=None, is_pretokenized=False, add_special_tokens=True):
|
| 821 |
+
"""
|
| 822 |
+
Encode the given sequence and pair. This method can process raw text sequences
|
| 823 |
+
as well as already pre-tokenized sequences.
|
| 824 |
+
|
| 825 |
+
Example:
|
| 826 |
+
Here are some examples of the inputs that are accepted::
|
| 827 |
+
|
| 828 |
+
encode("A single sequence")`
|
| 829 |
+
encode("A sequence", "And its pair")`
|
| 830 |
+
encode([ "A", "pre", "tokenized", "sequence" ], is_pretokenized=True)`
|
| 831 |
+
encode(
|
| 832 |
+
[ "A", "pre", "tokenized", "sequence" ], [ "And", "its", "pair" ],
|
| 833 |
+
is_pretokenized=True
|
| 834 |
+
)
|
| 835 |
+
|
| 836 |
+
Args:
|
| 837 |
+
sequence (:obj:`~tokenizers.InputSequence`):
|
| 838 |
+
The main input sequence we want to encode. This sequence can be either raw
|
| 839 |
+
text or pre-tokenized, according to the ``is_pretokenized`` argument:
|
| 840 |
+
|
| 841 |
+
- If ``is_pretokenized=False``: :class:`~tokenizers.TextInputSequence`
|
| 842 |
+
- If ``is_pretokenized=True``: :class:`~tokenizers.PreTokenizedInputSequence`
|
| 843 |
+
|
| 844 |
+
pair (:obj:`~tokenizers.InputSequence`, `optional`):
|
| 845 |
+
An optional input sequence. The expected format is the same that for ``sequence``.
|
| 846 |
+
|
| 847 |
+
is_pretokenized (:obj:`bool`, defaults to :obj:`False`):
|
| 848 |
+
Whether the input is already pre-tokenized
|
| 849 |
+
|
| 850 |
+
add_special_tokens (:obj:`bool`, defaults to :obj:`True`):
|
| 851 |
+
Whether to add the special tokens
|
| 852 |
+
|
| 853 |
+
Returns:
|
| 854 |
+
:class:`~tokenizers.Encoding`: The encoded result
|
| 855 |
+
|
| 856 |
+
"""
|
| 857 |
+
pass
|
| 858 |
+
|
| 859 |
+
def encode_batch(self, input, is_pretokenized=False, add_special_tokens=True):
|
| 860 |
+
"""
|
| 861 |
+
Encode the given batch of inputs. This method accept both raw text sequences
|
| 862 |
+
as well as already pre-tokenized sequences. The reason we use `PySequence` is
|
| 863 |
+
because it allows type checking with zero-cost (according to PyO3) as we don't
|
| 864 |
+
have to convert to check.
|
| 865 |
+
|
| 866 |
+
Example:
|
| 867 |
+
Here are some examples of the inputs that are accepted::
|
| 868 |
+
|
| 869 |
+
encode_batch([
|
| 870 |
+
"A single sequence",
|
| 871 |
+
("A tuple with a sequence", "And its pair"),
|
| 872 |
+
[ "A", "pre", "tokenized", "sequence" ],
|
| 873 |
+
([ "A", "pre", "tokenized", "sequence" ], "And its pair")
|
| 874 |
+
])
|
| 875 |
+
|
| 876 |
+
Args:
|
| 877 |
+
input (A :obj:`List`/:obj:`Tuple` of :obj:`~tokenizers.EncodeInput`):
|
| 878 |
+
A list of single sequences or pair sequences to encode. Each sequence
|
| 879 |
+
can be either raw text or pre-tokenized, according to the ``is_pretokenized``
|
| 880 |
+
argument:
|
| 881 |
+
|
| 882 |
+
- If ``is_pretokenized=False``: :class:`~tokenizers.TextEncodeInput`
|
| 883 |
+
- If ``is_pretokenized=True``: :class:`~tokenizers.PreTokenizedEncodeInput`
|
| 884 |
+
|
| 885 |
+
is_pretokenized (:obj:`bool`, defaults to :obj:`False`):
|
| 886 |
+
Whether the input is already pre-tokenized
|
| 887 |
+
|
| 888 |
+
add_special_tokens (:obj:`bool`, defaults to :obj:`True`):
|
| 889 |
+
Whether to add the special tokens
|
| 890 |
+
|
| 891 |
+
Returns:
|
| 892 |
+
A :obj:`List` of :class:`~tokenizers.Encoding`: The encoded batch
|
| 893 |
+
|
| 894 |
+
"""
|
| 895 |
+
pass
|
| 896 |
+
|
| 897 |
+
def encode_batch_fast(self, input, is_pretokenized=False, add_special_tokens=True):
|
| 898 |
+
"""
|
| 899 |
+
Encode the given batch of inputs. This method is faster than `encode_batch`
|
| 900 |
+
because it doesn't keep track of offsets, they will be all zeros.
|
| 901 |
+
|
| 902 |
+
Example:
|
| 903 |
+
Here are some examples of the inputs that are accepted::
|
| 904 |
+
|
| 905 |
+
encode_batch_fast([
|
| 906 |
+
"A single sequence",
|
| 907 |
+
("A tuple with a sequence", "And its pair"),
|
| 908 |
+
[ "A", "pre", "tokenized", "sequence" ],
|
| 909 |
+
([ "A", "pre", "tokenized", "sequence" ], "And its pair")
|
| 910 |
+
])
|
| 911 |
+
|
| 912 |
+
Args:
|
| 913 |
+
input (A :obj:`List`/:obj:`Tuple` of :obj:`~tokenizers.EncodeInput`):
|
| 914 |
+
A list of single sequences or pair sequences to encode. Each sequence
|
| 915 |
+
can be either raw text or pre-tokenized, according to the ``is_pretokenized``
|
| 916 |
+
argument:
|
| 917 |
+
|
| 918 |
+
- If ``is_pretokenized=False``: :class:`~tokenizers.TextEncodeInput`
|
| 919 |
+
- If ``is_pretokenized=True``: :class:`~tokenizers.PreTokenizedEncodeInput`
|
| 920 |
+
|
| 921 |
+
is_pretokenized (:obj:`bool`, defaults to :obj:`False`):
|
| 922 |
+
Whether the input is already pre-tokenized
|
| 923 |
+
|
| 924 |
+
add_special_tokens (:obj:`bool`, defaults to :obj:`True`):
|
| 925 |
+
Whether to add the special tokens
|
| 926 |
+
|
| 927 |
+
Returns:
|
| 928 |
+
A :obj:`List` of :class:`~tokenizers.Encoding`: The encoded batch
|
| 929 |
+
|
| 930 |
+
"""
|
| 931 |
+
pass
|
| 932 |
+
|
| 933 |
+
@property
|
| 934 |
+
def encode_special_tokens(self):
|
| 935 |
+
"""
|
| 936 |
+
Modifies the tokenizer in order to use or not the special tokens
|
| 937 |
+
during encoding.
|
| 938 |
+
|
| 939 |
+
Args:
|
| 940 |
+
value (:obj:`bool`):
|
| 941 |
+
Whether to use the special tokens or not
|
| 942 |
+
|
| 943 |
+
"""
|
| 944 |
+
pass
|
| 945 |
+
|
| 946 |
+
@staticmethod
|
| 947 |
+
def from_buffer(buffer):
|
| 948 |
+
"""
|
| 949 |
+
Instantiate a new :class:`~tokenizers.Tokenizer` from the given buffer.
|
| 950 |
+
|
| 951 |
+
Args:
|
| 952 |
+
buffer (:obj:`bytes`):
|
| 953 |
+
A buffer containing a previously serialized :class:`~tokenizers.Tokenizer`
|
| 954 |
+
|
| 955 |
+
Returns:
|
| 956 |
+
:class:`~tokenizers.Tokenizer`: The new tokenizer
|
| 957 |
+
"""
|
| 958 |
+
pass
|
| 959 |
+
|
| 960 |
+
@staticmethod
|
| 961 |
+
def from_file(path):
|
| 962 |
+
"""
|
| 963 |
+
Instantiate a new :class:`~tokenizers.Tokenizer` from the file at the given path.
|
| 964 |
+
|
| 965 |
+
Args:
|
| 966 |
+
path (:obj:`str`):
|
| 967 |
+
A path to a local JSON file representing a previously serialized
|
| 968 |
+
:class:`~tokenizers.Tokenizer`
|
| 969 |
+
|
| 970 |
+
Returns:
|
| 971 |
+
:class:`~tokenizers.Tokenizer`: The new tokenizer
|
| 972 |
+
"""
|
| 973 |
+
pass
|
| 974 |
+
|
| 975 |
+
@staticmethod
|
| 976 |
+
def from_pretrained(identifier, revision="main", token=None):
|
| 977 |
+
"""
|
| 978 |
+
Instantiate a new :class:`~tokenizers.Tokenizer` from an existing file on the
|
| 979 |
+
Hugging Face Hub.
|
| 980 |
+
|
| 981 |
+
Args:
|
| 982 |
+
identifier (:obj:`str`):
|
| 983 |
+
The identifier of a Model on the Hugging Face Hub, that contains
|
| 984 |
+
a tokenizer.json file
|
| 985 |
+
revision (:obj:`str`, defaults to `main`):
|
| 986 |
+
A branch or commit id
|
| 987 |
+
token (:obj:`str`, `optional`, defaults to `None`):
|
| 988 |
+
An optional auth token used to access private repositories on the
|
| 989 |
+
Hugging Face Hub
|
| 990 |
+
|
| 991 |
+
Returns:
|
| 992 |
+
:class:`~tokenizers.Tokenizer`: The new tokenizer
|
| 993 |
+
"""
|
| 994 |
+
pass
|
| 995 |
+
|
| 996 |
+
@staticmethod
|
| 997 |
+
def from_str(json):
|
| 998 |
+
"""
|
| 999 |
+
Instantiate a new :class:`~tokenizers.Tokenizer` from the given JSON string.
|
| 1000 |
+
|
| 1001 |
+
Args:
|
| 1002 |
+
json (:obj:`str`):
|
| 1003 |
+
A valid JSON string representing a previously serialized
|
| 1004 |
+
:class:`~tokenizers.Tokenizer`
|
| 1005 |
+
|
| 1006 |
+
Returns:
|
| 1007 |
+
:class:`~tokenizers.Tokenizer`: The new tokenizer
|
| 1008 |
+
"""
|
| 1009 |
+
pass
|
| 1010 |
+
|
| 1011 |
+
def get_added_tokens_decoder(self):
|
| 1012 |
+
"""
|
| 1013 |
+
Get the underlying vocabulary
|
| 1014 |
+
|
| 1015 |
+
Returns:
|
| 1016 |
+
:obj:`Dict[int, AddedToken]`: The vocabulary
|
| 1017 |
+
"""
|
| 1018 |
+
pass
|
| 1019 |
+
|
| 1020 |
+
def get_vocab(self, with_added_tokens=True):
|
| 1021 |
+
"""
|
| 1022 |
+
Get the underlying vocabulary
|
| 1023 |
+
|
| 1024 |
+
Args:
|
| 1025 |
+
with_added_tokens (:obj:`bool`, defaults to :obj:`True`):
|
| 1026 |
+
Whether to include the added tokens
|
| 1027 |
+
|
| 1028 |
+
Returns:
|
| 1029 |
+
:obj:`Dict[str, int]`: The vocabulary
|
| 1030 |
+
"""
|
| 1031 |
+
pass
|
| 1032 |
+
|
| 1033 |
+
def get_vocab_size(self, with_added_tokens=True):
|
| 1034 |
+
"""
|
| 1035 |
+
Get the size of the underlying vocabulary
|
| 1036 |
+
|
| 1037 |
+
Args:
|
| 1038 |
+
with_added_tokens (:obj:`bool`, defaults to :obj:`True`):
|
| 1039 |
+
Whether to include the added tokens
|
| 1040 |
+
|
| 1041 |
+
Returns:
|
| 1042 |
+
:obj:`int`: The size of the vocabulary
|
| 1043 |
+
"""
|
| 1044 |
+
pass
|
| 1045 |
+
|
| 1046 |
+
def id_to_token(self, id):
|
| 1047 |
+
"""
|
| 1048 |
+
Convert the given id to its corresponding token if it exists
|
| 1049 |
+
|
| 1050 |
+
Args:
|
| 1051 |
+
id (:obj:`int`):
|
| 1052 |
+
The id to convert
|
| 1053 |
+
|
| 1054 |
+
Returns:
|
| 1055 |
+
:obj:`Optional[str]`: An optional token, :obj:`None` if out of vocabulary
|
| 1056 |
+
"""
|
| 1057 |
+
pass
|
| 1058 |
+
|
| 1059 |
+
@property
|
| 1060 |
+
def model(self):
|
| 1061 |
+
"""
|
| 1062 |
+
The :class:`~tokenizers.models.Model` in use by the Tokenizer
|
| 1063 |
+
"""
|
| 1064 |
+
pass
|
| 1065 |
+
|
| 1066 |
+
def no_padding(self):
|
| 1067 |
+
"""
|
| 1068 |
+
Disable padding
|
| 1069 |
+
"""
|
| 1070 |
+
pass
|
| 1071 |
+
|
| 1072 |
+
def no_truncation(self):
|
| 1073 |
+
"""
|
| 1074 |
+
Disable truncation
|
| 1075 |
+
"""
|
| 1076 |
+
pass
|
| 1077 |
+
|
| 1078 |
+
@property
|
| 1079 |
+
def normalizer(self):
|
| 1080 |
+
"""
|
| 1081 |
+
The `optional` :class:`~tokenizers.normalizers.Normalizer` in use by the Tokenizer
|
| 1082 |
+
"""
|
| 1083 |
+
pass
|
| 1084 |
+
|
| 1085 |
+
def num_special_tokens_to_add(self, is_pair):
|
| 1086 |
+
"""
|
| 1087 |
+
Return the number of special tokens that would be added for single/pair sentences.
|
| 1088 |
+
:param is_pair: Boolean indicating if the input would be a single sentence or a pair
|
| 1089 |
+
:return:
|
| 1090 |
+
"""
|
| 1091 |
+
pass
|
| 1092 |
+
|
| 1093 |
+
@property
|
| 1094 |
+
def padding(self):
|
| 1095 |
+
"""
|
| 1096 |
+
Get the current padding parameters
|
| 1097 |
+
|
| 1098 |
+
`Cannot be set, use` :meth:`~tokenizers.Tokenizer.enable_padding` `instead`
|
| 1099 |
+
|
| 1100 |
+
Returns:
|
| 1101 |
+
(:obj:`dict`, `optional`):
|
| 1102 |
+
A dict with the current padding parameters if padding is enabled
|
| 1103 |
+
"""
|
| 1104 |
+
pass
|
| 1105 |
+
|
| 1106 |
+
def post_process(self, encoding, pair=None, add_special_tokens=True):
|
| 1107 |
+
"""
|
| 1108 |
+
Apply all the post-processing steps to the given encodings.
|
| 1109 |
+
|
| 1110 |
+
The various steps are:
|
| 1111 |
+
|
| 1112 |
+
1. Truncate according to the set truncation params (provided with
|
| 1113 |
+
:meth:`~tokenizers.Tokenizer.enable_truncation`)
|
| 1114 |
+
2. Apply the :class:`~tokenizers.processors.PostProcessor`
|
| 1115 |
+
3. Pad according to the set padding params (provided with
|
| 1116 |
+
:meth:`~tokenizers.Tokenizer.enable_padding`)
|
| 1117 |
+
|
| 1118 |
+
Args:
|
| 1119 |
+
encoding (:class:`~tokenizers.Encoding`):
|
| 1120 |
+
The :class:`~tokenizers.Encoding` corresponding to the main sequence.
|
| 1121 |
+
|
| 1122 |
+
pair (:class:`~tokenizers.Encoding`, `optional`):
|
| 1123 |
+
An optional :class:`~tokenizers.Encoding` corresponding to the pair sequence.
|
| 1124 |
+
|
| 1125 |
+
add_special_tokens (:obj:`bool`):
|
| 1126 |
+
Whether to add the special tokens
|
| 1127 |
+
|
| 1128 |
+
Returns:
|
| 1129 |
+
:class:`~tokenizers.Encoding`: The final post-processed encoding
|
| 1130 |
+
"""
|
| 1131 |
+
pass
|
| 1132 |
+
|
| 1133 |
+
@property
|
| 1134 |
+
def post_processor(self):
|
| 1135 |
+
"""
|
| 1136 |
+
The `optional` :class:`~tokenizers.processors.PostProcessor` in use by the Tokenizer
|
| 1137 |
+
"""
|
| 1138 |
+
pass
|
| 1139 |
+
|
| 1140 |
+
@property
|
| 1141 |
+
def pre_tokenizer(self):
|
| 1142 |
+
"""
|
| 1143 |
+
The `optional` :class:`~tokenizers.pre_tokenizers.PreTokenizer` in use by the Tokenizer
|
| 1144 |
+
"""
|
| 1145 |
+
pass
|
| 1146 |
+
|
| 1147 |
+
def save(self, path, pretty=True):
|
| 1148 |
+
"""
|
| 1149 |
+
Save the :class:`~tokenizers.Tokenizer` to the file at the given path.
|
| 1150 |
+
|
| 1151 |
+
Args:
|
| 1152 |
+
path (:obj:`str`):
|
| 1153 |
+
A path to a file in which to save the serialized tokenizer.
|
| 1154 |
+
|
| 1155 |
+
pretty (:obj:`bool`, defaults to :obj:`True`):
|
| 1156 |
+
Whether the JSON file should be pretty formatted.
|
| 1157 |
+
"""
|
| 1158 |
+
pass
|
| 1159 |
+
|
| 1160 |
+
def to_str(self, pretty=False):
|
| 1161 |
+
"""
|
| 1162 |
+
Gets a serialized string representing this :class:`~tokenizers.Tokenizer`.
|
| 1163 |
+
|
| 1164 |
+
Args:
|
| 1165 |
+
pretty (:obj:`bool`, defaults to :obj:`False`):
|
| 1166 |
+
Whether the JSON string should be pretty formatted.
|
| 1167 |
+
|
| 1168 |
+
Returns:
|
| 1169 |
+
:obj:`str`: A string representing the serialized Tokenizer
|
| 1170 |
+
"""
|
| 1171 |
+
pass
|
| 1172 |
+
|
| 1173 |
+
def token_to_id(self, token):
|
| 1174 |
+
"""
|
| 1175 |
+
Convert the given token to its corresponding id if it exists
|
| 1176 |
+
|
| 1177 |
+
Args:
|
| 1178 |
+
token (:obj:`str`):
|
| 1179 |
+
The token to convert
|
| 1180 |
+
|
| 1181 |
+
Returns:
|
| 1182 |
+
:obj:`Optional[int]`: An optional id, :obj:`None` if out of vocabulary
|
| 1183 |
+
"""
|
| 1184 |
+
pass
|
| 1185 |
+
|
| 1186 |
+
def train(self, files, trainer=None):
|
| 1187 |
+
"""
|
| 1188 |
+
Train the Tokenizer using the given files.
|
| 1189 |
+
|
| 1190 |
+
Reads the files line by line, while keeping all the whitespace, even new lines.
|
| 1191 |
+
If you want to train from data store in-memory, you can check
|
| 1192 |
+
:meth:`~tokenizers.Tokenizer.train_from_iterator`
|
| 1193 |
+
|
| 1194 |
+
Args:
|
| 1195 |
+
files (:obj:`List[str]`):
|
| 1196 |
+
A list of path to the files that we should use for training
|
| 1197 |
+
|
| 1198 |
+
trainer (:obj:`~tokenizers.trainers.Trainer`, `optional`):
|
| 1199 |
+
An optional trainer that should be used to train our Model
|
| 1200 |
+
"""
|
| 1201 |
+
pass
|
| 1202 |
+
|
| 1203 |
+
def train_from_iterator(self, iterator, trainer=None, length=None):
|
| 1204 |
+
"""
|
| 1205 |
+
Train the Tokenizer using the provided iterator.
|
| 1206 |
+
|
| 1207 |
+
You can provide anything that is a Python Iterator
|
| 1208 |
+
|
| 1209 |
+
* A list of sequences :obj:`List[str]`
|
| 1210 |
+
* A generator that yields :obj:`str` or :obj:`List[str]`
|
| 1211 |
+
* A Numpy array of strings
|
| 1212 |
+
* ...
|
| 1213 |
+
|
| 1214 |
+
Args:
|
| 1215 |
+
iterator (:obj:`Iterator`):
|
| 1216 |
+
Any iterator over strings or list of strings
|
| 1217 |
+
|
| 1218 |
+
trainer (:obj:`~tokenizers.trainers.Trainer`, `optional`):
|
| 1219 |
+
An optional trainer that should be used to train our Model
|
| 1220 |
+
|
| 1221 |
+
length (:obj:`int`, `optional`):
|
| 1222 |
+
The total number of sequences in the iterator. This is used to
|
| 1223 |
+
provide meaningful progress tracking
|
| 1224 |
+
"""
|
| 1225 |
+
pass
|
| 1226 |
+
|
| 1227 |
+
@property
|
| 1228 |
+
def truncation(self):
|
| 1229 |
+
"""
|
| 1230 |
+
Get the currently set truncation parameters
|
| 1231 |
+
|
| 1232 |
+
`Cannot set, use` :meth:`~tokenizers.Tokenizer.enable_truncation` `instead`
|
| 1233 |
+
|
| 1234 |
+
Returns:
|
| 1235 |
+
(:obj:`dict`, `optional`):
|
| 1236 |
+
A dict with the current truncation parameters if truncation is enabled
|
| 1237 |
+
"""
|
| 1238 |
+
pass
|
vlmpy310/lib/python3.10/site-packages/tokenizers/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (1.78 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/tokenizers/decoders/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .. import decoders
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
Decoder = decoders.Decoder
|
| 5 |
+
ByteLevel = decoders.ByteLevel
|
| 6 |
+
Replace = decoders.Replace
|
| 7 |
+
WordPiece = decoders.WordPiece
|
| 8 |
+
ByteFallback = decoders.ByteFallback
|
| 9 |
+
Fuse = decoders.Fuse
|
| 10 |
+
Strip = decoders.Strip
|
| 11 |
+
Metaspace = decoders.Metaspace
|
| 12 |
+
BPEDecoder = decoders.BPEDecoder
|
| 13 |
+
CTC = decoders.CTC
|
| 14 |
+
Sequence = decoders.Sequence
|
| 15 |
+
DecodeStream = decoders.DecodeStream
|
vlmpy310/lib/python3.10/site-packages/tokenizers/decoders/__init__.pyi
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generated content DO NOT EDIT
|
| 2 |
+
class DecodeStream:
|
| 3 |
+
"""
|
| 4 |
+
Class needed for streaming decode
|
| 5 |
+
|
| 6 |
+
"""
|
| 7 |
+
def __init__(self, skip_special_tokens):
|
| 8 |
+
pass
|
| 9 |
+
|
| 10 |
+
class Decoder:
|
| 11 |
+
"""
|
| 12 |
+
Base class for all decoders
|
| 13 |
+
|
| 14 |
+
This class is not supposed to be instantiated directly. Instead, any implementation of
|
| 15 |
+
a Decoder will return an instance of this class when instantiated.
|
| 16 |
+
"""
|
| 17 |
+
def decode(self, tokens):
|
| 18 |
+
"""
|
| 19 |
+
Decode the given list of tokens to a final string
|
| 20 |
+
|
| 21 |
+
Args:
|
| 22 |
+
tokens (:obj:`List[str]`):
|
| 23 |
+
The list of tokens to decode
|
| 24 |
+
|
| 25 |
+
Returns:
|
| 26 |
+
:obj:`str`: The decoded string
|
| 27 |
+
"""
|
| 28 |
+
pass
|
| 29 |
+
|
| 30 |
+
class BPEDecoder(Decoder):
|
| 31 |
+
"""
|
| 32 |
+
BPEDecoder Decoder
|
| 33 |
+
|
| 34 |
+
Args:
|
| 35 |
+
suffix (:obj:`str`, `optional`, defaults to :obj:`</w>`):
|
| 36 |
+
The suffix that was used to caracterize an end-of-word. This suffix will
|
| 37 |
+
be replaced by whitespaces during the decoding
|
| 38 |
+
"""
|
| 39 |
+
def __init__(self, suffix="</w>"):
|
| 40 |
+
pass
|
| 41 |
+
|
| 42 |
+
def decode(self, tokens):
|
| 43 |
+
"""
|
| 44 |
+
Decode the given list of tokens to a final string
|
| 45 |
+
|
| 46 |
+
Args:
|
| 47 |
+
tokens (:obj:`List[str]`):
|
| 48 |
+
The list of tokens to decode
|
| 49 |
+
|
| 50 |
+
Returns:
|
| 51 |
+
:obj:`str`: The decoded string
|
| 52 |
+
"""
|
| 53 |
+
pass
|
| 54 |
+
|
| 55 |
+
class ByteFallback(Decoder):
|
| 56 |
+
"""
|
| 57 |
+
ByteFallback Decoder
|
| 58 |
+
ByteFallback is a simple trick which converts tokens looking like `<0x61>`
|
| 59 |
+
to pure bytes, and attempts to make them into a string. If the tokens
|
| 60 |
+
cannot be decoded you will get � instead for each inconvertable byte token
|
| 61 |
+
|
| 62 |
+
"""
|
| 63 |
+
def __init__(self):
|
| 64 |
+
pass
|
| 65 |
+
|
| 66 |
+
def decode(self, tokens):
|
| 67 |
+
"""
|
| 68 |
+
Decode the given list of tokens to a final string
|
| 69 |
+
|
| 70 |
+
Args:
|
| 71 |
+
tokens (:obj:`List[str]`):
|
| 72 |
+
The list of tokens to decode
|
| 73 |
+
|
| 74 |
+
Returns:
|
| 75 |
+
:obj:`str`: The decoded string
|
| 76 |
+
"""
|
| 77 |
+
pass
|
| 78 |
+
|
| 79 |
+
class ByteLevel(Decoder):
|
| 80 |
+
"""
|
| 81 |
+
ByteLevel Decoder
|
| 82 |
+
|
| 83 |
+
This decoder is to be used in tandem with the :class:`~tokenizers.pre_tokenizers.ByteLevel`
|
| 84 |
+
:class:`~tokenizers.pre_tokenizers.PreTokenizer`.
|
| 85 |
+
"""
|
| 86 |
+
def __init__(self):
|
| 87 |
+
pass
|
| 88 |
+
|
| 89 |
+
def decode(self, tokens):
|
| 90 |
+
"""
|
| 91 |
+
Decode the given list of tokens to a final string
|
| 92 |
+
|
| 93 |
+
Args:
|
| 94 |
+
tokens (:obj:`List[str]`):
|
| 95 |
+
The list of tokens to decode
|
| 96 |
+
|
| 97 |
+
Returns:
|
| 98 |
+
:obj:`str`: The decoded string
|
| 99 |
+
"""
|
| 100 |
+
pass
|
| 101 |
+
|
| 102 |
+
class CTC(Decoder):
|
| 103 |
+
"""
|
| 104 |
+
CTC Decoder
|
| 105 |
+
|
| 106 |
+
Args:
|
| 107 |
+
pad_token (:obj:`str`, `optional`, defaults to :obj:`<pad>`):
|
| 108 |
+
The pad token used by CTC to delimit a new token.
|
| 109 |
+
word_delimiter_token (:obj:`str`, `optional`, defaults to :obj:`|`):
|
| 110 |
+
The word delimiter token. It will be replaced by a <space>
|
| 111 |
+
cleanup (:obj:`bool`, `optional`, defaults to :obj:`True`):
|
| 112 |
+
Whether to cleanup some tokenization artifacts.
|
| 113 |
+
Mainly spaces before punctuation, and some abbreviated english forms.
|
| 114 |
+
"""
|
| 115 |
+
def __init__(self, pad_token="<pad>", word_delimiter_token="|", cleanup=True):
|
| 116 |
+
pass
|
| 117 |
+
|
| 118 |
+
def decode(self, tokens):
|
| 119 |
+
"""
|
| 120 |
+
Decode the given list of tokens to a final string
|
| 121 |
+
|
| 122 |
+
Args:
|
| 123 |
+
tokens (:obj:`List[str]`):
|
| 124 |
+
The list of tokens to decode
|
| 125 |
+
|
| 126 |
+
Returns:
|
| 127 |
+
:obj:`str`: The decoded string
|
| 128 |
+
"""
|
| 129 |
+
pass
|
| 130 |
+
|
| 131 |
+
class Fuse(Decoder):
|
| 132 |
+
"""
|
| 133 |
+
Fuse Decoder
|
| 134 |
+
Fuse simply fuses every token into a single string.
|
| 135 |
+
This is the last step of decoding, this decoder exists only if
|
| 136 |
+
there is need to add other decoders *after* the fusion
|
| 137 |
+
"""
|
| 138 |
+
def __init__(self):
|
| 139 |
+
pass
|
| 140 |
+
|
| 141 |
+
def decode(self, tokens):
|
| 142 |
+
"""
|
| 143 |
+
Decode the given list of tokens to a final string
|
| 144 |
+
|
| 145 |
+
Args:
|
| 146 |
+
tokens (:obj:`List[str]`):
|
| 147 |
+
The list of tokens to decode
|
| 148 |
+
|
| 149 |
+
Returns:
|
| 150 |
+
:obj:`str`: The decoded string
|
| 151 |
+
"""
|
| 152 |
+
pass
|
| 153 |
+
|
| 154 |
+
class Metaspace(Decoder):
|
| 155 |
+
"""
|
| 156 |
+
Metaspace Decoder
|
| 157 |
+
|
| 158 |
+
Args:
|
| 159 |
+
replacement (:obj:`str`, `optional`, defaults to :obj:`▁`):
|
| 160 |
+
The replacement character. Must be exactly one character. By default we
|
| 161 |
+
use the `▁` (U+2581) meta symbol (Same as in SentencePiece).
|
| 162 |
+
|
| 163 |
+
prepend_scheme (:obj:`str`, `optional`, defaults to :obj:`"always"`):
|
| 164 |
+
Whether to add a space to the first word if there isn't already one. This
|
| 165 |
+
lets us treat `hello` exactly like `say hello`.
|
| 166 |
+
Choices: "always", "never", "first". First means the space is only added on the first
|
| 167 |
+
token (relevant when special tokens are used or other pre_tokenizer are used).
|
| 168 |
+
"""
|
| 169 |
+
def __init__(self, replacement="▁", prepend_scheme="always", split=True):
|
| 170 |
+
pass
|
| 171 |
+
|
| 172 |
+
def decode(self, tokens):
|
| 173 |
+
"""
|
| 174 |
+
Decode the given list of tokens to a final string
|
| 175 |
+
|
| 176 |
+
Args:
|
| 177 |
+
tokens (:obj:`List[str]`):
|
| 178 |
+
The list of tokens to decode
|
| 179 |
+
|
| 180 |
+
Returns:
|
| 181 |
+
:obj:`str`: The decoded string
|
| 182 |
+
"""
|
| 183 |
+
pass
|
| 184 |
+
|
| 185 |
+
class Replace(Decoder):
|
| 186 |
+
"""
|
| 187 |
+
Replace Decoder
|
| 188 |
+
|
| 189 |
+
This decoder is to be used in tandem with the :class:`~tokenizers.pre_tokenizers.Replace`
|
| 190 |
+
:class:`~tokenizers.pre_tokenizers.PreTokenizer`.
|
| 191 |
+
"""
|
| 192 |
+
def __init__(self, pattern, content):
|
| 193 |
+
pass
|
| 194 |
+
|
| 195 |
+
def decode(self, tokens):
|
| 196 |
+
"""
|
| 197 |
+
Decode the given list of tokens to a final string
|
| 198 |
+
|
| 199 |
+
Args:
|
| 200 |
+
tokens (:obj:`List[str]`):
|
| 201 |
+
The list of tokens to decode
|
| 202 |
+
|
| 203 |
+
Returns:
|
| 204 |
+
:obj:`str`: The decoded string
|
| 205 |
+
"""
|
| 206 |
+
pass
|
| 207 |
+
|
| 208 |
+
class Sequence(Decoder):
|
| 209 |
+
"""
|
| 210 |
+
Sequence Decoder
|
| 211 |
+
|
| 212 |
+
Args:
|
| 213 |
+
decoders (:obj:`List[Decoder]`)
|
| 214 |
+
The decoders that need to be chained
|
| 215 |
+
"""
|
| 216 |
+
def __init__(self, decoders):
|
| 217 |
+
pass
|
| 218 |
+
|
| 219 |
+
def decode(self, tokens):
|
| 220 |
+
"""
|
| 221 |
+
Decode the given list of tokens to a final string
|
| 222 |
+
|
| 223 |
+
Args:
|
| 224 |
+
tokens (:obj:`List[str]`):
|
| 225 |
+
The list of tokens to decode
|
| 226 |
+
|
| 227 |
+
Returns:
|
| 228 |
+
:obj:`str`: The decoded string
|
| 229 |
+
"""
|
| 230 |
+
pass
|
| 231 |
+
|
| 232 |
+
class Strip(Decoder):
|
| 233 |
+
"""
|
| 234 |
+
Strip normalizer
|
| 235 |
+
Strips n left characters of each token, or n right characters of each token
|
| 236 |
+
"""
|
| 237 |
+
def __init__(self, content, left=0, right=0):
|
| 238 |
+
pass
|
| 239 |
+
|
| 240 |
+
def decode(self, tokens):
|
| 241 |
+
"""
|
| 242 |
+
Decode the given list of tokens to a final string
|
| 243 |
+
|
| 244 |
+
Args:
|
| 245 |
+
tokens (:obj:`List[str]`):
|
| 246 |
+
The list of tokens to decode
|
| 247 |
+
|
| 248 |
+
Returns:
|
| 249 |
+
:obj:`str`: The decoded string
|
| 250 |
+
"""
|
| 251 |
+
pass
|
| 252 |
+
|
| 253 |
+
class WordPiece(Decoder):
|
| 254 |
+
"""
|
| 255 |
+
WordPiece Decoder
|
| 256 |
+
|
| 257 |
+
Args:
|
| 258 |
+
prefix (:obj:`str`, `optional`, defaults to :obj:`##`):
|
| 259 |
+
The prefix to use for subwords that are not a beginning-of-word
|
| 260 |
+
|
| 261 |
+
cleanup (:obj:`bool`, `optional`, defaults to :obj:`True`):
|
| 262 |
+
Whether to cleanup some tokenization artifacts. Mainly spaces before punctuation,
|
| 263 |
+
and some abbreviated english forms.
|
| 264 |
+
"""
|
| 265 |
+
def __init__(self, prefix="##", cleanup=True):
|
| 266 |
+
pass
|
| 267 |
+
|
| 268 |
+
def decode(self, tokens):
|
| 269 |
+
"""
|
| 270 |
+
Decode the given list of tokens to a final string
|
| 271 |
+
|
| 272 |
+
Args:
|
| 273 |
+
tokens (:obj:`List[str]`):
|
| 274 |
+
The list of tokens to decode
|
| 275 |
+
|
| 276 |
+
Returns:
|
| 277 |
+
:obj:`str`: The decoded string
|
| 278 |
+
"""
|
| 279 |
+
pass
|
vlmpy310/lib/python3.10/site-packages/tokenizers/decoders/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (421 Bytes). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .base_tokenizer import BaseTokenizer
|
| 2 |
+
from .bert_wordpiece import BertWordPieceTokenizer
|
| 3 |
+
from .byte_level_bpe import ByteLevelBPETokenizer
|
| 4 |
+
from .char_level_bpe import CharBPETokenizer
|
| 5 |
+
from .sentencepiece_bpe import SentencePieceBPETokenizer
|
| 6 |
+
from .sentencepiece_unigram import SentencePieceUnigramTokenizer
|
vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (550 Bytes). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__pycache__/base_tokenizer.cpython-310.pyc
ADDED
|
Binary file (15.5 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__pycache__/bert_wordpiece.cpython-310.pyc
ADDED
|
Binary file (3.86 kB). View file
|
|
|
vlmpy310/lib/python3.10/site-packages/tokenizers/implementations/__pycache__/byte_level_bpe.cpython-310.pyc
ADDED
|
Binary file (3.39 kB). View file
|
|
|