initial commit
This commit is contained in:
123
earth.py
Normal file
123
earth.py
Normal file
@@ -0,0 +1,123 @@
|
||||
import curses
|
||||
import numpy as np
|
||||
import math
|
||||
import time
|
||||
|
||||
# Define the rotation speed of the globe
|
||||
ROTATION_SPEED = 0.02
|
||||
|
||||
# Define the radius of the globe (in terms of terminal characters)
|
||||
RADIUS = 10
|
||||
|
||||
# Define the number of latitude and longitude lines for the wireframe
|
||||
NUM_LATITUDE_LINES = 12
|
||||
NUM_LONGITUDE_LINES = 24
|
||||
|
||||
# Define characters for drawing the wireframe
|
||||
WIREFRAME_CHAR = '◦'
|
||||
CONTINENT_CHAR = '■' # Different character for continents outline
|
||||
|
||||
# A simplified list of latitude and longitude points for continents
|
||||
# This is a minimal representation; a real globe would need a much larger dataset
|
||||
CONTINENT_POINTS = [
|
||||
# Example points for North America, Europe, Africa, etc.
|
||||
(45, -100), (60, -100), (30, -90), # North America
|
||||
(50, 0), (55, 10), (60, 20), # Europe
|
||||
(0, 10), (-10, 20), (-30, 10), # Africa
|
||||
(-20, -50), (-30, -60), (-10, -70), # South America
|
||||
(10, 100), (20, 120), (-10, 130), # Asia
|
||||
]
|
||||
|
||||
# Function to convert latitude and longitude into 3D points on the globe
|
||||
def lat_lon_to_xyz(lat, lon, radius):
|
||||
lat_rad = math.radians(lat)
|
||||
lon_rad = math.radians(lon)
|
||||
x = radius * math.cos(lat_rad) * math.cos(lon_rad)
|
||||
y = radius * math.cos(lat_rad) * math.sin(lon_rad)
|
||||
z = radius * math.sin(lat_rad)
|
||||
return x, y, z
|
||||
|
||||
# Function to project 3D points to 2D terminal coordinates
|
||||
def project(x, y, z, screen_width, screen_height, scale=1):
|
||||
factor = scale / (z + 3)
|
||||
proj_x = int(screen_width / 2 + x * factor * screen_width / 4)
|
||||
proj_y = int(screen_height / 2 - y * factor * screen_height / 4)
|
||||
return proj_x, proj_y
|
||||
|
||||
# Function to generate globe wireframe points
|
||||
def generate_globe(radius, lat_lines, long_lines):
|
||||
points = []
|
||||
for lat in range(0, lat_lines + 1):
|
||||
theta = lat * math.pi / lat_lines
|
||||
for lon in range(0, long_lines + 1):
|
||||
phi = lon * 2 * math.pi / long_lines
|
||||
x = radius * math.sin(theta) * math.cos(phi)
|
||||
y = radius * math.sin(theta) * math.sin(phi)
|
||||
z = radius * math.cos(theta)
|
||||
points.append((x, y, z))
|
||||
return points
|
||||
|
||||
# Function to apply rotation to the globe
|
||||
def rotate(point, angle_x, angle_y, angle_z):
|
||||
x, y, z = point
|
||||
|
||||
# Rotation around X-axis
|
||||
y, z = y * math.cos(angle_x) - z * math.sin(angle_x), y * math.sin(angle_x) + z * math.cos(angle_x)
|
||||
|
||||
# Rotation around Y-axis
|
||||
x, z = x * math.cos(angle_y) + z * math.sin(angle_y), -x * math.sin(angle_y) + z * math.cos(angle_y)
|
||||
|
||||
# Rotation around Z-axis
|
||||
x, y = x * math.cos(angle_z) - y * math.sin(angle_z), x * math.sin(angle_z) + y * math.cos(angle_z)
|
||||
|
||||
return x, y, z
|
||||
|
||||
# Main drawing function
|
||||
def draw_globe(stdscr):
|
||||
curses.curs_set(0) # Hide cursor
|
||||
stdscr.nodelay(True)
|
||||
stdscr.timeout(50)
|
||||
|
||||
screen_height, screen_width = stdscr.getmaxyx()
|
||||
globe_points = generate_globe(RADIUS, NUM_LATITUDE_LINES, NUM_LONGITUDE_LINES)
|
||||
angle_x = angle_y = angle_z = 0
|
||||
|
||||
# Convert continent points to 3D points
|
||||
continent_points_3d = [lat_lon_to_xyz(lat, lon, RADIUS) for lat, lon in CONTINENT_POINTS]
|
||||
|
||||
while True:
|
||||
stdscr.clear()
|
||||
|
||||
# Increment angles for rotation
|
||||
angle_x += ROTATION_SPEED
|
||||
angle_y += ROTATION_SPEED / 2 # Slow Y-axis rotation for realism
|
||||
angle_z += ROTATION_SPEED / 4 # Slow Z-axis rotation for realism
|
||||
|
||||
# Draw the wireframe globe by rotating points and projecting them
|
||||
for point in globe_points:
|
||||
rotated_point = rotate(point, angle_x, angle_y, angle_z)
|
||||
proj_x, proj_y = project(*rotated_point, screen_width, screen_height)
|
||||
if 0 <= proj_x < screen_width and 0 <= proj_y < screen_height:
|
||||
stdscr.addch(proj_y, proj_x, WIREFRAME_CHAR)
|
||||
|
||||
# Draw the continent outlines
|
||||
for point in continent_points_3d:
|
||||
rotated_point = rotate(point, angle_x, angle_y, angle_z)
|
||||
proj_x, proj_y = project(*rotated_point, screen_width, screen_height)
|
||||
if 0 <= proj_x < screen_width and 0 <= proj_y < screen_height:
|
||||
stdscr.addch(proj_y, proj_x, CONTINENT_CHAR)
|
||||
|
||||
stdscr.refresh()
|
||||
|
||||
try:
|
||||
key = stdscr.getch()
|
||||
if key == ord('q'):
|
||||
break # Quit the application
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
time.sleep(0.05)
|
||||
|
||||
# Main entry point for curses wrapper
|
||||
if __name__ == "__main__":
|
||||
curses.wrapper(draw_globe)
|
||||
247
venv/bin/Activate.ps1
Normal file
247
venv/bin/Activate.ps1
Normal file
@@ -0,0 +1,247 @@
|
||||
<#
|
||||
.Synopsis
|
||||
Activate a Python virtual environment for the current PowerShell session.
|
||||
|
||||
.Description
|
||||
Pushes the python executable for a virtual environment to the front of the
|
||||
$Env:PATH environment variable and sets the prompt to signify that you are
|
||||
in a Python virtual environment. Makes use of the command line switches as
|
||||
well as the `pyvenv.cfg` file values present in the virtual environment.
|
||||
|
||||
.Parameter VenvDir
|
||||
Path to the directory that contains the virtual environment to activate. The
|
||||
default value for this is the parent of the directory that the Activate.ps1
|
||||
script is located within.
|
||||
|
||||
.Parameter Prompt
|
||||
The prompt prefix to display when this virtual environment is activated. By
|
||||
default, this prompt is the name of the virtual environment folder (VenvDir)
|
||||
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
|
||||
|
||||
.Example
|
||||
Activate.ps1
|
||||
Activates the Python virtual environment that contains the Activate.ps1 script.
|
||||
|
||||
.Example
|
||||
Activate.ps1 -Verbose
|
||||
Activates the Python virtual environment that contains the Activate.ps1 script,
|
||||
and shows extra information about the activation as it executes.
|
||||
|
||||
.Example
|
||||
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
|
||||
Activates the Python virtual environment located in the specified location.
|
||||
|
||||
.Example
|
||||
Activate.ps1 -Prompt "MyPython"
|
||||
Activates the Python virtual environment that contains the Activate.ps1 script,
|
||||
and prefixes the current prompt with the specified string (surrounded in
|
||||
parentheses) while the virtual environment is active.
|
||||
|
||||
.Notes
|
||||
On Windows, it may be required to enable this Activate.ps1 script by setting the
|
||||
execution policy for the user. You can do this by issuing the following PowerShell
|
||||
command:
|
||||
|
||||
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
||||
|
||||
For more information on Execution Policies:
|
||||
https://go.microsoft.com/fwlink/?LinkID=135170
|
||||
|
||||
#>
|
||||
Param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[String]
|
||||
$VenvDir,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[String]
|
||||
$Prompt
|
||||
)
|
||||
|
||||
<# Function declarations --------------------------------------------------- #>
|
||||
|
||||
<#
|
||||
.Synopsis
|
||||
Remove all shell session elements added by the Activate script, including the
|
||||
addition of the virtual environment's Python executable from the beginning of
|
||||
the PATH variable.
|
||||
|
||||
.Parameter NonDestructive
|
||||
If present, do not remove this function from the global namespace for the
|
||||
session.
|
||||
|
||||
#>
|
||||
function global:deactivate ([switch]$NonDestructive) {
|
||||
# Revert to original values
|
||||
|
||||
# The prior prompt:
|
||||
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
|
||||
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
|
||||
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
|
||||
}
|
||||
|
||||
# The prior PYTHONHOME:
|
||||
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
|
||||
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
|
||||
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
|
||||
}
|
||||
|
||||
# The prior PATH:
|
||||
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
|
||||
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
|
||||
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
|
||||
}
|
||||
|
||||
# Just remove the VIRTUAL_ENV altogether:
|
||||
if (Test-Path -Path Env:VIRTUAL_ENV) {
|
||||
Remove-Item -Path env:VIRTUAL_ENV
|
||||
}
|
||||
|
||||
# Just remove VIRTUAL_ENV_PROMPT altogether.
|
||||
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
|
||||
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
|
||||
}
|
||||
|
||||
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
|
||||
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
|
||||
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
|
||||
}
|
||||
|
||||
# Leave deactivate function in the global namespace if requested:
|
||||
if (-not $NonDestructive) {
|
||||
Remove-Item -Path function:deactivate
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.Description
|
||||
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
|
||||
given folder, and returns them in a map.
|
||||
|
||||
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
|
||||
two strings separated by `=` (with any amount of whitespace surrounding the =)
|
||||
then it is considered a `key = value` line. The left hand string is the key,
|
||||
the right hand is the value.
|
||||
|
||||
If the value starts with a `'` or a `"` then the first and last character is
|
||||
stripped from the value before being captured.
|
||||
|
||||
.Parameter ConfigDir
|
||||
Path to the directory that contains the `pyvenv.cfg` file.
|
||||
#>
|
||||
function Get-PyVenvConfig(
|
||||
[String]
|
||||
$ConfigDir
|
||||
) {
|
||||
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
|
||||
|
||||
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
|
||||
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
|
||||
|
||||
# An empty map will be returned if no config file is found.
|
||||
$pyvenvConfig = @{ }
|
||||
|
||||
if ($pyvenvConfigPath) {
|
||||
|
||||
Write-Verbose "File exists, parse `key = value` lines"
|
||||
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
|
||||
|
||||
$pyvenvConfigContent | ForEach-Object {
|
||||
$keyval = $PSItem -split "\s*=\s*", 2
|
||||
if ($keyval[0] -and $keyval[1]) {
|
||||
$val = $keyval[1]
|
||||
|
||||
# Remove extraneous quotations around a string value.
|
||||
if ("'""".Contains($val.Substring(0, 1))) {
|
||||
$val = $val.Substring(1, $val.Length - 2)
|
||||
}
|
||||
|
||||
$pyvenvConfig[$keyval[0]] = $val
|
||||
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
|
||||
}
|
||||
}
|
||||
}
|
||||
return $pyvenvConfig
|
||||
}
|
||||
|
||||
|
||||
<# Begin Activate script --------------------------------------------------- #>
|
||||
|
||||
# Determine the containing directory of this script
|
||||
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
||||
$VenvExecDir = Get-Item -Path $VenvExecPath
|
||||
|
||||
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
|
||||
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
|
||||
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
|
||||
|
||||
# Set values required in priority: CmdLine, ConfigFile, Default
|
||||
# First, get the location of the virtual environment, it might not be
|
||||
# VenvExecDir if specified on the command line.
|
||||
if ($VenvDir) {
|
||||
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
|
||||
}
|
||||
else {
|
||||
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
|
||||
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
|
||||
Write-Verbose "VenvDir=$VenvDir"
|
||||
}
|
||||
|
||||
# Next, read the `pyvenv.cfg` file to determine any required value such
|
||||
# as `prompt`.
|
||||
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
|
||||
|
||||
# Next, set the prompt from the command line, or the config file, or
|
||||
# just use the name of the virtual environment folder.
|
||||
if ($Prompt) {
|
||||
Write-Verbose "Prompt specified as argument, using '$Prompt'"
|
||||
}
|
||||
else {
|
||||
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
|
||||
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
|
||||
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
|
||||
$Prompt = $pyvenvCfg['prompt'];
|
||||
}
|
||||
else {
|
||||
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
|
||||
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
|
||||
$Prompt = Split-Path -Path $venvDir -Leaf
|
||||
}
|
||||
}
|
||||
|
||||
Write-Verbose "Prompt = '$Prompt'"
|
||||
Write-Verbose "VenvDir='$VenvDir'"
|
||||
|
||||
# Deactivate any currently active virtual environment, but leave the
|
||||
# deactivate function in place.
|
||||
deactivate -nondestructive
|
||||
|
||||
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
|
||||
# that there is an activated venv.
|
||||
$env:VIRTUAL_ENV = $VenvDir
|
||||
|
||||
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
|
||||
|
||||
Write-Verbose "Setting prompt to '$Prompt'"
|
||||
|
||||
# Set the prompt to include the env name
|
||||
# Make sure _OLD_VIRTUAL_PROMPT is global
|
||||
function global:_OLD_VIRTUAL_PROMPT { "" }
|
||||
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
|
||||
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
|
||||
|
||||
function global:prompt {
|
||||
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
|
||||
_OLD_VIRTUAL_PROMPT
|
||||
}
|
||||
$env:VIRTUAL_ENV_PROMPT = $Prompt
|
||||
}
|
||||
|
||||
# Clear PYTHONHOME
|
||||
if (Test-Path -Path Env:PYTHONHOME) {
|
||||
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
|
||||
Remove-Item -Path Env:PYTHONHOME
|
||||
}
|
||||
|
||||
# Add the venv to the PATH
|
||||
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
|
||||
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
|
||||
69
venv/bin/activate
Normal file
69
venv/bin/activate
Normal file
@@ -0,0 +1,69 @@
|
||||
# This file must be used with "source bin/activate" *from bash*
|
||||
# you cannot run it directly
|
||||
|
||||
deactivate () {
|
||||
# reset old environment variables
|
||||
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
||||
PATH="${_OLD_VIRTUAL_PATH:-}"
|
||||
export PATH
|
||||
unset _OLD_VIRTUAL_PATH
|
||||
fi
|
||||
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
||||
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
||||
export PYTHONHOME
|
||||
unset _OLD_VIRTUAL_PYTHONHOME
|
||||
fi
|
||||
|
||||
# This should detect bash and zsh, which have a hash command that must
|
||||
# be called to get it to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||
hash -r 2> /dev/null
|
||||
fi
|
||||
|
||||
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
||||
PS1="${_OLD_VIRTUAL_PS1:-}"
|
||||
export PS1
|
||||
unset _OLD_VIRTUAL_PS1
|
||||
fi
|
||||
|
||||
unset VIRTUAL_ENV
|
||||
unset VIRTUAL_ENV_PROMPT
|
||||
if [ ! "${1:-}" = "nondestructive" ] ; then
|
||||
# Self destruct!
|
||||
unset -f deactivate
|
||||
fi
|
||||
}
|
||||
|
||||
# unset irrelevant variables
|
||||
deactivate nondestructive
|
||||
|
||||
VIRTUAL_ENV="/home/klein/codeWS/Python3/earth/venv"
|
||||
export VIRTUAL_ENV
|
||||
|
||||
_OLD_VIRTUAL_PATH="$PATH"
|
||||
PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||
export PATH
|
||||
|
||||
# unset PYTHONHOME if set
|
||||
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
||||
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
||||
if [ -n "${PYTHONHOME:-}" ] ; then
|
||||
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
||||
unset PYTHONHOME
|
||||
fi
|
||||
|
||||
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
||||
_OLD_VIRTUAL_PS1="${PS1:-}"
|
||||
PS1="(venv) ${PS1:-}"
|
||||
export PS1
|
||||
VIRTUAL_ENV_PROMPT="(venv) "
|
||||
export VIRTUAL_ENV_PROMPT
|
||||
fi
|
||||
|
||||
# This should detect bash and zsh, which have a hash command that must
|
||||
# be called to get it to forget past commands. Without forgetting
|
||||
# past commands the $PATH changes we made may not be respected
|
||||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
||||
hash -r 2> /dev/null
|
||||
fi
|
||||
26
venv/bin/activate.csh
Normal file
26
venv/bin/activate.csh
Normal file
@@ -0,0 +1,26 @@
|
||||
# This file must be used with "source bin/activate.csh" *from csh*.
|
||||
# You cannot run it directly.
|
||||
# Created by Davide Di Blasi <davidedb@gmail.com>.
|
||||
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
|
||||
|
||||
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'
|
||||
|
||||
# Unset irrelevant variables.
|
||||
deactivate nondestructive
|
||||
|
||||
setenv VIRTUAL_ENV "/home/klein/codeWS/Python3/earth/venv"
|
||||
|
||||
set _OLD_VIRTUAL_PATH="$PATH"
|
||||
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
|
||||
set _OLD_VIRTUAL_PROMPT="$prompt"
|
||||
|
||||
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
|
||||
set prompt = "(venv) $prompt"
|
||||
setenv VIRTUAL_ENV_PROMPT "(venv) "
|
||||
endif
|
||||
|
||||
alias pydoc python -m pydoc
|
||||
|
||||
rehash
|
||||
69
venv/bin/activate.fish
Normal file
69
venv/bin/activate.fish
Normal file
@@ -0,0 +1,69 @@
|
||||
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
|
||||
# (https://fishshell.com/); you cannot run it directly.
|
||||
|
||||
function deactivate -d "Exit virtual environment and return to normal shell environment"
|
||||
# reset old environment variables
|
||||
if test -n "$_OLD_VIRTUAL_PATH"
|
||||
set -gx PATH $_OLD_VIRTUAL_PATH
|
||||
set -e _OLD_VIRTUAL_PATH
|
||||
end
|
||||
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
|
||||
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
|
||||
set -e _OLD_VIRTUAL_PYTHONHOME
|
||||
end
|
||||
|
||||
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
|
||||
set -e _OLD_FISH_PROMPT_OVERRIDE
|
||||
# prevents error when using nested fish instances (Issue #93858)
|
||||
if functions -q _old_fish_prompt
|
||||
functions -e fish_prompt
|
||||
functions -c _old_fish_prompt fish_prompt
|
||||
functions -e _old_fish_prompt
|
||||
end
|
||||
end
|
||||
|
||||
set -e VIRTUAL_ENV
|
||||
set -e VIRTUAL_ENV_PROMPT
|
||||
if test "$argv[1]" != "nondestructive"
|
||||
# Self-destruct!
|
||||
functions -e deactivate
|
||||
end
|
||||
end
|
||||
|
||||
# Unset irrelevant variables.
|
||||
deactivate nondestructive
|
||||
|
||||
set -gx VIRTUAL_ENV "/home/klein/codeWS/Python3/earth/venv"
|
||||
|
||||
set -gx _OLD_VIRTUAL_PATH $PATH
|
||||
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
|
||||
|
||||
# Unset PYTHONHOME if set.
|
||||
if set -q PYTHONHOME
|
||||
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
|
||||
set -e PYTHONHOME
|
||||
end
|
||||
|
||||
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
|
||||
# fish uses a function instead of an env var to generate the prompt.
|
||||
|
||||
# Save the current fish_prompt function as the function _old_fish_prompt.
|
||||
functions -c fish_prompt _old_fish_prompt
|
||||
|
||||
# With the original prompt function renamed, we can override with our own.
|
||||
function fish_prompt
|
||||
# Save the return status of the last command.
|
||||
set -l old_status $status
|
||||
|
||||
# Output the venv prompt; color taken from the blue of the Python logo.
|
||||
printf "%s%s%s" (set_color 4B8BBE) "(venv) " (set_color normal)
|
||||
|
||||
# Restore the return status of the previous command.
|
||||
echo "exit $old_status" | .
|
||||
# Output the original/"old" prompt.
|
||||
_old_fish_prompt
|
||||
end
|
||||
|
||||
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
|
||||
set -gx VIRTUAL_ENV_PROMPT "(venv) "
|
||||
end
|
||||
8
venv/bin/f2py
Executable file
8
venv/bin/f2py
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/home/klein/codeWS/Python3/earth/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from numpy.f2py.f2py2e import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
8
venv/bin/numpy-config
Executable file
8
venv/bin/numpy-config
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/home/klein/codeWS/Python3/earth/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from numpy._configtool import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
8
venv/bin/pip
Executable file
8
venv/bin/pip
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/home/klein/codeWS/Python3/earth/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pip._internal.cli.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
8
venv/bin/pip3
Executable file
8
venv/bin/pip3
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/home/klein/codeWS/Python3/earth/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pip._internal.cli.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
8
venv/bin/pip3.11
Executable file
8
venv/bin/pip3.11
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/home/klein/codeWS/Python3/earth/venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pip._internal.cli.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
1
venv/bin/python
Symbolic link
1
venv/bin/python
Symbolic link
@@ -0,0 +1 @@
|
||||
python3
|
||||
1
venv/bin/python3
Symbolic link
1
venv/bin/python3
Symbolic link
@@ -0,0 +1 @@
|
||||
/usr/bin/python3
|
||||
1
venv/bin/python3.11
Symbolic link
1
venv/bin/python3.11
Symbolic link
@@ -0,0 +1 @@
|
||||
python3
|
||||
Binary file not shown.
222
venv/lib/python3.11/site-packages/_distutils_hack/__init__.py
Normal file
222
venv/lib/python3.11/site-packages/_distutils_hack/__init__.py
Normal file
@@ -0,0 +1,222 @@
|
||||
# don't import any costly modules
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
is_pypy = '__pypy__' in sys.builtin_module_names
|
||||
|
||||
|
||||
def warn_distutils_present():
|
||||
if 'distutils' not in sys.modules:
|
||||
return
|
||||
if is_pypy and sys.version_info < (3, 7):
|
||||
# PyPy for 3.6 unconditionally imports distutils, so bypass the warning
|
||||
# https://foss.heptapod.net/pypy/pypy/-/blob/be829135bc0d758997b3566062999ee8b23872b4/lib-python/3/site.py#L250
|
||||
return
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"Distutils was imported before Setuptools, but importing Setuptools "
|
||||
"also replaces the `distutils` module in `sys.modules`. This may lead "
|
||||
"to undesirable behaviors or errors. To avoid these issues, avoid "
|
||||
"using distutils directly, ensure that setuptools is installed in the "
|
||||
"traditional way (e.g. not an editable install), and/or make sure "
|
||||
"that setuptools is always imported before distutils."
|
||||
)
|
||||
|
||||
|
||||
def clear_distutils():
|
||||
if 'distutils' not in sys.modules:
|
||||
return
|
||||
import warnings
|
||||
|
||||
warnings.warn("Setuptools is replacing distutils.")
|
||||
mods = [
|
||||
name
|
||||
for name in sys.modules
|
||||
if name == "distutils" or name.startswith("distutils.")
|
||||
]
|
||||
for name in mods:
|
||||
del sys.modules[name]
|
||||
|
||||
|
||||
def enabled():
|
||||
"""
|
||||
Allow selection of distutils by environment variable.
|
||||
"""
|
||||
which = os.environ.get('SETUPTOOLS_USE_DISTUTILS', 'local')
|
||||
return which == 'local'
|
||||
|
||||
|
||||
def ensure_local_distutils():
|
||||
import importlib
|
||||
|
||||
clear_distutils()
|
||||
|
||||
# With the DistutilsMetaFinder in place,
|
||||
# perform an import to cause distutils to be
|
||||
# loaded from setuptools._distutils. Ref #2906.
|
||||
with shim():
|
||||
importlib.import_module('distutils')
|
||||
|
||||
# check that submodules load as expected
|
||||
core = importlib.import_module('distutils.core')
|
||||
assert '_distutils' in core.__file__, core.__file__
|
||||
assert 'setuptools._distutils.log' not in sys.modules
|
||||
|
||||
|
||||
def do_override():
|
||||
"""
|
||||
Ensure that the local copy of distutils is preferred over stdlib.
|
||||
|
||||
See https://github.com/pypa/setuptools/issues/417#issuecomment-392298401
|
||||
for more motivation.
|
||||
"""
|
||||
if enabled():
|
||||
warn_distutils_present()
|
||||
ensure_local_distutils()
|
||||
|
||||
|
||||
class _TrivialRe:
|
||||
def __init__(self, *patterns):
|
||||
self._patterns = patterns
|
||||
|
||||
def match(self, string):
|
||||
return all(pat in string for pat in self._patterns)
|
||||
|
||||
|
||||
class DistutilsMetaFinder:
|
||||
def find_spec(self, fullname, path, target=None):
|
||||
# optimization: only consider top level modules and those
|
||||
# found in the CPython test suite.
|
||||
if path is not None and not fullname.startswith('test.'):
|
||||
return
|
||||
|
||||
method_name = 'spec_for_{fullname}'.format(**locals())
|
||||
method = getattr(self, method_name, lambda: None)
|
||||
return method()
|
||||
|
||||
def spec_for_distutils(self):
|
||||
if self.is_cpython():
|
||||
return
|
||||
|
||||
import importlib
|
||||
import importlib.abc
|
||||
import importlib.util
|
||||
|
||||
try:
|
||||
mod = importlib.import_module('setuptools._distutils')
|
||||
except Exception:
|
||||
# There are a couple of cases where setuptools._distutils
|
||||
# may not be present:
|
||||
# - An older Setuptools without a local distutils is
|
||||
# taking precedence. Ref #2957.
|
||||
# - Path manipulation during sitecustomize removes
|
||||
# setuptools from the path but only after the hook
|
||||
# has been loaded. Ref #2980.
|
||||
# In either case, fall back to stdlib behavior.
|
||||
return
|
||||
|
||||
class DistutilsLoader(importlib.abc.Loader):
|
||||
def create_module(self, spec):
|
||||
mod.__name__ = 'distutils'
|
||||
return mod
|
||||
|
||||
def exec_module(self, module):
|
||||
pass
|
||||
|
||||
return importlib.util.spec_from_loader(
|
||||
'distutils', DistutilsLoader(), origin=mod.__file__
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def is_cpython():
|
||||
"""
|
||||
Suppress supplying distutils for CPython (build and tests).
|
||||
Ref #2965 and #3007.
|
||||
"""
|
||||
return os.path.isfile('pybuilddir.txt')
|
||||
|
||||
def spec_for_pip(self):
|
||||
"""
|
||||
Ensure stdlib distutils when running under pip.
|
||||
See pypa/pip#8761 for rationale.
|
||||
"""
|
||||
if self.pip_imported_during_build():
|
||||
return
|
||||
clear_distutils()
|
||||
self.spec_for_distutils = lambda: None
|
||||
|
||||
@classmethod
|
||||
def pip_imported_during_build(cls):
|
||||
"""
|
||||
Detect if pip is being imported in a build script. Ref #2355.
|
||||
"""
|
||||
import traceback
|
||||
|
||||
return any(
|
||||
cls.frame_file_is_setup(frame) for frame, line in traceback.walk_stack(None)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def frame_file_is_setup(frame):
|
||||
"""
|
||||
Return True if the indicated frame suggests a setup.py file.
|
||||
"""
|
||||
# some frames may not have __file__ (#2940)
|
||||
return frame.f_globals.get('__file__', '').endswith('setup.py')
|
||||
|
||||
def spec_for_sensitive_tests(self):
|
||||
"""
|
||||
Ensure stdlib distutils when running select tests under CPython.
|
||||
|
||||
python/cpython#91169
|
||||
"""
|
||||
clear_distutils()
|
||||
self.spec_for_distutils = lambda: None
|
||||
|
||||
sensitive_tests = (
|
||||
[
|
||||
'test.test_distutils',
|
||||
'test.test_peg_generator',
|
||||
'test.test_importlib',
|
||||
]
|
||||
if sys.version_info < (3, 10)
|
||||
else [
|
||||
'test.test_distutils',
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
for name in DistutilsMetaFinder.sensitive_tests:
|
||||
setattr(
|
||||
DistutilsMetaFinder,
|
||||
f'spec_for_{name}',
|
||||
DistutilsMetaFinder.spec_for_sensitive_tests,
|
||||
)
|
||||
|
||||
|
||||
DISTUTILS_FINDER = DistutilsMetaFinder()
|
||||
|
||||
|
||||
def add_shim():
|
||||
DISTUTILS_FINDER in sys.meta_path or insert_shim()
|
||||
|
||||
|
||||
class shim:
|
||||
def __enter__(self):
|
||||
insert_shim()
|
||||
|
||||
def __exit__(self, exc, value, tb):
|
||||
remove_shim()
|
||||
|
||||
|
||||
def insert_shim():
|
||||
sys.meta_path.insert(0, DISTUTILS_FINDER)
|
||||
|
||||
|
||||
def remove_shim():
|
||||
try:
|
||||
sys.meta_path.remove(DISTUTILS_FINDER)
|
||||
except ValueError:
|
||||
pass
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
__import__('_distutils_hack').do_override()
|
||||
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2014 Jeff Quast
|
||||
Copyright (c) 2011 Erik Rose
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,268 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: blessed
|
||||
Version: 1.20.0
|
||||
Summary: Easy, practical library for making terminal apps, by providing an elegant, well-documented interface to Colors, Keyboard input, and screen Positioning capabilities.
|
||||
Home-page: https://github.com/jquast/blessed
|
||||
Author: Jeff Quast, Erik Rose, Avram Lubkin
|
||||
Author-email: contact@jeffquast.com
|
||||
License: MIT
|
||||
Project-URL: Documentation, https://blessed.readthedocs.io
|
||||
Keywords: terminal,sequences,tty,curses,ncurses,formatting,style,color,console,keyboard,ansi,xterm
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: Natural Language :: English
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Environment :: Console
|
||||
Classifier: Environment :: Console :: Curses
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Operating System :: POSIX
|
||||
Classifier: Operating System :: Microsoft :: Windows
|
||||
Classifier: Programming Language :: Python :: 2
|
||||
Classifier: Programming Language :: Python :: 2.7
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3.4
|
||||
Classifier: Programming Language :: Python :: 3.5
|
||||
Classifier: Programming Language :: Python :: 3.6
|
||||
Classifier: Programming Language :: Python :: 3.7
|
||||
Classifier: Programming Language :: Python :: 3.8
|
||||
Classifier: Programming Language :: Python :: 3.9
|
||||
Classifier: Programming Language :: Python :: 3.10
|
||||
Classifier: Programming Language :: Python :: 3.11
|
||||
Classifier: Topic :: Software Development :: Libraries
|
||||
Classifier: Topic :: Software Development :: User Interfaces
|
||||
Classifier: Topic :: Terminals
|
||||
Classifier: Typing :: Typed
|
||||
Requires-Python: >=2.7
|
||||
License-File: LICENSE
|
||||
Requires-Dist: wcwidth (>=0.1.4)
|
||||
Requires-Dist: six (>=1.9.0)
|
||||
Requires-Dist: jinxed (>=1.1.0) ; platform_system == "Windows"
|
||||
Requires-Dist: ordereddict (==1.1) ; python_version < "2.7"
|
||||
Requires-Dist: backports.functools-lru-cache (>=1.2.1) ; python_version < "3.2"
|
||||
|
||||
| |pypi_downloads| |codecov| |windows| |linux| |mac| |bsd|
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
Blessed is an easy, practical *library* for making *terminal* apps, by providing an elegant,
|
||||
well-documented interface to Colors_, Keyboard_ input, and screen position and Location_
|
||||
capabilities.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from blessed import Terminal
|
||||
|
||||
term = Terminal()
|
||||
|
||||
print(term.home + term.clear + term.move_y(term.height // 2))
|
||||
print(term.black_on_darkkhaki(term.center('press any key to continue.')))
|
||||
|
||||
with term.cbreak(), term.hidden_cursor():
|
||||
inp = term.inkey()
|
||||
|
||||
print(term.move_down(2) + 'You pressed ' + term.bold(repr(inp)))
|
||||
|
||||
.. figure:: https://dxtz6bzwq9sxx.cloudfront.net/demo_basic_intro.gif
|
||||
:alt: Animation of running the code example
|
||||
|
||||
It's meant to be *fun* and *easy*, to do basic terminal graphics and styling with Python using
|
||||
*blessed*. Terminal_ is the only class you need to import and the only object you should need for
|
||||
Terminal capabilities.
|
||||
|
||||
Whether you want to improve CLI apps with colors, or make fullscreen applications or games,
|
||||
*blessed* should help get you started quickly. Your users will love it because it works on Windows,
|
||||
Mac, and Linux, and you will love it because it has plenty of documentation and examples!
|
||||
|
||||
Full documentation at https://blessed.readthedocs.io/en/latest/
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. figure:: https://dxtz6bzwq9sxx.cloudfront.net/blessed_demo_intro.gif
|
||||
:alt: Animations of x11-colorpicker.py, bounce.py, worms.py, and plasma.py
|
||||
|
||||
x11-colorpicker.py_, bounce.py_, worms.py_, and plasma.py_, from our repository.
|
||||
|
||||
Exemplary 3rd-party examples which use *blessed*,
|
||||
|
||||
.. figure:: https://dxtz6bzwq9sxx.cloudfront.net/demo_3rdparty_voltron.png
|
||||
:alt: Screenshot of 'Voltron' (By the author of Voltron, from their README).
|
||||
|
||||
Voltron_ is an extensible debugger UI toolkit written in Python
|
||||
|
||||
.. figure:: https://dxtz6bzwq9sxx.cloudfront.net/demo_3rdparty_cursewords.gif
|
||||
:alt: Animation of 'cursewords' (By the author of cursewords, from their README).
|
||||
|
||||
cursewords_ is "graphical" command line program for solving crossword puzzles in the terminal.
|
||||
|
||||
.. figure:: https://dxtz6bzwq9sxx.cloudfront.net/demo_3rdparty_githeat.gif
|
||||
:alt: Animation of 'githeat.interactive', using blessed repository at the time of capture.
|
||||
|
||||
GitHeat_ builds an interactive heatmap of git history.
|
||||
|
||||
.. figure:: https://dxtz6bzwq9sxx.cloudfront.net/demo_3rdparty_dashing.gif
|
||||
:alt: Animations from 'Dashing' (By the author of Dashing, from their README)
|
||||
|
||||
Dashing_ is a library to quickly create terminal-based dashboards.
|
||||
|
||||
.. figure:: https://dxtz6bzwq9sxx.cloudfront.net/demo_3rdparty_enlighten.gif
|
||||
:alt: Animations from 'Enlighten' (By the author of Enlighten, from their README)
|
||||
|
||||
Enlighten_ is a console progress bar library that allows simultaneous output without redirection.
|
||||
|
||||
.. figure:: https://dxtz6bzwq9sxx.cloudfront.net/blessed_3rdparty_macht.gif
|
||||
:alt: Demonstration of 'macht', a 2048 clone
|
||||
|
||||
macht_ is a clone of the (briefly popular) puzzle game, 2048.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
*Blessed* works with Windows, Mac, Linux, and BSD's, on Python 2.7, 3.4, 3.5, 3.6, 3.7, and 3.8.
|
||||
|
||||
Brief Overview
|
||||
--------------
|
||||
|
||||
*Blessed* is more than just a Python wrapper around curses_:
|
||||
|
||||
* Styles_, Colors_, and maybe a little positioning without necessarily clearing the whole screen
|
||||
first.
|
||||
* Works great with Python's new f-strings_ or any other kind of string formatting.
|
||||
* Provides up-to-the-moment Location_ and terminal height and width, so you can respond to terminal
|
||||
size changes.
|
||||
* Avoids making a mess if the output gets piped to a non-terminal, you can output sequences to any
|
||||
file-like object such as *StringIO*, files, pipes or sockets.
|
||||
* Uses `terminfo(5)`_ so it works with any terminal type and capability: No more C-like calls to
|
||||
tigetstr_ and tparm_.
|
||||
* Non-obtrusive calls to only the capabilities database ensures that you are free to mix and match
|
||||
with calls to any other curses application code or library you like.
|
||||
* Provides context managers `Terminal.fullscreen()`_ and `Terminal.hidden_cursor()`_ to safely
|
||||
express terminal modes, curses development will no longer fudge up your shell.
|
||||
* Act intelligently when somebody redirects your output to a file, omitting all of the special
|
||||
sequences colors, but still containing all of the text.
|
||||
|
||||
*Blessed* is a fork of `blessings <https://github.com/erikrose/blessings>`_, which does all of
|
||||
the same above with the same API, as well as following **enhancements**:
|
||||
|
||||
* Windows support, new since Dec. 2019!
|
||||
* Dead-simple keyboard handling: safely decoding unicode input in your system's preferred locale and
|
||||
supports application/arrow keys.
|
||||
* 24-bit color support, using `Terminal.color_rgb()`_ and `Terminal.on_color_rgb()`_ and all X11
|
||||
Colors_ by name, and not by number.
|
||||
* Determine cursor location using `Terminal.get_location()`_, enter key-at-a-time input mode using
|
||||
`Terminal.cbreak()`_ or `Terminal.raw()`_ context managers, and read timed key presses using
|
||||
`Terminal.inkey()`_.
|
||||
* Allows the *printable length* of strings that contain sequences to be determined by
|
||||
`Terminal.length()`_, supporting additional methods `Terminal.wrap()`_ and `Terminal.center()`_,
|
||||
terminal-aware variants of the built-in function `textwrap.wrap()`_ and method `str.center()`_,
|
||||
respectively.
|
||||
* Allows sequences to be removed from strings that contain them, using `Terminal.strip_seqs()`_ or
|
||||
sequences and whitespace using `Terminal.strip()`_.
|
||||
|
||||
Before And After
|
||||
----------------
|
||||
|
||||
With the built-in curses_ module, this is how you would typically
|
||||
print some underlined text at the bottom of the screen:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from curses import tigetstr, setupterm, tparm
|
||||
from fcntl import ioctl
|
||||
from os import isatty
|
||||
import struct
|
||||
import sys
|
||||
from termios import TIOCGWINSZ
|
||||
|
||||
# If we want to tolerate having our output piped to other commands or
|
||||
# files without crashing, we need to do all this branching:
|
||||
if hasattr(sys.stdout, 'fileno') and isatty(sys.stdout.fileno()):
|
||||
setupterm()
|
||||
sc = tigetstr('sc')
|
||||
cup = tigetstr('cup')
|
||||
rc = tigetstr('rc')
|
||||
underline = tigetstr('smul')
|
||||
normal = tigetstr('sgr0')
|
||||
else:
|
||||
sc = cup = rc = underline = normal = ''
|
||||
|
||||
# Save cursor position.
|
||||
print(sc)
|
||||
|
||||
if cup:
|
||||
# tigetnum('lines') doesn't always update promptly, hence this:
|
||||
height = struct.unpack('hhhh', ioctl(0, TIOCGWINSZ, '\000' * 8))[0]
|
||||
|
||||
# Move cursor to bottom.
|
||||
print(tparm(cup, height - 1, 0))
|
||||
|
||||
print('This is {under}underlined{normal}!'
|
||||
.format(under=underline, normal=normal))
|
||||
|
||||
# Restore cursor position.
|
||||
print(rc)
|
||||
|
||||
The same program with *Blessed* is simply:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from blessed import Terminal
|
||||
|
||||
term = Terminal()
|
||||
with term.location(0, term.height - 1):
|
||||
print('This is ' + term.underline('underlined') + '!', end='')
|
||||
|
||||
.. _curses: https://docs.python.org/3/library/curses.html
|
||||
.. _tigetstr: http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/tigetstr.3
|
||||
.. _tparm: http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/tparm.3
|
||||
.. _`terminfo(5)`: https://invisible-island.net/ncurses/man/terminfo.5.html
|
||||
.. _str.center(): https://docs.python.org/3/library/stdtypes.html#str.center
|
||||
.. _textwrap.wrap(): https://docs.python.org/3/library/textwrap.html#textwrap.wrap
|
||||
.. _Terminal: https://blessed.readthedocs.io/en/stable/terminal.html
|
||||
.. _`Terminal.fullscreen()`: https://blessed.readthedocs.io/en/latest/api/terminal.html#blessed.terminal.Terminal.fullscreen
|
||||
.. _`Terminal.get_location()`: https://blessed.readthedocs.io/en/latest/location.html#finding-the-cursor
|
||||
.. _`Terminal.color_rgb()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.color_rgb
|
||||
.. _`Terminal.hidden_cursor()`: https://blessed.readthedocs.io/en/latest/api/terminal.html#blessed.terminal.Terminal.hidden_cursor
|
||||
.. _`Terminal.on_color_rgb()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.on_color_rgb
|
||||
.. _`Terminal.length()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.length
|
||||
.. _`Terminal.strip()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.strip
|
||||
.. _`Terminal.rstrip()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.rstrip
|
||||
.. _`Terminal.lstrip()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.lstrip
|
||||
.. _`Terminal.strip_seqs()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.strip_seqs
|
||||
.. _`Terminal.wrap()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.wrap
|
||||
.. _`Terminal.center()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.center
|
||||
.. _`Terminal.rjust()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.rjust
|
||||
.. _`Terminal.ljust()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.ljust
|
||||
.. _`Terminal.cbreak()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.cbreak
|
||||
.. _`Terminal.raw()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.raw
|
||||
.. _`Terminal.inkey()`: https://blessed.readthedocs.io/en/stable/api/terminal.html#blessed.terminal.Terminal.inkey
|
||||
.. _Colors: https://blessed.readthedocs.io/en/stable/colors.html
|
||||
.. _Styles: https://blessed.readthedocs.io/en/stable/terminal.html#styles
|
||||
.. _Location: https://blessed.readthedocs.io/en/stable/location.html
|
||||
.. _Keyboard: https://blessed.readthedocs.io/en/stable/keyboard.html
|
||||
.. _Examples: https://blessed.readthedocs.io/en/stable/examples.html
|
||||
.. _x11-colorpicker.py: https://blessed.readthedocs.io/en/stable/examples.html#x11-colorpicker-py
|
||||
.. _bounce.py: https://blessed.readthedocs.io/en/stable/examples.html#bounce-py
|
||||
.. _worms.py: https://blessed.readthedocs.io/en/stable/examples.html#worms-py
|
||||
.. _plasma.py: https://blessed.readthedocs.io/en/stable/examples.html#plasma-py
|
||||
.. _Voltron: https://github.com/snare/voltron
|
||||
.. _cursewords: https://github.com/thisisparker/cursewords
|
||||
.. _GitHeat: https://github.com/AmmsA/Githeat
|
||||
.. _Dashing: https://github.com/FedericoCeratto/dashing
|
||||
.. _Enlighten: https://github.com/Rockhopper-Technologies/enlighten
|
||||
.. _macht: https://github.com/rolfmorel/macht
|
||||
.. _f-strings: https://docs.python.org/3/reference/lexical_analysis.html#f-strings
|
||||
.. |pypi_downloads| image:: https://img.shields.io/pypi/dm/blessed.svg?logo=pypi
|
||||
:alt: Downloads
|
||||
:target: https://pypi.org/project/blessed/
|
||||
.. |codecov| image:: https://codecov.io/gh/jquast/blessed/branch/master/graph/badge.svg
|
||||
:alt: codecov.io Code Coverage
|
||||
:target: https://codecov.io/gh/jquast/blessed/
|
||||
.. |linux| image:: https://img.shields.io/badge/Linux-yes-success?logo=linux
|
||||
:alt: Linux supported
|
||||
.. |windows| image:: https://img.shields.io/badge/Windows-NEW-success?logo=windows
|
||||
:alt: Windows supported
|
||||
.. |mac| image:: https://img.shields.io/badge/MacOS-yes-success?logo=apple
|
||||
:alt: MacOS supported
|
||||
.. |bsd| image:: https://img.shields.io/badge/BSD-yes-success?logo=freebsd
|
||||
:alt: BSD supported
|
||||
@@ -0,0 +1,34 @@
|
||||
blessed-1.20.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
blessed-1.20.0.dist-info/LICENSE,sha256=YBSQ1biC0QDEeC-dqb_dI_lg5reeNazESZQ5XBj01X0,1083
|
||||
blessed-1.20.0.dist-info/METADATA,sha256=vMzKv4ScrFcnTZHR41JkReyuG8DWttQ2aHMptngB22A,13237
|
||||
blessed-1.20.0.dist-info/RECORD,,
|
||||
blessed-1.20.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
blessed-1.20.0.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
|
||||
blessed-1.20.0.dist-info/top_level.txt,sha256=2lUIfLwFZtAucvesS5UE8_MxXID5rSx_3gJ2-1JGckA,8
|
||||
blessed/__init__.py,sha256=UubFXL35qZPrqiwOud7s9AlgyQI7XdHrk-cuCJ_zlvE,687
|
||||
blessed/__pycache__/__init__.cpython-311.pyc,,
|
||||
blessed/__pycache__/_capabilities.cpython-311.pyc,,
|
||||
blessed/__pycache__/color.cpython-311.pyc,,
|
||||
blessed/__pycache__/colorspace.cpython-311.pyc,,
|
||||
blessed/__pycache__/formatters.cpython-311.pyc,,
|
||||
blessed/__pycache__/keyboard.cpython-311.pyc,,
|
||||
blessed/__pycache__/sequences.cpython-311.pyc,,
|
||||
blessed/__pycache__/terminal.cpython-311.pyc,,
|
||||
blessed/__pycache__/win_terminal.cpython-311.pyc,,
|
||||
blessed/_capabilities.py,sha256=Thj8lgDvhfM6TttvziDu0mabqZqYnwAwC3NTtSMntxc,6292
|
||||
blessed/_capabilities.pyi,sha256=If5dG9LhrIyTxUuCuV44bNxnWMk3S7Xvry3oGOBHp2k,265
|
||||
blessed/color.py,sha256=D5VmWAsZxSYIERKmkJ7FVhZgNssEtUkV8GcMbDnoxVk,7502
|
||||
blessed/color.pyi,sha256=4DNLFe-SMCVKbsvuMFLWUzNCdy45bgtZuk3wP51HlKQ,690
|
||||
blessed/colorspace.py,sha256=LMf6DePXVx0wOJx-jwGbixLgrBS4wy6vnDg4XBkNkis,35313
|
||||
blessed/colorspace.pyi,sha256=zwo_F4rf0GSPJsW2irvxHQ3SqNlGgt7VQOFN2hXnTnw,234
|
||||
blessed/formatters.py,sha256=vifyppCMWZgHk3jSzzARpgGNkeEsfQaegfp_TJNalA0,19393
|
||||
blessed/formatters.pyi,sha256=gDgcWIk3pqif7SZgL5DG--GjO7QXwzen5UNgqQ_XHsw,2091
|
||||
blessed/keyboard.py,sha256=hO5QKEDsNY4W1nRGR4-dSI2WtWQGud9UzeHegccrJCU,17708
|
||||
blessed/keyboard.pyi,sha256=9ibu_A44OkWKcdy_36EeHVhK4ybnurig5arrXxwVOeM,796
|
||||
blessed/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
blessed/sequences.py,sha256=gdYs1AxZTwve8XYiz_dalfA5R7nDH95vXVha-pKaQIg,17114
|
||||
blessed/sequences.pyi,sha256=_zJkZm8S015g242mRUoEp12Qs27DS348vFqkSRsYfHc,1852
|
||||
blessed/terminal.py,sha256=jYUIfIBQBmhPLi-pkDoyVRHDOBn5YCqWV3JzIhIzPIU,62075
|
||||
blessed/terminal.pyi,sha256=hG_PWNjMuB6zRVVeZCDOMD_ncrN_4uraIVpyZqSCB78,4307
|
||||
blessed/win_terminal.py,sha256=uGl52EiEq4K3udsZJHn2tlnESUHg_77fxWrEuFD77WY,5804
|
||||
blessed/win_terminal.pyi,sha256=GoS67cnj927_SXZRr1WCLD21ie_w7zlA20V33clpV7E,333
|
||||
@@ -0,0 +1,6 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.37.1)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py2-none-any
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
blessed
|
||||
23
venv/lib/python3.11/site-packages/blessed/__init__.py
Normal file
23
venv/lib/python3.11/site-packages/blessed/__init__.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
A thin, practical wrapper around terminal capabilities in Python.
|
||||
|
||||
http://pypi.python.org/pypi/blessed
|
||||
"""
|
||||
# std imports
|
||||
import sys as _sys
|
||||
import platform as _platform
|
||||
|
||||
# isort: off
|
||||
if _platform.system() == 'Windows':
|
||||
from blessed.win_terminal import Terminal
|
||||
else:
|
||||
from blessed.terminal import Terminal # type: ignore
|
||||
|
||||
if (3, 0, 0) <= _sys.version_info[:3] < (3, 2, 3):
|
||||
# Good till 3.2.10
|
||||
# Python 3.x < 3.2.3 has a bug in which tparm() erroneously takes a string.
|
||||
raise ImportError('Blessed needs Python 3.2.3 or greater for Python 3 '
|
||||
'support due to http://bugs.python.org/issue10570.')
|
||||
|
||||
__all__ = ('Terminal',)
|
||||
__version__ = "1.20.0"
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
168
venv/lib/python3.11/site-packages/blessed/_capabilities.py
Normal file
168
venv/lib/python3.11/site-packages/blessed/_capabilities.py
Normal file
@@ -0,0 +1,168 @@
|
||||
"""Terminal capability builder patterns."""
|
||||
# std imports
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
|
||||
__all__ = (
|
||||
'CAPABILITY_DATABASE',
|
||||
'CAPABILITIES_RAW_MIXIN',
|
||||
'CAPABILITIES_ADDITIVES',
|
||||
'CAPABILITIES_CAUSE_MOVEMENT',
|
||||
)
|
||||
|
||||
CAPABILITY_DATABASE = OrderedDict((
|
||||
('bell', ('bel', {})),
|
||||
('carriage_return', ('cr', {})),
|
||||
('change_scroll_region', ('csr', {'nparams': 2})),
|
||||
('clear_all_tabs', ('tbc', {})),
|
||||
('clear_screen', ('clear', {})),
|
||||
('clr_bol', ('el1', {})),
|
||||
('clr_eol', ('el', {})),
|
||||
('clr_eos', ('clear_eos', {})),
|
||||
('column_address', ('hpa', {'nparams': 1})),
|
||||
('cursor_address', ('cup', {'nparams': 2, 'match_grouped': True})),
|
||||
('cursor_down', ('cud1', {})),
|
||||
('cursor_home', ('home', {})),
|
||||
('cursor_invisible', ('civis', {})),
|
||||
('cursor_left', ('cub1', {})),
|
||||
('cursor_normal', ('cnorm', {})),
|
||||
('cursor_report', ('u6', {'nparams': 2, 'match_grouped': True})),
|
||||
('cursor_right', ('cuf1', {})),
|
||||
('cursor_up', ('cuu1', {})),
|
||||
('cursor_visible', ('cvvis', {})),
|
||||
('delete_character', ('dch1', {})),
|
||||
('delete_line', ('dl1', {})),
|
||||
('enter_blink_mode', ('blink', {})),
|
||||
('enter_bold_mode', ('bold', {})),
|
||||
('enter_dim_mode', ('dim', {})),
|
||||
('enter_fullscreen', ('smcup', {})),
|
||||
('enter_standout_mode', ('standout', {})),
|
||||
('enter_superscript_mode', ('superscript', {})),
|
||||
('enter_susimpleript_mode', ('susimpleript', {})),
|
||||
('enter_underline_mode', ('underline', {})),
|
||||
('erase_chars', ('ech', {'nparams': 1})),
|
||||
('exit_alt_charset_mode', ('rmacs', {})),
|
||||
('exit_am_mode', ('rmam', {})),
|
||||
('exit_attribute_mode', ('sgr0', {})),
|
||||
('exit_ca_mode', ('rmcup', {})),
|
||||
('exit_fullscreen', ('rmcup', {})),
|
||||
('exit_insert_mode', ('rmir', {})),
|
||||
('exit_standout_mode', ('rmso', {})),
|
||||
('exit_underline_mode', ('rmul', {})),
|
||||
('flash_hook', ('hook', {})),
|
||||
('flash_screen', ('flash', {})),
|
||||
('insert_line', ('il1', {})),
|
||||
('keypad_local', ('rmkx', {})),
|
||||
('keypad_xmit', ('smkx', {})),
|
||||
('meta_off', ('rmm', {})),
|
||||
('meta_on', ('smm', {})),
|
||||
('orig_pair', ('op', {})),
|
||||
('parm_down_cursor', ('cud', {'nparams': 1})),
|
||||
('parm_left_cursor', ('cub', {'nparams': 1, 'match_grouped': True})),
|
||||
('parm_dch', ('dch', {'nparams': 1})),
|
||||
('parm_delete_line', ('dl', {'nparams': 1})),
|
||||
('parm_ich', ('ich', {'nparams': 1})),
|
||||
('parm_index', ('indn', {'nparams': 1})),
|
||||
('parm_insert_line', ('il', {'nparams': 1})),
|
||||
('parm_right_cursor', ('cuf', {'nparams': 1, 'match_grouped': True})),
|
||||
('parm_rindex', ('rin', {'nparams': 1})),
|
||||
('parm_up_cursor', ('cuu', {'nparams': 1})),
|
||||
('print_screen', ('mc0', {})),
|
||||
('prtr_off', ('mc4', {})),
|
||||
('prtr_on', ('mc5', {})),
|
||||
('reset_1string', ('r1', {})),
|
||||
('reset_2string', ('r2', {})),
|
||||
('reset_3string', ('r3', {})),
|
||||
('restore_cursor', ('rc', {})),
|
||||
('row_address', ('vpa', {'nparams': 1})),
|
||||
('save_cursor', ('sc', {})),
|
||||
('scroll_forward', ('ind', {})),
|
||||
('scroll_reverse', ('rev', {})),
|
||||
('set0_des_seq', ('s0ds', {})),
|
||||
('set1_des_seq', ('s1ds', {})),
|
||||
('set2_des_seq', ('s2ds', {})),
|
||||
('set3_des_seq', ('s3ds', {})),
|
||||
# this 'color' is deceiving, but often matching, and a better match
|
||||
# than set_a_attributes1 or set_a_foreground.
|
||||
('color', ('_foreground_color', {'nparams': 1, 'match_any': True,
|
||||
'numeric': 1})),
|
||||
('set_a_foreground', ('color', {'nparams': 1, 'match_any': True,
|
||||
'numeric': 1})),
|
||||
('set_a_background', ('on_color', {'nparams': 1, 'match_any': True,
|
||||
'numeric': 1})),
|
||||
('set_tab', ('hts', {})),
|
||||
('tab', ('ht', {})),
|
||||
('italic', ('sitm', {})),
|
||||
('no_italic', ('sitm', {})),
|
||||
))
|
||||
|
||||
CAPABILITIES_RAW_MIXIN = {
|
||||
'bell': re.escape('\a'),
|
||||
'carriage_return': re.escape('\r'),
|
||||
'cursor_left': re.escape('\b'),
|
||||
'cursor_report': re.escape('\x1b') + r'\[(\d+)\;(\d+)R',
|
||||
'cursor_right': re.escape('\x1b') + r'\[C',
|
||||
'exit_attribute_mode': re.escape('\x1b') + r'\[m',
|
||||
'parm_left_cursor': re.escape('\x1b') + r'\[(\d+)D',
|
||||
'parm_right_cursor': re.escape('\x1b') + r'\[(\d+)C',
|
||||
'restore_cursor': re.escape(r'\x1b\[u'),
|
||||
'save_cursor': re.escape(r'\x1b\[s'),
|
||||
'scroll_forward': re.escape('\n'),
|
||||
'set0_des_seq': re.escape('\x1b(B'),
|
||||
'tab': re.escape('\t'),
|
||||
}
|
||||
_ANY_NOTESC = '[^' + re.escape('\x1b') + ']*'
|
||||
|
||||
CAPABILITIES_ADDITIVES = {
|
||||
'link': ('link',
|
||||
re.escape('\x1b') + r'\]8;' + _ANY_NOTESC + ';' +
|
||||
_ANY_NOTESC + re.escape('\x1b') + '\\\\'),
|
||||
'color256': ('color', re.escape('\x1b') + r'\[38;5;\d+m'),
|
||||
'on_color256': ('on_color', re.escape('\x1b') + r'\[48;5;\d+m'),
|
||||
'color_rgb': ('color_rgb', re.escape('\x1b') + r'\[38;2;\d+;\d+;\d+m'),
|
||||
'on_color_rgb': ('on_color_rgb', re.escape('\x1b') + r'\[48;2;\d+;\d+;\d+m'),
|
||||
'shift_in': ('', re.escape('\x0f')),
|
||||
'shift_out': ('', re.escape('\x0e')),
|
||||
# sgr(...) outputs strangely, use the basic ANSI/EMCA-48 codes here.
|
||||
'set_a_attributes1': (
|
||||
'sgr', re.escape('\x1b') + r'\[\d+m'),
|
||||
'set_a_attributes2': (
|
||||
'sgr', re.escape('\x1b') + r'\[\d+\;\d+m'),
|
||||
'set_a_attributes3': (
|
||||
'sgr', re.escape('\x1b') + r'\[\d+\;\d+\;\d+m'),
|
||||
'set_a_attributes4': (
|
||||
'sgr', re.escape('\x1b') + r'\[\d+\;\d+\;\d+\;\d+m'),
|
||||
# this helps where xterm's sgr0 includes set0_des_seq, we'd
|
||||
# rather like to also match this immediate substring.
|
||||
'sgr0': ('sgr0', re.escape('\x1b') + r'\[m'),
|
||||
'backspace': ('', re.escape('\b')),
|
||||
'ascii_tab': ('', re.escape('\t')),
|
||||
'clr_eol': ('', re.escape('\x1b[K')),
|
||||
'clr_eol0': ('', re.escape('\x1b[0K')),
|
||||
'clr_bol': ('', re.escape('\x1b[1K')),
|
||||
'clr_eosK': ('', re.escape('\x1b[2K')),
|
||||
}
|
||||
|
||||
CAPABILITIES_CAUSE_MOVEMENT = (
|
||||
'ascii_tab',
|
||||
'backspace',
|
||||
'carriage_return',
|
||||
'clear_screen',
|
||||
'column_address',
|
||||
'cursor_address',
|
||||
'cursor_down',
|
||||
'cursor_home',
|
||||
'cursor_left',
|
||||
'cursor_right',
|
||||
'cursor_up',
|
||||
'enter_fullscreen',
|
||||
'exit_fullscreen',
|
||||
'parm_down_cursor',
|
||||
'parm_left_cursor',
|
||||
'parm_right_cursor',
|
||||
'parm_up_cursor',
|
||||
'restore_cursor',
|
||||
'row_address',
|
||||
'scroll_forward',
|
||||
'tab',
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
# std imports
|
||||
from typing import Any, Dict, Tuple, OrderedDict
|
||||
|
||||
CAPABILITY_DATABASE: OrderedDict[str, Tuple[str, Dict[str, Any]]]
|
||||
CAPABILITIES_RAW_MIXIN: Dict[str, str]
|
||||
CAPABILITIES_ADDITIVES: Dict[str, Tuple[str, str]]
|
||||
CAPABILITIES_CAUSE_MOVEMENT: Tuple[str, ...]
|
||||
258
venv/lib/python3.11/site-packages/blessed/color.py
Normal file
258
venv/lib/python3.11/site-packages/blessed/color.py
Normal file
@@ -0,0 +1,258 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Sub-module providing color functions.
|
||||
|
||||
References,
|
||||
|
||||
- https://en.wikipedia.org/wiki/Color_difference
|
||||
- http://www.easyrgb.com/en/math.php
|
||||
- Measuring Colour by R.W.G. Hunt and M.R. Pointer
|
||||
"""
|
||||
|
||||
# std imports
|
||||
from math import cos, exp, sin, sqrt, atan2
|
||||
|
||||
# isort: off
|
||||
try:
|
||||
from functools import lru_cache
|
||||
except ImportError:
|
||||
# lru_cache was added in Python 3.2
|
||||
from backports.functools_lru_cache import lru_cache
|
||||
|
||||
|
||||
def rgb_to_xyz(red, green, blue):
|
||||
"""
|
||||
Convert standard RGB color to XYZ color.
|
||||
|
||||
:arg int red: RGB value of Red.
|
||||
:arg int green: RGB value of Green.
|
||||
:arg int blue: RGB value of Blue.
|
||||
:returns: Tuple (X, Y, Z) representing XYZ color
|
||||
:rtype: tuple
|
||||
|
||||
D65/2° standard illuminant
|
||||
"""
|
||||
rgb = []
|
||||
for val in red, green, blue:
|
||||
val /= 255.0
|
||||
if val > 0.04045:
|
||||
val = pow((val + 0.055) / 1.055, 2.4)
|
||||
else:
|
||||
val /= 12.92
|
||||
val *= 100
|
||||
rgb.append(val)
|
||||
|
||||
red, green, blue = rgb # pylint: disable=unbalanced-tuple-unpacking
|
||||
x_val = red * 0.4124 + green * 0.3576 + blue * 0.1805
|
||||
y_val = red * 0.2126 + green * 0.7152 + blue * 0.0722
|
||||
z_val = red * 0.0193 + green * 0.1192 + blue * 0.9505
|
||||
|
||||
return x_val, y_val, z_val
|
||||
|
||||
|
||||
def xyz_to_lab(x_val, y_val, z_val):
|
||||
"""
|
||||
Convert XYZ color to CIE-Lab color.
|
||||
|
||||
:arg float x_val: XYZ value of X.
|
||||
:arg float y_val: XYZ value of Y.
|
||||
:arg float z_val: XYZ value of Z.
|
||||
:returns: Tuple (L, a, b) representing CIE-Lab color
|
||||
:rtype: tuple
|
||||
|
||||
D65/2° standard illuminant
|
||||
"""
|
||||
xyz = []
|
||||
for val, ref in (x_val, 95.047), (y_val, 100.0), (z_val, 108.883):
|
||||
val /= ref
|
||||
val = pow(val, 1 / 3.0) if val > 0.008856 else 7.787 * val + 16 / 116.0
|
||||
xyz.append(val)
|
||||
|
||||
x_val, y_val, z_val = xyz # pylint: disable=unbalanced-tuple-unpacking
|
||||
cie_l = 116 * y_val - 16
|
||||
cie_a = 500 * (x_val - y_val)
|
||||
cie_b = 200 * (y_val - z_val)
|
||||
|
||||
return cie_l, cie_a, cie_b
|
||||
|
||||
|
||||
@lru_cache(maxsize=256)
|
||||
def rgb_to_lab(red, green, blue):
|
||||
"""
|
||||
Convert RGB color to CIE-Lab color.
|
||||
|
||||
:arg int red: RGB value of Red.
|
||||
:arg int green: RGB value of Green.
|
||||
:arg int blue: RGB value of Blue.
|
||||
:returns: Tuple (L, a, b) representing CIE-Lab color
|
||||
:rtype: tuple
|
||||
|
||||
D65/2° standard illuminant
|
||||
"""
|
||||
return xyz_to_lab(*rgb_to_xyz(red, green, blue))
|
||||
|
||||
|
||||
def dist_rgb(rgb1, rgb2):
|
||||
"""
|
||||
Determine distance between two rgb colors.
|
||||
|
||||
:arg tuple rgb1: RGB color definition
|
||||
:arg tuple rgb2: RGB color definition
|
||||
:returns: Square of the distance between provided colors
|
||||
:rtype: float
|
||||
|
||||
This works by treating RGB colors as coordinates in three dimensional
|
||||
space and finding the closest point within the configured color range
|
||||
using the formula::
|
||||
|
||||
d^2 = (r2 - r1)^2 + (g2 - g1)^2 + (b2 - b1)^2
|
||||
|
||||
For efficiency, the square of the distance is returned
|
||||
which is sufficient for comparisons
|
||||
"""
|
||||
return sum(pow(rgb1[idx] - rgb2[idx], 2) for idx in (0, 1, 2))
|
||||
|
||||
|
||||
def dist_rgb_weighted(rgb1, rgb2):
|
||||
"""
|
||||
Determine the weighted distance between two rgb colors.
|
||||
|
||||
:arg tuple rgb1: RGB color definition
|
||||
:arg tuple rgb2: RGB color definition
|
||||
:returns: Square of the distance between provided colors
|
||||
:rtype: float
|
||||
|
||||
Similar to a standard distance formula, the values are weighted
|
||||
to approximate human perception of color differences
|
||||
|
||||
For efficiency, the square of the distance is returned
|
||||
which is sufficient for comparisons
|
||||
"""
|
||||
red_mean = (rgb1[0] + rgb2[0]) / 2.0
|
||||
|
||||
return ((2 + red_mean / 256) * pow(rgb1[0] - rgb2[0], 2) +
|
||||
4 * pow(rgb1[1] - rgb2[1], 2) +
|
||||
(2 + (255 - red_mean) / 256) * pow(rgb1[2] - rgb2[2], 2))
|
||||
|
||||
|
||||
def dist_cie76(rgb1, rgb2):
|
||||
"""
|
||||
Determine distance between two rgb colors using the CIE94 algorithm.
|
||||
|
||||
:arg tuple rgb1: RGB color definition
|
||||
:arg tuple rgb2: RGB color definition
|
||||
:returns: Square of the distance between provided colors
|
||||
:rtype: float
|
||||
|
||||
For efficiency, the square of the distance is returned
|
||||
which is sufficient for comparisons
|
||||
"""
|
||||
l_1, a_1, b_1 = rgb_to_lab(*rgb1)
|
||||
l_2, a_2, b_2 = rgb_to_lab(*rgb2)
|
||||
return pow(l_1 - l_2, 2) + pow(a_1 - a_2, 2) + pow(b_1 - b_2, 2)
|
||||
|
||||
|
||||
def dist_cie94(rgb1, rgb2):
|
||||
# pylint: disable=too-many-locals
|
||||
"""
|
||||
Determine distance between two rgb colors using the CIE94 algorithm.
|
||||
|
||||
:arg tuple rgb1: RGB color definition
|
||||
:arg tuple rgb2: RGB color definition
|
||||
:returns: Square of the distance between provided colors
|
||||
:rtype: float
|
||||
|
||||
For efficiency, the square of the distance is returned
|
||||
which is sufficient for comparisons
|
||||
"""
|
||||
l_1, a_1, b_1 = rgb_to_lab(*rgb1)
|
||||
l_2, a_2, b_2 = rgb_to_lab(*rgb2)
|
||||
|
||||
s_l = k_l = k_c = k_h = 1
|
||||
k_1 = 0.045
|
||||
k_2 = 0.015
|
||||
|
||||
delta_l = l_1 - l_2
|
||||
delta_a = a_1 - a_2
|
||||
delta_b = b_1 - b_2
|
||||
c_1 = sqrt(a_1 ** 2 + b_1 ** 2)
|
||||
c_2 = sqrt(a_2 ** 2 + b_2 ** 2)
|
||||
delta_c = c_1 - c_2
|
||||
delta_h = sqrt(delta_a ** 2 + delta_b ** 2 + delta_c ** 2)
|
||||
s_c = 1 + k_1 * c_1
|
||||
s_h = 1 + k_2 * c_1
|
||||
|
||||
return ((delta_l / (k_l * s_l)) ** 2 + # pylint: disable=superfluous-parens
|
||||
(delta_c / (k_c * s_c)) ** 2 +
|
||||
(delta_h / (k_h * s_h)) ** 2)
|
||||
|
||||
|
||||
def dist_cie2000(rgb1, rgb2):
|
||||
# pylint: disable=too-many-locals
|
||||
"""
|
||||
Determine distance between two rgb colors using the CIE2000 algorithm.
|
||||
|
||||
:arg tuple rgb1: RGB color definition
|
||||
:arg tuple rgb2: RGB color definition
|
||||
:returns: Square of the distance between provided colors
|
||||
:rtype: float
|
||||
|
||||
For efficiency, the square of the distance is returned
|
||||
which is sufficient for comparisons
|
||||
"""
|
||||
s_l = k_l = k_c = k_h = 1
|
||||
|
||||
l_1, a_1, b_1 = rgb_to_lab(*rgb1)
|
||||
l_2, a_2, b_2 = rgb_to_lab(*rgb2)
|
||||
|
||||
delta_l = l_2 - l_1
|
||||
l_mean = (l_1 + l_2) / 2
|
||||
|
||||
c_1 = sqrt(a_1 ** 2 + b_1 ** 2)
|
||||
c_2 = sqrt(a_2 ** 2 + b_2 ** 2)
|
||||
c_mean = (c_1 + c_2) / 2
|
||||
delta_c = c_1 - c_2
|
||||
|
||||
g_x = sqrt(c_mean ** 7 / (c_mean ** 7 + 25 ** 7))
|
||||
h_1 = atan2(b_1, a_1 + (a_1 / 2) * (1 - g_x)) % 360
|
||||
h_2 = atan2(b_2, a_2 + (a_2 / 2) * (1 - g_x)) % 360
|
||||
|
||||
if 0 in (c_1, c_2):
|
||||
delta_h_prime = 0
|
||||
h_mean = h_1 + h_2
|
||||
else:
|
||||
delta_h_prime = h_2 - h_1
|
||||
if abs(delta_h_prime) <= 180:
|
||||
h_mean = (h_1 + h_2) / 2
|
||||
else:
|
||||
if h_2 <= h_1:
|
||||
delta_h_prime += 360
|
||||
else:
|
||||
delta_h_prime -= 360
|
||||
h_mean = (h_1 + h_2 + 360) / 2 if h_1 + h_2 < 360 else (h_1 + h_2 - 360) / 2
|
||||
|
||||
delta_h = 2 * sqrt(c_1 * c_2) * sin(delta_h_prime / 2)
|
||||
|
||||
t_x = (1 -
|
||||
0.17 * cos(h_mean - 30) +
|
||||
0.24 * cos(2 * h_mean) +
|
||||
0.32 * cos(3 * h_mean + 6) -
|
||||
0.20 * cos(4 * h_mean - 63))
|
||||
|
||||
s_l = 1 + (0.015 * (l_mean - 50) ** 2) / sqrt(20 + (l_mean - 50) ** 2)
|
||||
s_c = 1 + 0.045 * c_mean
|
||||
s_h = 1 + 0.015 * c_mean * t_x
|
||||
r_t = -2 * g_x * sin(abs(60 * exp(-1 * abs((delta_h - 275) / 25) ** 2)))
|
||||
|
||||
delta_l = delta_l / (k_l * s_l)
|
||||
delta_c = delta_c / (k_c * s_c)
|
||||
delta_h = delta_h / (k_h * s_h)
|
||||
|
||||
return delta_l ** 2 + delta_c ** 2 + delta_h ** 2 + r_t * delta_c * delta_h
|
||||
|
||||
|
||||
COLOR_DISTANCE_ALGORITHMS = {'rgb': dist_rgb,
|
||||
'rgb-weighted': dist_rgb_weighted,
|
||||
'cie76': dist_cie76,
|
||||
'cie94': dist_cie94,
|
||||
'cie2000': dist_cie2000}
|
||||
17
venv/lib/python3.11/site-packages/blessed/color.pyi
Normal file
17
venv/lib/python3.11/site-packages/blessed/color.pyi
Normal file
@@ -0,0 +1,17 @@
|
||||
# std imports
|
||||
from typing import Dict, Tuple, Callable
|
||||
|
||||
_RGB = Tuple[int, int, int]
|
||||
|
||||
def rgb_to_xyz(red: int, green: int, blue: int) -> Tuple[float, float, float]: ...
|
||||
def xyz_to_lab(
|
||||
x_val: float, y_val: float, z_val: float
|
||||
) -> Tuple[float, float, float]: ...
|
||||
def rgb_to_lab(red: int, green: int, blue: int) -> Tuple[float, float, float]: ...
|
||||
def dist_rgb(rgb1: _RGB, rgb2: _RGB) -> float: ...
|
||||
def dist_rgb_weighted(rgb1: _RGB, rgb2: _RGB) -> float: ...
|
||||
def dist_cie76(rgb1: _RGB, rgb2: _RGB) -> float: ...
|
||||
def dist_cie94(rgb1: _RGB, rgb2: _RGB) -> float: ...
|
||||
def dist_cie2000(rgb1: _RGB, rgb2: _RGB) -> float: ...
|
||||
|
||||
COLOR_DISTANCE_ALGORITHMS: Dict[str, Callable[[_RGB, _RGB], float]]
|
||||
973
venv/lib/python3.11/site-packages/blessed/colorspace.py
Normal file
973
venv/lib/python3.11/site-packages/blessed/colorspace.py
Normal file
@@ -0,0 +1,973 @@
|
||||
"""
|
||||
Color reference data.
|
||||
|
||||
References,
|
||||
|
||||
- https://github.com/freedesktop/xorg-rgb/blob/master/rgb.txt
|
||||
- https://github.com/ThomasDickey/xterm-snapshots/blob/master/256colres.h
|
||||
- https://github.com/ThomasDickey/xterm-snapshots/blob/master/XTerm-col.ad
|
||||
- https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||
- https://gist.github.com/XVilka/8346728
|
||||
- https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/
|
||||
- http://jdebp.uk/Softwares/nosh/guide/TerminalCapabilities.html
|
||||
"""
|
||||
|
||||
# std imports
|
||||
import collections
|
||||
|
||||
__all__ = (
|
||||
'CGA_COLORS',
|
||||
'RGBColor',
|
||||
'RGB_256TABLE',
|
||||
'X11_COLORNAMES_TO_RGB',
|
||||
)
|
||||
|
||||
CGA_COLORS = {'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'}
|
||||
|
||||
|
||||
class RGBColor(collections.namedtuple("RGBColor", ["red", "green", "blue"])):
|
||||
"""Named tuple for an RGB color definition."""
|
||||
|
||||
def __str__(self):
|
||||
return '#{0:02x}{1:02x}{2:02x}'.format(*self)
|
||||
|
||||
|
||||
#: X11 Color names to (XTerm-defined) RGB values from xorg-rgb/rgb.txt
|
||||
X11_COLORNAMES_TO_RGB = {
|
||||
'aliceblue': RGBColor(240, 248, 255),
|
||||
'antiquewhite': RGBColor(250, 235, 215),
|
||||
'antiquewhite1': RGBColor(255, 239, 219),
|
||||
'antiquewhite2': RGBColor(238, 223, 204),
|
||||
'antiquewhite3': RGBColor(205, 192, 176),
|
||||
'antiquewhite4': RGBColor(139, 131, 120),
|
||||
'aqua': RGBColor(0, 255, 255),
|
||||
'aquamarine': RGBColor(127, 255, 212),
|
||||
'aquamarine1': RGBColor(127, 255, 212),
|
||||
'aquamarine2': RGBColor(118, 238, 198),
|
||||
'aquamarine3': RGBColor(102, 205, 170),
|
||||
'aquamarine4': RGBColor(69, 139, 116),
|
||||
'azure': RGBColor(240, 255, 255),
|
||||
'azure1': RGBColor(240, 255, 255),
|
||||
'azure2': RGBColor(224, 238, 238),
|
||||
'azure3': RGBColor(193, 205, 205),
|
||||
'azure4': RGBColor(131, 139, 139),
|
||||
'beige': RGBColor(245, 245, 220),
|
||||
'bisque': RGBColor(255, 228, 196),
|
||||
'bisque1': RGBColor(255, 228, 196),
|
||||
'bisque2': RGBColor(238, 213, 183),
|
||||
'bisque3': RGBColor(205, 183, 158),
|
||||
'bisque4': RGBColor(139, 125, 107),
|
||||
'black': RGBColor(0, 0, 0),
|
||||
'blanchedalmond': RGBColor(255, 235, 205),
|
||||
'blue': RGBColor(0, 0, 255),
|
||||
'blue1': RGBColor(0, 0, 255),
|
||||
'blue2': RGBColor(0, 0, 238),
|
||||
'blue3': RGBColor(0, 0, 205),
|
||||
'blue4': RGBColor(0, 0, 139),
|
||||
'blueviolet': RGBColor(138, 43, 226),
|
||||
'brown': RGBColor(165, 42, 42),
|
||||
'brown1': RGBColor(255, 64, 64),
|
||||
'brown2': RGBColor(238, 59, 59),
|
||||
'brown3': RGBColor(205, 51, 51),
|
||||
'brown4': RGBColor(139, 35, 35),
|
||||
'burlywood': RGBColor(222, 184, 135),
|
||||
'burlywood1': RGBColor(255, 211, 155),
|
||||
'burlywood2': RGBColor(238, 197, 145),
|
||||
'burlywood3': RGBColor(205, 170, 125),
|
||||
'burlywood4': RGBColor(139, 115, 85),
|
||||
'cadetblue': RGBColor(95, 158, 160),
|
||||
'cadetblue1': RGBColor(152, 245, 255),
|
||||
'cadetblue2': RGBColor(142, 229, 238),
|
||||
'cadetblue3': RGBColor(122, 197, 205),
|
||||
'cadetblue4': RGBColor(83, 134, 139),
|
||||
'chartreuse': RGBColor(127, 255, 0),
|
||||
'chartreuse1': RGBColor(127, 255, 0),
|
||||
'chartreuse2': RGBColor(118, 238, 0),
|
||||
'chartreuse3': RGBColor(102, 205, 0),
|
||||
'chartreuse4': RGBColor(69, 139, 0),
|
||||
'chocolate': RGBColor(210, 105, 30),
|
||||
'chocolate1': RGBColor(255, 127, 36),
|
||||
'chocolate2': RGBColor(238, 118, 33),
|
||||
'chocolate3': RGBColor(205, 102, 29),
|
||||
'chocolate4': RGBColor(139, 69, 19),
|
||||
'coral': RGBColor(255, 127, 80),
|
||||
'coral1': RGBColor(255, 114, 86),
|
||||
'coral2': RGBColor(238, 106, 80),
|
||||
'coral3': RGBColor(205, 91, 69),
|
||||
'coral4': RGBColor(139, 62, 47),
|
||||
'cornflowerblue': RGBColor(100, 149, 237),
|
||||
'cornsilk': RGBColor(255, 248, 220),
|
||||
'cornsilk1': RGBColor(255, 248, 220),
|
||||
'cornsilk2': RGBColor(238, 232, 205),
|
||||
'cornsilk3': RGBColor(205, 200, 177),
|
||||
'cornsilk4': RGBColor(139, 136, 120),
|
||||
'crimson': RGBColor(220, 20, 60),
|
||||
'cyan': RGBColor(0, 255, 255),
|
||||
'cyan1': RGBColor(0, 255, 255),
|
||||
'cyan2': RGBColor(0, 238, 238),
|
||||
'cyan3': RGBColor(0, 205, 205),
|
||||
'cyan4': RGBColor(0, 139, 139),
|
||||
'darkblue': RGBColor(0, 0, 139),
|
||||
'darkcyan': RGBColor(0, 139, 139),
|
||||
'darkgoldenrod': RGBColor(184, 134, 11),
|
||||
'darkgoldenrod1': RGBColor(255, 185, 15),
|
||||
'darkgoldenrod2': RGBColor(238, 173, 14),
|
||||
'darkgoldenrod3': RGBColor(205, 149, 12),
|
||||
'darkgoldenrod4': RGBColor(139, 101, 8),
|
||||
'darkgray': RGBColor(169, 169, 169),
|
||||
'darkgreen': RGBColor(0, 100, 0),
|
||||
'darkgrey': RGBColor(169, 169, 169),
|
||||
'darkkhaki': RGBColor(189, 183, 107),
|
||||
'darkmagenta': RGBColor(139, 0, 139),
|
||||
'darkolivegreen': RGBColor(85, 107, 47),
|
||||
'darkolivegreen1': RGBColor(202, 255, 112),
|
||||
'darkolivegreen2': RGBColor(188, 238, 104),
|
||||
'darkolivegreen3': RGBColor(162, 205, 90),
|
||||
'darkolivegreen4': RGBColor(110, 139, 61),
|
||||
'darkorange': RGBColor(255, 140, 0),
|
||||
'darkorange1': RGBColor(255, 127, 0),
|
||||
'darkorange2': RGBColor(238, 118, 0),
|
||||
'darkorange3': RGBColor(205, 102, 0),
|
||||
'darkorange4': RGBColor(139, 69, 0),
|
||||
'darkorchid': RGBColor(153, 50, 204),
|
||||
'darkorchid1': RGBColor(191, 62, 255),
|
||||
'darkorchid2': RGBColor(178, 58, 238),
|
||||
'darkorchid3': RGBColor(154, 50, 205),
|
||||
'darkorchid4': RGBColor(104, 34, 139),
|
||||
'darkred': RGBColor(139, 0, 0),
|
||||
'darksalmon': RGBColor(233, 150, 122),
|
||||
'darkseagreen': RGBColor(143, 188, 143),
|
||||
'darkseagreen1': RGBColor(193, 255, 193),
|
||||
'darkseagreen2': RGBColor(180, 238, 180),
|
||||
'darkseagreen3': RGBColor(155, 205, 155),
|
||||
'darkseagreen4': RGBColor(105, 139, 105),
|
||||
'darkslateblue': RGBColor(72, 61, 139),
|
||||
'darkslategray': RGBColor(47, 79, 79),
|
||||
'darkslategray1': RGBColor(151, 255, 255),
|
||||
'darkslategray2': RGBColor(141, 238, 238),
|
||||
'darkslategray3': RGBColor(121, 205, 205),
|
||||
'darkslategray4': RGBColor(82, 139, 139),
|
||||
'darkslategrey': RGBColor(47, 79, 79),
|
||||
'darkturquoise': RGBColor(0, 206, 209),
|
||||
'darkviolet': RGBColor(148, 0, 211),
|
||||
'deeppink': RGBColor(255, 20, 147),
|
||||
'deeppink1': RGBColor(255, 20, 147),
|
||||
'deeppink2': RGBColor(238, 18, 137),
|
||||
'deeppink3': RGBColor(205, 16, 118),
|
||||
'deeppink4': RGBColor(139, 10, 80),
|
||||
'deepskyblue': RGBColor(0, 191, 255),
|
||||
'deepskyblue1': RGBColor(0, 191, 255),
|
||||
'deepskyblue2': RGBColor(0, 178, 238),
|
||||
'deepskyblue3': RGBColor(0, 154, 205),
|
||||
'deepskyblue4': RGBColor(0, 104, 139),
|
||||
'dimgray': RGBColor(105, 105, 105),
|
||||
'dimgrey': RGBColor(105, 105, 105),
|
||||
'dodgerblue': RGBColor(30, 144, 255),
|
||||
'dodgerblue1': RGBColor(30, 144, 255),
|
||||
'dodgerblue2': RGBColor(28, 134, 238),
|
||||
'dodgerblue3': RGBColor(24, 116, 205),
|
||||
'dodgerblue4': RGBColor(16, 78, 139),
|
||||
'firebrick': RGBColor(178, 34, 34),
|
||||
'firebrick1': RGBColor(255, 48, 48),
|
||||
'firebrick2': RGBColor(238, 44, 44),
|
||||
'firebrick3': RGBColor(205, 38, 38),
|
||||
'firebrick4': RGBColor(139, 26, 26),
|
||||
'floralwhite': RGBColor(255, 250, 240),
|
||||
'forestgreen': RGBColor(34, 139, 34),
|
||||
'fuchsia': RGBColor(255, 0, 255),
|
||||
'gainsboro': RGBColor(220, 220, 220),
|
||||
'ghostwhite': RGBColor(248, 248, 255),
|
||||
'gold': RGBColor(255, 215, 0),
|
||||
'gold1': RGBColor(255, 215, 0),
|
||||
'gold2': RGBColor(238, 201, 0),
|
||||
'gold3': RGBColor(205, 173, 0),
|
||||
'gold4': RGBColor(139, 117, 0),
|
||||
'goldenrod': RGBColor(218, 165, 32),
|
||||
'goldenrod1': RGBColor(255, 193, 37),
|
||||
'goldenrod2': RGBColor(238, 180, 34),
|
||||
'goldenrod3': RGBColor(205, 155, 29),
|
||||
'goldenrod4': RGBColor(139, 105, 20),
|
||||
'gray': RGBColor(190, 190, 190),
|
||||
'gray0': RGBColor(0, 0, 0),
|
||||
'gray1': RGBColor(3, 3, 3),
|
||||
'gray10': RGBColor(26, 26, 26),
|
||||
'gray100': RGBColor(255, 255, 255),
|
||||
'gray11': RGBColor(28, 28, 28),
|
||||
'gray12': RGBColor(31, 31, 31),
|
||||
'gray13': RGBColor(33, 33, 33),
|
||||
'gray14': RGBColor(36, 36, 36),
|
||||
'gray15': RGBColor(38, 38, 38),
|
||||
'gray16': RGBColor(41, 41, 41),
|
||||
'gray17': RGBColor(43, 43, 43),
|
||||
'gray18': RGBColor(46, 46, 46),
|
||||
'gray19': RGBColor(48, 48, 48),
|
||||
'gray2': RGBColor(5, 5, 5),
|
||||
'gray20': RGBColor(51, 51, 51),
|
||||
'gray21': RGBColor(54, 54, 54),
|
||||
'gray22': RGBColor(56, 56, 56),
|
||||
'gray23': RGBColor(59, 59, 59),
|
||||
'gray24': RGBColor(61, 61, 61),
|
||||
'gray25': RGBColor(64, 64, 64),
|
||||
'gray26': RGBColor(66, 66, 66),
|
||||
'gray27': RGBColor(69, 69, 69),
|
||||
'gray28': RGBColor(71, 71, 71),
|
||||
'gray29': RGBColor(74, 74, 74),
|
||||
'gray3': RGBColor(8, 8, 8),
|
||||
'gray30': RGBColor(77, 77, 77),
|
||||
'gray31': RGBColor(79, 79, 79),
|
||||
'gray32': RGBColor(82, 82, 82),
|
||||
'gray33': RGBColor(84, 84, 84),
|
||||
'gray34': RGBColor(87, 87, 87),
|
||||
'gray35': RGBColor(89, 89, 89),
|
||||
'gray36': RGBColor(92, 92, 92),
|
||||
'gray37': RGBColor(94, 94, 94),
|
||||
'gray38': RGBColor(97, 97, 97),
|
||||
'gray39': RGBColor(99, 99, 99),
|
||||
'gray4': RGBColor(10, 10, 10),
|
||||
'gray40': RGBColor(102, 102, 102),
|
||||
'gray41': RGBColor(105, 105, 105),
|
||||
'gray42': RGBColor(107, 107, 107),
|
||||
'gray43': RGBColor(110, 110, 110),
|
||||
'gray44': RGBColor(112, 112, 112),
|
||||
'gray45': RGBColor(115, 115, 115),
|
||||
'gray46': RGBColor(117, 117, 117),
|
||||
'gray47': RGBColor(120, 120, 120),
|
||||
'gray48': RGBColor(122, 122, 122),
|
||||
'gray49': RGBColor(125, 125, 125),
|
||||
'gray5': RGBColor(13, 13, 13),
|
||||
'gray50': RGBColor(127, 127, 127),
|
||||
'gray51': RGBColor(130, 130, 130),
|
||||
'gray52': RGBColor(133, 133, 133),
|
||||
'gray53': RGBColor(135, 135, 135),
|
||||
'gray54': RGBColor(138, 138, 138),
|
||||
'gray55': RGBColor(140, 140, 140),
|
||||
'gray56': RGBColor(143, 143, 143),
|
||||
'gray57': RGBColor(145, 145, 145),
|
||||
'gray58': RGBColor(148, 148, 148),
|
||||
'gray59': RGBColor(150, 150, 150),
|
||||
'gray6': RGBColor(15, 15, 15),
|
||||
'gray60': RGBColor(153, 153, 153),
|
||||
'gray61': RGBColor(156, 156, 156),
|
||||
'gray62': RGBColor(158, 158, 158),
|
||||
'gray63': RGBColor(161, 161, 161),
|
||||
'gray64': RGBColor(163, 163, 163),
|
||||
'gray65': RGBColor(166, 166, 166),
|
||||
'gray66': RGBColor(168, 168, 168),
|
||||
'gray67': RGBColor(171, 171, 171),
|
||||
'gray68': RGBColor(173, 173, 173),
|
||||
'gray69': RGBColor(176, 176, 176),
|
||||
'gray7': RGBColor(18, 18, 18),
|
||||
'gray70': RGBColor(179, 179, 179),
|
||||
'gray71': RGBColor(181, 181, 181),
|
||||
'gray72': RGBColor(184, 184, 184),
|
||||
'gray73': RGBColor(186, 186, 186),
|
||||
'gray74': RGBColor(189, 189, 189),
|
||||
'gray75': RGBColor(191, 191, 191),
|
||||
'gray76': RGBColor(194, 194, 194),
|
||||
'gray77': RGBColor(196, 196, 196),
|
||||
'gray78': RGBColor(199, 199, 199),
|
||||
'gray79': RGBColor(201, 201, 201),
|
||||
'gray8': RGBColor(20, 20, 20),
|
||||
'gray80': RGBColor(204, 204, 204),
|
||||
'gray81': RGBColor(207, 207, 207),
|
||||
'gray82': RGBColor(209, 209, 209),
|
||||
'gray83': RGBColor(212, 212, 212),
|
||||
'gray84': RGBColor(214, 214, 214),
|
||||
'gray85': RGBColor(217, 217, 217),
|
||||
'gray86': RGBColor(219, 219, 219),
|
||||
'gray87': RGBColor(222, 222, 222),
|
||||
'gray88': RGBColor(224, 224, 224),
|
||||
'gray89': RGBColor(227, 227, 227),
|
||||
'gray9': RGBColor(23, 23, 23),
|
||||
'gray90': RGBColor(229, 229, 229),
|
||||
'gray91': RGBColor(232, 232, 232),
|
||||
'gray92': RGBColor(235, 235, 235),
|
||||
'gray93': RGBColor(237, 237, 237),
|
||||
'gray94': RGBColor(240, 240, 240),
|
||||
'gray95': RGBColor(242, 242, 242),
|
||||
'gray96': RGBColor(245, 245, 245),
|
||||
'gray97': RGBColor(247, 247, 247),
|
||||
'gray98': RGBColor(250, 250, 250),
|
||||
'gray99': RGBColor(252, 252, 252),
|
||||
'green': RGBColor(0, 255, 0),
|
||||
'green1': RGBColor(0, 255, 0),
|
||||
'green2': RGBColor(0, 238, 0),
|
||||
'green3': RGBColor(0, 205, 0),
|
||||
'green4': RGBColor(0, 139, 0),
|
||||
'greenyellow': RGBColor(173, 255, 47),
|
||||
'grey': RGBColor(190, 190, 190),
|
||||
'grey0': RGBColor(0, 0, 0),
|
||||
'grey1': RGBColor(3, 3, 3),
|
||||
'grey10': RGBColor(26, 26, 26),
|
||||
'grey100': RGBColor(255, 255, 255),
|
||||
'grey11': RGBColor(28, 28, 28),
|
||||
'grey12': RGBColor(31, 31, 31),
|
||||
'grey13': RGBColor(33, 33, 33),
|
||||
'grey14': RGBColor(36, 36, 36),
|
||||
'grey15': RGBColor(38, 38, 38),
|
||||
'grey16': RGBColor(41, 41, 41),
|
||||
'grey17': RGBColor(43, 43, 43),
|
||||
'grey18': RGBColor(46, 46, 46),
|
||||
'grey19': RGBColor(48, 48, 48),
|
||||
'grey2': RGBColor(5, 5, 5),
|
||||
'grey20': RGBColor(51, 51, 51),
|
||||
'grey21': RGBColor(54, 54, 54),
|
||||
'grey22': RGBColor(56, 56, 56),
|
||||
'grey23': RGBColor(59, 59, 59),
|
||||
'grey24': RGBColor(61, 61, 61),
|
||||
'grey25': RGBColor(64, 64, 64),
|
||||
'grey26': RGBColor(66, 66, 66),
|
||||
'grey27': RGBColor(69, 69, 69),
|
||||
'grey28': RGBColor(71, 71, 71),
|
||||
'grey29': RGBColor(74, 74, 74),
|
||||
'grey3': RGBColor(8, 8, 8),
|
||||
'grey30': RGBColor(77, 77, 77),
|
||||
'grey31': RGBColor(79, 79, 79),
|
||||
'grey32': RGBColor(82, 82, 82),
|
||||
'grey33': RGBColor(84, 84, 84),
|
||||
'grey34': RGBColor(87, 87, 87),
|
||||
'grey35': RGBColor(89, 89, 89),
|
||||
'grey36': RGBColor(92, 92, 92),
|
||||
'grey37': RGBColor(94, 94, 94),
|
||||
'grey38': RGBColor(97, 97, 97),
|
||||
'grey39': RGBColor(99, 99, 99),
|
||||
'grey4': RGBColor(10, 10, 10),
|
||||
'grey40': RGBColor(102, 102, 102),
|
||||
'grey41': RGBColor(105, 105, 105),
|
||||
'grey42': RGBColor(107, 107, 107),
|
||||
'grey43': RGBColor(110, 110, 110),
|
||||
'grey44': RGBColor(112, 112, 112),
|
||||
'grey45': RGBColor(115, 115, 115),
|
||||
'grey46': RGBColor(117, 117, 117),
|
||||
'grey47': RGBColor(120, 120, 120),
|
||||
'grey48': RGBColor(122, 122, 122),
|
||||
'grey49': RGBColor(125, 125, 125),
|
||||
'grey5': RGBColor(13, 13, 13),
|
||||
'grey50': RGBColor(127, 127, 127),
|
||||
'grey51': RGBColor(130, 130, 130),
|
||||
'grey52': RGBColor(133, 133, 133),
|
||||
'grey53': RGBColor(135, 135, 135),
|
||||
'grey54': RGBColor(138, 138, 138),
|
||||
'grey55': RGBColor(140, 140, 140),
|
||||
'grey56': RGBColor(143, 143, 143),
|
||||
'grey57': RGBColor(145, 145, 145),
|
||||
'grey58': RGBColor(148, 148, 148),
|
||||
'grey59': RGBColor(150, 150, 150),
|
||||
'grey6': RGBColor(15, 15, 15),
|
||||
'grey60': RGBColor(153, 153, 153),
|
||||
'grey61': RGBColor(156, 156, 156),
|
||||
'grey62': RGBColor(158, 158, 158),
|
||||
'grey63': RGBColor(161, 161, 161),
|
||||
'grey64': RGBColor(163, 163, 163),
|
||||
'grey65': RGBColor(166, 166, 166),
|
||||
'grey66': RGBColor(168, 168, 168),
|
||||
'grey67': RGBColor(171, 171, 171),
|
||||
'grey68': RGBColor(173, 173, 173),
|
||||
'grey69': RGBColor(176, 176, 176),
|
||||
'grey7': RGBColor(18, 18, 18),
|
||||
'grey70': RGBColor(179, 179, 179),
|
||||
'grey71': RGBColor(181, 181, 181),
|
||||
'grey72': RGBColor(184, 184, 184),
|
||||
'grey73': RGBColor(186, 186, 186),
|
||||
'grey74': RGBColor(189, 189, 189),
|
||||
'grey75': RGBColor(191, 191, 191),
|
||||
'grey76': RGBColor(194, 194, 194),
|
||||
'grey77': RGBColor(196, 196, 196),
|
||||
'grey78': RGBColor(199, 199, 199),
|
||||
'grey79': RGBColor(201, 201, 201),
|
||||
'grey8': RGBColor(20, 20, 20),
|
||||
'grey80': RGBColor(204, 204, 204),
|
||||
'grey81': RGBColor(207, 207, 207),
|
||||
'grey82': RGBColor(209, 209, 209),
|
||||
'grey83': RGBColor(212, 212, 212),
|
||||
'grey84': RGBColor(214, 214, 214),
|
||||
'grey85': RGBColor(217, 217, 217),
|
||||
'grey86': RGBColor(219, 219, 219),
|
||||
'grey87': RGBColor(222, 222, 222),
|
||||
'grey88': RGBColor(224, 224, 224),
|
||||
'grey89': RGBColor(227, 227, 227),
|
||||
'grey9': RGBColor(23, 23, 23),
|
||||
'grey90': RGBColor(229, 229, 229),
|
||||
'grey91': RGBColor(232, 232, 232),
|
||||
'grey92': RGBColor(235, 235, 235),
|
||||
'grey93': RGBColor(237, 237, 237),
|
||||
'grey94': RGBColor(240, 240, 240),
|
||||
'grey95': RGBColor(242, 242, 242),
|
||||
'grey96': RGBColor(245, 245, 245),
|
||||
'grey97': RGBColor(247, 247, 247),
|
||||
'grey98': RGBColor(250, 250, 250),
|
||||
'grey99': RGBColor(252, 252, 252),
|
||||
'honeydew': RGBColor(240, 255, 240),
|
||||
'honeydew1': RGBColor(240, 255, 240),
|
||||
'honeydew2': RGBColor(224, 238, 224),
|
||||
'honeydew3': RGBColor(193, 205, 193),
|
||||
'honeydew4': RGBColor(131, 139, 131),
|
||||
'hotpink': RGBColor(255, 105, 180),
|
||||
'hotpink1': RGBColor(255, 110, 180),
|
||||
'hotpink2': RGBColor(238, 106, 167),
|
||||
'hotpink3': RGBColor(205, 96, 144),
|
||||
'hotpink4': RGBColor(139, 58, 98),
|
||||
'indianred': RGBColor(205, 92, 92),
|
||||
'indianred1': RGBColor(255, 106, 106),
|
||||
'indianred2': RGBColor(238, 99, 99),
|
||||
'indianred3': RGBColor(205, 85, 85),
|
||||
'indianred4': RGBColor(139, 58, 58),
|
||||
'indigo': RGBColor(75, 0, 130),
|
||||
'ivory': RGBColor(255, 255, 240),
|
||||
'ivory1': RGBColor(255, 255, 240),
|
||||
'ivory2': RGBColor(238, 238, 224),
|
||||
'ivory3': RGBColor(205, 205, 193),
|
||||
'ivory4': RGBColor(139, 139, 131),
|
||||
'khaki': RGBColor(240, 230, 140),
|
||||
'khaki1': RGBColor(255, 246, 143),
|
||||
'khaki2': RGBColor(238, 230, 133),
|
||||
'khaki3': RGBColor(205, 198, 115),
|
||||
'khaki4': RGBColor(139, 134, 78),
|
||||
'lavender': RGBColor(230, 230, 250),
|
||||
'lavenderblush': RGBColor(255, 240, 245),
|
||||
'lavenderblush1': RGBColor(255, 240, 245),
|
||||
'lavenderblush2': RGBColor(238, 224, 229),
|
||||
'lavenderblush3': RGBColor(205, 193, 197),
|
||||
'lavenderblush4': RGBColor(139, 131, 134),
|
||||
'lawngreen': RGBColor(124, 252, 0),
|
||||
'lemonchiffon': RGBColor(255, 250, 205),
|
||||
'lemonchiffon1': RGBColor(255, 250, 205),
|
||||
'lemonchiffon2': RGBColor(238, 233, 191),
|
||||
'lemonchiffon3': RGBColor(205, 201, 165),
|
||||
'lemonchiffon4': RGBColor(139, 137, 112),
|
||||
'lightblue': RGBColor(173, 216, 230),
|
||||
'lightblue1': RGBColor(191, 239, 255),
|
||||
'lightblue2': RGBColor(178, 223, 238),
|
||||
'lightblue3': RGBColor(154, 192, 205),
|
||||
'lightblue4': RGBColor(104, 131, 139),
|
||||
'lightcoral': RGBColor(240, 128, 128),
|
||||
'lightcyan': RGBColor(224, 255, 255),
|
||||
'lightcyan1': RGBColor(224, 255, 255),
|
||||
'lightcyan2': RGBColor(209, 238, 238),
|
||||
'lightcyan3': RGBColor(180, 205, 205),
|
||||
'lightcyan4': RGBColor(122, 139, 139),
|
||||
'lightgoldenrod': RGBColor(238, 221, 130),
|
||||
'lightgoldenrod1': RGBColor(255, 236, 139),
|
||||
'lightgoldenrod2': RGBColor(238, 220, 130),
|
||||
'lightgoldenrod3': RGBColor(205, 190, 112),
|
||||
'lightgoldenrod4': RGBColor(139, 129, 76),
|
||||
'lightgoldenrodyellow': RGBColor(250, 250, 210),
|
||||
'lightgray': RGBColor(211, 211, 211),
|
||||
'lightgreen': RGBColor(144, 238, 144),
|
||||
'lightgrey': RGBColor(211, 211, 211),
|
||||
'lightpink': RGBColor(255, 182, 193),
|
||||
'lightpink1': RGBColor(255, 174, 185),
|
||||
'lightpink2': RGBColor(238, 162, 173),
|
||||
'lightpink3': RGBColor(205, 140, 149),
|
||||
'lightpink4': RGBColor(139, 95, 101),
|
||||
'lightsalmon': RGBColor(255, 160, 122),
|
||||
'lightsalmon1': RGBColor(255, 160, 122),
|
||||
'lightsalmon2': RGBColor(238, 149, 114),
|
||||
'lightsalmon3': RGBColor(205, 129, 98),
|
||||
'lightsalmon4': RGBColor(139, 87, 66),
|
||||
'lightseagreen': RGBColor(32, 178, 170),
|
||||
'lightskyblue': RGBColor(135, 206, 250),
|
||||
'lightskyblue1': RGBColor(176, 226, 255),
|
||||
'lightskyblue2': RGBColor(164, 211, 238),
|
||||
'lightskyblue3': RGBColor(141, 182, 205),
|
||||
'lightskyblue4': RGBColor(96, 123, 139),
|
||||
'lightslateblue': RGBColor(132, 112, 255),
|
||||
'lightslategray': RGBColor(119, 136, 153),
|
||||
'lightslategrey': RGBColor(119, 136, 153),
|
||||
'lightsteelblue': RGBColor(176, 196, 222),
|
||||
'lightsteelblue1': RGBColor(202, 225, 255),
|
||||
'lightsteelblue2': RGBColor(188, 210, 238),
|
||||
'lightsteelblue3': RGBColor(162, 181, 205),
|
||||
'lightsteelblue4': RGBColor(110, 123, 139),
|
||||
'lightyellow': RGBColor(255, 255, 224),
|
||||
'lightyellow1': RGBColor(255, 255, 224),
|
||||
'lightyellow2': RGBColor(238, 238, 209),
|
||||
'lightyellow3': RGBColor(205, 205, 180),
|
||||
'lightyellow4': RGBColor(139, 139, 122),
|
||||
'lime': RGBColor(0, 255, 0),
|
||||
'limegreen': RGBColor(50, 205, 50),
|
||||
'linen': RGBColor(250, 240, 230),
|
||||
'magenta': RGBColor(255, 0, 255),
|
||||
'magenta1': RGBColor(255, 0, 255),
|
||||
'magenta2': RGBColor(238, 0, 238),
|
||||
'magenta3': RGBColor(205, 0, 205),
|
||||
'magenta4': RGBColor(139, 0, 139),
|
||||
'maroon': RGBColor(176, 48, 96),
|
||||
'maroon1': RGBColor(255, 52, 179),
|
||||
'maroon2': RGBColor(238, 48, 167),
|
||||
'maroon3': RGBColor(205, 41, 144),
|
||||
'maroon4': RGBColor(139, 28, 98),
|
||||
'mediumaquamarine': RGBColor(102, 205, 170),
|
||||
'mediumblue': RGBColor(0, 0, 205),
|
||||
'mediumorchid': RGBColor(186, 85, 211),
|
||||
'mediumorchid1': RGBColor(224, 102, 255),
|
||||
'mediumorchid2': RGBColor(209, 95, 238),
|
||||
'mediumorchid3': RGBColor(180, 82, 205),
|
||||
'mediumorchid4': RGBColor(122, 55, 139),
|
||||
'mediumpurple': RGBColor(147, 112, 219),
|
||||
'mediumpurple1': RGBColor(171, 130, 255),
|
||||
'mediumpurple2': RGBColor(159, 121, 238),
|
||||
'mediumpurple3': RGBColor(137, 104, 205),
|
||||
'mediumpurple4': RGBColor(93, 71, 139),
|
||||
'mediumseagreen': RGBColor(60, 179, 113),
|
||||
'mediumslateblue': RGBColor(123, 104, 238),
|
||||
'mediumspringgreen': RGBColor(0, 250, 154),
|
||||
'mediumturquoise': RGBColor(72, 209, 204),
|
||||
'mediumvioletred': RGBColor(199, 21, 133),
|
||||
'midnightblue': RGBColor(25, 25, 112),
|
||||
'mintcream': RGBColor(245, 255, 250),
|
||||
'mistyrose': RGBColor(255, 228, 225),
|
||||
'mistyrose1': RGBColor(255, 228, 225),
|
||||
'mistyrose2': RGBColor(238, 213, 210),
|
||||
'mistyrose3': RGBColor(205, 183, 181),
|
||||
'mistyrose4': RGBColor(139, 125, 123),
|
||||
'moccasin': RGBColor(255, 228, 181),
|
||||
'navajowhite': RGBColor(255, 222, 173),
|
||||
'navajowhite1': RGBColor(255, 222, 173),
|
||||
'navajowhite2': RGBColor(238, 207, 161),
|
||||
'navajowhite3': RGBColor(205, 179, 139),
|
||||
'navajowhite4': RGBColor(139, 121, 94),
|
||||
'navy': RGBColor(0, 0, 128),
|
||||
'navyblue': RGBColor(0, 0, 128),
|
||||
'oldlace': RGBColor(253, 245, 230),
|
||||
'olive': RGBColor(128, 128, 0),
|
||||
'olivedrab': RGBColor(107, 142, 35),
|
||||
'olivedrab1': RGBColor(192, 255, 62),
|
||||
'olivedrab2': RGBColor(179, 238, 58),
|
||||
'olivedrab3': RGBColor(154, 205, 50),
|
||||
'olivedrab4': RGBColor(105, 139, 34),
|
||||
'orange': RGBColor(255, 165, 0),
|
||||
'orange1': RGBColor(255, 165, 0),
|
||||
'orange2': RGBColor(238, 154, 0),
|
||||
'orange3': RGBColor(205, 133, 0),
|
||||
'orange4': RGBColor(139, 90, 0),
|
||||
'orangered': RGBColor(255, 69, 0),
|
||||
'orangered1': RGBColor(255, 69, 0),
|
||||
'orangered2': RGBColor(238, 64, 0),
|
||||
'orangered3': RGBColor(205, 55, 0),
|
||||
'orangered4': RGBColor(139, 37, 0),
|
||||
'orchid': RGBColor(218, 112, 214),
|
||||
'orchid1': RGBColor(255, 131, 250),
|
||||
'orchid2': RGBColor(238, 122, 233),
|
||||
'orchid3': RGBColor(205, 105, 201),
|
||||
'orchid4': RGBColor(139, 71, 137),
|
||||
'palegoldenrod': RGBColor(238, 232, 170),
|
||||
'palegreen': RGBColor(152, 251, 152),
|
||||
'palegreen1': RGBColor(154, 255, 154),
|
||||
'palegreen2': RGBColor(144, 238, 144),
|
||||
'palegreen3': RGBColor(124, 205, 124),
|
||||
'palegreen4': RGBColor(84, 139, 84),
|
||||
'paleturquoise': RGBColor(175, 238, 238),
|
||||
'paleturquoise1': RGBColor(187, 255, 255),
|
||||
'paleturquoise2': RGBColor(174, 238, 238),
|
||||
'paleturquoise3': RGBColor(150, 205, 205),
|
||||
'paleturquoise4': RGBColor(102, 139, 139),
|
||||
'palevioletred': RGBColor(219, 112, 147),
|
||||
'palevioletred1': RGBColor(255, 130, 171),
|
||||
'palevioletred2': RGBColor(238, 121, 159),
|
||||
'palevioletred3': RGBColor(205, 104, 137),
|
||||
'palevioletred4': RGBColor(139, 71, 93),
|
||||
'papayawhip': RGBColor(255, 239, 213),
|
||||
'peachpuff': RGBColor(255, 218, 185),
|
||||
'peachpuff1': RGBColor(255, 218, 185),
|
||||
'peachpuff2': RGBColor(238, 203, 173),
|
||||
'peachpuff3': RGBColor(205, 175, 149),
|
||||
'peachpuff4': RGBColor(139, 119, 101),
|
||||
'peru': RGBColor(205, 133, 63),
|
||||
'pink': RGBColor(255, 192, 203),
|
||||
'pink1': RGBColor(255, 181, 197),
|
||||
'pink2': RGBColor(238, 169, 184),
|
||||
'pink3': RGBColor(205, 145, 158),
|
||||
'pink4': RGBColor(139, 99, 108),
|
||||
'plum': RGBColor(221, 160, 221),
|
||||
'plum1': RGBColor(255, 187, 255),
|
||||
'plum2': RGBColor(238, 174, 238),
|
||||
'plum3': RGBColor(205, 150, 205),
|
||||
'plum4': RGBColor(139, 102, 139),
|
||||
'powderblue': RGBColor(176, 224, 230),
|
||||
'purple': RGBColor(160, 32, 240),
|
||||
'purple1': RGBColor(155, 48, 255),
|
||||
'purple2': RGBColor(145, 44, 238),
|
||||
'purple3': RGBColor(125, 38, 205),
|
||||
'purple4': RGBColor(85, 26, 139),
|
||||
'rebeccapurple': RGBColor(102, 51, 153),
|
||||
'red': RGBColor(255, 0, 0),
|
||||
'red1': RGBColor(255, 0, 0),
|
||||
'red2': RGBColor(238, 0, 0),
|
||||
'red3': RGBColor(205, 0, 0),
|
||||
'red4': RGBColor(139, 0, 0),
|
||||
'rosybrown': RGBColor(188, 143, 143),
|
||||
'rosybrown1': RGBColor(255, 193, 193),
|
||||
'rosybrown2': RGBColor(238, 180, 180),
|
||||
'rosybrown3': RGBColor(205, 155, 155),
|
||||
'rosybrown4': RGBColor(139, 105, 105),
|
||||
'royalblue': RGBColor(65, 105, 225),
|
||||
'royalblue1': RGBColor(72, 118, 255),
|
||||
'royalblue2': RGBColor(67, 110, 238),
|
||||
'royalblue3': RGBColor(58, 95, 205),
|
||||
'royalblue4': RGBColor(39, 64, 139),
|
||||
'saddlebrown': RGBColor(139, 69, 19),
|
||||
'salmon': RGBColor(250, 128, 114),
|
||||
'salmon1': RGBColor(255, 140, 105),
|
||||
'salmon2': RGBColor(238, 130, 98),
|
||||
'salmon3': RGBColor(205, 112, 84),
|
||||
'salmon4': RGBColor(139, 76, 57),
|
||||
'sandybrown': RGBColor(244, 164, 96),
|
||||
'seagreen': RGBColor(46, 139, 87),
|
||||
'seagreen1': RGBColor(84, 255, 159),
|
||||
'seagreen2': RGBColor(78, 238, 148),
|
||||
'seagreen3': RGBColor(67, 205, 128),
|
||||
'seagreen4': RGBColor(46, 139, 87),
|
||||
'seashell': RGBColor(255, 245, 238),
|
||||
'seashell1': RGBColor(255, 245, 238),
|
||||
'seashell2': RGBColor(238, 229, 222),
|
||||
'seashell3': RGBColor(205, 197, 191),
|
||||
'seashell4': RGBColor(139, 134, 130),
|
||||
'sienna': RGBColor(160, 82, 45),
|
||||
'sienna1': RGBColor(255, 130, 71),
|
||||
'sienna2': RGBColor(238, 121, 66),
|
||||
'sienna3': RGBColor(205, 104, 57),
|
||||
'sienna4': RGBColor(139, 71, 38),
|
||||
'silver': RGBColor(192, 192, 192),
|
||||
'skyblue': RGBColor(135, 206, 235),
|
||||
'skyblue1': RGBColor(135, 206, 255),
|
||||
'skyblue2': RGBColor(126, 192, 238),
|
||||
'skyblue3': RGBColor(108, 166, 205),
|
||||
'skyblue4': RGBColor(74, 112, 139),
|
||||
'slateblue': RGBColor(106, 90, 205),
|
||||
'slateblue1': RGBColor(131, 111, 255),
|
||||
'slateblue2': RGBColor(122, 103, 238),
|
||||
'slateblue3': RGBColor(105, 89, 205),
|
||||
'slateblue4': RGBColor(71, 60, 139),
|
||||
'slategray': RGBColor(112, 128, 144),
|
||||
'slategray1': RGBColor(198, 226, 255),
|
||||
'slategray2': RGBColor(185, 211, 238),
|
||||
'slategray3': RGBColor(159, 182, 205),
|
||||
'slategray4': RGBColor(108, 123, 139),
|
||||
'slategrey': RGBColor(112, 128, 144),
|
||||
'snow': RGBColor(255, 250, 250),
|
||||
'snow1': RGBColor(255, 250, 250),
|
||||
'snow2': RGBColor(238, 233, 233),
|
||||
'snow3': RGBColor(205, 201, 201),
|
||||
'snow4': RGBColor(139, 137, 137),
|
||||
'springgreen': RGBColor(0, 255, 127),
|
||||
'springgreen1': RGBColor(0, 255, 127),
|
||||
'springgreen2': RGBColor(0, 238, 118),
|
||||
'springgreen3': RGBColor(0, 205, 102),
|
||||
'springgreen4': RGBColor(0, 139, 69),
|
||||
'steelblue': RGBColor(70, 130, 180),
|
||||
'steelblue1': RGBColor(99, 184, 255),
|
||||
'steelblue2': RGBColor(92, 172, 238),
|
||||
'steelblue3': RGBColor(79, 148, 205),
|
||||
'steelblue4': RGBColor(54, 100, 139),
|
||||
'tan': RGBColor(210, 180, 140),
|
||||
'tan1': RGBColor(255, 165, 79),
|
||||
'tan2': RGBColor(238, 154, 73),
|
||||
'tan3': RGBColor(205, 133, 63),
|
||||
'tan4': RGBColor(139, 90, 43),
|
||||
'teal': RGBColor(0, 128, 128),
|
||||
'thistle': RGBColor(216, 191, 216),
|
||||
'thistle1': RGBColor(255, 225, 255),
|
||||
'thistle2': RGBColor(238, 210, 238),
|
||||
'thistle3': RGBColor(205, 181, 205),
|
||||
'thistle4': RGBColor(139, 123, 139),
|
||||
'tomato': RGBColor(255, 99, 71),
|
||||
'tomato1': RGBColor(255, 99, 71),
|
||||
'tomato2': RGBColor(238, 92, 66),
|
||||
'tomato3': RGBColor(205, 79, 57),
|
||||
'tomato4': RGBColor(139, 54, 38),
|
||||
'turquoise': RGBColor(64, 224, 208),
|
||||
'turquoise1': RGBColor(0, 245, 255),
|
||||
'turquoise2': RGBColor(0, 229, 238),
|
||||
'turquoise3': RGBColor(0, 197, 205),
|
||||
'turquoise4': RGBColor(0, 134, 139),
|
||||
'violet': RGBColor(238, 130, 238),
|
||||
'violetred': RGBColor(208, 32, 144),
|
||||
'violetred1': RGBColor(255, 62, 150),
|
||||
'violetred2': RGBColor(238, 58, 140),
|
||||
'violetred3': RGBColor(205, 50, 120),
|
||||
'violetred4': RGBColor(139, 34, 82),
|
||||
'webgray': RGBColor(128, 128, 128),
|
||||
'webgreen': RGBColor(0, 128, 0),
|
||||
'webgrey': RGBColor(128, 128, 128),
|
||||
'webmaroon': RGBColor(128, 0, 0),
|
||||
'webpurple': RGBColor(128, 0, 128),
|
||||
'wheat': RGBColor(245, 222, 179),
|
||||
'wheat1': RGBColor(255, 231, 186),
|
||||
'wheat2': RGBColor(238, 216, 174),
|
||||
'wheat3': RGBColor(205, 186, 150),
|
||||
'wheat4': RGBColor(139, 126, 102),
|
||||
'white': RGBColor(255, 255, 255),
|
||||
'whitesmoke': RGBColor(245, 245, 245),
|
||||
'x11gray': RGBColor(190, 190, 190),
|
||||
'x11green': RGBColor(0, 255, 0),
|
||||
'x11grey': RGBColor(190, 190, 190),
|
||||
'x11maroon': RGBColor(176, 48, 96),
|
||||
'x11purple': RGBColor(160, 32, 240),
|
||||
'yellow': RGBColor(255, 255, 0),
|
||||
'yellow1': RGBColor(255, 255, 0),
|
||||
'yellow2': RGBColor(238, 238, 0),
|
||||
'yellow3': RGBColor(205, 205, 0),
|
||||
'yellow4': RGBColor(139, 139, 0),
|
||||
'yellowgreen': RGBColor(154, 205, 50)
|
||||
}
|
||||
|
||||
#: Curses color indices of 8, 16, and 256-color terminals
|
||||
RGB_256TABLE = (
|
||||
RGBColor(0, 0, 0),
|
||||
RGBColor(205, 0, 0),
|
||||
RGBColor(0, 205, 0),
|
||||
RGBColor(205, 205, 0),
|
||||
RGBColor(0, 0, 238),
|
||||
RGBColor(205, 0, 205),
|
||||
RGBColor(0, 205, 205),
|
||||
RGBColor(229, 229, 229),
|
||||
RGBColor(127, 127, 127),
|
||||
RGBColor(255, 0, 0),
|
||||
RGBColor(0, 255, 0),
|
||||
RGBColor(255, 255, 0),
|
||||
RGBColor(92, 92, 255),
|
||||
RGBColor(255, 0, 255),
|
||||
RGBColor(0, 255, 255),
|
||||
RGBColor(255, 255, 255),
|
||||
RGBColor(0, 0, 0),
|
||||
RGBColor(0, 0, 95),
|
||||
RGBColor(0, 0, 135),
|
||||
RGBColor(0, 0, 175),
|
||||
RGBColor(0, 0, 215),
|
||||
RGBColor(0, 0, 255),
|
||||
RGBColor(0, 95, 0),
|
||||
RGBColor(0, 95, 95),
|
||||
RGBColor(0, 95, 135),
|
||||
RGBColor(0, 95, 175),
|
||||
RGBColor(0, 95, 215),
|
||||
RGBColor(0, 95, 255),
|
||||
RGBColor(0, 135, 0),
|
||||
RGBColor(0, 135, 95),
|
||||
RGBColor(0, 135, 135),
|
||||
RGBColor(0, 135, 175),
|
||||
RGBColor(0, 135, 215),
|
||||
RGBColor(0, 135, 255),
|
||||
RGBColor(0, 175, 0),
|
||||
RGBColor(0, 175, 95),
|
||||
RGBColor(0, 175, 135),
|
||||
RGBColor(0, 175, 175),
|
||||
RGBColor(0, 175, 215),
|
||||
RGBColor(0, 175, 255),
|
||||
RGBColor(0, 215, 0),
|
||||
RGBColor(0, 215, 95),
|
||||
RGBColor(0, 215, 135),
|
||||
RGBColor(0, 215, 175),
|
||||
RGBColor(0, 215, 215),
|
||||
RGBColor(0, 215, 255),
|
||||
RGBColor(0, 255, 0),
|
||||
RGBColor(0, 255, 95),
|
||||
RGBColor(0, 255, 135),
|
||||
RGBColor(0, 255, 175),
|
||||
RGBColor(0, 255, 215),
|
||||
RGBColor(0, 255, 255),
|
||||
RGBColor(95, 0, 0),
|
||||
RGBColor(95, 0, 95),
|
||||
RGBColor(95, 0, 135),
|
||||
RGBColor(95, 0, 175),
|
||||
RGBColor(95, 0, 215),
|
||||
RGBColor(95, 0, 255),
|
||||
RGBColor(95, 95, 0),
|
||||
RGBColor(95, 95, 95),
|
||||
RGBColor(95, 95, 135),
|
||||
RGBColor(95, 95, 175),
|
||||
RGBColor(95, 95, 215),
|
||||
RGBColor(95, 95, 255),
|
||||
RGBColor(95, 135, 0),
|
||||
RGBColor(95, 135, 95),
|
||||
RGBColor(95, 135, 135),
|
||||
RGBColor(95, 135, 175),
|
||||
RGBColor(95, 135, 215),
|
||||
RGBColor(95, 135, 255),
|
||||
RGBColor(95, 175, 0),
|
||||
RGBColor(95, 175, 95),
|
||||
RGBColor(95, 175, 135),
|
||||
RGBColor(95, 175, 175),
|
||||
RGBColor(95, 175, 215),
|
||||
RGBColor(95, 175, 255),
|
||||
RGBColor(95, 215, 0),
|
||||
RGBColor(95, 215, 95),
|
||||
RGBColor(95, 215, 135),
|
||||
RGBColor(95, 215, 175),
|
||||
RGBColor(95, 215, 215),
|
||||
RGBColor(95, 215, 255),
|
||||
RGBColor(95, 255, 0),
|
||||
RGBColor(95, 255, 95),
|
||||
RGBColor(95, 255, 135),
|
||||
RGBColor(95, 255, 175),
|
||||
RGBColor(95, 255, 215),
|
||||
RGBColor(95, 255, 255),
|
||||
RGBColor(135, 0, 0),
|
||||
RGBColor(135, 0, 95),
|
||||
RGBColor(135, 0, 135),
|
||||
RGBColor(135, 0, 175),
|
||||
RGBColor(135, 0, 215),
|
||||
RGBColor(135, 0, 255),
|
||||
RGBColor(135, 95, 0),
|
||||
RGBColor(135, 95, 95),
|
||||
RGBColor(135, 95, 135),
|
||||
RGBColor(135, 95, 175),
|
||||
RGBColor(135, 95, 215),
|
||||
RGBColor(135, 95, 255),
|
||||
RGBColor(135, 135, 0),
|
||||
RGBColor(135, 135, 95),
|
||||
RGBColor(135, 135, 135),
|
||||
RGBColor(135, 135, 175),
|
||||
RGBColor(135, 135, 215),
|
||||
RGBColor(135, 135, 255),
|
||||
RGBColor(135, 175, 0),
|
||||
RGBColor(135, 175, 95),
|
||||
RGBColor(135, 175, 135),
|
||||
RGBColor(135, 175, 175),
|
||||
RGBColor(135, 175, 215),
|
||||
RGBColor(135, 175, 255),
|
||||
RGBColor(135, 215, 0),
|
||||
RGBColor(135, 215, 95),
|
||||
RGBColor(135, 215, 135),
|
||||
RGBColor(135, 215, 175),
|
||||
RGBColor(135, 215, 215),
|
||||
RGBColor(135, 215, 255),
|
||||
RGBColor(135, 255, 0),
|
||||
RGBColor(135, 255, 95),
|
||||
RGBColor(135, 255, 135),
|
||||
RGBColor(135, 255, 175),
|
||||
RGBColor(135, 255, 215),
|
||||
RGBColor(135, 255, 255),
|
||||
RGBColor(175, 0, 0),
|
||||
RGBColor(175, 0, 95),
|
||||
RGBColor(175, 0, 135),
|
||||
RGBColor(175, 0, 175),
|
||||
RGBColor(175, 0, 215),
|
||||
RGBColor(175, 0, 255),
|
||||
RGBColor(175, 95, 0),
|
||||
RGBColor(175, 95, 95),
|
||||
RGBColor(175, 95, 135),
|
||||
RGBColor(175, 95, 175),
|
||||
RGBColor(175, 95, 215),
|
||||
RGBColor(175, 95, 255),
|
||||
RGBColor(175, 135, 0),
|
||||
RGBColor(175, 135, 95),
|
||||
RGBColor(175, 135, 135),
|
||||
RGBColor(175, 135, 175),
|
||||
RGBColor(175, 135, 215),
|
||||
RGBColor(175, 135, 255),
|
||||
RGBColor(175, 175, 0),
|
||||
RGBColor(175, 175, 95),
|
||||
RGBColor(175, 175, 135),
|
||||
RGBColor(175, 175, 175),
|
||||
RGBColor(175, 175, 215),
|
||||
RGBColor(175, 175, 255),
|
||||
RGBColor(175, 215, 0),
|
||||
RGBColor(175, 215, 95),
|
||||
RGBColor(175, 215, 135),
|
||||
RGBColor(175, 215, 175),
|
||||
RGBColor(175, 215, 215),
|
||||
RGBColor(175, 215, 255),
|
||||
RGBColor(175, 255, 0),
|
||||
RGBColor(175, 255, 95),
|
||||
RGBColor(175, 255, 135),
|
||||
RGBColor(175, 255, 175),
|
||||
RGBColor(175, 255, 215),
|
||||
RGBColor(175, 255, 255),
|
||||
RGBColor(215, 0, 0),
|
||||
RGBColor(215, 0, 95),
|
||||
RGBColor(215, 0, 135),
|
||||
RGBColor(215, 0, 175),
|
||||
RGBColor(215, 0, 215),
|
||||
RGBColor(215, 0, 255),
|
||||
RGBColor(215, 95, 0),
|
||||
RGBColor(215, 95, 95),
|
||||
RGBColor(215, 95, 135),
|
||||
RGBColor(215, 95, 175),
|
||||
RGBColor(215, 95, 215),
|
||||
RGBColor(215, 95, 255),
|
||||
RGBColor(215, 135, 0),
|
||||
RGBColor(215, 135, 95),
|
||||
RGBColor(215, 135, 135),
|
||||
RGBColor(215, 135, 175),
|
||||
RGBColor(215, 135, 215),
|
||||
RGBColor(215, 135, 255),
|
||||
RGBColor(215, 175, 0),
|
||||
RGBColor(215, 175, 95),
|
||||
RGBColor(215, 175, 135),
|
||||
RGBColor(215, 175, 175),
|
||||
RGBColor(215, 175, 215),
|
||||
RGBColor(215, 175, 255),
|
||||
RGBColor(215, 215, 0),
|
||||
RGBColor(215, 215, 95),
|
||||
RGBColor(215, 215, 135),
|
||||
RGBColor(215, 215, 175),
|
||||
RGBColor(215, 215, 215),
|
||||
RGBColor(215, 215, 255),
|
||||
RGBColor(215, 255, 0),
|
||||
RGBColor(215, 255, 95),
|
||||
RGBColor(215, 255, 135),
|
||||
RGBColor(215, 255, 175),
|
||||
RGBColor(215, 255, 215),
|
||||
RGBColor(215, 255, 255),
|
||||
RGBColor(255, 0, 0),
|
||||
RGBColor(255, 0, 135),
|
||||
RGBColor(255, 0, 95),
|
||||
RGBColor(255, 0, 175),
|
||||
RGBColor(255, 0, 215),
|
||||
RGBColor(255, 0, 255),
|
||||
RGBColor(255, 95, 0),
|
||||
RGBColor(255, 95, 95),
|
||||
RGBColor(255, 95, 135),
|
||||
RGBColor(255, 95, 175),
|
||||
RGBColor(255, 95, 215),
|
||||
RGBColor(255, 95, 255),
|
||||
RGBColor(255, 135, 0),
|
||||
RGBColor(255, 135, 95),
|
||||
RGBColor(255, 135, 135),
|
||||
RGBColor(255, 135, 175),
|
||||
RGBColor(255, 135, 215),
|
||||
RGBColor(255, 135, 255),
|
||||
RGBColor(255, 175, 0),
|
||||
RGBColor(255, 175, 95),
|
||||
RGBColor(255, 175, 135),
|
||||
RGBColor(255, 175, 175),
|
||||
RGBColor(255, 175, 215),
|
||||
RGBColor(255, 175, 255),
|
||||
RGBColor(255, 215, 0),
|
||||
RGBColor(255, 215, 95),
|
||||
RGBColor(255, 215, 135),
|
||||
RGBColor(255, 215, 175),
|
||||
RGBColor(255, 215, 215),
|
||||
RGBColor(255, 215, 255),
|
||||
RGBColor(255, 255, 0),
|
||||
RGBColor(255, 255, 95),
|
||||
RGBColor(255, 255, 135),
|
||||
RGBColor(255, 255, 175),
|
||||
RGBColor(255, 255, 215),
|
||||
RGBColor(255, 255, 255),
|
||||
RGBColor(8, 8, 8),
|
||||
RGBColor(18, 18, 18),
|
||||
RGBColor(28, 28, 28),
|
||||
RGBColor(38, 38, 38),
|
||||
RGBColor(48, 48, 48),
|
||||
RGBColor(58, 58, 58),
|
||||
RGBColor(68, 68, 68),
|
||||
RGBColor(78, 78, 78),
|
||||
RGBColor(88, 88, 88),
|
||||
RGBColor(98, 98, 98),
|
||||
RGBColor(108, 108, 108),
|
||||
RGBColor(118, 118, 118),
|
||||
RGBColor(128, 128, 128),
|
||||
RGBColor(138, 138, 138),
|
||||
RGBColor(148, 148, 148),
|
||||
RGBColor(158, 158, 158),
|
||||
RGBColor(168, 168, 168),
|
||||
RGBColor(178, 178, 178),
|
||||
RGBColor(188, 188, 188),
|
||||
RGBColor(198, 198, 198),
|
||||
RGBColor(208, 208, 208),
|
||||
RGBColor(218, 218, 218),
|
||||
RGBColor(228, 228, 228),
|
||||
RGBColor(238, 238, 238),
|
||||
)
|
||||
12
venv/lib/python3.11/site-packages/blessed/colorspace.pyi
Normal file
12
venv/lib/python3.11/site-packages/blessed/colorspace.pyi
Normal file
@@ -0,0 +1,12 @@
|
||||
# std imports
|
||||
from typing import Set, Dict, Tuple, NamedTuple
|
||||
|
||||
CGA_COLORS: Set[str]
|
||||
|
||||
class RGBColor(NamedTuple):
|
||||
red: int
|
||||
green: int
|
||||
blue: int
|
||||
|
||||
X11_COLORNAMES_TO_RGB: Dict[str, RGBColor]
|
||||
RGB_256TABLE: Tuple[RGBColor, ...]
|
||||
496
venv/lib/python3.11/site-packages/blessed/formatters.py
Normal file
496
venv/lib/python3.11/site-packages/blessed/formatters.py
Normal file
@@ -0,0 +1,496 @@
|
||||
"""Sub-module providing sequence-formatting functions."""
|
||||
# std imports
|
||||
import platform
|
||||
|
||||
# 3rd party
|
||||
import six
|
||||
|
||||
# local
|
||||
from blessed.colorspace import CGA_COLORS, X11_COLORNAMES_TO_RGB
|
||||
|
||||
# isort: off
|
||||
# curses
|
||||
if platform.system() == 'Windows':
|
||||
import jinxed as curses # pylint: disable=import-error
|
||||
else:
|
||||
import curses
|
||||
|
||||
|
||||
def _make_colors():
|
||||
"""
|
||||
Return set of valid colors and their derivatives.
|
||||
|
||||
:rtype: set
|
||||
:returns: Color names with prefixes
|
||||
"""
|
||||
colors = set()
|
||||
# basic CGA foreground color, background, high intensity, and bold
|
||||
# background ('iCE colors' in my day).
|
||||
for cga_color in CGA_COLORS:
|
||||
colors.add(cga_color)
|
||||
colors.add('on_' + cga_color)
|
||||
colors.add('bright_' + cga_color)
|
||||
colors.add('on_bright_' + cga_color)
|
||||
|
||||
# foreground and background VGA color
|
||||
for vga_color in X11_COLORNAMES_TO_RGB:
|
||||
colors.add(vga_color)
|
||||
colors.add('on_' + vga_color)
|
||||
return colors
|
||||
|
||||
|
||||
#: Valid colors and their background (on), bright, and bright-background
|
||||
#: derivatives.
|
||||
COLORS = _make_colors()
|
||||
|
||||
#: Attributes that may be compounded with colors, by underscore, such as
|
||||
#: 'reverse_indigo'.
|
||||
COMPOUNDABLES = set('bold underline reverse blink italic standout'.split())
|
||||
|
||||
|
||||
class ParameterizingString(six.text_type):
|
||||
r"""
|
||||
A Unicode string which can be called as a parameterizing termcap.
|
||||
|
||||
For example::
|
||||
|
||||
>>> from blessed import Terminal
|
||||
>>> term = Terminal()
|
||||
>>> color = ParameterizingString(term.color, term.normal, 'color')
|
||||
>>> color(9)('color #9')
|
||||
u'\x1b[91mcolor #9\x1b(B\x1b[m'
|
||||
"""
|
||||
|
||||
def __new__(cls, cap, normal=u'', name=u'<not specified>'):
|
||||
# pylint: disable = missing-return-doc, missing-return-type-doc
|
||||
"""
|
||||
Class constructor accepting 3 positional arguments.
|
||||
|
||||
:arg str cap: parameterized string suitable for curses.tparm()
|
||||
:arg str normal: terminating sequence for this capability (optional).
|
||||
:arg str name: name of this terminal capability (optional).
|
||||
"""
|
||||
new = six.text_type.__new__(cls, cap)
|
||||
new._normal = normal
|
||||
new._name = name
|
||||
return new
|
||||
|
||||
def __call__(self, *args):
|
||||
"""
|
||||
Returning :class:`FormattingString` instance for given parameters.
|
||||
|
||||
Return evaluated terminal capability (self), receiving arguments
|
||||
``*args``, followed by the terminating sequence (self.normal) into
|
||||
a :class:`FormattingString` capable of being called.
|
||||
|
||||
:raises TypeError: Mismatch between capability and arguments
|
||||
:raises curses.error: :func:`curses.tparm` raised an exception
|
||||
:rtype: :class:`FormattingString` or :class:`NullCallableString`
|
||||
:returns: Callable string for given parameters
|
||||
"""
|
||||
try:
|
||||
# Re-encode the cap, because tparm() takes a bytestring in Python
|
||||
# 3. However, appear to be a plain Unicode string otherwise so
|
||||
# concats work.
|
||||
attr = curses.tparm(self.encode('latin1'), *args).decode('latin1')
|
||||
return FormattingString(attr, self._normal)
|
||||
except TypeError as err:
|
||||
# If the first non-int (i.e. incorrect) arg was a string, suggest
|
||||
# something intelligent:
|
||||
if args and isinstance(args[0], six.string_types):
|
||||
raise TypeError(
|
||||
"Unknown terminal capability, %r, or, TypeError "
|
||||
"for arguments %r: %s" % (self._name, args, err))
|
||||
# Somebody passed a non-string; I don't feel confident
|
||||
# guessing what they were trying to do.
|
||||
raise
|
||||
except curses.error as err:
|
||||
# ignore 'tparm() returned NULL', you won't get any styling,
|
||||
# even if does_styling is True. This happens on win32 platforms
|
||||
# with http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses installed
|
||||
if "tparm() returned NULL" not in six.text_type(err):
|
||||
raise
|
||||
return NullCallableString()
|
||||
|
||||
|
||||
class ParameterizingProxyString(six.text_type):
|
||||
r"""
|
||||
A Unicode string which can be called to proxy missing termcap entries.
|
||||
|
||||
This class supports the function :func:`get_proxy_string`, and mirrors
|
||||
the behavior of :class:`ParameterizingString`, except that instead of
|
||||
a capability name, receives a format string, and callable to filter the
|
||||
given positional ``*args`` of :meth:`ParameterizingProxyString.__call__`
|
||||
into a terminal sequence.
|
||||
|
||||
For example::
|
||||
|
||||
>>> from blessed import Terminal
|
||||
>>> term = Terminal('screen')
|
||||
>>> hpa = ParameterizingString(term.hpa, term.normal, 'hpa')
|
||||
>>> hpa(9)
|
||||
u''
|
||||
>>> fmt = u'\x1b[{0}G'
|
||||
>>> fmt_arg = lambda *arg: (arg[0] + 1,)
|
||||
>>> hpa = ParameterizingProxyString((fmt, fmt_arg), term.normal, 'hpa')
|
||||
>>> hpa(9)
|
||||
u'\x1b[10G'
|
||||
"""
|
||||
|
||||
def __new__(cls, fmt_pair, normal=u'', name=u'<not specified>'):
|
||||
# pylint: disable = missing-return-doc, missing-return-type-doc
|
||||
"""
|
||||
Class constructor accepting 4 positional arguments.
|
||||
|
||||
:arg tuple fmt_pair: Two element tuple containing:
|
||||
- format string suitable for displaying terminal sequences
|
||||
- callable suitable for receiving __call__ arguments for formatting string
|
||||
:arg str normal: terminating sequence for this capability (optional).
|
||||
:arg str name: name of this terminal capability (optional).
|
||||
"""
|
||||
assert isinstance(fmt_pair, tuple), fmt_pair
|
||||
assert callable(fmt_pair[1]), fmt_pair[1]
|
||||
new = six.text_type.__new__(cls, fmt_pair[0])
|
||||
new._fmt_args = fmt_pair[1]
|
||||
new._normal = normal
|
||||
new._name = name
|
||||
return new
|
||||
|
||||
def __call__(self, *args):
|
||||
"""
|
||||
Returning :class:`FormattingString` instance for given parameters.
|
||||
|
||||
Arguments are determined by the capability. For example, ``hpa``
|
||||
(move_x) receives only a single integer, whereas ``cup`` (move)
|
||||
receives two integers. See documentation in terminfo(5) for the
|
||||
given capability.
|
||||
|
||||
:rtype: FormattingString
|
||||
:returns: Callable string for given parameters
|
||||
"""
|
||||
return FormattingString(self.format(*self._fmt_args(*args)),
|
||||
self._normal)
|
||||
|
||||
|
||||
class FormattingString(six.text_type):
|
||||
r"""
|
||||
A Unicode string which doubles as a callable.
|
||||
|
||||
This is used for terminal attributes, so that it may be used both
|
||||
directly, or as a callable. When used directly, it simply emits
|
||||
the given terminal sequence. When used as a callable, it wraps the
|
||||
given (string) argument with the 2nd argument used by the class
|
||||
constructor::
|
||||
|
||||
>>> from blessed import Terminal
|
||||
>>> term = Terminal()
|
||||
>>> style = FormattingString(term.bright_blue, term.normal)
|
||||
>>> print(repr(style))
|
||||
u'\x1b[94m'
|
||||
>>> style('Big Blue')
|
||||
u'\x1b[94mBig Blue\x1b(B\x1b[m'
|
||||
"""
|
||||
|
||||
def __new__(cls, sequence, normal=u''):
|
||||
# pylint: disable = missing-return-doc, missing-return-type-doc
|
||||
"""
|
||||
Class constructor accepting 2 positional arguments.
|
||||
|
||||
:arg str sequence: terminal attribute sequence.
|
||||
:arg str normal: terminating sequence for this attribute (optional).
|
||||
"""
|
||||
new = six.text_type.__new__(cls, sequence)
|
||||
new._normal = normal
|
||||
return new
|
||||
|
||||
def __call__(self, *args):
|
||||
"""
|
||||
Return ``text`` joined by ``sequence`` and ``normal``.
|
||||
|
||||
:raises TypeError: Not a string type
|
||||
:rtype: str
|
||||
:returns: Arguments wrapped in sequence and normal
|
||||
"""
|
||||
# Jim Allman brings us this convenience of allowing existing
|
||||
# unicode strings to be joined as a call parameter to a formatting
|
||||
# string result, allowing nestation:
|
||||
#
|
||||
# >>> t.red('This is ', t.bold('extremely'), ' dangerous!')
|
||||
for idx, ucs_part in enumerate(args):
|
||||
if not isinstance(ucs_part, six.string_types):
|
||||
expected_types = ', '.join(_type.__name__ for _type in six.string_types)
|
||||
raise TypeError(
|
||||
"TypeError for FormattingString argument, "
|
||||
"%r, at position %s: expected type %s, "
|
||||
"got %s" % (ucs_part, idx, expected_types,
|
||||
type(ucs_part).__name__))
|
||||
postfix = u''
|
||||
if self and self._normal:
|
||||
postfix = self._normal
|
||||
_refresh = self._normal + self
|
||||
args = [_refresh.join(ucs_part.split(self._normal))
|
||||
for ucs_part in args]
|
||||
|
||||
return self + u''.join(args) + postfix
|
||||
|
||||
|
||||
class FormattingOtherString(six.text_type):
|
||||
r"""
|
||||
A Unicode string which doubles as a callable for another sequence when called.
|
||||
|
||||
This is used for the :meth:`~.Terminal.move_up`, ``down``, ``left``, and ``right()``
|
||||
family of functions::
|
||||
|
||||
>>> from blessed import Terminal
|
||||
>>> term = Terminal()
|
||||
>>> move_right = FormattingOtherString(term.cuf1, term.cuf)
|
||||
>>> print(repr(move_right))
|
||||
u'\x1b[C'
|
||||
>>> print(repr(move_right(666)))
|
||||
u'\x1b[666C'
|
||||
>>> print(repr(move_right()))
|
||||
u'\x1b[C'
|
||||
"""
|
||||
|
||||
def __new__(cls, direct, target):
|
||||
# pylint: disable = missing-return-doc, missing-return-type-doc
|
||||
"""
|
||||
Class constructor accepting 2 positional arguments.
|
||||
|
||||
:arg str direct: capability name for direct formatting, eg ``('x' + term.right)``.
|
||||
:arg str target: capability name for callable, eg ``('x' + term.right(99))``.
|
||||
"""
|
||||
new = six.text_type.__new__(cls, direct)
|
||||
new._callable = target
|
||||
return new
|
||||
|
||||
def __getnewargs__(self):
|
||||
# return arguments used for the __new__ method upon unpickling.
|
||||
return six.text_type.__new__(six.text_type, self), self._callable
|
||||
|
||||
def __call__(self, *args):
|
||||
"""Return ``text`` by ``target``."""
|
||||
return self._callable(*args) if args else self
|
||||
|
||||
|
||||
class NullCallableString(six.text_type):
|
||||
"""
|
||||
A dummy callable Unicode alternative to :class:`FormattingString`.
|
||||
|
||||
This is used for colors on terminals that do not support colors, it is just a basic form of
|
||||
unicode that may also act as a callable.
|
||||
"""
|
||||
|
||||
def __new__(cls):
|
||||
"""Class constructor."""
|
||||
return six.text_type.__new__(cls, u'')
|
||||
|
||||
def __call__(self, *args):
|
||||
"""
|
||||
Allow empty string to be callable, returning given string, if any.
|
||||
|
||||
When called with an int as the first arg, return an empty Unicode. An
|
||||
int is a good hint that I am a :class:`ParameterizingString`, as there
|
||||
are only about half a dozen string-returning capabilities listed in
|
||||
terminfo(5) which accept non-int arguments, they are seldom used.
|
||||
|
||||
When called with a non-int as the first arg (no no args at all), return
|
||||
the first arg, acting in place of :class:`FormattingString` without
|
||||
any attributes.
|
||||
"""
|
||||
if not args or isinstance(args[0], int):
|
||||
# As a NullCallableString, even when provided with a parameter,
|
||||
# such as t.color(5), we must also still be callable, fe:
|
||||
#
|
||||
# >>> t.color(5)('shmoo')
|
||||
#
|
||||
# is actually simplified result of NullCallable()() on terminals
|
||||
# without color support, so turtles all the way down: we return
|
||||
# another instance.
|
||||
return NullCallableString()
|
||||
return u''.join(args)
|
||||
|
||||
|
||||
def get_proxy_string(term, attr):
|
||||
"""
|
||||
Proxy and return callable string for proxied attributes.
|
||||
|
||||
:arg Terminal term: :class:`~.Terminal` instance.
|
||||
:arg str attr: terminal capability name that may be proxied.
|
||||
:rtype: None or :class:`ParameterizingProxyString`.
|
||||
:returns: :class:`ParameterizingProxyString` for some attributes
|
||||
of some terminal types that support it, where the terminfo(5)
|
||||
database would otherwise come up empty, such as ``move_x``
|
||||
attribute for ``term.kind`` of ``screen``. Otherwise, None.
|
||||
"""
|
||||
# normalize 'screen-256color', or 'ansi.sys' to its basic names
|
||||
term_kind = next(iter(_kind for _kind in ('screen', 'ansi',)
|
||||
if term.kind.startswith(_kind)), term)
|
||||
_proxy_table = { # pragma: no cover
|
||||
'screen': {
|
||||
# proxy move_x/move_y for 'screen' terminal type, used by tmux(1).
|
||||
'hpa': ParameterizingProxyString(
|
||||
(u'\x1b[{0}G', lambda *arg: (arg[0] + 1,)), term.normal, attr),
|
||||
'vpa': ParameterizingProxyString(
|
||||
(u'\x1b[{0}d', lambda *arg: (arg[0] + 1,)), term.normal, attr),
|
||||
},
|
||||
'ansi': {
|
||||
# proxy show/hide cursor for 'ansi' terminal type. There is some
|
||||
# demand for a richly working ANSI terminal type for some reason.
|
||||
'civis': ParameterizingProxyString(
|
||||
(u'\x1b[?25l', lambda *arg: ()), term.normal, attr),
|
||||
'cnorm': ParameterizingProxyString(
|
||||
(u'\x1b[?25h', lambda *arg: ()), term.normal, attr),
|
||||
'hpa': ParameterizingProxyString(
|
||||
(u'\x1b[{0}G', lambda *arg: (arg[0] + 1,)), term.normal, attr),
|
||||
'vpa': ParameterizingProxyString(
|
||||
(u'\x1b[{0}d', lambda *arg: (arg[0] + 1,)), term.normal, attr),
|
||||
'sc': '\x1b[s',
|
||||
'rc': '\x1b[u',
|
||||
}
|
||||
}
|
||||
return _proxy_table.get(term_kind, {}).get(attr, None)
|
||||
|
||||
|
||||
def split_compound(compound):
|
||||
"""
|
||||
Split compound formating string into segments.
|
||||
|
||||
>>> split_compound('bold_underline_bright_blue_on_red')
|
||||
['bold', 'underline', 'bright_blue', 'on_red']
|
||||
|
||||
:arg str compound: a string that may contain compounds, separated by
|
||||
underline (``_``).
|
||||
:rtype: list
|
||||
:returns: List of formating string segments
|
||||
"""
|
||||
merged_segs = []
|
||||
# These occur only as prefixes, so they can always be merged:
|
||||
mergeable_prefixes = ['on', 'bright', 'on_bright']
|
||||
for segment in compound.split('_'):
|
||||
if merged_segs and merged_segs[-1] in mergeable_prefixes:
|
||||
merged_segs[-1] += '_' + segment
|
||||
else:
|
||||
merged_segs.append(segment)
|
||||
return merged_segs
|
||||
|
||||
|
||||
def resolve_capability(term, attr):
|
||||
"""
|
||||
Resolve a raw terminal capability using :func:`tigetstr`.
|
||||
|
||||
:arg Terminal term: :class:`~.Terminal` instance.
|
||||
:arg str attr: terminal capability name.
|
||||
:returns: string of the given terminal capability named by ``attr``,
|
||||
which may be empty (u'') if not found or not supported by the
|
||||
given :attr:`~.Terminal.kind`.
|
||||
:rtype: str
|
||||
"""
|
||||
if not term.does_styling:
|
||||
return u''
|
||||
val = curses.tigetstr(term._sugar.get(attr, attr)) # pylint: disable=protected-access
|
||||
# Decode sequences as latin1, as they are always 8-bit bytes, so when
|
||||
# b'\xff' is returned, this is decoded as u'\xff'.
|
||||
return u'' if val is None else val.decode('latin1')
|
||||
|
||||
|
||||
def resolve_color(term, color):
|
||||
"""
|
||||
Resolve a simple color name to a callable capability.
|
||||
|
||||
This function supports :func:`resolve_attribute`.
|
||||
|
||||
:arg Terminal term: :class:`~.Terminal` instance.
|
||||
:arg str color: any string found in set :const:`COLORS`.
|
||||
:returns: a string class instance which emits the terminal sequence
|
||||
for the given color, and may be used as a callable to wrap the
|
||||
given string with such sequence.
|
||||
:returns: :class:`NullCallableString` when
|
||||
:attr:`~.Terminal.number_of_colors` is 0,
|
||||
otherwise :class:`FormattingString`.
|
||||
:rtype: :class:`NullCallableString` or :class:`FormattingString`
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
if term.number_of_colors == 0:
|
||||
return NullCallableString()
|
||||
|
||||
# fg/bg capabilities terminals that support 0-256+ colors.
|
||||
vga_color_cap = (term._background_color if 'on_' in color else
|
||||
term._foreground_color)
|
||||
|
||||
base_color = color.rsplit('_', 1)[-1]
|
||||
if base_color in CGA_COLORS:
|
||||
# curses constants go up to only 7, so add an offset to get at the
|
||||
# bright colors at 8-15:
|
||||
offset = 8 if 'bright_' in color else 0
|
||||
base_color = color.rsplit('_', 1)[-1]
|
||||
attr = 'COLOR_%s' % (base_color.upper(),)
|
||||
fmt_attr = vga_color_cap(getattr(curses, attr) + offset)
|
||||
return FormattingString(fmt_attr, term.normal)
|
||||
|
||||
assert base_color in X11_COLORNAMES_TO_RGB, (
|
||||
'color not known', base_color)
|
||||
rgb = X11_COLORNAMES_TO_RGB[base_color]
|
||||
|
||||
# downconvert X11 colors to CGA, EGA, or VGA color spaces
|
||||
if term.number_of_colors <= 256:
|
||||
fmt_attr = vga_color_cap(term.rgb_downconvert(*rgb))
|
||||
return FormattingString(fmt_attr, term.normal)
|
||||
|
||||
# Modern 24-bit color terminals are written pretty basically. The
|
||||
# foreground and background sequences are:
|
||||
# - ^[38;2;<r>;<g>;<b>m
|
||||
# - ^[48;2;<r>;<g>;<b>m
|
||||
fgbg_seq = ('48' if 'on_' in color else '38')
|
||||
assert term.number_of_colors == 1 << 24
|
||||
fmt_attr = u'\x1b[' + fgbg_seq + ';2;{0};{1};{2}m'
|
||||
return FormattingString(fmt_attr.format(*rgb), term.normal)
|
||||
|
||||
|
||||
def resolve_attribute(term, attr):
|
||||
"""
|
||||
Resolve a terminal attribute name into a capability class.
|
||||
|
||||
:arg Terminal term: :class:`~.Terminal` instance.
|
||||
:arg str attr: Sugary, ordinary, or compound formatted terminal
|
||||
capability, such as "red_on_white", "normal", "red", or
|
||||
"bold_on_black".
|
||||
:returns: a string class instance which emits the terminal sequence
|
||||
for the given terminal capability, or may be used as a callable to
|
||||
wrap the given string with such sequence.
|
||||
:returns: :class:`NullCallableString` when
|
||||
:attr:`~.Terminal.number_of_colors` is 0,
|
||||
otherwise :class:`FormattingString`.
|
||||
:rtype: :class:`NullCallableString` or :class:`FormattingString`
|
||||
"""
|
||||
if attr in COLORS:
|
||||
return resolve_color(term, attr)
|
||||
|
||||
# A direct compoundable, such as `bold' or `on_red'.
|
||||
if attr in COMPOUNDABLES:
|
||||
sequence = resolve_capability(term, attr)
|
||||
return FormattingString(sequence, term.normal)
|
||||
|
||||
# Given `bold_on_red', resolve to ('bold', 'on_red'), RECURSIVE
|
||||
# call for each compounding section, joined and returned as
|
||||
# a completed completed FormattingString.
|
||||
formatters = split_compound(attr)
|
||||
if all((fmt in COLORS or fmt in COMPOUNDABLES) for fmt in formatters):
|
||||
resolution = (resolve_attribute(term, fmt) for fmt in formatters)
|
||||
return FormattingString(u''.join(resolution), term.normal)
|
||||
|
||||
# otherwise, this is our end-game: given a sequence such as 'csr'
|
||||
# (change scrolling region), return a ParameterizingString instance,
|
||||
# that when called, performs and returns the final string after curses
|
||||
# capability lookup is performed.
|
||||
tparm_capseq = resolve_capability(term, attr)
|
||||
if not tparm_capseq:
|
||||
# and, for special terminals, such as 'screen', provide a Proxy
|
||||
# ParameterizingString for attributes they do not claim to support,
|
||||
# but actually do! (such as 'hpa' and 'vpa').
|
||||
proxy = get_proxy_string(term,
|
||||
term._sugar.get(attr, attr)) # pylint: disable=protected-access
|
||||
if proxy is not None:
|
||||
return proxy
|
||||
|
||||
return ParameterizingString(tparm_capseq, term.normal, attr)
|
||||
70
venv/lib/python3.11/site-packages/blessed/formatters.pyi
Normal file
70
venv/lib/python3.11/site-packages/blessed/formatters.pyi
Normal file
@@ -0,0 +1,70 @@
|
||||
# std imports
|
||||
from typing import (Any,
|
||||
Set,
|
||||
List,
|
||||
Type,
|
||||
Tuple,
|
||||
Union,
|
||||
TypeVar,
|
||||
Callable,
|
||||
NoReturn,
|
||||
Optional,
|
||||
overload)
|
||||
|
||||
# local
|
||||
from .terminal import Terminal
|
||||
|
||||
COLORS: Set[str]
|
||||
COMPOUNDABLES: Set[str]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class ParameterizingString(str):
|
||||
def __new__(cls: Type[_T], cap: str, normal: str = ..., name: str = ...) -> _T: ...
|
||||
@overload
|
||||
def __call__(
|
||||
self, *args: int
|
||||
) -> Union["FormattingString", "NullCallableString"]: ...
|
||||
@overload
|
||||
def __call__(self, *args: str) -> NoReturn: ...
|
||||
|
||||
class ParameterizingProxyString(str):
|
||||
def __new__(
|
||||
cls: Type[_T],
|
||||
fmt_pair: Tuple[str, Callable[..., Tuple[object, ...]]],
|
||||
normal: str = ...,
|
||||
name: str = ...,
|
||||
) -> _T: ...
|
||||
def __call__(self, *args: Any) -> "FormattingString": ...
|
||||
|
||||
class FormattingString(str):
|
||||
def __new__(cls: Type[_T], sequence: str, normal: str = ...) -> _T: ...
|
||||
@overload
|
||||
def __call__(self, *args: int) -> NoReturn: ...
|
||||
@overload
|
||||
def __call__(self, *args: str) -> str: ...
|
||||
|
||||
class FormattingOtherString(str):
|
||||
def __new__(
|
||||
cls: Type[_T], direct: ParameterizingString, target: ParameterizingString = ...
|
||||
) -> _T: ...
|
||||
def __call__(self, *args: Union[int, str]) -> str: ...
|
||||
|
||||
class NullCallableString(str):
|
||||
def __new__(cls: Type[_T]) -> _T: ...
|
||||
@overload
|
||||
def __call__(self, *args: int) -> "NullCallableString": ...
|
||||
@overload
|
||||
def __call__(self, *args: str) -> str: ...
|
||||
|
||||
def get_proxy_string(
|
||||
term: Terminal, attr: str
|
||||
) -> Optional[ParameterizingProxyString]: ...
|
||||
def split_compound(compound: str) -> List[str]: ...
|
||||
def resolve_capability(term: Terminal, attr: str) -> str: ...
|
||||
def resolve_color(
|
||||
term: Terminal, color: str
|
||||
) -> Union[NullCallableString, FormattingString]: ...
|
||||
def resolve_attribute(
|
||||
term: Terminal, attr: str
|
||||
) -> Union[ParameterizingString, FormattingString]: ...
|
||||
451
venv/lib/python3.11/site-packages/blessed/keyboard.py
Normal file
451
venv/lib/python3.11/site-packages/blessed/keyboard.py
Normal file
@@ -0,0 +1,451 @@
|
||||
"""Sub-module providing 'keyboard awareness'."""
|
||||
|
||||
# std imports
|
||||
import re
|
||||
import time
|
||||
import platform
|
||||
from collections import OrderedDict
|
||||
|
||||
# 3rd party
|
||||
import six
|
||||
|
||||
# isort: off
|
||||
# curses
|
||||
if platform.system() == 'Windows':
|
||||
# pylint: disable=import-error
|
||||
import jinxed as curses
|
||||
from jinxed.has_key import _capability_names as capability_names
|
||||
else:
|
||||
import curses
|
||||
from curses.has_key import _capability_names as capability_names
|
||||
|
||||
|
||||
class Keystroke(six.text_type):
|
||||
"""
|
||||
A unicode-derived class for describing a single keystroke.
|
||||
|
||||
A class instance describes a single keystroke received on input,
|
||||
which may contain multiple characters as a multibyte sequence,
|
||||
which is indicated by properties :attr:`is_sequence` returning
|
||||
``True``.
|
||||
|
||||
When the string is a known sequence, :attr:`code` matches terminal
|
||||
class attributes for comparison, such as ``term.KEY_LEFT``.
|
||||
|
||||
The string-name of the sequence, such as ``u'KEY_LEFT'`` is accessed
|
||||
by property :attr:`name`, and is used by the :meth:`__repr__` method
|
||||
to display a human-readable form of the Keystroke this class
|
||||
instance represents. It may otherwise by joined, split, or evaluated
|
||||
just as as any other unicode string.
|
||||
"""
|
||||
|
||||
def __new__(cls, ucs='', code=None, name=None):
|
||||
"""Class constructor."""
|
||||
new = six.text_type.__new__(cls, ucs)
|
||||
new._name = name
|
||||
new._code = code
|
||||
return new
|
||||
|
||||
@property
|
||||
def is_sequence(self):
|
||||
"""Whether the value represents a multibyte sequence (bool)."""
|
||||
return self._code is not None
|
||||
|
||||
def __repr__(self):
|
||||
"""Docstring overwritten."""
|
||||
return (six.text_type.__repr__(self) if self._name is None else
|
||||
self._name)
|
||||
__repr__.__doc__ = six.text_type.__doc__
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""String-name of key sequence, such as ``u'KEY_LEFT'`` (str)."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def code(self):
|
||||
"""Integer keycode value of multibyte sequence (int)."""
|
||||
return self._code
|
||||
|
||||
|
||||
def get_curses_keycodes():
|
||||
"""
|
||||
Return mapping of curses key-names paired by their keycode integer value.
|
||||
|
||||
:rtype: dict
|
||||
:returns: Dictionary of (name, code) pairs for curses keyboard constant
|
||||
values and their mnemonic name. Such as code ``260``, with the value of
|
||||
its key-name identity, ``u'KEY_LEFT'``.
|
||||
"""
|
||||
_keynames = [attr for attr in dir(curses)
|
||||
if attr.startswith('KEY_')]
|
||||
return {keyname: getattr(curses, keyname) for keyname in _keynames}
|
||||
|
||||
|
||||
def get_keyboard_codes():
|
||||
"""
|
||||
Return mapping of keycode integer values paired by their curses key-name.
|
||||
|
||||
:rtype: dict
|
||||
:returns: Dictionary of (code, name) pairs for curses keyboard constant
|
||||
values and their mnemonic name. Such as key ``260``, with the value of
|
||||
its identity, ``u'KEY_LEFT'``.
|
||||
|
||||
These keys are derived from the attributes by the same of the curses module,
|
||||
with the following exceptions:
|
||||
|
||||
* ``KEY_DELETE`` in place of ``KEY_DC``
|
||||
* ``KEY_INSERT`` in place of ``KEY_IC``
|
||||
* ``KEY_PGUP`` in place of ``KEY_PPAGE``
|
||||
* ``KEY_PGDOWN`` in place of ``KEY_NPAGE``
|
||||
* ``KEY_ESCAPE`` in place of ``KEY_EXIT``
|
||||
* ``KEY_SUP`` in place of ``KEY_SR``
|
||||
* ``KEY_SDOWN`` in place of ``KEY_SF``
|
||||
|
||||
This function is the inverse of :func:`get_curses_keycodes`. With the
|
||||
given override "mixins" listed above, the keycode for the delete key will
|
||||
map to our imaginary ``KEY_DELETE`` mnemonic, effectively erasing the
|
||||
phrase ``KEY_DC`` from our code vocabulary for anyone that wishes to use
|
||||
the return value to determine the key-name by keycode.
|
||||
"""
|
||||
keycodes = OrderedDict(get_curses_keycodes())
|
||||
keycodes.update(CURSES_KEYCODE_OVERRIDE_MIXIN)
|
||||
# merge _CURSES_KEYCODE_ADDINS added to our module space
|
||||
keycodes.update(
|
||||
(name, value) for name, value in globals().copy().items() if name.startswith('KEY_')
|
||||
)
|
||||
|
||||
# invert dictionary (key, values) => (values, key), preferring the
|
||||
# last-most inserted value ('KEY_DELETE' over 'KEY_DC').
|
||||
return dict(zip(keycodes.values(), keycodes.keys()))
|
||||
|
||||
|
||||
def _alternative_left_right(term):
|
||||
r"""
|
||||
Determine and return mapping of left and right arrow keys sequences.
|
||||
|
||||
:arg blessed.Terminal term: :class:`~.Terminal` instance.
|
||||
:rtype: dict
|
||||
:returns: Dictionary of sequences ``term._cuf1``, and ``term._cub1``,
|
||||
valued as ``KEY_RIGHT``, ``KEY_LEFT`` (when appropriate).
|
||||
|
||||
This function supports :func:`get_terminal_sequences` to discover
|
||||
the preferred input sequence for the left and right application keys.
|
||||
|
||||
It is necessary to check the value of these sequences to ensure we do not
|
||||
use ``u' '`` and ``u'\b'`` for ``KEY_RIGHT`` and ``KEY_LEFT``,
|
||||
preferring their true application key sequence, instead.
|
||||
"""
|
||||
# pylint: disable=protected-access
|
||||
keymap = {}
|
||||
if term._cuf1 and term._cuf1 != u' ':
|
||||
keymap[term._cuf1] = curses.KEY_RIGHT
|
||||
if term._cub1 and term._cub1 != u'\b':
|
||||
keymap[term._cub1] = curses.KEY_LEFT
|
||||
return keymap
|
||||
|
||||
|
||||
def get_keyboard_sequences(term):
|
||||
r"""
|
||||
Return mapping of keyboard sequences paired by keycodes.
|
||||
|
||||
:arg blessed.Terminal term: :class:`~.Terminal` instance.
|
||||
:returns: mapping of keyboard unicode sequences paired by keycodes
|
||||
as integer. This is used as the argument ``mapper`` to
|
||||
the supporting function :func:`resolve_sequence`.
|
||||
:rtype: OrderedDict
|
||||
|
||||
Initialize and return a keyboard map and sequence lookup table,
|
||||
(sequence, keycode) from :class:`~.Terminal` instance ``term``,
|
||||
where ``sequence`` is a multibyte input sequence of unicode
|
||||
characters, such as ``u'\x1b[D'``, and ``keycode`` is an integer
|
||||
value, matching curses constant such as term.KEY_LEFT.
|
||||
|
||||
The return value is an OrderedDict instance, with their keys
|
||||
sorted longest-first.
|
||||
"""
|
||||
# A small gem from curses.has_key that makes this all possible,
|
||||
# _capability_names: a lookup table of terminal capability names for
|
||||
# keyboard sequences (fe. kcub1, key_left), keyed by the values of
|
||||
# constants found beginning with KEY_ in the main curses module
|
||||
# (such as KEY_LEFT).
|
||||
#
|
||||
# latin1 encoding is used so that bytes in 8-bit range of 127-255
|
||||
# have equivalent chr() and unichr() values, so that the sequence
|
||||
# of a kermit or avatar terminal, for example, remains unchanged
|
||||
# in its byte sequence values even when represented by unicode.
|
||||
#
|
||||
sequence_map = dict((
|
||||
(seq.decode('latin1'), val)
|
||||
for (seq, val) in (
|
||||
(curses.tigetstr(cap), val)
|
||||
for (val, cap) in capability_names.items()
|
||||
) if seq
|
||||
) if term.does_styling else ())
|
||||
|
||||
sequence_map.update(_alternative_left_right(term))
|
||||
sequence_map.update(DEFAULT_SEQUENCE_MIXIN)
|
||||
|
||||
# This is for fast lookup matching of sequences, preferring
|
||||
# full-length sequence such as ('\x1b[D', KEY_LEFT)
|
||||
# over simple sequences such as ('\x1b', KEY_EXIT).
|
||||
return OrderedDict((
|
||||
(seq, sequence_map[seq]) for seq in sorted(
|
||||
sequence_map.keys(), key=len, reverse=True)))
|
||||
|
||||
|
||||
def get_leading_prefixes(sequences):
|
||||
"""
|
||||
Return a set of proper prefixes for given sequence of strings.
|
||||
|
||||
:arg iterable sequences
|
||||
:rtype: set
|
||||
:return: Set of all string prefixes
|
||||
|
||||
Given an iterable of strings, all textparts leading up to the final
|
||||
string is returned as a unique set. This function supports the
|
||||
:meth:`~.Terminal.inkey` method by determining whether the given
|
||||
input is a sequence that **may** lead to a final matching pattern.
|
||||
|
||||
>>> prefixes(['abc', 'abdf', 'e', 'jkl'])
|
||||
set([u'a', u'ab', u'abd', u'j', u'jk'])
|
||||
"""
|
||||
return {seq[:i] for seq in sequences for i in range(1, len(seq))}
|
||||
|
||||
|
||||
def resolve_sequence(text, mapper, codes):
|
||||
r"""
|
||||
Return a single :class:`Keystroke` instance for given sequence ``text``.
|
||||
|
||||
:arg str text: string of characters received from terminal input stream.
|
||||
:arg OrderedDict mapper: unicode multibyte sequences, such as ``u'\x1b[D'``
|
||||
paired by their integer value (260)
|
||||
:arg dict codes: a :type:`dict` of integer values (such as 260) paired
|
||||
by their mnemonic name, such as ``'KEY_LEFT'``.
|
||||
:rtype: Keystroke
|
||||
:returns: Keystroke instance for the given sequence
|
||||
|
||||
The given ``text`` may extend beyond a matching sequence, such as
|
||||
``u\x1b[Dxxx`` returns a :class:`Keystroke` instance of attribute
|
||||
:attr:`Keystroke.sequence` valued only ``u\x1b[D``. It is up to
|
||||
calls to determine that ``xxx`` remains unresolved.
|
||||
"""
|
||||
for sequence, code in mapper.items():
|
||||
if text.startswith(sequence):
|
||||
return Keystroke(ucs=sequence, code=code, name=codes[code])
|
||||
return Keystroke(ucs=text and text[0] or u'')
|
||||
|
||||
|
||||
def _time_left(stime, timeout):
|
||||
"""
|
||||
Return time remaining since ``stime`` before given ``timeout``.
|
||||
|
||||
This function assists determining the value of ``timeout`` for
|
||||
class method :meth:`~.Terminal.kbhit` and similar functions.
|
||||
|
||||
:arg float stime: starting time for measurement
|
||||
:arg float timeout: timeout period, may be set to None to
|
||||
indicate no timeout (where None is always returned).
|
||||
:rtype: float or int
|
||||
:returns: time remaining as float. If no time is remaining,
|
||||
then the integer ``0`` is returned.
|
||||
"""
|
||||
return max(0, timeout - (time.time() - stime)) if timeout else timeout
|
||||
|
||||
|
||||
def _read_until(term, pattern, timeout):
|
||||
"""
|
||||
Convenience read-until-pattern function, supporting :meth:`~.get_location`.
|
||||
|
||||
:arg blessed.Terminal term: :class:`~.Terminal` instance.
|
||||
:arg float timeout: timeout period, may be set to None to indicate no
|
||||
timeout (where 0 is always returned).
|
||||
:arg str pattern: target regular expression pattern to seek.
|
||||
:rtype: tuple
|
||||
:returns: tuple in form of ``(match, str)``, *match*
|
||||
may be :class:`re.MatchObject` if pattern is discovered
|
||||
in input stream before timeout has elapsed, otherwise
|
||||
None. ``str`` is any remaining text received exclusive
|
||||
of the matching pattern).
|
||||
|
||||
The reason a tuple containing non-matching data is returned, is that the
|
||||
consumer should push such data back into the input buffer by
|
||||
:meth:`~.Terminal.ungetch` if any was received.
|
||||
|
||||
For example, when a user is performing rapid input keystrokes while its
|
||||
terminal emulator surreptitiously responds to this in-band sequence, we
|
||||
must ensure any such keyboard data is well-received by the next call to
|
||||
term.inkey() without delay.
|
||||
"""
|
||||
stime = time.time()
|
||||
match, buf = None, u''
|
||||
|
||||
# first, buffer all pending data. pexpect library provides a
|
||||
# 'searchwindowsize' attribute that limits this memory region. We're not
|
||||
# concerned about OOM conditions: only (human) keyboard input and terminal
|
||||
# response sequences are expected.
|
||||
|
||||
while True: # pragma: no branch
|
||||
# block as long as necessary to ensure at least one character is
|
||||
# received on input or remaining timeout has elapsed.
|
||||
ucs = term.inkey(timeout=_time_left(stime, timeout))
|
||||
# while the keyboard buffer is "hot" (has input), we continue to
|
||||
# aggregate all awaiting data. We do this to ensure slow I/O
|
||||
# calls do not unnecessarily give up within the first 'while' loop
|
||||
# for short timeout periods.
|
||||
while ucs:
|
||||
buf += ucs
|
||||
ucs = term.inkey(timeout=0)
|
||||
|
||||
match = re.search(pattern=pattern, string=buf)
|
||||
if match is not None:
|
||||
# match
|
||||
break
|
||||
|
||||
if timeout is not None and not _time_left(stime, timeout):
|
||||
# timeout
|
||||
break
|
||||
|
||||
return match, buf
|
||||
|
||||
|
||||
#: Though we may determine *keynames* and codes for keyboard input that
|
||||
#: generate multibyte sequences, it is also especially useful to aliases
|
||||
#: a few basic ASCII characters such as ``KEY_TAB`` instead of ``u'\t'`` for
|
||||
#: uniformity.
|
||||
#:
|
||||
#: Furthermore, many key-names for application keys enabled only by context
|
||||
#: manager :meth:`~.Terminal.keypad` are surprisingly absent. We inject them
|
||||
#: here directly into the curses module.
|
||||
_CURSES_KEYCODE_ADDINS = (
|
||||
'TAB',
|
||||
'KP_MULTIPLY',
|
||||
'KP_ADD',
|
||||
'KP_SEPARATOR',
|
||||
'KP_SUBTRACT',
|
||||
'KP_DECIMAL',
|
||||
'KP_DIVIDE',
|
||||
'KP_EQUAL',
|
||||
'KP_0',
|
||||
'KP_1',
|
||||
'KP_2',
|
||||
'KP_3',
|
||||
'KP_4',
|
||||
'KP_5',
|
||||
'KP_6',
|
||||
'KP_7',
|
||||
'KP_8',
|
||||
'KP_9')
|
||||
|
||||
_LASTVAL = max(get_curses_keycodes().values())
|
||||
for keycode_name in _CURSES_KEYCODE_ADDINS:
|
||||
_LASTVAL += 1
|
||||
globals()['KEY_' + keycode_name] = _LASTVAL
|
||||
|
||||
#: In a perfect world, terminal emulators would always send exactly what
|
||||
#: the terminfo(5) capability database plans for them, accordingly by the
|
||||
#: value of the ``TERM`` name they declare.
|
||||
#:
|
||||
#: But this isn't a perfect world. Many vt220-derived terminals, such as
|
||||
#: those declaring 'xterm', will continue to send vt220 codes instead of
|
||||
#: their native-declared codes, for backwards-compatibility.
|
||||
#:
|
||||
#: This goes for many: rxvt, putty, iTerm.
|
||||
#:
|
||||
#: These "mixins" are used for *all* terminals, regardless of their type.
|
||||
#:
|
||||
#: Furthermore, curses does not provide sequences sent by the keypad,
|
||||
#: at least, it does not provide a way to distinguish between keypad 0
|
||||
#: and numeric 0.
|
||||
DEFAULT_SEQUENCE_MIXIN = (
|
||||
# these common control characters (and 127, ctrl+'?') mapped to
|
||||
# an application key definition.
|
||||
(six.unichr(10), curses.KEY_ENTER),
|
||||
(six.unichr(13), curses.KEY_ENTER),
|
||||
(six.unichr(8), curses.KEY_BACKSPACE),
|
||||
(six.unichr(9), KEY_TAB), # noqa # pylint: disable=undefined-variable
|
||||
(six.unichr(27), curses.KEY_EXIT),
|
||||
(six.unichr(127), curses.KEY_BACKSPACE),
|
||||
|
||||
(u"\x1b[A", curses.KEY_UP),
|
||||
(u"\x1b[B", curses.KEY_DOWN),
|
||||
(u"\x1b[C", curses.KEY_RIGHT),
|
||||
(u"\x1b[D", curses.KEY_LEFT),
|
||||
(u"\x1b[1;2A", curses.KEY_SR),
|
||||
(u"\x1b[1;2B", curses.KEY_SF),
|
||||
(u"\x1b[1;2C", curses.KEY_SRIGHT),
|
||||
(u"\x1b[1;2D", curses.KEY_SLEFT),
|
||||
(u"\x1b[F", curses.KEY_END),
|
||||
(u"\x1b[H", curses.KEY_HOME),
|
||||
# not sure where these are from .. please report
|
||||
(u"\x1b[K", curses.KEY_END),
|
||||
(u"\x1b[U", curses.KEY_NPAGE),
|
||||
(u"\x1b[V", curses.KEY_PPAGE),
|
||||
|
||||
# keys sent after term.smkx (keypad_xmit) is emitted, source:
|
||||
# http://www.xfree86.org/current/ctlseqs.html#PC-Style%20Function%20Keys
|
||||
# http://fossies.org/linux/rxvt/doc/rxvtRef.html#KeyCodes
|
||||
#
|
||||
# keypad, numlock on
|
||||
(u"\x1bOM", curses.KEY_ENTER), # noqa return
|
||||
(u"\x1bOj", KEY_KP_MULTIPLY), # noqa * # pylint: disable=undefined-variable
|
||||
(u"\x1bOk", KEY_KP_ADD), # noqa + # pylint: disable=undefined-variable
|
||||
(u"\x1bOl", KEY_KP_SEPARATOR), # noqa , # pylint: disable=undefined-variable
|
||||
(u"\x1bOm", KEY_KP_SUBTRACT), # noqa - # pylint: disable=undefined-variable
|
||||
(u"\x1bOn", KEY_KP_DECIMAL), # noqa . # pylint: disable=undefined-variable
|
||||
(u"\x1bOo", KEY_KP_DIVIDE), # noqa / # pylint: disable=undefined-variable
|
||||
(u"\x1bOX", KEY_KP_EQUAL), # noqa = # pylint: disable=undefined-variable
|
||||
(u"\x1bOp", KEY_KP_0), # noqa 0 # pylint: disable=undefined-variable
|
||||
(u"\x1bOq", KEY_KP_1), # noqa 1 # pylint: disable=undefined-variable
|
||||
(u"\x1bOr", KEY_KP_2), # noqa 2 # pylint: disable=undefined-variable
|
||||
(u"\x1bOs", KEY_KP_3), # noqa 3 # pylint: disable=undefined-variable
|
||||
(u"\x1bOt", KEY_KP_4), # noqa 4 # pylint: disable=undefined-variable
|
||||
(u"\x1bOu", KEY_KP_5), # noqa 5 # pylint: disable=undefined-variable
|
||||
(u"\x1bOv", KEY_KP_6), # noqa 6 # pylint: disable=undefined-variable
|
||||
(u"\x1bOw", KEY_KP_7), # noqa 7 # pylint: disable=undefined-variable
|
||||
(u"\x1bOx", KEY_KP_8), # noqa 8 # pylint: disable=undefined-variable
|
||||
(u"\x1bOy", KEY_KP_9), # noqa 9 # pylint: disable=undefined-variable
|
||||
|
||||
# keypad, numlock off
|
||||
(u"\x1b[1~", curses.KEY_FIND), # find
|
||||
(u"\x1b[2~", curses.KEY_IC), # insert (0)
|
||||
(u"\x1b[3~", curses.KEY_DC), # delete (.), "Execute"
|
||||
(u"\x1b[4~", curses.KEY_SELECT), # select
|
||||
(u"\x1b[5~", curses.KEY_PPAGE), # pgup (9)
|
||||
(u"\x1b[6~", curses.KEY_NPAGE), # pgdown (3)
|
||||
(u"\x1b[7~", curses.KEY_HOME), # home
|
||||
(u"\x1b[8~", curses.KEY_END), # end
|
||||
(u"\x1b[OA", curses.KEY_UP), # up (8)
|
||||
(u"\x1b[OB", curses.KEY_DOWN), # down (2)
|
||||
(u"\x1b[OC", curses.KEY_RIGHT), # right (6)
|
||||
(u"\x1b[OD", curses.KEY_LEFT), # left (4)
|
||||
(u"\x1b[OF", curses.KEY_END), # end (1)
|
||||
(u"\x1b[OH", curses.KEY_HOME), # home (7)
|
||||
|
||||
# The vt220 placed F1-F4 above the keypad, in place of actual
|
||||
# F1-F4 were local functions (hold screen, print screen,
|
||||
# set up, data/talk, break).
|
||||
(u"\x1bOP", curses.KEY_F1),
|
||||
(u"\x1bOQ", curses.KEY_F2),
|
||||
(u"\x1bOR", curses.KEY_F3),
|
||||
(u"\x1bOS", curses.KEY_F4),
|
||||
)
|
||||
|
||||
#: Override mixins for a few curses constants with easier
|
||||
#: mnemonics: there may only be a 1:1 mapping when only a
|
||||
#: keycode (int) is given, where these phrases are preferred.
|
||||
CURSES_KEYCODE_OVERRIDE_MIXIN = (
|
||||
('KEY_DELETE', curses.KEY_DC),
|
||||
('KEY_INSERT', curses.KEY_IC),
|
||||
('KEY_PGUP', curses.KEY_PPAGE),
|
||||
('KEY_PGDOWN', curses.KEY_NPAGE),
|
||||
('KEY_ESCAPE', curses.KEY_EXIT),
|
||||
('KEY_SUP', curses.KEY_SR),
|
||||
('KEY_SDOWN', curses.KEY_SF),
|
||||
('KEY_UP_LEFT', curses.KEY_A1),
|
||||
('KEY_UP_RIGHT', curses.KEY_A3),
|
||||
('KEY_CENTER', curses.KEY_B2),
|
||||
('KEY_BEGIN', curses.KEY_BEG),
|
||||
)
|
||||
|
||||
__all__ = ('Keystroke', 'get_keyboard_codes', 'get_keyboard_sequences',)
|
||||
28
venv/lib/python3.11/site-packages/blessed/keyboard.pyi
Normal file
28
venv/lib/python3.11/site-packages/blessed/keyboard.pyi
Normal file
@@ -0,0 +1,28 @@
|
||||
# std imports
|
||||
from typing import Set, Dict, Type, Mapping, TypeVar, Iterable, Optional, OrderedDict
|
||||
|
||||
# local
|
||||
from .terminal import Terminal
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class Keystroke(str):
|
||||
def __new__(
|
||||
cls: Type[_T],
|
||||
ucs: str = ...,
|
||||
code: Optional[int] = ...,
|
||||
name: Optional[str] = ...,
|
||||
) -> _T: ...
|
||||
@property
|
||||
def is_sequence(self) -> bool: ...
|
||||
@property
|
||||
def name(self) -> Optional[str]: ...
|
||||
@property
|
||||
def code(self) -> Optional[int]: ...
|
||||
|
||||
def get_keyboard_codes() -> Dict[int, str]: ...
|
||||
def get_keyboard_sequences(term: Terminal) -> OrderedDict[str, int]: ...
|
||||
def get_leading_prefixes(sequences: Iterable[str]) -> Set[str]: ...
|
||||
def resolve_sequence(
|
||||
text: str, mapper: Mapping[str, int], codes: Mapping[int, str]
|
||||
) -> Keystroke: ...
|
||||
0
venv/lib/python3.11/site-packages/blessed/py.typed
Normal file
0
venv/lib/python3.11/site-packages/blessed/py.typed
Normal file
461
venv/lib/python3.11/site-packages/blessed/sequences.py
Normal file
461
venv/lib/python3.11/site-packages/blessed/sequences.py
Normal file
@@ -0,0 +1,461 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Module providing 'sequence awareness'."""
|
||||
# std imports
|
||||
import re
|
||||
import math
|
||||
import textwrap
|
||||
|
||||
# 3rd party
|
||||
import six
|
||||
from wcwidth import wcwidth
|
||||
|
||||
# local
|
||||
from blessed._capabilities import CAPABILITIES_CAUSE_MOVEMENT
|
||||
|
||||
__all__ = ('Sequence', 'SequenceTextWrapper', 'iter_parse', 'measure_length')
|
||||
|
||||
|
||||
class Termcap(object):
|
||||
"""Terminal capability of given variable name and pattern."""
|
||||
|
||||
def __init__(self, name, pattern, attribute):
|
||||
"""
|
||||
Class initializer.
|
||||
|
||||
:arg str name: name describing capability.
|
||||
:arg str pattern: regular expression string.
|
||||
:arg str attribute: :class:`~.Terminal` attribute used to build
|
||||
this terminal capability.
|
||||
"""
|
||||
self.name = name
|
||||
self.pattern = pattern
|
||||
self.attribute = attribute
|
||||
self._re_compiled = None
|
||||
|
||||
def __repr__(self):
|
||||
# pylint: disable=redundant-keyword-arg
|
||||
return '<Termcap {self.name}:{self.pattern!r}>'.format(self=self)
|
||||
|
||||
@property
|
||||
def named_pattern(self):
|
||||
"""Regular expression pattern for capability with named group."""
|
||||
# pylint: disable=redundant-keyword-arg
|
||||
return '(?P<{self.name}>{self.pattern})'.format(self=self)
|
||||
|
||||
@property
|
||||
def re_compiled(self):
|
||||
"""Compiled regular expression pattern for capability."""
|
||||
if self._re_compiled is None:
|
||||
self._re_compiled = re.compile(self.pattern)
|
||||
return self._re_compiled
|
||||
|
||||
@property
|
||||
def will_move(self):
|
||||
"""Whether capability causes cursor movement."""
|
||||
return self.name in CAPABILITIES_CAUSE_MOVEMENT
|
||||
|
||||
def horizontal_distance(self, text):
|
||||
"""
|
||||
Horizontal carriage adjusted by capability, may be negative.
|
||||
|
||||
:rtype: int
|
||||
:arg str text: for capabilities *parm_left_cursor*,
|
||||
*parm_right_cursor*, provide the matching sequence
|
||||
text, its interpreted distance is returned.
|
||||
|
||||
:returns: 0 except for matching '
|
||||
"""
|
||||
value = {
|
||||
'cursor_left': -1,
|
||||
'backspace': -1,
|
||||
'cursor_right': 1,
|
||||
'tab': 8,
|
||||
'ascii_tab': 8,
|
||||
}.get(self.name)
|
||||
if value is not None:
|
||||
return value
|
||||
|
||||
unit = {
|
||||
'parm_left_cursor': -1,
|
||||
'parm_right_cursor': 1
|
||||
}.get(self.name)
|
||||
if unit is not None:
|
||||
value = int(self.re_compiled.match(text).group(1))
|
||||
return unit * value
|
||||
|
||||
return 0
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
@classmethod
|
||||
def build(cls, name, capability, attribute, nparams=0,
|
||||
numeric=99, match_grouped=False, match_any=False,
|
||||
match_optional=False):
|
||||
r"""
|
||||
Class factory builder for given capability definition.
|
||||
|
||||
:arg str name: Variable name given for this pattern.
|
||||
:arg str capability: A unicode string representing a terminal
|
||||
capability to build for. When ``nparams`` is non-zero, it
|
||||
must be a callable unicode string (such as the result from
|
||||
``getattr(term, 'bold')``.
|
||||
:arg str attribute: The terminfo(5) capability name by which this
|
||||
pattern is known.
|
||||
:arg int nparams: number of positional arguments for callable.
|
||||
:arg int numeric: Value to substitute into capability to when generating pattern
|
||||
:arg bool match_grouped: If the numeric pattern should be
|
||||
grouped, ``(\d+)`` when ``True``, ``\d+`` default.
|
||||
:arg bool match_any: When keyword argument ``nparams`` is given,
|
||||
*any* numeric found in output is suitable for building as
|
||||
pattern ``(\d+)``. Otherwise, only the first matching value of
|
||||
range *(numeric - 1)* through *(numeric + 1)* will be replaced by
|
||||
pattern ``(\d+)`` in builder.
|
||||
:arg bool match_optional: When ``True``, building of numeric patterns
|
||||
containing ``(\d+)`` will be built as optional, ``(\d+)?``.
|
||||
:rtype: blessed.sequences.Termcap
|
||||
:returns: Terminal capability instance for given capability definition
|
||||
"""
|
||||
_numeric_regex = r'\d+'
|
||||
if match_grouped:
|
||||
_numeric_regex = r'(\d+)'
|
||||
if match_optional:
|
||||
_numeric_regex = r'(\d+)?'
|
||||
numeric = 99 if numeric is None else numeric
|
||||
|
||||
# basic capability attribute, not used as a callable
|
||||
if nparams == 0:
|
||||
return cls(name, re.escape(capability), attribute)
|
||||
|
||||
# a callable capability accepting numeric argument
|
||||
_outp = re.escape(capability(*(numeric,) * nparams))
|
||||
if not match_any:
|
||||
for num in range(numeric - 1, numeric + 2):
|
||||
if str(num) in _outp:
|
||||
pattern = _outp.replace(str(num), _numeric_regex)
|
||||
return cls(name, pattern, attribute)
|
||||
|
||||
if match_grouped:
|
||||
pattern = re.sub(r'(\d+)', lambda x: _numeric_regex, _outp)
|
||||
else:
|
||||
pattern = re.sub(r'\d+', lambda x: _numeric_regex, _outp)
|
||||
return cls(name, pattern, attribute)
|
||||
|
||||
|
||||
class SequenceTextWrapper(textwrap.TextWrapper):
|
||||
"""Docstring overridden."""
|
||||
|
||||
def __init__(self, width, term, **kwargs):
|
||||
"""
|
||||
Class initializer.
|
||||
|
||||
This class supports the :meth:`~.Terminal.wrap` method.
|
||||
"""
|
||||
self.term = term
|
||||
textwrap.TextWrapper.__init__(self, width, **kwargs)
|
||||
|
||||
def _wrap_chunks(self, chunks):
|
||||
"""
|
||||
Sequence-aware variant of :meth:`textwrap.TextWrapper._wrap_chunks`.
|
||||
|
||||
:raises ValueError: ``self.width`` is not a positive integer
|
||||
:rtype: list
|
||||
:returns: text chunks adjusted for width
|
||||
|
||||
This simply ensures that word boundaries are not broken mid-sequence, as standard python
|
||||
textwrap would incorrectly determine the length of a string containing sequences, and may
|
||||
also break consider sequences part of a "word" that may be broken by hyphen (``-``), where
|
||||
this implementation corrects both.
|
||||
"""
|
||||
lines = []
|
||||
if self.width <= 0 or not isinstance(self.width, int):
|
||||
raise ValueError(
|
||||
"invalid width {0!r}({1!r}) (must be integer > 0)"
|
||||
.format(self.width, type(self.width)))
|
||||
|
||||
term = self.term
|
||||
drop_whitespace = not hasattr(self, 'drop_whitespace'
|
||||
) or self.drop_whitespace
|
||||
chunks.reverse()
|
||||
while chunks:
|
||||
cur_line = []
|
||||
cur_len = 0
|
||||
indent = self.subsequent_indent if lines else self.initial_indent
|
||||
width = self.width - len(indent)
|
||||
if drop_whitespace and (
|
||||
Sequence(chunks[-1], term).strip() == '' and lines):
|
||||
del chunks[-1]
|
||||
while chunks:
|
||||
chunk_len = Sequence(chunks[-1], term).length()
|
||||
if cur_len + chunk_len > width:
|
||||
break
|
||||
cur_line.append(chunks.pop())
|
||||
cur_len += chunk_len
|
||||
if chunks and Sequence(chunks[-1], term).length() > width:
|
||||
self._handle_long_word(chunks, cur_line, cur_len, width)
|
||||
if drop_whitespace and (
|
||||
cur_line and Sequence(cur_line[-1], term).strip() == ''):
|
||||
del cur_line[-1]
|
||||
if cur_line:
|
||||
lines.append(indent + u''.join(cur_line))
|
||||
return lines
|
||||
|
||||
def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
|
||||
"""
|
||||
Sequence-aware :meth:`textwrap.TextWrapper._handle_long_word`.
|
||||
|
||||
This simply ensures that word boundaries are not broken mid-sequence, as standard python
|
||||
textwrap would incorrectly determine the length of a string containing sequences, and may
|
||||
also break consider sequences part of a "word" that may be broken by hyphen (``-``), where
|
||||
this implementation corrects both.
|
||||
"""
|
||||
# Figure out when indent is larger than the specified width, and make
|
||||
# sure at least one character is stripped off on every pass
|
||||
space_left = 1 if width < 1 else width - cur_len
|
||||
# If we're allowed to break long words, then do so: put as much
|
||||
# of the next chunk onto the current line as will fit.
|
||||
|
||||
if self.break_long_words:
|
||||
term = self.term
|
||||
chunk = reversed_chunks[-1]
|
||||
idx = nxt = 0
|
||||
for text, _ in iter_parse(term, chunk):
|
||||
nxt += len(text)
|
||||
if Sequence(chunk[:nxt], term).length() > space_left:
|
||||
break
|
||||
idx = nxt
|
||||
cur_line.append(chunk[:idx])
|
||||
reversed_chunks[-1] = chunk[idx:]
|
||||
|
||||
# Otherwise, we have to preserve the long word intact. Only add
|
||||
# it to the current line if there's nothing already there --
|
||||
# that minimizes how much we violate the width constraint.
|
||||
elif not cur_line:
|
||||
cur_line.append(reversed_chunks.pop())
|
||||
|
||||
# If we're not allowed to break long words, and there's already
|
||||
# text on the current line, do nothing. Next time through the
|
||||
# main loop of _wrap_chunks(), we'll wind up here again, but
|
||||
# cur_len will be zero, so the next line will be entirely
|
||||
# devoted to the long word that we can't handle right now.
|
||||
|
||||
|
||||
SequenceTextWrapper.__doc__ = textwrap.TextWrapper.__doc__
|
||||
|
||||
|
||||
class Sequence(six.text_type):
|
||||
"""
|
||||
A "sequence-aware" version of the base :class:`str` class.
|
||||
|
||||
This unicode-derived class understands the effect of escape sequences
|
||||
of printable length, allowing a properly implemented :meth:`rjust`,
|
||||
:meth:`ljust`, :meth:`center`, and :meth:`length`.
|
||||
"""
|
||||
|
||||
def __new__(cls, sequence_text, term):
|
||||
# pylint: disable = missing-return-doc, missing-return-type-doc
|
||||
"""
|
||||
Class constructor.
|
||||
|
||||
:arg str sequence_text: A string that may contain sequences.
|
||||
:arg blessed.Terminal term: :class:`~.Terminal` instance.
|
||||
"""
|
||||
new = six.text_type.__new__(cls, sequence_text)
|
||||
new._term = term
|
||||
return new
|
||||
|
||||
def ljust(self, width, fillchar=u' '):
|
||||
"""
|
||||
Return string containing sequences, left-adjusted.
|
||||
|
||||
:arg int width: Total width given to left-adjust ``text``. If
|
||||
unspecified, the width of the attached terminal is used (default).
|
||||
:arg str fillchar: String for padding right-of ``text``.
|
||||
:returns: String of ``text``, left-aligned by ``width``.
|
||||
:rtype: str
|
||||
"""
|
||||
rightside = fillchar * int(
|
||||
(max(0.0, float(width.__index__() - self.length()))) / float(len(fillchar)))
|
||||
return u''.join((self, rightside))
|
||||
|
||||
def rjust(self, width, fillchar=u' '):
|
||||
"""
|
||||
Return string containing sequences, right-adjusted.
|
||||
|
||||
:arg int width: Total width given to right-adjust ``text``. If
|
||||
unspecified, the width of the attached terminal is used (default).
|
||||
:arg str fillchar: String for padding left-of ``text``.
|
||||
:returns: String of ``text``, right-aligned by ``width``.
|
||||
:rtype: str
|
||||
"""
|
||||
leftside = fillchar * int(
|
||||
(max(0.0, float(width.__index__() - self.length()))) / float(len(fillchar)))
|
||||
return u''.join((leftside, self))
|
||||
|
||||
def center(self, width, fillchar=u' '):
|
||||
"""
|
||||
Return string containing sequences, centered.
|
||||
|
||||
:arg int width: Total width given to center ``text``. If
|
||||
unspecified, the width of the attached terminal is used (default).
|
||||
:arg str fillchar: String for padding left and right-of ``text``.
|
||||
:returns: String of ``text``, centered by ``width``.
|
||||
:rtype: str
|
||||
"""
|
||||
split = max(0.0, float(width.__index__()) - self.length()) / 2
|
||||
leftside = fillchar * int(
|
||||
(max(0.0, math.floor(split))) / float(len(fillchar)))
|
||||
rightside = fillchar * int(
|
||||
(max(0.0, math.ceil(split))) / float(len(fillchar)))
|
||||
return u''.join((leftside, self, rightside))
|
||||
|
||||
def truncate(self, width):
|
||||
"""
|
||||
Truncate a string in a sequence-aware manner.
|
||||
|
||||
Any printable characters beyond ``width`` are removed, while all
|
||||
sequences remain in place. Horizontal Sequences are first expanded
|
||||
by :meth:`padd`.
|
||||
|
||||
:arg int width: The printable width to truncate the string to.
|
||||
:rtype: str
|
||||
:returns: String truncated to at most ``width`` printable characters.
|
||||
"""
|
||||
output = ""
|
||||
current_width = 0
|
||||
target_width = width.__index__()
|
||||
parsed_seq = iter_parse(self._term, self.padd())
|
||||
|
||||
# Retain all text until non-cap width reaches desired width
|
||||
for text, cap in parsed_seq:
|
||||
if not cap:
|
||||
# use wcwidth clipped to 0 because it can sometimes return -1
|
||||
current_width += max(wcwidth(text), 0)
|
||||
if current_width > target_width:
|
||||
break
|
||||
output += text
|
||||
|
||||
# Return with remaining caps appended
|
||||
return output + ''.join(text for text, cap in parsed_seq if cap)
|
||||
|
||||
def length(self):
|
||||
r"""
|
||||
Return the printable length of string containing sequences.
|
||||
|
||||
Strings containing ``term.left`` or ``\b`` will cause "overstrike",
|
||||
but a length less than 0 is not ever returned. So ``_\b+`` is a
|
||||
length of 1 (displays as ``+``), but ``\b`` alone is simply a
|
||||
length of 0.
|
||||
|
||||
Some characters may consume more than one cell, mainly those CJK
|
||||
Unified Ideographs (Chinese, Japanese, Korean) defined by Unicode
|
||||
as half or full-width characters.
|
||||
|
||||
For example:
|
||||
|
||||
>>> from blessed import Terminal
|
||||
>>> from blessed.sequences import Sequence
|
||||
>>> term = Terminal()
|
||||
>>> msg = term.clear + term.red(u'コンニチハ')
|
||||
>>> Sequence(msg, term).length()
|
||||
10
|
||||
|
||||
.. note:: Although accounted for, strings containing sequences such
|
||||
as ``term.clear`` will not give accurate returns, it is not
|
||||
considered lengthy (a length of 0).
|
||||
"""
|
||||
# because control characters may return -1, "clip" their length to 0.
|
||||
return sum(max(wcwidth(w_char), 0) for w_char in self.padd(strip=True))
|
||||
|
||||
def strip(self, chars=None):
|
||||
"""
|
||||
Return string of sequences, leading and trailing whitespace removed.
|
||||
|
||||
:arg str chars: Remove characters in chars instead of whitespace.
|
||||
:rtype: str
|
||||
:returns: string of sequences with leading and trailing whitespace removed.
|
||||
"""
|
||||
return self.strip_seqs().strip(chars)
|
||||
|
||||
def lstrip(self, chars=None):
|
||||
"""
|
||||
Return string of all sequences and leading whitespace removed.
|
||||
|
||||
:arg str chars: Remove characters in chars instead of whitespace.
|
||||
:rtype: str
|
||||
:returns: string of sequences with leading removed.
|
||||
"""
|
||||
return self.strip_seqs().lstrip(chars)
|
||||
|
||||
def rstrip(self, chars=None):
|
||||
"""
|
||||
Return string of all sequences and trailing whitespace removed.
|
||||
|
||||
:arg str chars: Remove characters in chars instead of whitespace.
|
||||
:rtype: str
|
||||
:returns: string of sequences with trailing removed.
|
||||
"""
|
||||
return self.strip_seqs().rstrip(chars)
|
||||
|
||||
def strip_seqs(self):
|
||||
"""
|
||||
Return ``text`` stripped of only its terminal sequences.
|
||||
|
||||
:rtype: str
|
||||
:returns: Text with terminal sequences removed
|
||||
"""
|
||||
return self.padd(strip=True)
|
||||
|
||||
def padd(self, strip=False):
|
||||
"""
|
||||
Return non-destructive horizontal movement as destructive spacing.
|
||||
|
||||
:arg bool strip: Strip terminal sequences
|
||||
:rtype: str
|
||||
:returns: Text adjusted for horizontal movement
|
||||
"""
|
||||
outp = ''
|
||||
for text, cap in iter_parse(self._term, self):
|
||||
if not cap:
|
||||
outp += text
|
||||
continue
|
||||
|
||||
value = cap.horizontal_distance(text)
|
||||
if value > 0:
|
||||
outp += ' ' * value
|
||||
elif value < 0:
|
||||
outp = outp[:value]
|
||||
elif not strip:
|
||||
outp += text
|
||||
return outp
|
||||
|
||||
|
||||
def iter_parse(term, text):
|
||||
"""
|
||||
Generator yields (text, capability) for characters of ``text``.
|
||||
|
||||
value for ``capability`` may be ``None``, where ``text`` is
|
||||
:class:`str` of length 1. Otherwise, ``text`` is a full
|
||||
matching sequence of given capability.
|
||||
"""
|
||||
for match in term._caps_compiled_any.finditer(text): # pylint: disable=protected-access
|
||||
name = match.lastgroup
|
||||
value = match.group(name)
|
||||
if name == 'MISMATCH':
|
||||
yield (value, None)
|
||||
else:
|
||||
yield value, term.caps[name]
|
||||
|
||||
|
||||
def measure_length(text, term):
|
||||
"""
|
||||
.. deprecated:: 1.12.0.
|
||||
|
||||
:rtype: int
|
||||
:returns: Length of the first sequence in the string
|
||||
"""
|
||||
try:
|
||||
text, capability = next(iter_parse(term, text))
|
||||
if capability:
|
||||
return len(text)
|
||||
except StopIteration:
|
||||
return 0
|
||||
return 0
|
||||
55
venv/lib/python3.11/site-packages/blessed/sequences.pyi
Normal file
55
venv/lib/python3.11/site-packages/blessed/sequences.pyi
Normal file
@@ -0,0 +1,55 @@
|
||||
# std imports
|
||||
import textwrap
|
||||
from typing import Any, Type, Tuple, Pattern, TypeVar, Iterator, Optional, SupportsIndex
|
||||
|
||||
# local
|
||||
from .terminal import Terminal
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class Termcap:
|
||||
name: str = ...
|
||||
pattern: str = ...
|
||||
attribute: str = ...
|
||||
def __init__(self, name: str, pattern: str, attribute: str) -> None: ...
|
||||
@property
|
||||
def named_pattern(self) -> str: ...
|
||||
@property
|
||||
def re_compiled(self) -> Pattern[str]: ...
|
||||
@property
|
||||
def will_move(self) -> bool: ...
|
||||
def horizontal_distance(self, text: str) -> int: ...
|
||||
@classmethod
|
||||
def build(
|
||||
cls,
|
||||
name: str,
|
||||
capability: str,
|
||||
attribute: str,
|
||||
nparams: int = ...,
|
||||
numeric: int = ...,
|
||||
match_grouped: bool = ...,
|
||||
match_any: bool = ...,
|
||||
match_optional: bool = ...,
|
||||
) -> "Termcap": ...
|
||||
|
||||
class SequenceTextWrapper(textwrap.TextWrapper):
|
||||
term: Terminal = ...
|
||||
def __init__(self, width: int, term: Terminal, **kwargs: Any) -> None: ...
|
||||
|
||||
class Sequence(str):
|
||||
def __new__(cls: Type[_T], sequence_text: str, term: Terminal) -> _T: ...
|
||||
def ljust(self, width: SupportsIndex, fillchar: str = ...) -> str: ...
|
||||
def rjust(self, width: SupportsIndex, fillchar: str = ...) -> str: ...
|
||||
def center(self, width: SupportsIndex, fillchar: str = ...) -> str: ...
|
||||
def truncate(self, width: SupportsIndex) -> str: ...
|
||||
def length(self) -> int: ...
|
||||
def strip(self, chars: Optional[str] = ...) -> str: ...
|
||||
def lstrip(self, chars: Optional[str] = ...) -> str: ...
|
||||
def rstrip(self, chars: Optional[str] = ...) -> str: ...
|
||||
def strip_seqs(self) -> str: ...
|
||||
def padd(self, strip: bool = ...) -> str: ...
|
||||
|
||||
def iter_parse(
|
||||
term: Terminal, text: str
|
||||
) -> Iterator[Tuple[str, Optional[Termcap]]]: ...
|
||||
def measure_length(text: str, term: Terminal) -> int: ...
|
||||
1552
venv/lib/python3.11/site-packages/blessed/terminal.py
Normal file
1552
venv/lib/python3.11/site-packages/blessed/terminal.py
Normal file
File diff suppressed because it is too large
Load Diff
108
venv/lib/python3.11/site-packages/blessed/terminal.pyi
Normal file
108
venv/lib/python3.11/site-packages/blessed/terminal.pyi
Normal file
@@ -0,0 +1,108 @@
|
||||
# std imports
|
||||
from typing import IO, Any, List, Tuple, Union, Optional, OrderedDict, SupportsIndex, ContextManager
|
||||
|
||||
# local
|
||||
from .keyboard import Keystroke
|
||||
from .sequences import Termcap
|
||||
from .formatters import (FormattingString,
|
||||
NullCallableString,
|
||||
ParameterizingString,
|
||||
FormattingOtherString)
|
||||
|
||||
HAS_TTY: bool
|
||||
|
||||
class Terminal:
|
||||
caps: OrderedDict[str, Termcap]
|
||||
errors: List[str] = ...
|
||||
def __init__(
|
||||
self,
|
||||
kind: Optional[str] = ...,
|
||||
stream: Optional[IO[str]] = ...,
|
||||
force_styling: bool = ...,
|
||||
) -> None: ...
|
||||
def __getattr__(
|
||||
self, attr: str
|
||||
) -> Union[NullCallableString, ParameterizingString, FormattingString]: ...
|
||||
@property
|
||||
def kind(self) -> str: ...
|
||||
@property
|
||||
def does_styling(self) -> bool: ...
|
||||
@property
|
||||
def is_a_tty(self) -> bool: ...
|
||||
@property
|
||||
def height(self) -> int: ...
|
||||
@property
|
||||
def width(self) -> int: ...
|
||||
@property
|
||||
def pixel_height(self) -> int: ...
|
||||
@property
|
||||
def pixel_width(self) -> int: ...
|
||||
def location(
|
||||
self, x: Optional[int] = ..., y: Optional[int] = ...
|
||||
) -> ContextManager[None]: ...
|
||||
def get_location(self, timeout: Optional[float] = ...) -> Tuple[int, int]: ...
|
||||
def get_fgcolor(self, timeout: Optional[float] = ...) -> Tuple[int, int, int]: ...
|
||||
def get_bgcolor(self, timeout: Optional[float] = ...) -> Tuple[int, int, int]: ...
|
||||
def fullscreen(self) -> ContextManager[None]: ...
|
||||
def hidden_cursor(self) -> ContextManager[None]: ...
|
||||
def move_xy(self, x: int, y: int) -> ParameterizingString: ...
|
||||
def move_yx(self, y: int, x: int) -> ParameterizingString: ...
|
||||
@property
|
||||
def move_left(self) -> FormattingOtherString: ...
|
||||
@property
|
||||
def move_right(self) -> FormattingOtherString: ...
|
||||
@property
|
||||
def move_up(self) -> FormattingOtherString: ...
|
||||
@property
|
||||
def move_down(self) -> FormattingOtherString: ...
|
||||
@property
|
||||
def color(self) -> Union[NullCallableString, ParameterizingString]: ...
|
||||
def color_rgb(self, red: int, green: int, blue: int) -> FormattingString: ...
|
||||
@property
|
||||
def on_color(self) -> Union[NullCallableString, ParameterizingString]: ...
|
||||
def on_color_rgb(self, red: int, green: int, blue: int) -> FormattingString: ...
|
||||
def formatter(self, value: str) -> Union[NullCallableString, FormattingString]: ...
|
||||
def rgb_downconvert(self, red: int, green: int, blue: int) -> int: ...
|
||||
@property
|
||||
def normal(self) -> str: ...
|
||||
def link(self, url: str, text: str, url_id: str = ...) -> str: ...
|
||||
@property
|
||||
def stream(self) -> IO[str]: ...
|
||||
@property
|
||||
def number_of_colors(self) -> int: ...
|
||||
@number_of_colors.setter
|
||||
def number_of_colors(self, value: int) -> None: ...
|
||||
@property
|
||||
def color_distance_algorithm(self) -> str: ...
|
||||
@color_distance_algorithm.setter
|
||||
def color_distance_algorithm(self, value: str) -> None: ...
|
||||
def ljust(
|
||||
self, text: str, width: Optional[SupportsIndex] = ..., fillchar: str = ...
|
||||
) -> str: ...
|
||||
def rjust(
|
||||
self, text: str, width: Optional[SupportsIndex] = ..., fillchar: str = ...
|
||||
) -> str: ...
|
||||
def center(
|
||||
self, text: str, width: Optional[SupportsIndex] = ..., fillchar: str = ...
|
||||
) -> str: ...
|
||||
def truncate(self, text: str, width: Optional[SupportsIndex] = ...) -> str: ...
|
||||
def length(self, text: str) -> int: ...
|
||||
def strip(self, text: str, chars: Optional[str] = ...) -> str: ...
|
||||
def rstrip(self, text: str, chars: Optional[str] = ...) -> str: ...
|
||||
def lstrip(self, text: str, chars: Optional[str] = ...) -> str: ...
|
||||
def strip_seqs(self, text: str) -> str: ...
|
||||
def split_seqs(self, text: str, maxsplit: int) -> List[str]: ...
|
||||
def wrap(
|
||||
self, text: str, width: Optional[int] = ..., **kwargs: Any
|
||||
) -> List[str]: ...
|
||||
def getch(self) -> str: ...
|
||||
def ungetch(self, text: str) -> None: ...
|
||||
def kbhit(self, timeout: Optional[float] = ...) -> bool: ...
|
||||
def cbreak(self) -> ContextManager[None]: ...
|
||||
def raw(self) -> ContextManager[None]: ...
|
||||
def keypad(self) -> ContextManager[None]: ...
|
||||
def inkey(
|
||||
self, timeout: Optional[float] = ..., esc_delay: float = ...
|
||||
) -> Keystroke: ...
|
||||
|
||||
class WINSZ: ...
|
||||
163
venv/lib/python3.11/site-packages/blessed/win_terminal.py
Normal file
163
venv/lib/python3.11/site-packages/blessed/win_terminal.py
Normal file
@@ -0,0 +1,163 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Module containing Windows version of :class:`Terminal`."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
# std imports
|
||||
import time
|
||||
import msvcrt # pylint: disable=import-error
|
||||
import contextlib
|
||||
|
||||
# 3rd party
|
||||
from jinxed import win32 # pylint: disable=import-error
|
||||
|
||||
# local
|
||||
from .terminal import WINSZ
|
||||
from .terminal import Terminal as _Terminal
|
||||
|
||||
|
||||
class Terminal(_Terminal):
|
||||
"""Windows subclass of :class:`Terminal`."""
|
||||
|
||||
def getch(self):
|
||||
r"""
|
||||
Read, decode, and return the next byte from the keyboard stream.
|
||||
|
||||
:rtype: unicode
|
||||
:returns: a single unicode character, or ``u''`` if a multi-byte
|
||||
sequence has not yet been fully received.
|
||||
|
||||
For versions of Windows 10.0.10586 and later, the console is expected
|
||||
to be in ENABLE_VIRTUAL_TERMINAL_INPUT mode and the default method is
|
||||
called.
|
||||
|
||||
For older versions of Windows, msvcrt.getwch() is used. If the received
|
||||
character is ``\x00`` or ``\xe0``, the next character is
|
||||
automatically retrieved.
|
||||
"""
|
||||
if win32.VTMODE_SUPPORTED:
|
||||
return super(Terminal, self).getch()
|
||||
|
||||
rtn = msvcrt.getwch()
|
||||
if rtn in ('\x00', '\xe0'):
|
||||
rtn += msvcrt.getwch()
|
||||
return rtn
|
||||
|
||||
def kbhit(self, timeout=None):
|
||||
"""
|
||||
Return whether a keypress has been detected on the keyboard.
|
||||
|
||||
This method is used by :meth:`inkey` to determine if a byte may
|
||||
be read using :meth:`getch` without blocking. This is implemented
|
||||
by wrapping msvcrt.kbhit() in a timeout.
|
||||
|
||||
:arg float timeout: When ``timeout`` is 0, this call is
|
||||
non-blocking, otherwise blocking indefinitely until keypress
|
||||
is detected when None (default). When ``timeout`` is a
|
||||
positive number, returns after ``timeout`` seconds have
|
||||
elapsed (float).
|
||||
:rtype: bool
|
||||
:returns: True if a keypress is awaiting to be read on the keyboard
|
||||
attached to this terminal.
|
||||
"""
|
||||
end = time.time() + (timeout or 0)
|
||||
while True:
|
||||
|
||||
if msvcrt.kbhit():
|
||||
return True
|
||||
|
||||
if timeout is not None and end < time.time():
|
||||
break
|
||||
|
||||
time.sleep(0.01) # Sleep to reduce CPU load
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _winsize(fd):
|
||||
"""
|
||||
Return named tuple describing size of the terminal by ``fd``.
|
||||
|
||||
:arg int fd: file descriptor queries for its window size.
|
||||
:rtype: WINSZ
|
||||
:returns: named tuple describing size of the terminal
|
||||
|
||||
WINSZ is a :class:`collections.namedtuple` instance, whose structure
|
||||
directly maps to the return value of the :const:`termios.TIOCGWINSZ`
|
||||
ioctl return value. The return parameters are:
|
||||
|
||||
- ``ws_row``: width of terminal by its number of character cells.
|
||||
- ``ws_col``: height of terminal by its number of character cells.
|
||||
- ``ws_xpixel``: width of terminal by pixels (not accurate).
|
||||
- ``ws_ypixel``: height of terminal by pixels (not accurate).
|
||||
"""
|
||||
window = win32.get_terminal_size(fd)
|
||||
return WINSZ(ws_row=window.lines, ws_col=window.columns,
|
||||
ws_xpixel=0, ws_ypixel=0)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def cbreak(self):
|
||||
"""
|
||||
Allow each keystroke to be read immediately after it is pressed.
|
||||
|
||||
This is a context manager for ``jinxed.w32.setcbreak()``.
|
||||
|
||||
.. note:: You must explicitly print any user input you would like
|
||||
displayed. If you provide any kind of editing, you must handle
|
||||
backspace and other line-editing control functions in this mode
|
||||
as well!
|
||||
|
||||
**Normally**, characters received from the keyboard cannot be read
|
||||
by Python until the *Return* key is pressed. Also known as *cooked* or
|
||||
*canonical input* mode, it allows the tty driver to provide
|
||||
line-editing before shuttling the input to your program and is the
|
||||
(implicit) default terminal mode set by most unix shells before
|
||||
executing programs.
|
||||
"""
|
||||
if self._keyboard_fd is not None:
|
||||
|
||||
filehandle = msvcrt.get_osfhandle(self._keyboard_fd)
|
||||
|
||||
# Save current terminal mode:
|
||||
save_mode = win32.get_console_mode(filehandle)
|
||||
save_line_buffered = self._line_buffered
|
||||
win32.setcbreak(filehandle)
|
||||
try:
|
||||
self._line_buffered = False
|
||||
yield
|
||||
finally:
|
||||
win32.set_console_mode(filehandle, save_mode)
|
||||
self._line_buffered = save_line_buffered
|
||||
|
||||
else:
|
||||
yield
|
||||
|
||||
@contextlib.contextmanager
|
||||
def raw(self):
|
||||
"""
|
||||
A context manager for ``jinxed.w32.setcbreak()``.
|
||||
|
||||
Although both :meth:`break` and :meth:`raw` modes allow each keystroke
|
||||
to be read immediately after it is pressed, Raw mode disables
|
||||
processing of input and output.
|
||||
|
||||
In cbreak mode, special input characters such as ``^C`` are
|
||||
interpreted by the terminal driver and excluded from the stdin stream.
|
||||
In raw mode these values are receive by the :meth:`inkey` method.
|
||||
"""
|
||||
if self._keyboard_fd is not None:
|
||||
|
||||
filehandle = msvcrt.get_osfhandle(self._keyboard_fd)
|
||||
|
||||
# Save current terminal mode:
|
||||
save_mode = win32.get_console_mode(filehandle)
|
||||
save_line_buffered = self._line_buffered
|
||||
win32.setraw(filehandle)
|
||||
try:
|
||||
self._line_buffered = False
|
||||
yield
|
||||
finally:
|
||||
win32.set_console_mode(filehandle, save_mode)
|
||||
self._line_buffered = save_line_buffered
|
||||
|
||||
else:
|
||||
yield
|
||||
11
venv/lib/python3.11/site-packages/blessed/win_terminal.pyi
Normal file
11
venv/lib/python3.11/site-packages/blessed/win_terminal.pyi
Normal file
@@ -0,0 +1,11 @@
|
||||
# std imports
|
||||
from typing import Optional, ContextManager
|
||||
|
||||
# local
|
||||
from .terminal import Terminal as _Terminal
|
||||
|
||||
class Terminal(_Terminal):
|
||||
def getch(self) -> str: ...
|
||||
def kbhit(self, timeout: Optional[float] = ...) -> bool: ...
|
||||
def cbreak(self) -> ContextManager[None]: ...
|
||||
def raw(self) -> ContextManager[None]: ...
|
||||
@@ -0,0 +1 @@
|
||||
import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distutils_hack').add_shim();
|
||||
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,966 @@
|
||||
Copyright (c) 2005-2024, NumPy Developers.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of the NumPy Developers nor the names of any
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----
|
||||
|
||||
The NumPy repository and source distributions bundle several libraries that are
|
||||
compatibly licensed. We list these here.
|
||||
|
||||
Name: lapack-lite
|
||||
Files: numpy/linalg/lapack_lite/*
|
||||
License: BSD-3-Clause
|
||||
For details, see numpy/linalg/lapack_lite/LICENSE.txt
|
||||
|
||||
Name: dragon4
|
||||
Files: numpy/_core/src/multiarray/dragon4.c
|
||||
License: MIT
|
||||
For license text, see numpy/_core/src/multiarray/dragon4.c
|
||||
|
||||
Name: libdivide
|
||||
Files: numpy/_core/include/numpy/libdivide/*
|
||||
License: Zlib
|
||||
For license text, see numpy/_core/include/numpy/libdivide/LICENSE.txt
|
||||
|
||||
|
||||
Note that the following files are vendored in the repository and sdist but not
|
||||
installed in built numpy packages:
|
||||
|
||||
Name: Meson
|
||||
Files: vendored-meson/meson/*
|
||||
License: Apache 2.0
|
||||
For license text, see vendored-meson/meson/COPYING
|
||||
|
||||
Name: spin
|
||||
Files: .spin/cmds.py
|
||||
License: BSD-3
|
||||
For license text, see .spin/LICENSE
|
||||
|
||||
----
|
||||
|
||||
This binary distribution of NumPy also bundles the following software:
|
||||
|
||||
|
||||
Name: OpenBLAS
|
||||
Files: numpy.libs/libscipy_openblas*.so
|
||||
Description: bundled as a dynamically linked library
|
||||
Availability: https://github.com/OpenMathLib/OpenBLAS/
|
||||
License: BSD-3-Clause
|
||||
Copyright (c) 2011-2014, The OpenBLAS Project
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Neither the name of the OpenBLAS project nor the names of
|
||||
its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Name: LAPACK
|
||||
Files: numpy.libs/libscipy_openblas*.so
|
||||
Description: bundled in OpenBLAS
|
||||
Availability: https://github.com/OpenMathLib/OpenBLAS/
|
||||
License: BSD-3-Clause-Attribution
|
||||
Copyright (c) 1992-2013 The University of Tennessee and The University
|
||||
of Tennessee Research Foundation. All rights
|
||||
reserved.
|
||||
Copyright (c) 2000-2013 The University of California Berkeley. All
|
||||
rights reserved.
|
||||
Copyright (c) 2006-2013 The University of Colorado Denver. All rights
|
||||
reserved.
|
||||
|
||||
$COPYRIGHT$
|
||||
|
||||
Additional copyrights may follow
|
||||
|
||||
$HEADER$
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer listed
|
||||
in this license in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
- Neither the name of the copyright holders nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
The copyright holders provide no reassurances that the source code
|
||||
provided does not infringe any patent, copyright, or any other
|
||||
intellectual property rights of third parties. The copyright holders
|
||||
disclaim any liability to any recipient for claims brought against
|
||||
recipient by any third party for infringement of that parties
|
||||
intellectual property rights.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
Name: GCC runtime library
|
||||
Files: numpy.libs/libgfortran*.so
|
||||
Description: dynamically linked to files compiled with gcc
|
||||
Availability: https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=libgfortran
|
||||
License: GPL-3.0-with-GCC-exception
|
||||
Copyright (C) 2002-2017 Free Software Foundation, Inc.
|
||||
|
||||
Libgfortran is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
Libgfortran is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
----
|
||||
|
||||
Full text of license texts referred to above follows (that they are
|
||||
listed below does not necessarily imply the conditions apply to the
|
||||
present binary release):
|
||||
|
||||
----
|
||||
|
||||
GCC RUNTIME LIBRARY EXCEPTION
|
||||
|
||||
Version 3.1, 31 March 2009
|
||||
|
||||
Copyright (C) 2009 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
This GCC Runtime Library Exception ("Exception") is an additional
|
||||
permission under section 7 of the GNU General Public License, version
|
||||
3 ("GPLv3"). It applies to a given file (the "Runtime Library") that
|
||||
bears a notice placed by the copyright holder of the file stating that
|
||||
the file is governed by GPLv3 along with this Exception.
|
||||
|
||||
When you use GCC to compile a program, GCC may combine portions of
|
||||
certain GCC header files and runtime libraries with the compiled
|
||||
program. The purpose of this Exception is to allow compilation of
|
||||
non-GPL (including proprietary) programs to use, in this way, the
|
||||
header files and runtime libraries covered by this Exception.
|
||||
|
||||
0. Definitions.
|
||||
|
||||
A file is an "Independent Module" if it either requires the Runtime
|
||||
Library for execution after a Compilation Process, or makes use of an
|
||||
interface provided by the Runtime Library, but is not otherwise based
|
||||
on the Runtime Library.
|
||||
|
||||
"GCC" means a version of the GNU Compiler Collection, with or without
|
||||
modifications, governed by version 3 (or a specified later version) of
|
||||
the GNU General Public License (GPL) with the option of using any
|
||||
subsequent versions published by the FSF.
|
||||
|
||||
"GPL-compatible Software" is software whose conditions of propagation,
|
||||
modification and use would permit combination with GCC in accord with
|
||||
the license of GCC.
|
||||
|
||||
"Target Code" refers to output from any compiler for a real or virtual
|
||||
target processor architecture, in executable form or suitable for
|
||||
input to an assembler, loader, linker and/or execution
|
||||
phase. Notwithstanding that, Target Code does not include data in any
|
||||
format that is used as a compiler intermediate representation, or used
|
||||
for producing a compiler intermediate representation.
|
||||
|
||||
The "Compilation Process" transforms code entirely represented in
|
||||
non-intermediate languages designed for human-written code, and/or in
|
||||
Java Virtual Machine byte code, into Target Code. Thus, for example,
|
||||
use of source code generators and preprocessors need not be considered
|
||||
part of the Compilation Process, since the Compilation Process can be
|
||||
understood as starting with the output of the generators or
|
||||
preprocessors.
|
||||
|
||||
A Compilation Process is "Eligible" if it is done using GCC, alone or
|
||||
with other GPL-compatible software, or if it is done without using any
|
||||
work based on GCC. For example, using non-GPL-compatible Software to
|
||||
optimize any GCC intermediate representations would not qualify as an
|
||||
Eligible Compilation Process.
|
||||
|
||||
1. Grant of Additional Permission.
|
||||
|
||||
You have permission to propagate a work of Target Code formed by
|
||||
combining the Runtime Library with Independent Modules, even if such
|
||||
propagation would otherwise violate the terms of GPLv3, provided that
|
||||
all Target Code was generated by Eligible Compilation Processes. You
|
||||
may then convey such a combination under terms of your choice,
|
||||
consistent with the licensing of the Independent Modules.
|
||||
|
||||
2. No Weakening of GCC Copyleft.
|
||||
|
||||
The availability of this Exception does not imply any general
|
||||
presumption that third-party software is unaffected by the copyleft
|
||||
requirements of the license of GCC.
|
||||
|
||||
----
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
Name: libquadmath
|
||||
Files: numpy.libs/libquadmath*.so
|
||||
Description: dynamically linked to files compiled with gcc
|
||||
Availability: https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=libquadmath
|
||||
License: LGPL-2.1-or-later
|
||||
|
||||
GCC Quad-Precision Math Library
|
||||
Copyright (C) 2010-2019 Free Software Foundation, Inc.
|
||||
Written by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
|
||||
|
||||
This file is part of the libquadmath library.
|
||||
Libquadmath is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
Libquadmath is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
|
||||
1087
venv/lib/python3.11/site-packages/numpy-2.1.1.dist-info/METADATA
Normal file
1087
venv/lib/python3.11/site-packages/numpy-2.1.1.dist-info/METADATA
Normal file
File diff suppressed because it is too large
Load Diff
1436
venv/lib/python3.11/site-packages/numpy-2.1.1.dist-info/RECORD
Normal file
1436
venv/lib/python3.11/site-packages/numpy-2.1.1.dist-info/RECORD
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: meson
|
||||
Root-Is-Purelib: false
|
||||
Tag: cp311-cp311-manylinux_2_17_x86_64
|
||||
Tag: cp311-cp311-manylinux2014_x86_64
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
[array_api]
|
||||
numpy = numpy
|
||||
|
||||
[pyinstaller40]
|
||||
hook-dirs = numpy:_pyinstaller_hooks_dir
|
||||
|
||||
[console_scripts]
|
||||
f2py = numpy.f2py.f2py2e:main
|
||||
numpy-config = numpy._configtool:main
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
venv/lib/python3.11/site-packages/numpy.libs/libscipy_openblas64_-ff651d7f.so
Executable file
BIN
venv/lib/python3.11/site-packages/numpy.libs/libscipy_openblas64_-ff651d7f.so
Executable file
Binary file not shown.
162
venv/lib/python3.11/site-packages/numpy/__config__.py
Normal file
162
venv/lib/python3.11/site-packages/numpy/__config__.py
Normal file
@@ -0,0 +1,162 @@
|
||||
# This file is generated by numpy's build process
|
||||
# It contains system_info results at the time of building this package.
|
||||
from enum import Enum
|
||||
from numpy._core._multiarray_umath import (
|
||||
__cpu_features__,
|
||||
__cpu_baseline__,
|
||||
__cpu_dispatch__,
|
||||
)
|
||||
|
||||
__all__ = ["show"]
|
||||
_built_with_meson = True
|
||||
|
||||
|
||||
class DisplayModes(Enum):
|
||||
stdout = "stdout"
|
||||
dicts = "dicts"
|
||||
|
||||
|
||||
def _cleanup(d):
|
||||
"""
|
||||
Removes empty values in a `dict` recursively
|
||||
This ensures we remove values that Meson could not provide to CONFIG
|
||||
"""
|
||||
if isinstance(d, dict):
|
||||
return {k: _cleanup(v) for k, v in d.items() if v and _cleanup(v)}
|
||||
else:
|
||||
return d
|
||||
|
||||
|
||||
CONFIG = _cleanup(
|
||||
{
|
||||
"Compilers": {
|
||||
"c": {
|
||||
"name": "gcc",
|
||||
"linker": r"ld.bfd",
|
||||
"version": "10.2.1",
|
||||
"commands": r"cc",
|
||||
"args": r"",
|
||||
"linker args": r"",
|
||||
},
|
||||
"cython": {
|
||||
"name": "cython",
|
||||
"linker": r"cython",
|
||||
"version": "3.0.11",
|
||||
"commands": r"cython",
|
||||
"args": r"",
|
||||
"linker args": r"",
|
||||
},
|
||||
"c++": {
|
||||
"name": "gcc",
|
||||
"linker": r"ld.bfd",
|
||||
"version": "10.2.1",
|
||||
"commands": r"c++",
|
||||
"args": r"",
|
||||
"linker args": r"",
|
||||
},
|
||||
},
|
||||
"Machine Information": {
|
||||
"host": {
|
||||
"cpu": "x86_64",
|
||||
"family": "x86_64",
|
||||
"endian": "little",
|
||||
"system": "linux",
|
||||
},
|
||||
"build": {
|
||||
"cpu": "x86_64",
|
||||
"family": "x86_64",
|
||||
"endian": "little",
|
||||
"system": "linux",
|
||||
},
|
||||
"cross-compiled": bool("False".lower().replace("false", "")),
|
||||
},
|
||||
"Build Dependencies": {
|
||||
"blas": {
|
||||
"name": "scipy-openblas",
|
||||
"found": bool("True".lower().replace("false", "")),
|
||||
"version": "0.3.27",
|
||||
"detection method": "pkgconfig",
|
||||
"include directory": r"/opt/_internal/cpython-3.11.9/lib/python3.11/site-packages/scipy_openblas64/include",
|
||||
"lib directory": r"/opt/_internal/cpython-3.11.9/lib/python3.11/site-packages/scipy_openblas64/lib",
|
||||
"openblas configuration": r"OpenBLAS 0.3.27 USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64",
|
||||
"pc file directory": r"/project/.openblas",
|
||||
},
|
||||
"lapack": {
|
||||
"name": "scipy-openblas",
|
||||
"found": bool("True".lower().replace("false", "")),
|
||||
"version": "0.3.27",
|
||||
"detection method": "pkgconfig",
|
||||
"include directory": r"/opt/_internal/cpython-3.11.9/lib/python3.11/site-packages/scipy_openblas64/include",
|
||||
"lib directory": r"/opt/_internal/cpython-3.11.9/lib/python3.11/site-packages/scipy_openblas64/lib",
|
||||
"openblas configuration": r"OpenBLAS 0.3.27 USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=64",
|
||||
"pc file directory": r"/project/.openblas",
|
||||
},
|
||||
},
|
||||
"Python Information": {
|
||||
"path": r"/tmp/build-env-9fu1yo6p/bin/python",
|
||||
"version": "3.11",
|
||||
},
|
||||
"SIMD Extensions": {
|
||||
"baseline": __cpu_baseline__,
|
||||
"found": [
|
||||
feature for feature in __cpu_dispatch__ if __cpu_features__[feature]
|
||||
],
|
||||
"not found": [
|
||||
feature for feature in __cpu_dispatch__ if not __cpu_features__[feature]
|
||||
],
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _check_pyyaml():
|
||||
import yaml
|
||||
|
||||
return yaml
|
||||
|
||||
|
||||
def show(mode=DisplayModes.stdout.value):
|
||||
"""
|
||||
Show libraries and system information on which NumPy was built
|
||||
and is being used
|
||||
|
||||
Parameters
|
||||
----------
|
||||
mode : {`'stdout'`, `'dicts'`}, optional.
|
||||
Indicates how to display the config information.
|
||||
`'stdout'` prints to console, `'dicts'` returns a dictionary
|
||||
of the configuration.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : {`dict`, `None`}
|
||||
If mode is `'dicts'`, a dict is returned, else None
|
||||
|
||||
See Also
|
||||
--------
|
||||
get_include : Returns the directory containing NumPy C
|
||||
header files.
|
||||
|
||||
Notes
|
||||
-----
|
||||
1. The `'stdout'` mode will give more readable
|
||||
output if ``pyyaml`` is installed
|
||||
|
||||
"""
|
||||
if mode == DisplayModes.stdout.value:
|
||||
try: # Non-standard library, check import
|
||||
yaml = _check_pyyaml()
|
||||
|
||||
print(yaml.dump(CONFIG))
|
||||
except ModuleNotFoundError:
|
||||
import warnings
|
||||
import json
|
||||
|
||||
warnings.warn("Install `pyyaml` for better output", stacklevel=1)
|
||||
print(json.dumps(CONFIG, indent=2))
|
||||
elif mode == DisplayModes.dicts.value:
|
||||
return CONFIG
|
||||
else:
|
||||
raise AttributeError(
|
||||
f"Invalid `mode`, use one of: {', '.join([e.value for e in DisplayModes])}"
|
||||
)
|
||||
1225
venv/lib/python3.11/site-packages/numpy/__init__.cython-30.pxd
Normal file
1225
venv/lib/python3.11/site-packages/numpy/__init__.cython-30.pxd
Normal file
File diff suppressed because it is too large
Load Diff
1140
venv/lib/python3.11/site-packages/numpy/__init__.pxd
Normal file
1140
venv/lib/python3.11/site-packages/numpy/__init__.pxd
Normal file
File diff suppressed because it is too large
Load Diff
542
venv/lib/python3.11/site-packages/numpy/__init__.py
Normal file
542
venv/lib/python3.11/site-packages/numpy/__init__.py
Normal file
@@ -0,0 +1,542 @@
|
||||
"""
|
||||
NumPy
|
||||
=====
|
||||
|
||||
Provides
|
||||
1. An array object of arbitrary homogeneous items
|
||||
2. Fast mathematical operations over arrays
|
||||
3. Linear Algebra, Fourier Transforms, Random Number Generation
|
||||
|
||||
How to use the documentation
|
||||
----------------------------
|
||||
Documentation is available in two forms: docstrings provided
|
||||
with the code, and a loose standing reference guide, available from
|
||||
`the NumPy homepage <https://numpy.org>`_.
|
||||
|
||||
We recommend exploring the docstrings using
|
||||
`IPython <https://ipython.org>`_, an advanced Python shell with
|
||||
TAB-completion and introspection capabilities. See below for further
|
||||
instructions.
|
||||
|
||||
The docstring examples assume that `numpy` has been imported as ``np``::
|
||||
|
||||
>>> import numpy as np
|
||||
|
||||
Code snippets are indicated by three greater-than signs::
|
||||
|
||||
>>> x = 42
|
||||
>>> x = x + 1
|
||||
|
||||
Use the built-in ``help`` function to view a function's docstring::
|
||||
|
||||
>>> help(np.sort)
|
||||
... # doctest: +SKIP
|
||||
|
||||
For some objects, ``np.info(obj)`` may provide additional help. This is
|
||||
particularly true if you see the line "Help on ufunc object:" at the top
|
||||
of the help() page. Ufuncs are implemented in C, not Python, for speed.
|
||||
The native Python help() does not know how to view their help, but our
|
||||
np.info() function does.
|
||||
|
||||
Available subpackages
|
||||
---------------------
|
||||
lib
|
||||
Basic functions used by several sub-packages.
|
||||
random
|
||||
Core Random Tools
|
||||
linalg
|
||||
Core Linear Algebra Tools
|
||||
fft
|
||||
Core FFT routines
|
||||
polynomial
|
||||
Polynomial tools
|
||||
testing
|
||||
NumPy testing tools
|
||||
distutils
|
||||
Enhancements to distutils with support for
|
||||
Fortran compilers support and more (for Python <= 3.11)
|
||||
|
||||
Utilities
|
||||
---------
|
||||
test
|
||||
Run numpy unittests
|
||||
show_config
|
||||
Show numpy build configuration
|
||||
__version__
|
||||
NumPy version string
|
||||
|
||||
Viewing documentation using IPython
|
||||
-----------------------------------
|
||||
|
||||
Start IPython and import `numpy` usually under the alias ``np``: `import
|
||||
numpy as np`. Then, directly past or use the ``%cpaste`` magic to paste
|
||||
examples into the shell. To see which functions are available in `numpy`,
|
||||
type ``np.<TAB>`` (where ``<TAB>`` refers to the TAB key), or use
|
||||
``np.*cos*?<ENTER>`` (where ``<ENTER>`` refers to the ENTER key) to narrow
|
||||
down the list. To view the docstring for a function, use
|
||||
``np.cos?<ENTER>`` (to view the docstring) and ``np.cos??<ENTER>`` (to view
|
||||
the source code).
|
||||
|
||||
Copies vs. in-place operation
|
||||
-----------------------------
|
||||
Most of the functions in `numpy` return a copy of the array argument
|
||||
(e.g., `np.sort`). In-place versions of these functions are often
|
||||
available as array methods, i.e. ``x = np.array([1,2,3]); x.sort()``.
|
||||
Exceptions to this rule are documented.
|
||||
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from ._globals import _NoValue, _CopyMode
|
||||
from ._expired_attrs_2_0 import __expired_attributes__
|
||||
|
||||
|
||||
# If a version with git hash was stored, use that instead
|
||||
from . import version
|
||||
from .version import __version__
|
||||
|
||||
# We first need to detect if we're being called as part of the numpy setup
|
||||
# procedure itself in a reliable manner.
|
||||
try:
|
||||
__NUMPY_SETUP__
|
||||
except NameError:
|
||||
__NUMPY_SETUP__ = False
|
||||
|
||||
if __NUMPY_SETUP__:
|
||||
sys.stderr.write('Running from numpy source directory.\n')
|
||||
else:
|
||||
# Allow distributors to run custom init code before importing numpy._core
|
||||
from . import _distributor_init
|
||||
|
||||
try:
|
||||
from numpy.__config__ import show as show_config
|
||||
except ImportError as e:
|
||||
msg = """Error importing numpy: you should not try to import numpy from
|
||||
its source directory; please exit the numpy source tree, and relaunch
|
||||
your python interpreter from there."""
|
||||
raise ImportError(msg) from e
|
||||
|
||||
from . import _core
|
||||
from ._core import (
|
||||
False_, ScalarType, True_, _get_promotion_state, _no_nep50_warning,
|
||||
_set_promotion_state, abs, absolute, acos, acosh, add, all, allclose,
|
||||
amax, amin, any, arange, arccos, arccosh, arcsin, arcsinh,
|
||||
arctan, arctan2, arctanh, argmax, argmin, argpartition, argsort,
|
||||
argwhere, around, array, array2string, array_equal, array_equiv,
|
||||
array_repr, array_str, asanyarray, asarray, ascontiguousarray,
|
||||
asfortranarray, asin, asinh, atan, atanh, atan2, astype, atleast_1d,
|
||||
atleast_2d, atleast_3d, base_repr, binary_repr, bitwise_and,
|
||||
bitwise_count, bitwise_invert, bitwise_left_shift, bitwise_not,
|
||||
bitwise_or, bitwise_right_shift, bitwise_xor, block, bool, bool_,
|
||||
broadcast, busday_count, busday_offset, busdaycalendar, byte, bytes_,
|
||||
can_cast, cbrt, cdouble, ceil, character, choose, clip, clongdouble,
|
||||
complex128, complex64, complexfloating, compress, concat, concatenate,
|
||||
conj, conjugate, convolve, copysign, copyto, correlate, cos, cosh,
|
||||
count_nonzero, cross, csingle, cumprod, cumsum, cumulative_prod,
|
||||
cumulative_sum, datetime64, datetime_as_string, datetime_data,
|
||||
deg2rad, degrees, diagonal, divide, divmod, dot, double, dtype, e,
|
||||
einsum, einsum_path, empty, empty_like, equal, errstate, euler_gamma,
|
||||
exp, exp2, expm1, fabs, finfo, flatiter, flatnonzero, flexible,
|
||||
float16, float32, float64, float_power, floating, floor, floor_divide,
|
||||
fmax, fmin, fmod, format_float_positional, format_float_scientific,
|
||||
frexp, from_dlpack, frombuffer, fromfile, fromfunction, fromiter,
|
||||
frompyfunc, fromstring, full, full_like, gcd, generic, geomspace,
|
||||
get_printoptions, getbufsize, geterr, geterrcall, greater,
|
||||
greater_equal, half, heaviside, hstack, hypot, identity, iinfo, iinfo,
|
||||
indices, inexact, inf, inner, int16, int32, int64, int8, int_, intc,
|
||||
integer, intp, invert, is_busday, isclose, isdtype, isfinite,
|
||||
isfortran, isinf, isnan, isnat, isscalar, issubdtype, lcm, ldexp,
|
||||
left_shift, less, less_equal, lexsort, linspace, little_endian, log,
|
||||
log10, log1p, log2, logaddexp, logaddexp2, logical_and, logical_not,
|
||||
logical_or, logical_xor, logspace, long, longdouble, longlong, matmul,
|
||||
matrix_transpose, max, maximum, may_share_memory, mean, memmap, min,
|
||||
min_scalar_type, minimum, mod, modf, moveaxis, multiply, nan, ndarray,
|
||||
ndim, nditer, negative, nested_iters, newaxis, nextafter, nonzero,
|
||||
not_equal, number, object_, ones, ones_like, outer, partition,
|
||||
permute_dims, pi, positive, pow, power, printoptions, prod,
|
||||
promote_types, ptp, put, putmask, rad2deg, radians, ravel, recarray,
|
||||
reciprocal, record, remainder, repeat, require, reshape, resize,
|
||||
result_type, right_shift, rint, roll, rollaxis, round, sctypeDict,
|
||||
searchsorted, set_printoptions, setbufsize, seterr, seterrcall, shape,
|
||||
shares_memory, short, sign, signbit, signedinteger, sin, single, sinh,
|
||||
size, sort, spacing, sqrt, square, squeeze, stack, std,
|
||||
str_, subtract, sum, swapaxes, take, tan, tanh, tensordot,
|
||||
timedelta64, trace, transpose, true_divide, trunc, typecodes, ubyte,
|
||||
ufunc, uint, uint16, uint32, uint64, uint8, uintc, uintp, ulong,
|
||||
ulonglong, unsignedinteger, unstack, ushort, var, vdot, vecdot, void,
|
||||
vstack, where, zeros, zeros_like
|
||||
)
|
||||
|
||||
# NOTE: It's still under discussion whether these aliases
|
||||
# should be removed.
|
||||
for ta in ["float96", "float128", "complex192", "complex256"]:
|
||||
try:
|
||||
globals()[ta] = getattr(_core, ta)
|
||||
except AttributeError:
|
||||
pass
|
||||
del ta
|
||||
|
||||
from . import lib
|
||||
from .lib import scimath as emath
|
||||
from .lib._histograms_impl import (
|
||||
histogram, histogram_bin_edges, histogramdd
|
||||
)
|
||||
from .lib._nanfunctions_impl import (
|
||||
nanargmax, nanargmin, nancumprod, nancumsum, nanmax, nanmean,
|
||||
nanmedian, nanmin, nanpercentile, nanprod, nanquantile, nanstd,
|
||||
nansum, nanvar
|
||||
)
|
||||
from .lib._function_base_impl import (
|
||||
select, piecewise, trim_zeros, copy, iterable, percentile, diff,
|
||||
gradient, angle, unwrap, sort_complex, flip, rot90, extract, place,
|
||||
vectorize, asarray_chkfinite, average, bincount, digitize, cov,
|
||||
corrcoef, median, sinc, hamming, hanning, bartlett, blackman,
|
||||
kaiser, trapezoid, trapz, i0, meshgrid, delete, insert, append,
|
||||
interp, quantile
|
||||
)
|
||||
from .lib._twodim_base_impl import (
|
||||
diag, diagflat, eye, fliplr, flipud, tri, triu, tril, vander,
|
||||
histogram2d, mask_indices, tril_indices, tril_indices_from,
|
||||
triu_indices, triu_indices_from
|
||||
)
|
||||
from .lib._shape_base_impl import (
|
||||
apply_over_axes, apply_along_axis, array_split, column_stack, dsplit,
|
||||
dstack, expand_dims, hsplit, kron, put_along_axis, row_stack, split,
|
||||
take_along_axis, tile, vsplit
|
||||
)
|
||||
from .lib._type_check_impl import (
|
||||
iscomplexobj, isrealobj, imag, iscomplex, isreal, nan_to_num, real,
|
||||
real_if_close, typename, mintypecode, common_type
|
||||
)
|
||||
from .lib._arraysetops_impl import (
|
||||
ediff1d, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d,
|
||||
unique, unique_all, unique_counts, unique_inverse, unique_values
|
||||
)
|
||||
from .lib._ufunclike_impl import fix, isneginf, isposinf
|
||||
from .lib._arraypad_impl import pad
|
||||
from .lib._utils_impl import (
|
||||
show_runtime, get_include, info
|
||||
)
|
||||
from .lib._stride_tricks_impl import (
|
||||
broadcast_arrays, broadcast_shapes, broadcast_to
|
||||
)
|
||||
from .lib._polynomial_impl import (
|
||||
poly, polyint, polyder, polyadd, polysub, polymul, polydiv, polyval,
|
||||
polyfit, poly1d, roots
|
||||
)
|
||||
from .lib._npyio_impl import (
|
||||
savetxt, loadtxt, genfromtxt, load, save, savez, packbits,
|
||||
savez_compressed, unpackbits, fromregex
|
||||
)
|
||||
from .lib._index_tricks_impl import (
|
||||
diag_indices_from, diag_indices, fill_diagonal, ndindex, ndenumerate,
|
||||
ix_, c_, r_, s_, ogrid, mgrid, unravel_index, ravel_multi_index,
|
||||
index_exp
|
||||
)
|
||||
|
||||
from . import matrixlib as _mat
|
||||
from .matrixlib import (
|
||||
asmatrix, bmat, matrix
|
||||
)
|
||||
|
||||
# public submodules are imported lazily, therefore are accessible from
|
||||
# __getattr__. Note that `distutils` (deprecated) and `array_api`
|
||||
# (experimental label) are not added here, because `from numpy import *`
|
||||
# must not raise any warnings - that's too disruptive.
|
||||
__numpy_submodules__ = {
|
||||
"linalg", "fft", "dtypes", "random", "polynomial", "ma",
|
||||
"exceptions", "lib", "ctypeslib", "testing", "typing",
|
||||
"f2py", "test", "rec", "char", "core", "strings",
|
||||
}
|
||||
|
||||
# We build warning messages for former attributes
|
||||
_msg = (
|
||||
"module 'numpy' has no attribute '{n}'.\n"
|
||||
"`np.{n}` was a deprecated alias for the builtin `{n}`. "
|
||||
"To avoid this error in existing code, use `{n}` by itself. "
|
||||
"Doing this will not modify any behavior and is safe. {extended_msg}\n"
|
||||
"The aliases was originally deprecated in NumPy 1.20; for more "
|
||||
"details and guidance see the original release note at:\n"
|
||||
" https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations")
|
||||
|
||||
_specific_msg = (
|
||||
"If you specifically wanted the numpy scalar type, use `np.{}` here.")
|
||||
|
||||
_int_extended_msg = (
|
||||
"When replacing `np.{}`, you may wish to use e.g. `np.int64` "
|
||||
"or `np.int32` to specify the precision. If you wish to review "
|
||||
"your current use, check the release note link for "
|
||||
"additional information.")
|
||||
|
||||
_type_info = [
|
||||
("object", ""), # The NumPy scalar only exists by name.
|
||||
("float", _specific_msg.format("float64")),
|
||||
("complex", _specific_msg.format("complex128")),
|
||||
("str", _specific_msg.format("str_")),
|
||||
("int", _int_extended_msg.format("int"))]
|
||||
|
||||
__former_attrs__ = {
|
||||
n: _msg.format(n=n, extended_msg=extended_msg)
|
||||
for n, extended_msg in _type_info
|
||||
}
|
||||
|
||||
|
||||
# Some of these could be defined right away, but most were aliases to
|
||||
# the Python objects and only removed in NumPy 1.24. Defining them should
|
||||
# probably wait for NumPy 1.26 or 2.0.
|
||||
# When defined, these should possibly not be added to `__all__` to avoid
|
||||
# import with `from numpy import *`.
|
||||
__future_scalars__ = {"str", "bytes", "object"}
|
||||
|
||||
__array_api_version__ = "2023.12"
|
||||
|
||||
from ._array_api_info import __array_namespace_info__
|
||||
|
||||
# now that numpy core module is imported, can initialize limits
|
||||
_core.getlimits._register_known_types()
|
||||
|
||||
__all__ = list(
|
||||
__numpy_submodules__ |
|
||||
set(_core.__all__) |
|
||||
set(_mat.__all__) |
|
||||
set(lib._histograms_impl.__all__) |
|
||||
set(lib._nanfunctions_impl.__all__) |
|
||||
set(lib._function_base_impl.__all__) |
|
||||
set(lib._twodim_base_impl.__all__) |
|
||||
set(lib._shape_base_impl.__all__) |
|
||||
set(lib._type_check_impl.__all__) |
|
||||
set(lib._arraysetops_impl.__all__) |
|
||||
set(lib._ufunclike_impl.__all__) |
|
||||
set(lib._arraypad_impl.__all__) |
|
||||
set(lib._utils_impl.__all__) |
|
||||
set(lib._stride_tricks_impl.__all__) |
|
||||
set(lib._polynomial_impl.__all__) |
|
||||
set(lib._npyio_impl.__all__) |
|
||||
set(lib._index_tricks_impl.__all__) |
|
||||
{"emath", "show_config", "__version__", "__array_namespace_info__"}
|
||||
)
|
||||
|
||||
# Filter out Cython harmless warnings
|
||||
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
|
||||
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
|
||||
warnings.filterwarnings("ignore", message="numpy.ndarray size changed")
|
||||
|
||||
def __getattr__(attr):
|
||||
# Warn for expired attributes
|
||||
import warnings
|
||||
|
||||
if attr == "linalg":
|
||||
import numpy.linalg as linalg
|
||||
return linalg
|
||||
elif attr == "fft":
|
||||
import numpy.fft as fft
|
||||
return fft
|
||||
elif attr == "dtypes":
|
||||
import numpy.dtypes as dtypes
|
||||
return dtypes
|
||||
elif attr == "random":
|
||||
import numpy.random as random
|
||||
return random
|
||||
elif attr == "polynomial":
|
||||
import numpy.polynomial as polynomial
|
||||
return polynomial
|
||||
elif attr == "ma":
|
||||
import numpy.ma as ma
|
||||
return ma
|
||||
elif attr == "ctypeslib":
|
||||
import numpy.ctypeslib as ctypeslib
|
||||
return ctypeslib
|
||||
elif attr == "exceptions":
|
||||
import numpy.exceptions as exceptions
|
||||
return exceptions
|
||||
elif attr == "testing":
|
||||
import numpy.testing as testing
|
||||
return testing
|
||||
elif attr == "matlib":
|
||||
import numpy.matlib as matlib
|
||||
return matlib
|
||||
elif attr == "f2py":
|
||||
import numpy.f2py as f2py
|
||||
return f2py
|
||||
elif attr == "typing":
|
||||
import numpy.typing as typing
|
||||
return typing
|
||||
elif attr == "rec":
|
||||
import numpy.rec as rec
|
||||
return rec
|
||||
elif attr == "char":
|
||||
import numpy.char as char
|
||||
return char
|
||||
elif attr == "array_api":
|
||||
raise AttributeError("`numpy.array_api` is not available from "
|
||||
"numpy 2.0 onwards", name=None)
|
||||
elif attr == "core":
|
||||
import numpy.core as core
|
||||
return core
|
||||
elif attr == "strings":
|
||||
import numpy.strings as strings
|
||||
return strings
|
||||
elif attr == "distutils":
|
||||
if 'distutils' in __numpy_submodules__:
|
||||
import numpy.distutils as distutils
|
||||
return distutils
|
||||
else:
|
||||
raise AttributeError("`numpy.distutils` is not available from "
|
||||
"Python 3.12 onwards", name=None)
|
||||
|
||||
if attr in __future_scalars__:
|
||||
# And future warnings for those that will change, but also give
|
||||
# the AttributeError
|
||||
warnings.warn(
|
||||
f"In the future `np.{attr}` will be defined as the "
|
||||
"corresponding NumPy scalar.", FutureWarning, stacklevel=2)
|
||||
|
||||
if attr in __former_attrs__:
|
||||
raise AttributeError(__former_attrs__[attr], name=None)
|
||||
|
||||
if attr in __expired_attributes__:
|
||||
raise AttributeError(
|
||||
f"`np.{attr}` was removed in the NumPy 2.0 release. "
|
||||
f"{__expired_attributes__[attr]}",
|
||||
name=None
|
||||
)
|
||||
|
||||
if attr == "chararray":
|
||||
warnings.warn(
|
||||
"`np.chararray` is deprecated and will be removed from "
|
||||
"the main namespace in the future. Use an array with a string "
|
||||
"or bytes dtype instead.", DeprecationWarning, stacklevel=2)
|
||||
import numpy.char as char
|
||||
return char.chararray
|
||||
|
||||
raise AttributeError("module {!r} has no attribute "
|
||||
"{!r}".format(__name__, attr))
|
||||
|
||||
def __dir__():
|
||||
public_symbols = (
|
||||
globals().keys() | __numpy_submodules__
|
||||
)
|
||||
public_symbols -= {
|
||||
"matrixlib", "matlib", "tests", "conftest", "version",
|
||||
"compat", "distutils", "array_api"
|
||||
}
|
||||
return list(public_symbols)
|
||||
|
||||
# Pytest testing
|
||||
from numpy._pytesttester import PytestTester
|
||||
test = PytestTester(__name__)
|
||||
del PytestTester
|
||||
|
||||
def _sanity_check():
|
||||
"""
|
||||
Quick sanity checks for common bugs caused by environment.
|
||||
There are some cases e.g. with wrong BLAS ABI that cause wrong
|
||||
results under specific runtime conditions that are not necessarily
|
||||
achieved during test suite runs, and it is useful to catch those early.
|
||||
|
||||
See https://github.com/numpy/numpy/issues/8577 and other
|
||||
similar bug reports.
|
||||
|
||||
"""
|
||||
try:
|
||||
x = ones(2, dtype=float32)
|
||||
if not abs(x.dot(x) - float32(2.0)) < 1e-5:
|
||||
raise AssertionError()
|
||||
except AssertionError:
|
||||
msg = ("The current Numpy installation ({!r}) fails to "
|
||||
"pass simple sanity checks. This can be caused for example "
|
||||
"by incorrect BLAS library being linked in, or by mixing "
|
||||
"package managers (pip, conda, apt, ...). Search closed "
|
||||
"numpy issues for similar problems.")
|
||||
raise RuntimeError(msg.format(__file__)) from None
|
||||
|
||||
_sanity_check()
|
||||
del _sanity_check
|
||||
|
||||
def _mac_os_check():
|
||||
"""
|
||||
Quick Sanity check for Mac OS look for accelerate build bugs.
|
||||
Testing numpy polyfit calls init_dgelsd(LAPACK)
|
||||
"""
|
||||
try:
|
||||
c = array([3., 2., 1.])
|
||||
x = linspace(0, 2, 5)
|
||||
y = polyval(c, x)
|
||||
_ = polyfit(x, y, 2, cov=True)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if sys.platform == "darwin":
|
||||
from . import exceptions
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
_mac_os_check()
|
||||
# Throw runtime error, if the test failed Check for warning and error_message
|
||||
if len(w) > 0:
|
||||
for _wn in w:
|
||||
if _wn.category is exceptions.RankWarning:
|
||||
# Ignore other warnings, they may not be relevant (see gh-25433).
|
||||
error_message = f"{_wn.category.__name__}: {str(_wn.message)}"
|
||||
msg = (
|
||||
"Polyfit sanity test emitted a warning, most likely due "
|
||||
"to using a buggy Accelerate backend."
|
||||
"\nIf you compiled yourself, more information is available at:"
|
||||
"\nhttps://numpy.org/devdocs/building/index.html"
|
||||
"\nOtherwise report this to the vendor "
|
||||
"that provided NumPy.\n\n{}\n".format(error_message))
|
||||
raise RuntimeError(msg)
|
||||
del _wn
|
||||
del w
|
||||
del _mac_os_check
|
||||
|
||||
def hugepage_setup():
|
||||
"""
|
||||
We usually use madvise hugepages support, but on some old kernels it
|
||||
is slow and thus better avoided. Specifically kernel version 4.6
|
||||
had a bug fix which probably fixed this:
|
||||
https://github.com/torvalds/linux/commit/7cf91a98e607c2f935dbcc177d70011e95b8faff
|
||||
"""
|
||||
use_hugepage = os.environ.get("NUMPY_MADVISE_HUGEPAGE", None)
|
||||
if sys.platform == "linux" and use_hugepage is None:
|
||||
# If there is an issue with parsing the kernel version,
|
||||
# set use_hugepage to 0. Usage of LooseVersion will handle
|
||||
# the kernel version parsing better, but avoided since it
|
||||
# will increase the import time.
|
||||
# See: #16679 for related discussion.
|
||||
try:
|
||||
use_hugepage = 1
|
||||
kernel_version = os.uname().release.split(".")[:2]
|
||||
kernel_version = tuple(int(v) for v in kernel_version)
|
||||
if kernel_version < (4, 6):
|
||||
use_hugepage = 0
|
||||
except ValueError:
|
||||
use_hugepage = 0
|
||||
elif use_hugepage is None:
|
||||
# This is not Linux, so it should not matter, just enable anyway
|
||||
use_hugepage = 1
|
||||
else:
|
||||
use_hugepage = int(use_hugepage)
|
||||
return use_hugepage
|
||||
|
||||
# Note that this will currently only make a difference on Linux
|
||||
_core.multiarray._set_madvise_hugepage(hugepage_setup())
|
||||
del hugepage_setup
|
||||
|
||||
# Give a warning if NumPy is reloaded or imported on a sub-interpreter
|
||||
# We do this from python, since the C-module may not be reloaded and
|
||||
# it is tidier organized.
|
||||
_core.multiarray._multiarray_umath._reload_guard()
|
||||
|
||||
# TODO: Remove the environment variable entirely now that it is "weak"
|
||||
_core._set_promotion_state(
|
||||
os.environ.get("NPY_PROMOTION_STATE", "weak"))
|
||||
|
||||
# Tell PyInstaller where to find hook-numpy.py
|
||||
def _pyinstaller_hooks_dir():
|
||||
from pathlib import Path
|
||||
return [str(Path(__file__).with_name("_pyinstaller").resolve())]
|
||||
|
||||
|
||||
# Remove symbols imported for internal use
|
||||
del os, sys, warnings
|
||||
4095
venv/lib/python3.11/site-packages/numpy/__init__.pyi
Normal file
4095
venv/lib/python3.11/site-packages/numpy/__init__.pyi
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
346
venv/lib/python3.11/site-packages/numpy/_array_api_info.py
Normal file
346
venv/lib/python3.11/site-packages/numpy/_array_api_info.py
Normal file
@@ -0,0 +1,346 @@
|
||||
"""
|
||||
Array API Inspection namespace
|
||||
|
||||
This is the namespace for inspection functions as defined by the array API
|
||||
standard. See
|
||||
https://data-apis.org/array-api/latest/API_specification/inspection.html for
|
||||
more details.
|
||||
|
||||
"""
|
||||
from numpy._core import (
|
||||
dtype,
|
||||
bool,
|
||||
intp,
|
||||
int8,
|
||||
int16,
|
||||
int32,
|
||||
int64,
|
||||
uint8,
|
||||
uint16,
|
||||
uint32,
|
||||
uint64,
|
||||
float32,
|
||||
float64,
|
||||
complex64,
|
||||
complex128,
|
||||
)
|
||||
|
||||
|
||||
class __array_namespace_info__:
|
||||
"""
|
||||
Get the array API inspection namespace for NumPy.
|
||||
|
||||
The array API inspection namespace defines the following functions:
|
||||
|
||||
- capabilities()
|
||||
- default_device()
|
||||
- default_dtypes()
|
||||
- dtypes()
|
||||
- devices()
|
||||
|
||||
See
|
||||
https://data-apis.org/array-api/latest/API_specification/inspection.html
|
||||
for more details.
|
||||
|
||||
Returns
|
||||
-------
|
||||
info : ModuleType
|
||||
The array API inspection namespace for NumPy.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> info = np.__array_namespace_info__()
|
||||
>>> info.default_dtypes()
|
||||
{'real floating': numpy.float64,
|
||||
'complex floating': numpy.complex128,
|
||||
'integral': numpy.int64,
|
||||
'indexing': numpy.int64}
|
||||
|
||||
"""
|
||||
|
||||
__module__ = 'numpy'
|
||||
|
||||
def capabilities(self):
|
||||
"""
|
||||
Return a dictionary of array API library capabilities.
|
||||
|
||||
The resulting dictionary has the following keys:
|
||||
|
||||
- **"boolean indexing"**: boolean indicating whether an array library
|
||||
supports boolean indexing. Always ``True`` for NumPy.
|
||||
|
||||
- **"data-dependent shapes"**: boolean indicating whether an array
|
||||
library supports data-dependent output shapes. Always ``True`` for
|
||||
NumPy.
|
||||
|
||||
See
|
||||
https://data-apis.org/array-api/latest/API_specification/generated/array_api.info.capabilities.html
|
||||
for more details.
|
||||
|
||||
See Also
|
||||
--------
|
||||
__array_namespace_info__.default_device,
|
||||
__array_namespace_info__.default_dtypes,
|
||||
__array_namespace_info__.dtypes,
|
||||
__array_namespace_info__.devices
|
||||
|
||||
Returns
|
||||
-------
|
||||
capabilities : dict
|
||||
A dictionary of array API library capabilities.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> info = np.__array_namespace_info__()
|
||||
>>> info.capabilities()
|
||||
{'boolean indexing': True,
|
||||
'data-dependent shapes': True}
|
||||
|
||||
"""
|
||||
return {
|
||||
"boolean indexing": True,
|
||||
"data-dependent shapes": True,
|
||||
# 'max rank' will be part of the 2024.12 standard
|
||||
# "max rank": 64,
|
||||
}
|
||||
|
||||
def default_device(self):
|
||||
"""
|
||||
The default device used for new NumPy arrays.
|
||||
|
||||
For NumPy, this always returns ``'cpu'``.
|
||||
|
||||
See Also
|
||||
--------
|
||||
__array_namespace_info__.capabilities,
|
||||
__array_namespace_info__.default_dtypes,
|
||||
__array_namespace_info__.dtypes,
|
||||
__array_namespace_info__.devices
|
||||
|
||||
Returns
|
||||
-------
|
||||
device : str
|
||||
The default device used for new NumPy arrays.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> info = np.__array_namespace_info__()
|
||||
>>> info.default_device()
|
||||
'cpu'
|
||||
|
||||
"""
|
||||
return "cpu"
|
||||
|
||||
def default_dtypes(self, *, device=None):
|
||||
"""
|
||||
The default data types used for new NumPy arrays.
|
||||
|
||||
For NumPy, this always returns the following dictionary:
|
||||
|
||||
- **"real floating"**: ``numpy.float64``
|
||||
- **"complex floating"**: ``numpy.complex128``
|
||||
- **"integral"**: ``numpy.intp``
|
||||
- **"indexing"**: ``numpy.intp``
|
||||
|
||||
Parameters
|
||||
----------
|
||||
device : str, optional
|
||||
The device to get the default data types for. For NumPy, only
|
||||
``'cpu'`` is allowed.
|
||||
|
||||
Returns
|
||||
-------
|
||||
dtypes : dict
|
||||
A dictionary describing the default data types used for new NumPy
|
||||
arrays.
|
||||
|
||||
See Also
|
||||
--------
|
||||
__array_namespace_info__.capabilities,
|
||||
__array_namespace_info__.default_device,
|
||||
__array_namespace_info__.dtypes,
|
||||
__array_namespace_info__.devices
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> info = np.__array_namespace_info__()
|
||||
>>> info.default_dtypes()
|
||||
{'real floating': numpy.float64,
|
||||
'complex floating': numpy.complex128,
|
||||
'integral': numpy.int64,
|
||||
'indexing': numpy.int64}
|
||||
|
||||
"""
|
||||
if device not in ["cpu", None]:
|
||||
raise ValueError(
|
||||
'Device not understood. Only "cpu" is allowed, but received:'
|
||||
f' {device}'
|
||||
)
|
||||
return {
|
||||
"real floating": dtype(float64),
|
||||
"complex floating": dtype(complex128),
|
||||
"integral": dtype(intp),
|
||||
"indexing": dtype(intp),
|
||||
}
|
||||
|
||||
def dtypes(self, *, device=None, kind=None):
|
||||
"""
|
||||
The array API data types supported by NumPy.
|
||||
|
||||
Note that this function only returns data types that are defined by
|
||||
the array API.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
device : str, optional
|
||||
The device to get the data types for. For NumPy, only ``'cpu'`` is
|
||||
allowed.
|
||||
kind : str or tuple of str, optional
|
||||
The kind of data types to return. If ``None``, all data types are
|
||||
returned. If a string, only data types of that kind are returned.
|
||||
If a tuple, a dictionary containing the union of the given kinds
|
||||
is returned. The following kinds are supported:
|
||||
|
||||
- ``'bool'``: boolean data types (i.e., ``bool``).
|
||||
- ``'signed integer'``: signed integer data types (i.e., ``int8``,
|
||||
``int16``, ``int32``, ``int64``).
|
||||
- ``'unsigned integer'``: unsigned integer data types (i.e.,
|
||||
``uint8``, ``uint16``, ``uint32``, ``uint64``).
|
||||
- ``'integral'``: integer data types. Shorthand for ``('signed
|
||||
integer', 'unsigned integer')``.
|
||||
- ``'real floating'``: real-valued floating-point data types
|
||||
(i.e., ``float32``, ``float64``).
|
||||
- ``'complex floating'``: complex floating-point data types (i.e.,
|
||||
``complex64``, ``complex128``).
|
||||
- ``'numeric'``: numeric data types. Shorthand for ``('integral',
|
||||
'real floating', 'complex floating')``.
|
||||
|
||||
Returns
|
||||
-------
|
||||
dtypes : dict
|
||||
A dictionary mapping the names of data types to the corresponding
|
||||
NumPy data types.
|
||||
|
||||
See Also
|
||||
--------
|
||||
__array_namespace_info__.capabilities,
|
||||
__array_namespace_info__.default_device,
|
||||
__array_namespace_info__.default_dtypes,
|
||||
__array_namespace_info__.devices
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> info = np.__array_namespace_info__()
|
||||
>>> info.dtypes(kind='signed integer')
|
||||
{'int8': numpy.int8,
|
||||
'int16': numpy.int16,
|
||||
'int32': numpy.int32,
|
||||
'int64': numpy.int64}
|
||||
|
||||
"""
|
||||
if device not in ["cpu", None]:
|
||||
raise ValueError(
|
||||
'Device not understood. Only "cpu" is allowed, but received:'
|
||||
f' {device}'
|
||||
)
|
||||
if kind is None:
|
||||
return {
|
||||
"bool": dtype(bool),
|
||||
"int8": dtype(int8),
|
||||
"int16": dtype(int16),
|
||||
"int32": dtype(int32),
|
||||
"int64": dtype(int64),
|
||||
"uint8": dtype(uint8),
|
||||
"uint16": dtype(uint16),
|
||||
"uint32": dtype(uint32),
|
||||
"uint64": dtype(uint64),
|
||||
"float32": dtype(float32),
|
||||
"float64": dtype(float64),
|
||||
"complex64": dtype(complex64),
|
||||
"complex128": dtype(complex128),
|
||||
}
|
||||
if kind == "bool":
|
||||
return {"bool": bool}
|
||||
if kind == "signed integer":
|
||||
return {
|
||||
"int8": dtype(int8),
|
||||
"int16": dtype(int16),
|
||||
"int32": dtype(int32),
|
||||
"int64": dtype(int64),
|
||||
}
|
||||
if kind == "unsigned integer":
|
||||
return {
|
||||
"uint8": dtype(uint8),
|
||||
"uint16": dtype(uint16),
|
||||
"uint32": dtype(uint32),
|
||||
"uint64": dtype(uint64),
|
||||
}
|
||||
if kind == "integral":
|
||||
return {
|
||||
"int8": dtype(int8),
|
||||
"int16": dtype(int16),
|
||||
"int32": dtype(int32),
|
||||
"int64": dtype(int64),
|
||||
"uint8": dtype(uint8),
|
||||
"uint16": dtype(uint16),
|
||||
"uint32": dtype(uint32),
|
||||
"uint64": dtype(uint64),
|
||||
}
|
||||
if kind == "real floating":
|
||||
return {
|
||||
"float32": dtype(float32),
|
||||
"float64": dtype(float64),
|
||||
}
|
||||
if kind == "complex floating":
|
||||
return {
|
||||
"complex64": dtype(complex64),
|
||||
"complex128": dtype(complex128),
|
||||
}
|
||||
if kind == "numeric":
|
||||
return {
|
||||
"int8": dtype(int8),
|
||||
"int16": dtype(int16),
|
||||
"int32": dtype(int32),
|
||||
"int64": dtype(int64),
|
||||
"uint8": dtype(uint8),
|
||||
"uint16": dtype(uint16),
|
||||
"uint32": dtype(uint32),
|
||||
"uint64": dtype(uint64),
|
||||
"float32": dtype(float32),
|
||||
"float64": dtype(float64),
|
||||
"complex64": dtype(complex64),
|
||||
"complex128": dtype(complex128),
|
||||
}
|
||||
if isinstance(kind, tuple):
|
||||
res = {}
|
||||
for k in kind:
|
||||
res.update(self.dtypes(kind=k))
|
||||
return res
|
||||
raise ValueError(f"unsupported kind: {kind!r}")
|
||||
|
||||
def devices(self):
|
||||
"""
|
||||
The devices supported by NumPy.
|
||||
|
||||
For NumPy, this always returns ``['cpu']``.
|
||||
|
||||
Returns
|
||||
-------
|
||||
devices : list of str
|
||||
The devices supported by NumPy.
|
||||
|
||||
See Also
|
||||
--------
|
||||
__array_namespace_info__.capabilities,
|
||||
__array_namespace_info__.default_device,
|
||||
__array_namespace_info__.default_dtypes,
|
||||
__array_namespace_info__.dtypes
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> info = np.__array_namespace_info__()
|
||||
>>> info.devices()
|
||||
['cpu']
|
||||
|
||||
"""
|
||||
return ["cpu"]
|
||||
213
venv/lib/python3.11/site-packages/numpy/_array_api_info.pyi
Normal file
213
venv/lib/python3.11/site-packages/numpy/_array_api_info.pyi
Normal file
@@ -0,0 +1,213 @@
|
||||
import sys
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
ClassVar,
|
||||
Literal,
|
||||
TypeAlias,
|
||||
TypedDict,
|
||||
TypeVar,
|
||||
final,
|
||||
overload,
|
||||
)
|
||||
|
||||
import numpy as np
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
from typing import Never
|
||||
elif TYPE_CHECKING:
|
||||
from typing_extensions import Never
|
||||
else:
|
||||
# `NoReturn` and `Never` are equivalent (but not equal) for type-checkers,
|
||||
# but are used in different places by convention
|
||||
from typing import NoReturn as Never
|
||||
|
||||
_Device: TypeAlias = Literal["cpu"]
|
||||
_DeviceLike: TypeAlias = None | _Device
|
||||
|
||||
_Capabilities = TypedDict(
|
||||
"_Capabilities",
|
||||
{
|
||||
"boolean indexing": Literal[True],
|
||||
"data-dependent shapes": Literal[True],
|
||||
},
|
||||
)
|
||||
|
||||
_DefaultDTypes = TypedDict(
|
||||
"_DefaultDTypes",
|
||||
{
|
||||
"real floating": np.dtype[np.float64],
|
||||
"complex floating": np.dtype[np.complex128],
|
||||
"integral": np.dtype[np.intp],
|
||||
"indexing": np.dtype[np.intp],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
_KindBool: TypeAlias = Literal["bool"]
|
||||
_KindInt: TypeAlias = Literal["signed integer"]
|
||||
_KindUInt: TypeAlias = Literal["unsigned integer"]
|
||||
_KindInteger: TypeAlias = Literal["integral"]
|
||||
_KindFloat: TypeAlias = Literal["real floating"]
|
||||
_KindComplex: TypeAlias = Literal["complex floating"]
|
||||
_KindNumber: TypeAlias = Literal["numeric"]
|
||||
_Kind: TypeAlias = (
|
||||
_KindBool
|
||||
| _KindInt
|
||||
| _KindUInt
|
||||
| _KindInteger
|
||||
| _KindFloat
|
||||
| _KindComplex
|
||||
| _KindNumber
|
||||
)
|
||||
|
||||
|
||||
_T1 = TypeVar("_T1")
|
||||
_T2 = TypeVar("_T2")
|
||||
_T3 = TypeVar("_T3")
|
||||
_Permute1: TypeAlias = _T1 | tuple[_T1]
|
||||
_Permute2: TypeAlias = tuple[_T1, _T2] | tuple[_T2, _T1]
|
||||
_Permute3: TypeAlias = (
|
||||
tuple[_T1, _T2, _T3] | tuple[_T1, _T3, _T2]
|
||||
| tuple[_T2, _T1, _T3] | tuple[_T2, _T3, _T1]
|
||||
| tuple[_T3, _T1, _T2] | tuple[_T3, _T2, _T1]
|
||||
)
|
||||
|
||||
class _DTypesBool(TypedDict):
|
||||
bool: np.dtype[np.bool]
|
||||
|
||||
class _DTypesInt(TypedDict):
|
||||
int8: np.dtype[np.int8]
|
||||
int16: np.dtype[np.int16]
|
||||
int32: np.dtype[np.int32]
|
||||
int64: np.dtype[np.int64]
|
||||
|
||||
class _DTypesUInt(TypedDict):
|
||||
uint8: np.dtype[np.uint8]
|
||||
uint16: np.dtype[np.uint16]
|
||||
uint32: np.dtype[np.uint32]
|
||||
uint64: np.dtype[np.uint64]
|
||||
|
||||
class _DTypesInteger(_DTypesInt, _DTypesUInt):
|
||||
...
|
||||
|
||||
class _DTypesFloat(TypedDict):
|
||||
float32: np.dtype[np.float32]
|
||||
float64: np.dtype[np.float64]
|
||||
|
||||
class _DTypesComplex(TypedDict):
|
||||
complex64: np.dtype[np.complex64]
|
||||
complex128: np.dtype[np.complex128]
|
||||
|
||||
class _DTypesNumber(_DTypesInteger, _DTypesFloat, _DTypesComplex):
|
||||
...
|
||||
|
||||
class _DTypes(_DTypesBool, _DTypesNumber):
|
||||
...
|
||||
|
||||
class _DTypesUnion(TypedDict, total=False):
|
||||
bool: np.dtype[np.bool]
|
||||
int8: np.dtype[np.int8]
|
||||
int16: np.dtype[np.int16]
|
||||
int32: np.dtype[np.int32]
|
||||
int64: np.dtype[np.int64]
|
||||
uint8: np.dtype[np.uint8]
|
||||
uint16: np.dtype[np.uint16]
|
||||
uint32: np.dtype[np.uint32]
|
||||
uint64: np.dtype[np.uint64]
|
||||
float32: np.dtype[np.float32]
|
||||
float64: np.dtype[np.float64]
|
||||
complex64: np.dtype[np.complex64]
|
||||
complex128: np.dtype[np.complex128]
|
||||
|
||||
_EmptyDict: TypeAlias = dict[Never, Never]
|
||||
|
||||
|
||||
@final
|
||||
class __array_namespace_info__:
|
||||
__module__: ClassVar[Literal['numpy']]
|
||||
|
||||
def capabilities(self) -> _Capabilities: ...
|
||||
def default_device(self) -> _Device: ...
|
||||
def default_dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
) -> _DefaultDTypes: ...
|
||||
def devices(self) -> list[_Device]: ...
|
||||
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: None = ...,
|
||||
) -> _DTypes: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: _Permute1[_KindBool],
|
||||
) -> _DTypesBool: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: _Permute1[_KindInt],
|
||||
) -> _DTypesInt: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: _Permute1[_KindUInt],
|
||||
) -> _DTypesUInt: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: _Permute1[_KindFloat],
|
||||
) -> _DTypesFloat: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: _Permute1[_KindComplex],
|
||||
) -> _DTypesComplex: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: (
|
||||
_Permute1[_KindInteger]
|
||||
| _Permute2[_KindInt, _KindUInt]
|
||||
),
|
||||
) -> _DTypesInteger: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: (
|
||||
_Permute1[_KindNumber]
|
||||
| _Permute3[_KindInteger, _KindFloat, _KindComplex]
|
||||
),
|
||||
) -> _DTypesNumber: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: tuple[()],
|
||||
) -> _EmptyDict: ...
|
||||
@overload
|
||||
def dtypes(
|
||||
self,
|
||||
*,
|
||||
device: _DeviceLike = ...,
|
||||
kind: tuple[_Kind, ...],
|
||||
) -> _DTypesUnion: ...
|
||||
39
venv/lib/python3.11/site-packages/numpy/_configtool.py
Normal file
39
venv/lib/python3.11/site-packages/numpy/_configtool.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
from .version import __version__
|
||||
from .lib._utils_impl import get_include
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--version",
|
||||
action="version",
|
||||
version=__version__,
|
||||
help="Print the version and exit.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--cflags",
|
||||
action="store_true",
|
||||
help="Compile flag needed when using the NumPy headers.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--pkgconfigdir",
|
||||
action="store_true",
|
||||
help=("Print the pkgconfig directory in which `numpy.pc` is stored "
|
||||
"(useful for setting $PKG_CONFIG_PATH)."),
|
||||
)
|
||||
args = parser.parse_args()
|
||||
if not sys.argv[1:]:
|
||||
parser.print_help()
|
||||
if args.cflags:
|
||||
print("-I" + get_include())
|
||||
if args.pkgconfigdir:
|
||||
_path = Path(get_include()) / '..' / 'lib' / 'pkgconfig'
|
||||
print(_path.resolve())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
180
venv/lib/python3.11/site-packages/numpy/_core/__init__.py
Normal file
180
venv/lib/python3.11/site-packages/numpy/_core/__init__.py
Normal file
@@ -0,0 +1,180 @@
|
||||
"""
|
||||
Contains the core of NumPy: ndarray, ufuncs, dtypes, etc.
|
||||
|
||||
Please note that this module is private. All functions and objects
|
||||
are available in the main ``numpy`` namespace - use that instead.
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from numpy.version import version as __version__
|
||||
|
||||
|
||||
# disables OpenBLAS affinity setting of the main thread that limits
|
||||
# python threads or processes to one core
|
||||
env_added = []
|
||||
for envkey in ['OPENBLAS_MAIN_FREE', 'GOTOBLAS_MAIN_FREE']:
|
||||
if envkey not in os.environ:
|
||||
os.environ[envkey] = '1'
|
||||
env_added.append(envkey)
|
||||
|
||||
try:
|
||||
from . import multiarray
|
||||
except ImportError as exc:
|
||||
import sys
|
||||
msg = """
|
||||
|
||||
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
|
||||
|
||||
Importing the numpy C-extensions failed. This error can happen for
|
||||
many reasons, often due to issues with your setup or how NumPy was
|
||||
installed.
|
||||
|
||||
We have compiled some common reasons and troubleshooting tips at:
|
||||
|
||||
https://numpy.org/devdocs/user/troubleshooting-importerror.html
|
||||
|
||||
Please note and check the following:
|
||||
|
||||
* The Python version is: Python%d.%d from "%s"
|
||||
* The NumPy version is: "%s"
|
||||
|
||||
and make sure that they are the versions you expect.
|
||||
Please carefully study the documentation linked above for further help.
|
||||
|
||||
Original error was: %s
|
||||
""" % (sys.version_info[0], sys.version_info[1], sys.executable,
|
||||
__version__, exc)
|
||||
raise ImportError(msg)
|
||||
finally:
|
||||
for envkey in env_added:
|
||||
del os.environ[envkey]
|
||||
del envkey
|
||||
del env_added
|
||||
del os
|
||||
|
||||
from . import umath
|
||||
|
||||
# Check that multiarray,umath are pure python modules wrapping
|
||||
# _multiarray_umath and not either of the old c-extension modules
|
||||
if not (hasattr(multiarray, '_multiarray_umath') and
|
||||
hasattr(umath, '_multiarray_umath')):
|
||||
import sys
|
||||
path = sys.modules['numpy'].__path__
|
||||
msg = ("Something is wrong with the numpy installation. "
|
||||
"While importing we detected an older version of "
|
||||
"numpy in {}. One method of fixing this is to repeatedly uninstall "
|
||||
"numpy until none is found, then reinstall this version.")
|
||||
raise ImportError(msg.format(path))
|
||||
|
||||
from . import numerictypes as nt
|
||||
from .numerictypes import sctypes, sctypeDict
|
||||
multiarray.set_typeDict(nt.sctypeDict)
|
||||
from . import numeric
|
||||
from .numeric import *
|
||||
from . import fromnumeric
|
||||
from .fromnumeric import *
|
||||
from .records import record, recarray
|
||||
# Note: module name memmap is overwritten by a class with same name
|
||||
from .memmap import *
|
||||
from . import function_base
|
||||
from .function_base import *
|
||||
from . import _machar
|
||||
from . import getlimits
|
||||
from .getlimits import *
|
||||
from . import shape_base
|
||||
from .shape_base import *
|
||||
from . import einsumfunc
|
||||
from .einsumfunc import *
|
||||
del nt
|
||||
|
||||
from .numeric import absolute as abs
|
||||
|
||||
# do this after everything else, to minimize the chance of this misleadingly
|
||||
# appearing in an import-time traceback
|
||||
from . import _add_newdocs
|
||||
from . import _add_newdocs_scalars
|
||||
# add these for module-freeze analysis (like PyInstaller)
|
||||
from . import _dtype_ctypes
|
||||
from . import _internal
|
||||
from . import _dtype
|
||||
from . import _methods
|
||||
|
||||
acos = numeric.arccos
|
||||
acosh = numeric.arccosh
|
||||
asin = numeric.arcsin
|
||||
asinh = numeric.arcsinh
|
||||
atan = numeric.arctan
|
||||
atanh = numeric.arctanh
|
||||
atan2 = numeric.arctan2
|
||||
concat = numeric.concatenate
|
||||
bitwise_left_shift = numeric.left_shift
|
||||
bitwise_invert = numeric.invert
|
||||
bitwise_right_shift = numeric.right_shift
|
||||
permute_dims = numeric.transpose
|
||||
pow = numeric.power
|
||||
|
||||
__all__ = [
|
||||
"abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "atan2",
|
||||
"bitwise_invert", "bitwise_left_shift", "bitwise_right_shift", "concat",
|
||||
"pow", "permute_dims", "memmap", "sctypeDict", "record", "recarray"
|
||||
]
|
||||
__all__ += numeric.__all__
|
||||
__all__ += function_base.__all__
|
||||
__all__ += getlimits.__all__
|
||||
__all__ += shape_base.__all__
|
||||
__all__ += einsumfunc.__all__
|
||||
|
||||
|
||||
def _ufunc_reduce(func):
|
||||
# Report the `__name__`. pickle will try to find the module. Note that
|
||||
# pickle supports for this `__name__` to be a `__qualname__`. It may
|
||||
# make sense to add a `__qualname__` to ufuncs, to allow this more
|
||||
# explicitly (Numba has ufuncs as attributes).
|
||||
# See also: https://github.com/dask/distributed/issues/3450
|
||||
return func.__name__
|
||||
|
||||
|
||||
def _DType_reconstruct(scalar_type):
|
||||
# This is a work-around to pickle type(np.dtype(np.float64)), etc.
|
||||
# and it should eventually be replaced with a better solution, e.g. when
|
||||
# DTypes become HeapTypes.
|
||||
return type(dtype(scalar_type))
|
||||
|
||||
|
||||
def _DType_reduce(DType):
|
||||
# As types/classes, most DTypes can simply be pickled by their name:
|
||||
if not DType._legacy or DType.__module__ == "numpy.dtypes":
|
||||
return DType.__name__
|
||||
|
||||
# However, user defined legacy dtypes (like rational) do not end up in
|
||||
# `numpy.dtypes` as module and do not have a public class at all.
|
||||
# For these, we pickle them by reconstructing them from the scalar type:
|
||||
scalar_type = DType.type
|
||||
return _DType_reconstruct, (scalar_type,)
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
# Deprecated 2022-11-22, NumPy 1.25.
|
||||
if name == "MachAr":
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"The `np._core.MachAr` is considered private API (NumPy 1.24)",
|
||||
DeprecationWarning, stacklevel=2,
|
||||
)
|
||||
return _machar.MachAr
|
||||
raise AttributeError(f"Module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
|
||||
import copyreg
|
||||
|
||||
copyreg.pickle(ufunc, _ufunc_reduce)
|
||||
copyreg.pickle(type(dtype), _DType_reduce, _DType_reconstruct)
|
||||
|
||||
# Unclutter namespace (must keep _*_reconstruct for unpickling)
|
||||
del copyreg, _ufunc_reduce, _DType_reduce
|
||||
|
||||
from numpy._pytesttester import PytestTester
|
||||
test = PytestTester(__name__)
|
||||
del PytestTester
|
||||
@@ -0,0 +1,2 @@
|
||||
# NOTE: The `np._core` namespace is deliberately kept empty due to it
|
||||
# being private
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user