ZTWHHH commited on
Commit
b4ece10
·
verified ·
1 Parent(s): 9d0f9bf

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/INSTALLER +1 -0
  2. evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/LICENSE +20 -0
  3. evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/METADATA +27 -0
  4. evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/RECORD +15 -0
  5. evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/REQUESTED +0 -0
  6. evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/WHEEL +5 -0
  7. evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/entry_points.txt +3 -0
  8. evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/top_level.txt +1 -0
  9. evalkit_internvl/lib/python3.10/site-packages/pyasn1-0.6.1.dist-info/RECORD +72 -0
  10. evalkit_internvl/lib/python3.10/site-packages/pyasn1-0.6.1.dist-info/REQUESTED +0 -0
  11. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__init__.py +20 -0
  12. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/__init__.cpython-310.pyc +0 -0
  13. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth1_auth.cpython-310.pyc +0 -0
  14. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth1_session.cpython-310.pyc +0 -0
  15. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth2_auth.cpython-310.pyc +0 -0
  16. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth2_session.cpython-310.pyc +0 -0
  17. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__init__.py +9 -0
  18. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/douban.cpython-310.pyc +0 -0
  19. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/fitbit.cpython-310.pyc +0 -0
  20. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/instagram.cpython-310.pyc +0 -0
  21. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/mailchimp.cpython-310.pyc +0 -0
  22. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/plentymarkets.cpython-310.pyc +0 -0
  23. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/slack.cpython-310.pyc +0 -0
  24. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/douban.py +15 -0
  25. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/ebay.py +22 -0
  26. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/facebook.py +27 -0
  27. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/fitbit.py +23 -0
  28. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/instagram.py +23 -0
  29. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/mailchimp.py +21 -0
  30. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/plentymarkets.py +27 -0
  31. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/slack.py +34 -0
  32. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/weibo.py +13 -0
  33. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/oauth1_auth.py +112 -0
  34. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/oauth1_session.py +395 -0
  35. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/oauth2_auth.py +36 -0
  36. evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py +587 -0
  37. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/__init__.cpython-310.pyc +0 -0
  38. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/assign.cpython-310.pyc +0 -0
  39. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/attrdict.cpython-310.pyc +0 -0
  40. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/base.cpython-310.pyc +0 -0
  41. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/bitfield.cpython-310.pyc +0 -0
  42. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/css.cpython-310.pyc +0 -0
  43. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/tspan.cpython-310.pyc +0 -0
  44. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/version.cpython-310.pyc +0 -0
  45. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/waveform.cpython-310.pyc +0 -0
  46. evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/waveskin.cpython-310.pyc +0 -0
  47. evalkit_internvl/lib/python3.10/site-packages/wavedrom/assign.py +174 -0
  48. evalkit_internvl/lib/python3.10/site-packages/wavedrom/attrdict.py +4 -0
  49. evalkit_internvl/lib/python3.10/site-packages/wavedrom/base.py +21 -0
  50. evalkit_internvl/lib/python3.10/site-packages/wavedrom/bitfield.py +259 -0
evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/LICENSE ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2022 Matthew Brennan Jones <matthew.brennan.jones@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/METADATA ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: py-cpuinfo
3
+ Version: 9.0.0
4
+ Summary: Get CPU info with pure Python
5
+ Home-page: https://github.com/workhorsy/py-cpuinfo
6
+ Author: Matthew Brennan Jones
7
+ Author-email: matthew.brennan.jones@gmail.com
8
+ License: MIT
9
+ Platform: UNKNOWN
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Topic :: Utilities
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ License-File: LICENSE
15
+
16
+ py-cpuinfo
17
+ ==========
18
+
19
+
20
+ Py-cpuinfo gets CPU info with pure Python. Py-cpuinfo should work
21
+ without any extra programs or libraries, beyond what your OS provides.
22
+ It does not require any compilation(C/C++, assembly, et cetera) to use.
23
+ It works with Python 3.
24
+
25
+ Documentation can be viewed here: https://github.com/workhorsy/py-cpuinfo
26
+
27
+
evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/RECORD ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ../../../bin/cpuinfo,sha256=0fOrVnZt9WoF2ubTTKZu5uP_4BTZTzW3UMEfI6lP8NQ,228
2
+ cpuinfo/__init__.py,sha256=T6gndqGAggfJCu4_iOziTnomCN7KzaAK_OYTewE4FMA,44
3
+ cpuinfo/__main__.py,sha256=nSxC6Hqhi-0lN7Z4WwtKdxQdf3cUJefb5hOahCzh4Yg,33
4
+ cpuinfo/__pycache__/__init__.cpython-310.pyc,,
5
+ cpuinfo/__pycache__/__main__.cpython-310.pyc,,
6
+ cpuinfo/__pycache__/cpuinfo.cpython-310.pyc,,
7
+ cpuinfo/cpuinfo.py,sha256=HHyDlDUNovE3QzJ3hviiM1ngyOC4iD7i6oGiz2iTmVk,84388
8
+ py_cpuinfo-9.0.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
9
+ py_cpuinfo-9.0.0.dist-info/LICENSE,sha256=3br3Y5a_XHqkWXWiHq_i4i7st9paoNt8sOYVL6r-800,1127
10
+ py_cpuinfo-9.0.0.dist-info/METADATA,sha256=rRFelvhFdoYcXnXXYDAbgdIxQ8_iVUa5lUHgEmU3ncE,794
11
+ py_cpuinfo-9.0.0.dist-info/RECORD,,
12
+ py_cpuinfo-9.0.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ py_cpuinfo-9.0.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
14
+ py_cpuinfo-9.0.0.dist-info/entry_points.txt,sha256=ZwrsclY_xUA0xJZK98bLxBdcowxnkK0ANYUT4FYcZJ8,42
15
+ py_cpuinfo-9.0.0.dist-info/top_level.txt,sha256=XsjpunhkxD4hvznqQjrFNw0rtgizHEOGzewPZY3UEtU,8
evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/REQUESTED ADDED
File without changes
evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.37.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/entry_points.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [console_scripts]
2
+ cpuinfo = cpuinfo:main
3
+
evalkit_internvl/lib/python3.10/site-packages/py_cpuinfo-9.0.0.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ cpuinfo
evalkit_internvl/lib/python3.10/site-packages/pyasn1-0.6.1.dist-info/RECORD ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pyasn1-0.6.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ pyasn1-0.6.1.dist-info/LICENSE.rst,sha256=Kq1fwA9wXEoa3bg-7RCmp10oajd58M-FGdh-YrxHNf0,1334
3
+ pyasn1-0.6.1.dist-info/METADATA,sha256=8e1KBL3kvp1MlLUqCM1uOCMaBKxwlo4N0xHXk-_sd2Y,8383
4
+ pyasn1-0.6.1.dist-info/RECORD,,
5
+ pyasn1-0.6.1.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ pyasn1-0.6.1.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
7
+ pyasn1-0.6.1.dist-info/top_level.txt,sha256=dnNEQt3nIDIO5mSCCOB5obQHrjDOUsRycdBujc2vrWE,7
8
+ pyasn1-0.6.1.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
+ pyasn1/__init__.py,sha256=tc4WulUv4ZkpkmVtee9-Fsgc6gi9jZFH1VIbAvSWj3s,66
10
+ pyasn1/__pycache__/__init__.cpython-310.pyc,,
11
+ pyasn1/__pycache__/debug.cpython-310.pyc,,
12
+ pyasn1/__pycache__/error.cpython-310.pyc,,
13
+ pyasn1/codec/__init__.py,sha256=EEDlJYS172EH39GUidN_8FbkNcWY9OVV8e30AV58pn0,59
14
+ pyasn1/codec/__pycache__/__init__.cpython-310.pyc,,
15
+ pyasn1/codec/__pycache__/streaming.cpython-310.pyc,,
16
+ pyasn1/codec/ber/__init__.py,sha256=EEDlJYS172EH39GUidN_8FbkNcWY9OVV8e30AV58pn0,59
17
+ pyasn1/codec/ber/__pycache__/__init__.cpython-310.pyc,,
18
+ pyasn1/codec/ber/__pycache__/decoder.cpython-310.pyc,,
19
+ pyasn1/codec/ber/__pycache__/encoder.cpython-310.pyc,,
20
+ pyasn1/codec/ber/__pycache__/eoo.cpython-310.pyc,,
21
+ pyasn1/codec/ber/decoder.py,sha256=HZWc3M9406bhApuJF-TAYpRfLWvQT54CrREDqDMyU0Y,79192
22
+ pyasn1/codec/ber/encoder.py,sha256=eO_--5b-0HXmPpIW2JhYlejU6V7FwdORmXFyCfKHyzI,29796
23
+ pyasn1/codec/ber/eoo.py,sha256=dspLKc2xr_W5Tbcr2WcfLd_bJLhOjotq1YxKn3DCQNI,639
24
+ pyasn1/codec/cer/__init__.py,sha256=EEDlJYS172EH39GUidN_8FbkNcWY9OVV8e30AV58pn0,59
25
+ pyasn1/codec/cer/__pycache__/__init__.cpython-310.pyc,,
26
+ pyasn1/codec/cer/__pycache__/decoder.cpython-310.pyc,,
27
+ pyasn1/codec/cer/__pycache__/encoder.cpython-310.pyc,,
28
+ pyasn1/codec/cer/decoder.py,sha256=S279_LRjwHyTUBuv4LPYOpib1X4hLmBh_3et49ocm4A,4589
29
+ pyasn1/codec/cer/encoder.py,sha256=vsGrgOHJokTeZqBJwNGokejvqH5EfTvy8hExd_j5bbY,9838
30
+ pyasn1/codec/der/__init__.py,sha256=EEDlJYS172EH39GUidN_8FbkNcWY9OVV8e30AV58pn0,59
31
+ pyasn1/codec/der/__pycache__/__init__.cpython-310.pyc,,
32
+ pyasn1/codec/der/__pycache__/decoder.cpython-310.pyc,,
33
+ pyasn1/codec/der/__pycache__/encoder.cpython-310.pyc,,
34
+ pyasn1/codec/der/decoder.py,sha256=GOpKZ1wFRYU0EEF3kSmIaMfe1h2w17VdGu57AHUqQFw,3428
35
+ pyasn1/codec/der/encoder.py,sha256=ldxrpvXDFsxLxtvN7aiR61JNNtainNagZCSpsZM9DZs,3479
36
+ pyasn1/codec/native/__init__.py,sha256=EEDlJYS172EH39GUidN_8FbkNcWY9OVV8e30AV58pn0,59
37
+ pyasn1/codec/native/__pycache__/__init__.cpython-310.pyc,,
38
+ pyasn1/codec/native/__pycache__/decoder.cpython-310.pyc,,
39
+ pyasn1/codec/native/__pycache__/encoder.cpython-310.pyc,,
40
+ pyasn1/codec/native/decoder.py,sha256=2vK9B0AJzLT2exSNtlCUlYzZvm0E7IzUU8Ygg_lLxNo,9118
41
+ pyasn1/codec/native/encoder.py,sha256=C24L5FkwhXPSRytaLlcL0uuYDTC2BXD75ZwH_bCqKX8,9184
42
+ pyasn1/codec/streaming.py,sha256=Vp-VDh0SlA5h7T133rne9UNlJlqv2ohpUzVlSCGjq24,6377
43
+ pyasn1/compat/__init__.py,sha256=-9FOJV1STFBatf2pVRiOYn14GmCKC8RY3TYCxOqfRXY,112
44
+ pyasn1/compat/__pycache__/__init__.cpython-310.pyc,,
45
+ pyasn1/compat/__pycache__/integer.cpython-310.pyc,,
46
+ pyasn1/compat/integer.py,sha256=lMXqbJBTyjg34Rhx6JlFcXyoQxDaeXGxhaIIab86hX8,404
47
+ pyasn1/debug.py,sha256=u-WmIFfewqp0041ezvtTjvhZcU9K14OI6p00ArXZ63g,3494
48
+ pyasn1/error.py,sha256=e352oqW33seeh2MbIF27sFSgpiegjstabCMFx2piR0M,3258
49
+ pyasn1/type/__init__.py,sha256=EEDlJYS172EH39GUidN_8FbkNcWY9OVV8e30AV58pn0,59
50
+ pyasn1/type/__pycache__/__init__.cpython-310.pyc,,
51
+ pyasn1/type/__pycache__/base.cpython-310.pyc,,
52
+ pyasn1/type/__pycache__/char.cpython-310.pyc,,
53
+ pyasn1/type/__pycache__/constraint.cpython-310.pyc,,
54
+ pyasn1/type/__pycache__/error.cpython-310.pyc,,
55
+ pyasn1/type/__pycache__/namedtype.cpython-310.pyc,,
56
+ pyasn1/type/__pycache__/namedval.cpython-310.pyc,,
57
+ pyasn1/type/__pycache__/opentype.cpython-310.pyc,,
58
+ pyasn1/type/__pycache__/tag.cpython-310.pyc,,
59
+ pyasn1/type/__pycache__/tagmap.cpython-310.pyc,,
60
+ pyasn1/type/__pycache__/univ.cpython-310.pyc,,
61
+ pyasn1/type/__pycache__/useful.cpython-310.pyc,,
62
+ pyasn1/type/base.py,sha256=tjBRvXIQSiHES5-e5rBbsnn5CtIvBgCuflujDbdrtkM,22050
63
+ pyasn1/type/char.py,sha256=Rvj5ypQLPNXcdHkfUV8nul1XX66R_Akn0g2HUyLj1qY,9438
64
+ pyasn1/type/constraint.py,sha256=jmrt5esLa095XdfS0beqaoRuUjnuHiTKdkTdCcKx1FI,21915
65
+ pyasn1/type/error.py,sha256=2kwYYkbd2jXIVEE56ThLRmBEOGZfafwogEOo-9RV_GY,259
66
+ pyasn1/type/namedtype.py,sha256=jnTClIUoRZi025GTY9GlMlMI-j5dqEcv_ilzZ7i0hUQ,16179
67
+ pyasn1/type/namedval.py,sha256=84u6wKOfte7U47aWrFqIZRM3tO2ryivpsBqVblPezuc,4899
68
+ pyasn1/type/opentype.py,sha256=jjqSbTgAaCxlSHSf66YcLbrxtfh_98nAx2v8wzW35MU,2861
69
+ pyasn1/type/tag.py,sha256=hqIuspUhc5QwN182LeQMc23W_vFNTgASvnUUSX4SPHM,9497
70
+ pyasn1/type/tagmap.py,sha256=alJ9ZfDGTAsPeygHT6yONTagUkCjlgij82YXpPaQ_-8,3000
71
+ pyasn1/type/univ.py,sha256=Bnu2gHdA84UXMLtgb4LXbHI5TYw-kKljlsJ7dkJ8KfI,109212
72
+ pyasn1/type/useful.py,sha256=-J7ej0hqdjF29h150dtNmIIcGcMBg_y-nKqcozvk-48,5284
evalkit_internvl/lib/python3.10/site-packages/pyasn1-0.6.1.dist-info/REQUESTED ADDED
File without changes
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__init__.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ruff: noqa: F401
2
+ import logging
3
+
4
+ from .oauth1_auth import OAuth1
5
+ from .oauth1_session import OAuth1Session
6
+ from .oauth2_auth import OAuth2
7
+ from .oauth2_session import OAuth2Session, TokenUpdated
8
+
9
+ __version__ = "2.0.0"
10
+
11
+ import requests
12
+
13
+ if requests.__version__ < "2.0.0":
14
+ msg = (
15
+ "You are using requests version %s, which is older than "
16
+ "requests-oauthlib expects, please upgrade to 2.0.0 or later."
17
+ )
18
+ raise Warning(msg % requests.__version__)
19
+
20
+ logging.getLogger("requests_oauthlib").addHandler(logging.NullHandler())
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (704 Bytes). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth1_auth.cpython-310.pyc ADDED
Binary file (2.44 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth1_session.cpython-310.pyc ADDED
Binary file (16.3 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth2_auth.cpython-310.pyc ADDED
Binary file (1.83 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/__pycache__/oauth2_session.cpython-310.pyc ADDED
Binary file (17.4 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__init__.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # ruff: noqa: F401
2
+ from .facebook import facebook_compliance_fix
3
+ from .fitbit import fitbit_compliance_fix
4
+ from .slack import slack_compliance_fix
5
+ from .instagram import instagram_compliance_fix
6
+ from .mailchimp import mailchimp_compliance_fix
7
+ from .weibo import weibo_compliance_fix
8
+ from .plentymarkets import plentymarkets_compliance_fix
9
+ from .ebay import ebay_compliance_fix
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/douban.cpython-310.pyc ADDED
Binary file (735 Bytes). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/fitbit.cpython-310.pyc ADDED
Binary file (1.1 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/instagram.cpython-310.pyc ADDED
Binary file (847 Bytes). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/mailchimp.cpython-310.pyc ADDED
Binary file (964 Bytes). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/plentymarkets.cpython-310.pyc ADDED
Binary file (1.06 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/__pycache__/slack.cpython-310.pyc ADDED
Binary file (921 Bytes). View file
 
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/douban.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+
4
+ def douban_compliance_fix(session):
5
+ def fix_token_type(r):
6
+ token = json.loads(r.text)
7
+ token.setdefault("token_type", "Bearer")
8
+ fixed_token = json.dumps(token)
9
+ r._content = fixed_token.encode()
10
+ return r
11
+
12
+ session._client_default_token_placement = "query"
13
+ session.register_compliance_hook("access_token_response", fix_token_type)
14
+
15
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/ebay.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+
4
+ def ebay_compliance_fix(session):
5
+ def _compliance_fix(response):
6
+ token = json.loads(response.text)
7
+
8
+ # eBay responds with non-compliant token types.
9
+ # https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html
10
+ # https://developer.ebay.com/api-docs/static/oauth-auth-code-grant-request.html
11
+ # Modify these to be "Bearer".
12
+ if token.get("token_type") in ["Application Access Token", "User Access Token"]:
13
+ token["token_type"] = "Bearer"
14
+ fixed_token = json.dumps(token)
15
+ response._content = fixed_token.encode()
16
+
17
+ return response
18
+
19
+ session.register_compliance_hook("access_token_response", _compliance_fix)
20
+ session.register_compliance_hook("refresh_token_response", _compliance_fix)
21
+
22
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/facebook.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from json import dumps
2
+ from urllib.parse import parse_qsl
3
+
4
+
5
+ def facebook_compliance_fix(session):
6
+ def _compliance_fix(r):
7
+ # if Facebook claims to be sending us json, let's trust them.
8
+ if "application/json" in r.headers.get("content-type", {}):
9
+ return r
10
+
11
+ # Facebook returns a content-type of text/plain when sending their
12
+ # x-www-form-urlencoded responses, along with a 200. If not, let's
13
+ # assume we're getting JSON and bail on the fix.
14
+ if "text/plain" in r.headers.get("content-type", {}) and r.status_code == 200:
15
+ token = dict(parse_qsl(r.text, keep_blank_values=True))
16
+ else:
17
+ return r
18
+
19
+ expires = token.get("expires")
20
+ if expires is not None:
21
+ token["expires_in"] = expires
22
+ token["token_type"] = "Bearer"
23
+ r._content = dumps(token).encode()
24
+ return r
25
+
26
+ session.register_compliance_hook("access_token_response", _compliance_fix)
27
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/fitbit.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ The Fitbit API breaks from the OAuth2 RFC standard by returning an "errors"
3
+ object list, rather than a single "error" string. This puts hooks in place so
4
+ that oauthlib can process an error in the results from access token and refresh
5
+ token responses. This is necessary to prevent getting the generic red herring
6
+ MissingTokenError.
7
+ """
8
+
9
+ from json import loads, dumps
10
+
11
+
12
+ def fitbit_compliance_fix(session):
13
+ def _missing_error(r):
14
+ token = loads(r.text)
15
+ if "errors" in token:
16
+ # Set the error to the first one we have
17
+ token["error"] = token["errors"][0]["errorType"]
18
+ r._content = dumps(token).encode()
19
+ return r
20
+
21
+ session.register_compliance_hook("access_token_response", _missing_error)
22
+ session.register_compliance_hook("refresh_token_response", _missing_error)
23
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/instagram.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from urllib.parse import urlparse, parse_qs
2
+
3
+ from oauthlib.common import add_params_to_uri
4
+
5
+
6
+ def instagram_compliance_fix(session):
7
+ def _non_compliant_param_name(url, headers, data):
8
+ # If the user has already specified the token in the URL
9
+ # then there's nothing to do.
10
+ # If the specified token is different from ``session.access_token``,
11
+ # we assume the user intends to override the access token.
12
+ url_query = dict(parse_qs(urlparse(url).query))
13
+ token = url_query.get("access_token")
14
+ if token:
15
+ # Nothing to do, just return.
16
+ return url, headers, data
17
+
18
+ token = [("access_token", session.access_token)]
19
+ url = add_params_to_uri(url, token)
20
+ return url, headers, data
21
+
22
+ session.register_compliance_hook("protected_request", _non_compliant_param_name)
23
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/mailchimp.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+
4
+ def mailchimp_compliance_fix(session):
5
+ def _null_scope(r):
6
+ token = json.loads(r.text)
7
+ if "scope" in token and token["scope"] is None:
8
+ token.pop("scope")
9
+ r._content = json.dumps(token).encode()
10
+ return r
11
+
12
+ def _non_zero_expiration(r):
13
+ token = json.loads(r.text)
14
+ if "expires_in" in token and token["expires_in"] == 0:
15
+ token["expires_in"] = 3600
16
+ r._content = json.dumps(token).encode()
17
+ return r
18
+
19
+ session.register_compliance_hook("access_token_response", _null_scope)
20
+ session.register_compliance_hook("access_token_response", _non_zero_expiration)
21
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/plentymarkets.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from json import dumps, loads
2
+ import re
3
+
4
+
5
+ def plentymarkets_compliance_fix(session):
6
+ def _to_snake_case(n):
7
+ return re.sub("(.)([A-Z][a-z]+)", r"\1_\2", n).lower()
8
+
9
+ def _compliance_fix(r):
10
+ # Plenty returns the Token in CamelCase instead of _
11
+ if (
12
+ "application/json" in r.headers.get("content-type", {})
13
+ and r.status_code == 200
14
+ ):
15
+ token = loads(r.text)
16
+ else:
17
+ return r
18
+
19
+ fixed_token = {}
20
+ for k, v in token.items():
21
+ fixed_token[_to_snake_case(k)] = v
22
+
23
+ r._content = dumps(fixed_token).encode()
24
+ return r
25
+
26
+ session.register_compliance_hook("access_token_response", _compliance_fix)
27
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/slack.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from urllib.parse import urlparse, parse_qs
2
+
3
+ from oauthlib.common import add_params_to_uri
4
+
5
+
6
+ def slack_compliance_fix(session):
7
+ def _non_compliant_param_name(url, headers, data):
8
+ # If the user has already specified the token, either in the URL
9
+ # or in a data dictionary, then there's nothing to do.
10
+ # If the specified token is different from ``session.access_token``,
11
+ # we assume the user intends to override the access token.
12
+ url_query = dict(parse_qs(urlparse(url).query))
13
+ token = url_query.get("token")
14
+ if not token and isinstance(data, dict):
15
+ token = data.get("token")
16
+
17
+ if token:
18
+ # Nothing to do, just return.
19
+ return url, headers, data
20
+
21
+ if not data:
22
+ data = {"token": session.access_token}
23
+ elif isinstance(data, dict):
24
+ data["token"] = session.access_token
25
+ else:
26
+ # ``data`` is something other than a dict: maybe a stream,
27
+ # maybe a file object, maybe something else. We can't easily
28
+ # modify it, so we'll set the token by modifying the URL instead.
29
+ token = [("token", session.access_token)]
30
+ url = add_params_to_uri(url, token)
31
+ return url, headers, data
32
+
33
+ session.register_compliance_hook("protected_request", _non_compliant_param_name)
34
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/compliance_fixes/weibo.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from json import loads, dumps
2
+
3
+
4
+ def weibo_compliance_fix(session):
5
+ def _missing_token_type(r):
6
+ token = loads(r.text)
7
+ token["token_type"] = "Bearer"
8
+ r._content = dumps(token).encode()
9
+ return r
10
+
11
+ session._client.default_token_placement = "query"
12
+ session.register_compliance_hook("access_token_response", _missing_token_type)
13
+ return session
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/oauth1_auth.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import logging
3
+
4
+ from oauthlib.common import extract_params
5
+ from oauthlib.oauth1 import Client, SIGNATURE_HMAC, SIGNATURE_TYPE_AUTH_HEADER
6
+ from oauthlib.oauth1 import SIGNATURE_TYPE_BODY
7
+ from requests.utils import to_native_string
8
+ from requests.auth import AuthBase
9
+
10
+ CONTENT_TYPE_FORM_URLENCODED = "application/x-www-form-urlencoded"
11
+ CONTENT_TYPE_MULTI_PART = "multipart/form-data"
12
+
13
+
14
+ log = logging.getLogger(__name__)
15
+
16
+ # OBS!: Correct signing of requests are conditional on invoking OAuth1
17
+ # as the last step of preparing a request, or at least having the
18
+ # content-type set properly.
19
+ class OAuth1(AuthBase):
20
+ """Signs the request using OAuth 1 (RFC5849)"""
21
+
22
+ client_class = Client
23
+
24
+ def __init__(
25
+ self,
26
+ client_key,
27
+ client_secret=None,
28
+ resource_owner_key=None,
29
+ resource_owner_secret=None,
30
+ callback_uri=None,
31
+ signature_method=SIGNATURE_HMAC,
32
+ signature_type=SIGNATURE_TYPE_AUTH_HEADER,
33
+ rsa_key=None,
34
+ verifier=None,
35
+ decoding="utf-8",
36
+ client_class=None,
37
+ force_include_body=False,
38
+ **kwargs
39
+ ):
40
+
41
+ try:
42
+ signature_type = signature_type.upper()
43
+ except AttributeError:
44
+ pass
45
+
46
+ client_class = client_class or self.client_class
47
+
48
+ self.force_include_body = force_include_body
49
+
50
+ self.client = client_class(
51
+ client_key,
52
+ client_secret,
53
+ resource_owner_key,
54
+ resource_owner_secret,
55
+ callback_uri,
56
+ signature_method,
57
+ signature_type,
58
+ rsa_key,
59
+ verifier,
60
+ decoding=decoding,
61
+ **kwargs
62
+ )
63
+
64
+ def __call__(self, r):
65
+ """Add OAuth parameters to the request.
66
+
67
+ Parameters may be included from the body if the content-type is
68
+ urlencoded, if no content type is set a guess is made.
69
+ """
70
+ # Overwriting url is safe here as request will not modify it past
71
+ # this point.
72
+ log.debug("Signing request %s using client %s", r, self.client)
73
+
74
+ content_type = r.headers.get("Content-Type", "")
75
+ if (
76
+ not content_type
77
+ and extract_params(r.body)
78
+ or self.client.signature_type == SIGNATURE_TYPE_BODY
79
+ ):
80
+ content_type = CONTENT_TYPE_FORM_URLENCODED
81
+ if not isinstance(content_type, str):
82
+ content_type = content_type.decode("utf-8")
83
+
84
+ is_form_encoded = CONTENT_TYPE_FORM_URLENCODED in content_type
85
+
86
+ log.debug(
87
+ "Including body in call to sign: %s",
88
+ is_form_encoded or self.force_include_body,
89
+ )
90
+
91
+ if is_form_encoded:
92
+ r.headers["Content-Type"] = CONTENT_TYPE_FORM_URLENCODED
93
+ r.url, headers, r.body = self.client.sign(
94
+ str(r.url), str(r.method), r.body or "", r.headers
95
+ )
96
+ elif self.force_include_body:
97
+ # To allow custom clients to work on non form encoded bodies.
98
+ r.url, headers, r.body = self.client.sign(
99
+ str(r.url), str(r.method), r.body or "", r.headers
100
+ )
101
+ else:
102
+ # Omit body data in the signing of non form-encoded requests
103
+ r.url, headers, _ = self.client.sign(
104
+ str(r.url), str(r.method), None, r.headers
105
+ )
106
+
107
+ r.prepare_headers(headers)
108
+ r.url = to_native_string(r.url)
109
+ log.debug("Updated url: %s", r.url)
110
+ log.debug("Updated headers: %s", headers)
111
+ log.debug("Updated body: %r", r.body)
112
+ return r
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/oauth1_session.py ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from urllib.parse import urlparse
2
+
3
+ import logging
4
+
5
+ from oauthlib.common import add_params_to_uri
6
+ from oauthlib.common import urldecode as _urldecode
7
+ from oauthlib.oauth1 import SIGNATURE_HMAC, SIGNATURE_RSA, SIGNATURE_TYPE_AUTH_HEADER
8
+ import requests
9
+
10
+ from . import OAuth1
11
+
12
+
13
+ log = logging.getLogger(__name__)
14
+
15
+
16
+ def urldecode(body):
17
+ """Parse query or json to python dictionary"""
18
+ try:
19
+ return _urldecode(body)
20
+ except Exception:
21
+ import json
22
+
23
+ return json.loads(body)
24
+
25
+
26
+ class TokenRequestDenied(ValueError):
27
+ def __init__(self, message, response):
28
+ super(TokenRequestDenied, self).__init__(message)
29
+ self.response = response
30
+
31
+ @property
32
+ def status_code(self):
33
+ """For backwards-compatibility purposes"""
34
+ return self.response.status_code
35
+
36
+
37
+ class TokenMissing(ValueError):
38
+ def __init__(self, message, response):
39
+ super(TokenMissing, self).__init__(message)
40
+ self.response = response
41
+
42
+
43
+ class VerifierMissing(ValueError):
44
+ pass
45
+
46
+
47
+ class OAuth1Session(requests.Session):
48
+ """Request signing and convenience methods for the oauth dance.
49
+
50
+ What is the difference between OAuth1Session and OAuth1?
51
+
52
+ OAuth1Session actually uses OAuth1 internally and its purpose is to assist
53
+ in the OAuth workflow through convenience methods to prepare authorization
54
+ URLs and parse the various token and redirection responses. It also provide
55
+ rudimentary validation of responses.
56
+
57
+ An example of the OAuth workflow using a basic CLI app and Twitter.
58
+
59
+ >>> # Credentials obtained during the registration.
60
+ >>> client_key = 'client key'
61
+ >>> client_secret = 'secret'
62
+ >>> callback_uri = 'https://127.0.0.1/callback'
63
+ >>>
64
+ >>> # Endpoints found in the OAuth provider API documentation
65
+ >>> request_token_url = 'https://api.twitter.com/oauth/request_token'
66
+ >>> authorization_url = 'https://api.twitter.com/oauth/authorize'
67
+ >>> access_token_url = 'https://api.twitter.com/oauth/access_token'
68
+ >>>
69
+ >>> oauth_session = OAuth1Session(client_key,client_secret=client_secret, callback_uri=callback_uri)
70
+ >>>
71
+ >>> # First step, fetch the request token.
72
+ >>> oauth_session.fetch_request_token(request_token_url)
73
+ {
74
+ 'oauth_token': 'kjerht2309u',
75
+ 'oauth_token_secret': 'lsdajfh923874',
76
+ }
77
+ >>>
78
+ >>> # Second step. Follow this link and authorize
79
+ >>> oauth_session.authorization_url(authorization_url)
80
+ 'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf&oauth_callback=https%3A%2F%2F127.0.0.1%2Fcallback'
81
+ >>>
82
+ >>> # Third step. Fetch the access token
83
+ >>> redirect_response = input('Paste the full redirect URL here.')
84
+ >>> oauth_session.parse_authorization_response(redirect_response)
85
+ {
86
+ 'oauth_token: 'kjerht2309u',
87
+ 'oauth_token_secret: 'lsdajfh923874',
88
+ 'oauth_verifier: 'w34o8967345',
89
+ }
90
+ >>> oauth_session.fetch_access_token(access_token_url)
91
+ {
92
+ 'oauth_token': 'sdf0o9823sjdfsdf',
93
+ 'oauth_token_secret': '2kjshdfp92i34asdasd',
94
+ }
95
+ >>> # Done. You can now make OAuth requests.
96
+ >>> status_url = 'http://api.twitter.com/1/statuses/update.json'
97
+ >>> new_status = {'status': 'hello world!'}
98
+ >>> oauth_session.post(status_url, data=new_status)
99
+ <Response [200]>
100
+ """
101
+
102
+ def __init__(
103
+ self,
104
+ client_key,
105
+ client_secret=None,
106
+ resource_owner_key=None,
107
+ resource_owner_secret=None,
108
+ callback_uri=None,
109
+ signature_method=SIGNATURE_HMAC,
110
+ signature_type=SIGNATURE_TYPE_AUTH_HEADER,
111
+ rsa_key=None,
112
+ verifier=None,
113
+ client_class=None,
114
+ force_include_body=False,
115
+ **kwargs
116
+ ):
117
+ """Construct the OAuth 1 session.
118
+
119
+ :param client_key: A client specific identifier.
120
+ :param client_secret: A client specific secret used to create HMAC and
121
+ plaintext signatures.
122
+ :param resource_owner_key: A resource owner key, also referred to as
123
+ request token or access token depending on
124
+ when in the workflow it is used.
125
+ :param resource_owner_secret: A resource owner secret obtained with
126
+ either a request or access token. Often
127
+ referred to as token secret.
128
+ :param callback_uri: The URL the user is redirect back to after
129
+ authorization.
130
+ :param signature_method: Signature methods determine how the OAuth
131
+ signature is created. The three options are
132
+ oauthlib.oauth1.SIGNATURE_HMAC (default),
133
+ oauthlib.oauth1.SIGNATURE_RSA and
134
+ oauthlib.oauth1.SIGNATURE_PLAIN.
135
+ :param signature_type: Signature type decides where the OAuth
136
+ parameters are added. Either in the
137
+ Authorization header (default) or to the URL
138
+ query parameters or the request body. Defined as
139
+ oauthlib.oauth1.SIGNATURE_TYPE_AUTH_HEADER,
140
+ oauthlib.oauth1.SIGNATURE_TYPE_QUERY and
141
+ oauthlib.oauth1.SIGNATURE_TYPE_BODY
142
+ respectively.
143
+ :param rsa_key: The private RSA key as a string. Can only be used with
144
+ signature_method=oauthlib.oauth1.SIGNATURE_RSA.
145
+ :param verifier: A verifier string to prove authorization was granted.
146
+ :param client_class: A subclass of `oauthlib.oauth1.Client` to use with
147
+ `requests_oauthlib.OAuth1` instead of the default
148
+ :param force_include_body: Always include the request body in the
149
+ signature creation.
150
+ :param **kwargs: Additional keyword arguments passed to `OAuth1`
151
+ """
152
+ super(OAuth1Session, self).__init__()
153
+ self._client = OAuth1(
154
+ client_key,
155
+ client_secret=client_secret,
156
+ resource_owner_key=resource_owner_key,
157
+ resource_owner_secret=resource_owner_secret,
158
+ callback_uri=callback_uri,
159
+ signature_method=signature_method,
160
+ signature_type=signature_type,
161
+ rsa_key=rsa_key,
162
+ verifier=verifier,
163
+ client_class=client_class,
164
+ force_include_body=force_include_body,
165
+ **kwargs
166
+ )
167
+ self.auth = self._client
168
+
169
+ @property
170
+ def token(self):
171
+ oauth_token = self._client.client.resource_owner_key
172
+ oauth_token_secret = self._client.client.resource_owner_secret
173
+ oauth_verifier = self._client.client.verifier
174
+
175
+ token_dict = {}
176
+ if oauth_token:
177
+ token_dict["oauth_token"] = oauth_token
178
+ if oauth_token_secret:
179
+ token_dict["oauth_token_secret"] = oauth_token_secret
180
+ if oauth_verifier:
181
+ token_dict["oauth_verifier"] = oauth_verifier
182
+
183
+ return token_dict
184
+
185
+ @token.setter
186
+ def token(self, value):
187
+ self._populate_attributes(value)
188
+
189
+ @property
190
+ def authorized(self):
191
+ """Boolean that indicates whether this session has an OAuth token
192
+ or not. If `self.authorized` is True, you can reasonably expect
193
+ OAuth-protected requests to the resource to succeed. If
194
+ `self.authorized` is False, you need the user to go through the OAuth
195
+ authentication dance before OAuth-protected requests to the resource
196
+ will succeed.
197
+ """
198
+ if self._client.client.signature_method == SIGNATURE_RSA:
199
+ # RSA only uses resource_owner_key
200
+ return bool(self._client.client.resource_owner_key)
201
+ else:
202
+ # other methods of authentication use all three pieces
203
+ return (
204
+ bool(self._client.client.client_secret)
205
+ and bool(self._client.client.resource_owner_key)
206
+ and bool(self._client.client.resource_owner_secret)
207
+ )
208
+
209
+ def authorization_url(self, url, request_token=None, **kwargs):
210
+ """Create an authorization URL by appending request_token and optional
211
+ kwargs to url.
212
+
213
+ This is the second step in the OAuth 1 workflow. The user should be
214
+ redirected to this authorization URL, grant access to you, and then
215
+ be redirected back to you. The redirection back can either be specified
216
+ during client registration or by supplying a callback URI per request.
217
+
218
+ :param url: The authorization endpoint URL.
219
+ :param request_token: The previously obtained request token.
220
+ :param kwargs: Optional parameters to append to the URL.
221
+ :returns: The authorization URL with new parameters embedded.
222
+
223
+ An example using a registered default callback URI.
224
+
225
+ >>> request_token_url = 'https://api.twitter.com/oauth/request_token'
226
+ >>> authorization_url = 'https://api.twitter.com/oauth/authorize'
227
+ >>> oauth_session = OAuth1Session('client-key', client_secret='secret')
228
+ >>> oauth_session.fetch_request_token(request_token_url)
229
+ {
230
+ 'oauth_token': 'sdf0o9823sjdfsdf',
231
+ 'oauth_token_secret': '2kjshdfp92i34asdasd',
232
+ }
233
+ >>> oauth_session.authorization_url(authorization_url)
234
+ 'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf'
235
+ >>> oauth_session.authorization_url(authorization_url, foo='bar')
236
+ 'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf&foo=bar'
237
+
238
+ An example using an explicit callback URI.
239
+
240
+ >>> request_token_url = 'https://api.twitter.com/oauth/request_token'
241
+ >>> authorization_url = 'https://api.twitter.com/oauth/authorize'
242
+ >>> oauth_session = OAuth1Session('client-key', client_secret='secret', callback_uri='https://127.0.0.1/callback')
243
+ >>> oauth_session.fetch_request_token(request_token_url)
244
+ {
245
+ 'oauth_token': 'sdf0o9823sjdfsdf',
246
+ 'oauth_token_secret': '2kjshdfp92i34asdasd',
247
+ }
248
+ >>> oauth_session.authorization_url(authorization_url)
249
+ 'https://api.twitter.com/oauth/authorize?oauth_token=sdf0o9823sjdfsdf&oauth_callback=https%3A%2F%2F127.0.0.1%2Fcallback'
250
+ """
251
+ kwargs["oauth_token"] = request_token or self._client.client.resource_owner_key
252
+ log.debug("Adding parameters %s to url %s", kwargs, url)
253
+ return add_params_to_uri(url, kwargs.items())
254
+
255
+ def fetch_request_token(self, url, realm=None, **request_kwargs):
256
+ """Fetch a request token.
257
+
258
+ This is the first step in the OAuth 1 workflow. A request token is
259
+ obtained by making a signed post request to url. The token is then
260
+ parsed from the application/x-www-form-urlencoded response and ready
261
+ to be used to construct an authorization url.
262
+
263
+ :param url: The request token endpoint URL.
264
+ :param realm: A list of realms to request access to.
265
+ :param request_kwargs: Optional arguments passed to ''post''
266
+ function in ''requests.Session''
267
+ :returns: The response in dict format.
268
+
269
+ Note that a previously set callback_uri will be reset for your
270
+ convenience, or else signature creation will be incorrect on
271
+ consecutive requests.
272
+
273
+ >>> request_token_url = 'https://api.twitter.com/oauth/request_token'
274
+ >>> oauth_session = OAuth1Session('client-key', client_secret='secret')
275
+ >>> oauth_session.fetch_request_token(request_token_url)
276
+ {
277
+ 'oauth_token': 'sdf0o9823sjdfsdf',
278
+ 'oauth_token_secret': '2kjshdfp92i34asdasd',
279
+ }
280
+ """
281
+ self._client.client.realm = " ".join(realm) if realm else None
282
+ token = self._fetch_token(url, **request_kwargs)
283
+ log.debug("Resetting callback_uri and realm (not needed in next phase).")
284
+ self._client.client.callback_uri = None
285
+ self._client.client.realm = None
286
+ return token
287
+
288
+ def fetch_access_token(self, url, verifier=None, **request_kwargs):
289
+ """Fetch an access token.
290
+
291
+ This is the final step in the OAuth 1 workflow. An access token is
292
+ obtained using all previously obtained credentials, including the
293
+ verifier from the authorization step.
294
+
295
+ Note that a previously set verifier will be reset for your
296
+ convenience, or else signature creation will be incorrect on
297
+ consecutive requests.
298
+
299
+ >>> access_token_url = 'https://api.twitter.com/oauth/access_token'
300
+ >>> redirect_response = 'https://127.0.0.1/callback?oauth_token=kjerht2309uf&oauth_token_secret=lsdajfh923874&oauth_verifier=w34o8967345'
301
+ >>> oauth_session = OAuth1Session('client-key', client_secret='secret')
302
+ >>> oauth_session.parse_authorization_response(redirect_response)
303
+ {
304
+ 'oauth_token: 'kjerht2309u',
305
+ 'oauth_token_secret: 'lsdajfh923874',
306
+ 'oauth_verifier: 'w34o8967345',
307
+ }
308
+ >>> oauth_session.fetch_access_token(access_token_url)
309
+ {
310
+ 'oauth_token': 'sdf0o9823sjdfsdf',
311
+ 'oauth_token_secret': '2kjshdfp92i34asdasd',
312
+ }
313
+ """
314
+ if verifier:
315
+ self._client.client.verifier = verifier
316
+ if not getattr(self._client.client, "verifier", None):
317
+ raise VerifierMissing("No client verifier has been set.")
318
+ token = self._fetch_token(url, **request_kwargs)
319
+ log.debug("Resetting verifier attribute, should not be used anymore.")
320
+ self._client.client.verifier = None
321
+ return token
322
+
323
+ def parse_authorization_response(self, url):
324
+ """Extract parameters from the post authorization redirect response URL.
325
+
326
+ :param url: The full URL that resulted from the user being redirected
327
+ back from the OAuth provider to you, the client.
328
+ :returns: A dict of parameters extracted from the URL.
329
+
330
+ >>> redirect_response = 'https://127.0.0.1/callback?oauth_token=kjerht2309uf&oauth_token_secret=lsdajfh923874&oauth_verifier=w34o8967345'
331
+ >>> oauth_session = OAuth1Session('client-key', client_secret='secret')
332
+ >>> oauth_session.parse_authorization_response(redirect_response)
333
+ {
334
+ 'oauth_token: 'kjerht2309u',
335
+ 'oauth_token_secret: 'lsdajfh923874',
336
+ 'oauth_verifier: 'w34o8967345',
337
+ }
338
+ """
339
+ log.debug("Parsing token from query part of url %s", url)
340
+ token = dict(urldecode(urlparse(url).query))
341
+ log.debug("Updating internal client token attribute.")
342
+ self._populate_attributes(token)
343
+ self.token = token
344
+ return token
345
+
346
+ def _populate_attributes(self, token):
347
+ if "oauth_token" in token:
348
+ self._client.client.resource_owner_key = token["oauth_token"]
349
+ else:
350
+ raise TokenMissing(
351
+ "Response does not contain a token: {resp}".format(resp=token), token
352
+ )
353
+ if "oauth_token_secret" in token:
354
+ self._client.client.resource_owner_secret = token["oauth_token_secret"]
355
+ if "oauth_verifier" in token:
356
+ self._client.client.verifier = token["oauth_verifier"]
357
+
358
+ def _fetch_token(self, url, **request_kwargs):
359
+ log.debug("Fetching token from %s using client %s", url, self._client.client)
360
+ r = self.post(url, **request_kwargs)
361
+
362
+ if r.status_code >= 400:
363
+ error = "Token request failed with code %s, response was '%s'."
364
+ raise TokenRequestDenied(error % (r.status_code, r.text), r)
365
+
366
+ log.debug('Decoding token from response "%s"', r.text)
367
+ try:
368
+ token = dict(urldecode(r.text.strip()))
369
+ except ValueError as e:
370
+ error = (
371
+ "Unable to decode token from token response. "
372
+ "This is commonly caused by an unsuccessful request where"
373
+ " a non urlencoded error message is returned. "
374
+ "The decoding error was %s"
375
+ "" % e
376
+ )
377
+ raise ValueError(error)
378
+
379
+ log.debug("Obtained token %s", token)
380
+ log.debug("Updating internal client attributes from token data.")
381
+ self._populate_attributes(token)
382
+ self.token = token
383
+ return token
384
+
385
+ def rebuild_auth(self, prepared_request, response):
386
+ """
387
+ When being redirected we should always strip Authorization
388
+ header, since nonce may not be reused as per OAuth spec.
389
+ """
390
+ if "Authorization" in prepared_request.headers:
391
+ # If we get redirected to a new host, we should strip out
392
+ # any authentication headers.
393
+ prepared_request.headers.pop("Authorization", True)
394
+ prepared_request.prepare_auth(self.auth)
395
+ return
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/oauth2_auth.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from oauthlib.oauth2 import WebApplicationClient, InsecureTransportError
2
+ from oauthlib.oauth2 import is_secure_transport
3
+ from requests.auth import AuthBase
4
+
5
+
6
+ class OAuth2(AuthBase):
7
+ """Adds proof of authorization (OAuth2 token) to the request."""
8
+
9
+ def __init__(self, client_id=None, client=None, token=None):
10
+ """Construct a new OAuth 2 authorization object.
11
+
12
+ :param client_id: Client id obtained during registration
13
+ :param client: :class:`oauthlib.oauth2.Client` to be used. Default is
14
+ WebApplicationClient which is useful for any
15
+ hosted application but not mobile or desktop.
16
+ :param token: Token dictionary, must include access_token
17
+ and token_type.
18
+ """
19
+ self._client = client or WebApplicationClient(client_id, token=token)
20
+ if token:
21
+ for k, v in token.items():
22
+ setattr(self._client, k, v)
23
+
24
+ def __call__(self, r):
25
+ """Append an OAuth 2 token to the request.
26
+
27
+ Note that currently HTTPS is required for all requests. There may be
28
+ a token type that allows for plain HTTP in the future and then this
29
+ should be updated to allow plain HTTP on a white list basis.
30
+ """
31
+ if not is_secure_transport(r.url):
32
+ raise InsecureTransportError()
33
+ r.url, r.headers, r.body = self._client.add_token(
34
+ r.url, http_method=r.method, body=r.body, headers=r.headers
35
+ )
36
+ return r
evalkit_internvl/lib/python3.10/site-packages/requests_oauthlib/oauth2_session.py ADDED
@@ -0,0 +1,587 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+
3
+ from oauthlib.common import generate_token, urldecode
4
+ from oauthlib.oauth2 import WebApplicationClient, InsecureTransportError
5
+ from oauthlib.oauth2 import LegacyApplicationClient
6
+ from oauthlib.oauth2 import TokenExpiredError, is_secure_transport
7
+ import requests
8
+
9
+ log = logging.getLogger(__name__)
10
+
11
+
12
+ class TokenUpdated(Warning):
13
+ def __init__(self, token):
14
+ super(TokenUpdated, self).__init__()
15
+ self.token = token
16
+
17
+
18
+ class OAuth2Session(requests.Session):
19
+ """Versatile OAuth 2 extension to :class:`requests.Session`.
20
+
21
+ Supports any grant type adhering to :class:`oauthlib.oauth2.Client` spec
22
+ including the four core OAuth 2 grants.
23
+
24
+ Can be used to create authorization urls, fetch tokens and access protected
25
+ resources using the :class:`requests.Session` interface you are used to.
26
+
27
+ - :class:`oauthlib.oauth2.WebApplicationClient` (default): Authorization Code Grant
28
+ - :class:`oauthlib.oauth2.MobileApplicationClient`: Implicit Grant
29
+ - :class:`oauthlib.oauth2.LegacyApplicationClient`: Password Credentials Grant
30
+ - :class:`oauthlib.oauth2.BackendApplicationClient`: Client Credentials Grant
31
+
32
+ Note that the only time you will be using Implicit Grant from python is if
33
+ you are driving a user agent able to obtain URL fragments.
34
+ """
35
+
36
+ def __init__(
37
+ self,
38
+ client_id=None,
39
+ client=None,
40
+ auto_refresh_url=None,
41
+ auto_refresh_kwargs=None,
42
+ scope=None,
43
+ redirect_uri=None,
44
+ token=None,
45
+ state=None,
46
+ token_updater=None,
47
+ pkce=None,
48
+ **kwargs
49
+ ):
50
+ """Construct a new OAuth 2 client session.
51
+
52
+ :param client_id: Client id obtained during registration
53
+ :param client: :class:`oauthlib.oauth2.Client` to be used. Default is
54
+ WebApplicationClient which is useful for any
55
+ hosted application but not mobile or desktop.
56
+ :param scope: List of scopes you wish to request access to
57
+ :param redirect_uri: Redirect URI you registered as callback
58
+ :param token: Token dictionary, must include access_token
59
+ and token_type.
60
+ :param state: State string used to prevent CSRF. This will be given
61
+ when creating the authorization url and must be supplied
62
+ when parsing the authorization response.
63
+ Can be either a string or a no argument callable.
64
+ :auto_refresh_url: Refresh token endpoint URL, must be HTTPS. Supply
65
+ this if you wish the client to automatically refresh
66
+ your access tokens.
67
+ :auto_refresh_kwargs: Extra arguments to pass to the refresh token
68
+ endpoint.
69
+ :token_updater: Method with one argument, token, to be used to update
70
+ your token database on automatic token refresh. If not
71
+ set a TokenUpdated warning will be raised when a token
72
+ has been refreshed. This warning will carry the token
73
+ in its token argument.
74
+ :param pkce: Set "S256" or "plain" to enable PKCE. Default is disabled.
75
+ :param kwargs: Arguments to pass to the Session constructor.
76
+ """
77
+ super(OAuth2Session, self).__init__(**kwargs)
78
+ self._client = client or WebApplicationClient(client_id, token=token)
79
+ self.token = token or {}
80
+ self._scope = scope
81
+ self.redirect_uri = redirect_uri
82
+ self.state = state or generate_token
83
+ self._state = state
84
+ self.auto_refresh_url = auto_refresh_url
85
+ self.auto_refresh_kwargs = auto_refresh_kwargs or {}
86
+ self.token_updater = token_updater
87
+ self._pkce = pkce
88
+
89
+ if self._pkce not in ["S256", "plain", None]:
90
+ raise AttributeError("Wrong value for {}(.., pkce={})".format(self.__class__, self._pkce))
91
+
92
+ # Ensure that requests doesn't do any automatic auth. See #278.
93
+ # The default behavior can be re-enabled by setting auth to None.
94
+ self.auth = lambda r: r
95
+
96
+ # Allow customizations for non compliant providers through various
97
+ # hooks to adjust requests and responses.
98
+ self.compliance_hook = {
99
+ "access_token_response": set(),
100
+ "refresh_token_response": set(),
101
+ "protected_request": set(),
102
+ "refresh_token_request": set(),
103
+ "access_token_request": set(),
104
+ }
105
+
106
+ @property
107
+ def scope(self):
108
+ """By default the scope from the client is used, except if overridden"""
109
+ if self._scope is not None:
110
+ return self._scope
111
+ elif self._client is not None:
112
+ return self._client.scope
113
+ else:
114
+ return None
115
+
116
+ @scope.setter
117
+ def scope(self, scope):
118
+ self._scope = scope
119
+
120
+ def new_state(self):
121
+ """Generates a state string to be used in authorizations."""
122
+ try:
123
+ self._state = self.state()
124
+ log.debug("Generated new state %s.", self._state)
125
+ except TypeError:
126
+ self._state = self.state
127
+ log.debug("Re-using previously supplied state %s.", self._state)
128
+ return self._state
129
+
130
+ @property
131
+ def client_id(self):
132
+ return getattr(self._client, "client_id", None)
133
+
134
+ @client_id.setter
135
+ def client_id(self, value):
136
+ self._client.client_id = value
137
+
138
+ @client_id.deleter
139
+ def client_id(self):
140
+ del self._client.client_id
141
+
142
+ @property
143
+ def token(self):
144
+ return getattr(self._client, "token", None)
145
+
146
+ @token.setter
147
+ def token(self, value):
148
+ self._client.token = value
149
+ self._client.populate_token_attributes(value)
150
+
151
+ @property
152
+ def access_token(self):
153
+ return getattr(self._client, "access_token", None)
154
+
155
+ @access_token.setter
156
+ def access_token(self, value):
157
+ self._client.access_token = value
158
+
159
+ @access_token.deleter
160
+ def access_token(self):
161
+ del self._client.access_token
162
+
163
+ @property
164
+ def authorized(self):
165
+ """Boolean that indicates whether this session has an OAuth token
166
+ or not. If `self.authorized` is True, you can reasonably expect
167
+ OAuth-protected requests to the resource to succeed. If
168
+ `self.authorized` is False, you need the user to go through the OAuth
169
+ authentication dance before OAuth-protected requests to the resource
170
+ will succeed.
171
+ """
172
+ return bool(self.access_token)
173
+
174
+ def authorization_url(self, url, state=None, **kwargs):
175
+ """Form an authorization URL.
176
+
177
+ :param url: Authorization endpoint url, must be HTTPS.
178
+ :param state: An optional state string for CSRF protection. If not
179
+ given it will be generated for you.
180
+ :param kwargs: Extra parameters to include.
181
+ :return: authorization_url, state
182
+ """
183
+ state = state or self.new_state()
184
+ if self._pkce:
185
+ self._code_verifier = self._client.create_code_verifier(43)
186
+ kwargs["code_challenge_method"] = self._pkce
187
+ kwargs["code_challenge"] = self._client.create_code_challenge(
188
+ code_verifier=self._code_verifier,
189
+ code_challenge_method=self._pkce
190
+ )
191
+ return (
192
+ self._client.prepare_request_uri(
193
+ url,
194
+ redirect_uri=self.redirect_uri,
195
+ scope=self.scope,
196
+ state=state,
197
+ **kwargs
198
+ ),
199
+ state,
200
+ )
201
+
202
+ def fetch_token(
203
+ self,
204
+ token_url,
205
+ code=None,
206
+ authorization_response=None,
207
+ body="",
208
+ auth=None,
209
+ username=None,
210
+ password=None,
211
+ method="POST",
212
+ force_querystring=False,
213
+ timeout=None,
214
+ headers=None,
215
+ verify=None,
216
+ proxies=None,
217
+ include_client_id=None,
218
+ client_secret=None,
219
+ cert=None,
220
+ **kwargs
221
+ ):
222
+ """Generic method for fetching an access token from the token endpoint.
223
+
224
+ If you are using the MobileApplicationClient you will want to use
225
+ `token_from_fragment` instead of `fetch_token`.
226
+
227
+ The current implementation enforces the RFC guidelines.
228
+
229
+ :param token_url: Token endpoint URL, must use HTTPS.
230
+ :param code: Authorization code (used by WebApplicationClients).
231
+ :param authorization_response: Authorization response URL, the callback
232
+ URL of the request back to you. Used by
233
+ WebApplicationClients instead of code.
234
+ :param body: Optional application/x-www-form-urlencoded body to add the
235
+ include in the token request. Prefer kwargs over body.
236
+ :param auth: An auth tuple or method as accepted by `requests`.
237
+ :param username: Username required by LegacyApplicationClients to appear
238
+ in the request body.
239
+ :param password: Password required by LegacyApplicationClients to appear
240
+ in the request body.
241
+ :param method: The HTTP method used to make the request. Defaults
242
+ to POST, but may also be GET. Other methods should
243
+ be added as needed.
244
+ :param force_querystring: If True, force the request body to be sent
245
+ in the querystring instead.
246
+ :param timeout: Timeout of the request in seconds.
247
+ :param headers: Dict to default request headers with.
248
+ :param verify: Verify SSL certificate.
249
+ :param proxies: The `proxies` argument is passed onto `requests`.
250
+ :param include_client_id: Should the request body include the
251
+ `client_id` parameter. Default is `None`,
252
+ which will attempt to autodetect. This can be
253
+ forced to always include (True) or never
254
+ include (False).
255
+ :param client_secret: The `client_secret` paired to the `client_id`.
256
+ This is generally required unless provided in the
257
+ `auth` tuple. If the value is `None`, it will be
258
+ omitted from the request, however if the value is
259
+ an empty string, an empty string will be sent.
260
+ :param cert: Client certificate to send for OAuth 2.0 Mutual-TLS Client
261
+ Authentication (draft-ietf-oauth-mtls). Can either be the
262
+ path of a file containing the private key and certificate or
263
+ a tuple of two filenames for certificate and key.
264
+ :param kwargs: Extra parameters to include in the token request.
265
+ :return: A token dict
266
+ """
267
+ if not is_secure_transport(token_url):
268
+ raise InsecureTransportError()
269
+
270
+ if not code and authorization_response:
271
+ self._client.parse_request_uri_response(
272
+ authorization_response, state=self._state
273
+ )
274
+ code = self._client.code
275
+ elif not code and isinstance(self._client, WebApplicationClient):
276
+ code = self._client.code
277
+ if not code:
278
+ raise ValueError(
279
+ "Please supply either code or " "authorization_response parameters."
280
+ )
281
+
282
+ if self._pkce:
283
+ if self._code_verifier is None:
284
+ raise ValueError(
285
+ "Code verifier is not found, authorization URL must be generated before"
286
+ )
287
+ kwargs["code_verifier"] = self._code_verifier
288
+
289
+ # Earlier versions of this library build an HTTPBasicAuth header out of
290
+ # `username` and `password`. The RFC states, however these attributes
291
+ # must be in the request body and not the header.
292
+ # If an upstream server is not spec compliant and requires them to
293
+ # appear as an Authorization header, supply an explicit `auth` header
294
+ # to this function.
295
+ # This check will allow for empty strings, but not `None`.
296
+ #
297
+ # References
298
+ # 4.3.2 - Resource Owner Password Credentials Grant
299
+ # https://tools.ietf.org/html/rfc6749#section-4.3.2
300
+
301
+ if isinstance(self._client, LegacyApplicationClient):
302
+ if username is None:
303
+ raise ValueError(
304
+ "`LegacyApplicationClient` requires both the "
305
+ "`username` and `password` parameters."
306
+ )
307
+ if password is None:
308
+ raise ValueError(
309
+ "The required parameter `username` was supplied, "
310
+ "but `password` was not."
311
+ )
312
+
313
+ # merge username and password into kwargs for `prepare_request_body`
314
+ if username is not None:
315
+ kwargs["username"] = username
316
+ if password is not None:
317
+ kwargs["password"] = password
318
+
319
+ # is an auth explicitly supplied?
320
+ if auth is not None:
321
+ # if we're dealing with the default of `include_client_id` (None):
322
+ # we will assume the `auth` argument is for an RFC compliant server
323
+ # and we should not send the `client_id` in the body.
324
+ # This approach allows us to still force the client_id by submitting
325
+ # `include_client_id=True` along with an `auth` object.
326
+ if include_client_id is None:
327
+ include_client_id = False
328
+
329
+ # otherwise we may need to create an auth header
330
+ else:
331
+ # since we don't have an auth header, we MAY need to create one
332
+ # it is possible that we want to send the `client_id` in the body
333
+ # if so, `include_client_id` should be set to True
334
+ # otherwise, we will generate an auth header
335
+ if include_client_id is not True:
336
+ client_id = self.client_id
337
+ if client_id:
338
+ log.debug(
339
+ 'Encoding `client_id` "%s" with `client_secret` '
340
+ "as Basic auth credentials.",
341
+ client_id,
342
+ )
343
+ client_secret = client_secret if client_secret is not None else ""
344
+ auth = requests.auth.HTTPBasicAuth(client_id, client_secret)
345
+
346
+ if include_client_id:
347
+ # this was pulled out of the params
348
+ # it needs to be passed into prepare_request_body
349
+ if client_secret is not None:
350
+ kwargs["client_secret"] = client_secret
351
+
352
+ body = self._client.prepare_request_body(
353
+ code=code,
354
+ body=body,
355
+ redirect_uri=self.redirect_uri,
356
+ include_client_id=include_client_id,
357
+ **kwargs
358
+ )
359
+
360
+ headers = headers or {
361
+ "Accept": "application/json",
362
+ "Content-Type": "application/x-www-form-urlencoded",
363
+ }
364
+ self.token = {}
365
+ request_kwargs = {}
366
+ if method.upper() == "POST":
367
+ request_kwargs["params" if force_querystring else "data"] = dict(
368
+ urldecode(body)
369
+ )
370
+ elif method.upper() == "GET":
371
+ request_kwargs["params"] = dict(urldecode(body))
372
+ else:
373
+ raise ValueError("The method kwarg must be POST or GET.")
374
+
375
+ for hook in self.compliance_hook["access_token_request"]:
376
+ log.debug("Invoking access_token_request hook %s.", hook)
377
+ token_url, headers, request_kwargs = hook(
378
+ token_url, headers, request_kwargs
379
+ )
380
+
381
+ r = self.request(
382
+ method=method,
383
+ url=token_url,
384
+ timeout=timeout,
385
+ headers=headers,
386
+ auth=auth,
387
+ verify=verify,
388
+ proxies=proxies,
389
+ cert=cert,
390
+ **request_kwargs
391
+ )
392
+
393
+ log.debug("Request to fetch token completed with status %s.", r.status_code)
394
+ log.debug("Request url was %s", r.request.url)
395
+ log.debug("Request headers were %s", r.request.headers)
396
+ log.debug("Request body was %s", r.request.body)
397
+ log.debug("Response headers were %s and content %s.", r.headers, r.text)
398
+ log.debug(
399
+ "Invoking %d token response hooks.",
400
+ len(self.compliance_hook["access_token_response"]),
401
+ )
402
+ for hook in self.compliance_hook["access_token_response"]:
403
+ log.debug("Invoking hook %s.", hook)
404
+ r = hook(r)
405
+
406
+ self._client.parse_request_body_response(r.text, scope=self.scope)
407
+ self.token = self._client.token
408
+ log.debug("Obtained token %s.", self.token)
409
+ return self.token
410
+
411
+ def token_from_fragment(self, authorization_response):
412
+ """Parse token from the URI fragment, used by MobileApplicationClients.
413
+
414
+ :param authorization_response: The full URL of the redirect back to you
415
+ :return: A token dict
416
+ """
417
+ self._client.parse_request_uri_response(
418
+ authorization_response, state=self._state
419
+ )
420
+ self.token = self._client.token
421
+ return self.token
422
+
423
+ def refresh_token(
424
+ self,
425
+ token_url,
426
+ refresh_token=None,
427
+ body="",
428
+ auth=None,
429
+ timeout=None,
430
+ headers=None,
431
+ verify=None,
432
+ proxies=None,
433
+ **kwargs
434
+ ):
435
+ """Fetch a new access token using a refresh token.
436
+
437
+ :param token_url: The token endpoint, must be HTTPS.
438
+ :param refresh_token: The refresh_token to use.
439
+ :param body: Optional application/x-www-form-urlencoded body to add the
440
+ include in the token request. Prefer kwargs over body.
441
+ :param auth: An auth tuple or method as accepted by `requests`.
442
+ :param timeout: Timeout of the request in seconds.
443
+ :param headers: A dict of headers to be used by `requests`.
444
+ :param verify: Verify SSL certificate.
445
+ :param proxies: The `proxies` argument will be passed to `requests`.
446
+ :param kwargs: Extra parameters to include in the token request.
447
+ :return: A token dict
448
+ """
449
+ if not token_url:
450
+ raise ValueError("No token endpoint set for auto_refresh.")
451
+
452
+ if not is_secure_transport(token_url):
453
+ raise InsecureTransportError()
454
+
455
+ refresh_token = refresh_token or self.token.get("refresh_token")
456
+
457
+ log.debug(
458
+ "Adding auto refresh key word arguments %s.", self.auto_refresh_kwargs
459
+ )
460
+ kwargs.update(self.auto_refresh_kwargs)
461
+ body = self._client.prepare_refresh_body(
462
+ body=body, refresh_token=refresh_token, scope=self.scope, **kwargs
463
+ )
464
+ log.debug("Prepared refresh token request body %s", body)
465
+
466
+ if headers is None:
467
+ headers = {
468
+ "Accept": "application/json",
469
+ "Content-Type": ("application/x-www-form-urlencoded"),
470
+ }
471
+
472
+ for hook in self.compliance_hook["refresh_token_request"]:
473
+ log.debug("Invoking refresh_token_request hook %s.", hook)
474
+ token_url, headers, body = hook(token_url, headers, body)
475
+
476
+ r = self.post(
477
+ token_url,
478
+ data=dict(urldecode(body)),
479
+ auth=auth,
480
+ timeout=timeout,
481
+ headers=headers,
482
+ verify=verify,
483
+ withhold_token=True,
484
+ proxies=proxies,
485
+ )
486
+ log.debug("Request to refresh token completed with status %s.", r.status_code)
487
+ log.debug("Response headers were %s and content %s.", r.headers, r.text)
488
+ log.debug(
489
+ "Invoking %d token response hooks.",
490
+ len(self.compliance_hook["refresh_token_response"]),
491
+ )
492
+ for hook in self.compliance_hook["refresh_token_response"]:
493
+ log.debug("Invoking hook %s.", hook)
494
+ r = hook(r)
495
+
496
+ self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
497
+ if "refresh_token" not in self.token:
498
+ log.debug("No new refresh token given. Re-using old.")
499
+ self.token["refresh_token"] = refresh_token
500
+ return self.token
501
+
502
+ def request(
503
+ self,
504
+ method,
505
+ url,
506
+ data=None,
507
+ headers=None,
508
+ withhold_token=False,
509
+ client_id=None,
510
+ client_secret=None,
511
+ files=None,
512
+ **kwargs
513
+ ):
514
+ """Intercept all requests and add the OAuth 2 token if present."""
515
+ if not is_secure_transport(url):
516
+ raise InsecureTransportError()
517
+ if self.token and not withhold_token:
518
+ log.debug(
519
+ "Invoking %d protected resource request hooks.",
520
+ len(self.compliance_hook["protected_request"]),
521
+ )
522
+ for hook in self.compliance_hook["protected_request"]:
523
+ log.debug("Invoking hook %s.", hook)
524
+ url, headers, data = hook(url, headers, data)
525
+
526
+ log.debug("Adding token %s to request.", self.token)
527
+ try:
528
+ url, headers, data = self._client.add_token(
529
+ url, http_method=method, body=data, headers=headers
530
+ )
531
+ # Attempt to retrieve and save new access token if expired
532
+ except TokenExpiredError:
533
+ if self.auto_refresh_url:
534
+ log.debug(
535
+ "Auto refresh is set, attempting to refresh at %s.",
536
+ self.auto_refresh_url,
537
+ )
538
+
539
+ # We mustn't pass auth twice.
540
+ auth = kwargs.pop("auth", None)
541
+ if client_id and client_secret and (auth is None):
542
+ log.debug(
543
+ 'Encoding client_id "%s" with client_secret as Basic auth credentials.',
544
+ client_id,
545
+ )
546
+ auth = requests.auth.HTTPBasicAuth(client_id, client_secret)
547
+ token = self.refresh_token(
548
+ self.auto_refresh_url, auth=auth, **kwargs
549
+ )
550
+ if self.token_updater:
551
+ log.debug(
552
+ "Updating token to %s using %s.", token, self.token_updater
553
+ )
554
+ self.token_updater(token)
555
+ url, headers, data = self._client.add_token(
556
+ url, http_method=method, body=data, headers=headers
557
+ )
558
+ else:
559
+ raise TokenUpdated(token)
560
+ else:
561
+ raise
562
+
563
+ log.debug("Requesting url %s using method %s.", url, method)
564
+ log.debug("Supplying headers %s and data %s", headers, data)
565
+ log.debug("Passing through key word arguments %s.", kwargs)
566
+ return super(OAuth2Session, self).request(
567
+ method, url, headers=headers, data=data, files=files, **kwargs
568
+ )
569
+
570
+ def register_compliance_hook(self, hook_type, hook):
571
+ """Register a hook for request/response tweaking.
572
+
573
+ Available hooks are:
574
+ access_token_response invoked before token parsing.
575
+ refresh_token_response invoked before refresh token parsing.
576
+ protected_request invoked before making a request.
577
+ access_token_request invoked before making a token fetch request.
578
+ refresh_token_request invoked before making a refresh request.
579
+
580
+ If you find a new hook is needed please send a GitHub PR request
581
+ or open an issue.
582
+ """
583
+ if hook_type not in self.compliance_hook:
584
+ raise ValueError(
585
+ "Hook type %s is not in %s.", hook_type, self.compliance_hook
586
+ )
587
+ self.compliance_hook[hook_type].add(hook)
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.83 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/assign.cpython-310.pyc ADDED
Binary file (6.19 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/attrdict.cpython-310.pyc ADDED
Binary file (546 Bytes). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/base.cpython-310.pyc ADDED
Binary file (686 Bytes). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/bitfield.cpython-310.pyc ADDED
Binary file (7.43 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/css.cpython-310.pyc ADDED
Binary file (9.18 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/tspan.cpython-310.pyc ADDED
Binary file (4.57 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/version.cpython-310.pyc ADDED
Binary file (551 Bytes). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/waveform.cpython-310.pyc ADDED
Binary file (26.6 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/__pycache__/waveskin.cpython-310.pyc ADDED
Binary file (42 kB). View file
 
evalkit_internvl/lib/python3.10/site-packages/wavedrom/assign.py ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright wavedrompy contributors.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ # Translated to Python from original file:
5
+ # https://github.com/drom/wavedrom/blob/master/src/WaveDrom.js
6
+
7
+ from collections import namedtuple
8
+ import svgwrite
9
+
10
+ from .base import SVGBase
11
+
12
+
13
+ class RenderState:
14
+ def __init__(self, x=0, y=0, xmax=0):
15
+ self.x = x
16
+ self.y = y
17
+ self.xmax = xmax
18
+
19
+ def __str__(self):
20
+ return "x={} y={}, xmax={}".format(self.x, self.y, self.xmax)
21
+
22
+
23
+ RenderObject = namedtuple("RenderObject", "name x y")
24
+
25
+
26
+ class Assign(SVGBase):
27
+ def render_tree(self, tree, state):
28
+ state.xmax = max(state.xmax, state.x)
29
+ y = state.y
30
+ for i in range(1, len(tree)):
31
+ if isinstance(tree[i], list):
32
+ state = self.render_tree(tree[i], RenderState(x=state.x+1, y=state.y, xmax=state.xmax))
33
+ else:
34
+ tree[i] = RenderObject(name=tree[i], x=state.x+1, y=state.y)
35
+ state.y += 2
36
+ tree[0] = RenderObject(name=tree[0], x=state.x, y=round((y+state.y-2)/2))
37
+ state.x -= 1
38
+
39
+ return state
40
+
41
+ def draw_body(self, type, ymin, ymax):
42
+ circle = ' M 4,0 C 4,1.1 3.1,2 2,2 0.9,2 0,1.1 0,0 c 0,-1.1 0.9,-2 2,-2 1.1,0 2,0.9 2,2 z'
43
+ gates = {
44
+ '~': 'M -11,-6 -11,6 0,0 z m -5,6 5,0' + circle,
45
+ '=': 'M -11,-6 -11,6 0,0 z m -5,6 5,0',
46
+ '&': 'm -16,-10 5,0 c 6,0 11,4 11,10 0,6 -5,10 -11,10 l -5,0 z',
47
+ '~&': 'm -16,-10 5,0 c 6,0 11,4 11,10 0,6 -5,10 -11,10 l -5,0 z' + circle,
48
+ '|': 'm -18,-10 4,0 c 6,0 12,5 14,10 -2,5 -8,10 -14,10 l -4,0 c 2.5,-5 2.5,-15 0,-20 z',
49
+ '~|': 'm -18,-10 4,0 c 6,0 12,5 14,10 -2,5 -8,10 -14,10 l -4,0 c 2.5,-5 2.5,-15 0,-20 z' + circle,
50
+ '^': 'm -21,-10 c 1,3 2,6 2,10 m 0,0 c 0,4 -1,7 -2,10 m 3,-20 4,0 c 6,0 12,5 14,10 -2,5 -8,10 -14,10 l -4,0 c 1,-3 2,-6 2,-10 0,-4 -1,-7 -2,-10 z',
51
+ '~^': 'm -21,-10 c 1,3 2,6 2,10 m 0,0 c 0,4 -1,7 -2,10 m 3,-20 4,0 c 6,0 12,5 14,10 -2,5 -8,10 -14,10 l -4,0 c 1,-3 2,-6 2,-10 0,-4 -1,-7 -2,-10 z' + circle,
52
+ '+': 'm -8,5 0,-10 m -5,5 10,0 m 3,0 c 0,4.418278 -3.581722,8 -8,8 -4.418278,0 -8,-3.581722 -8,-8 0,-4.418278 3.581722,-8 8,-8 4.418278,0 8,3.581722 8,8 z',
53
+ '*': 'm -4,4 -8,-8 m 0,8 8,-8 m 4,4 c 0,4.418278 -3.581722,8 -8,8 -4.418278,0 -8,-3.581722 -8,-8 0,-4.418278 3.581722,-8 8,-8 4.418278,0 8,3.581722 8,8 z'
54
+ }
55
+ iec = {
56
+ "BUF": 1, "INV": 1, "AND": '&', "NAND": '&',
57
+ "OR": '\u22651', "NOR": '\u22651', "XOR": '=1', "XNOR": '=1', "box": ''
58
+ }
59
+ circled = { "INV", "NAND", "NOR", "XNOR" }
60
+
61
+ if ymax == ymin:
62
+ ymax = 4
63
+ ymin = -4
64
+
65
+ if type in gates:
66
+ return self.element.path(class_='gate', d=gates[type])
67
+ elif type in iec:
68
+ g = self.container.g()
69
+ if type in circled:
70
+ path = self.element.path(class_="gate", d="m -16,{} 16,0 0,{} -16,0 z {}".format(ymin-3, ymax-ymin+6, circle))
71
+ else:
72
+ path = self.element.path(class_="gate", d="m -16,{} 16,0 0,{} -16,0 z".format(ymin-3, ymax-ymin+6))
73
+ g.add(path)
74
+ tspan = self.element.tspan(iec[type], x=[-14], y=[4], class_='wirename')
75
+ text = self.element.text('')
76
+ text.add(tspan)
77
+ g.add(text)
78
+ return g
79
+ else:
80
+ tspan = self.element.tspan(type, x=[-14], y=[4], class_='wirename')
81
+ text = self.element.text('')
82
+ text.add(tspan)
83
+ return text
84
+
85
+ def draw_gate(self, spec):
86
+ ret = self.container.g()
87
+
88
+ ys = [s[1] for s in spec[2:]]
89
+
90
+ ymin = min(ys)
91
+ ymax = max(ys)
92
+
93
+ g = self.container.g(transform="translate(16,0)")
94
+ g.add(self.element.path(d="M {},{} {},{}".format(spec[2][0], ymin, spec[2][0], ymax), class_='wire'))
95
+ ret.add(g)
96
+
97
+ for s in spec[2:]:
98
+ path = self.element.path(d="m {},{} 16,0".format(s[0], s[1]), class_='wire')
99
+ ret.add(self.container.g().add(path))
100
+
101
+ g = self.container.g(transform="translate({},{})".format(spec[1][0], spec[1][1]))
102
+ g.add(self.element.title(spec[0]))
103
+ g.add(self.draw_body(spec[0], ymin - spec[1][1], ymax - spec[1][1]))
104
+ ret.add(g)
105
+
106
+ return ret
107
+
108
+ def draw_boxes(self, tree, xmax):
109
+ ret = self.container.g()
110
+ spec = []
111
+
112
+ if isinstance(tree, list):
113
+ spec.append(tree[0].name);
114
+ spec.append([32 * (xmax - tree[0].x), 8 * tree[0].y]);
115
+ for t in tree[1:]:
116
+ if isinstance(t, list):
117
+ spec.append([32 * (xmax - t[0].x), 8 * t[0].y])
118
+ else:
119
+ spec.append([32 * (xmax - t.x), 8 * t.y])
120
+
121
+ ret.add(self.draw_gate(spec))
122
+
123
+ for t in tree[1:]:
124
+ ret.add(self.draw_boxes(t, xmax))
125
+ else:
126
+ fname = tree.name
127
+ fx = 32 * (xmax - tree.x)
128
+ fy = 8 * tree.y
129
+ g = self.container.g(transform="translate({},{})".format(fx, fy))
130
+ g.add(self.element.title(fname))
131
+ g.add(self.element.path(d='M 2,0 a 2,2 0 1 1 -4,0 2,2 0 1 1 4,0 z'))
132
+ tspan = self.element.tspan(fname, x=[-4], y=[4], class_='pinname')
133
+ text = self.element.text('')
134
+ text.add(tspan)
135
+ g.add(text)
136
+ ret.add(g)
137
+
138
+ return ret
139
+
140
+ def render(self, index = 0, source = {}, output = []):
141
+ STYLE = ".pinname {font-size:12px; font-style:normal; font-variant:normal; font-weight:500; font-stretch:normal; text-align:center; text-anchor:end; font-family:Helvetica} .wirename {font-size:12px; font-style:normal; font-variant:normal; font-weight:500; font-stretch:normal; text-align:center; text-anchor:start; font-family:Helvetica} .wirename:hover {fill:blue} .gate {color:#000; fill:#ffc; fill-opacity: 1;stroke:#000; stroke-width:1; stroke-opacity:1} .gate:hover {fill:red !important; } .wire {fill:none; stroke:#000; stroke-width:1; stroke-opacity:1} .grid {fill:#fff; fill-opacity:1; stroke:none}"
142
+
143
+ tree = source.get("assign")
144
+ state = RenderState(x=0, y=2, xmax=0)
145
+
146
+ for t in tree:
147
+ state = self.render_tree(t, state)
148
+ state.x += 1
149
+
150
+ xmax = state.xmax + 3
151
+
152
+ width = 32 * (xmax + 1) + 1
153
+ height = 8 * (state.y + 1) - 7
154
+ ilen = 4 * (xmax + 1)
155
+ jlen = state.y + 1
156
+
157
+ grid = self.container.g()
158
+
159
+ for i in range(ilen+1):
160
+ for j in range(jlen+1):
161
+ grid.add(self.element.rect(height=1, width=1, x=(i * 8 - 0.5), y=(j * 8 - 0.5), class_='grid'))
162
+
163
+ for t in tree:
164
+ content = self.draw_boxes(t, xmax)
165
+
166
+
167
+ attr = { 'viewBox': "0 0 {} {}".format(width, height)}
168
+ template = svgwrite.Drawing(id="svgcontent_{index}".format(index=index), size=[width, height], **attr)
169
+ template.defs.add(svgwrite.container.Style(content=STYLE))
170
+ g = self.container.g(transform="translate(0.5,0.5)")
171
+ g.add(grid)
172
+ g.add(content)
173
+ template.add(g)
174
+ return template
evalkit_internvl/lib/python3.10/site-packages/wavedrom/attrdict.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ class AttrDict(dict):
2
+ def __init__(self, *args, **kwargs):
3
+ super(AttrDict, self).__init__(*args, **kwargs)
4
+ self.__dict__ = self
evalkit_internvl/lib/python3.10/site-packages/wavedrom/base.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright wavedrompy contributors.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import svgwrite
5
+ from .attrdict import AttrDict
6
+
7
+ class SVGBase(object):
8
+ container = AttrDict({
9
+ "defs": svgwrite.container.Defs,
10
+ "g": svgwrite.container.Group,
11
+ "marker": svgwrite.container.Marker,
12
+ "use": svgwrite.container.Use,
13
+ })
14
+ element = AttrDict({
15
+ "rect": svgwrite.shapes.Rect,
16
+ "path": svgwrite.path.Path,
17
+ "text": svgwrite.text.Text,
18
+ "tspan": svgwrite.text.TSpan,
19
+ "title": svgwrite.base.Title,
20
+ "line": svgwrite.shapes.Line,
21
+ })
evalkit_internvl/lib/python3.10/site-packages/wavedrom/bitfield.py ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright wavedrompy contributors.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ # Translated to Python from original file:
5
+ # https://github.com/drom/wavedrom/blob/master/src/WaveDrom.js
6
+
7
+ from math import floor
8
+
9
+ import svgwrite
10
+
11
+ from .base import SVGBase
12
+ from .tspan import TspanParser
13
+
14
+ class Options:
15
+ def __init__(self, vspace=80, hspace=800, lanes=1, bits=32, hflip=False, vflip=False, fontsize=14, fontfamily='sans-serif', fontweight='normal'):
16
+ self.vspace = vspace if vspace > 19 else 80
17
+ self.hspace = hspace if hspace > 39 else 800
18
+ self.lanes = lanes if lanes > 0 else 1
19
+ self.bits = bits if bits > 4 else 32
20
+ self.hflip = hflip
21
+ self.vflip = vflip
22
+ self.fontsize = fontsize if fontsize > 5 else 14
23
+ self.fontfamily = fontfamily
24
+ self.fontweight = fontweight
25
+
26
+ colors = {2: 0, 3: 80, 4: 170, 5: 45, 6: 126, 7: 215}
27
+
28
+ def type_style(t):
29
+ if t in colors.keys():
30
+ return ";fill:hsl({},100%,50%)".format(colors[t])
31
+ else:
32
+ return ''
33
+
34
+
35
+ class BitField(SVGBase):
36
+ def tspan_parse(self, text):
37
+ parser = TspanParser()
38
+ parser.feed(text)
39
+ return parser.get_text()
40
+
41
+ def hline(self, len, x=0, y=0):
42
+ return self.element.line(start=(x,y), end=(x+len,y))
43
+
44
+ def vline(self, len, x=0, y=0):
45
+ return self.element.line(start=(x,y), end=(x,y+len))
46
+
47
+ def get_text(self, body, x, y=None):
48
+ x_list = None
49
+ if x:
50
+ x_list = [x]
51
+ y_list = None
52
+ if y:
53
+ y_list = [y]
54
+ text = self.element.text('', x=x_list, y=y_list)
55
+ for t in self.tspan_parse(str(body)):
56
+ text.add(t)
57
+ return text
58
+
59
+ def get_label(self, attr, x, y, step=0, length=0):
60
+ if isinstance(attr, int):
61
+ attr = int(attr)
62
+ res = []
63
+ for i in range(length):
64
+ val = (attr >> i) & 1
65
+ xi = x + step * (length / 2 - i - 0.5)
66
+ res.append(self.get_text(val, xi, y))
67
+ return res
68
+ else:
69
+ if '\n' in attr:
70
+ names = attr.split('\n')
71
+ count = len(names)
72
+ return [
73
+ self.get_text(name, x, y + (-(count - 1) / 2 + i) * self.opt.fontsize)
74
+ for (i, name) in enumerate(names)
75
+ ]
76
+ return [self.get_text(attr, x, y)]
77
+
78
+ def get_attrs(self, e, step, lsbm, msbm):
79
+ if self.opt.vflip:
80
+ x = step * (msbm + lsbm) / 2
81
+ else:
82
+ x = step * (self.mod - ((msbm + lsbm) / 2) - 1)
83
+ attr = e['attr']
84
+ bits = e['bits']
85
+ attrs = [attr]
86
+ # 'attr' supports both a scalar and a list.
87
+ if isinstance(attr, list):
88
+ attrs = attr
89
+ return [self.get_label(a, x, 16 * i, step, bits)
90
+ for (i, a) in enumerate(attrs)]
91
+
92
+ def labelArr(self, desc):
93
+ step = self.opt.hspace / self.mod
94
+ bits = self.container.g(transform="translate({},{})".format(step/2, self.opt.vspace/5))
95
+ names = self.container.g(transform="translate({},{})".format(step/2, self.opt.vspace/2+4))
96
+ attrs = self.container.g(transform="translate({},{})".format(step/2, self.opt.vspace))
97
+ blanks = self.container.g(transform="translate(0,{})".format(self.opt.vspace/4))
98
+
99
+ for e in desc:
100
+ lsbm = 0
101
+ msbm = self.mod - 1
102
+ lsb = self.index * self.mod
103
+ msb = (self.index + 1) * self.mod - 1
104
+
105
+ if floor(e["lsb"] / self.mod) == self.index:
106
+ lsbm = e["lsbm"]
107
+ lsb = e["lsb"]
108
+ if floor(e["msb"] / self.mod) == self.index:
109
+ msb = e["msb"]
110
+ msbm = e["msbm"]
111
+ else:
112
+ if floor(e["msb"] / self.mod) == self.index:
113
+ msb = e["msb"]
114
+ msbm = e["msbm"]
115
+ else:
116
+ continue
117
+
118
+ if self.opt.vflip:
119
+ bits.add(self.get_text(lsb, x=[step*lsbm]))
120
+ else:
121
+ bits.add(self.get_text(lsb, x=[step*(self.mod-lsbm - 1)]))
122
+ if lsbm != msbm:
123
+ if self.opt.vflip:
124
+ bits.add(self.get_text(msb, x=[step * msbm]))
125
+ else:
126
+ bits.add(self.get_text(msb, x=[step * (self.mod - msbm - 1)]))
127
+ if e.get('name'):
128
+ if self.opt.vflip:
129
+ x = step*(msbm+lsbm)/2
130
+ else:
131
+ x = step*(self.mod-((msbm+lsbm)/2)-1)
132
+ for n in self.get_label(e['name'], x, 0):
133
+ names.add(n)
134
+
135
+ if not e.get('name') or e.get('type'):
136
+ style = 'fill-opacity:0.1' + type_style(e.get('type', 0))
137
+ if self.opt.vflip:
138
+ insert_x = lsbm
139
+ else:
140
+ insert_x = self.mod - msbm - 1
141
+ insert = [step * insert_x, 0]
142
+ size = [step * (msbm - lsbm + 1), self.opt.vspace/2]
143
+ blanks.add(self.element.rect(insert=insert, size=size, style=style))
144
+ if e.get('attr') is not None:
145
+ for attr in self.get_attrs(e, step, lsbm, msbm):
146
+ for a in attr:
147
+ attrs.add(a)
148
+
149
+ g = self.container.g()
150
+ g.add(blanks)
151
+ g.add(bits)
152
+ g.add(names)
153
+ g.add(attrs)
154
+ return g
155
+
156
+ def labels(self, desc):
157
+ g = self.container.g(text_anchor='middle')
158
+ g.add(self.labelArr(desc))
159
+ return g
160
+
161
+ def cage(self, desc):
162
+ hspace = self.opt.hspace
163
+ vspace = self.opt.vspace
164
+ mod = self.mod
165
+
166
+ g = self.container.g(stroke='black', stroke_width=1, stroke_linecap='round', transform="translate(0,{})".format(vspace/4))
167
+
168
+ g.add(self.hline(hspace));
169
+ if self.opt.vflip:
170
+ g.add(self.vline(0));
171
+ else:
172
+ g.add(self.vline(vspace / 2));
173
+ g.add(self.hline(hspace, 0, vspace / 2));
174
+
175
+ i = self.index * mod
176
+ if self.opt.vflip:
177
+ r = range(0, mod + 1)
178
+ else:
179
+ r = range(mod, 0, -1)
180
+ for j in r:
181
+ if j == mod or any([(e["lsb"] == i) for e in desc]):
182
+ g.add(self.vline((vspace / 2), j * (hspace / mod)));
183
+ else:
184
+ g.add(self.vline((vspace / 16), j * (hspace / mod)));
185
+ g.add(self.vline((vspace / 16), j * (hspace / mod), vspace * 7 / 16));
186
+ i += 1
187
+
188
+ return g
189
+
190
+ def lane(self, desc):
191
+ x = 4.5
192
+ if self.opt.hflip:
193
+ i = self.index
194
+ else:
195
+ i = self.opt.lanes-self.index-1
196
+ y = i * self.opt.vspace + 0.5
197
+ g = self.container.g(transform = "translate({},{})".format(x, y),
198
+ text_anchor = "middle",
199
+ font_size = self.opt.fontsize,
200
+ font_family = self.opt.fontfamily,
201
+ font_weight = self.opt.fontweight)
202
+
203
+ g.add(self.cage(desc))
204
+ g.add(self.labels(desc))
205
+ return g
206
+
207
+ def get_max_attrs(self, desc):
208
+ max_count = 0
209
+ for e in desc:
210
+ if 'attr' in e:
211
+ if isinstance(e['attr'], list):
212
+ max_count = max(max_count, len(e['attr']))
213
+ else:
214
+ max_count = max(max_count, 1)
215
+ return max_count
216
+
217
+ def render(self, desc, opt = Options()):
218
+ self.opt = opt
219
+
220
+ # Compute extra per-lane space needed if there are more than one attr
221
+ # for any field. This spaces all lanes uniformly, matching the lane
222
+ # with the most attr's.
223
+ extra_attrs = 0
224
+ max_attrs = self.get_max_attrs(desc)
225
+ if max_attrs > 1:
226
+ extra_attrs = max_attrs - 1
227
+ self.extra_attr_space = extra_attrs * 16
228
+
229
+ width = opt.hspace + 9
230
+ height = (opt.vspace + self.extra_attr_space) * opt.lanes + 5
231
+
232
+ template = svgwrite.Drawing()
233
+ template["width"] = width
234
+ template["height"] = height
235
+ template["class"] = "WaveDrom"
236
+ template.viewbox(0, 0, width, height)
237
+
238
+ lsb = 0
239
+ self.mod = int(opt.bits / opt.lanes)
240
+
241
+ for e in desc:
242
+ e["lsb"] = lsb
243
+ e["lsbm"] = lsb % self.mod
244
+ lsb += e['bits']
245
+ e['msb'] = lsb - 1
246
+ e['msbm'] = e['msb'] % self.mod
247
+
248
+ for i in range(opt.lanes):
249
+ self.index = i
250
+ template.add(self.lane(desc))
251
+
252
+ return template
253
+
254
+ def renderJson(self, source):
255
+ opt = Options()
256
+ if source.get("config"):
257
+ opt = Options(**source['config'])
258
+ if source.get("reg"):
259
+ return self.render(source['reg'], opt)