Matt300209 commited on
Commit
baa5c6b
·
verified ·
1 Parent(s): 7c5eac4

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. venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/INSTALLER +1 -0
  2. venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/METADATA +10 -0
  3. venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/RECORD +124 -0
  4. venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/REQUESTED +0 -0
  5. venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/WHEEL +5 -0
  6. venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/entry_points.txt +2 -0
  7. venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/top_level.txt +1 -0
  8. venv/lib/python3.10/site-packages/colorama/__init__.py +7 -0
  9. venv/lib/python3.10/site-packages/colorama/__pycache__/__init__.cpython-310.pyc +0 -0
  10. venv/lib/python3.10/site-packages/colorama/__pycache__/ansi.cpython-310.pyc +0 -0
  11. venv/lib/python3.10/site-packages/colorama/__pycache__/ansitowin32.cpython-310.pyc +0 -0
  12. venv/lib/python3.10/site-packages/colorama/__pycache__/initialise.cpython-310.pyc +0 -0
  13. venv/lib/python3.10/site-packages/colorama/__pycache__/win32.cpython-310.pyc +0 -0
  14. venv/lib/python3.10/site-packages/colorama/__pycache__/winterm.cpython-310.pyc +0 -0
  15. venv/lib/python3.10/site-packages/colorama/ansi.py +102 -0
  16. venv/lib/python3.10/site-packages/colorama/ansitowin32.py +277 -0
  17. venv/lib/python3.10/site-packages/colorama/initialise.py +121 -0
  18. venv/lib/python3.10/site-packages/colorama/tests/__init__.py +1 -0
  19. venv/lib/python3.10/site-packages/colorama/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  20. venv/lib/python3.10/site-packages/colorama/tests/__pycache__/ansi_test.cpython-310.pyc +0 -0
  21. venv/lib/python3.10/site-packages/colorama/tests/__pycache__/ansitowin32_test.cpython-310.pyc +0 -0
  22. venv/lib/python3.10/site-packages/colorama/tests/__pycache__/initialise_test.cpython-310.pyc +0 -0
  23. venv/lib/python3.10/site-packages/colorama/tests/__pycache__/isatty_test.cpython-310.pyc +0 -0
  24. venv/lib/python3.10/site-packages/colorama/tests/__pycache__/utils.cpython-310.pyc +0 -0
  25. venv/lib/python3.10/site-packages/colorama/tests/__pycache__/winterm_test.cpython-310.pyc +0 -0
  26. venv/lib/python3.10/site-packages/colorama/tests/ansi_test.py +76 -0
  27. venv/lib/python3.10/site-packages/colorama/tests/ansitowin32_test.py +294 -0
  28. venv/lib/python3.10/site-packages/colorama/tests/initialise_test.py +189 -0
  29. venv/lib/python3.10/site-packages/colorama/tests/isatty_test.py +57 -0
  30. venv/lib/python3.10/site-packages/colorama/tests/utils.py +49 -0
  31. venv/lib/python3.10/site-packages/colorama/tests/winterm_test.py +131 -0
  32. venv/lib/python3.10/site-packages/colorama/win32.py +180 -0
  33. venv/lib/python3.10/site-packages/colorama/winterm.py +195 -0
  34. venv/lib/python3.10/site-packages/networkx/__pycache__/__init__.cpython-310.pyc +0 -0
  35. venv/lib/python3.10/site-packages/networkx/__pycache__/conftest.cpython-310.pyc +0 -0
  36. venv/lib/python3.10/site-packages/networkx/__pycache__/convert.cpython-310.pyc +0 -0
  37. venv/lib/python3.10/site-packages/networkx/__pycache__/convert_matrix.cpython-310.pyc +0 -0
  38. venv/lib/python3.10/site-packages/networkx/__pycache__/exception.cpython-310.pyc +0 -0
  39. venv/lib/python3.10/site-packages/networkx/__pycache__/lazy_imports.cpython-310.pyc +0 -0
  40. venv/lib/python3.10/site-packages/networkx/__pycache__/relabel.cpython-310.pyc +0 -0
  41. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/__init__.cpython-310.pyc +0 -0
  42. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/atlas.cpython-310.pyc +0 -0
  43. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/classic.cpython-310.pyc +0 -0
  44. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/cographs.cpython-310.pyc +0 -0
  45. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/community.cpython-310.pyc +0 -0
  46. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/degree_seq.cpython-310.pyc +0 -0
  47. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/directed.cpython-310.pyc +0 -0
  48. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/duplication.cpython-310.pyc +0 -0
  49. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/ego.cpython-310.pyc +0 -0
  50. venv/lib/python3.10/site-packages/networkx/generators/__pycache__/expanders.cpython-310.pyc +0 -0
venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/METADATA ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: antlr4-python3-runtime
3
+ Version: 4.11.0
4
+ Summary: ANTLR 4.11.0 runtime for Python 3
5
+ Home-page: http://www.antlr.org
6
+ Author: Eric Vergnaud, Terence Parr, Sam Harwell
7
+ Author-email: eric.vergnaud@wanadoo.fr
8
+ License: BSD
9
+ Requires-Dist: typing ; python_version < "3.5"
10
+
venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/RECORD ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ../../../bin/pygrun,sha256=onGX__OGGVVyYuQrGa9MNnId430aRkAkUc0pLkke2Y0,283
2
+ antlr4/BufferedTokenStream.py,sha256=_BwmzOH1TO6yL2yC_ZaUzkghq8wzc0UPHfI3UpnZUwM,10780
3
+ antlr4/CommonTokenFactory.py,sha256=Tv16zg_pWD1Dv3IphsxFu8nwWdLeXYcqJ8CC5yHwjH8,2110
4
+ antlr4/CommonTokenStream.py,sha256=NNJHXwRg2_Zn46ZhJyDxZtvZzsPWhb6JjXa7BjM45eg,2770
5
+ antlr4/FileStream.py,sha256=-ZR_-jl_If9IIBYLINIwlQrlTSmu5k1VUKDc3ie7WR4,868
6
+ antlr4/InputStream.py,sha256=sggjE2jEGvSgQmxFvqeeuT3aOVgcH5tS7mMybW8wKS4,2334
7
+ antlr4/IntervalSet.py,sha256=Cd0WKhd_kYbiLYKkDNncgSM19GAuS7OaTOC4-5Yubs4,5965
8
+ antlr4/LL1Analyzer.py,sha256=oJBvO7_S8cAlb_D4qWNxd2IlK0qP4ka-oeoDxx16CZ4,7752
9
+ antlr4/Lexer.py,sha256=C72hqayfkympxb46AcSnhPD9kVZ0quWgboGxa6gcIcg,11542
10
+ antlr4/ListTokenSource.py,sha256=IffLMo7YQnD_CjKryrrgNWSk0q5QSYd7puZyyUk7vOk,5356
11
+ antlr4/Parser.py,sha256=F2Q25z0-__KHfa354KQhDu3ZOVzLFfag3s2ixJ4dl_o,22883
12
+ antlr4/ParserInterpreter.py,sha256=-QU9kn4x3WCQ-LSA99R231HoicTqakiHZ5KM72l-hIo,7206
13
+ antlr4/ParserRuleContext.py,sha256=wHAVdOxMAO5jkUqloTXVzn_xYnJhiHbvvuhZpth0ZF8,6762
14
+ antlr4/PredictionContext.py,sha256=cb4KI6EGpS7sRzJ8UvPEkxphINZuWhyiZ95752g3prI,22977
15
+ antlr4/Recognizer.py,sha256=tMXl-YTlUqLYXfYTfQy7fUX9V5KKXEO96WBTdAb3dgk,5384
16
+ antlr4/RuleContext.py,sha256=GiviRv2k_al1IBgdJOEEoD0ohJaVd-_h5T_CPG_Bsmg,8099
17
+ antlr4/StdinStream.py,sha256=MMSH4zN8T6i_nu-3_TlN-3E4nPM4b5KgK4GT6n_FUQA,303
18
+ antlr4/Token.py,sha256=OtWCab4Ut52X_nLLAA-8x4Zl6xaF6TEN-0033uaoaEo,5206
19
+ antlr4/TokenStreamRewriter.py,sha256=cuErQTrXwC_0kqVv3MsTWGZSm-E1Vy1yzA-3SOhKd_s,10324
20
+ antlr4/Utils.py,sha256=Oyg8CJCRL1TrF_QSB_LLlVdWOB4loVcKOgFNT-icO7c,931
21
+ antlr4/__init__.py,sha256=g8UGpflnlMWcAyLtihejzrgAP1Uo3b9GhwfI8QnZjtw,1125
22
+ antlr4/__pycache__/BufferedTokenStream.cpython-310.pyc,,
23
+ antlr4/__pycache__/CommonTokenFactory.cpython-310.pyc,,
24
+ antlr4/__pycache__/CommonTokenStream.cpython-310.pyc,,
25
+ antlr4/__pycache__/FileStream.cpython-310.pyc,,
26
+ antlr4/__pycache__/InputStream.cpython-310.pyc,,
27
+ antlr4/__pycache__/IntervalSet.cpython-310.pyc,,
28
+ antlr4/__pycache__/LL1Analyzer.cpython-310.pyc,,
29
+ antlr4/__pycache__/Lexer.cpython-310.pyc,,
30
+ antlr4/__pycache__/ListTokenSource.cpython-310.pyc,,
31
+ antlr4/__pycache__/Parser.cpython-310.pyc,,
32
+ antlr4/__pycache__/ParserInterpreter.cpython-310.pyc,,
33
+ antlr4/__pycache__/ParserRuleContext.cpython-310.pyc,,
34
+ antlr4/__pycache__/PredictionContext.cpython-310.pyc,,
35
+ antlr4/__pycache__/Recognizer.cpython-310.pyc,,
36
+ antlr4/__pycache__/RuleContext.cpython-310.pyc,,
37
+ antlr4/__pycache__/StdinStream.cpython-310.pyc,,
38
+ antlr4/__pycache__/Token.cpython-310.pyc,,
39
+ antlr4/__pycache__/TokenStreamRewriter.cpython-310.pyc,,
40
+ antlr4/__pycache__/Utils.cpython-310.pyc,,
41
+ antlr4/__pycache__/__init__.cpython-310.pyc,,
42
+ antlr4/__pycache__/_pygrun.cpython-310.pyc,,
43
+ antlr4/_pygrun.py,sha256=0iyrI1ZYoDznH_IZdtqtazTNuyZSvqLz2D4WBnbVNbI,6289
44
+ antlr4/atn/ATN.py,sha256=LYE8kT-D8FpUd5fpOtyOLqvXLFkUSa83TVFowhCWAiY,5789
45
+ antlr4/atn/ATNConfig.py,sha256=tNdIC6_GrxXllHBx3npAWyDh6KrohLZDV_XyPrydRMY,6565
46
+ antlr4/atn/ATNConfigSet.py,sha256=qRzVsBeMqk2txjG3DrGptwF6Vb2hHC5w3umkSL0GNJw,8312
47
+ antlr4/atn/ATNDeserializationOptions.py,sha256=lUV_bGW6mxj7t20esda5Yv-X9m-U_x1-0xaLifhXIPo,1010
48
+ antlr4/atn/ATNDeserializer.py,sha256=3VDf5ToU5cVwq1j-nCsMhhVQVu2SzrjGfdhZcWriHZ0,18958
49
+ antlr4/atn/ATNSimulator.py,sha256=mDc-G3GF3kSeqpfGDabUOLJ0WLVTqibxZlkvXQYmBRk,2298
50
+ antlr4/atn/ATNState.py,sha256=NbndISWUwFDF_vuBfbTiZZ8GPHoQa6UXdqbD-yjJE7c,7663
51
+ antlr4/atn/ATNType.py,sha256=xgv8AMVU7tc07U73_hRTm1AiZ7MvGhoaP5fTiOrrCGg,422
52
+ antlr4/atn/LexerATNSimulator.py,sha256=kYXRwUvHptSRU8T_K9pSrGlCk9YypWeHlAcjgry1VVo,25465
53
+ antlr4/atn/LexerAction.py,sha256=KUeJwKekBch0m1poSPskHIh-15dcKAG4lR7zlq98tzc,10014
54
+ antlr4/atn/LexerActionExecutor.py,sha256=7rlg17THcwLsuTmh7NsLrTbRH4DTrm8qIdW9_235CEc,6420
55
+ antlr4/atn/ParserATNSimulator.py,sha256=IKCzsDLcznROSVojU-daAygKr3svl0DmK5DhkUllASY,80365
56
+ antlr4/atn/PredictionMode.py,sha256=i8B7MULA7v-qbXeCY_xp6sgi21kHM6kybqIrG6rSrro,22486
57
+ antlr4/atn/SemanticContext.py,sha256=5MB8uOBfsQEIPZMN6yw_meokK_uxUWI6ZjjpT1Agn7E,10561
58
+ antlr4/atn/Transition.py,sha256=ZAsEFpa5I_n-zxD6U-DauM5_33jFK65x3PWu6-NW0RA,8762
59
+ antlr4/atn/__init__.py,sha256=gsnQdtTH8IUgCiVUpQfzhxx2pFRvksW76SjwIk3fYSk,28
60
+ antlr4/atn/__pycache__/ATN.cpython-310.pyc,,
61
+ antlr4/atn/__pycache__/ATNConfig.cpython-310.pyc,,
62
+ antlr4/atn/__pycache__/ATNConfigSet.cpython-310.pyc,,
63
+ antlr4/atn/__pycache__/ATNDeserializationOptions.cpython-310.pyc,,
64
+ antlr4/atn/__pycache__/ATNDeserializer.cpython-310.pyc,,
65
+ antlr4/atn/__pycache__/ATNSimulator.cpython-310.pyc,,
66
+ antlr4/atn/__pycache__/ATNState.cpython-310.pyc,,
67
+ antlr4/atn/__pycache__/ATNType.cpython-310.pyc,,
68
+ antlr4/atn/__pycache__/LexerATNSimulator.cpython-310.pyc,,
69
+ antlr4/atn/__pycache__/LexerAction.cpython-310.pyc,,
70
+ antlr4/atn/__pycache__/LexerActionExecutor.cpython-310.pyc,,
71
+ antlr4/atn/__pycache__/ParserATNSimulator.cpython-310.pyc,,
72
+ antlr4/atn/__pycache__/PredictionMode.cpython-310.pyc,,
73
+ antlr4/atn/__pycache__/SemanticContext.cpython-310.pyc,,
74
+ antlr4/atn/__pycache__/Transition.cpython-310.pyc,,
75
+ antlr4/atn/__pycache__/__init__.cpython-310.pyc,,
76
+ antlr4/dfa/DFA.py,sha256=weIh0uaRfakP12mFvHo7U0tqO3GONV3-nHFkc2xk-ZE,5388
77
+ antlr4/dfa/DFASerializer.py,sha256=1st_HO85yXLYy7gInTEnkztgA6am4CT-yReh-mazp9E,2518
78
+ antlr4/dfa/DFAState.py,sha256=R7JwKf0GtAEs9J_MD_Y0WKcuzdt0BVX1sow-uv9yFYc,5583
79
+ antlr4/dfa/__init__.py,sha256=gsnQdtTH8IUgCiVUpQfzhxx2pFRvksW76SjwIk3fYSk,28
80
+ antlr4/dfa/__pycache__/DFA.cpython-310.pyc,,
81
+ antlr4/dfa/__pycache__/DFASerializer.cpython-310.pyc,,
82
+ antlr4/dfa/__pycache__/DFAState.cpython-310.pyc,,
83
+ antlr4/dfa/__pycache__/__init__.cpython-310.pyc,,
84
+ antlr4/error/DiagnosticErrorListener.py,sha256=EwS2D_Ox6CmvCa16NPJ9ud4QYPHmlPXt6-Wdn1h5Kg8,4430
85
+ antlr4/error/ErrorListener.py,sha256=yP_MDguol4Cj0_pEPyNzeH3v4ZvUjW5iwDjhYTVAHbE,2722
86
+ antlr4/error/ErrorStrategy.py,sha256=0mhzFL57ZVnjKkGrtadta93Zm3NXdF-HW10DVD07VXs,30391
87
+ antlr4/error/Errors.py,sha256=hlKngclBfXdkDiAymhYsvh2OCXlvmHM2kTl_A1vgp-w,6759
88
+ antlr4/error/__init__.py,sha256=gsnQdtTH8IUgCiVUpQfzhxx2pFRvksW76SjwIk3fYSk,28
89
+ antlr4/error/__pycache__/DiagnosticErrorListener.cpython-310.pyc,,
90
+ antlr4/error/__pycache__/ErrorListener.cpython-310.pyc,,
91
+ antlr4/error/__pycache__/ErrorStrategy.cpython-310.pyc,,
92
+ antlr4/error/__pycache__/Errors.cpython-310.pyc,,
93
+ antlr4/error/__pycache__/__init__.cpython-310.pyc,,
94
+ antlr4/tree/Chunk.py,sha256=oCIZjolLq9xkxtVDROEDxfUGgndcEnsDW0eUmLM7Gpk,695
95
+ antlr4/tree/ParseTreeMatch.py,sha256=Dc6GVWSUqoIAFXUaUZqUwCUlZfTcgUbGLGzNf6QxQvE,4485
96
+ antlr4/tree/ParseTreePattern.py,sha256=rGVYxhs9wYLNoR44sjdiNwXROkooJLwoPJAOxn8K4K8,2835
97
+ antlr4/tree/ParseTreePatternMatcher.py,sha256=HtE9yi1Urr2QPLGLJDBvr0lxv6bjuj9CHl-4clahSe8,16388
98
+ antlr4/tree/RuleTagToken.py,sha256=n4zXcmrrfsGyl91pj5ZYcc_CeKMhPrvYkUdppgMBpbY,2022
99
+ antlr4/tree/TokenTagToken.py,sha256=S3o3DJhfzL5kpClxsKyI-Il-xvuuZQiBAIsLCKFjRHo,1576
100
+ antlr4/tree/Tree.py,sha256=ZI7U_5IxBLm_IrnfJOtb12BCPIWyzfeZtLnhHKVVZIw,5572
101
+ antlr4/tree/Trees.py,sha256=JtQ7cYWmKwI9TIBP6y9XIgjlNS4mYjv3ARwOfwWc5Vg,3968
102
+ antlr4/tree/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
+ antlr4/tree/__pycache__/Chunk.cpython-310.pyc,,
104
+ antlr4/tree/__pycache__/ParseTreeMatch.cpython-310.pyc,,
105
+ antlr4/tree/__pycache__/ParseTreePattern.cpython-310.pyc,,
106
+ antlr4/tree/__pycache__/ParseTreePatternMatcher.cpython-310.pyc,,
107
+ antlr4/tree/__pycache__/RuleTagToken.cpython-310.pyc,,
108
+ antlr4/tree/__pycache__/TokenTagToken.cpython-310.pyc,,
109
+ antlr4/tree/__pycache__/Tree.cpython-310.pyc,,
110
+ antlr4/tree/__pycache__/Trees.cpython-310.pyc,,
111
+ antlr4/tree/__pycache__/__init__.cpython-310.pyc,,
112
+ antlr4/xpath/XPath.py,sha256=qoihVNLvdI5AFi_M3YWoiBFwGO0-x68pCSNOfHgKQbI,9661
113
+ antlr4/xpath/XPathLexer.py,sha256=Dh-4DSobLUERz6iESERcUBtQaUaYVPwi3C74bWZ_Bzs,3446
114
+ antlr4/xpath/__init__.py,sha256=gsnQdtTH8IUgCiVUpQfzhxx2pFRvksW76SjwIk3fYSk,28
115
+ antlr4/xpath/__pycache__/XPath.cpython-310.pyc,,
116
+ antlr4/xpath/__pycache__/XPathLexer.cpython-310.pyc,,
117
+ antlr4/xpath/__pycache__/__init__.cpython-310.pyc,,
118
+ antlr4_python3_runtime-4.11.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
119
+ antlr4_python3_runtime-4.11.0.dist-info/METADATA,sha256=Ndproapb7NxiRP-ltT13tUk85hpHBKt-QKAOO_Q3wzM,291
120
+ antlr4_python3_runtime-4.11.0.dist-info/RECORD,,
121
+ antlr4_python3_runtime-4.11.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
122
+ antlr4_python3_runtime-4.11.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
123
+ antlr4_python3_runtime-4.11.0.dist-info/entry_points.txt,sha256=M2tWLwWgEVV1Djr6ugO3b3902YJIpTDHoM8BFMAt4P4,47
124
+ antlr4_python3_runtime-4.11.0.dist-info/top_level.txt,sha256=OsoZsh9bb30wgXb2zBUjdDwYg46MfV-RVZA6Pk8pcB0,7
venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/REQUESTED ADDED
File without changes
venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.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
+
venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/entry_points.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [console_scripts]
2
+ pygrun = antlr4._pygrun:main
venv/lib/python3.10/site-packages/antlr4_python3_runtime-4.11.0.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ antlr4
venv/lib/python3.10/site-packages/colorama/__init__.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ from .initialise import init, deinit, reinit, colorama_text, just_fix_windows_console
3
+ from .ansi import Fore, Back, Style, Cursor
4
+ from .ansitowin32 import AnsiToWin32
5
+
6
+ __version__ = '0.4.6'
7
+
venv/lib/python3.10/site-packages/colorama/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (530 Bytes). View file
 
venv/lib/python3.10/site-packages/colorama/__pycache__/ansi.cpython-310.pyc ADDED
Binary file (3.06 kB). View file
 
venv/lib/python3.10/site-packages/colorama/__pycache__/ansitowin32.cpython-310.pyc ADDED
Binary file (8.57 kB). View file
 
venv/lib/python3.10/site-packages/colorama/__pycache__/initialise.cpython-310.pyc ADDED
Binary file (2.31 kB). View file
 
venv/lib/python3.10/site-packages/colorama/__pycache__/win32.cpython-310.pyc ADDED
Binary file (4.52 kB). View file
 
venv/lib/python3.10/site-packages/colorama/__pycache__/winterm.cpython-310.pyc ADDED
Binary file (5.22 kB). View file
 
venv/lib/python3.10/site-packages/colorama/ansi.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ '''
3
+ This module generates ANSI character codes to printing colors to terminals.
4
+ See: http://en.wikipedia.org/wiki/ANSI_escape_code
5
+ '''
6
+
7
+ CSI = '\033['
8
+ OSC = '\033]'
9
+ BEL = '\a'
10
+
11
+
12
+ def code_to_chars(code):
13
+ return CSI + str(code) + 'm'
14
+
15
+ def set_title(title):
16
+ return OSC + '2;' + title + BEL
17
+
18
+ def clear_screen(mode=2):
19
+ return CSI + str(mode) + 'J'
20
+
21
+ def clear_line(mode=2):
22
+ return CSI + str(mode) + 'K'
23
+
24
+
25
+ class AnsiCodes(object):
26
+ def __init__(self):
27
+ # the subclasses declare class attributes which are numbers.
28
+ # Upon instantiation we define instance attributes, which are the same
29
+ # as the class attributes but wrapped with the ANSI escape sequence
30
+ for name in dir(self):
31
+ if not name.startswith('_'):
32
+ value = getattr(self, name)
33
+ setattr(self, name, code_to_chars(value))
34
+
35
+
36
+ class AnsiCursor(object):
37
+ def UP(self, n=1):
38
+ return CSI + str(n) + 'A'
39
+ def DOWN(self, n=1):
40
+ return CSI + str(n) + 'B'
41
+ def FORWARD(self, n=1):
42
+ return CSI + str(n) + 'C'
43
+ def BACK(self, n=1):
44
+ return CSI + str(n) + 'D'
45
+ def POS(self, x=1, y=1):
46
+ return CSI + str(y) + ';' + str(x) + 'H'
47
+
48
+
49
+ class AnsiFore(AnsiCodes):
50
+ BLACK = 30
51
+ RED = 31
52
+ GREEN = 32
53
+ YELLOW = 33
54
+ BLUE = 34
55
+ MAGENTA = 35
56
+ CYAN = 36
57
+ WHITE = 37
58
+ RESET = 39
59
+
60
+ # These are fairly well supported, but not part of the standard.
61
+ LIGHTBLACK_EX = 90
62
+ LIGHTRED_EX = 91
63
+ LIGHTGREEN_EX = 92
64
+ LIGHTYELLOW_EX = 93
65
+ LIGHTBLUE_EX = 94
66
+ LIGHTMAGENTA_EX = 95
67
+ LIGHTCYAN_EX = 96
68
+ LIGHTWHITE_EX = 97
69
+
70
+
71
+ class AnsiBack(AnsiCodes):
72
+ BLACK = 40
73
+ RED = 41
74
+ GREEN = 42
75
+ YELLOW = 43
76
+ BLUE = 44
77
+ MAGENTA = 45
78
+ CYAN = 46
79
+ WHITE = 47
80
+ RESET = 49
81
+
82
+ # These are fairly well supported, but not part of the standard.
83
+ LIGHTBLACK_EX = 100
84
+ LIGHTRED_EX = 101
85
+ LIGHTGREEN_EX = 102
86
+ LIGHTYELLOW_EX = 103
87
+ LIGHTBLUE_EX = 104
88
+ LIGHTMAGENTA_EX = 105
89
+ LIGHTCYAN_EX = 106
90
+ LIGHTWHITE_EX = 107
91
+
92
+
93
+ class AnsiStyle(AnsiCodes):
94
+ BRIGHT = 1
95
+ DIM = 2
96
+ NORMAL = 22
97
+ RESET_ALL = 0
98
+
99
+ Fore = AnsiFore()
100
+ Back = AnsiBack()
101
+ Style = AnsiStyle()
102
+ Cursor = AnsiCursor()
venv/lib/python3.10/site-packages/colorama/ansitowin32.py ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ import re
3
+ import sys
4
+ import os
5
+
6
+ from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style, BEL
7
+ from .winterm import enable_vt_processing, WinTerm, WinColor, WinStyle
8
+ from .win32 import windll, winapi_test
9
+
10
+
11
+ winterm = None
12
+ if windll is not None:
13
+ winterm = WinTerm()
14
+
15
+
16
+ class StreamWrapper(object):
17
+ '''
18
+ Wraps a stream (such as stdout), acting as a transparent proxy for all
19
+ attribute access apart from method 'write()', which is delegated to our
20
+ Converter instance.
21
+ '''
22
+ def __init__(self, wrapped, converter):
23
+ # double-underscore everything to prevent clashes with names of
24
+ # attributes on the wrapped stream object.
25
+ self.__wrapped = wrapped
26
+ self.__convertor = converter
27
+
28
+ def __getattr__(self, name):
29
+ return getattr(self.__wrapped, name)
30
+
31
+ def __enter__(self, *args, **kwargs):
32
+ # special method lookup bypasses __getattr__/__getattribute__, see
33
+ # https://stackoverflow.com/questions/12632894/why-doesnt-getattr-work-with-exit
34
+ # thus, contextlib magic methods are not proxied via __getattr__
35
+ return self.__wrapped.__enter__(*args, **kwargs)
36
+
37
+ def __exit__(self, *args, **kwargs):
38
+ return self.__wrapped.__exit__(*args, **kwargs)
39
+
40
+ def __setstate__(self, state):
41
+ self.__dict__ = state
42
+
43
+ def __getstate__(self):
44
+ return self.__dict__
45
+
46
+ def write(self, text):
47
+ self.__convertor.write(text)
48
+
49
+ def isatty(self):
50
+ stream = self.__wrapped
51
+ if 'PYCHARM_HOSTED' in os.environ:
52
+ if stream is not None and (stream is sys.__stdout__ or stream is sys.__stderr__):
53
+ return True
54
+ try:
55
+ stream_isatty = stream.isatty
56
+ except AttributeError:
57
+ return False
58
+ else:
59
+ return stream_isatty()
60
+
61
+ @property
62
+ def closed(self):
63
+ stream = self.__wrapped
64
+ try:
65
+ return stream.closed
66
+ # AttributeError in the case that the stream doesn't support being closed
67
+ # ValueError for the case that the stream has already been detached when atexit runs
68
+ except (AttributeError, ValueError):
69
+ return True
70
+
71
+
72
+ class AnsiToWin32(object):
73
+ '''
74
+ Implements a 'write()' method which, on Windows, will strip ANSI character
75
+ sequences from the text, and if outputting to a tty, will convert them into
76
+ win32 function calls.
77
+ '''
78
+ ANSI_CSI_RE = re.compile('\001?\033\\[((?:\\d|;)*)([a-zA-Z])\002?') # Control Sequence Introducer
79
+ ANSI_OSC_RE = re.compile('\001?\033\\]([^\a]*)(\a)\002?') # Operating System Command
80
+
81
+ def __init__(self, wrapped, convert=None, strip=None, autoreset=False):
82
+ # The wrapped stream (normally sys.stdout or sys.stderr)
83
+ self.wrapped = wrapped
84
+
85
+ # should we reset colors to defaults after every .write()
86
+ self.autoreset = autoreset
87
+
88
+ # create the proxy wrapping our output stream
89
+ self.stream = StreamWrapper(wrapped, self)
90
+
91
+ on_windows = os.name == 'nt'
92
+ # We test if the WinAPI works, because even if we are on Windows
93
+ # we may be using a terminal that doesn't support the WinAPI
94
+ # (e.g. Cygwin Terminal). In this case it's up to the terminal
95
+ # to support the ANSI codes.
96
+ conversion_supported = on_windows and winapi_test()
97
+ try:
98
+ fd = wrapped.fileno()
99
+ except Exception:
100
+ fd = -1
101
+ system_has_native_ansi = not on_windows or enable_vt_processing(fd)
102
+ have_tty = not self.stream.closed and self.stream.isatty()
103
+ need_conversion = conversion_supported and not system_has_native_ansi
104
+
105
+ # should we strip ANSI sequences from our output?
106
+ if strip is None:
107
+ strip = need_conversion or not have_tty
108
+ self.strip = strip
109
+
110
+ # should we should convert ANSI sequences into win32 calls?
111
+ if convert is None:
112
+ convert = need_conversion and have_tty
113
+ self.convert = convert
114
+
115
+ # dict of ansi codes to win32 functions and parameters
116
+ self.win32_calls = self.get_win32_calls()
117
+
118
+ # are we wrapping stderr?
119
+ self.on_stderr = self.wrapped is sys.stderr
120
+
121
+ def should_wrap(self):
122
+ '''
123
+ True if this class is actually needed. If false, then the output
124
+ stream will not be affected, nor will win32 calls be issued, so
125
+ wrapping stdout is not actually required. This will generally be
126
+ False on non-Windows platforms, unless optional functionality like
127
+ autoreset has been requested using kwargs to init()
128
+ '''
129
+ return self.convert or self.strip or self.autoreset
130
+
131
+ def get_win32_calls(self):
132
+ if self.convert and winterm:
133
+ return {
134
+ AnsiStyle.RESET_ALL: (winterm.reset_all, ),
135
+ AnsiStyle.BRIGHT: (winterm.style, WinStyle.BRIGHT),
136
+ AnsiStyle.DIM: (winterm.style, WinStyle.NORMAL),
137
+ AnsiStyle.NORMAL: (winterm.style, WinStyle.NORMAL),
138
+ AnsiFore.BLACK: (winterm.fore, WinColor.BLACK),
139
+ AnsiFore.RED: (winterm.fore, WinColor.RED),
140
+ AnsiFore.GREEN: (winterm.fore, WinColor.GREEN),
141
+ AnsiFore.YELLOW: (winterm.fore, WinColor.YELLOW),
142
+ AnsiFore.BLUE: (winterm.fore, WinColor.BLUE),
143
+ AnsiFore.MAGENTA: (winterm.fore, WinColor.MAGENTA),
144
+ AnsiFore.CYAN: (winterm.fore, WinColor.CYAN),
145
+ AnsiFore.WHITE: (winterm.fore, WinColor.GREY),
146
+ AnsiFore.RESET: (winterm.fore, ),
147
+ AnsiFore.LIGHTBLACK_EX: (winterm.fore, WinColor.BLACK, True),
148
+ AnsiFore.LIGHTRED_EX: (winterm.fore, WinColor.RED, True),
149
+ AnsiFore.LIGHTGREEN_EX: (winterm.fore, WinColor.GREEN, True),
150
+ AnsiFore.LIGHTYELLOW_EX: (winterm.fore, WinColor.YELLOW, True),
151
+ AnsiFore.LIGHTBLUE_EX: (winterm.fore, WinColor.BLUE, True),
152
+ AnsiFore.LIGHTMAGENTA_EX: (winterm.fore, WinColor.MAGENTA, True),
153
+ AnsiFore.LIGHTCYAN_EX: (winterm.fore, WinColor.CYAN, True),
154
+ AnsiFore.LIGHTWHITE_EX: (winterm.fore, WinColor.GREY, True),
155
+ AnsiBack.BLACK: (winterm.back, WinColor.BLACK),
156
+ AnsiBack.RED: (winterm.back, WinColor.RED),
157
+ AnsiBack.GREEN: (winterm.back, WinColor.GREEN),
158
+ AnsiBack.YELLOW: (winterm.back, WinColor.YELLOW),
159
+ AnsiBack.BLUE: (winterm.back, WinColor.BLUE),
160
+ AnsiBack.MAGENTA: (winterm.back, WinColor.MAGENTA),
161
+ AnsiBack.CYAN: (winterm.back, WinColor.CYAN),
162
+ AnsiBack.WHITE: (winterm.back, WinColor.GREY),
163
+ AnsiBack.RESET: (winterm.back, ),
164
+ AnsiBack.LIGHTBLACK_EX: (winterm.back, WinColor.BLACK, True),
165
+ AnsiBack.LIGHTRED_EX: (winterm.back, WinColor.RED, True),
166
+ AnsiBack.LIGHTGREEN_EX: (winterm.back, WinColor.GREEN, True),
167
+ AnsiBack.LIGHTYELLOW_EX: (winterm.back, WinColor.YELLOW, True),
168
+ AnsiBack.LIGHTBLUE_EX: (winterm.back, WinColor.BLUE, True),
169
+ AnsiBack.LIGHTMAGENTA_EX: (winterm.back, WinColor.MAGENTA, True),
170
+ AnsiBack.LIGHTCYAN_EX: (winterm.back, WinColor.CYAN, True),
171
+ AnsiBack.LIGHTWHITE_EX: (winterm.back, WinColor.GREY, True),
172
+ }
173
+ return dict()
174
+
175
+ def write(self, text):
176
+ if self.strip or self.convert:
177
+ self.write_and_convert(text)
178
+ else:
179
+ self.wrapped.write(text)
180
+ self.wrapped.flush()
181
+ if self.autoreset:
182
+ self.reset_all()
183
+
184
+
185
+ def reset_all(self):
186
+ if self.convert:
187
+ self.call_win32('m', (0,))
188
+ elif not self.strip and not self.stream.closed:
189
+ self.wrapped.write(Style.RESET_ALL)
190
+
191
+
192
+ def write_and_convert(self, text):
193
+ '''
194
+ Write the given text to our wrapped stream, stripping any ANSI
195
+ sequences from the text, and optionally converting them into win32
196
+ calls.
197
+ '''
198
+ cursor = 0
199
+ text = self.convert_osc(text)
200
+ for match in self.ANSI_CSI_RE.finditer(text):
201
+ start, end = match.span()
202
+ self.write_plain_text(text, cursor, start)
203
+ self.convert_ansi(*match.groups())
204
+ cursor = end
205
+ self.write_plain_text(text, cursor, len(text))
206
+
207
+
208
+ def write_plain_text(self, text, start, end):
209
+ if start < end:
210
+ self.wrapped.write(text[start:end])
211
+ self.wrapped.flush()
212
+
213
+
214
+ def convert_ansi(self, paramstring, command):
215
+ if self.convert:
216
+ params = self.extract_params(command, paramstring)
217
+ self.call_win32(command, params)
218
+
219
+
220
+ def extract_params(self, command, paramstring):
221
+ if command in 'Hf':
222
+ params = tuple(int(p) if len(p) != 0 else 1 for p in paramstring.split(';'))
223
+ while len(params) < 2:
224
+ # defaults:
225
+ params = params + (1,)
226
+ else:
227
+ params = tuple(int(p) for p in paramstring.split(';') if len(p) != 0)
228
+ if len(params) == 0:
229
+ # defaults:
230
+ if command in 'JKm':
231
+ params = (0,)
232
+ elif command in 'ABCD':
233
+ params = (1,)
234
+
235
+ return params
236
+
237
+
238
+ def call_win32(self, command, params):
239
+ if command == 'm':
240
+ for param in params:
241
+ if param in self.win32_calls:
242
+ func_args = self.win32_calls[param]
243
+ func = func_args[0]
244
+ args = func_args[1:]
245
+ kwargs = dict(on_stderr=self.on_stderr)
246
+ func(*args, **kwargs)
247
+ elif command in 'J':
248
+ winterm.erase_screen(params[0], on_stderr=self.on_stderr)
249
+ elif command in 'K':
250
+ winterm.erase_line(params[0], on_stderr=self.on_stderr)
251
+ elif command in 'Hf': # cursor position - absolute
252
+ winterm.set_cursor_position(params, on_stderr=self.on_stderr)
253
+ elif command in 'ABCD': # cursor position - relative
254
+ n = params[0]
255
+ # A - up, B - down, C - forward, D - back
256
+ x, y = {'A': (0, -n), 'B': (0, n), 'C': (n, 0), 'D': (-n, 0)}[command]
257
+ winterm.cursor_adjust(x, y, on_stderr=self.on_stderr)
258
+
259
+
260
+ def convert_osc(self, text):
261
+ for match in self.ANSI_OSC_RE.finditer(text):
262
+ start, end = match.span()
263
+ text = text[:start] + text[end:]
264
+ paramstring, command = match.groups()
265
+ if command == BEL:
266
+ if paramstring.count(";") == 1:
267
+ params = paramstring.split(";")
268
+ # 0 - change title and icon (we will only change title)
269
+ # 1 - change icon (we don't support this)
270
+ # 2 - change title
271
+ if params[0] in '02':
272
+ winterm.set_title(params[1])
273
+ return text
274
+
275
+
276
+ def flush(self):
277
+ self.wrapped.flush()
venv/lib/python3.10/site-packages/colorama/initialise.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ import atexit
3
+ import contextlib
4
+ import sys
5
+
6
+ from .ansitowin32 import AnsiToWin32
7
+
8
+
9
+ def _wipe_internal_state_for_tests():
10
+ global orig_stdout, orig_stderr
11
+ orig_stdout = None
12
+ orig_stderr = None
13
+
14
+ global wrapped_stdout, wrapped_stderr
15
+ wrapped_stdout = None
16
+ wrapped_stderr = None
17
+
18
+ global atexit_done
19
+ atexit_done = False
20
+
21
+ global fixed_windows_console
22
+ fixed_windows_console = False
23
+
24
+ try:
25
+ # no-op if it wasn't registered
26
+ atexit.unregister(reset_all)
27
+ except AttributeError:
28
+ # python 2: no atexit.unregister. Oh well, we did our best.
29
+ pass
30
+
31
+
32
+ def reset_all():
33
+ if AnsiToWin32 is not None: # Issue #74: objects might become None at exit
34
+ AnsiToWin32(orig_stdout).reset_all()
35
+
36
+
37
+ def init(autoreset=False, convert=None, strip=None, wrap=True):
38
+
39
+ if not wrap and any([autoreset, convert, strip]):
40
+ raise ValueError('wrap=False conflicts with any other arg=True')
41
+
42
+ global wrapped_stdout, wrapped_stderr
43
+ global orig_stdout, orig_stderr
44
+
45
+ orig_stdout = sys.stdout
46
+ orig_stderr = sys.stderr
47
+
48
+ if sys.stdout is None:
49
+ wrapped_stdout = None
50
+ else:
51
+ sys.stdout = wrapped_stdout = \
52
+ wrap_stream(orig_stdout, convert, strip, autoreset, wrap)
53
+ if sys.stderr is None:
54
+ wrapped_stderr = None
55
+ else:
56
+ sys.stderr = wrapped_stderr = \
57
+ wrap_stream(orig_stderr, convert, strip, autoreset, wrap)
58
+
59
+ global atexit_done
60
+ if not atexit_done:
61
+ atexit.register(reset_all)
62
+ atexit_done = True
63
+
64
+
65
+ def deinit():
66
+ if orig_stdout is not None:
67
+ sys.stdout = orig_stdout
68
+ if orig_stderr is not None:
69
+ sys.stderr = orig_stderr
70
+
71
+
72
+ def just_fix_windows_console():
73
+ global fixed_windows_console
74
+
75
+ if sys.platform != "win32":
76
+ return
77
+ if fixed_windows_console:
78
+ return
79
+ if wrapped_stdout is not None or wrapped_stderr is not None:
80
+ # Someone already ran init() and it did stuff, so we won't second-guess them
81
+ return
82
+
83
+ # On newer versions of Windows, AnsiToWin32.__init__ will implicitly enable the
84
+ # native ANSI support in the console as a side-effect. We only need to actually
85
+ # replace sys.stdout/stderr if we're in the old-style conversion mode.
86
+ new_stdout = AnsiToWin32(sys.stdout, convert=None, strip=None, autoreset=False)
87
+ if new_stdout.convert:
88
+ sys.stdout = new_stdout
89
+ new_stderr = AnsiToWin32(sys.stderr, convert=None, strip=None, autoreset=False)
90
+ if new_stderr.convert:
91
+ sys.stderr = new_stderr
92
+
93
+ fixed_windows_console = True
94
+
95
+ @contextlib.contextmanager
96
+ def colorama_text(*args, **kwargs):
97
+ init(*args, **kwargs)
98
+ try:
99
+ yield
100
+ finally:
101
+ deinit()
102
+
103
+
104
+ def reinit():
105
+ if wrapped_stdout is not None:
106
+ sys.stdout = wrapped_stdout
107
+ if wrapped_stderr is not None:
108
+ sys.stderr = wrapped_stderr
109
+
110
+
111
+ def wrap_stream(stream, convert, strip, autoreset, wrap):
112
+ if wrap:
113
+ wrapper = AnsiToWin32(stream,
114
+ convert=convert, strip=strip, autoreset=autoreset)
115
+ if wrapper.should_wrap():
116
+ stream = wrapper.stream
117
+ return stream
118
+
119
+
120
+ # Use this for initial setup as well, to reduce code duplication
121
+ _wipe_internal_state_for_tests()
venv/lib/python3.10/site-packages/colorama/tests/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
venv/lib/python3.10/site-packages/colorama/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (250 Bytes). View file
 
venv/lib/python3.10/site-packages/colorama/tests/__pycache__/ansi_test.cpython-310.pyc ADDED
Binary file (2.34 kB). View file
 
venv/lib/python3.10/site-packages/colorama/tests/__pycache__/ansitowin32_test.cpython-310.pyc ADDED
Binary file (11.7 kB). View file
 
venv/lib/python3.10/site-packages/colorama/tests/__pycache__/initialise_test.cpython-310.pyc ADDED
Binary file (6.95 kB). View file
 
venv/lib/python3.10/site-packages/colorama/tests/__pycache__/isatty_test.cpython-310.pyc ADDED
Binary file (2.74 kB). View file
 
venv/lib/python3.10/site-packages/colorama/tests/__pycache__/utils.cpython-310.pyc ADDED
Binary file (1.65 kB). View file
 
venv/lib/python3.10/site-packages/colorama/tests/__pycache__/winterm_test.cpython-310.pyc ADDED
Binary file (3.24 kB). View file
 
venv/lib/python3.10/site-packages/colorama/tests/ansi_test.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ import sys
3
+ from unittest import TestCase, main
4
+
5
+ from ..ansi import Back, Fore, Style
6
+ from ..ansitowin32 import AnsiToWin32
7
+
8
+ stdout_orig = sys.stdout
9
+ stderr_orig = sys.stderr
10
+
11
+
12
+ class AnsiTest(TestCase):
13
+
14
+ def setUp(self):
15
+ # sanity check: stdout should be a file or StringIO object.
16
+ # It will only be AnsiToWin32 if init() has previously wrapped it
17
+ self.assertNotEqual(type(sys.stdout), AnsiToWin32)
18
+ self.assertNotEqual(type(sys.stderr), AnsiToWin32)
19
+
20
+ def tearDown(self):
21
+ sys.stdout = stdout_orig
22
+ sys.stderr = stderr_orig
23
+
24
+
25
+ def testForeAttributes(self):
26
+ self.assertEqual(Fore.BLACK, '\033[30m')
27
+ self.assertEqual(Fore.RED, '\033[31m')
28
+ self.assertEqual(Fore.GREEN, '\033[32m')
29
+ self.assertEqual(Fore.YELLOW, '\033[33m')
30
+ self.assertEqual(Fore.BLUE, '\033[34m')
31
+ self.assertEqual(Fore.MAGENTA, '\033[35m')
32
+ self.assertEqual(Fore.CYAN, '\033[36m')
33
+ self.assertEqual(Fore.WHITE, '\033[37m')
34
+ self.assertEqual(Fore.RESET, '\033[39m')
35
+
36
+ # Check the light, extended versions.
37
+ self.assertEqual(Fore.LIGHTBLACK_EX, '\033[90m')
38
+ self.assertEqual(Fore.LIGHTRED_EX, '\033[91m')
39
+ self.assertEqual(Fore.LIGHTGREEN_EX, '\033[92m')
40
+ self.assertEqual(Fore.LIGHTYELLOW_EX, '\033[93m')
41
+ self.assertEqual(Fore.LIGHTBLUE_EX, '\033[94m')
42
+ self.assertEqual(Fore.LIGHTMAGENTA_EX, '\033[95m')
43
+ self.assertEqual(Fore.LIGHTCYAN_EX, '\033[96m')
44
+ self.assertEqual(Fore.LIGHTWHITE_EX, '\033[97m')
45
+
46
+
47
+ def testBackAttributes(self):
48
+ self.assertEqual(Back.BLACK, '\033[40m')
49
+ self.assertEqual(Back.RED, '\033[41m')
50
+ self.assertEqual(Back.GREEN, '\033[42m')
51
+ self.assertEqual(Back.YELLOW, '\033[43m')
52
+ self.assertEqual(Back.BLUE, '\033[44m')
53
+ self.assertEqual(Back.MAGENTA, '\033[45m')
54
+ self.assertEqual(Back.CYAN, '\033[46m')
55
+ self.assertEqual(Back.WHITE, '\033[47m')
56
+ self.assertEqual(Back.RESET, '\033[49m')
57
+
58
+ # Check the light, extended versions.
59
+ self.assertEqual(Back.LIGHTBLACK_EX, '\033[100m')
60
+ self.assertEqual(Back.LIGHTRED_EX, '\033[101m')
61
+ self.assertEqual(Back.LIGHTGREEN_EX, '\033[102m')
62
+ self.assertEqual(Back.LIGHTYELLOW_EX, '\033[103m')
63
+ self.assertEqual(Back.LIGHTBLUE_EX, '\033[104m')
64
+ self.assertEqual(Back.LIGHTMAGENTA_EX, '\033[105m')
65
+ self.assertEqual(Back.LIGHTCYAN_EX, '\033[106m')
66
+ self.assertEqual(Back.LIGHTWHITE_EX, '\033[107m')
67
+
68
+
69
+ def testStyleAttributes(self):
70
+ self.assertEqual(Style.DIM, '\033[2m')
71
+ self.assertEqual(Style.NORMAL, '\033[22m')
72
+ self.assertEqual(Style.BRIGHT, '\033[1m')
73
+
74
+
75
+ if __name__ == '__main__':
76
+ main()
venv/lib/python3.10/site-packages/colorama/tests/ansitowin32_test.py ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ from io import StringIO, TextIOWrapper
3
+ from unittest import TestCase, main
4
+ try:
5
+ from contextlib import ExitStack
6
+ except ImportError:
7
+ # python 2
8
+ from contextlib2 import ExitStack
9
+
10
+ try:
11
+ from unittest.mock import MagicMock, Mock, patch
12
+ except ImportError:
13
+ from mock import MagicMock, Mock, patch
14
+
15
+ from ..ansitowin32 import AnsiToWin32, StreamWrapper
16
+ from ..win32 import ENABLE_VIRTUAL_TERMINAL_PROCESSING
17
+ from .utils import osname
18
+
19
+
20
+ class StreamWrapperTest(TestCase):
21
+
22
+ def testIsAProxy(self):
23
+ mockStream = Mock()
24
+ wrapper = StreamWrapper(mockStream, None)
25
+ self.assertTrue( wrapper.random_attr is mockStream.random_attr )
26
+
27
+ def testDelegatesWrite(self):
28
+ mockStream = Mock()
29
+ mockConverter = Mock()
30
+ wrapper = StreamWrapper(mockStream, mockConverter)
31
+ wrapper.write('hello')
32
+ self.assertTrue(mockConverter.write.call_args, (('hello',), {}))
33
+
34
+ def testDelegatesContext(self):
35
+ mockConverter = Mock()
36
+ s = StringIO()
37
+ with StreamWrapper(s, mockConverter) as fp:
38
+ fp.write(u'hello')
39
+ self.assertTrue(s.closed)
40
+
41
+ def testProxyNoContextManager(self):
42
+ mockStream = MagicMock()
43
+ mockStream.__enter__.side_effect = AttributeError()
44
+ mockConverter = Mock()
45
+ with self.assertRaises(AttributeError) as excinfo:
46
+ with StreamWrapper(mockStream, mockConverter) as wrapper:
47
+ wrapper.write('hello')
48
+
49
+ def test_closed_shouldnt_raise_on_closed_stream(self):
50
+ stream = StringIO()
51
+ stream.close()
52
+ wrapper = StreamWrapper(stream, None)
53
+ self.assertEqual(wrapper.closed, True)
54
+
55
+ def test_closed_shouldnt_raise_on_detached_stream(self):
56
+ stream = TextIOWrapper(StringIO())
57
+ stream.detach()
58
+ wrapper = StreamWrapper(stream, None)
59
+ self.assertEqual(wrapper.closed, True)
60
+
61
+ class AnsiToWin32Test(TestCase):
62
+
63
+ def testInit(self):
64
+ mockStdout = Mock()
65
+ auto = Mock()
66
+ stream = AnsiToWin32(mockStdout, autoreset=auto)
67
+ self.assertEqual(stream.wrapped, mockStdout)
68
+ self.assertEqual(stream.autoreset, auto)
69
+
70
+ @patch('colorama.ansitowin32.winterm', None)
71
+ @patch('colorama.ansitowin32.winapi_test', lambda *_: True)
72
+ def testStripIsTrueOnWindows(self):
73
+ with osname('nt'):
74
+ mockStdout = Mock()
75
+ stream = AnsiToWin32(mockStdout)
76
+ self.assertTrue(stream.strip)
77
+
78
+ def testStripIsFalseOffWindows(self):
79
+ with osname('posix'):
80
+ mockStdout = Mock(closed=False)
81
+ stream = AnsiToWin32(mockStdout)
82
+ self.assertFalse(stream.strip)
83
+
84
+ def testWriteStripsAnsi(self):
85
+ mockStdout = Mock()
86
+ stream = AnsiToWin32(mockStdout)
87
+ stream.wrapped = Mock()
88
+ stream.write_and_convert = Mock()
89
+ stream.strip = True
90
+
91
+ stream.write('abc')
92
+
93
+ self.assertFalse(stream.wrapped.write.called)
94
+ self.assertEqual(stream.write_and_convert.call_args, (('abc',), {}))
95
+
96
+ def testWriteDoesNotStripAnsi(self):
97
+ mockStdout = Mock()
98
+ stream = AnsiToWin32(mockStdout)
99
+ stream.wrapped = Mock()
100
+ stream.write_and_convert = Mock()
101
+ stream.strip = False
102
+ stream.convert = False
103
+
104
+ stream.write('abc')
105
+
106
+ self.assertFalse(stream.write_and_convert.called)
107
+ self.assertEqual(stream.wrapped.write.call_args, (('abc',), {}))
108
+
109
+ def assert_autoresets(self, convert, autoreset=True):
110
+ stream = AnsiToWin32(Mock())
111
+ stream.convert = convert
112
+ stream.reset_all = Mock()
113
+ stream.autoreset = autoreset
114
+ stream.winterm = Mock()
115
+
116
+ stream.write('abc')
117
+
118
+ self.assertEqual(stream.reset_all.called, autoreset)
119
+
120
+ def testWriteAutoresets(self):
121
+ self.assert_autoresets(convert=True)
122
+ self.assert_autoresets(convert=False)
123
+ self.assert_autoresets(convert=True, autoreset=False)
124
+ self.assert_autoresets(convert=False, autoreset=False)
125
+
126
+ def testWriteAndConvertWritesPlainText(self):
127
+ stream = AnsiToWin32(Mock())
128
+ stream.write_and_convert( 'abc' )
129
+ self.assertEqual( stream.wrapped.write.call_args, (('abc',), {}) )
130
+
131
+ def testWriteAndConvertStripsAllValidAnsi(self):
132
+ stream = AnsiToWin32(Mock())
133
+ stream.call_win32 = Mock()
134
+ data = [
135
+ 'abc\033[mdef',
136
+ 'abc\033[0mdef',
137
+ 'abc\033[2mdef',
138
+ 'abc\033[02mdef',
139
+ 'abc\033[002mdef',
140
+ 'abc\033[40mdef',
141
+ 'abc\033[040mdef',
142
+ 'abc\033[0;1mdef',
143
+ 'abc\033[40;50mdef',
144
+ 'abc\033[50;30;40mdef',
145
+ 'abc\033[Adef',
146
+ 'abc\033[0Gdef',
147
+ 'abc\033[1;20;128Hdef',
148
+ ]
149
+ for datum in data:
150
+ stream.wrapped.write.reset_mock()
151
+ stream.write_and_convert( datum )
152
+ self.assertEqual(
153
+ [args[0] for args in stream.wrapped.write.call_args_list],
154
+ [ ('abc',), ('def',) ]
155
+ )
156
+
157
+ def testWriteAndConvertSkipsEmptySnippets(self):
158
+ stream = AnsiToWin32(Mock())
159
+ stream.call_win32 = Mock()
160
+ stream.write_and_convert( '\033[40m\033[41m' )
161
+ self.assertFalse( stream.wrapped.write.called )
162
+
163
+ def testWriteAndConvertCallsWin32WithParamsAndCommand(self):
164
+ stream = AnsiToWin32(Mock())
165
+ stream.convert = True
166
+ stream.call_win32 = Mock()
167
+ stream.extract_params = Mock(return_value='params')
168
+ data = {
169
+ 'abc\033[adef': ('a', 'params'),
170
+ 'abc\033[;;bdef': ('b', 'params'),
171
+ 'abc\033[0cdef': ('c', 'params'),
172
+ 'abc\033[;;0;;Gdef': ('G', 'params'),
173
+ 'abc\033[1;20;128Hdef': ('H', 'params'),
174
+ }
175
+ for datum, expected in data.items():
176
+ stream.call_win32.reset_mock()
177
+ stream.write_and_convert( datum )
178
+ self.assertEqual( stream.call_win32.call_args[0], expected )
179
+
180
+ def test_reset_all_shouldnt_raise_on_closed_orig_stdout(self):
181
+ stream = StringIO()
182
+ converter = AnsiToWin32(stream)
183
+ stream.close()
184
+
185
+ converter.reset_all()
186
+
187
+ def test_wrap_shouldnt_raise_on_closed_orig_stdout(self):
188
+ stream = StringIO()
189
+ stream.close()
190
+ with \
191
+ patch("colorama.ansitowin32.os.name", "nt"), \
192
+ patch("colorama.ansitowin32.winapi_test", lambda: True):
193
+ converter = AnsiToWin32(stream)
194
+ self.assertTrue(converter.strip)
195
+ self.assertFalse(converter.convert)
196
+
197
+ def test_wrap_shouldnt_raise_on_missing_closed_attr(self):
198
+ with \
199
+ patch("colorama.ansitowin32.os.name", "nt"), \
200
+ patch("colorama.ansitowin32.winapi_test", lambda: True):
201
+ converter = AnsiToWin32(object())
202
+ self.assertTrue(converter.strip)
203
+ self.assertFalse(converter.convert)
204
+
205
+ def testExtractParams(self):
206
+ stream = AnsiToWin32(Mock())
207
+ data = {
208
+ '': (0,),
209
+ ';;': (0,),
210
+ '2': (2,),
211
+ ';;002;;': (2,),
212
+ '0;1': (0, 1),
213
+ ';;003;;456;;': (3, 456),
214
+ '11;22;33;44;55': (11, 22, 33, 44, 55),
215
+ }
216
+ for datum, expected in data.items():
217
+ self.assertEqual(stream.extract_params('m', datum), expected)
218
+
219
+ def testCallWin32UsesLookup(self):
220
+ listener = Mock()
221
+ stream = AnsiToWin32(listener)
222
+ stream.win32_calls = {
223
+ 1: (lambda *_, **__: listener(11),),
224
+ 2: (lambda *_, **__: listener(22),),
225
+ 3: (lambda *_, **__: listener(33),),
226
+ }
227
+ stream.call_win32('m', (3, 1, 99, 2))
228
+ self.assertEqual(
229
+ [a[0][0] for a in listener.call_args_list],
230
+ [33, 11, 22] )
231
+
232
+ def test_osc_codes(self):
233
+ mockStdout = Mock()
234
+ stream = AnsiToWin32(mockStdout, convert=True)
235
+ with patch('colorama.ansitowin32.winterm') as winterm:
236
+ data = [
237
+ '\033]0\x07', # missing arguments
238
+ '\033]0;foo\x08', # wrong OSC command
239
+ '\033]0;colorama_test_title\x07', # should work
240
+ '\033]1;colorama_test_title\x07', # wrong set command
241
+ '\033]2;colorama_test_title\x07', # should work
242
+ '\033]' + ';' * 64 + '\x08', # see issue #247
243
+ ]
244
+ for code in data:
245
+ stream.write(code)
246
+ self.assertEqual(winterm.set_title.call_count, 2)
247
+
248
+ def test_native_windows_ansi(self):
249
+ with ExitStack() as stack:
250
+ def p(a, b):
251
+ stack.enter_context(patch(a, b, create=True))
252
+ # Pretend to be on Windows
253
+ p("colorama.ansitowin32.os.name", "nt")
254
+ p("colorama.ansitowin32.winapi_test", lambda: True)
255
+ p("colorama.win32.winapi_test", lambda: True)
256
+ p("colorama.winterm.win32.windll", "non-None")
257
+ p("colorama.winterm.get_osfhandle", lambda _: 1234)
258
+
259
+ # Pretend that our mock stream has native ANSI support
260
+ p(
261
+ "colorama.winterm.win32.GetConsoleMode",
262
+ lambda _: ENABLE_VIRTUAL_TERMINAL_PROCESSING,
263
+ )
264
+ SetConsoleMode = Mock()
265
+ p("colorama.winterm.win32.SetConsoleMode", SetConsoleMode)
266
+
267
+ stdout = Mock()
268
+ stdout.closed = False
269
+ stdout.isatty.return_value = True
270
+ stdout.fileno.return_value = 1
271
+
272
+ # Our fake console says it has native vt support, so AnsiToWin32 should
273
+ # enable that support and do nothing else.
274
+ stream = AnsiToWin32(stdout)
275
+ SetConsoleMode.assert_called_with(1234, ENABLE_VIRTUAL_TERMINAL_PROCESSING)
276
+ self.assertFalse(stream.strip)
277
+ self.assertFalse(stream.convert)
278
+ self.assertFalse(stream.should_wrap())
279
+
280
+ # Now let's pretend we're on an old Windows console, that doesn't have
281
+ # native ANSI support.
282
+ p("colorama.winterm.win32.GetConsoleMode", lambda _: 0)
283
+ SetConsoleMode = Mock()
284
+ p("colorama.winterm.win32.SetConsoleMode", SetConsoleMode)
285
+
286
+ stream = AnsiToWin32(stdout)
287
+ SetConsoleMode.assert_called_with(1234, ENABLE_VIRTUAL_TERMINAL_PROCESSING)
288
+ self.assertTrue(stream.strip)
289
+ self.assertTrue(stream.convert)
290
+ self.assertTrue(stream.should_wrap())
291
+
292
+
293
+ if __name__ == '__main__':
294
+ main()
venv/lib/python3.10/site-packages/colorama/tests/initialise_test.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ import sys
3
+ from unittest import TestCase, main, skipUnless
4
+
5
+ try:
6
+ from unittest.mock import patch, Mock
7
+ except ImportError:
8
+ from mock import patch, Mock
9
+
10
+ from ..ansitowin32 import StreamWrapper
11
+ from ..initialise import init, just_fix_windows_console, _wipe_internal_state_for_tests
12
+ from .utils import osname, replace_by
13
+
14
+ orig_stdout = sys.stdout
15
+ orig_stderr = sys.stderr
16
+
17
+
18
+ class InitTest(TestCase):
19
+
20
+ @skipUnless(sys.stdout.isatty(), "sys.stdout is not a tty")
21
+ def setUp(self):
22
+ # sanity check
23
+ self.assertNotWrapped()
24
+
25
+ def tearDown(self):
26
+ _wipe_internal_state_for_tests()
27
+ sys.stdout = orig_stdout
28
+ sys.stderr = orig_stderr
29
+
30
+ def assertWrapped(self):
31
+ self.assertIsNot(sys.stdout, orig_stdout, 'stdout should be wrapped')
32
+ self.assertIsNot(sys.stderr, orig_stderr, 'stderr should be wrapped')
33
+ self.assertTrue(isinstance(sys.stdout, StreamWrapper),
34
+ 'bad stdout wrapper')
35
+ self.assertTrue(isinstance(sys.stderr, StreamWrapper),
36
+ 'bad stderr wrapper')
37
+
38
+ def assertNotWrapped(self):
39
+ self.assertIs(sys.stdout, orig_stdout, 'stdout should not be wrapped')
40
+ self.assertIs(sys.stderr, orig_stderr, 'stderr should not be wrapped')
41
+
42
+ @patch('colorama.initialise.reset_all')
43
+ @patch('colorama.ansitowin32.winapi_test', lambda *_: True)
44
+ @patch('colorama.ansitowin32.enable_vt_processing', lambda *_: False)
45
+ def testInitWrapsOnWindows(self, _):
46
+ with osname("nt"):
47
+ init()
48
+ self.assertWrapped()
49
+
50
+ @patch('colorama.initialise.reset_all')
51
+ @patch('colorama.ansitowin32.winapi_test', lambda *_: False)
52
+ def testInitDoesntWrapOnEmulatedWindows(self, _):
53
+ with osname("nt"):
54
+ init()
55
+ self.assertNotWrapped()
56
+
57
+ def testInitDoesntWrapOnNonWindows(self):
58
+ with osname("posix"):
59
+ init()
60
+ self.assertNotWrapped()
61
+
62
+ def testInitDoesntWrapIfNone(self):
63
+ with replace_by(None):
64
+ init()
65
+ # We can't use assertNotWrapped here because replace_by(None)
66
+ # changes stdout/stderr already.
67
+ self.assertIsNone(sys.stdout)
68
+ self.assertIsNone(sys.stderr)
69
+
70
+ def testInitAutoresetOnWrapsOnAllPlatforms(self):
71
+ with osname("posix"):
72
+ init(autoreset=True)
73
+ self.assertWrapped()
74
+
75
+ def testInitWrapOffDoesntWrapOnWindows(self):
76
+ with osname("nt"):
77
+ init(wrap=False)
78
+ self.assertNotWrapped()
79
+
80
+ def testInitWrapOffIncompatibleWithAutoresetOn(self):
81
+ self.assertRaises(ValueError, lambda: init(autoreset=True, wrap=False))
82
+
83
+ @patch('colorama.win32.SetConsoleTextAttribute')
84
+ @patch('colorama.initialise.AnsiToWin32')
85
+ def testAutoResetPassedOn(self, mockATW32, _):
86
+ with osname("nt"):
87
+ init(autoreset=True)
88
+ self.assertEqual(len(mockATW32.call_args_list), 2)
89
+ self.assertEqual(mockATW32.call_args_list[1][1]['autoreset'], True)
90
+ self.assertEqual(mockATW32.call_args_list[0][1]['autoreset'], True)
91
+
92
+ @patch('colorama.initialise.AnsiToWin32')
93
+ def testAutoResetChangeable(self, mockATW32):
94
+ with osname("nt"):
95
+ init()
96
+
97
+ init(autoreset=True)
98
+ self.assertEqual(len(mockATW32.call_args_list), 4)
99
+ self.assertEqual(mockATW32.call_args_list[2][1]['autoreset'], True)
100
+ self.assertEqual(mockATW32.call_args_list[3][1]['autoreset'], True)
101
+
102
+ init()
103
+ self.assertEqual(len(mockATW32.call_args_list), 6)
104
+ self.assertEqual(
105
+ mockATW32.call_args_list[4][1]['autoreset'], False)
106
+ self.assertEqual(
107
+ mockATW32.call_args_list[5][1]['autoreset'], False)
108
+
109
+
110
+ @patch('colorama.initialise.atexit.register')
111
+ def testAtexitRegisteredOnlyOnce(self, mockRegister):
112
+ init()
113
+ self.assertTrue(mockRegister.called)
114
+ mockRegister.reset_mock()
115
+ init()
116
+ self.assertFalse(mockRegister.called)
117
+
118
+
119
+ class JustFixWindowsConsoleTest(TestCase):
120
+ def _reset(self):
121
+ _wipe_internal_state_for_tests()
122
+ sys.stdout = orig_stdout
123
+ sys.stderr = orig_stderr
124
+
125
+ def tearDown(self):
126
+ self._reset()
127
+
128
+ @patch("colorama.ansitowin32.winapi_test", lambda: True)
129
+ def testJustFixWindowsConsole(self):
130
+ if sys.platform != "win32":
131
+ # just_fix_windows_console should be a no-op
132
+ just_fix_windows_console()
133
+ self.assertIs(sys.stdout, orig_stdout)
134
+ self.assertIs(sys.stderr, orig_stderr)
135
+ else:
136
+ def fake_std():
137
+ # Emulate stdout=not a tty, stderr=tty
138
+ # to check that we handle both cases correctly
139
+ stdout = Mock()
140
+ stdout.closed = False
141
+ stdout.isatty.return_value = False
142
+ stdout.fileno.return_value = 1
143
+ sys.stdout = stdout
144
+
145
+ stderr = Mock()
146
+ stderr.closed = False
147
+ stderr.isatty.return_value = True
148
+ stderr.fileno.return_value = 2
149
+ sys.stderr = stderr
150
+
151
+ for native_ansi in [False, True]:
152
+ with patch(
153
+ 'colorama.ansitowin32.enable_vt_processing',
154
+ lambda *_: native_ansi
155
+ ):
156
+ self._reset()
157
+ fake_std()
158
+
159
+ # Regular single-call test
160
+ prev_stdout = sys.stdout
161
+ prev_stderr = sys.stderr
162
+ just_fix_windows_console()
163
+ self.assertIs(sys.stdout, prev_stdout)
164
+ if native_ansi:
165
+ self.assertIs(sys.stderr, prev_stderr)
166
+ else:
167
+ self.assertIsNot(sys.stderr, prev_stderr)
168
+
169
+ # second call without resetting is always a no-op
170
+ prev_stdout = sys.stdout
171
+ prev_stderr = sys.stderr
172
+ just_fix_windows_console()
173
+ self.assertIs(sys.stdout, prev_stdout)
174
+ self.assertIs(sys.stderr, prev_stderr)
175
+
176
+ self._reset()
177
+ fake_std()
178
+
179
+ # If init() runs first, just_fix_windows_console should be a no-op
180
+ init()
181
+ prev_stdout = sys.stdout
182
+ prev_stderr = sys.stderr
183
+ just_fix_windows_console()
184
+ self.assertIs(prev_stdout, sys.stdout)
185
+ self.assertIs(prev_stderr, sys.stderr)
186
+
187
+
188
+ if __name__ == '__main__':
189
+ main()
venv/lib/python3.10/site-packages/colorama/tests/isatty_test.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ import sys
3
+ from unittest import TestCase, main
4
+
5
+ from ..ansitowin32 import StreamWrapper, AnsiToWin32
6
+ from .utils import pycharm, replace_by, replace_original_by, StreamTTY, StreamNonTTY
7
+
8
+
9
+ def is_a_tty(stream):
10
+ return StreamWrapper(stream, None).isatty()
11
+
12
+ class IsattyTest(TestCase):
13
+
14
+ def test_TTY(self):
15
+ tty = StreamTTY()
16
+ self.assertTrue(is_a_tty(tty))
17
+ with pycharm():
18
+ self.assertTrue(is_a_tty(tty))
19
+
20
+ def test_nonTTY(self):
21
+ non_tty = StreamNonTTY()
22
+ self.assertFalse(is_a_tty(non_tty))
23
+ with pycharm():
24
+ self.assertFalse(is_a_tty(non_tty))
25
+
26
+ def test_withPycharm(self):
27
+ with pycharm():
28
+ self.assertTrue(is_a_tty(sys.stderr))
29
+ self.assertTrue(is_a_tty(sys.stdout))
30
+
31
+ def test_withPycharmTTYOverride(self):
32
+ tty = StreamTTY()
33
+ with pycharm(), replace_by(tty):
34
+ self.assertTrue(is_a_tty(tty))
35
+
36
+ def test_withPycharmNonTTYOverride(self):
37
+ non_tty = StreamNonTTY()
38
+ with pycharm(), replace_by(non_tty):
39
+ self.assertFalse(is_a_tty(non_tty))
40
+
41
+ def test_withPycharmNoneOverride(self):
42
+ with pycharm():
43
+ with replace_by(None), replace_original_by(None):
44
+ self.assertFalse(is_a_tty(None))
45
+ self.assertFalse(is_a_tty(StreamNonTTY()))
46
+ self.assertTrue(is_a_tty(StreamTTY()))
47
+
48
+ def test_withPycharmStreamWrapped(self):
49
+ with pycharm():
50
+ self.assertTrue(AnsiToWin32(StreamTTY()).stream.isatty())
51
+ self.assertFalse(AnsiToWin32(StreamNonTTY()).stream.isatty())
52
+ self.assertTrue(AnsiToWin32(sys.stdout).stream.isatty())
53
+ self.assertTrue(AnsiToWin32(sys.stderr).stream.isatty())
54
+
55
+
56
+ if __name__ == '__main__':
57
+ main()
venv/lib/python3.10/site-packages/colorama/tests/utils.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ from contextlib import contextmanager
3
+ from io import StringIO
4
+ import sys
5
+ import os
6
+
7
+
8
+ class StreamTTY(StringIO):
9
+ def isatty(self):
10
+ return True
11
+
12
+ class StreamNonTTY(StringIO):
13
+ def isatty(self):
14
+ return False
15
+
16
+ @contextmanager
17
+ def osname(name):
18
+ orig = os.name
19
+ os.name = name
20
+ yield
21
+ os.name = orig
22
+
23
+ @contextmanager
24
+ def replace_by(stream):
25
+ orig_stdout = sys.stdout
26
+ orig_stderr = sys.stderr
27
+ sys.stdout = stream
28
+ sys.stderr = stream
29
+ yield
30
+ sys.stdout = orig_stdout
31
+ sys.stderr = orig_stderr
32
+
33
+ @contextmanager
34
+ def replace_original_by(stream):
35
+ orig_stdout = sys.__stdout__
36
+ orig_stderr = sys.__stderr__
37
+ sys.__stdout__ = stream
38
+ sys.__stderr__ = stream
39
+ yield
40
+ sys.__stdout__ = orig_stdout
41
+ sys.__stderr__ = orig_stderr
42
+
43
+ @contextmanager
44
+ def pycharm():
45
+ os.environ["PYCHARM_HOSTED"] = "1"
46
+ non_tty = StreamNonTTY()
47
+ with replace_by(non_tty), replace_original_by(non_tty):
48
+ yield
49
+ del os.environ["PYCHARM_HOSTED"]
venv/lib/python3.10/site-packages/colorama/tests/winterm_test.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ import sys
3
+ from unittest import TestCase, main, skipUnless
4
+
5
+ try:
6
+ from unittest.mock import Mock, patch
7
+ except ImportError:
8
+ from mock import Mock, patch
9
+
10
+ from ..winterm import WinColor, WinStyle, WinTerm
11
+
12
+
13
+ class WinTermTest(TestCase):
14
+
15
+ @patch('colorama.winterm.win32')
16
+ def testInit(self, mockWin32):
17
+ mockAttr = Mock()
18
+ mockAttr.wAttributes = 7 + 6 * 16 + 8
19
+ mockWin32.GetConsoleScreenBufferInfo.return_value = mockAttr
20
+ term = WinTerm()
21
+ self.assertEqual(term._fore, 7)
22
+ self.assertEqual(term._back, 6)
23
+ self.assertEqual(term._style, 8)
24
+
25
+ @skipUnless(sys.platform.startswith("win"), "requires Windows")
26
+ def testGetAttrs(self):
27
+ term = WinTerm()
28
+
29
+ term._fore = 0
30
+ term._back = 0
31
+ term._style = 0
32
+ self.assertEqual(term.get_attrs(), 0)
33
+
34
+ term._fore = WinColor.YELLOW
35
+ self.assertEqual(term.get_attrs(), WinColor.YELLOW)
36
+
37
+ term._back = WinColor.MAGENTA
38
+ self.assertEqual(
39
+ term.get_attrs(),
40
+ WinColor.YELLOW + WinColor.MAGENTA * 16)
41
+
42
+ term._style = WinStyle.BRIGHT
43
+ self.assertEqual(
44
+ term.get_attrs(),
45
+ WinColor.YELLOW + WinColor.MAGENTA * 16 + WinStyle.BRIGHT)
46
+
47
+ @patch('colorama.winterm.win32')
48
+ def testResetAll(self, mockWin32):
49
+ mockAttr = Mock()
50
+ mockAttr.wAttributes = 1 + 2 * 16 + 8
51
+ mockWin32.GetConsoleScreenBufferInfo.return_value = mockAttr
52
+ term = WinTerm()
53
+
54
+ term.set_console = Mock()
55
+ term._fore = -1
56
+ term._back = -1
57
+ term._style = -1
58
+
59
+ term.reset_all()
60
+
61
+ self.assertEqual(term._fore, 1)
62
+ self.assertEqual(term._back, 2)
63
+ self.assertEqual(term._style, 8)
64
+ self.assertEqual(term.set_console.called, True)
65
+
66
+ @skipUnless(sys.platform.startswith("win"), "requires Windows")
67
+ def testFore(self):
68
+ term = WinTerm()
69
+ term.set_console = Mock()
70
+ term._fore = 0
71
+
72
+ term.fore(5)
73
+
74
+ self.assertEqual(term._fore, 5)
75
+ self.assertEqual(term.set_console.called, True)
76
+
77
+ @skipUnless(sys.platform.startswith("win"), "requires Windows")
78
+ def testBack(self):
79
+ term = WinTerm()
80
+ term.set_console = Mock()
81
+ term._back = 0
82
+
83
+ term.back(5)
84
+
85
+ self.assertEqual(term._back, 5)
86
+ self.assertEqual(term.set_console.called, True)
87
+
88
+ @skipUnless(sys.platform.startswith("win"), "requires Windows")
89
+ def testStyle(self):
90
+ term = WinTerm()
91
+ term.set_console = Mock()
92
+ term._style = 0
93
+
94
+ term.style(22)
95
+
96
+ self.assertEqual(term._style, 22)
97
+ self.assertEqual(term.set_console.called, True)
98
+
99
+ @patch('colorama.winterm.win32')
100
+ def testSetConsole(self, mockWin32):
101
+ mockAttr = Mock()
102
+ mockAttr.wAttributes = 0
103
+ mockWin32.GetConsoleScreenBufferInfo.return_value = mockAttr
104
+ term = WinTerm()
105
+ term.windll = Mock()
106
+
107
+ term.set_console()
108
+
109
+ self.assertEqual(
110
+ mockWin32.SetConsoleTextAttribute.call_args,
111
+ ((mockWin32.STDOUT, term.get_attrs()), {})
112
+ )
113
+
114
+ @patch('colorama.winterm.win32')
115
+ def testSetConsoleOnStderr(self, mockWin32):
116
+ mockAttr = Mock()
117
+ mockAttr.wAttributes = 0
118
+ mockWin32.GetConsoleScreenBufferInfo.return_value = mockAttr
119
+ term = WinTerm()
120
+ term.windll = Mock()
121
+
122
+ term.set_console(on_stderr=True)
123
+
124
+ self.assertEqual(
125
+ mockWin32.SetConsoleTextAttribute.call_args,
126
+ ((mockWin32.STDERR, term.get_attrs()), {})
127
+ )
128
+
129
+
130
+ if __name__ == '__main__':
131
+ main()
venv/lib/python3.10/site-packages/colorama/win32.py ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+
3
+ # from winbase.h
4
+ STDOUT = -11
5
+ STDERR = -12
6
+
7
+ ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004
8
+
9
+ try:
10
+ import ctypes
11
+ from ctypes import LibraryLoader
12
+ windll = LibraryLoader(ctypes.WinDLL)
13
+ from ctypes import wintypes
14
+ except (AttributeError, ImportError):
15
+ windll = None
16
+ SetConsoleTextAttribute = lambda *_: None
17
+ winapi_test = lambda *_: None
18
+ else:
19
+ from ctypes import byref, Structure, c_char, POINTER
20
+
21
+ COORD = wintypes._COORD
22
+
23
+ class CONSOLE_SCREEN_BUFFER_INFO(Structure):
24
+ """struct in wincon.h."""
25
+ _fields_ = [
26
+ ("dwSize", COORD),
27
+ ("dwCursorPosition", COORD),
28
+ ("wAttributes", wintypes.WORD),
29
+ ("srWindow", wintypes.SMALL_RECT),
30
+ ("dwMaximumWindowSize", COORD),
31
+ ]
32
+ def __str__(self):
33
+ return '(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)' % (
34
+ self.dwSize.Y, self.dwSize.X
35
+ , self.dwCursorPosition.Y, self.dwCursorPosition.X
36
+ , self.wAttributes
37
+ , self.srWindow.Top, self.srWindow.Left, self.srWindow.Bottom, self.srWindow.Right
38
+ , self.dwMaximumWindowSize.Y, self.dwMaximumWindowSize.X
39
+ )
40
+
41
+ _GetStdHandle = windll.kernel32.GetStdHandle
42
+ _GetStdHandle.argtypes = [
43
+ wintypes.DWORD,
44
+ ]
45
+ _GetStdHandle.restype = wintypes.HANDLE
46
+
47
+ _GetConsoleScreenBufferInfo = windll.kernel32.GetConsoleScreenBufferInfo
48
+ _GetConsoleScreenBufferInfo.argtypes = [
49
+ wintypes.HANDLE,
50
+ POINTER(CONSOLE_SCREEN_BUFFER_INFO),
51
+ ]
52
+ _GetConsoleScreenBufferInfo.restype = wintypes.BOOL
53
+
54
+ _SetConsoleTextAttribute = windll.kernel32.SetConsoleTextAttribute
55
+ _SetConsoleTextAttribute.argtypes = [
56
+ wintypes.HANDLE,
57
+ wintypes.WORD,
58
+ ]
59
+ _SetConsoleTextAttribute.restype = wintypes.BOOL
60
+
61
+ _SetConsoleCursorPosition = windll.kernel32.SetConsoleCursorPosition
62
+ _SetConsoleCursorPosition.argtypes = [
63
+ wintypes.HANDLE,
64
+ COORD,
65
+ ]
66
+ _SetConsoleCursorPosition.restype = wintypes.BOOL
67
+
68
+ _FillConsoleOutputCharacterA = windll.kernel32.FillConsoleOutputCharacterA
69
+ _FillConsoleOutputCharacterA.argtypes = [
70
+ wintypes.HANDLE,
71
+ c_char,
72
+ wintypes.DWORD,
73
+ COORD,
74
+ POINTER(wintypes.DWORD),
75
+ ]
76
+ _FillConsoleOutputCharacterA.restype = wintypes.BOOL
77
+
78
+ _FillConsoleOutputAttribute = windll.kernel32.FillConsoleOutputAttribute
79
+ _FillConsoleOutputAttribute.argtypes = [
80
+ wintypes.HANDLE,
81
+ wintypes.WORD,
82
+ wintypes.DWORD,
83
+ COORD,
84
+ POINTER(wintypes.DWORD),
85
+ ]
86
+ _FillConsoleOutputAttribute.restype = wintypes.BOOL
87
+
88
+ _SetConsoleTitleW = windll.kernel32.SetConsoleTitleW
89
+ _SetConsoleTitleW.argtypes = [
90
+ wintypes.LPCWSTR
91
+ ]
92
+ _SetConsoleTitleW.restype = wintypes.BOOL
93
+
94
+ _GetConsoleMode = windll.kernel32.GetConsoleMode
95
+ _GetConsoleMode.argtypes = [
96
+ wintypes.HANDLE,
97
+ POINTER(wintypes.DWORD)
98
+ ]
99
+ _GetConsoleMode.restype = wintypes.BOOL
100
+
101
+ _SetConsoleMode = windll.kernel32.SetConsoleMode
102
+ _SetConsoleMode.argtypes = [
103
+ wintypes.HANDLE,
104
+ wintypes.DWORD
105
+ ]
106
+ _SetConsoleMode.restype = wintypes.BOOL
107
+
108
+ def _winapi_test(handle):
109
+ csbi = CONSOLE_SCREEN_BUFFER_INFO()
110
+ success = _GetConsoleScreenBufferInfo(
111
+ handle, byref(csbi))
112
+ return bool(success)
113
+
114
+ def winapi_test():
115
+ return any(_winapi_test(h) for h in
116
+ (_GetStdHandle(STDOUT), _GetStdHandle(STDERR)))
117
+
118
+ def GetConsoleScreenBufferInfo(stream_id=STDOUT):
119
+ handle = _GetStdHandle(stream_id)
120
+ csbi = CONSOLE_SCREEN_BUFFER_INFO()
121
+ success = _GetConsoleScreenBufferInfo(
122
+ handle, byref(csbi))
123
+ return csbi
124
+
125
+ def SetConsoleTextAttribute(stream_id, attrs):
126
+ handle = _GetStdHandle(stream_id)
127
+ return _SetConsoleTextAttribute(handle, attrs)
128
+
129
+ def SetConsoleCursorPosition(stream_id, position, adjust=True):
130
+ position = COORD(*position)
131
+ # If the position is out of range, do nothing.
132
+ if position.Y <= 0 or position.X <= 0:
133
+ return
134
+ # Adjust for Windows' SetConsoleCursorPosition:
135
+ # 1. being 0-based, while ANSI is 1-based.
136
+ # 2. expecting (x,y), while ANSI uses (y,x).
137
+ adjusted_position = COORD(position.Y - 1, position.X - 1)
138
+ if adjust:
139
+ # Adjust for viewport's scroll position
140
+ sr = GetConsoleScreenBufferInfo(STDOUT).srWindow
141
+ adjusted_position.Y += sr.Top
142
+ adjusted_position.X += sr.Left
143
+ # Resume normal processing
144
+ handle = _GetStdHandle(stream_id)
145
+ return _SetConsoleCursorPosition(handle, adjusted_position)
146
+
147
+ def FillConsoleOutputCharacter(stream_id, char, length, start):
148
+ handle = _GetStdHandle(stream_id)
149
+ char = c_char(char.encode())
150
+ length = wintypes.DWORD(length)
151
+ num_written = wintypes.DWORD(0)
152
+ # Note that this is hard-coded for ANSI (vs wide) bytes.
153
+ success = _FillConsoleOutputCharacterA(
154
+ handle, char, length, start, byref(num_written))
155
+ return num_written.value
156
+
157
+ def FillConsoleOutputAttribute(stream_id, attr, length, start):
158
+ ''' FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten )'''
159
+ handle = _GetStdHandle(stream_id)
160
+ attribute = wintypes.WORD(attr)
161
+ length = wintypes.DWORD(length)
162
+ num_written = wintypes.DWORD(0)
163
+ # Note that this is hard-coded for ANSI (vs wide) bytes.
164
+ return _FillConsoleOutputAttribute(
165
+ handle, attribute, length, start, byref(num_written))
166
+
167
+ def SetConsoleTitle(title):
168
+ return _SetConsoleTitleW(title)
169
+
170
+ def GetConsoleMode(handle):
171
+ mode = wintypes.DWORD()
172
+ success = _GetConsoleMode(handle, byref(mode))
173
+ if not success:
174
+ raise ctypes.WinError()
175
+ return mode.value
176
+
177
+ def SetConsoleMode(handle, mode):
178
+ success = _SetConsoleMode(handle, mode)
179
+ if not success:
180
+ raise ctypes.WinError()
venv/lib/python3.10/site-packages/colorama/winterm.py ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2
+ try:
3
+ from msvcrt import get_osfhandle
4
+ except ImportError:
5
+ def get_osfhandle(_):
6
+ raise OSError("This isn't windows!")
7
+
8
+
9
+ from . import win32
10
+
11
+ # from wincon.h
12
+ class WinColor(object):
13
+ BLACK = 0
14
+ BLUE = 1
15
+ GREEN = 2
16
+ CYAN = 3
17
+ RED = 4
18
+ MAGENTA = 5
19
+ YELLOW = 6
20
+ GREY = 7
21
+
22
+ # from wincon.h
23
+ class WinStyle(object):
24
+ NORMAL = 0x00 # dim text, dim background
25
+ BRIGHT = 0x08 # bright text, dim background
26
+ BRIGHT_BACKGROUND = 0x80 # dim text, bright background
27
+
28
+ class WinTerm(object):
29
+
30
+ def __init__(self):
31
+ self._default = win32.GetConsoleScreenBufferInfo(win32.STDOUT).wAttributes
32
+ self.set_attrs(self._default)
33
+ self._default_fore = self._fore
34
+ self._default_back = self._back
35
+ self._default_style = self._style
36
+ # In order to emulate LIGHT_EX in windows, we borrow the BRIGHT style.
37
+ # So that LIGHT_EX colors and BRIGHT style do not clobber each other,
38
+ # we track them separately, since LIGHT_EX is overwritten by Fore/Back
39
+ # and BRIGHT is overwritten by Style codes.
40
+ self._light = 0
41
+
42
+ def get_attrs(self):
43
+ return self._fore + self._back * 16 + (self._style | self._light)
44
+
45
+ def set_attrs(self, value):
46
+ self._fore = value & 7
47
+ self._back = (value >> 4) & 7
48
+ self._style = value & (WinStyle.BRIGHT | WinStyle.BRIGHT_BACKGROUND)
49
+
50
+ def reset_all(self, on_stderr=None):
51
+ self.set_attrs(self._default)
52
+ self.set_console(attrs=self._default)
53
+ self._light = 0
54
+
55
+ def fore(self, fore=None, light=False, on_stderr=False):
56
+ if fore is None:
57
+ fore = self._default_fore
58
+ self._fore = fore
59
+ # Emulate LIGHT_EX with BRIGHT Style
60
+ if light:
61
+ self._light |= WinStyle.BRIGHT
62
+ else:
63
+ self._light &= ~WinStyle.BRIGHT
64
+ self.set_console(on_stderr=on_stderr)
65
+
66
+ def back(self, back=None, light=False, on_stderr=False):
67
+ if back is None:
68
+ back = self._default_back
69
+ self._back = back
70
+ # Emulate LIGHT_EX with BRIGHT_BACKGROUND Style
71
+ if light:
72
+ self._light |= WinStyle.BRIGHT_BACKGROUND
73
+ else:
74
+ self._light &= ~WinStyle.BRIGHT_BACKGROUND
75
+ self.set_console(on_stderr=on_stderr)
76
+
77
+ def style(self, style=None, on_stderr=False):
78
+ if style is None:
79
+ style = self._default_style
80
+ self._style = style
81
+ self.set_console(on_stderr=on_stderr)
82
+
83
+ def set_console(self, attrs=None, on_stderr=False):
84
+ if attrs is None:
85
+ attrs = self.get_attrs()
86
+ handle = win32.STDOUT
87
+ if on_stderr:
88
+ handle = win32.STDERR
89
+ win32.SetConsoleTextAttribute(handle, attrs)
90
+
91
+ def get_position(self, handle):
92
+ position = win32.GetConsoleScreenBufferInfo(handle).dwCursorPosition
93
+ # Because Windows coordinates are 0-based,
94
+ # and win32.SetConsoleCursorPosition expects 1-based.
95
+ position.X += 1
96
+ position.Y += 1
97
+ return position
98
+
99
+ def set_cursor_position(self, position=None, on_stderr=False):
100
+ if position is None:
101
+ # I'm not currently tracking the position, so there is no default.
102
+ # position = self.get_position()
103
+ return
104
+ handle = win32.STDOUT
105
+ if on_stderr:
106
+ handle = win32.STDERR
107
+ win32.SetConsoleCursorPosition(handle, position)
108
+
109
+ def cursor_adjust(self, x, y, on_stderr=False):
110
+ handle = win32.STDOUT
111
+ if on_stderr:
112
+ handle = win32.STDERR
113
+ position = self.get_position(handle)
114
+ adjusted_position = (position.Y + y, position.X + x)
115
+ win32.SetConsoleCursorPosition(handle, adjusted_position, adjust=False)
116
+
117
+ def erase_screen(self, mode=0, on_stderr=False):
118
+ # 0 should clear from the cursor to the end of the screen.
119
+ # 1 should clear from the cursor to the beginning of the screen.
120
+ # 2 should clear the entire screen, and move cursor to (1,1)
121
+ handle = win32.STDOUT
122
+ if on_stderr:
123
+ handle = win32.STDERR
124
+ csbi = win32.GetConsoleScreenBufferInfo(handle)
125
+ # get the number of character cells in the current buffer
126
+ cells_in_screen = csbi.dwSize.X * csbi.dwSize.Y
127
+ # get number of character cells before current cursor position
128
+ cells_before_cursor = csbi.dwSize.X * csbi.dwCursorPosition.Y + csbi.dwCursorPosition.X
129
+ if mode == 0:
130
+ from_coord = csbi.dwCursorPosition
131
+ cells_to_erase = cells_in_screen - cells_before_cursor
132
+ elif mode == 1:
133
+ from_coord = win32.COORD(0, 0)
134
+ cells_to_erase = cells_before_cursor
135
+ elif mode == 2:
136
+ from_coord = win32.COORD(0, 0)
137
+ cells_to_erase = cells_in_screen
138
+ else:
139
+ # invalid mode
140
+ return
141
+ # fill the entire screen with blanks
142
+ win32.FillConsoleOutputCharacter(handle, ' ', cells_to_erase, from_coord)
143
+ # now set the buffer's attributes accordingly
144
+ win32.FillConsoleOutputAttribute(handle, self.get_attrs(), cells_to_erase, from_coord)
145
+ if mode == 2:
146
+ # put the cursor where needed
147
+ win32.SetConsoleCursorPosition(handle, (1, 1))
148
+
149
+ def erase_line(self, mode=0, on_stderr=False):
150
+ # 0 should clear from the cursor to the end of the line.
151
+ # 1 should clear from the cursor to the beginning of the line.
152
+ # 2 should clear the entire line.
153
+ handle = win32.STDOUT
154
+ if on_stderr:
155
+ handle = win32.STDERR
156
+ csbi = win32.GetConsoleScreenBufferInfo(handle)
157
+ if mode == 0:
158
+ from_coord = csbi.dwCursorPosition
159
+ cells_to_erase = csbi.dwSize.X - csbi.dwCursorPosition.X
160
+ elif mode == 1:
161
+ from_coord = win32.COORD(0, csbi.dwCursorPosition.Y)
162
+ cells_to_erase = csbi.dwCursorPosition.X
163
+ elif mode == 2:
164
+ from_coord = win32.COORD(0, csbi.dwCursorPosition.Y)
165
+ cells_to_erase = csbi.dwSize.X
166
+ else:
167
+ # invalid mode
168
+ return
169
+ # fill the entire screen with blanks
170
+ win32.FillConsoleOutputCharacter(handle, ' ', cells_to_erase, from_coord)
171
+ # now set the buffer's attributes accordingly
172
+ win32.FillConsoleOutputAttribute(handle, self.get_attrs(), cells_to_erase, from_coord)
173
+
174
+ def set_title(self, title):
175
+ win32.SetConsoleTitle(title)
176
+
177
+
178
+ def enable_vt_processing(fd):
179
+ if win32.windll is None or not win32.winapi_test():
180
+ return False
181
+
182
+ try:
183
+ handle = get_osfhandle(fd)
184
+ mode = win32.GetConsoleMode(handle)
185
+ win32.SetConsoleMode(
186
+ handle,
187
+ mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING,
188
+ )
189
+
190
+ mode = win32.GetConsoleMode(handle)
191
+ if mode & win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING:
192
+ return True
193
+ # Can get TypeError in testsuite where 'fd' is a Mock()
194
+ except (OSError, TypeError):
195
+ return False
venv/lib/python3.10/site-packages/networkx/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.37 kB). View file
 
venv/lib/python3.10/site-packages/networkx/__pycache__/conftest.cpython-310.pyc ADDED
Binary file (6.11 kB). View file
 
venv/lib/python3.10/site-packages/networkx/__pycache__/convert.cpython-310.pyc ADDED
Binary file (13.2 kB). View file
 
venv/lib/python3.10/site-packages/networkx/__pycache__/convert_matrix.cpython-310.pyc ADDED
Binary file (41.3 kB). View file
 
venv/lib/python3.10/site-packages/networkx/__pycache__/exception.cpython-310.pyc ADDED
Binary file (4.84 kB). View file
 
venv/lib/python3.10/site-packages/networkx/__pycache__/lazy_imports.cpython-310.pyc ADDED
Binary file (5.93 kB). View file
 
venv/lib/python3.10/site-packages/networkx/__pycache__/relabel.cpython-310.pyc ADDED
Binary file (10.2 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.55 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/atlas.cpython-310.pyc ADDED
Binary file (4.4 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/classic.cpython-310.pyc ADDED
Binary file (29.9 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/cographs.cpython-310.pyc ADDED
Binary file (2.31 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/community.cpython-310.pyc ADDED
Binary file (31.2 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/degree_seq.cpython-310.pyc ADDED
Binary file (25.7 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/directed.cpython-310.pyc ADDED
Binary file (15 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/duplication.cpython-310.pyc ADDED
Binary file (5.14 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/ego.cpython-310.pyc ADDED
Binary file (1.89 kB). View file
 
venv/lib/python3.10/site-packages/networkx/generators/__pycache__/expanders.cpython-310.pyc ADDED
Binary file (12.5 kB). View file