ebartan commited on
Commit
f59cb3c
·
1 Parent(s): 626c96d

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +32 -0
  2. README.md +3 -3
  3. app.py +6 -0
  4. venv/bin/Activate.ps1 +247 -0
  5. venv/bin/activate +69 -0
  6. venv/bin/activate.csh +26 -0
  7. venv/bin/activate.fish +66 -0
  8. venv/bin/f2py +8 -0
  9. venv/bin/fonttools +8 -0
  10. venv/bin/gradio +8 -0
  11. venv/bin/httpx +8 -0
  12. venv/bin/huggingface-cli +8 -0
  13. venv/bin/jsonschema +8 -0
  14. venv/bin/normalizer +8 -0
  15. venv/bin/pip +8 -0
  16. venv/bin/pip3 +8 -0
  17. venv/bin/pip3.10 +8 -0
  18. venv/bin/pyftmerge +8 -0
  19. venv/bin/pyftsubset +8 -0
  20. venv/bin/python +3 -0
  21. venv/bin/python3 +3 -0
  22. venv/bin/python3.10 +3 -0
  23. venv/bin/tqdm +8 -0
  24. venv/bin/ttx +8 -0
  25. venv/bin/upload_theme +8 -0
  26. venv/bin/uvicorn +8 -0
  27. venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/INSTALLER +1 -0
  28. venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/LICENSE.rst +28 -0
  29. venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/METADATA +113 -0
  30. venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/RECORD +58 -0
  31. venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/WHEEL +5 -0
  32. venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/entry_points.txt +2 -0
  33. venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/top_level.txt +1 -0
  34. venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/INSTALLER +1 -0
  35. venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/LICENSE.rst +28 -0
  36. venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/METADATA +93 -0
  37. venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/RECORD +14 -0
  38. venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/WHEEL +6 -0
  39. venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/top_level.txt +1 -0
  40. venv/lib/python3.10/site-packages/PIL/BdfFontFile.py +122 -0
  41. venv/lib/python3.10/site-packages/PIL/BlpImagePlugin.py +474 -0
  42. venv/lib/python3.10/site-packages/PIL/BmpImagePlugin.py +471 -0
  43. venv/lib/python3.10/site-packages/PIL/BufrStubImagePlugin.py +73 -0
  44. venv/lib/python3.10/site-packages/PIL/ContainerIO.py +120 -0
  45. venv/lib/python3.10/site-packages/PIL/CurImagePlugin.py +75 -0
  46. venv/lib/python3.10/site-packages/PIL/DcxImagePlugin.py +79 -0
  47. venv/lib/python3.10/site-packages/PIL/DdsImagePlugin.py +295 -0
  48. venv/lib/python3.10/site-packages/PIL/EpsImagePlugin.py +480 -0
  49. venv/lib/python3.10/site-packages/PIL/ExifTags.py +380 -0
  50. venv/lib/python3.10/site-packages/PIL/FitsImagePlugin.py +73 -0
.gitattributes CHANGED
@@ -33,3 +33,35 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ venv/bin/python filter=lfs diff=lfs merge=lfs -text
37
+ venv/bin/python3 filter=lfs diff=lfs merge=lfs -text
38
+ venv/bin/python3.10 filter=lfs diff=lfs merge=lfs -text
39
+ venv/lib/python3.10/site-packages/Pillow.libs/libfreetype-82733d78.so.6.20.1 filter=lfs diff=lfs merge=lfs -text
40
+ venv/lib/python3.10/site-packages/Pillow.libs/libharfbuzz-e3b74c67.so.0.60821.0 filter=lfs diff=lfs merge=lfs -text
41
+ venv/lib/python3.10/site-packages/altair/vegalite/v5/schema/__pycache__/core.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
42
+ venv/lib/python3.10/site-packages/fontTools/feaLib/lexer.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
43
+ venv/lib/python3.10/site-packages/fontTools/misc/bezierTools.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
44
+ venv/lib/python3.10/site-packages/fontTools/pens/momentsPen.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
45
+ venv/lib/python3.10/site-packages/fontTools/qu2cu/qu2cu.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
46
+ venv/lib/python3.10/site-packages/fontTools/varLib/iup.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
47
+ venv/lib/python3.10/site-packages/gradio/templates/cdn/assets/index-973aa9f2.js.map filter=lfs diff=lfs merge=lfs -text
48
+ venv/lib/python3.10/site-packages/gradio/templates/frontend/assets/index-397dd2f4.js.map filter=lfs diff=lfs merge=lfs -text
49
+ venv/lib/python3.10/site-packages/kiwisolver/_cext.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
50
+ venv/lib/python3.10/site-packages/matplotlib/_image.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
51
+ venv/lib/python3.10/site-packages/matplotlib/_path.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
52
+ venv/lib/python3.10/site-packages/matplotlib/_qhull.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
53
+ venv/lib/python3.10/site-packages/matplotlib/backends/_backend_agg.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
54
+ venv/lib/python3.10/site-packages/matplotlib/ft2font.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
55
+ venv/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
56
+ venv/lib/python3.10/site-packages/numpy/core/_simd.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
57
+ venv/lib/python3.10/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
58
+ venv/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so filter=lfs diff=lfs merge=lfs -text
59
+ venv/lib/python3.10/site-packages/pandas/_libs/algos.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
60
+ venv/lib/python3.10/site-packages/pandas/_libs/groupby.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
61
+ venv/lib/python3.10/site-packages/pandas/_libs/hashtable.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
62
+ venv/lib/python3.10/site-packages/pandas/_libs/interval.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
63
+ venv/lib/python3.10/site-packages/pandas/_libs/join.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
64
+ venv/lib/python3.10/site-packages/pandas/_libs/tslibs/offsets.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
65
+ venv/lib/python3.10/site-packages/pydantic_core/_pydantic_core.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
66
+ venv/lib/python3.10/site-packages/rpds/rpds.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
67
+ venv/lib/python3.10/site-packages/yaml/_yaml.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: Discordbot
3
- emoji: 💻
4
- colorFrom: blue
5
- colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 3.50.2
8
  app_file: app.py
 
1
  ---
2
  title: Discordbot
3
+ emoji: 🏆
4
+ colorFrom: pink
5
+ colorTo: pink
6
  sdk: gradio
7
  sdk_version: 3.50.2
8
  app_file: app.py
app.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def slow_echo(message, history):
4
+ return message
5
+
6
+ demo = gr.ChatInterface(slow_echo).queue().launch()
venv/bin/Activate.ps1 ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <#
2
+ .Synopsis
3
+ Activate a Python virtual environment for the current PowerShell session.
4
+
5
+ .Description
6
+ Pushes the python executable for a virtual environment to the front of the
7
+ $Env:PATH environment variable and sets the prompt to signify that you are
8
+ in a Python virtual environment. Makes use of the command line switches as
9
+ well as the `pyvenv.cfg` file values present in the virtual environment.
10
+
11
+ .Parameter VenvDir
12
+ Path to the directory that contains the virtual environment to activate. The
13
+ default value for this is the parent of the directory that the Activate.ps1
14
+ script is located within.
15
+
16
+ .Parameter Prompt
17
+ The prompt prefix to display when this virtual environment is activated. By
18
+ default, this prompt is the name of the virtual environment folder (VenvDir)
19
+ surrounded by parentheses and followed by a single space (ie. '(.venv) ').
20
+
21
+ .Example
22
+ Activate.ps1
23
+ Activates the Python virtual environment that contains the Activate.ps1 script.
24
+
25
+ .Example
26
+ Activate.ps1 -Verbose
27
+ Activates the Python virtual environment that contains the Activate.ps1 script,
28
+ and shows extra information about the activation as it executes.
29
+
30
+ .Example
31
+ Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
32
+ Activates the Python virtual environment located in the specified location.
33
+
34
+ .Example
35
+ Activate.ps1 -Prompt "MyPython"
36
+ Activates the Python virtual environment that contains the Activate.ps1 script,
37
+ and prefixes the current prompt with the specified string (surrounded in
38
+ parentheses) while the virtual environment is active.
39
+
40
+ .Notes
41
+ On Windows, it may be required to enable this Activate.ps1 script by setting the
42
+ execution policy for the user. You can do this by issuing the following PowerShell
43
+ command:
44
+
45
+ PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
46
+
47
+ For more information on Execution Policies:
48
+ https://go.microsoft.com/fwlink/?LinkID=135170
49
+
50
+ #>
51
+ Param(
52
+ [Parameter(Mandatory = $false)]
53
+ [String]
54
+ $VenvDir,
55
+ [Parameter(Mandatory = $false)]
56
+ [String]
57
+ $Prompt
58
+ )
59
+
60
+ <# Function declarations --------------------------------------------------- #>
61
+
62
+ <#
63
+ .Synopsis
64
+ Remove all shell session elements added by the Activate script, including the
65
+ addition of the virtual environment's Python executable from the beginning of
66
+ the PATH variable.
67
+
68
+ .Parameter NonDestructive
69
+ If present, do not remove this function from the global namespace for the
70
+ session.
71
+
72
+ #>
73
+ function global:deactivate ([switch]$NonDestructive) {
74
+ # Revert to original values
75
+
76
+ # The prior prompt:
77
+ if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
78
+ Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
79
+ Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
80
+ }
81
+
82
+ # The prior PYTHONHOME:
83
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
84
+ Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
85
+ Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
86
+ }
87
+
88
+ # The prior PATH:
89
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
90
+ Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
91
+ Remove-Item -Path Env:_OLD_VIRTUAL_PATH
92
+ }
93
+
94
+ # Just remove the VIRTUAL_ENV altogether:
95
+ if (Test-Path -Path Env:VIRTUAL_ENV) {
96
+ Remove-Item -Path env:VIRTUAL_ENV
97
+ }
98
+
99
+ # Just remove VIRTUAL_ENV_PROMPT altogether.
100
+ if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
101
+ Remove-Item -Path env:VIRTUAL_ENV_PROMPT
102
+ }
103
+
104
+ # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
105
+ if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
106
+ Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
107
+ }
108
+
109
+ # Leave deactivate function in the global namespace if requested:
110
+ if (-not $NonDestructive) {
111
+ Remove-Item -Path function:deactivate
112
+ }
113
+ }
114
+
115
+ <#
116
+ .Description
117
+ Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
118
+ given folder, and returns them in a map.
119
+
120
+ For each line in the pyvenv.cfg file, if that line can be parsed into exactly
121
+ two strings separated by `=` (with any amount of whitespace surrounding the =)
122
+ then it is considered a `key = value` line. The left hand string is the key,
123
+ the right hand is the value.
124
+
125
+ If the value starts with a `'` or a `"` then the first and last character is
126
+ stripped from the value before being captured.
127
+
128
+ .Parameter ConfigDir
129
+ Path to the directory that contains the `pyvenv.cfg` file.
130
+ #>
131
+ function Get-PyVenvConfig(
132
+ [String]
133
+ $ConfigDir
134
+ ) {
135
+ Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
136
+
137
+ # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
138
+ $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
139
+
140
+ # An empty map will be returned if no config file is found.
141
+ $pyvenvConfig = @{ }
142
+
143
+ if ($pyvenvConfigPath) {
144
+
145
+ Write-Verbose "File exists, parse `key = value` lines"
146
+ $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
147
+
148
+ $pyvenvConfigContent | ForEach-Object {
149
+ $keyval = $PSItem -split "\s*=\s*", 2
150
+ if ($keyval[0] -and $keyval[1]) {
151
+ $val = $keyval[1]
152
+
153
+ # Remove extraneous quotations around a string value.
154
+ if ("'""".Contains($val.Substring(0, 1))) {
155
+ $val = $val.Substring(1, $val.Length - 2)
156
+ }
157
+
158
+ $pyvenvConfig[$keyval[0]] = $val
159
+ Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
160
+ }
161
+ }
162
+ }
163
+ return $pyvenvConfig
164
+ }
165
+
166
+
167
+ <# Begin Activate script --------------------------------------------------- #>
168
+
169
+ # Determine the containing directory of this script
170
+ $VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
171
+ $VenvExecDir = Get-Item -Path $VenvExecPath
172
+
173
+ Write-Verbose "Activation script is located in path: '$VenvExecPath'"
174
+ Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
175
+ Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
176
+
177
+ # Set values required in priority: CmdLine, ConfigFile, Default
178
+ # First, get the location of the virtual environment, it might not be
179
+ # VenvExecDir if specified on the command line.
180
+ if ($VenvDir) {
181
+ Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
182
+ }
183
+ else {
184
+ Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
185
+ $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
186
+ Write-Verbose "VenvDir=$VenvDir"
187
+ }
188
+
189
+ # Next, read the `pyvenv.cfg` file to determine any required value such
190
+ # as `prompt`.
191
+ $pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
192
+
193
+ # Next, set the prompt from the command line, or the config file, or
194
+ # just use the name of the virtual environment folder.
195
+ if ($Prompt) {
196
+ Write-Verbose "Prompt specified as argument, using '$Prompt'"
197
+ }
198
+ else {
199
+ Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
200
+ if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
201
+ Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
202
+ $Prompt = $pyvenvCfg['prompt'];
203
+ }
204
+ else {
205
+ Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
206
+ Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
207
+ $Prompt = Split-Path -Path $venvDir -Leaf
208
+ }
209
+ }
210
+
211
+ Write-Verbose "Prompt = '$Prompt'"
212
+ Write-Verbose "VenvDir='$VenvDir'"
213
+
214
+ # Deactivate any currently active virtual environment, but leave the
215
+ # deactivate function in place.
216
+ deactivate -nondestructive
217
+
218
+ # Now set the environment variable VIRTUAL_ENV, used by many tools to determine
219
+ # that there is an activated venv.
220
+ $env:VIRTUAL_ENV = $VenvDir
221
+
222
+ if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
223
+
224
+ Write-Verbose "Setting prompt to '$Prompt'"
225
+
226
+ # Set the prompt to include the env name
227
+ # Make sure _OLD_VIRTUAL_PROMPT is global
228
+ function global:_OLD_VIRTUAL_PROMPT { "" }
229
+ Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
230
+ New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
231
+
232
+ function global:prompt {
233
+ Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
234
+ _OLD_VIRTUAL_PROMPT
235
+ }
236
+ $env:VIRTUAL_ENV_PROMPT = $Prompt
237
+ }
238
+
239
+ # Clear PYTHONHOME
240
+ if (Test-Path -Path Env:PYTHONHOME) {
241
+ Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
242
+ Remove-Item -Path Env:PYTHONHOME
243
+ }
244
+
245
+ # Add the venv to the PATH
246
+ Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
247
+ $Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
venv/bin/activate ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate" *from bash*
2
+ # you cannot run it directly
3
+
4
+ deactivate () {
5
+ # reset old environment variables
6
+ if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7
+ PATH="${_OLD_VIRTUAL_PATH:-}"
8
+ export PATH
9
+ unset _OLD_VIRTUAL_PATH
10
+ fi
11
+ if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12
+ PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13
+ export PYTHONHOME
14
+ unset _OLD_VIRTUAL_PYTHONHOME
15
+ fi
16
+
17
+ # This should detect bash and zsh, which have a hash command that must
18
+ # be called to get it to forget past commands. Without forgetting
19
+ # past commands the $PATH changes we made may not be respected
20
+ if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
21
+ hash -r 2> /dev/null
22
+ fi
23
+
24
+ if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
25
+ PS1="${_OLD_VIRTUAL_PS1:-}"
26
+ export PS1
27
+ unset _OLD_VIRTUAL_PS1
28
+ fi
29
+
30
+ unset VIRTUAL_ENV
31
+ unset VIRTUAL_ENV_PROMPT
32
+ if [ ! "${1:-}" = "nondestructive" ] ; then
33
+ # Self destruct!
34
+ unset -f deactivate
35
+ fi
36
+ }
37
+
38
+ # unset irrelevant variables
39
+ deactivate nondestructive
40
+
41
+ VIRTUAL_ENV="/workspaces/oxfidiscord/discordbot/venv"
42
+ export VIRTUAL_ENV
43
+
44
+ _OLD_VIRTUAL_PATH="$PATH"
45
+ PATH="$VIRTUAL_ENV/bin:$PATH"
46
+ export PATH
47
+
48
+ # unset PYTHONHOME if set
49
+ # this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
50
+ # could use `if (set -u; : $PYTHONHOME) ;` in bash
51
+ if [ -n "${PYTHONHOME:-}" ] ; then
52
+ _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
53
+ unset PYTHONHOME
54
+ fi
55
+
56
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
57
+ _OLD_VIRTUAL_PS1="${PS1:-}"
58
+ PS1="(venv) ${PS1:-}"
59
+ export PS1
60
+ VIRTUAL_ENV_PROMPT="(venv) "
61
+ export VIRTUAL_ENV_PROMPT
62
+ fi
63
+
64
+ # This should detect bash and zsh, which have a hash command that must
65
+ # be called to get it to forget past commands. Without forgetting
66
+ # past commands the $PATH changes we made may not be respected
67
+ if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
68
+ hash -r 2> /dev/null
69
+ fi
venv/bin/activate.csh ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate.csh" *from csh*.
2
+ # You cannot run it directly.
3
+ # Created by Davide Di Blasi <davidedb@gmail.com>.
4
+ # Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
5
+
6
+ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
7
+
8
+ # Unset irrelevant variables.
9
+ deactivate nondestructive
10
+
11
+ setenv VIRTUAL_ENV "/workspaces/oxfidiscord/discordbot/venv"
12
+
13
+ set _OLD_VIRTUAL_PATH="$PATH"
14
+ setenv PATH "$VIRTUAL_ENV/bin:$PATH"
15
+
16
+
17
+ set _OLD_VIRTUAL_PROMPT="$prompt"
18
+
19
+ if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
20
+ set prompt = "(venv) $prompt"
21
+ setenv VIRTUAL_ENV_PROMPT "(venv) "
22
+ endif
23
+
24
+ alias pydoc python -m pydoc
25
+
26
+ rehash
venv/bin/activate.fish ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source <venv>/bin/activate.fish" *from fish*
2
+ # (https://fishshell.com/); you cannot run it directly.
3
+
4
+ function deactivate -d "Exit virtual environment and return to normal shell environment"
5
+ # reset old environment variables
6
+ if test -n "$_OLD_VIRTUAL_PATH"
7
+ set -gx PATH $_OLD_VIRTUAL_PATH
8
+ set -e _OLD_VIRTUAL_PATH
9
+ end
10
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11
+ set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12
+ set -e _OLD_VIRTUAL_PYTHONHOME
13
+ end
14
+
15
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16
+ functions -e fish_prompt
17
+ set -e _OLD_FISH_PROMPT_OVERRIDE
18
+ functions -c _old_fish_prompt fish_prompt
19
+ functions -e _old_fish_prompt
20
+ end
21
+
22
+ set -e VIRTUAL_ENV
23
+ set -e VIRTUAL_ENV_PROMPT
24
+ if test "$argv[1]" != "nondestructive"
25
+ # Self-destruct!
26
+ functions -e deactivate
27
+ end
28
+ end
29
+
30
+ # Unset irrelevant variables.
31
+ deactivate nondestructive
32
+
33
+ set -gx VIRTUAL_ENV "/workspaces/oxfidiscord/discordbot/venv"
34
+
35
+ set -gx _OLD_VIRTUAL_PATH $PATH
36
+ set -gx PATH "$VIRTUAL_ENV/bin" $PATH
37
+
38
+ # Unset PYTHONHOME if set.
39
+ if set -q PYTHONHOME
40
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
41
+ set -e PYTHONHOME
42
+ end
43
+
44
+ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
45
+ # fish uses a function instead of an env var to generate the prompt.
46
+
47
+ # Save the current fish_prompt function as the function _old_fish_prompt.
48
+ functions -c fish_prompt _old_fish_prompt
49
+
50
+ # With the original prompt function renamed, we can override with our own.
51
+ function fish_prompt
52
+ # Save the return status of the last command.
53
+ set -l old_status $status
54
+
55
+ # Output the venv prompt; color taken from the blue of the Python logo.
56
+ printf "%s%s%s" (set_color 4B8BBE) "(venv) " (set_color normal)
57
+
58
+ # Restore the return status of the previous command.
59
+ echo "exit $old_status" | .
60
+ # Output the original/"old" prompt.
61
+ _old_fish_prompt
62
+ end
63
+
64
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
65
+ set -gx VIRTUAL_ENV_PROMPT "(venv) "
66
+ end
venv/bin/f2py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from numpy.f2py.f2py2e import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/fonttools ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.__main__ import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/gradio ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from gradio.cli import cli
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli())
venv/bin/httpx ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from httpx import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/huggingface-cli ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from huggingface_hub.commands.huggingface_cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/jsonschema ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from jsonschema.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/normalizer ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from charset_normalizer.cli import cli_detect
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli_detect())
venv/bin/pip ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/pip3 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/pip3.10 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pip._internal.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/pyftmerge ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.merge import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/pyftsubset ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.subset import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/python ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:729896386432552aa2edda436a32ff1b981792dde24c6b1c1b5708263904c01e
3
+ size 24210968
venv/bin/python3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:729896386432552aa2edda436a32ff1b981792dde24c6b1c1b5708263904c01e
3
+ size 24210968
venv/bin/python3.10 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:729896386432552aa2edda436a32ff1b981792dde24c6b1c1b5708263904c01e
3
+ size 24210968
venv/bin/tqdm ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from tqdm.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/ttx ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.ttx import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/upload_theme ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from gradio.themes.upload_theme import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/bin/uvicorn ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/workspaces/oxfidiscord/discordbot/venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from uvicorn.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/LICENSE.rst ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2007 Pallets
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of the copyright holder nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/METADATA ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: Jinja2
3
+ Version: 3.1.2
4
+ Summary: A very fast and expressive template engine.
5
+ Home-page: https://palletsprojects.com/p/jinja/
6
+ Author: Armin Ronacher
7
+ Author-email: armin.ronacher@active-4.com
8
+ Maintainer: Pallets
9
+ Maintainer-email: contact@palletsprojects.com
10
+ License: BSD-3-Clause
11
+ Project-URL: Donate, https://palletsprojects.com/donate
12
+ Project-URL: Documentation, https://jinja.palletsprojects.com/
13
+ Project-URL: Changes, https://jinja.palletsprojects.com/changes/
14
+ Project-URL: Source Code, https://github.com/pallets/jinja/
15
+ Project-URL: Issue Tracker, https://github.com/pallets/jinja/issues/
16
+ Project-URL: Twitter, https://twitter.com/PalletsTeam
17
+ Project-URL: Chat, https://discord.gg/pallets
18
+ Platform: UNKNOWN
19
+ Classifier: Development Status :: 5 - Production/Stable
20
+ Classifier: Environment :: Web Environment
21
+ Classifier: Intended Audience :: Developers
22
+ Classifier: License :: OSI Approved :: BSD License
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: Programming Language :: Python
25
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
26
+ Classifier: Topic :: Text Processing :: Markup :: HTML
27
+ Requires-Python: >=3.7
28
+ Description-Content-Type: text/x-rst
29
+ License-File: LICENSE.rst
30
+ Requires-Dist: MarkupSafe (>=2.0)
31
+ Provides-Extra: i18n
32
+ Requires-Dist: Babel (>=2.7) ; extra == 'i18n'
33
+
34
+ Jinja
35
+ =====
36
+
37
+ Jinja is a fast, expressive, extensible templating engine. Special
38
+ placeholders in the template allow writing code similar to Python
39
+ syntax. Then the template is passed data to render the final document.
40
+
41
+ It includes:
42
+
43
+ - Template inheritance and inclusion.
44
+ - Define and import macros within templates.
45
+ - HTML templates can use autoescaping to prevent XSS from untrusted
46
+ user input.
47
+ - A sandboxed environment can safely render untrusted templates.
48
+ - AsyncIO support for generating templates and calling async
49
+ functions.
50
+ - I18N support with Babel.
51
+ - Templates are compiled to optimized Python code just-in-time and
52
+ cached, or can be compiled ahead-of-time.
53
+ - Exceptions point to the correct line in templates to make debugging
54
+ easier.
55
+ - Extensible filters, tests, functions, and even syntax.
56
+
57
+ Jinja's philosophy is that while application logic belongs in Python if
58
+ possible, it shouldn't make the template designer's job difficult by
59
+ restricting functionality too much.
60
+
61
+
62
+ Installing
63
+ ----------
64
+
65
+ Install and update using `pip`_:
66
+
67
+ .. code-block:: text
68
+
69
+ $ pip install -U Jinja2
70
+
71
+ .. _pip: https://pip.pypa.io/en/stable/getting-started/
72
+
73
+
74
+ In A Nutshell
75
+ -------------
76
+
77
+ .. code-block:: jinja
78
+
79
+ {% extends "base.html" %}
80
+ {% block title %}Members{% endblock %}
81
+ {% block content %}
82
+ <ul>
83
+ {% for user in users %}
84
+ <li><a href="{{ user.url }}">{{ user.username }}</a></li>
85
+ {% endfor %}
86
+ </ul>
87
+ {% endblock %}
88
+
89
+
90
+ Donate
91
+ ------
92
+
93
+ The Pallets organization develops and supports Jinja and other popular
94
+ packages. In order to grow the community of contributors and users, and
95
+ allow the maintainers to devote more time to the projects, `please
96
+ donate today`_.
97
+
98
+ .. _please donate today: https://palletsprojects.com/donate
99
+
100
+
101
+ Links
102
+ -----
103
+
104
+ - Documentation: https://jinja.palletsprojects.com/
105
+ - Changes: https://jinja.palletsprojects.com/changes/
106
+ - PyPI Releases: https://pypi.org/project/Jinja2/
107
+ - Source Code: https://github.com/pallets/jinja/
108
+ - Issue Tracker: https://github.com/pallets/jinja/issues/
109
+ - Website: https://palletsprojects.com/p/jinja/
110
+ - Twitter: https://twitter.com/PalletsTeam
111
+ - Chat: https://discord.gg/pallets
112
+
113
+
venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/RECORD ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Jinja2-3.1.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ Jinja2-3.1.2.dist-info/LICENSE.rst,sha256=O0nc7kEF6ze6wQ-vG-JgQI_oXSUrjp3y4JefweCUQ3s,1475
3
+ Jinja2-3.1.2.dist-info/METADATA,sha256=PZ6v2SIidMNixR7MRUX9f7ZWsPwtXanknqiZUmRbh4U,3539
4
+ Jinja2-3.1.2.dist-info/RECORD,,
5
+ Jinja2-3.1.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
6
+ Jinja2-3.1.2.dist-info/entry_points.txt,sha256=zRd62fbqIyfUpsRtU7EVIFyiu1tPwfgO7EvPErnxgTE,59
7
+ Jinja2-3.1.2.dist-info/top_level.txt,sha256=PkeVWtLb3-CqjWi1fO29OCbj55EhX_chhKrCdrVe_zs,7
8
+ jinja2/__init__.py,sha256=8vGduD8ytwgD6GDSqpYc2m3aU-T7PKOAddvVXgGr_Fs,1927
9
+ jinja2/__pycache__/__init__.cpython-310.pyc,,
10
+ jinja2/__pycache__/_identifier.cpython-310.pyc,,
11
+ jinja2/__pycache__/async_utils.cpython-310.pyc,,
12
+ jinja2/__pycache__/bccache.cpython-310.pyc,,
13
+ jinja2/__pycache__/compiler.cpython-310.pyc,,
14
+ jinja2/__pycache__/constants.cpython-310.pyc,,
15
+ jinja2/__pycache__/debug.cpython-310.pyc,,
16
+ jinja2/__pycache__/defaults.cpython-310.pyc,,
17
+ jinja2/__pycache__/environment.cpython-310.pyc,,
18
+ jinja2/__pycache__/exceptions.cpython-310.pyc,,
19
+ jinja2/__pycache__/ext.cpython-310.pyc,,
20
+ jinja2/__pycache__/filters.cpython-310.pyc,,
21
+ jinja2/__pycache__/idtracking.cpython-310.pyc,,
22
+ jinja2/__pycache__/lexer.cpython-310.pyc,,
23
+ jinja2/__pycache__/loaders.cpython-310.pyc,,
24
+ jinja2/__pycache__/meta.cpython-310.pyc,,
25
+ jinja2/__pycache__/nativetypes.cpython-310.pyc,,
26
+ jinja2/__pycache__/nodes.cpython-310.pyc,,
27
+ jinja2/__pycache__/optimizer.cpython-310.pyc,,
28
+ jinja2/__pycache__/parser.cpython-310.pyc,,
29
+ jinja2/__pycache__/runtime.cpython-310.pyc,,
30
+ jinja2/__pycache__/sandbox.cpython-310.pyc,,
31
+ jinja2/__pycache__/tests.cpython-310.pyc,,
32
+ jinja2/__pycache__/utils.cpython-310.pyc,,
33
+ jinja2/__pycache__/visitor.cpython-310.pyc,,
34
+ jinja2/_identifier.py,sha256=_zYctNKzRqlk_murTNlzrju1FFJL7Va_Ijqqd7ii2lU,1958
35
+ jinja2/async_utils.py,sha256=dHlbTeaxFPtAOQEYOGYh_PHcDT0rsDaUJAFDl_0XtTg,2472
36
+ jinja2/bccache.py,sha256=mhz5xtLxCcHRAa56azOhphIAe19u1we0ojifNMClDio,14061
37
+ jinja2/compiler.py,sha256=Gs-N8ThJ7OWK4-reKoO8Wh1ZXz95MVphBKNVf75qBr8,72172
38
+ jinja2/constants.py,sha256=GMoFydBF_kdpaRKPoM5cl5MviquVRLVyZtfp5-16jg0,1433
39
+ jinja2/debug.py,sha256=iWJ432RadxJNnaMOPrjIDInz50UEgni3_HKuFXi2vuQ,6299
40
+ jinja2/defaults.py,sha256=boBcSw78h-lp20YbaXSJsqkAI2uN_mD_TtCydpeq5wU,1267
41
+ jinja2/environment.py,sha256=6uHIcc7ZblqOMdx_uYNKqRnnwAF0_nzbyeMP9FFtuh4,61349
42
+ jinja2/exceptions.py,sha256=ioHeHrWwCWNaXX1inHmHVblvc4haO7AXsjCp3GfWvx0,5071
43
+ jinja2/ext.py,sha256=ivr3P7LKbddiXDVez20EflcO3q2aHQwz9P_PgWGHVqE,31502
44
+ jinja2/filters.py,sha256=9js1V-h2RlyW90IhLiBGLM2U-k6SCy2F4BUUMgB3K9Q,53509
45
+ jinja2/idtracking.py,sha256=GfNmadir4oDALVxzn3DL9YInhJDr69ebXeA2ygfuCGA,10704
46
+ jinja2/lexer.py,sha256=DW2nX9zk-6MWp65YR2bqqj0xqCvLtD-u9NWT8AnFRxQ,29726
47
+ jinja2/loaders.py,sha256=BfptfvTVpClUd-leMkHczdyPNYFzp_n7PKOJ98iyHOg,23207
48
+ jinja2/meta.py,sha256=GNPEvifmSaU3CMxlbheBOZjeZ277HThOPUTf1RkppKQ,4396
49
+ jinja2/nativetypes.py,sha256=DXgORDPRmVWgy034H0xL8eF7qYoK3DrMxs-935d0Fzk,4226
50
+ jinja2/nodes.py,sha256=i34GPRAZexXMT6bwuf5SEyvdmS-bRCy9KMjwN5O6pjk,34550
51
+ jinja2/optimizer.py,sha256=tHkMwXxfZkbfA1KmLcqmBMSaz7RLIvvItrJcPoXTyD8,1650
52
+ jinja2/parser.py,sha256=nHd-DFHbiygvfaPtm9rcQXJChZG7DPsWfiEsqfwKerY,39595
53
+ jinja2/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
+ jinja2/runtime.py,sha256=5CmD5BjbEJxSiDNTFBeKCaq8qU4aYD2v6q2EluyExms,33476
55
+ jinja2/sandbox.py,sha256=Y0xZeXQnH6EX5VjaV2YixESxoepnRbW_3UeQosaBU3M,14584
56
+ jinja2/tests.py,sha256=Am5Z6Lmfr2XaH_npIfJJ8MdXtWsbLjMULZJulTAj30E,5905
57
+ jinja2/utils.py,sha256=u9jXESxGn8ATZNVolwmkjUVu4SA-tLgV0W7PcSfPfdQ,23965
58
+ jinja2/visitor.py,sha256=MH14C6yq24G_KVtWzjwaI7Wg14PCJIYlWW1kpkxYak0,3568
venv/lib/python3.10/site-packages/Jinja2-3.1.2.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/Jinja2-3.1.2.dist-info/entry_points.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [babel.extractors]
2
+ jinja2 = jinja2.ext:babel_extract[i18n]
venv/lib/python3.10/site-packages/Jinja2-3.1.2.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ jinja2
venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/LICENSE.rst ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2010 Pallets
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are
5
+ met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ 3. Neither the name of the copyright holder nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/METADATA ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: MarkupSafe
3
+ Version: 2.1.3
4
+ Summary: Safely add untrusted strings to HTML/XML markup.
5
+ Home-page: https://palletsprojects.com/p/markupsafe/
6
+ Maintainer: Pallets
7
+ Maintainer-email: contact@palletsprojects.com
8
+ License: BSD-3-Clause
9
+ Project-URL: Donate, https://palletsprojects.com/donate
10
+ Project-URL: Documentation, https://markupsafe.palletsprojects.com/
11
+ Project-URL: Changes, https://markupsafe.palletsprojects.com/changes/
12
+ Project-URL: Source Code, https://github.com/pallets/markupsafe/
13
+ Project-URL: Issue Tracker, https://github.com/pallets/markupsafe/issues/
14
+ Project-URL: Chat, https://discord.gg/pallets
15
+ Classifier: Development Status :: 5 - Production/Stable
16
+ Classifier: Environment :: Web Environment
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: License :: OSI Approved :: BSD License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
22
+ Classifier: Topic :: Text Processing :: Markup :: HTML
23
+ Requires-Python: >=3.7
24
+ Description-Content-Type: text/x-rst
25
+ License-File: LICENSE.rst
26
+
27
+ MarkupSafe
28
+ ==========
29
+
30
+ MarkupSafe implements a text object that escapes characters so it is
31
+ safe to use in HTML and XML. Characters that have special meanings are
32
+ replaced so that they display as the actual characters. This mitigates
33
+ injection attacks, meaning untrusted user input can safely be displayed
34
+ on a page.
35
+
36
+
37
+ Installing
38
+ ----------
39
+
40
+ Install and update using `pip`_:
41
+
42
+ .. code-block:: text
43
+
44
+ pip install -U MarkupSafe
45
+
46
+ .. _pip: https://pip.pypa.io/en/stable/getting-started/
47
+
48
+
49
+ Examples
50
+ --------
51
+
52
+ .. code-block:: pycon
53
+
54
+ >>> from markupsafe import Markup, escape
55
+
56
+ >>> # escape replaces special characters and wraps in Markup
57
+ >>> escape("<script>alert(document.cookie);</script>")
58
+ Markup('&lt;script&gt;alert(document.cookie);&lt;/script&gt;')
59
+
60
+ >>> # wrap in Markup to mark text "safe" and prevent escaping
61
+ >>> Markup("<strong>Hello</strong>")
62
+ Markup('<strong>hello</strong>')
63
+
64
+ >>> escape(Markup("<strong>Hello</strong>"))
65
+ Markup('<strong>hello</strong>')
66
+
67
+ >>> # Markup is a str subclass
68
+ >>> # methods and operators escape their arguments
69
+ >>> template = Markup("Hello <em>{name}</em>")
70
+ >>> template.format(name='"World"')
71
+ Markup('Hello <em>&#34;World&#34;</em>')
72
+
73
+
74
+ Donate
75
+ ------
76
+
77
+ The Pallets organization develops and supports MarkupSafe and other
78
+ popular packages. In order to grow the community of contributors and
79
+ users, and allow the maintainers to devote more time to the projects,
80
+ `please donate today`_.
81
+
82
+ .. _please donate today: https://palletsprojects.com/donate
83
+
84
+
85
+ Links
86
+ -----
87
+
88
+ - Documentation: https://markupsafe.palletsprojects.com/
89
+ - Changes: https://markupsafe.palletsprojects.com/changes/
90
+ - PyPI Releases: https://pypi.org/project/MarkupSafe/
91
+ - Source Code: https://github.com/pallets/markupsafe/
92
+ - Issue Tracker: https://github.com/pallets/markupsafe/issues/
93
+ - Chat: https://discord.gg/pallets
venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/RECORD ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MarkupSafe-2.1.3.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ MarkupSafe-2.1.3.dist-info/LICENSE.rst,sha256=SJqOEQhQntmKN7uYPhHg9-HTHwvY-Zp5yESOf_N9B-o,1475
3
+ MarkupSafe-2.1.3.dist-info/METADATA,sha256=Wvvh4Tz-YtW24YagYdqrrrBdm9m-DjTdqJWhxlbU6-0,3003
4
+ MarkupSafe-2.1.3.dist-info/RECORD,,
5
+ MarkupSafe-2.1.3.dist-info/WHEEL,sha256=iZaXX0Td62Nww8bojl0E84uJHjT41csHPKZmbUBbJPs,152
6
+ MarkupSafe-2.1.3.dist-info/top_level.txt,sha256=qy0Plje5IJuvsCBjejJyhDCjEAdcDLK_2agVcex8Z6U,11
7
+ markupsafe/__init__.py,sha256=xIItqrn1Bwi7FxPJO9rCVQBG0Evewue1Tl4BV0l9xEs,10338
8
+ markupsafe/__pycache__/__init__.cpython-310.pyc,,
9
+ markupsafe/__pycache__/_native.cpython-310.pyc,,
10
+ markupsafe/_native.py,sha256=GR86Qvo_GcgKmKreA1WmYN9ud17OFwkww8E-fiW-57s,1713
11
+ markupsafe/_speedups.c,sha256=X2XvQVtIdcK4Usz70BvkzoOfjTCmQlDkkjYSn-swE0g,7083
12
+ markupsafe/_speedups.cpython-310-x86_64-linux-gnu.so,sha256=huh9xBZy3L1q1ar3y-f44Ozfa25Rg6xiomsq8MThk_Y,44240
13
+ markupsafe/_speedups.pyi,sha256=vfMCsOgbAXRNLUXkyuyonG8uEWKYU4PDqNuMaDELAYw,229
14
+ markupsafe/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/WHEEL ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.40.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-manylinux_2_17_x86_64
5
+ Tag: cp310-cp310-manylinux2014_x86_64
6
+
venv/lib/python3.10/site-packages/MarkupSafe-2.1.3.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ markupsafe
venv/lib/python3.10/site-packages/PIL/BdfFontFile.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library
3
+ # $Id$
4
+ #
5
+ # bitmap distribution font (bdf) file parser
6
+ #
7
+ # history:
8
+ # 1996-05-16 fl created (as bdf2pil)
9
+ # 1997-08-25 fl converted to FontFile driver
10
+ # 2001-05-25 fl removed bogus __init__ call
11
+ # 2002-11-20 fl robustification (from Kevin Cazabon, Dmitry Vasiliev)
12
+ # 2003-04-22 fl more robustification (from Graham Dumpleton)
13
+ #
14
+ # Copyright (c) 1997-2003 by Secret Labs AB.
15
+ # Copyright (c) 1997-2003 by Fredrik Lundh.
16
+ #
17
+ # See the README file for information on usage and redistribution.
18
+ #
19
+
20
+ """
21
+ Parse X Bitmap Distribution Format (BDF)
22
+ """
23
+
24
+
25
+ from . import FontFile, Image
26
+
27
+ bdf_slant = {
28
+ "R": "Roman",
29
+ "I": "Italic",
30
+ "O": "Oblique",
31
+ "RI": "Reverse Italic",
32
+ "RO": "Reverse Oblique",
33
+ "OT": "Other",
34
+ }
35
+
36
+ bdf_spacing = {"P": "Proportional", "M": "Monospaced", "C": "Cell"}
37
+
38
+
39
+ def bdf_char(f):
40
+ # skip to STARTCHAR
41
+ while True:
42
+ s = f.readline()
43
+ if not s:
44
+ return None
45
+ if s[:9] == b"STARTCHAR":
46
+ break
47
+ id = s[9:].strip().decode("ascii")
48
+
49
+ # load symbol properties
50
+ props = {}
51
+ while True:
52
+ s = f.readline()
53
+ if not s or s[:6] == b"BITMAP":
54
+ break
55
+ i = s.find(b" ")
56
+ props[s[:i].decode("ascii")] = s[i + 1 : -1].decode("ascii")
57
+
58
+ # load bitmap
59
+ bitmap = []
60
+ while True:
61
+ s = f.readline()
62
+ if not s or s[:7] == b"ENDCHAR":
63
+ break
64
+ bitmap.append(s[:-1])
65
+ bitmap = b"".join(bitmap)
66
+
67
+ # The word BBX
68
+ # followed by the width in x (BBw), height in y (BBh),
69
+ # and x and y displacement (BBxoff0, BByoff0)
70
+ # of the lower left corner from the origin of the character.
71
+ width, height, x_disp, y_disp = (int(p) for p in props["BBX"].split())
72
+
73
+ # The word DWIDTH
74
+ # followed by the width in x and y of the character in device pixels.
75
+ dwx, dwy = (int(p) for p in props["DWIDTH"].split())
76
+
77
+ bbox = (
78
+ (dwx, dwy),
79
+ (x_disp, -y_disp - height, width + x_disp, -y_disp),
80
+ (0, 0, width, height),
81
+ )
82
+
83
+ try:
84
+ im = Image.frombytes("1", (width, height), bitmap, "hex", "1")
85
+ except ValueError:
86
+ # deal with zero-width characters
87
+ im = Image.new("1", (width, height))
88
+
89
+ return id, int(props["ENCODING"]), bbox, im
90
+
91
+
92
+ class BdfFontFile(FontFile.FontFile):
93
+ """Font file plugin for the X11 BDF format."""
94
+
95
+ def __init__(self, fp):
96
+ super().__init__()
97
+
98
+ s = fp.readline()
99
+ if s[:13] != b"STARTFONT 2.1":
100
+ msg = "not a valid BDF file"
101
+ raise SyntaxError(msg)
102
+
103
+ props = {}
104
+ comments = []
105
+
106
+ while True:
107
+ s = fp.readline()
108
+ if not s or s[:13] == b"ENDPROPERTIES":
109
+ break
110
+ i = s.find(b" ")
111
+ props[s[:i].decode("ascii")] = s[i + 1 : -1].decode("ascii")
112
+ if s[:i] in [b"COMMENT", b"COPYRIGHT"]:
113
+ if s.find(b"LogicalFontDescription") < 0:
114
+ comments.append(s[i + 1 : -1].decode("ascii"))
115
+
116
+ while True:
117
+ c = bdf_char(fp)
118
+ if not c:
119
+ break
120
+ id, ch, (xy, dst, src), im = c
121
+ if 0 <= ch < len(self.glyph):
122
+ self.glyph[ch] = xy, dst, src, im
venv/lib/python3.10/site-packages/PIL/BlpImagePlugin.py ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Blizzard Mipmap Format (.blp)
3
+ Jerome Leclanche <jerome@leclan.ch>
4
+
5
+ The contents of this file are hereby released in the public domain (CC0)
6
+ Full text of the CC0 license:
7
+ https://creativecommons.org/publicdomain/zero/1.0/
8
+
9
+ BLP1 files, used mostly in Warcraft III, are not fully supported.
10
+ All types of BLP2 files used in World of Warcraft are supported.
11
+
12
+ The BLP file structure consists of a header, up to 16 mipmaps of the
13
+ texture
14
+
15
+ Texture sizes must be powers of two, though the two dimensions do
16
+ not have to be equal; 512x256 is valid, but 512x200 is not.
17
+ The first mipmap (mipmap #0) is the full size image; each subsequent
18
+ mipmap halves both dimensions. The final mipmap should be 1x1.
19
+
20
+ BLP files come in many different flavours:
21
+ * JPEG-compressed (type == 0) - only supported for BLP1.
22
+ * RAW images (type == 1, encoding == 1). Each mipmap is stored as an
23
+ array of 8-bit values, one per pixel, left to right, top to bottom.
24
+ Each value is an index to the palette.
25
+ * DXT-compressed (type == 1, encoding == 2):
26
+ - DXT1 compression is used if alpha_encoding == 0.
27
+ - An additional alpha bit is used if alpha_depth == 1.
28
+ - DXT3 compression is used if alpha_encoding == 1.
29
+ - DXT5 compression is used if alpha_encoding == 7.
30
+ """
31
+
32
+ import os
33
+ import struct
34
+ from enum import IntEnum
35
+ from io import BytesIO
36
+
37
+ from . import Image, ImageFile
38
+
39
+
40
+ class Format(IntEnum):
41
+ JPEG = 0
42
+
43
+
44
+ class Encoding(IntEnum):
45
+ UNCOMPRESSED = 1
46
+ DXT = 2
47
+ UNCOMPRESSED_RAW_BGRA = 3
48
+
49
+
50
+ class AlphaEncoding(IntEnum):
51
+ DXT1 = 0
52
+ DXT3 = 1
53
+ DXT5 = 7
54
+
55
+
56
+ def unpack_565(i):
57
+ return ((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3
58
+
59
+
60
+ def decode_dxt1(data, alpha=False):
61
+ """
62
+ input: one "row" of data (i.e. will produce 4*width pixels)
63
+ """
64
+
65
+ blocks = len(data) // 8 # number of blocks in row
66
+ ret = (bytearray(), bytearray(), bytearray(), bytearray())
67
+
68
+ for block in range(blocks):
69
+ # Decode next 8-byte block.
70
+ idx = block * 8
71
+ color0, color1, bits = struct.unpack_from("<HHI", data, idx)
72
+
73
+ r0, g0, b0 = unpack_565(color0)
74
+ r1, g1, b1 = unpack_565(color1)
75
+
76
+ # Decode this block into 4x4 pixels
77
+ # Accumulate the results onto our 4 row accumulators
78
+ for j in range(4):
79
+ for i in range(4):
80
+ # get next control op and generate a pixel
81
+
82
+ control = bits & 3
83
+ bits = bits >> 2
84
+
85
+ a = 0xFF
86
+ if control == 0:
87
+ r, g, b = r0, g0, b0
88
+ elif control == 1:
89
+ r, g, b = r1, g1, b1
90
+ elif control == 2:
91
+ if color0 > color1:
92
+ r = (2 * r0 + r1) // 3
93
+ g = (2 * g0 + g1) // 3
94
+ b = (2 * b0 + b1) // 3
95
+ else:
96
+ r = (r0 + r1) // 2
97
+ g = (g0 + g1) // 2
98
+ b = (b0 + b1) // 2
99
+ elif control == 3:
100
+ if color0 > color1:
101
+ r = (2 * r1 + r0) // 3
102
+ g = (2 * g1 + g0) // 3
103
+ b = (2 * b1 + b0) // 3
104
+ else:
105
+ r, g, b, a = 0, 0, 0, 0
106
+
107
+ if alpha:
108
+ ret[j].extend([r, g, b, a])
109
+ else:
110
+ ret[j].extend([r, g, b])
111
+
112
+ return ret
113
+
114
+
115
+ def decode_dxt3(data):
116
+ """
117
+ input: one "row" of data (i.e. will produce 4*width pixels)
118
+ """
119
+
120
+ blocks = len(data) // 16 # number of blocks in row
121
+ ret = (bytearray(), bytearray(), bytearray(), bytearray())
122
+
123
+ for block in range(blocks):
124
+ idx = block * 16
125
+ block = data[idx : idx + 16]
126
+ # Decode next 16-byte block.
127
+ bits = struct.unpack_from("<8B", block)
128
+ color0, color1 = struct.unpack_from("<HH", block, 8)
129
+
130
+ (code,) = struct.unpack_from("<I", block, 12)
131
+
132
+ r0, g0, b0 = unpack_565(color0)
133
+ r1, g1, b1 = unpack_565(color1)
134
+
135
+ for j in range(4):
136
+ high = False # Do we want the higher bits?
137
+ for i in range(4):
138
+ alphacode_index = (4 * j + i) // 2
139
+ a = bits[alphacode_index]
140
+ if high:
141
+ high = False
142
+ a >>= 4
143
+ else:
144
+ high = True
145
+ a &= 0xF
146
+ a *= 17 # We get a value between 0 and 15
147
+
148
+ color_code = (code >> 2 * (4 * j + i)) & 0x03
149
+
150
+ if color_code == 0:
151
+ r, g, b = r0, g0, b0
152
+ elif color_code == 1:
153
+ r, g, b = r1, g1, b1
154
+ elif color_code == 2:
155
+ r = (2 * r0 + r1) // 3
156
+ g = (2 * g0 + g1) // 3
157
+ b = (2 * b0 + b1) // 3
158
+ elif color_code == 3:
159
+ r = (2 * r1 + r0) // 3
160
+ g = (2 * g1 + g0) // 3
161
+ b = (2 * b1 + b0) // 3
162
+
163
+ ret[j].extend([r, g, b, a])
164
+
165
+ return ret
166
+
167
+
168
+ def decode_dxt5(data):
169
+ """
170
+ input: one "row" of data (i.e. will produce 4 * width pixels)
171
+ """
172
+
173
+ blocks = len(data) // 16 # number of blocks in row
174
+ ret = (bytearray(), bytearray(), bytearray(), bytearray())
175
+
176
+ for block in range(blocks):
177
+ idx = block * 16
178
+ block = data[idx : idx + 16]
179
+ # Decode next 16-byte block.
180
+ a0, a1 = struct.unpack_from("<BB", block)
181
+
182
+ bits = struct.unpack_from("<6B", block, 2)
183
+ alphacode1 = bits[2] | (bits[3] << 8) | (bits[4] << 16) | (bits[5] << 24)
184
+ alphacode2 = bits[0] | (bits[1] << 8)
185
+
186
+ color0, color1 = struct.unpack_from("<HH", block, 8)
187
+
188
+ (code,) = struct.unpack_from("<I", block, 12)
189
+
190
+ r0, g0, b0 = unpack_565(color0)
191
+ r1, g1, b1 = unpack_565(color1)
192
+
193
+ for j in range(4):
194
+ for i in range(4):
195
+ # get next control op and generate a pixel
196
+ alphacode_index = 3 * (4 * j + i)
197
+
198
+ if alphacode_index <= 12:
199
+ alphacode = (alphacode2 >> alphacode_index) & 0x07
200
+ elif alphacode_index == 15:
201
+ alphacode = (alphacode2 >> 15) | ((alphacode1 << 1) & 0x06)
202
+ else: # alphacode_index >= 18 and alphacode_index <= 45
203
+ alphacode = (alphacode1 >> (alphacode_index - 16)) & 0x07
204
+
205
+ if alphacode == 0:
206
+ a = a0
207
+ elif alphacode == 1:
208
+ a = a1
209
+ elif a0 > a1:
210
+ a = ((8 - alphacode) * a0 + (alphacode - 1) * a1) // 7
211
+ elif alphacode == 6:
212
+ a = 0
213
+ elif alphacode == 7:
214
+ a = 255
215
+ else:
216
+ a = ((6 - alphacode) * a0 + (alphacode - 1) * a1) // 5
217
+
218
+ color_code = (code >> 2 * (4 * j + i)) & 0x03
219
+
220
+ if color_code == 0:
221
+ r, g, b = r0, g0, b0
222
+ elif color_code == 1:
223
+ r, g, b = r1, g1, b1
224
+ elif color_code == 2:
225
+ r = (2 * r0 + r1) // 3
226
+ g = (2 * g0 + g1) // 3
227
+ b = (2 * b0 + b1) // 3
228
+ elif color_code == 3:
229
+ r = (2 * r1 + r0) // 3
230
+ g = (2 * g1 + g0) // 3
231
+ b = (2 * b1 + b0) // 3
232
+
233
+ ret[j].extend([r, g, b, a])
234
+
235
+ return ret
236
+
237
+
238
+ class BLPFormatError(NotImplementedError):
239
+ pass
240
+
241
+
242
+ def _accept(prefix):
243
+ return prefix[:4] in (b"BLP1", b"BLP2")
244
+
245
+
246
+ class BlpImageFile(ImageFile.ImageFile):
247
+ """
248
+ Blizzard Mipmap Format
249
+ """
250
+
251
+ format = "BLP"
252
+ format_description = "Blizzard Mipmap Format"
253
+
254
+ def _open(self):
255
+ self.magic = self.fp.read(4)
256
+
257
+ self.fp.seek(5, os.SEEK_CUR)
258
+ (self._blp_alpha_depth,) = struct.unpack("<b", self.fp.read(1))
259
+
260
+ self.fp.seek(2, os.SEEK_CUR)
261
+ self._size = struct.unpack("<II", self.fp.read(8))
262
+
263
+ if self.magic in (b"BLP1", b"BLP2"):
264
+ decoder = self.magic.decode()
265
+ else:
266
+ msg = f"Bad BLP magic {repr(self.magic)}"
267
+ raise BLPFormatError(msg)
268
+
269
+ self._mode = "RGBA" if self._blp_alpha_depth else "RGB"
270
+ self.tile = [(decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))]
271
+
272
+
273
+ class _BLPBaseDecoder(ImageFile.PyDecoder):
274
+ _pulls_fd = True
275
+
276
+ def decode(self, buffer):
277
+ try:
278
+ self._read_blp_header()
279
+ self._load()
280
+ except struct.error as e:
281
+ msg = "Truncated BLP file"
282
+ raise OSError(msg) from e
283
+ return -1, 0
284
+
285
+ def _read_blp_header(self):
286
+ self.fd.seek(4)
287
+ (self._blp_compression,) = struct.unpack("<i", self._safe_read(4))
288
+
289
+ (self._blp_encoding,) = struct.unpack("<b", self._safe_read(1))
290
+ (self._blp_alpha_depth,) = struct.unpack("<b", self._safe_read(1))
291
+ (self._blp_alpha_encoding,) = struct.unpack("<b", self._safe_read(1))
292
+ self.fd.seek(1, os.SEEK_CUR) # mips
293
+
294
+ self.size = struct.unpack("<II", self._safe_read(8))
295
+
296
+ if isinstance(self, BLP1Decoder):
297
+ # Only present for BLP1
298
+ (self._blp_encoding,) = struct.unpack("<i", self._safe_read(4))
299
+ self.fd.seek(4, os.SEEK_CUR) # subtype
300
+
301
+ self._blp_offsets = struct.unpack("<16I", self._safe_read(16 * 4))
302
+ self._blp_lengths = struct.unpack("<16I", self._safe_read(16 * 4))
303
+
304
+ def _safe_read(self, length):
305
+ return ImageFile._safe_read(self.fd, length)
306
+
307
+ def _read_palette(self):
308
+ ret = []
309
+ for i in range(256):
310
+ try:
311
+ b, g, r, a = struct.unpack("<4B", self._safe_read(4))
312
+ except struct.error:
313
+ break
314
+ ret.append((b, g, r, a))
315
+ return ret
316
+
317
+ def _read_bgra(self, palette):
318
+ data = bytearray()
319
+ _data = BytesIO(self._safe_read(self._blp_lengths[0]))
320
+ while True:
321
+ try:
322
+ (offset,) = struct.unpack("<B", _data.read(1))
323
+ except struct.error:
324
+ break
325
+ b, g, r, a = palette[offset]
326
+ d = (r, g, b)
327
+ if self._blp_alpha_depth:
328
+ d += (a,)
329
+ data.extend(d)
330
+ return data
331
+
332
+
333
+ class BLP1Decoder(_BLPBaseDecoder):
334
+ def _load(self):
335
+ if self._blp_compression == Format.JPEG:
336
+ self._decode_jpeg_stream()
337
+
338
+ elif self._blp_compression == 1:
339
+ if self._blp_encoding in (4, 5):
340
+ palette = self._read_palette()
341
+ data = self._read_bgra(palette)
342
+ self.set_as_raw(bytes(data))
343
+ else:
344
+ msg = f"Unsupported BLP encoding {repr(self._blp_encoding)}"
345
+ raise BLPFormatError(msg)
346
+ else:
347
+ msg = f"Unsupported BLP compression {repr(self._blp_encoding)}"
348
+ raise BLPFormatError(msg)
349
+
350
+ def _decode_jpeg_stream(self):
351
+ from .JpegImagePlugin import JpegImageFile
352
+
353
+ (jpeg_header_size,) = struct.unpack("<I", self._safe_read(4))
354
+ jpeg_header = self._safe_read(jpeg_header_size)
355
+ self._safe_read(self._blp_offsets[0] - self.fd.tell()) # What IS this?
356
+ data = self._safe_read(self._blp_lengths[0])
357
+ data = jpeg_header + data
358
+ data = BytesIO(data)
359
+ image = JpegImageFile(data)
360
+ Image._decompression_bomb_check(image.size)
361
+ if image.mode == "CMYK":
362
+ decoder_name, extents, offset, args = image.tile[0]
363
+ image.tile = [(decoder_name, extents, offset, (args[0], "CMYK"))]
364
+ r, g, b = image.convert("RGB").split()
365
+ image = Image.merge("RGB", (b, g, r))
366
+ self.set_as_raw(image.tobytes())
367
+
368
+
369
+ class BLP2Decoder(_BLPBaseDecoder):
370
+ def _load(self):
371
+ palette = self._read_palette()
372
+
373
+ self.fd.seek(self._blp_offsets[0])
374
+
375
+ if self._blp_compression == 1:
376
+ # Uncompressed or DirectX compression
377
+
378
+ if self._blp_encoding == Encoding.UNCOMPRESSED:
379
+ data = self._read_bgra(palette)
380
+
381
+ elif self._blp_encoding == Encoding.DXT:
382
+ data = bytearray()
383
+ if self._blp_alpha_encoding == AlphaEncoding.DXT1:
384
+ linesize = (self.size[0] + 3) // 4 * 8
385
+ for yb in range((self.size[1] + 3) // 4):
386
+ for d in decode_dxt1(
387
+ self._safe_read(linesize), alpha=bool(self._blp_alpha_depth)
388
+ ):
389
+ data += d
390
+
391
+ elif self._blp_alpha_encoding == AlphaEncoding.DXT3:
392
+ linesize = (self.size[0] + 3) // 4 * 16
393
+ for yb in range((self.size[1] + 3) // 4):
394
+ for d in decode_dxt3(self._safe_read(linesize)):
395
+ data += d
396
+
397
+ elif self._blp_alpha_encoding == AlphaEncoding.DXT5:
398
+ linesize = (self.size[0] + 3) // 4 * 16
399
+ for yb in range((self.size[1] + 3) // 4):
400
+ for d in decode_dxt5(self._safe_read(linesize)):
401
+ data += d
402
+ else:
403
+ msg = f"Unsupported alpha encoding {repr(self._blp_alpha_encoding)}"
404
+ raise BLPFormatError(msg)
405
+ else:
406
+ msg = f"Unknown BLP encoding {repr(self._blp_encoding)}"
407
+ raise BLPFormatError(msg)
408
+
409
+ else:
410
+ msg = f"Unknown BLP compression {repr(self._blp_compression)}"
411
+ raise BLPFormatError(msg)
412
+
413
+ self.set_as_raw(bytes(data))
414
+
415
+
416
+ class BLPEncoder(ImageFile.PyEncoder):
417
+ _pushes_fd = True
418
+
419
+ def _write_palette(self):
420
+ data = b""
421
+ palette = self.im.getpalette("RGBA", "RGBA")
422
+ for i in range(len(palette) // 4):
423
+ r, g, b, a = palette[i * 4 : (i + 1) * 4]
424
+ data += struct.pack("<4B", b, g, r, a)
425
+ while len(data) < 256 * 4:
426
+ data += b"\x00" * 4
427
+ return data
428
+
429
+ def encode(self, bufsize):
430
+ palette_data = self._write_palette()
431
+
432
+ offset = 20 + 16 * 4 * 2 + len(palette_data)
433
+ data = struct.pack("<16I", offset, *((0,) * 15))
434
+
435
+ w, h = self.im.size
436
+ data += struct.pack("<16I", w * h, *((0,) * 15))
437
+
438
+ data += palette_data
439
+
440
+ for y in range(h):
441
+ for x in range(w):
442
+ data += struct.pack("<B", self.im.getpixel((x, y)))
443
+
444
+ return len(data), 0, data
445
+
446
+
447
+ def _save(im, fp, filename):
448
+ if im.mode != "P":
449
+ msg = "Unsupported BLP image mode"
450
+ raise ValueError(msg)
451
+
452
+ magic = b"BLP1" if im.encoderinfo.get("blp_version") == "BLP1" else b"BLP2"
453
+ fp.write(magic)
454
+
455
+ fp.write(struct.pack("<i", 1)) # Uncompressed or DirectX compression
456
+ fp.write(struct.pack("<b", Encoding.UNCOMPRESSED))
457
+ fp.write(struct.pack("<b", 1 if im.palette.mode == "RGBA" else 0))
458
+ fp.write(struct.pack("<b", 0)) # alpha encoding
459
+ fp.write(struct.pack("<b", 0)) # mips
460
+ fp.write(struct.pack("<II", *im.size))
461
+ if magic == b"BLP1":
462
+ fp.write(struct.pack("<i", 5))
463
+ fp.write(struct.pack("<i", 0))
464
+
465
+ ImageFile._save(im, fp, [("BLP", (0, 0) + im.size, 0, im.mode)])
466
+
467
+
468
+ Image.register_open(BlpImageFile.format, BlpImageFile, _accept)
469
+ Image.register_extension(BlpImageFile.format, ".blp")
470
+ Image.register_decoder("BLP1", BLP1Decoder)
471
+ Image.register_decoder("BLP2", BLP2Decoder)
472
+
473
+ Image.register_save(BlpImageFile.format, _save)
474
+ Image.register_encoder("BLP", BLPEncoder)
venv/lib/python3.10/site-packages/PIL/BmpImagePlugin.py ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library.
3
+ # $Id$
4
+ #
5
+ # BMP file handler
6
+ #
7
+ # Windows (and OS/2) native bitmap storage format.
8
+ #
9
+ # history:
10
+ # 1995-09-01 fl Created
11
+ # 1996-04-30 fl Added save
12
+ # 1997-08-27 fl Fixed save of 1-bit images
13
+ # 1998-03-06 fl Load P images as L where possible
14
+ # 1998-07-03 fl Load P images as 1 where possible
15
+ # 1998-12-29 fl Handle small palettes
16
+ # 2002-12-30 fl Fixed load of 1-bit palette images
17
+ # 2003-04-21 fl Fixed load of 1-bit monochrome images
18
+ # 2003-04-23 fl Added limited support for BI_BITFIELDS compression
19
+ #
20
+ # Copyright (c) 1997-2003 by Secret Labs AB
21
+ # Copyright (c) 1995-2003 by Fredrik Lundh
22
+ #
23
+ # See the README file for information on usage and redistribution.
24
+ #
25
+
26
+
27
+ import os
28
+
29
+ from . import Image, ImageFile, ImagePalette
30
+ from ._binary import i16le as i16
31
+ from ._binary import i32le as i32
32
+ from ._binary import o8
33
+ from ._binary import o16le as o16
34
+ from ._binary import o32le as o32
35
+
36
+ #
37
+ # --------------------------------------------------------------------
38
+ # Read BMP file
39
+
40
+ BIT2MODE = {
41
+ # bits => mode, rawmode
42
+ 1: ("P", "P;1"),
43
+ 4: ("P", "P;4"),
44
+ 8: ("P", "P"),
45
+ 16: ("RGB", "BGR;15"),
46
+ 24: ("RGB", "BGR"),
47
+ 32: ("RGB", "BGRX"),
48
+ }
49
+
50
+
51
+ def _accept(prefix):
52
+ return prefix[:2] == b"BM"
53
+
54
+
55
+ def _dib_accept(prefix):
56
+ return i32(prefix) in [12, 40, 64, 108, 124]
57
+
58
+
59
+ # =============================================================================
60
+ # Image plugin for the Windows BMP format.
61
+ # =============================================================================
62
+ class BmpImageFile(ImageFile.ImageFile):
63
+ """Image plugin for the Windows Bitmap format (BMP)"""
64
+
65
+ # ------------------------------------------------------------- Description
66
+ format_description = "Windows Bitmap"
67
+ format = "BMP"
68
+
69
+ # -------------------------------------------------- BMP Compression values
70
+ COMPRESSIONS = {"RAW": 0, "RLE8": 1, "RLE4": 2, "BITFIELDS": 3, "JPEG": 4, "PNG": 5}
71
+ for k, v in COMPRESSIONS.items():
72
+ vars()[k] = v
73
+
74
+ def _bitmap(self, header=0, offset=0):
75
+ """Read relevant info about the BMP"""
76
+ read, seek = self.fp.read, self.fp.seek
77
+ if header:
78
+ seek(header)
79
+ # read bmp header size @offset 14 (this is part of the header size)
80
+ file_info = {"header_size": i32(read(4)), "direction": -1}
81
+
82
+ # -------------------- If requested, read header at a specific position
83
+ # read the rest of the bmp header, without its size
84
+ header_data = ImageFile._safe_read(self.fp, file_info["header_size"] - 4)
85
+
86
+ # -------------------------------------------------- IBM OS/2 Bitmap v1
87
+ # ----- This format has different offsets because of width/height types
88
+ if file_info["header_size"] == 12:
89
+ file_info["width"] = i16(header_data, 0)
90
+ file_info["height"] = i16(header_data, 2)
91
+ file_info["planes"] = i16(header_data, 4)
92
+ file_info["bits"] = i16(header_data, 6)
93
+ file_info["compression"] = self.RAW
94
+ file_info["palette_padding"] = 3
95
+
96
+ # --------------------------------------------- Windows Bitmap v2 to v5
97
+ # v3, OS/2 v2, v4, v5
98
+ elif file_info["header_size"] in (40, 64, 108, 124):
99
+ file_info["y_flip"] = header_data[7] == 0xFF
100
+ file_info["direction"] = 1 if file_info["y_flip"] else -1
101
+ file_info["width"] = i32(header_data, 0)
102
+ file_info["height"] = (
103
+ i32(header_data, 4)
104
+ if not file_info["y_flip"]
105
+ else 2**32 - i32(header_data, 4)
106
+ )
107
+ file_info["planes"] = i16(header_data, 8)
108
+ file_info["bits"] = i16(header_data, 10)
109
+ file_info["compression"] = i32(header_data, 12)
110
+ # byte size of pixel data
111
+ file_info["data_size"] = i32(header_data, 16)
112
+ file_info["pixels_per_meter"] = (
113
+ i32(header_data, 20),
114
+ i32(header_data, 24),
115
+ )
116
+ file_info["colors"] = i32(header_data, 28)
117
+ file_info["palette_padding"] = 4
118
+ self.info["dpi"] = tuple(x / 39.3701 for x in file_info["pixels_per_meter"])
119
+ if file_info["compression"] == self.BITFIELDS:
120
+ if len(header_data) >= 52:
121
+ for idx, mask in enumerate(
122
+ ["r_mask", "g_mask", "b_mask", "a_mask"]
123
+ ):
124
+ file_info[mask] = i32(header_data, 36 + idx * 4)
125
+ else:
126
+ # 40 byte headers only have the three components in the
127
+ # bitfields masks, ref:
128
+ # https://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx
129
+ # See also
130
+ # https://github.com/python-pillow/Pillow/issues/1293
131
+ # There is a 4th component in the RGBQuad, in the alpha
132
+ # location, but it is listed as a reserved component,
133
+ # and it is not generally an alpha channel
134
+ file_info["a_mask"] = 0x0
135
+ for mask in ["r_mask", "g_mask", "b_mask"]:
136
+ file_info[mask] = i32(read(4))
137
+ file_info["rgb_mask"] = (
138
+ file_info["r_mask"],
139
+ file_info["g_mask"],
140
+ file_info["b_mask"],
141
+ )
142
+ file_info["rgba_mask"] = (
143
+ file_info["r_mask"],
144
+ file_info["g_mask"],
145
+ file_info["b_mask"],
146
+ file_info["a_mask"],
147
+ )
148
+ else:
149
+ msg = f"Unsupported BMP header type ({file_info['header_size']})"
150
+ raise OSError(msg)
151
+
152
+ # ------------------ Special case : header is reported 40, which
153
+ # ---------------------- is shorter than real size for bpp >= 16
154
+ self._size = file_info["width"], file_info["height"]
155
+
156
+ # ------- If color count was not found in the header, compute from bits
157
+ file_info["colors"] = (
158
+ file_info["colors"]
159
+ if file_info.get("colors", 0)
160
+ else (1 << file_info["bits"])
161
+ )
162
+ if offset == 14 + file_info["header_size"] and file_info["bits"] <= 8:
163
+ offset += 4 * file_info["colors"]
164
+
165
+ # ---------------------- Check bit depth for unusual unsupported values
166
+ self._mode, raw_mode = BIT2MODE.get(file_info["bits"], (None, None))
167
+ if self.mode is None:
168
+ msg = f"Unsupported BMP pixel depth ({file_info['bits']})"
169
+ raise OSError(msg)
170
+
171
+ # ---------------- Process BMP with Bitfields compression (not palette)
172
+ decoder_name = "raw"
173
+ if file_info["compression"] == self.BITFIELDS:
174
+ SUPPORTED = {
175
+ 32: [
176
+ (0xFF0000, 0xFF00, 0xFF, 0x0),
177
+ (0xFF000000, 0xFF0000, 0xFF00, 0x0),
178
+ (0xFF000000, 0xFF0000, 0xFF00, 0xFF),
179
+ (0xFF, 0xFF00, 0xFF0000, 0xFF000000),
180
+ (0xFF0000, 0xFF00, 0xFF, 0xFF000000),
181
+ (0x0, 0x0, 0x0, 0x0),
182
+ ],
183
+ 24: [(0xFF0000, 0xFF00, 0xFF)],
184
+ 16: [(0xF800, 0x7E0, 0x1F), (0x7C00, 0x3E0, 0x1F)],
185
+ }
186
+ MASK_MODES = {
187
+ (32, (0xFF0000, 0xFF00, 0xFF, 0x0)): "BGRX",
188
+ (32, (0xFF000000, 0xFF0000, 0xFF00, 0x0)): "XBGR",
189
+ (32, (0xFF000000, 0xFF0000, 0xFF00, 0xFF)): "ABGR",
190
+ (32, (0xFF, 0xFF00, 0xFF0000, 0xFF000000)): "RGBA",
191
+ (32, (0xFF0000, 0xFF00, 0xFF, 0xFF000000)): "BGRA",
192
+ (32, (0x0, 0x0, 0x0, 0x0)): "BGRA",
193
+ (24, (0xFF0000, 0xFF00, 0xFF)): "BGR",
194
+ (16, (0xF800, 0x7E0, 0x1F)): "BGR;16",
195
+ (16, (0x7C00, 0x3E0, 0x1F)): "BGR;15",
196
+ }
197
+ if file_info["bits"] in SUPPORTED:
198
+ if (
199
+ file_info["bits"] == 32
200
+ and file_info["rgba_mask"] in SUPPORTED[file_info["bits"]]
201
+ ):
202
+ raw_mode = MASK_MODES[(file_info["bits"], file_info["rgba_mask"])]
203
+ self._mode = "RGBA" if "A" in raw_mode else self.mode
204
+ elif (
205
+ file_info["bits"] in (24, 16)
206
+ and file_info["rgb_mask"] in SUPPORTED[file_info["bits"]]
207
+ ):
208
+ raw_mode = MASK_MODES[(file_info["bits"], file_info["rgb_mask"])]
209
+ else:
210
+ msg = "Unsupported BMP bitfields layout"
211
+ raise OSError(msg)
212
+ else:
213
+ msg = "Unsupported BMP bitfields layout"
214
+ raise OSError(msg)
215
+ elif file_info["compression"] == self.RAW:
216
+ if file_info["bits"] == 32 and header == 22: # 32-bit .cur offset
217
+ raw_mode, self._mode = "BGRA", "RGBA"
218
+ elif file_info["compression"] in (self.RLE8, self.RLE4):
219
+ decoder_name = "bmp_rle"
220
+ else:
221
+ msg = f"Unsupported BMP compression ({file_info['compression']})"
222
+ raise OSError(msg)
223
+
224
+ # --------------- Once the header is processed, process the palette/LUT
225
+ if self.mode == "P": # Paletted for 1, 4 and 8 bit images
226
+ # ---------------------------------------------------- 1-bit images
227
+ if not (0 < file_info["colors"] <= 65536):
228
+ msg = f"Unsupported BMP Palette size ({file_info['colors']})"
229
+ raise OSError(msg)
230
+ else:
231
+ padding = file_info["palette_padding"]
232
+ palette = read(padding * file_info["colors"])
233
+ greyscale = True
234
+ indices = (
235
+ (0, 255)
236
+ if file_info["colors"] == 2
237
+ else list(range(file_info["colors"]))
238
+ )
239
+
240
+ # ----------------- Check if greyscale and ignore palette if so
241
+ for ind, val in enumerate(indices):
242
+ rgb = palette[ind * padding : ind * padding + 3]
243
+ if rgb != o8(val) * 3:
244
+ greyscale = False
245
+
246
+ # ------- If all colors are grey, white or black, ditch palette
247
+ if greyscale:
248
+ self._mode = "1" if file_info["colors"] == 2 else "L"
249
+ raw_mode = self.mode
250
+ else:
251
+ self._mode = "P"
252
+ self.palette = ImagePalette.raw(
253
+ "BGRX" if padding == 4 else "BGR", palette
254
+ )
255
+
256
+ # ---------------------------- Finally set the tile data for the plugin
257
+ self.info["compression"] = file_info["compression"]
258
+ args = [raw_mode]
259
+ if decoder_name == "bmp_rle":
260
+ args.append(file_info["compression"] == self.RLE4)
261
+ else:
262
+ args.append(((file_info["width"] * file_info["bits"] + 31) >> 3) & (~3))
263
+ args.append(file_info["direction"])
264
+ self.tile = [
265
+ (
266
+ decoder_name,
267
+ (0, 0, file_info["width"], file_info["height"]),
268
+ offset or self.fp.tell(),
269
+ tuple(args),
270
+ )
271
+ ]
272
+
273
+ def _open(self):
274
+ """Open file, check magic number and read header"""
275
+ # read 14 bytes: magic number, filesize, reserved, header final offset
276
+ head_data = self.fp.read(14)
277
+ # choke if the file does not have the required magic bytes
278
+ if not _accept(head_data):
279
+ msg = "Not a BMP file"
280
+ raise SyntaxError(msg)
281
+ # read the start position of the BMP image data (u32)
282
+ offset = i32(head_data, 10)
283
+ # load bitmap information (offset=raster info)
284
+ self._bitmap(offset=offset)
285
+
286
+
287
+ class BmpRleDecoder(ImageFile.PyDecoder):
288
+ _pulls_fd = True
289
+
290
+ def decode(self, buffer):
291
+ rle4 = self.args[1]
292
+ data = bytearray()
293
+ x = 0
294
+ while len(data) < self.state.xsize * self.state.ysize:
295
+ pixels = self.fd.read(1)
296
+ byte = self.fd.read(1)
297
+ if not pixels or not byte:
298
+ break
299
+ num_pixels = pixels[0]
300
+ if num_pixels:
301
+ # encoded mode
302
+ if x + num_pixels > self.state.xsize:
303
+ # Too much data for row
304
+ num_pixels = max(0, self.state.xsize - x)
305
+ if rle4:
306
+ first_pixel = o8(byte[0] >> 4)
307
+ second_pixel = o8(byte[0] & 0x0F)
308
+ for index in range(num_pixels):
309
+ if index % 2 == 0:
310
+ data += first_pixel
311
+ else:
312
+ data += second_pixel
313
+ else:
314
+ data += byte * num_pixels
315
+ x += num_pixels
316
+ else:
317
+ if byte[0] == 0:
318
+ # end of line
319
+ while len(data) % self.state.xsize != 0:
320
+ data += b"\x00"
321
+ x = 0
322
+ elif byte[0] == 1:
323
+ # end of bitmap
324
+ break
325
+ elif byte[0] == 2:
326
+ # delta
327
+ bytes_read = self.fd.read(2)
328
+ if len(bytes_read) < 2:
329
+ break
330
+ right, up = self.fd.read(2)
331
+ data += b"\x00" * (right + up * self.state.xsize)
332
+ x = len(data) % self.state.xsize
333
+ else:
334
+ # absolute mode
335
+ if rle4:
336
+ # 2 pixels per byte
337
+ byte_count = byte[0] // 2
338
+ bytes_read = self.fd.read(byte_count)
339
+ for byte_read in bytes_read:
340
+ data += o8(byte_read >> 4)
341
+ data += o8(byte_read & 0x0F)
342
+ else:
343
+ byte_count = byte[0]
344
+ bytes_read = self.fd.read(byte_count)
345
+ data += bytes_read
346
+ if len(bytes_read) < byte_count:
347
+ break
348
+ x += byte[0]
349
+
350
+ # align to 16-bit word boundary
351
+ if self.fd.tell() % 2 != 0:
352
+ self.fd.seek(1, os.SEEK_CUR)
353
+ rawmode = "L" if self.mode == "L" else "P"
354
+ self.set_as_raw(bytes(data), (rawmode, 0, self.args[-1]))
355
+ return -1, 0
356
+
357
+
358
+ # =============================================================================
359
+ # Image plugin for the DIB format (BMP alias)
360
+ # =============================================================================
361
+ class DibImageFile(BmpImageFile):
362
+ format = "DIB"
363
+ format_description = "Windows Bitmap"
364
+
365
+ def _open(self):
366
+ self._bitmap()
367
+
368
+
369
+ #
370
+ # --------------------------------------------------------------------
371
+ # Write BMP file
372
+
373
+
374
+ SAVE = {
375
+ "1": ("1", 1, 2),
376
+ "L": ("L", 8, 256),
377
+ "P": ("P", 8, 256),
378
+ "RGB": ("BGR", 24, 0),
379
+ "RGBA": ("BGRA", 32, 0),
380
+ }
381
+
382
+
383
+ def _dib_save(im, fp, filename):
384
+ _save(im, fp, filename, False)
385
+
386
+
387
+ def _save(im, fp, filename, bitmap_header=True):
388
+ try:
389
+ rawmode, bits, colors = SAVE[im.mode]
390
+ except KeyError as e:
391
+ msg = f"cannot write mode {im.mode} as BMP"
392
+ raise OSError(msg) from e
393
+
394
+ info = im.encoderinfo
395
+
396
+ dpi = info.get("dpi", (96, 96))
397
+
398
+ # 1 meter == 39.3701 inches
399
+ ppm = tuple(map(lambda x: int(x * 39.3701 + 0.5), dpi))
400
+
401
+ stride = ((im.size[0] * bits + 7) // 8 + 3) & (~3)
402
+ header = 40 # or 64 for OS/2 version 2
403
+ image = stride * im.size[1]
404
+
405
+ if im.mode == "1":
406
+ palette = b"".join(o8(i) * 4 for i in (0, 255))
407
+ elif im.mode == "L":
408
+ palette = b"".join(o8(i) * 4 for i in range(256))
409
+ elif im.mode == "P":
410
+ palette = im.im.getpalette("RGB", "BGRX")
411
+ colors = len(palette) // 4
412
+ else:
413
+ palette = None
414
+
415
+ # bitmap header
416
+ if bitmap_header:
417
+ offset = 14 + header + colors * 4
418
+ file_size = offset + image
419
+ if file_size > 2**32 - 1:
420
+ msg = "File size is too large for the BMP format"
421
+ raise ValueError(msg)
422
+ fp.write(
423
+ b"BM" # file type (magic)
424
+ + o32(file_size) # file size
425
+ + o32(0) # reserved
426
+ + o32(offset) # image data offset
427
+ )
428
+
429
+ # bitmap info header
430
+ fp.write(
431
+ o32(header) # info header size
432
+ + o32(im.size[0]) # width
433
+ + o32(im.size[1]) # height
434
+ + o16(1) # planes
435
+ + o16(bits) # depth
436
+ + o32(0) # compression (0=uncompressed)
437
+ + o32(image) # size of bitmap
438
+ + o32(ppm[0]) # resolution
439
+ + o32(ppm[1]) # resolution
440
+ + o32(colors) # colors used
441
+ + o32(colors) # colors important
442
+ )
443
+
444
+ fp.write(b"\0" * (header - 40)) # padding (for OS/2 format)
445
+
446
+ if palette:
447
+ fp.write(palette)
448
+
449
+ ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, stride, -1))])
450
+
451
+
452
+ #
453
+ # --------------------------------------------------------------------
454
+ # Registry
455
+
456
+
457
+ Image.register_open(BmpImageFile.format, BmpImageFile, _accept)
458
+ Image.register_save(BmpImageFile.format, _save)
459
+
460
+ Image.register_extension(BmpImageFile.format, ".bmp")
461
+
462
+ Image.register_mime(BmpImageFile.format, "image/bmp")
463
+
464
+ Image.register_decoder("bmp_rle", BmpRleDecoder)
465
+
466
+ Image.register_open(DibImageFile.format, DibImageFile, _dib_accept)
467
+ Image.register_save(DibImageFile.format, _dib_save)
468
+
469
+ Image.register_extension(DibImageFile.format, ".dib")
470
+
471
+ Image.register_mime(DibImageFile.format, "image/bmp")
venv/lib/python3.10/site-packages/PIL/BufrStubImagePlugin.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library
3
+ # $Id$
4
+ #
5
+ # BUFR stub adapter
6
+ #
7
+ # Copyright (c) 1996-2003 by Fredrik Lundh
8
+ #
9
+ # See the README file for information on usage and redistribution.
10
+ #
11
+
12
+ from . import Image, ImageFile
13
+
14
+ _handler = None
15
+
16
+
17
+ def register_handler(handler):
18
+ """
19
+ Install application-specific BUFR image handler.
20
+
21
+ :param handler: Handler object.
22
+ """
23
+ global _handler
24
+ _handler = handler
25
+
26
+
27
+ # --------------------------------------------------------------------
28
+ # Image adapter
29
+
30
+
31
+ def _accept(prefix):
32
+ return prefix[:4] == b"BUFR" or prefix[:4] == b"ZCZC"
33
+
34
+
35
+ class BufrStubImageFile(ImageFile.StubImageFile):
36
+ format = "BUFR"
37
+ format_description = "BUFR"
38
+
39
+ def _open(self):
40
+ offset = self.fp.tell()
41
+
42
+ if not _accept(self.fp.read(4)):
43
+ msg = "Not a BUFR file"
44
+ raise SyntaxError(msg)
45
+
46
+ self.fp.seek(offset)
47
+
48
+ # make something up
49
+ self._mode = "F"
50
+ self._size = 1, 1
51
+
52
+ loader = self._load()
53
+ if loader:
54
+ loader.open(self)
55
+
56
+ def _load(self):
57
+ return _handler
58
+
59
+
60
+ def _save(im, fp, filename):
61
+ if _handler is None or not hasattr(_handler, "save"):
62
+ msg = "BUFR save handler not installed"
63
+ raise OSError(msg)
64
+ _handler.save(im, fp, filename)
65
+
66
+
67
+ # --------------------------------------------------------------------
68
+ # Registry
69
+
70
+ Image.register_open(BufrStubImageFile.format, BufrStubImageFile, _accept)
71
+ Image.register_save(BufrStubImageFile.format, _save)
72
+
73
+ Image.register_extension(BufrStubImageFile.format, ".bufr")
venv/lib/python3.10/site-packages/PIL/ContainerIO.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library.
3
+ # $Id$
4
+ #
5
+ # a class to read from a container file
6
+ #
7
+ # History:
8
+ # 1995-06-18 fl Created
9
+ # 1995-09-07 fl Added readline(), readlines()
10
+ #
11
+ # Copyright (c) 1997-2001 by Secret Labs AB
12
+ # Copyright (c) 1995 by Fredrik Lundh
13
+ #
14
+ # See the README file for information on usage and redistribution.
15
+ #
16
+
17
+
18
+ import io
19
+
20
+
21
+ class ContainerIO:
22
+ """
23
+ A file object that provides read access to a part of an existing
24
+ file (for example a TAR file).
25
+ """
26
+
27
+ def __init__(self, file, offset, length):
28
+ """
29
+ Create file object.
30
+
31
+ :param file: Existing file.
32
+ :param offset: Start of region, in bytes.
33
+ :param length: Size of region, in bytes.
34
+ """
35
+ self.fh = file
36
+ self.pos = 0
37
+ self.offset = offset
38
+ self.length = length
39
+ self.fh.seek(offset)
40
+
41
+ ##
42
+ # Always false.
43
+
44
+ def isatty(self):
45
+ return False
46
+
47
+ def seek(self, offset, mode=io.SEEK_SET):
48
+ """
49
+ Move file pointer.
50
+
51
+ :param offset: Offset in bytes.
52
+ :param mode: Starting position. Use 0 for beginning of region, 1
53
+ for current offset, and 2 for end of region. You cannot move
54
+ the pointer outside the defined region.
55
+ """
56
+ if mode == 1:
57
+ self.pos = self.pos + offset
58
+ elif mode == 2:
59
+ self.pos = self.length + offset
60
+ else:
61
+ self.pos = offset
62
+ # clamp
63
+ self.pos = max(0, min(self.pos, self.length))
64
+ self.fh.seek(self.offset + self.pos)
65
+
66
+ def tell(self):
67
+ """
68
+ Get current file pointer.
69
+
70
+ :returns: Offset from start of region, in bytes.
71
+ """
72
+ return self.pos
73
+
74
+ def read(self, n=0):
75
+ """
76
+ Read data.
77
+
78
+ :param n: Number of bytes to read. If omitted or zero,
79
+ read until end of region.
80
+ :returns: An 8-bit string.
81
+ """
82
+ if n:
83
+ n = min(n, self.length - self.pos)
84
+ else:
85
+ n = self.length - self.pos
86
+ if not n: # EOF
87
+ return b"" if "b" in self.fh.mode else ""
88
+ self.pos = self.pos + n
89
+ return self.fh.read(n)
90
+
91
+ def readline(self):
92
+ """
93
+ Read a line of text.
94
+
95
+ :returns: An 8-bit string.
96
+ """
97
+ s = b"" if "b" in self.fh.mode else ""
98
+ newline_character = b"\n" if "b" in self.fh.mode else "\n"
99
+ while True:
100
+ c = self.read(1)
101
+ if not c:
102
+ break
103
+ s = s + c
104
+ if c == newline_character:
105
+ break
106
+ return s
107
+
108
+ def readlines(self):
109
+ """
110
+ Read multiple lines of text.
111
+
112
+ :returns: A list of 8-bit strings.
113
+ """
114
+ lines = []
115
+ while True:
116
+ s = self.readline()
117
+ if not s:
118
+ break
119
+ lines.append(s)
120
+ return lines
venv/lib/python3.10/site-packages/PIL/CurImagePlugin.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library.
3
+ # $Id$
4
+ #
5
+ # Windows Cursor support for PIL
6
+ #
7
+ # notes:
8
+ # uses BmpImagePlugin.py to read the bitmap data.
9
+ #
10
+ # history:
11
+ # 96-05-27 fl Created
12
+ #
13
+ # Copyright (c) Secret Labs AB 1997.
14
+ # Copyright (c) Fredrik Lundh 1996.
15
+ #
16
+ # See the README file for information on usage and redistribution.
17
+ #
18
+ from . import BmpImagePlugin, Image
19
+ from ._binary import i16le as i16
20
+ from ._binary import i32le as i32
21
+
22
+ #
23
+ # --------------------------------------------------------------------
24
+
25
+
26
+ def _accept(prefix):
27
+ return prefix[:4] == b"\0\0\2\0"
28
+
29
+
30
+ ##
31
+ # Image plugin for Windows Cursor files.
32
+
33
+
34
+ class CurImageFile(BmpImagePlugin.BmpImageFile):
35
+ format = "CUR"
36
+ format_description = "Windows Cursor"
37
+
38
+ def _open(self):
39
+ offset = self.fp.tell()
40
+
41
+ # check magic
42
+ s = self.fp.read(6)
43
+ if not _accept(s):
44
+ msg = "not a CUR file"
45
+ raise SyntaxError(msg)
46
+
47
+ # pick the largest cursor in the file
48
+ m = b""
49
+ for i in range(i16(s, 4)):
50
+ s = self.fp.read(16)
51
+ if not m:
52
+ m = s
53
+ elif s[0] > m[0] and s[1] > m[1]:
54
+ m = s
55
+ if not m:
56
+ msg = "No cursors were found"
57
+ raise TypeError(msg)
58
+
59
+ # load as bitmap
60
+ self._bitmap(i32(m, 12) + offset)
61
+
62
+ # patch up the bitmap height
63
+ self._size = self.size[0], self.size[1] // 2
64
+ d, e, o, a = self.tile[0]
65
+ self.tile[0] = d, (0, 0) + self.size, o, a
66
+
67
+ return
68
+
69
+
70
+ #
71
+ # --------------------------------------------------------------------
72
+
73
+ Image.register_open(CurImageFile.format, CurImageFile, _accept)
74
+
75
+ Image.register_extension(CurImageFile.format, ".cur")
venv/lib/python3.10/site-packages/PIL/DcxImagePlugin.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library.
3
+ # $Id$
4
+ #
5
+ # DCX file handling
6
+ #
7
+ # DCX is a container file format defined by Intel, commonly used
8
+ # for fax applications. Each DCX file consists of a directory
9
+ # (a list of file offsets) followed by a set of (usually 1-bit)
10
+ # PCX files.
11
+ #
12
+ # History:
13
+ # 1995-09-09 fl Created
14
+ # 1996-03-20 fl Properly derived from PcxImageFile.
15
+ # 1998-07-15 fl Renamed offset attribute to avoid name clash
16
+ # 2002-07-30 fl Fixed file handling
17
+ #
18
+ # Copyright (c) 1997-98 by Secret Labs AB.
19
+ # Copyright (c) 1995-96 by Fredrik Lundh.
20
+ #
21
+ # See the README file for information on usage and redistribution.
22
+ #
23
+
24
+ from . import Image
25
+ from ._binary import i32le as i32
26
+ from .PcxImagePlugin import PcxImageFile
27
+
28
+ MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then?
29
+
30
+
31
+ def _accept(prefix):
32
+ return len(prefix) >= 4 and i32(prefix) == MAGIC
33
+
34
+
35
+ ##
36
+ # Image plugin for the Intel DCX format.
37
+
38
+
39
+ class DcxImageFile(PcxImageFile):
40
+ format = "DCX"
41
+ format_description = "Intel DCX"
42
+ _close_exclusive_fp_after_loading = False
43
+
44
+ def _open(self):
45
+ # Header
46
+ s = self.fp.read(4)
47
+ if not _accept(s):
48
+ msg = "not a DCX file"
49
+ raise SyntaxError(msg)
50
+
51
+ # Component directory
52
+ self._offset = []
53
+ for i in range(1024):
54
+ offset = i32(self.fp.read(4))
55
+ if not offset:
56
+ break
57
+ self._offset.append(offset)
58
+
59
+ self._fp = self.fp
60
+ self.frame = None
61
+ self.n_frames = len(self._offset)
62
+ self.is_animated = self.n_frames > 1
63
+ self.seek(0)
64
+
65
+ def seek(self, frame):
66
+ if not self._seek_check(frame):
67
+ return
68
+ self.frame = frame
69
+ self.fp = self._fp
70
+ self.fp.seek(self._offset[frame])
71
+ PcxImageFile._open(self)
72
+
73
+ def tell(self):
74
+ return self.frame
75
+
76
+
77
+ Image.register_open(DcxImageFile.format, DcxImageFile, _accept)
78
+
79
+ Image.register_extension(DcxImageFile.format, ".dcx")
venv/lib/python3.10/site-packages/PIL/DdsImagePlugin.py ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A Pillow loader for .dds files (S3TC-compressed aka DXTC)
3
+ Jerome Leclanche <jerome@leclan.ch>
4
+
5
+ Documentation:
6
+ https://web.archive.org/web/20170802060935/http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_compression_s3tc.txt
7
+
8
+ The contents of this file are hereby released in the public domain (CC0)
9
+ Full text of the CC0 license:
10
+ https://creativecommons.org/publicdomain/zero/1.0/
11
+ """
12
+
13
+ import struct
14
+ from io import BytesIO
15
+
16
+ from . import Image, ImageFile, ImagePalette
17
+ from ._binary import o32le as o32
18
+
19
+ # Magic ("DDS ")
20
+ DDS_MAGIC = 0x20534444
21
+
22
+ # DDS flags
23
+ DDSD_CAPS = 0x1
24
+ DDSD_HEIGHT = 0x2
25
+ DDSD_WIDTH = 0x4
26
+ DDSD_PITCH = 0x8
27
+ DDSD_PIXELFORMAT = 0x1000
28
+ DDSD_MIPMAPCOUNT = 0x20000
29
+ DDSD_LINEARSIZE = 0x80000
30
+ DDSD_DEPTH = 0x800000
31
+
32
+ # DDS caps
33
+ DDSCAPS_COMPLEX = 0x8
34
+ DDSCAPS_TEXTURE = 0x1000
35
+ DDSCAPS_MIPMAP = 0x400000
36
+
37
+ DDSCAPS2_CUBEMAP = 0x200
38
+ DDSCAPS2_CUBEMAP_POSITIVEX = 0x400
39
+ DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800
40
+ DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000
41
+ DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000
42
+ DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000
43
+ DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000
44
+ DDSCAPS2_VOLUME = 0x200000
45
+
46
+ # Pixel Format
47
+ DDPF_ALPHAPIXELS = 0x1
48
+ DDPF_ALPHA = 0x2
49
+ DDPF_FOURCC = 0x4
50
+ DDPF_PALETTEINDEXED8 = 0x20
51
+ DDPF_RGB = 0x40
52
+ DDPF_LUMINANCE = 0x20000
53
+
54
+
55
+ # dds.h
56
+
57
+ DDS_FOURCC = DDPF_FOURCC
58
+ DDS_RGB = DDPF_RGB
59
+ DDS_RGBA = DDPF_RGB | DDPF_ALPHAPIXELS
60
+ DDS_LUMINANCE = DDPF_LUMINANCE
61
+ DDS_LUMINANCEA = DDPF_LUMINANCE | DDPF_ALPHAPIXELS
62
+ DDS_ALPHA = DDPF_ALPHA
63
+ DDS_PAL8 = DDPF_PALETTEINDEXED8
64
+
65
+ DDS_HEADER_FLAGS_TEXTURE = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
66
+ DDS_HEADER_FLAGS_MIPMAP = DDSD_MIPMAPCOUNT
67
+ DDS_HEADER_FLAGS_VOLUME = DDSD_DEPTH
68
+ DDS_HEADER_FLAGS_PITCH = DDSD_PITCH
69
+ DDS_HEADER_FLAGS_LINEARSIZE = DDSD_LINEARSIZE
70
+
71
+ DDS_HEIGHT = DDSD_HEIGHT
72
+ DDS_WIDTH = DDSD_WIDTH
73
+
74
+ DDS_SURFACE_FLAGS_TEXTURE = DDSCAPS_TEXTURE
75
+ DDS_SURFACE_FLAGS_MIPMAP = DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
76
+ DDS_SURFACE_FLAGS_CUBEMAP = DDSCAPS_COMPLEX
77
+
78
+ DDS_CUBEMAP_POSITIVEX = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
79
+ DDS_CUBEMAP_NEGATIVEX = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
80
+ DDS_CUBEMAP_POSITIVEY = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY
81
+ DDS_CUBEMAP_NEGATIVEY = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY
82
+ DDS_CUBEMAP_POSITIVEZ = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ
83
+ DDS_CUBEMAP_NEGATIVEZ = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ
84
+
85
+
86
+ # DXT1
87
+ DXT1_FOURCC = 0x31545844
88
+
89
+ # DXT3
90
+ DXT3_FOURCC = 0x33545844
91
+
92
+ # DXT5
93
+ DXT5_FOURCC = 0x35545844
94
+
95
+
96
+ # dxgiformat.h
97
+
98
+ DXGI_FORMAT_R8G8B8A8_TYPELESS = 27
99
+ DXGI_FORMAT_R8G8B8A8_UNORM = 28
100
+ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29
101
+ DXGI_FORMAT_BC5_TYPELESS = 82
102
+ DXGI_FORMAT_BC5_UNORM = 83
103
+ DXGI_FORMAT_BC5_SNORM = 84
104
+ DXGI_FORMAT_BC6H_UF16 = 95
105
+ DXGI_FORMAT_BC6H_SF16 = 96
106
+ DXGI_FORMAT_BC7_TYPELESS = 97
107
+ DXGI_FORMAT_BC7_UNORM = 98
108
+ DXGI_FORMAT_BC7_UNORM_SRGB = 99
109
+
110
+
111
+ class DdsImageFile(ImageFile.ImageFile):
112
+ format = "DDS"
113
+ format_description = "DirectDraw Surface"
114
+
115
+ def _open(self):
116
+ if not _accept(self.fp.read(4)):
117
+ msg = "not a DDS file"
118
+ raise SyntaxError(msg)
119
+ (header_size,) = struct.unpack("<I", self.fp.read(4))
120
+ if header_size != 124:
121
+ msg = f"Unsupported header size {repr(header_size)}"
122
+ raise OSError(msg)
123
+ header_bytes = self.fp.read(header_size - 4)
124
+ if len(header_bytes) != 120:
125
+ msg = f"Incomplete header: {len(header_bytes)} bytes"
126
+ raise OSError(msg)
127
+ header = BytesIO(header_bytes)
128
+
129
+ flags, height, width = struct.unpack("<3I", header.read(12))
130
+ self._size = (width, height)
131
+ self._mode = "RGBA"
132
+
133
+ pitch, depth, mipmaps = struct.unpack("<3I", header.read(12))
134
+ struct.unpack("<11I", header.read(44)) # reserved
135
+
136
+ # pixel format
137
+ pfsize, pfflags = struct.unpack("<2I", header.read(8))
138
+ fourcc = header.read(4)
139
+ (bitcount,) = struct.unpack("<I", header.read(4))
140
+ masks = struct.unpack("<4I", header.read(16))
141
+ if pfflags & DDPF_LUMINANCE:
142
+ # Texture contains uncompressed L or LA data
143
+ if pfflags & DDPF_ALPHAPIXELS:
144
+ self._mode = "LA"
145
+ else:
146
+ self._mode = "L"
147
+
148
+ self.tile = [("raw", (0, 0) + self.size, 0, (self.mode, 0, 1))]
149
+ elif pfflags & DDPF_RGB:
150
+ # Texture contains uncompressed RGB data
151
+ masks = {mask: ["R", "G", "B", "A"][i] for i, mask in enumerate(masks)}
152
+ rawmode = ""
153
+ if pfflags & DDPF_ALPHAPIXELS:
154
+ rawmode += masks[0xFF000000]
155
+ else:
156
+ self._mode = "RGB"
157
+ rawmode += masks[0xFF0000] + masks[0xFF00] + masks[0xFF]
158
+
159
+ self.tile = [("raw", (0, 0) + self.size, 0, (rawmode[::-1], 0, 1))]
160
+ elif pfflags & DDPF_PALETTEINDEXED8:
161
+ self._mode = "P"
162
+ self.palette = ImagePalette.raw("RGBA", self.fp.read(1024))
163
+ self.tile = [("raw", (0, 0) + self.size, 0, "L")]
164
+ else:
165
+ data_start = header_size + 4
166
+ n = 0
167
+ if fourcc == b"DXT1":
168
+ self.pixel_format = "DXT1"
169
+ n = 1
170
+ elif fourcc == b"DXT3":
171
+ self.pixel_format = "DXT3"
172
+ n = 2
173
+ elif fourcc == b"DXT5":
174
+ self.pixel_format = "DXT5"
175
+ n = 3
176
+ elif fourcc == b"ATI1":
177
+ self.pixel_format = "BC4"
178
+ n = 4
179
+ self._mode = "L"
180
+ elif fourcc in (b"ATI2", b"BC5U"):
181
+ self.pixel_format = "BC5"
182
+ n = 5
183
+ self._mode = "RGB"
184
+ elif fourcc == b"BC5S":
185
+ self.pixel_format = "BC5S"
186
+ n = 5
187
+ self._mode = "RGB"
188
+ elif fourcc == b"DX10":
189
+ data_start += 20
190
+ # ignoring flags which pertain to volume textures and cubemaps
191
+ (dxgi_format,) = struct.unpack("<I", self.fp.read(4))
192
+ self.fp.read(16)
193
+ if dxgi_format in (DXGI_FORMAT_BC5_TYPELESS, DXGI_FORMAT_BC5_UNORM):
194
+ self.pixel_format = "BC5"
195
+ n = 5
196
+ self._mode = "RGB"
197
+ elif dxgi_format == DXGI_FORMAT_BC5_SNORM:
198
+ self.pixel_format = "BC5S"
199
+ n = 5
200
+ self._mode = "RGB"
201
+ elif dxgi_format == DXGI_FORMAT_BC6H_UF16:
202
+ self.pixel_format = "BC6H"
203
+ n = 6
204
+ self._mode = "RGB"
205
+ elif dxgi_format == DXGI_FORMAT_BC6H_SF16:
206
+ self.pixel_format = "BC6HS"
207
+ n = 6
208
+ self._mode = "RGB"
209
+ elif dxgi_format in (DXGI_FORMAT_BC7_TYPELESS, DXGI_FORMAT_BC7_UNORM):
210
+ self.pixel_format = "BC7"
211
+ n = 7
212
+ elif dxgi_format == DXGI_FORMAT_BC7_UNORM_SRGB:
213
+ self.pixel_format = "BC7"
214
+ self.info["gamma"] = 1 / 2.2
215
+ n = 7
216
+ elif dxgi_format in (
217
+ DXGI_FORMAT_R8G8B8A8_TYPELESS,
218
+ DXGI_FORMAT_R8G8B8A8_UNORM,
219
+ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
220
+ ):
221
+ self.tile = [("raw", (0, 0) + self.size, 0, ("RGBA", 0, 1))]
222
+ if dxgi_format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
223
+ self.info["gamma"] = 1 / 2.2
224
+ return
225
+ else:
226
+ msg = f"Unimplemented DXGI format {dxgi_format}"
227
+ raise NotImplementedError(msg)
228
+ else:
229
+ msg = f"Unimplemented pixel format {repr(fourcc)}"
230
+ raise NotImplementedError(msg)
231
+
232
+ self.tile = [
233
+ ("bcn", (0, 0) + self.size, data_start, (n, self.pixel_format))
234
+ ]
235
+
236
+ def load_seek(self, pos):
237
+ pass
238
+
239
+
240
+ def _save(im, fp, filename):
241
+ if im.mode not in ("RGB", "RGBA", "L", "LA"):
242
+ msg = f"cannot write mode {im.mode} as DDS"
243
+ raise OSError(msg)
244
+
245
+ rawmode = im.mode
246
+ masks = [0xFF0000, 0xFF00, 0xFF]
247
+ if im.mode in ("L", "LA"):
248
+ pixel_flags = DDPF_LUMINANCE
249
+ else:
250
+ pixel_flags = DDPF_RGB
251
+ rawmode = rawmode[::-1]
252
+ if im.mode in ("LA", "RGBA"):
253
+ pixel_flags |= DDPF_ALPHAPIXELS
254
+ masks.append(0xFF000000)
255
+
256
+ bitcount = len(masks) * 8
257
+ while len(masks) < 4:
258
+ masks.append(0)
259
+
260
+ fp.write(
261
+ o32(DDS_MAGIC)
262
+ + o32(124) # header size
263
+ + o32(
264
+ DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PITCH | DDSD_PIXELFORMAT
265
+ ) # flags
266
+ + o32(im.height)
267
+ + o32(im.width)
268
+ + o32((im.width * bitcount + 7) // 8) # pitch
269
+ + o32(0) # depth
270
+ + o32(0) # mipmaps
271
+ + o32(0) * 11 # reserved
272
+ + o32(32) # pfsize
273
+ + o32(pixel_flags) # pfflags
274
+ + o32(0) # fourcc
275
+ + o32(bitcount) # bitcount
276
+ + b"".join(o32(mask) for mask in masks) # rgbabitmask
277
+ + o32(DDSCAPS_TEXTURE) # dwCaps
278
+ + o32(0) # dwCaps2
279
+ + o32(0) # dwCaps3
280
+ + o32(0) # dwCaps4
281
+ + o32(0) # dwReserved2
282
+ )
283
+ if im.mode == "RGBA":
284
+ r, g, b, a = im.split()
285
+ im = Image.merge("RGBA", (a, r, g, b))
286
+ ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, 0, 1))])
287
+
288
+
289
+ def _accept(prefix):
290
+ return prefix[:4] == b"DDS "
291
+
292
+
293
+ Image.register_open(DdsImageFile.format, DdsImageFile, _accept)
294
+ Image.register_save(DdsImageFile.format, _save)
295
+ Image.register_extension(DdsImageFile.format, ".dds")
venv/lib/python3.10/site-packages/PIL/EpsImagePlugin.py ADDED
@@ -0,0 +1,480 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library.
3
+ # $Id$
4
+ #
5
+ # EPS file handling
6
+ #
7
+ # History:
8
+ # 1995-09-01 fl Created (0.1)
9
+ # 1996-05-18 fl Don't choke on "atend" fields, Ghostscript interface (0.2)
10
+ # 1996-08-22 fl Don't choke on floating point BoundingBox values
11
+ # 1996-08-23 fl Handle files from Macintosh (0.3)
12
+ # 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.4)
13
+ # 2003-09-07 fl Check gs.close status (from Federico Di Gregorio) (0.5)
14
+ # 2014-05-07 e Handling of EPS with binary preview and fixed resolution
15
+ # resizing
16
+ #
17
+ # Copyright (c) 1997-2003 by Secret Labs AB.
18
+ # Copyright (c) 1995-2003 by Fredrik Lundh
19
+ #
20
+ # See the README file for information on usage and redistribution.
21
+ #
22
+
23
+ import io
24
+ import os
25
+ import re
26
+ import subprocess
27
+ import sys
28
+ import tempfile
29
+
30
+ from . import Image, ImageFile
31
+ from ._binary import i32le as i32
32
+ from ._deprecate import deprecate
33
+
34
+ # --------------------------------------------------------------------
35
+
36
+
37
+ split = re.compile(r"^%%([^:]*):[ \t]*(.*)[ \t]*$")
38
+ field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$")
39
+
40
+ gs_binary = None
41
+ gs_windows_binary = None
42
+
43
+
44
+ def has_ghostscript():
45
+ global gs_binary, gs_windows_binary
46
+ if gs_binary is None:
47
+ if sys.platform.startswith("win"):
48
+ if gs_windows_binary is None:
49
+ import shutil
50
+
51
+ for binary in ("gswin32c", "gswin64c", "gs"):
52
+ if shutil.which(binary) is not None:
53
+ gs_windows_binary = binary
54
+ break
55
+ else:
56
+ gs_windows_binary = False
57
+ gs_binary = gs_windows_binary
58
+ else:
59
+ try:
60
+ subprocess.check_call(["gs", "--version"], stdout=subprocess.DEVNULL)
61
+ gs_binary = "gs"
62
+ except OSError:
63
+ gs_binary = False
64
+ return gs_binary is not False
65
+
66
+
67
+ def Ghostscript(tile, size, fp, scale=1, transparency=False):
68
+ """Render an image using Ghostscript"""
69
+ global gs_binary
70
+ if not has_ghostscript():
71
+ msg = "Unable to locate Ghostscript on paths"
72
+ raise OSError(msg)
73
+
74
+ # Unpack decoder tile
75
+ decoder, tile, offset, data = tile[0]
76
+ length, bbox = data
77
+
78
+ # Hack to support hi-res rendering
79
+ scale = int(scale) or 1
80
+ # orig_size = size
81
+ # orig_bbox = bbox
82
+ size = (size[0] * scale, size[1] * scale)
83
+ # resolution is dependent on bbox and size
84
+ res = (
85
+ 72.0 * size[0] / (bbox[2] - bbox[0]),
86
+ 72.0 * size[1] / (bbox[3] - bbox[1]),
87
+ )
88
+
89
+ out_fd, outfile = tempfile.mkstemp()
90
+ os.close(out_fd)
91
+
92
+ infile_temp = None
93
+ if hasattr(fp, "name") and os.path.exists(fp.name):
94
+ infile = fp.name
95
+ else:
96
+ in_fd, infile_temp = tempfile.mkstemp()
97
+ os.close(in_fd)
98
+ infile = infile_temp
99
+
100
+ # Ignore length and offset!
101
+ # Ghostscript can read it
102
+ # Copy whole file to read in Ghostscript
103
+ with open(infile_temp, "wb") as f:
104
+ # fetch length of fp
105
+ fp.seek(0, io.SEEK_END)
106
+ fsize = fp.tell()
107
+ # ensure start position
108
+ # go back
109
+ fp.seek(0)
110
+ lengthfile = fsize
111
+ while lengthfile > 0:
112
+ s = fp.read(min(lengthfile, 100 * 1024))
113
+ if not s:
114
+ break
115
+ lengthfile -= len(s)
116
+ f.write(s)
117
+
118
+ device = "pngalpha" if transparency else "ppmraw"
119
+
120
+ # Build Ghostscript command
121
+ command = [
122
+ gs_binary,
123
+ "-q", # quiet mode
124
+ "-g%dx%d" % size, # set output geometry (pixels)
125
+ "-r%fx%f" % res, # set input DPI (dots per inch)
126
+ "-dBATCH", # exit after processing
127
+ "-dNOPAUSE", # don't pause between pages
128
+ "-dSAFER", # safe mode
129
+ f"-sDEVICE={device}",
130
+ f"-sOutputFile={outfile}", # output file
131
+ # adjust for image origin
132
+ "-c",
133
+ f"{-bbox[0]} {-bbox[1]} translate",
134
+ "-f",
135
+ infile, # input file
136
+ # showpage (see https://bugs.ghostscript.com/show_bug.cgi?id=698272)
137
+ "-c",
138
+ "showpage",
139
+ ]
140
+
141
+ # push data through Ghostscript
142
+ try:
143
+ startupinfo = None
144
+ if sys.platform.startswith("win"):
145
+ startupinfo = subprocess.STARTUPINFO()
146
+ startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
147
+ subprocess.check_call(command, startupinfo=startupinfo)
148
+ out_im = Image.open(outfile)
149
+ out_im.load()
150
+ finally:
151
+ try:
152
+ os.unlink(outfile)
153
+ if infile_temp:
154
+ os.unlink(infile_temp)
155
+ except OSError:
156
+ pass
157
+
158
+ im = out_im.im.copy()
159
+ out_im.close()
160
+ return im
161
+
162
+
163
+ class PSFile:
164
+ """
165
+ Wrapper for bytesio object that treats either CR or LF as end of line.
166
+ This class is no longer used internally, but kept for backwards compatibility.
167
+ """
168
+
169
+ def __init__(self, fp):
170
+ deprecate(
171
+ "PSFile",
172
+ 11,
173
+ action="If you need the functionality of this class "
174
+ "you will need to implement it yourself.",
175
+ )
176
+ self.fp = fp
177
+ self.char = None
178
+
179
+ def seek(self, offset, whence=io.SEEK_SET):
180
+ self.char = None
181
+ self.fp.seek(offset, whence)
182
+
183
+ def readline(self):
184
+ s = [self.char or b""]
185
+ self.char = None
186
+
187
+ c = self.fp.read(1)
188
+ while (c not in b"\r\n") and len(c):
189
+ s.append(c)
190
+ c = self.fp.read(1)
191
+
192
+ self.char = self.fp.read(1)
193
+ # line endings can be 1 or 2 of \r \n, in either order
194
+ if self.char in b"\r\n":
195
+ self.char = None
196
+
197
+ return b"".join(s).decode("latin-1")
198
+
199
+
200
+ def _accept(prefix):
201
+ return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
202
+
203
+
204
+ ##
205
+ # Image plugin for Encapsulated PostScript. This plugin supports only
206
+ # a few variants of this format.
207
+
208
+
209
+ class EpsImageFile(ImageFile.ImageFile):
210
+ """EPS File Parser for the Python Imaging Library"""
211
+
212
+ format = "EPS"
213
+ format_description = "Encapsulated Postscript"
214
+
215
+ mode_map = {1: "L", 2: "LAB", 3: "RGB", 4: "CMYK"}
216
+
217
+ def _open(self):
218
+ (length, offset) = self._find_offset(self.fp)
219
+
220
+ # go to offset - start of "%!PS"
221
+ self.fp.seek(offset)
222
+
223
+ self._mode = "RGB"
224
+ self._size = None
225
+
226
+ byte_arr = bytearray(255)
227
+ bytes_mv = memoryview(byte_arr)
228
+ bytes_read = 0
229
+ reading_header_comments = True
230
+ reading_trailer_comments = False
231
+ trailer_reached = False
232
+
233
+ def check_required_header_comments():
234
+ if "PS-Adobe" not in self.info:
235
+ msg = 'EPS header missing "%!PS-Adobe" comment'
236
+ raise SyntaxError(msg)
237
+ if "BoundingBox" not in self.info:
238
+ msg = 'EPS header missing "%%BoundingBox" comment'
239
+ raise SyntaxError(msg)
240
+
241
+ def _read_comment(s):
242
+ nonlocal reading_trailer_comments
243
+ try:
244
+ m = split.match(s)
245
+ except re.error as e:
246
+ msg = "not an EPS file"
247
+ raise SyntaxError(msg) from e
248
+
249
+ if m:
250
+ k, v = m.group(1, 2)
251
+ self.info[k] = v
252
+ if k == "BoundingBox":
253
+ if v == "(atend)":
254
+ reading_trailer_comments = True
255
+ elif not self._size or (
256
+ trailer_reached and reading_trailer_comments
257
+ ):
258
+ try:
259
+ # Note: The DSC spec says that BoundingBox
260
+ # fields should be integers, but some drivers
261
+ # put floating point values there anyway.
262
+ box = [int(float(i)) for i in v.split()]
263
+ self._size = box[2] - box[0], box[3] - box[1]
264
+ self.tile = [
265
+ ("eps", (0, 0) + self.size, offset, (length, box))
266
+ ]
267
+ except Exception:
268
+ pass
269
+ return True
270
+
271
+ while True:
272
+ byte = self.fp.read(1)
273
+ if byte == b"":
274
+ # if we didn't read a byte we must be at the end of the file
275
+ if bytes_read == 0:
276
+ break
277
+ elif byte in b"\r\n":
278
+ # if we read a line ending character, ignore it and parse what
279
+ # we have already read. if we haven't read any other characters,
280
+ # continue reading
281
+ if bytes_read == 0:
282
+ continue
283
+ else:
284
+ # ASCII/hexadecimal lines in an EPS file must not exceed
285
+ # 255 characters, not including line ending characters
286
+ if bytes_read >= 255:
287
+ # only enforce this for lines starting with a "%",
288
+ # otherwise assume it's binary data
289
+ if byte_arr[0] == ord("%"):
290
+ msg = "not an EPS file"
291
+ raise SyntaxError(msg)
292
+ else:
293
+ if reading_header_comments:
294
+ check_required_header_comments()
295
+ reading_header_comments = False
296
+ # reset bytes_read so we can keep reading
297
+ # data until the end of the line
298
+ bytes_read = 0
299
+ byte_arr[bytes_read] = byte[0]
300
+ bytes_read += 1
301
+ continue
302
+
303
+ if reading_header_comments:
304
+ # Load EPS header
305
+
306
+ # if this line doesn't start with a "%",
307
+ # or does start with "%%EndComments",
308
+ # then we've reached the end of the header/comments
309
+ if byte_arr[0] != ord("%") or bytes_mv[:13] == b"%%EndComments":
310
+ check_required_header_comments()
311
+ reading_header_comments = False
312
+ continue
313
+
314
+ s = str(bytes_mv[:bytes_read], "latin-1")
315
+ if not _read_comment(s):
316
+ m = field.match(s)
317
+ if m:
318
+ k = m.group(1)
319
+ if k[:8] == "PS-Adobe":
320
+ self.info["PS-Adobe"] = k[9:]
321
+ else:
322
+ self.info[k] = ""
323
+ elif s[0] == "%":
324
+ # handle non-DSC PostScript comments that some
325
+ # tools mistakenly put in the Comments section
326
+ pass
327
+ else:
328
+ msg = "bad EPS header"
329
+ raise OSError(msg)
330
+ elif bytes_mv[:11] == b"%ImageData:":
331
+ # Check for an "ImageData" descriptor
332
+ # https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577413_pgfId-1035096
333
+
334
+ # Values:
335
+ # columns
336
+ # rows
337
+ # bit depth (1 or 8)
338
+ # mode (1: L, 2: LAB, 3: RGB, 4: CMYK)
339
+ # number of padding channels
340
+ # block size (number of bytes per row per channel)
341
+ # binary/ascii (1: binary, 2: ascii)
342
+ # data start identifier (the image data follows after a single line
343
+ # consisting only of this quoted value)
344
+ image_data_values = byte_arr[11:bytes_read].split(None, 7)
345
+ columns, rows, bit_depth, mode_id = (
346
+ int(value) for value in image_data_values[:4]
347
+ )
348
+
349
+ if bit_depth == 1:
350
+ self._mode = "1"
351
+ elif bit_depth == 8:
352
+ try:
353
+ self._mode = self.mode_map[mode_id]
354
+ except ValueError:
355
+ break
356
+ else:
357
+ break
358
+
359
+ self._size = columns, rows
360
+ return
361
+ elif trailer_reached and reading_trailer_comments:
362
+ # Load EPS trailer
363
+
364
+ # if this line starts with "%%EOF",
365
+ # then we've reached the end of the file
366
+ if bytes_mv[:5] == b"%%EOF":
367
+ break
368
+
369
+ s = str(bytes_mv[:bytes_read], "latin-1")
370
+ _read_comment(s)
371
+ elif bytes_mv[:9] == b"%%Trailer":
372
+ trailer_reached = True
373
+ bytes_read = 0
374
+
375
+ check_required_header_comments()
376
+
377
+ if not self._size:
378
+ msg = "cannot determine EPS bounding box"
379
+ raise OSError(msg)
380
+
381
+ def _find_offset(self, fp):
382
+ s = fp.read(4)
383
+
384
+ if s == b"%!PS":
385
+ # for HEAD without binary preview
386
+ fp.seek(0, io.SEEK_END)
387
+ length = fp.tell()
388
+ offset = 0
389
+ elif i32(s) == 0xC6D3D0C5:
390
+ # FIX for: Some EPS file not handled correctly / issue #302
391
+ # EPS can contain binary data
392
+ # or start directly with latin coding
393
+ # more info see:
394
+ # https://web.archive.org/web/20160528181353/http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf
395
+ s = fp.read(8)
396
+ offset = i32(s)
397
+ length = i32(s, 4)
398
+ else:
399
+ msg = "not an EPS file"
400
+ raise SyntaxError(msg)
401
+
402
+ return length, offset
403
+
404
+ def load(self, scale=1, transparency=False):
405
+ # Load EPS via Ghostscript
406
+ if self.tile:
407
+ self.im = Ghostscript(self.tile, self.size, self.fp, scale, transparency)
408
+ self._mode = self.im.mode
409
+ self._size = self.im.size
410
+ self.tile = []
411
+ return Image.Image.load(self)
412
+
413
+ def load_seek(self, *args, **kwargs):
414
+ # we can't incrementally load, so force ImageFile.parser to
415
+ # use our custom load method by defining this method.
416
+ pass
417
+
418
+
419
+ # --------------------------------------------------------------------
420
+
421
+
422
+ def _save(im, fp, filename, eps=1):
423
+ """EPS Writer for the Python Imaging Library."""
424
+
425
+ # make sure image data is available
426
+ im.load()
427
+
428
+ # determine PostScript image mode
429
+ if im.mode == "L":
430
+ operator = (8, 1, b"image")
431
+ elif im.mode == "RGB":
432
+ operator = (8, 3, b"false 3 colorimage")
433
+ elif im.mode == "CMYK":
434
+ operator = (8, 4, b"false 4 colorimage")
435
+ else:
436
+ msg = "image mode is not supported"
437
+ raise ValueError(msg)
438
+
439
+ if eps:
440
+ # write EPS header
441
+ fp.write(b"%!PS-Adobe-3.0 EPSF-3.0\n")
442
+ fp.write(b"%%Creator: PIL 0.1 EpsEncode\n")
443
+ # fp.write("%%CreationDate: %s"...)
444
+ fp.write(b"%%%%BoundingBox: 0 0 %d %d\n" % im.size)
445
+ fp.write(b"%%Pages: 1\n")
446
+ fp.write(b"%%EndComments\n")
447
+ fp.write(b"%%Page: 1 1\n")
448
+ fp.write(b"%%ImageData: %d %d " % im.size)
449
+ fp.write(b'%d %d 0 1 1 "%s"\n' % operator)
450
+
451
+ # image header
452
+ fp.write(b"gsave\n")
453
+ fp.write(b"10 dict begin\n")
454
+ fp.write(b"/buf %d string def\n" % (im.size[0] * operator[1]))
455
+ fp.write(b"%d %d scale\n" % im.size)
456
+ fp.write(b"%d %d 8\n" % im.size) # <= bits
457
+ fp.write(b"[%d 0 0 -%d 0 %d]\n" % (im.size[0], im.size[1], im.size[1]))
458
+ fp.write(b"{ currentfile buf readhexstring pop } bind\n")
459
+ fp.write(operator[2] + b"\n")
460
+ if hasattr(fp, "flush"):
461
+ fp.flush()
462
+
463
+ ImageFile._save(im, fp, [("eps", (0, 0) + im.size, 0, None)])
464
+
465
+ fp.write(b"\n%%%%EndBinary\n")
466
+ fp.write(b"grestore end\n")
467
+ if hasattr(fp, "flush"):
468
+ fp.flush()
469
+
470
+
471
+ # --------------------------------------------------------------------
472
+
473
+
474
+ Image.register_open(EpsImageFile.format, EpsImageFile, _accept)
475
+
476
+ Image.register_save(EpsImageFile.format, _save)
477
+
478
+ Image.register_extensions(EpsImageFile.format, [".ps", ".eps"])
479
+
480
+ Image.register_mime(EpsImageFile.format, "application/postscript")
venv/lib/python3.10/site-packages/PIL/ExifTags.py ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library.
3
+ # $Id$
4
+ #
5
+ # EXIF tags
6
+ #
7
+ # Copyright (c) 2003 by Secret Labs AB
8
+ #
9
+ # See the README file for information on usage and redistribution.
10
+ #
11
+
12
+ """
13
+ This module provides constants and clear-text names for various
14
+ well-known EXIF tags.
15
+ """
16
+
17
+ from enum import IntEnum
18
+
19
+
20
+ class Base(IntEnum):
21
+ # possibly incomplete
22
+ InteropIndex = 0x0001
23
+ ProcessingSoftware = 0x000B
24
+ NewSubfileType = 0x00FE
25
+ SubfileType = 0x00FF
26
+ ImageWidth = 0x0100
27
+ ImageLength = 0x0101
28
+ BitsPerSample = 0x0102
29
+ Compression = 0x0103
30
+ PhotometricInterpretation = 0x0106
31
+ Thresholding = 0x0107
32
+ CellWidth = 0x0108
33
+ CellLength = 0x0109
34
+ FillOrder = 0x010A
35
+ DocumentName = 0x010D
36
+ ImageDescription = 0x010E
37
+ Make = 0x010F
38
+ Model = 0x0110
39
+ StripOffsets = 0x0111
40
+ Orientation = 0x0112
41
+ SamplesPerPixel = 0x0115
42
+ RowsPerStrip = 0x0116
43
+ StripByteCounts = 0x0117
44
+ MinSampleValue = 0x0118
45
+ MaxSampleValue = 0x0119
46
+ XResolution = 0x011A
47
+ YResolution = 0x011B
48
+ PlanarConfiguration = 0x011C
49
+ PageName = 0x011D
50
+ FreeOffsets = 0x0120
51
+ FreeByteCounts = 0x0121
52
+ GrayResponseUnit = 0x0122
53
+ GrayResponseCurve = 0x0123
54
+ T4Options = 0x0124
55
+ T6Options = 0x0125
56
+ ResolutionUnit = 0x0128
57
+ PageNumber = 0x0129
58
+ TransferFunction = 0x012D
59
+ Software = 0x0131
60
+ DateTime = 0x0132
61
+ Artist = 0x013B
62
+ HostComputer = 0x013C
63
+ Predictor = 0x013D
64
+ WhitePoint = 0x013E
65
+ PrimaryChromaticities = 0x013F
66
+ ColorMap = 0x0140
67
+ HalftoneHints = 0x0141
68
+ TileWidth = 0x0142
69
+ TileLength = 0x0143
70
+ TileOffsets = 0x0144
71
+ TileByteCounts = 0x0145
72
+ SubIFDs = 0x014A
73
+ InkSet = 0x014C
74
+ InkNames = 0x014D
75
+ NumberOfInks = 0x014E
76
+ DotRange = 0x0150
77
+ TargetPrinter = 0x0151
78
+ ExtraSamples = 0x0152
79
+ SampleFormat = 0x0153
80
+ SMinSampleValue = 0x0154
81
+ SMaxSampleValue = 0x0155
82
+ TransferRange = 0x0156
83
+ ClipPath = 0x0157
84
+ XClipPathUnits = 0x0158
85
+ YClipPathUnits = 0x0159
86
+ Indexed = 0x015A
87
+ JPEGTables = 0x015B
88
+ OPIProxy = 0x015F
89
+ JPEGProc = 0x0200
90
+ JpegIFOffset = 0x0201
91
+ JpegIFByteCount = 0x0202
92
+ JpegRestartInterval = 0x0203
93
+ JpegLosslessPredictors = 0x0205
94
+ JpegPointTransforms = 0x0206
95
+ JpegQTables = 0x0207
96
+ JpegDCTables = 0x0208
97
+ JpegACTables = 0x0209
98
+ YCbCrCoefficients = 0x0211
99
+ YCbCrSubSampling = 0x0212
100
+ YCbCrPositioning = 0x0213
101
+ ReferenceBlackWhite = 0x0214
102
+ XMLPacket = 0x02BC
103
+ RelatedImageFileFormat = 0x1000
104
+ RelatedImageWidth = 0x1001
105
+ RelatedImageLength = 0x1002
106
+ Rating = 0x4746
107
+ RatingPercent = 0x4749
108
+ ImageID = 0x800D
109
+ CFARepeatPatternDim = 0x828D
110
+ BatteryLevel = 0x828F
111
+ Copyright = 0x8298
112
+ ExposureTime = 0x829A
113
+ FNumber = 0x829D
114
+ IPTCNAA = 0x83BB
115
+ ImageResources = 0x8649
116
+ ExifOffset = 0x8769
117
+ InterColorProfile = 0x8773
118
+ ExposureProgram = 0x8822
119
+ SpectralSensitivity = 0x8824
120
+ GPSInfo = 0x8825
121
+ ISOSpeedRatings = 0x8827
122
+ OECF = 0x8828
123
+ Interlace = 0x8829
124
+ TimeZoneOffset = 0x882A
125
+ SelfTimerMode = 0x882B
126
+ SensitivityType = 0x8830
127
+ StandardOutputSensitivity = 0x8831
128
+ RecommendedExposureIndex = 0x8832
129
+ ISOSpeed = 0x8833
130
+ ISOSpeedLatitudeyyy = 0x8834
131
+ ISOSpeedLatitudezzz = 0x8835
132
+ ExifVersion = 0x9000
133
+ DateTimeOriginal = 0x9003
134
+ DateTimeDigitized = 0x9004
135
+ OffsetTime = 0x9010
136
+ OffsetTimeOriginal = 0x9011
137
+ OffsetTimeDigitized = 0x9012
138
+ ComponentsConfiguration = 0x9101
139
+ CompressedBitsPerPixel = 0x9102
140
+ ShutterSpeedValue = 0x9201
141
+ ApertureValue = 0x9202
142
+ BrightnessValue = 0x9203
143
+ ExposureBiasValue = 0x9204
144
+ MaxApertureValue = 0x9205
145
+ SubjectDistance = 0x9206
146
+ MeteringMode = 0x9207
147
+ LightSource = 0x9208
148
+ Flash = 0x9209
149
+ FocalLength = 0x920A
150
+ Noise = 0x920D
151
+ ImageNumber = 0x9211
152
+ SecurityClassification = 0x9212
153
+ ImageHistory = 0x9213
154
+ TIFFEPStandardID = 0x9216
155
+ MakerNote = 0x927C
156
+ UserComment = 0x9286
157
+ SubsecTime = 0x9290
158
+ SubsecTimeOriginal = 0x9291
159
+ SubsecTimeDigitized = 0x9292
160
+ AmbientTemperature = 0x9400
161
+ Humidity = 0x9401
162
+ Pressure = 0x9402
163
+ WaterDepth = 0x9403
164
+ Acceleration = 0x9404
165
+ CameraElevationAngle = 0x9405
166
+ XPTitle = 0x9C9B
167
+ XPComment = 0x9C9C
168
+ XPAuthor = 0x9C9D
169
+ XPKeywords = 0x9C9E
170
+ XPSubject = 0x9C9F
171
+ FlashPixVersion = 0xA000
172
+ ColorSpace = 0xA001
173
+ ExifImageWidth = 0xA002
174
+ ExifImageHeight = 0xA003
175
+ RelatedSoundFile = 0xA004
176
+ ExifInteroperabilityOffset = 0xA005
177
+ FlashEnergy = 0xA20B
178
+ SpatialFrequencyResponse = 0xA20C
179
+ FocalPlaneXResolution = 0xA20E
180
+ FocalPlaneYResolution = 0xA20F
181
+ FocalPlaneResolutionUnit = 0xA210
182
+ SubjectLocation = 0xA214
183
+ ExposureIndex = 0xA215
184
+ SensingMethod = 0xA217
185
+ FileSource = 0xA300
186
+ SceneType = 0xA301
187
+ CFAPattern = 0xA302
188
+ CustomRendered = 0xA401
189
+ ExposureMode = 0xA402
190
+ WhiteBalance = 0xA403
191
+ DigitalZoomRatio = 0xA404
192
+ FocalLengthIn35mmFilm = 0xA405
193
+ SceneCaptureType = 0xA406
194
+ GainControl = 0xA407
195
+ Contrast = 0xA408
196
+ Saturation = 0xA409
197
+ Sharpness = 0xA40A
198
+ DeviceSettingDescription = 0xA40B
199
+ SubjectDistanceRange = 0xA40C
200
+ ImageUniqueID = 0xA420
201
+ CameraOwnerName = 0xA430
202
+ BodySerialNumber = 0xA431
203
+ LensSpecification = 0xA432
204
+ LensMake = 0xA433
205
+ LensModel = 0xA434
206
+ LensSerialNumber = 0xA435
207
+ CompositeImage = 0xA460
208
+ CompositeImageCount = 0xA461
209
+ CompositeImageExposureTimes = 0xA462
210
+ Gamma = 0xA500
211
+ PrintImageMatching = 0xC4A5
212
+ DNGVersion = 0xC612
213
+ DNGBackwardVersion = 0xC613
214
+ UniqueCameraModel = 0xC614
215
+ LocalizedCameraModel = 0xC615
216
+ CFAPlaneColor = 0xC616
217
+ CFALayout = 0xC617
218
+ LinearizationTable = 0xC618
219
+ BlackLevelRepeatDim = 0xC619
220
+ BlackLevel = 0xC61A
221
+ BlackLevelDeltaH = 0xC61B
222
+ BlackLevelDeltaV = 0xC61C
223
+ WhiteLevel = 0xC61D
224
+ DefaultScale = 0xC61E
225
+ DefaultCropOrigin = 0xC61F
226
+ DefaultCropSize = 0xC620
227
+ ColorMatrix1 = 0xC621
228
+ ColorMatrix2 = 0xC622
229
+ CameraCalibration1 = 0xC623
230
+ CameraCalibration2 = 0xC624
231
+ ReductionMatrix1 = 0xC625
232
+ ReductionMatrix2 = 0xC626
233
+ AnalogBalance = 0xC627
234
+ AsShotNeutral = 0xC628
235
+ AsShotWhiteXY = 0xC629
236
+ BaselineExposure = 0xC62A
237
+ BaselineNoise = 0xC62B
238
+ BaselineSharpness = 0xC62C
239
+ BayerGreenSplit = 0xC62D
240
+ LinearResponseLimit = 0xC62E
241
+ CameraSerialNumber = 0xC62F
242
+ LensInfo = 0xC630
243
+ ChromaBlurRadius = 0xC631
244
+ AntiAliasStrength = 0xC632
245
+ ShadowScale = 0xC633
246
+ DNGPrivateData = 0xC634
247
+ MakerNoteSafety = 0xC635
248
+ CalibrationIlluminant1 = 0xC65A
249
+ CalibrationIlluminant2 = 0xC65B
250
+ BestQualityScale = 0xC65C
251
+ RawDataUniqueID = 0xC65D
252
+ OriginalRawFileName = 0xC68B
253
+ OriginalRawFileData = 0xC68C
254
+ ActiveArea = 0xC68D
255
+ MaskedAreas = 0xC68E
256
+ AsShotICCProfile = 0xC68F
257
+ AsShotPreProfileMatrix = 0xC690
258
+ CurrentICCProfile = 0xC691
259
+ CurrentPreProfileMatrix = 0xC692
260
+ ColorimetricReference = 0xC6BF
261
+ CameraCalibrationSignature = 0xC6F3
262
+ ProfileCalibrationSignature = 0xC6F4
263
+ AsShotProfileName = 0xC6F6
264
+ NoiseReductionApplied = 0xC6F7
265
+ ProfileName = 0xC6F8
266
+ ProfileHueSatMapDims = 0xC6F9
267
+ ProfileHueSatMapData1 = 0xC6FA
268
+ ProfileHueSatMapData2 = 0xC6FB
269
+ ProfileToneCurve = 0xC6FC
270
+ ProfileEmbedPolicy = 0xC6FD
271
+ ProfileCopyright = 0xC6FE
272
+ ForwardMatrix1 = 0xC714
273
+ ForwardMatrix2 = 0xC715
274
+ PreviewApplicationName = 0xC716
275
+ PreviewApplicationVersion = 0xC717
276
+ PreviewSettingsName = 0xC718
277
+ PreviewSettingsDigest = 0xC719
278
+ PreviewColorSpace = 0xC71A
279
+ PreviewDateTime = 0xC71B
280
+ RawImageDigest = 0xC71C
281
+ OriginalRawFileDigest = 0xC71D
282
+ SubTileBlockSize = 0xC71E
283
+ RowInterleaveFactor = 0xC71F
284
+ ProfileLookTableDims = 0xC725
285
+ ProfileLookTableData = 0xC726
286
+ OpcodeList1 = 0xC740
287
+ OpcodeList2 = 0xC741
288
+ OpcodeList3 = 0xC74E
289
+ NoiseProfile = 0xC761
290
+
291
+
292
+ """Maps EXIF tags to tag names."""
293
+ TAGS = {
294
+ **{i.value: i.name for i in Base},
295
+ 0x920C: "SpatialFrequencyResponse",
296
+ 0x9214: "SubjectLocation",
297
+ 0x9215: "ExposureIndex",
298
+ 0x828E: "CFAPattern",
299
+ 0x920B: "FlashEnergy",
300
+ 0x9216: "TIFF/EPStandardID",
301
+ }
302
+
303
+
304
+ class GPS(IntEnum):
305
+ GPSVersionID = 0
306
+ GPSLatitudeRef = 1
307
+ GPSLatitude = 2
308
+ GPSLongitudeRef = 3
309
+ GPSLongitude = 4
310
+ GPSAltitudeRef = 5
311
+ GPSAltitude = 6
312
+ GPSTimeStamp = 7
313
+ GPSSatellites = 8
314
+ GPSStatus = 9
315
+ GPSMeasureMode = 10
316
+ GPSDOP = 11
317
+ GPSSpeedRef = 12
318
+ GPSSpeed = 13
319
+ GPSTrackRef = 14
320
+ GPSTrack = 15
321
+ GPSImgDirectionRef = 16
322
+ GPSImgDirection = 17
323
+ GPSMapDatum = 18
324
+ GPSDestLatitudeRef = 19
325
+ GPSDestLatitude = 20
326
+ GPSDestLongitudeRef = 21
327
+ GPSDestLongitude = 22
328
+ GPSDestBearingRef = 23
329
+ GPSDestBearing = 24
330
+ GPSDestDistanceRef = 25
331
+ GPSDestDistance = 26
332
+ GPSProcessingMethod = 27
333
+ GPSAreaInformation = 28
334
+ GPSDateStamp = 29
335
+ GPSDifferential = 30
336
+ GPSHPositioningError = 31
337
+
338
+
339
+ """Maps EXIF GPS tags to tag names."""
340
+ GPSTAGS = {i.value: i.name for i in GPS}
341
+
342
+
343
+ class Interop(IntEnum):
344
+ InteropIndex = 1
345
+ InteropVersion = 2
346
+ RelatedImageFileFormat = 4096
347
+ RelatedImageWidth = 4097
348
+ RleatedImageHeight = 4098
349
+
350
+
351
+ class IFD(IntEnum):
352
+ Exif = 34665
353
+ GPSInfo = 34853
354
+ Makernote = 37500
355
+ Interop = 40965
356
+ IFD1 = -1
357
+
358
+
359
+ class LightSource(IntEnum):
360
+ Unknown = 0
361
+ Daylight = 1
362
+ Fluorescent = 2
363
+ Tungsten = 3
364
+ Flash = 4
365
+ Fine = 9
366
+ Cloudy = 10
367
+ Shade = 11
368
+ DaylightFluorescent = 12
369
+ DayWhiteFluorescent = 13
370
+ CoolWhiteFluorescent = 14
371
+ WhiteFluorescent = 15
372
+ StandardLightA = 17
373
+ StandardLightB = 18
374
+ StandardLightC = 19
375
+ D55 = 20
376
+ D65 = 21
377
+ D75 = 22
378
+ D50 = 23
379
+ ISO = 24
380
+ Other = 255
venv/lib/python3.10/site-packages/PIL/FitsImagePlugin.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # The Python Imaging Library
3
+ # $Id$
4
+ #
5
+ # FITS file handling
6
+ #
7
+ # Copyright (c) 1998-2003 by Fredrik Lundh
8
+ #
9
+ # See the README file for information on usage and redistribution.
10
+ #
11
+
12
+ import math
13
+
14
+ from . import Image, ImageFile
15
+
16
+
17
+ def _accept(prefix):
18
+ return prefix[:6] == b"SIMPLE"
19
+
20
+
21
+ class FitsImageFile(ImageFile.ImageFile):
22
+ format = "FITS"
23
+ format_description = "FITS"
24
+
25
+ def _open(self):
26
+ headers = {}
27
+ while True:
28
+ header = self.fp.read(80)
29
+ if not header:
30
+ msg = "Truncated FITS file"
31
+ raise OSError(msg)
32
+ keyword = header[:8].strip()
33
+ if keyword == b"END":
34
+ break
35
+ value = header[8:].split(b"/")[0].strip()
36
+ if value.startswith(b"="):
37
+ value = value[1:].strip()
38
+ if not headers and (not _accept(keyword) or value != b"T"):
39
+ msg = "Not a FITS file"
40
+ raise SyntaxError(msg)
41
+ headers[keyword] = value
42
+
43
+ naxis = int(headers[b"NAXIS"])
44
+ if naxis == 0:
45
+ msg = "No image data"
46
+ raise ValueError(msg)
47
+ elif naxis == 1:
48
+ self._size = 1, int(headers[b"NAXIS1"])
49
+ else:
50
+ self._size = int(headers[b"NAXIS1"]), int(headers[b"NAXIS2"])
51
+
52
+ number_of_bits = int(headers[b"BITPIX"])
53
+ if number_of_bits == 8:
54
+ self._mode = "L"
55
+ elif number_of_bits == 16:
56
+ self._mode = "I"
57
+ # rawmode = "I;16S"
58
+ elif number_of_bits == 32:
59
+ self._mode = "I"
60
+ elif number_of_bits in (-32, -64):
61
+ self._mode = "F"
62
+ # rawmode = "F" if number_of_bits == -32 else "F;64F"
63
+
64
+ offset = math.ceil(self.fp.tell() / 2880) * 2880
65
+ self.tile = [("raw", (0, 0) + self.size, offset, (self.mode, 0, -1))]
66
+
67
+
68
+ # --------------------------------------------------------------------
69
+ # Registry
70
+
71
+ Image.register_open(FitsImageFile.format, FitsImageFile, _accept)
72
+
73
+ Image.register_extensions(FitsImageFile.format, [".fit", ".fits"])