resurection
This commit is contained in:
parent
38355d2442
commit
3ee74bcbfa
9090 changed files with 1065 additions and 1225734 deletions
41
.envrc
41
.envrc
|
|
@ -1,41 +0,0 @@
|
|||
#!/bin/bash
|
||||
# shortcut for creating new virtual environments
|
||||
venvnew() {
|
||||
python3 -m venv .venv --prompt $(basename $PWD)
|
||||
source .venv/bin/activate
|
||||
|
||||
python3 -m pip install pip --upgrade
|
||||
|
||||
if [ -d "src" ]; then
|
||||
pip install -e "src[all]" || \
|
||||
pip install -e "src[dev]" || \
|
||||
pip install -e "src"
|
||||
elif [[ -f "setup.py" ]]; then
|
||||
pip install -e .
|
||||
elif [[ -f "requirements.txt" ]]; then
|
||||
pip install pre-commit
|
||||
pre-commit install
|
||||
fi
|
||||
|
||||
if [[ -f ".pre-commit-config.yaml" ]]; then
|
||||
pip install pre-commit
|
||||
pre-commit install
|
||||
fi
|
||||
|
||||
pip show kedro > /dev/null 2>&1 && pip install kedro-lsp
|
||||
|
||||
pip install \
|
||||
black \
|
||||
flake8 \
|
||||
ipython \
|
||||
isort \
|
||||
lolcat \
|
||||
mypy \
|
||||
pyflyby \
|
||||
rich \
|
||||
rope
|
||||
}
|
||||
|
||||
source .venv/bin/activate > /dev/null 2>&1 || venvnew
|
||||
|
||||
echo $(basename $PWD) | lolcat
|
||||
959
.gitignore
vendored
Normal file
959
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,959 @@
|
|||
# Created by https://www.toptal.com/developers/gitignore/api/vim,node,data,emacs,python,pycharm,executable,sublimetext,visualstudio,visualstudiocode
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,node,data,emacs,python,pycharm,executable,sublimetext,visualstudio,visualstudiocode
|
||||
|
||||
### Data ###
|
||||
*.csv
|
||||
*.dat
|
||||
*.efx
|
||||
*.gbr
|
||||
*.key
|
||||
*.pps
|
||||
*.ppt
|
||||
*.pptx
|
||||
*.sdf
|
||||
*.tax2010
|
||||
*.vcf
|
||||
*.xml
|
||||
|
||||
### Emacs ###
|
||||
# -*- mode: gitignore; -*-
|
||||
*~
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
auto-save-list
|
||||
tramp
|
||||
.\#*
|
||||
|
||||
# Org-mode
|
||||
.org-id-locations
|
||||
*_archive
|
||||
|
||||
# flymake-mode
|
||||
*_flymake.*
|
||||
|
||||
# eshell files
|
||||
/eshell/history
|
||||
/eshell/lastdir
|
||||
|
||||
# elpa packages
|
||||
/elpa/
|
||||
|
||||
# reftex files
|
||||
*.rel
|
||||
|
||||
# AUCTeX auto folder
|
||||
/auto/
|
||||
|
||||
# cask packages
|
||||
.cask/
|
||||
dist/
|
||||
|
||||
# Flycheck
|
||||
flycheck_*.el
|
||||
|
||||
# server auth directory
|
||||
/server/
|
||||
|
||||
# projectiles files
|
||||
.projectile
|
||||
|
||||
# directory configuration
|
||||
.dir-locals.el
|
||||
|
||||
# network security
|
||||
/network-security.data
|
||||
|
||||
|
||||
### Executable ###
|
||||
*.app
|
||||
*.bat
|
||||
*.cgi
|
||||
*.com
|
||||
*.exe
|
||||
*.gadget
|
||||
*.jar
|
||||
*.pif
|
||||
*.vb
|
||||
*.wsf
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
### Node Patch ###
|
||||
# Serverless Webpack directories
|
||||
.webpack/
|
||||
|
||||
# Optional stylelint cache
|
||||
|
||||
# SvelteKit build / generate output
|
||||
.svelte-kit
|
||||
|
||||
### PyCharm ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### PyCharm Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||
.idea/**/sonarlint/
|
||||
|
||||
# SonarQube Plugin
|
||||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||
.idea/**/sonarIssues.xml
|
||||
|
||||
# Markdown Navigator plugin
|
||||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||
.idea/**/markdown-navigator.xml
|
||||
.idea/**/markdown-navigator-enh.xml
|
||||
.idea/**/markdown-navigator/
|
||||
|
||||
# Cache file creation bug
|
||||
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||
.idea/$CACHE_FILE$
|
||||
|
||||
# CodeStream plugin
|
||||
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||
.idea/codestream.xml
|
||||
|
||||
# Azure Toolkit for IntelliJ plugin
|
||||
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
|
||||
.idea/**/azureSettings.xml
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
### Python Patch ###
|
||||
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
||||
poetry.toml
|
||||
|
||||
|
||||
### SublimeText ###
|
||||
# Cache files for Sublime Text
|
||||
*.tmlanguage.cache
|
||||
*.tmPreferences.cache
|
||||
*.stTheme.cache
|
||||
|
||||
# Workspace files are user-specific
|
||||
*.sublime-workspace
|
||||
|
||||
# Project files should be checked into the repository, unless a significant
|
||||
# proportion of contributors will probably not be using Sublime Text
|
||||
# *.sublime-project
|
||||
|
||||
# SFTP configuration file
|
||||
sftp-config.json
|
||||
sftp-config-alt*.json
|
||||
|
||||
# Package control specific files
|
||||
Package Control.last-run
|
||||
Package Control.ca-list
|
||||
Package Control.ca-bundle
|
||||
Package Control.system-ca-bundle
|
||||
Package Control.cache/
|
||||
Package Control.ca-certs/
|
||||
Package Control.merged-ca-bundle
|
||||
Package Control.user-ca-bundle
|
||||
oscrypto-ca-bundle.crt
|
||||
bh_unicode_properties.cache
|
||||
|
||||
# Sublime-github package stores a github token in this file
|
||||
# https://packagecontrol.io/packages/sublime-github
|
||||
GitHub.sublime-settings
|
||||
|
||||
### Vim ###
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
!*.svg # comment out if you don't need vector files
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Built Visual Studio Code Extensions
|
||||
*.vsix
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
### VisualStudio ###
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
### VisualStudio Patch ###
|
||||
# Additional files built by Visual Studio
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/vim,node,data,emacs,python,pycharm,executable,sublimetext,visualstudio,visualstudiocode
|
||||
|
|
@ -1,241 +0,0 @@
|
|||
<#
|
||||
.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 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 virutal 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
|
||||
}
|
||||
}
|
||||
|
||||
# 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"
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
# 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
|
||||
fi
|
||||
|
||||
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
||||
PS1="${_OLD_VIRTUAL_PS1:-}"
|
||||
export PS1
|
||||
unset _OLD_VIRTUAL_PS1
|
||||
fi
|
||||
|
||||
unset VIRTUAL_ENV
|
||||
if [ ! "${1:-}" = "nondestructive" ] ; then
|
||||
# Self destruct!
|
||||
unset -f deactivate
|
||||
fi
|
||||
}
|
||||
|
||||
# unset irrelevant variables
|
||||
deactivate nondestructive
|
||||
|
||||
VIRTUAL_ENV="/home/walkers/git/creeper-adventure/.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:-}"
|
||||
if [ "x(creeper-adventure) " != x ] ; then
|
||||
PS1="(creeper-adventure) ${PS1:-}"
|
||||
else
|
||||
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
|
||||
# special case for Aspen magic directories
|
||||
# see https://aspen.io/
|
||||
PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
|
||||
else
|
||||
PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
|
||||
fi
|
||||
fi
|
||||
export PS1
|
||||
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
|
||||
fi
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
# 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; test "\!:*" != "nondestructive" && unalias deactivate'
|
||||
|
||||
# Unset irrelevant variables.
|
||||
deactivate nondestructive
|
||||
|
||||
setenv VIRTUAL_ENV "/home/walkers/git/creeper-adventure/.venv"
|
||||
|
||||
set _OLD_VIRTUAL_PATH="$PATH"
|
||||
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
|
||||
|
||||
|
||||
set _OLD_VIRTUAL_PROMPT="$prompt"
|
||||
|
||||
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
|
||||
if (".venv" != "") then
|
||||
set env_name = ".venv"
|
||||
else
|
||||
if (`basename "VIRTUAL_ENV"` == "__") then
|
||||
# special case for Aspen magic directories
|
||||
# see https://aspen.io/
|
||||
set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
|
||||
else
|
||||
set env_name = `basename "$VIRTUAL_ENV"`
|
||||
endif
|
||||
endif
|
||||
set prompt = "[$env_name] $prompt"
|
||||
unset env_name
|
||||
endif
|
||||
|
||||
alias pydoc python -m pydoc
|
||||
|
||||
rehash
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
|
||||
# you cannot run it directly
|
||||
|
||||
function deactivate -d "Exit virtualenv 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"
|
||||
functions -e fish_prompt
|
||||
set -e _OLD_FISH_PROMPT_OVERRIDE
|
||||
functions -c _old_fish_prompt fish_prompt
|
||||
functions -e _old_fish_prompt
|
||||
end
|
||||
|
||||
set -e VIRTUAL_ENV
|
||||
if test "$argv[1]" != "nondestructive"
|
||||
# Self destruct!
|
||||
functions -e deactivate
|
||||
end
|
||||
end
|
||||
|
||||
# unset irrelevant variables
|
||||
deactivate nondestructive
|
||||
|
||||
set -gx VIRTUAL_ENV "/home/walkers/git/creeper-adventure/.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
|
||||
|
||||
# Prompt override?
|
||||
if test -n "(creeper-adventure) "
|
||||
printf "%s%s" "(creeper-adventure) " (set_color normal)
|
||||
else
|
||||
# ...Otherwise, prepend env
|
||||
set -l _checkbase (basename "$VIRTUAL_ENV")
|
||||
if test $_checkbase = "__"
|
||||
# special case for Aspen magic directories
|
||||
# see https://aspen.io/
|
||||
printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal)
|
||||
else
|
||||
printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal)
|
||||
end
|
||||
end
|
||||
|
||||
# Restore the return status of the previous command.
|
||||
echo "exit $old_status" | .
|
||||
_old_fish_prompt
|
||||
end
|
||||
|
||||
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
|
||||
end
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from black import patched_main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(patched_main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from blackd import patched_main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(patched_main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from commonmark.cmark import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
collect-exports module1 module2...
|
||||
|
||||
Collect all exports in the specified modules and generate "from foo import
|
||||
..." lines for public members defined in those modules.
|
||||
|
||||
Print the result to stdout.
|
||||
|
||||
"""
|
||||
|
||||
# pyflyby/collect-exports
|
||||
# Copyright (C) 2011, 2012, 2013, 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
from pyflyby._cmdline import hfmt, parse_args
|
||||
from pyflyby._importdb import ImportDB
|
||||
from pyflyby._log import logger
|
||||
from pyflyby._modules import ModuleHandle
|
||||
|
||||
|
||||
def main():
|
||||
def addopts(parser):
|
||||
parser.add_option("--ignore-known", default=False, action='store_true',
|
||||
help=hfmt('''
|
||||
Don't list imports already in the
|
||||
known-imports database.'''))
|
||||
parser.add_option("--no-ignore-known", dest="ignore_known",
|
||||
action='store_false',
|
||||
help=hfmt('''
|
||||
(Default) List all imports, including those
|
||||
already in the known-imports database.'''))
|
||||
parser.add_option("--expand-known", default=False, action='store_true',
|
||||
help=hfmt('''
|
||||
Scan all modules mentioned in known-imports
|
||||
database.'''))
|
||||
parser.add_option("--no-expand-known", dest="expand_known",
|
||||
action='store_false',
|
||||
help=hfmt('''
|
||||
(Default) Scan only modules listed explicitly
|
||||
on the command line.'''))
|
||||
options, args = parse_args(addopts, import_format_params=True)
|
||||
if options.expand_known:
|
||||
db = ImportDB.get_default(".")
|
||||
known = db.known_imports.imports
|
||||
args += sorted(set(
|
||||
[_f for _f in [i.split.module_name for i in known] if _f]))
|
||||
bad_module_names = []
|
||||
for module_name in args:
|
||||
module = ModuleHandle(module_name)
|
||||
try:
|
||||
imports = module.exports
|
||||
except Exception as e:
|
||||
logger.warning("couldn't get exports for %s; ignoring: %s: %s",
|
||||
module, type(e).__name__, e)
|
||||
bad_module_names.append(module_name)
|
||||
continue
|
||||
if not imports:
|
||||
continue
|
||||
if options.ignore_known:
|
||||
db = ImportDB.get_default(module.__file__)
|
||||
imports = imports.without_imports(db)
|
||||
sys.stdout.write(imports.pretty_print(
|
||||
allow_conflicts=True, params=options.params))
|
||||
if bad_module_names:
|
||||
print("collect-exports: there were problems with: %s" % (
|
||||
' '.join(bad_module_names)), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
collect-imports *.py
|
||||
collect-imports < foo.py
|
||||
|
||||
Collect all imports from named files or stdin, and combine them into a single
|
||||
block of import statements. Print the result to stdout.
|
||||
|
||||
"""
|
||||
# pyflyby/collect-imports
|
||||
# Copyright (C) 2011, 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
from pyflyby._cmdline import filename_args, hfmt, parse_args
|
||||
from pyflyby._importclns import ImportSet
|
||||
from pyflyby._importdb import ImportDB
|
||||
|
||||
|
||||
def main():
|
||||
def addopts(parser):
|
||||
parser.add_option("--ignore-known", default=False, action='store_true',
|
||||
help=hfmt('''
|
||||
Don't list imports already in the
|
||||
known-imports database.'''))
|
||||
parser.add_option("--no-ignore-known", dest="ignore_known",
|
||||
action='store_false',
|
||||
help=hfmt('''
|
||||
(Default) List all imports, including those
|
||||
already in the known-imports database.'''))
|
||||
parser.add_option("--include",
|
||||
default=[], action="append",
|
||||
help=hfmt('''
|
||||
Include only imports under the given package.'''))
|
||||
options, args = parse_args(addopts, import_format_params=True)
|
||||
filenames = filename_args(args)
|
||||
importset = ImportSet(filenames, ignore_nonimports=True)
|
||||
if options.include:
|
||||
regexps = [
|
||||
re.escape(prefix) if prefix.endswith(".") else
|
||||
re.escape(prefix) + "([.]|$)"
|
||||
for prefix in options.include
|
||||
]
|
||||
regexp = re.compile("|".join(regexps))
|
||||
match = lambda imp: regexp.match(imp.fullname)
|
||||
importset = ImportSet([imp for imp in importset if match(imp)])
|
||||
if options.ignore_known:
|
||||
db = ImportDB.get_default(".")
|
||||
importset = importset.without_imports(db.known_imports)
|
||||
sys.stdout.write(importset.pretty_print(
|
||||
allow_conflicts=True, params=options.params))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from mypy.dmypy.client import console_entry
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(console_entry())
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
Usage: find-import names...
|
||||
|
||||
Prints how to import given name(s).
|
||||
"""
|
||||
# pyflyby/find-import
|
||||
# Copyright (C) 2011, 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
from __future__ import print_function
|
||||
|
||||
from pyflyby._cmdline import parse_args, syntax
|
||||
from pyflyby._importdb import ImportDB
|
||||
from pyflyby._log import logger
|
||||
|
||||
|
||||
def main():
|
||||
options, args = parse_args(import_format_params=True)
|
||||
if not args:
|
||||
syntax()
|
||||
db = ImportDB.get_default(".")
|
||||
known = db.known_imports.by_import_as
|
||||
errors = 0
|
||||
for arg in args:
|
||||
try:
|
||||
imports = known[arg]
|
||||
except KeyError:
|
||||
errors += 1
|
||||
logger.error("Can't find import for %r", arg)
|
||||
else:
|
||||
for imp in imports:
|
||||
print(imp.pretty_print(params=options.params), end=' ')
|
||||
if errors:
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from flake8.main.cli import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from identify.cli import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from IPython import start_ipython
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(start_ipython())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from IPython import start_ipython
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(start_ipython())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from isort.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from isort.main import identify_imports_main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(identify_imports_main())
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
Usage: list-bad-xrefs modules... filenames...
|
||||
|
||||
Prints the bad docstring cross-references in the given modules.
|
||||
|
||||
Similar to running C{epydoc -v}, but:
|
||||
- The output is organized so that it is easy to identify the code needing
|
||||
fixing.
|
||||
- If a cross-reference is to an external module, its references are included
|
||||
automatically.
|
||||
"""
|
||||
# pyflyby/list-bad-xrefs
|
||||
# Copyright (C) 2011, 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
from __future__ import print_function
|
||||
|
||||
from pyflyby._cmdline import parse_args, syntax
|
||||
from pyflyby._docxref import find_bad_doc_cross_references
|
||||
|
||||
|
||||
def main():
|
||||
options, args = parse_args()
|
||||
if not args:
|
||||
syntax()
|
||||
for rec in find_bad_doc_cross_references(args):
|
||||
module, linenos, container_name, identifier = rec
|
||||
for lineno in linenos or ["?"]:
|
||||
print("%s:%s: undefined docstring cross-reference in %s: %s" % (
|
||||
module.filename, lineno, container_name, identifier))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
242
.venv/bin/lolcat
242
.venv/bin/lolcat
|
|
@ -1,242 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
#
|
||||
# "THE BEER-WARE LICENSE" (Revision 43~maze)
|
||||
#
|
||||
# <maze@pyth0n.org> wrote these files. As long as you retain this notice you
|
||||
# can do whatever you want with this stuff. If we meet some day, and you think
|
||||
# this stuff is worth it, you can buy me a beer in return.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import atexit
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from signal import signal, SIGPIPE, SIG_DFL
|
||||
|
||||
PY3 = sys.version_info >= (3,)
|
||||
|
||||
# override default handler so no exceptions on SIGPIPE
|
||||
signal(SIGPIPE, SIG_DFL)
|
||||
|
||||
# Reset terminal colors at exit
|
||||
def reset():
|
||||
sys.stdout.write('\x1b[0m')
|
||||
sys.stdout.flush()
|
||||
|
||||
atexit.register(reset)
|
||||
|
||||
|
||||
STRIP_ANSI = re.compile(r'\x1b\[(\d+)(;\d+)?(;\d+)?[m|K]')
|
||||
COLOR_ANSI = (
|
||||
(0x00, 0x00, 0x00), (0xcd, 0x00, 0x00),
|
||||
(0x00, 0xcd, 0x00), (0xcd, 0xcd, 0x00),
|
||||
(0x00, 0x00, 0xee), (0xcd, 0x00, 0xcd),
|
||||
(0x00, 0xcd, 0xcd), (0xe5, 0xe5, 0xe5),
|
||||
(0x7f, 0x7f, 0x7f), (0xff, 0x00, 0x00),
|
||||
(0x00, 0xff, 0x00), (0xff, 0xff, 0x00),
|
||||
(0x5c, 0x5c, 0xff), (0xff, 0x00, 0xff),
|
||||
(0x00, 0xff, 0xff), (0xff, 0xff, 0xff),
|
||||
)
|
||||
|
||||
|
||||
class stdoutWin():
|
||||
def __init__(self):
|
||||
self.output = sys.stdout
|
||||
self.string = ''
|
||||
self.i = 0
|
||||
|
||||
def isatty(self):
|
||||
return self.output.isatty()
|
||||
|
||||
def write(self,s):
|
||||
self.string = self.string + s
|
||||
|
||||
def flush(self):
|
||||
return self.output.flush()
|
||||
|
||||
def prints(self):
|
||||
string = 'echo|set /p="%s"' %(self.string)
|
||||
os.system(string)
|
||||
self.i += 1
|
||||
self.string = ''
|
||||
|
||||
def println(self):
|
||||
print()
|
||||
self.prints()
|
||||
|
||||
|
||||
class LolCat(object):
|
||||
def __init__(self, mode=256, output=sys.stdout):
|
||||
self.mode =mode
|
||||
self.output = output
|
||||
|
||||
def _distance(self, rgb1, rgb2):
|
||||
return sum(map(lambda c: (c[0] - c[1]) ** 2,
|
||||
zip(rgb1, rgb2)))
|
||||
|
||||
def ansi(self, rgb):
|
||||
r, g, b = rgb
|
||||
|
||||
if self.mode in (8, 16):
|
||||
colors = COLOR_ANSI[:self.mode]
|
||||
matches = [(self._distance(c, map(int, rgb)), i) for i, c in enumerate(colors)]
|
||||
matches.sort()
|
||||
color = matches[0][1]
|
||||
|
||||
return '3%d' % (color,)
|
||||
else:
|
||||
gray_possible = True
|
||||
sep = 2.5
|
||||
|
||||
while gray_possible:
|
||||
if r < sep or g < sep or b < sep:
|
||||
gray = r < sep and g < sep and b < sep
|
||||
gray_possible = False
|
||||
|
||||
sep += 42.5
|
||||
|
||||
if gray:
|
||||
color = 232 + int(float(sum(rgb) / 33.0))
|
||||
else:
|
||||
color = sum([16]+[int(6 * float(val)/256) * mod
|
||||
for val, mod in zip(rgb, [36, 6, 1])])
|
||||
|
||||
return '38;5;%d' % (color,)
|
||||
|
||||
def wrap(self, *codes):
|
||||
return '\x1b[%sm' % (''.join(codes),)
|
||||
|
||||
def rainbow(self, freq, i):
|
||||
r = math.sin(freq * i) * 127 + 128
|
||||
g = math.sin(freq * i + 2 * math.pi / 3) * 127 + 128
|
||||
b = math.sin(freq * i + 4 * math.pi / 3) * 127 + 128
|
||||
return [r, g, b]
|
||||
|
||||
def cat(self, fd, options):
|
||||
if options.animate:
|
||||
self.output.write('\x1b[?25l')
|
||||
|
||||
for line in fd:
|
||||
options.os += 1
|
||||
self.println(line, options)
|
||||
|
||||
if options.animate:
|
||||
self.output.write('\x1b[?25h')
|
||||
|
||||
def println(self, s, options):
|
||||
s = s.rstrip()
|
||||
if options.force or self.output.isatty():
|
||||
s = STRIP_ANSI.sub('', s)
|
||||
|
||||
if options.animate:
|
||||
self.println_ani(s, options)
|
||||
else:
|
||||
self.println_plain(s, options)
|
||||
|
||||
self.output.write('\n')
|
||||
self.output.flush()
|
||||
if os.name == 'nt':
|
||||
self.output.println()
|
||||
|
||||
def println_ani(self, s, options):
|
||||
if not s:
|
||||
return
|
||||
|
||||
for i in range(1, options.duration):
|
||||
self.output.write('\x1b[%dD' % (len(s),))
|
||||
self.output.flush()
|
||||
options.os += options.spread
|
||||
self.println_plain(s, options)
|
||||
time.sleep(1.0 / options.speed)
|
||||
|
||||
def println_plain(self, s, options):
|
||||
for i, c in enumerate(s if PY3 else s.decode(options.charset_py2, 'replace')):
|
||||
rgb = self.rainbow(options.freq, options.os + i / options.spread)
|
||||
self.output.write(''.join([
|
||||
self.wrap(self.ansi(rgb)),
|
||||
c if PY3 else c.encode(options.charset_py2, 'replace'),
|
||||
]))
|
||||
if os.name == 'nt':
|
||||
self.output.print()
|
||||
|
||||
|
||||
def detect_mode(term_hint='xterm-256color'):
|
||||
'''
|
||||
Poor-mans color mode detection.
|
||||
'''
|
||||
if 'ANSICON' in os.environ:
|
||||
return 16
|
||||
elif os.environ.get('ConEmuANSI', 'OFF') == 'ON':
|
||||
return 256
|
||||
else:
|
||||
term = os.environ.get('TERM', term_hint)
|
||||
if term.endswith('-256color') or term in ('xterm', 'screen'):
|
||||
return 256
|
||||
elif term.endswith('-color') or term in ('rxvt',):
|
||||
return 16
|
||||
else:
|
||||
return 256 # optimistic default
|
||||
|
||||
|
||||
def run():
|
||||
"""Main entry point."""
|
||||
import optparse
|
||||
|
||||
parser = optparse.OptionParser(usage=r'%prog [<options>] [file ...]')
|
||||
parser.add_option('-p', '--spread', type='float', default=3.0,
|
||||
help='Rainbow spread')
|
||||
parser.add_option('-F', '--freq', type='float', default=0.1,
|
||||
help='Rainbow frequency')
|
||||
parser.add_option('-S', '--seed', type='int', default=0,
|
||||
help='Rainbow seed')
|
||||
parser.add_option('-a', '--animate', action='store_true', default=False,
|
||||
help='Enable psychedelics')
|
||||
parser.add_option('-d', '--duration', type='int', default=12,
|
||||
help='Animation duration')
|
||||
parser.add_option('-s', '--speed', type='float', default=20.0,
|
||||
help='Animation speed')
|
||||
parser.add_option('-f', '--force', action='store_true', default=False,
|
||||
help='Force colour even when stdout is not a tty')
|
||||
|
||||
parser.add_option('-3', action='store_const', dest='mode', const=8,
|
||||
help='Force 3 bit colour mode')
|
||||
parser.add_option('-4', action='store_const', dest='mode', const=16,
|
||||
help='Force 4 bit colour mode')
|
||||
parser.add_option('-8', action='store_const', dest='mode', const=256,
|
||||
help='Force 8 bit colour mode')
|
||||
|
||||
parser.add_option('-c', '--charset-py2', default='utf-8',
|
||||
help='Manually set a charset to convert from, for python 2.7')
|
||||
|
||||
options, args = parser.parse_args()
|
||||
options.os = random.randint(0, 256) if options.seed == 0 else options.seed
|
||||
options.mode = options.mode or detect_mode()
|
||||
|
||||
if os.name == 'nt':
|
||||
lolcat = LolCat(mode=options.mode,output=stdoutWin())
|
||||
else:
|
||||
lolcat = LolCat(mode=options.mode)
|
||||
|
||||
if not args:
|
||||
args = ['-']
|
||||
|
||||
for filename in args:
|
||||
try:
|
||||
if filename == '-':
|
||||
lolcat.cat(sys.stdin, options)
|
||||
else:
|
||||
with open(filename, 'r', errors='backslashreplace') as handle:
|
||||
lolcat.cat(handle, options)
|
||||
except IOError as error:
|
||||
sys.stderr.write(str(error) + '\n')
|
||||
except KeyboardInterrupt:
|
||||
sys.stderr.write('\n')
|
||||
# exit 130 for terminated-by-ctrl-c, from http://tldp.org/LDP/abs/html/exitcodes.html
|
||||
return 130
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(run())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from mypy.__main__ import console_entry
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(console_entry())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from mypyc.__main__ import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from nodeenv import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.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,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.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,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.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,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pre_commit.main import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pre_commit.clientlib import validate_config_main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(validate_config_main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pre_commit.clientlib import validate_manifest_main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(validate_manifest_main())
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
prune-broken-imports *.py
|
||||
prune-broken-imports < foo.py
|
||||
|
||||
Removes broken imports.
|
||||
|
||||
Note: This actually executes imports.
|
||||
|
||||
If filenames are given on the command line, rewrites them. Otherwise, if
|
||||
stdin is not a tty, read from stdin and write to stdout.
|
||||
|
||||
Only top-level import statements are touched.
|
||||
|
||||
"""
|
||||
# pyflyby/prune-broken-imports
|
||||
# Copyright (C) 2012, 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
|
||||
from pyflyby._cmdline import parse_args, process_actions
|
||||
from pyflyby._imports2s import remove_broken_imports
|
||||
|
||||
|
||||
def main():
|
||||
options, args = parse_args(
|
||||
import_format_params=True, modify_action_params=True)
|
||||
def modify(x):
|
||||
return remove_broken_imports(x, params=options.params)
|
||||
process_actions(args, options.actions, modify)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pyflyby._py import py_main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(py_main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pyflyby._py import py_main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(py_main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pycodestyle import _main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(_main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pyflakes.api import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# License for THIS FILE ONLY: CC0 Public Domain Dedication
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
# Get the directory containing to the symlink target of the script.
|
||||
if script=$(readlink -e "$0" 2>/dev/null) && [[ "$script" -ef "$0" ]]; then
|
||||
scriptdir=$(dirname "$script")
|
||||
elif script=$(realpath "$0" 2>/dev/null) && [[ "$script" -ef "$0" ]]; then
|
||||
scriptdir=$(dirname "$script")
|
||||
elif script=$(greadlink -e "$0" 2>/dev/null) && [[ "$script" -ef "$0" ]]; then
|
||||
scriptdir=$(dirname "$script")
|
||||
else
|
||||
scriptdir=$(
|
||||
d=$(dirname "$0")
|
||||
b=$(basename "$0")
|
||||
cd "$d"
|
||||
if l=$(readlink "$b"); then
|
||||
ld=$(dirname "$l")
|
||||
cd "$ld"
|
||||
fi
|
||||
pwd
|
||||
)
|
||||
fi
|
||||
|
||||
PATH="$scriptdir:$PATH"
|
||||
|
||||
if [[ -t 1 ]] && type -p diff-colorize >/dev/null; then
|
||||
diff -u "$@" | diff-colorize
|
||||
else
|
||||
diff -u "$@"
|
||||
fi
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from pygments.cmdline import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1 +0,0 @@
|
|||
python3
|
||||
|
|
@ -1 +0,0 @@
|
|||
/home/walkers/.pyenv/versions/3.8.12/bin/python3
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
reformat-imports *.py
|
||||
reformat-imports < foo.py
|
||||
|
||||
Reformats the top-level 'import' blocks within the python module/script.
|
||||
|
||||
"""
|
||||
# pyflyby/reformat-imports
|
||||
# Copyright (C) 2011, 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
|
||||
from pyflyby._cmdline import parse_args, process_actions
|
||||
from pyflyby._imports2s import reformat_import_statements
|
||||
|
||||
|
||||
def main():
|
||||
options, args = parse_args(
|
||||
import_format_params=True, modify_action_params=True)
|
||||
def modify(x):
|
||||
return reformat_import_statements(x, params=options.params)
|
||||
process_actions(args, options.actions, modify)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
replace-star-imports *.py
|
||||
replace-star-imports < foo.py
|
||||
|
||||
Replaces::
|
||||
from foo.bar import *
|
||||
with::
|
||||
from foo.bar import (f1, f2, ...)
|
||||
|
||||
Note: This actually executes imports.
|
||||
|
||||
If filenames are given on the command line, rewrites them. Otherwise, if
|
||||
stdin is not a tty, read from stdin and write to stdout.
|
||||
|
||||
Only top-level import statements are touched.
|
||||
|
||||
"""
|
||||
# pyflyby/replace-star-imports
|
||||
# Copyright (C) 2012, 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
|
||||
from pyflyby._cmdline import parse_args, process_actions
|
||||
from pyflyby._imports2s import replace_star_imports
|
||||
|
||||
|
||||
def main():
|
||||
options, args = parse_args(
|
||||
import_format_params=True, modify_action_params=True)
|
||||
def modify(x):
|
||||
return replace_star_imports(x, params=options.params)
|
||||
process_actions(args, options.actions, modify)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from mypy.stubgen import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from mypy.stubtest import main
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(main())
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
tidy-imports *.py
|
||||
tidy-imports < foo.py
|
||||
|
||||
Automatically improves python import statements.
|
||||
|
||||
- Adds missing imports and mandatory imports.
|
||||
- Removes unused imports.
|
||||
- Nicely formats imports (sorts, aligns, wraps).
|
||||
|
||||
If filenames are given on the command line, rewrites them. Otherwise, if
|
||||
stdin is not a tty, read from stdin and write to stdout.
|
||||
|
||||
Only top-level import statements are touched.
|
||||
|
||||
"""
|
||||
|
||||
# pyflyby/tidy-imports
|
||||
# Copyright (C) 2011, 2012, 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
from __future__ import print_function, absolute_import, division, with_statement
|
||||
|
||||
from distutils.spawn import find_executable
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from pyflyby._cmdline import hfmt, parse_args, process_actions
|
||||
from pyflyby._imports2s import (canonicalize_imports,
|
||||
fix_unused_and_missing_imports,
|
||||
replace_star_imports,
|
||||
transform_imports)
|
||||
from pyflyby._log import logger
|
||||
|
||||
|
||||
def main():
|
||||
def addopts(parser):
|
||||
parser.add_option('--add-missing',
|
||||
default=True, action='store_true',
|
||||
help=hfmt('''
|
||||
(Default) Add missing imports.'''))
|
||||
parser.add_option('--no-add-missing', dest='add_missing',
|
||||
default=True, action='store_false',
|
||||
help=hfmt('''
|
||||
Don't add missing imports.'''))
|
||||
parser.add_option('--remove-unused',
|
||||
default="AUTOMATIC", action='store_true',
|
||||
help=hfmt('''
|
||||
Remove unused imports
|
||||
(default unless filename == __init__.py).'''))
|
||||
parser.add_option('--no-remove-unused', dest='remove_unused',
|
||||
action='store_false',
|
||||
help=hfmt('''
|
||||
Don't remove unused imports
|
||||
(default if filename == __init__.py).'''))
|
||||
parser.add_option('--add-mandatory',
|
||||
default=True, action='store_true',
|
||||
help=hfmt('''
|
||||
(Default) Add mandatory imports.'''))
|
||||
parser.add_option('--no-add-mandatory', dest='add_mandatory',
|
||||
default=True, action='store_false',
|
||||
help=hfmt('''
|
||||
Don't add mandatory imports.'''))
|
||||
parser.add_option('--replace-star-imports',
|
||||
default=False, action='store_true',
|
||||
help=hfmt('''
|
||||
Replace 'from foo.bar import *' with full list
|
||||
of imports before removing unused imports.'''))
|
||||
parser.add_option('--no-replace-star-imports',
|
||||
dest='replace_star_imports',
|
||||
action='store_false',
|
||||
help=hfmt('''
|
||||
(Default) Don't replace 'from foo.bar import
|
||||
*'.'''))
|
||||
parser.add_option('--canonicalize',
|
||||
default=True, action='store_true',
|
||||
help=hfmt('''
|
||||
(Default) Replace imports with canonical
|
||||
equivalent imports, according to database.'''))
|
||||
parser.add_option('--no-canonicalize', dest='canonicalize',
|
||||
default=True, action='store_false',
|
||||
help=hfmt('''
|
||||
Don't canonicalize imports.'''))
|
||||
parser.add_option('--py23-fallback', dest='py23_fallback',
|
||||
default=True, action='store_true',
|
||||
help=hfmt('''
|
||||
(Default) Automatically fallback to
|
||||
python2/python3 if the source file has a syntax
|
||||
error.'''))
|
||||
parser.add_option('--no-py23-fallback', dest='py23_fallback',
|
||||
default=True, action='store_false',
|
||||
help=hfmt('''
|
||||
Do not automatically fallback to
|
||||
python2/python3 if the source file has a syntax
|
||||
error.'''))
|
||||
|
||||
|
||||
def transform_callback(option, opt_str, value, group):
|
||||
k, v = value.split("=", 1)
|
||||
group.values.transformations[k] = v
|
||||
parser.add_option("--transform", action='callback',
|
||||
type="string", callback=transform_callback,
|
||||
metavar="OLD=NEW",
|
||||
dest="transformations", default={},
|
||||
help=hfmt('''
|
||||
Replace OLD with NEW in imports.
|
||||
May be specified multiple times.'''))
|
||||
def no_add_callback(option, opt_str, value, group):
|
||||
group.values.add_missing = False
|
||||
group.values.add_mandatory = False
|
||||
parser.add_option('--no-add', action='callback',
|
||||
callback=no_add_callback,
|
||||
help=hfmt('''
|
||||
Equivalent to --no-add-missing
|
||||
--no-add-mandatory.'''))
|
||||
options, args = parse_args(
|
||||
addopts, import_format_params=True, modify_action_params=True)
|
||||
def modify(x):
|
||||
if options.canonicalize:
|
||||
x = canonicalize_imports(x, params=options.params)
|
||||
if options.transformations:
|
||||
x = transform_imports(x, options.transformations,
|
||||
params=options.params)
|
||||
if options.replace_star_imports:
|
||||
x = replace_star_imports(x, params=options.params)
|
||||
return fix_unused_and_missing_imports(
|
||||
x, params=options.params,
|
||||
add_missing=options.add_missing,
|
||||
remove_unused=options.remove_unused,
|
||||
add_mandatory=options.add_mandatory,
|
||||
)
|
||||
|
||||
if options.py23_fallback:
|
||||
try:
|
||||
process_actions(args, options.actions, modify,
|
||||
reraise_exceptions=SyntaxError)
|
||||
except SyntaxError as e:
|
||||
python = 'python2' if sys.version_info[0] == 3 else 'python3'
|
||||
python_full = find_executable(python)
|
||||
if not python_full:
|
||||
logger.error("Fallback failed: could not find %s", python)
|
||||
raise
|
||||
logger.info("SyntaxError detected ({}), falling back to {}".format(
|
||||
e, python))
|
||||
args = [python_full] + sys.argv + ['--no-py23-fallback']
|
||||
try:
|
||||
raise SystemExit(subprocess.call(args))
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
else:
|
||||
process_actions(args, options.actions, modify)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
"""
|
||||
transform-imports --transform aa.bb=xx.yy *.py
|
||||
transform-imports --transform aa.bb=xx.yy < foo.py
|
||||
|
||||
Transforms::
|
||||
from aa.bb.cc import dd, ee
|
||||
from aa import bb
|
||||
to::
|
||||
from xx.yy.cc import dd, ee
|
||||
from xx import yy as bb
|
||||
|
||||
If filenames are given on the command line, rewrites them. Otherwise, if
|
||||
stdin is not a tty, read from stdin and write to stdout.
|
||||
|
||||
"""
|
||||
|
||||
# pyflyby/transform-imports
|
||||
# Copyright (C) 2014 Karl Chen.
|
||||
# License: MIT http://opensource.org/licenses/MIT
|
||||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
|
||||
from pyflyby._cmdline import hfmt, parse_args, process_actions
|
||||
from pyflyby._imports2s import transform_imports
|
||||
|
||||
|
||||
def main():
|
||||
transformations = {}
|
||||
def addopts(parser):
|
||||
def callback(option, opt_str, value, group):
|
||||
k, v = value.split("=", 1)
|
||||
transformations[k] = v
|
||||
parser.add_option("--transform", action='callback',
|
||||
type="string", callback=callback,
|
||||
metavar="OLD=NEW",
|
||||
help=hfmt('''
|
||||
Replace OLD with NEW in imports.
|
||||
May be specified multiple times.'''))
|
||||
options, args = parse_args(
|
||||
addopts, import_format_params=True, modify_action_params=True)
|
||||
def modify(x):
|
||||
return transform_imports(x, transformations, params=options.params)
|
||||
process_actions(args, options.actions, modify)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#!/home/walkers/git/creeper-adventure/.venv/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import re
|
||||
import sys
|
||||
from virtualenv.__main__ import run_with_catch
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(run_with_catch())
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,10 +0,0 @@
|
|||
|
||||
# To make tidy-imports automatically transform imports, create a dictionary
|
||||
# like this:
|
||||
# __canonical_imports__ = {
|
||||
# "oldmodule.oldname": "newmodule.newname"
|
||||
# }
|
||||
#
|
||||
# You can write this in any *.py file in your $PYFLYBY_PATH,
|
||||
# e.g. ~/.pyflyby/canonical.py.
|
||||
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
from Crypto.Cipher import AES
|
||||
import IPython
|
||||
import blist
|
||||
from blist import sorteddict
|
||||
import cssutils
|
||||
import dateutil
|
||||
import dateutil.parser
|
||||
import kerberos
|
||||
import mutagen
|
||||
import perl
|
||||
import pexpect
|
||||
import pstats
|
||||
import pyflyby
|
||||
from pyflyby import xreload
|
||||
import pylab
|
||||
import pyodbc
|
||||
import pysvn
|
||||
import pytest
|
||||
import pytz
|
||||
import requests
|
||||
import sqlalchemy
|
||||
import sqlalchemy.orm
|
||||
import sqlalchemy.sql
|
||||
import sympy
|
||||
import xlrd
|
||||
import yaml
|
||||
from yaml import MarkedYAMLError, YAMLError, YAMLObject
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
# To remove imports from the set of known imports, write, for example:
|
||||
# __forget_imports__ = [
|
||||
# 'numpy.sin',
|
||||
# ]
|
||||
#
|
||||
# You can write this in any *.py file in your $PYFLYBY_PATH,
|
||||
# e.g. ~/.pyflyby/forget.py.
|
||||
#
|
||||
# This can be useful if you're inheriting somebody else's import database.
|
||||
# You can inherit most of the parent database, but exclude certain imports.
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
# The following __mandatory_imports__ line makes tidy-imports add the
|
||||
# mentioned imports to all files.
|
||||
# You can also include imports other than __future__ imports.
|
||||
#
|
||||
# You can write this in any *.py file in your $PYFLYBY_PATH,
|
||||
# e.g. ~/.pyflyby/mandatory.py.
|
||||
|
||||
# __mandatory_imports__ = [
|
||||
# 'from __future__ import absolute_import, division',
|
||||
# ]
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
import matplotlib
|
||||
from matplotlib import pyplot
|
||||
import matplotlib.colors
|
||||
from matplotlib.colors import ColorConverter
|
||||
from matplotlib.font_manager import FontProperties
|
||||
from matplotlib.patches import Rectangle
|
||||
from matplotlib.pyplot import (clf, draw, figure, gca, gcf, grid,
|
||||
ioff, legend, plot, savefig, scatter,
|
||||
show, subplot, title, xlabel, ylabel,
|
||||
ylim)
|
||||
from matplotlib.ticker import (Formatter, Locator, NullFormatter,
|
||||
NullLocator)
|
||||
import numexpr
|
||||
import numpy as np, numpy as npy, numpy
|
||||
from numpy import (Inf, NAN, NaN, abs as aabs, absolute,
|
||||
add, all as aall, allclose, alltrue,
|
||||
amax, amin, angle, any as aany,
|
||||
append as aappend, apply_along_axis,
|
||||
apply_over_axes, arange, arccos,
|
||||
arccosh, arcsin, arcsinh, arctan,
|
||||
arctan2, arctanh, argmax, argmin,
|
||||
argsort, argwhere, around, array,
|
||||
array2string, array_equal, array_equiv,
|
||||
array_repr, array_split, array_str,
|
||||
asanyarray, asarray, asarray_chkfinite,
|
||||
ascontiguousarray, asfarray,
|
||||
asfortranarray, asmatrix, asscalar,
|
||||
atleast_1d, atleast_2d, atleast_3d,
|
||||
average, bartlett, base_repr,
|
||||
binary_repr, bincount, bitwise_and,
|
||||
bitwise_not, bitwise_or, bitwise_xor,
|
||||
blackman, bmat, bool8, bool_,
|
||||
broadcast, broadcast_arrays, byte,
|
||||
byte_bounds, c_, can_cast, cdouble,
|
||||
ceil, cfloat, character, chararray,
|
||||
choose, clip, clongdouble, clongfloat,
|
||||
column_stack, common_type,
|
||||
compare_chararrays, compat, complex128,
|
||||
complex64, complex_, complexfloating,
|
||||
concatenate, conj, conjugate, convolve,
|
||||
copy, copysign, corrcoef, correlate,
|
||||
cos, cosh, cov, cross, csingle,
|
||||
ctypeslib, cumprod, cumproduct, cumsum,
|
||||
deg2rad, degrees, diag, diag_indices,
|
||||
diag_indices_from, diagflat, diagonal,
|
||||
diff, digitize, disp, divide, dot,
|
||||
double, dsplit, dstack, dtype, ediff1d,
|
||||
einsum, emath, empty, empty_like,
|
||||
equal, exp, exp2, expand_dims, expm1,
|
||||
extract, eye, fabs,
|
||||
fastCopyAndTranspose, fill_diagonal,
|
||||
find_common_type, fix, flatiter,
|
||||
flatnonzero, fliplr, flipud, float32,
|
||||
float64, float_, floating, floor,
|
||||
floor_divide, fmax, fmin, fmod, frexp,
|
||||
frombuffer, fromfile, fromfunction,
|
||||
fromiter, frompyfunc, fromregex,
|
||||
fromstring, gradient, greater,
|
||||
greater_equal, hamming, hanning,
|
||||
histogram, histogram2d, histogramdd,
|
||||
hsplit, hstack, hypot, i0, identity,
|
||||
iinfo, imag, in1d, index_exp, indices,
|
||||
inexact, inf, inner, int0, int16,
|
||||
int32, int64, int8, int_, intc,
|
||||
integer, interp, intersect1d, intp,
|
||||
invert, ipmt, irr, iscomplex,
|
||||
iscomplexobj, isfinite, isfortran,
|
||||
isinf, isnan, isneginf, isposinf,
|
||||
isreal, isrealobj, isscalar, issctype,
|
||||
issubclass_, issubdtype, issubsctype,
|
||||
iterable, ix_, kaiser, kron, ldexp,
|
||||
left_shift, less, less_equal, lexsort,
|
||||
linalg, linspace, little_endian,
|
||||
loadtxt, log, log as logarithm, log10,
|
||||
log1p, log2, logaddexp, logaddexp2,
|
||||
logical_and, logical_not, logical_or,
|
||||
logical_xor, logspace, longcomplex,
|
||||
longdouble, longfloat, longlong,
|
||||
mafromtxt, mask_indices, mat, matrix,
|
||||
maximum, mean, median, memmap,
|
||||
meshgrid, mgrid, minimum, mintypecode,
|
||||
mirr, mod, modf, msort, multiply, nan,
|
||||
nan_to_num, nanargmax, nanargmin,
|
||||
nanmax, nanmin, nansum, nbytes,
|
||||
ndarray, ndenumerate, ndim, ndindex,
|
||||
negative, newaxis, newbuffer,
|
||||
nextafter, nonzero, not_equal, nper,
|
||||
npv, number, object0, object_, ogrid,
|
||||
ones, ones_like, outer, packbits, pi,
|
||||
piecewise, pkgload, place, pmt, poly,
|
||||
poly1d, polyadd, polyder, polydiv,
|
||||
polyfit, polyint, polymul, polynomial,
|
||||
polysub, polyval, power, ppmt, prod,
|
||||
product, ptp, putmask, pv, r_, rad2deg,
|
||||
radians, rank, rate, ravel, real,
|
||||
real_if_close, recarray, recfromcsv,
|
||||
recfromtxt, reciprocal, record,
|
||||
remainder, repeat, reshape, resize,
|
||||
restoredot, right_shift, rint, roll,
|
||||
rollaxis, roots, rot90, round, round_,
|
||||
row_stack, s_, searchsorted,
|
||||
select as aselect, setbufsize,
|
||||
setdiff1d, setxor1d, shape, short,
|
||||
show_config, sign, signbit,
|
||||
signedinteger, sin, sinc, single,
|
||||
singlecomplex, sinh, size as asize,
|
||||
sometrue, sort as asort, sort,
|
||||
sort_complex, spacing, split, sqrt,
|
||||
square, squeeze, std, str_, string0,
|
||||
string_, subtract, sum, swapaxes, take,
|
||||
tan, tanh, tensordot, testing, tile,
|
||||
trace, transpose, trapz, tri, tril,
|
||||
tril_indices, tril_indices_from,
|
||||
trim_zeros, triu, triu_indices,
|
||||
triu_indices_from, true_divide, trunc,
|
||||
ubyte, ufunc, uint, uint0, uint16,
|
||||
uint32, uint64, uint8, uintc, uintp,
|
||||
ulonglong, unicode0, unicode_, union1d,
|
||||
unique, unpackbits, unravel_index,
|
||||
unsignedinteger, unwrap, ushort,
|
||||
vander, var, vdot, vectorize, void,
|
||||
void0, vsplit, vstack, where, zeros,
|
||||
zeros_like)
|
||||
from numpy.core.umath_tests import inner1d
|
||||
from numpy.fft import (fft, fft2, fftn, ifft, ifft2, ifftn,
|
||||
irfft, irfft2, irfftn, rfft, rfft2,
|
||||
rfftn)
|
||||
from numpy.lib import recfunctions as recf, recfunctions
|
||||
from numpy.lib.stride_tricks import as_strided
|
||||
import numpy.linalg
|
||||
from numpy.linalg import cholesky, det, eigh, inv, pinv, svd
|
||||
from numpy.random import (normal, rand, randint, randn,
|
||||
random as arandom, shuffle)
|
||||
import numpy.testing
|
||||
import numpy.version
|
||||
import pandas, pandas as pd
|
||||
from pandas import DataFrame, Series, TimeSeries
|
||||
import pylab as pl, pylab
|
||||
import scipy
|
||||
from scipy import integrate, optimize, special, stats
|
||||
import scipy.cluster.hierarchy
|
||||
import scipy.integrate
|
||||
import scipy.interpolate
|
||||
from scipy.interpolate import InterpolatedUnivariateSpline, interp1d
|
||||
import scipy.linalg
|
||||
import scipy.optimize
|
||||
from scipy.optimize import (curve_fit, fmin_l_bfgs_b, fsolve,
|
||||
leastsq)
|
||||
from scipy.optimize.zeros import bisect
|
||||
import scipy.special
|
||||
from scipy.special import gamma, gammainc, gammaincinv, ndtri
|
||||
import scipy.stats
|
||||
from scipy.stats import (chisqprob, distributions,
|
||||
scoreatpercentile, uniform)
|
||||
from scipy.stats.distributions \
|
||||
import norm
|
||||
|
|
@ -1,331 +0,0 @@
|
|||
import UserDict
|
||||
from UserDict import DictMixin
|
||||
from UserList import UserList
|
||||
from _strptime import TimeRE
|
||||
import abc
|
||||
import argparse
|
||||
import ast
|
||||
import atexit
|
||||
import base64
|
||||
from base64 import b64decode, b64encode
|
||||
import binascii
|
||||
from binascii import hexlify, unhexlify
|
||||
import bisect
|
||||
import bootstrap
|
||||
import bz2
|
||||
import cProfile
|
||||
import cgi
|
||||
import collections
|
||||
from collections import defaultdict, deque, namedtuple
|
||||
import commands
|
||||
import contextlib
|
||||
from contextlib import closing, contextmanager, nested
|
||||
import copy
|
||||
import csv
|
||||
import ctypes
|
||||
from ctypes import CDLL
|
||||
import datetime
|
||||
import decimal
|
||||
from decimal import Decimal
|
||||
import decorator
|
||||
import difflib
|
||||
from difflib import SequenceMatcher, context_diff
|
||||
import dis
|
||||
import email
|
||||
from email import encoders
|
||||
from email.encoders import encode_base64
|
||||
from email.message import Message
|
||||
from email.mime.audio import MIMEAudio
|
||||
from email.utils import COMMASPACE, formatdate
|
||||
import errno
|
||||
from errno import (E2BIG, EACCES, EADDRINUSE,
|
||||
EADDRNOTAVAIL, EAFNOSUPPORT, EAGAIN,
|
||||
EALREADY, EBADF, EBADMSG, EBUSY,
|
||||
ECHILD, ECONNABORTED, ECONNREFUSED,
|
||||
ECONNRESET, EDEADLK, EDESTADDRREQ,
|
||||
EDOM, EDQUOT, EEXIST, EFAULT, EFBIG,
|
||||
EHOSTDOWN, EHOSTUNREACH, EIDRM, EILSEQ,
|
||||
EINPROGRESS, EINTR, EINVAL, EIO,
|
||||
EISCONN, EISDIR, ELOOP, EMFILE, EMLINK,
|
||||
EMSGSIZE, EMULTIHOP, ENAMETOOLONG,
|
||||
ENETDOWN, ENETRESET, ENETUNREACH,
|
||||
ENFILE, ENOBUFS, ENODATA, ENODEV,
|
||||
ENOENT, ENOEXEC, ENOLCK, ENOLINK,
|
||||
ENOMEM, ENOMSG, ENOPROTOOPT, ENOSPC,
|
||||
ENOSR, ENOSTR, ENOSYS, ENOTBLK,
|
||||
ENOTCONN, ENOTDIR, ENOTEMPTY, ENOTSOCK,
|
||||
ENOTSUP, ENOTTY, ENXIO, EOPNOTSUPP,
|
||||
EOVERFLOW, EPERM, EPFNOSUPPORT, EPIPE,
|
||||
EPROTO, EPROTONOSUPPORT, EPROTOTYPE,
|
||||
ERANGE, EREMOTE, EROFS, ESHUTDOWN,
|
||||
ESOCKTNOSUPPORT, ESPIPE, ESRCH, ESTALE,
|
||||
ETIME, ETIMEDOUT, ETOOMANYREFS,
|
||||
ETXTBSY, EUSERS, EWOULDBLOCK, EXDEV)
|
||||
import exceptions
|
||||
import fcntl
|
||||
import filecmp
|
||||
import fileinput
|
||||
import functional
|
||||
import functools
|
||||
from functools import (partial, reduce, total_ordering,
|
||||
update_wrapper, wraps)
|
||||
import gc
|
||||
import getpass
|
||||
from getpass import getuser
|
||||
import glob
|
||||
import grp
|
||||
from grp import getgrall, getgrgid, getgrnam
|
||||
import gzip
|
||||
import h5py
|
||||
import hashlib
|
||||
from hashlib import (md5, sha1, sha224, sha256, sha384,
|
||||
sha512)
|
||||
import heapq
|
||||
import imp
|
||||
import inspect
|
||||
from inspect import ArgSpec, getargspec
|
||||
import io
|
||||
import itertools
|
||||
from itertools import (chain, count, groupby, islice, product,
|
||||
repeat, tee)
|
||||
import json
|
||||
from keyword import iskeyword
|
||||
import linecache
|
||||
import locale
|
||||
import logging
|
||||
from lxml import etree
|
||||
import marshal
|
||||
import math
|
||||
import matplotlib
|
||||
import mimetypes
|
||||
import misc.double
|
||||
import mmap
|
||||
import new
|
||||
import numbers
|
||||
from numbers import (Complex, Integral, Number, Rational,
|
||||
Real)
|
||||
import operator
|
||||
from operator import add, indexOf, itemgetter, mul
|
||||
import optparse
|
||||
from optparse import (BadOptionError, OptParseError,
|
||||
OptionParser, OptionValueError)
|
||||
import os
|
||||
from os import (chmod, close, getcwd, getenv, geteuid,
|
||||
getpid, getuid, makedirs, mkdir,
|
||||
mkfifo, path, remove, rename, system,
|
||||
unlink)
|
||||
import os.path
|
||||
from os.path import (abspath, basename, dirname, exists,
|
||||
getsize, isfile, normpath, realpath)
|
||||
import parser
|
||||
import pdb
|
||||
import pickle
|
||||
from pickle import PickleError, UnpicklingError
|
||||
import pickletools
|
||||
import pkg_resources
|
||||
from pkg_resources import load_entry_point
|
||||
import pkgutil
|
||||
import pprint
|
||||
import psutil
|
||||
import pwd
|
||||
from pwd import getpwall, getpwnam, getpwuid
|
||||
import random
|
||||
from random import shuffle
|
||||
import re
|
||||
import resource
|
||||
import select
|
||||
import shlex
|
||||
import shutil
|
||||
from shutil import (copyfile, copyfileobj, copystat,
|
||||
copytree, rmtree)
|
||||
import signal
|
||||
import six
|
||||
from six import StringIO
|
||||
from six.moves import (builtins, cPickle, configparser,
|
||||
copyreg, email_mime_base,
|
||||
email_mime_image, email_mime_multipart,
|
||||
email_mime_text, http_client, map,
|
||||
queue, zip)
|
||||
from six.moves.urllib.parse import urlencode
|
||||
from six.moves.urllib.request import urlopen
|
||||
import smtplib
|
||||
from smtplib import (SMTP, SMTPAuthenticationError,
|
||||
SMTPConnectError, SMTPDataError,
|
||||
SMTPException, SMTPHeloError,
|
||||
SMTPRecipientsRefused,
|
||||
SMTPResponseException,
|
||||
SMTPSenderRefused,
|
||||
SMTPServerDisconnected, SMTP_SSL)
|
||||
import socket
|
||||
from socket import (AF_APPLETALK, AF_ASH, AF_ATMPVC,
|
||||
AF_ATMSVC, AF_AX25, AF_BRIDGE,
|
||||
AF_DECnet, AF_ECONET, AF_INET,
|
||||
AF_INET6, AF_IPX, AF_IRDA, AF_KEY,
|
||||
AF_LLC, AF_NETBEUI, AF_NETLINK,
|
||||
AF_NETROM, AF_PACKET, AF_PPPOX,
|
||||
AF_ROSE, AF_ROUTE, AF_SECURITY, AF_SNA,
|
||||
AF_TIPC, AF_UNIX, AF_UNSPEC,
|
||||
AF_WANPIPE, AF_X25, AI_ADDRCONFIG,
|
||||
AI_ALL, AI_CANONNAME, AI_NUMERICHOST,
|
||||
AI_NUMERICSERV, AI_PASSIVE,
|
||||
AI_V4MAPPED, CAPI, EAI_ADDRFAMILY,
|
||||
EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL,
|
||||
EAI_FAMILY, EAI_MEMORY, EAI_NODATA,
|
||||
EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE,
|
||||
EAI_SOCKTYPE, EAI_SYSTEM,
|
||||
INADDR_ALLHOSTS_GROUP, INADDR_ANY,
|
||||
INADDR_BROADCAST, INADDR_LOOPBACK,
|
||||
INADDR_MAX_LOCAL_GROUP, INADDR_NONE,
|
||||
INADDR_UNSPEC_GROUP, IPPORT_RESERVED,
|
||||
IPPORT_USERRESERVED, IPPROTO_AH,
|
||||
IPPROTO_DSTOPTS, IPPROTO_EGP,
|
||||
IPPROTO_ESP, IPPROTO_FRAGMENT,
|
||||
IPPROTO_GRE, IPPROTO_HOPOPTS,
|
||||
IPPROTO_ICMP, IPPROTO_ICMPV6,
|
||||
IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IP,
|
||||
IPPROTO_IPIP, IPPROTO_IPV6,
|
||||
IPPROTO_NONE, IPPROTO_PIM, IPPROTO_PUP,
|
||||
IPPROTO_RAW, IPPROTO_ROUTING,
|
||||
IPPROTO_RSVP, IPPROTO_TCP, IPPROTO_TP,
|
||||
IPPROTO_UDP, IPV6_CHECKSUM,
|
||||
IPV6_DSTOPTS, IPV6_HOPLIMIT,
|
||||
IPV6_HOPOPTS, IPV6_JOIN_GROUP,
|
||||
IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS,
|
||||
IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP,
|
||||
IPV6_NEXTHOP, IPV6_PKTINFO,
|
||||
IPV6_RECVDSTOPTS, IPV6_RECVHOPLIMIT,
|
||||
IPV6_RECVHOPOPTS, IPV6_RECVPKTINFO,
|
||||
IPV6_RECVRTHDR, IPV6_RECVTCLASS,
|
||||
IPV6_RTHDR, IPV6_RTHDRDSTOPTS,
|
||||
IPV6_RTHDR_TYPE_0, IPV6_TCLASS,
|
||||
IPV6_UNICAST_HOPS, IPV6_V6ONLY,
|
||||
IP_ADD_MEMBERSHIP,
|
||||
IP_DEFAULT_MULTICAST_LOOP,
|
||||
IP_DEFAULT_MULTICAST_TTL,
|
||||
IP_DROP_MEMBERSHIP, IP_HDRINCL,
|
||||
IP_MAX_MEMBERSHIPS, IP_MULTICAST_IF,
|
||||
IP_MULTICAST_LOOP, IP_MULTICAST_TTL,
|
||||
IP_OPTIONS, IP_RECVOPTS,
|
||||
IP_RECVRETOPTS, IP_RETOPTS, IP_TOS,
|
||||
IP_TTL, MSG_CTRUNC, MSG_DONTROUTE,
|
||||
MSG_DONTWAIT, MSG_EOR, MSG_OOB,
|
||||
MSG_PEEK, MSG_TRUNC, MSG_WAITALL,
|
||||
NETLINK_DNRTMSG, NETLINK_FIREWALL,
|
||||
NETLINK_IP6_FW, NETLINK_NFLOG,
|
||||
NETLINK_ROUTE, NETLINK_USERSOCK,
|
||||
NETLINK_XFRM, NI_DGRAM, NI_MAXHOST,
|
||||
NI_MAXSERV, NI_NAMEREQD, NI_NOFQDN,
|
||||
NI_NUMERICHOST, NI_NUMERICSERV,
|
||||
PACKET_BROADCAST, PACKET_FASTROUTE,
|
||||
PACKET_HOST, PACKET_LOOPBACK,
|
||||
PACKET_MULTICAST, PACKET_OTHERHOST,
|
||||
PACKET_OUTGOING, PF_PACKET, SHUT_RD,
|
||||
SHUT_RDWR, SHUT_WR, SOCK_DGRAM,
|
||||
SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET,
|
||||
SOCK_STREAM, SOL_IP, SOL_SOCKET,
|
||||
SOL_TCP, SOL_TIPC, SOL_UDP, SOMAXCONN,
|
||||
SO_ACCEPTCONN, SO_ATTACH_FILTER,
|
||||
SO_BINDTODEVICE, SO_BROADCAST,
|
||||
SO_BSDCOMPAT, SO_DEBUG,
|
||||
SO_DETACH_FILTER, SO_DONTROUTE,
|
||||
SO_ERROR, SO_KEEPALIVE, SO_LINGER,
|
||||
SO_NO_CHECK, SO_OOBINLINE, SO_PASSCRED,
|
||||
SO_PASSSEC, SO_PEERCRED, SO_PEERNAME,
|
||||
SO_PEERSEC, SO_PRIORITY, SO_RCVBUF,
|
||||
SO_RCVBUFFORCE, SO_RCVLOWAT,
|
||||
SO_RCVTIMEO, SO_REUSEADDR,
|
||||
SO_SECURITY_AUTHENTICATION,
|
||||
SO_SECURITY_ENCRYPTION_NETWORK,
|
||||
SO_SECURITY_ENCRYPTION_TRANSPORT,
|
||||
SO_SNDBUF, SO_SNDBUFFORCE, SO_SNDLOWAT,
|
||||
SO_SNDTIMEO, SO_TIMESTAMP,
|
||||
SO_TIMESTAMPNS, SO_TYPE, SocketType,
|
||||
TCP_CONGESTION, TCP_CORK,
|
||||
TCP_DEFER_ACCEPT, TCP_INFO,
|
||||
TCP_KEEPCNT, TCP_KEEPIDLE,
|
||||
TCP_KEEPINTVL, TCP_LINGER2, TCP_MAXSEG,
|
||||
TCP_MD5SIG, TCP_MD5SIG_MAXKEYLEN,
|
||||
TCP_NODELAY, TCP_QUICKACK, TCP_SYNCNT,
|
||||
TCP_WINDOW_CLAMP, TIPC_ADDR_ID,
|
||||
TIPC_ADDR_NAME, TIPC_ADDR_NAMESEQ,
|
||||
TIPC_CFG_SRV, TIPC_CLUSTER_SCOPE,
|
||||
TIPC_CONN_TIMEOUT,
|
||||
TIPC_CRITICAL_IMPORTANCE,
|
||||
TIPC_DEST_DROPPABLE,
|
||||
TIPC_HIGH_IMPORTANCE, TIPC_IMPORTANCE,
|
||||
TIPC_LOW_IMPORTANCE,
|
||||
TIPC_MEDIUM_IMPORTANCE,
|
||||
TIPC_NODE_SCOPE, TIPC_PUBLISHED,
|
||||
TIPC_SRC_DROPPABLE,
|
||||
TIPC_SUBSCR_TIMEOUT, TIPC_SUB_CANCEL,
|
||||
TIPC_SUB_PORTS, TIPC_SUB_SERVICE,
|
||||
TIPC_TOP_SRV, TIPC_WAIT_FOREVER,
|
||||
TIPC_WITHDRAWN, TIPC_ZONE_SCOPE,
|
||||
gaierror, getaddrinfo, getfqdn,
|
||||
gethostbyaddr, gethostbyname,
|
||||
gethostbyname_ex, gethostname,
|
||||
getnameinfo, getprotobyname,
|
||||
getservbyname, getservbyport, htonl,
|
||||
htons, inet_aton, inet_ntoa, inet_ntop,
|
||||
inet_pton, ntohl, ntohs,
|
||||
setdefaulttimeout, socketpair)
|
||||
import sqlite3
|
||||
import ssl
|
||||
import stat
|
||||
from stat import (ST_MTIME, S_IFMT, S_IMODE, S_ISBLK,
|
||||
S_ISCHR, S_ISDIR, S_ISFIFO, S_ISLNK,
|
||||
S_ISREG, S_ISSOCK)
|
||||
import string
|
||||
import struct
|
||||
import subprocess
|
||||
from subprocess import (CalledProcessError, PIPE, Popen, call,
|
||||
check_call)
|
||||
import symbol
|
||||
import sys
|
||||
from sys import exit, getsizeof, stderr, stdout
|
||||
import tempfile
|
||||
from tempfile import (NamedTemporaryFile,
|
||||
SpooledTemporaryFile, TemporaryFile,
|
||||
mkdtemp, mkstemp, mktemp)
|
||||
import termios
|
||||
import textwrap
|
||||
from textwrap import dedent
|
||||
import threading
|
||||
from threading import (BoundedSemaphore, Condition, Lock,
|
||||
RLock, Semaphore, Thread, Timer,
|
||||
currentThread, current_thread)
|
||||
import time
|
||||
from time import (asctime, ctime, gmtime, localtime,
|
||||
mktime, sleep, strftime, strptime)
|
||||
import timeit
|
||||
import token
|
||||
import traceback
|
||||
import types
|
||||
from types import (BooleanType, BufferType,
|
||||
BuiltinFunctionType, BuiltinMethodType,
|
||||
ClassType, CodeType, ComplexType,
|
||||
DictProxyType, DictType,
|
||||
DictionaryType, EllipsisType, FileType,
|
||||
FloatType, FrameType, FunctionType,
|
||||
GeneratorType, GetSetDescriptorType,
|
||||
InstanceType, IntType, LambdaType,
|
||||
ListType, LongType,
|
||||
MemberDescriptorType, MethodType,
|
||||
ModuleType, NoneType,
|
||||
NotImplementedType, ObjectType,
|
||||
SliceType, StringType, StringTypes,
|
||||
TracebackType, TupleType, TypeType,
|
||||
UnboundMethodType, UnicodeType,
|
||||
XRangeType)
|
||||
import unittest
|
||||
import urllib
|
||||
import urllib2
|
||||
import warnings
|
||||
import weakref
|
||||
from weakref import (CallableProxyType, ProxyType,
|
||||
ProxyTypes, ReferenceType,
|
||||
WeakKeyDictionary, WeakValueDictionary,
|
||||
getweakrefcount, getweakrefs)
|
||||
from xml.dom import minidom
|
||||
import xml.parsers.expat
|
||||
import zlib
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _CAMERA_H
|
||||
#define _CAMERA_H
|
||||
|
||||
#include "_pygame.h"
|
||||
#include "camera.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,326 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
/* This will use PYGAMEAPI_EXTERN_SLOTS instead
|
||||
* of PYGAMEAPI_DEFINE_SLOTS for base modules.
|
||||
*/
|
||||
#ifndef _PYGAME_INTERNAL_H
|
||||
#define _PYGAME_INTERNAL_H
|
||||
|
||||
#include "pgplatform.h"
|
||||
/*
|
||||
If PY_SSIZE_T_CLEAN is defined before including Python.h, length is a
|
||||
Py_ssize_t rather than an int for all # variants of formats (s#, y#, etc.)
|
||||
*/
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include <Python.h>
|
||||
|
||||
/* Ensure PyPy-specific code is not in use when running on GraalPython (PR
|
||||
* #2580) */
|
||||
#if defined(GRAALVM_PYTHON) && defined(PYPY_VERSION)
|
||||
#undef PYPY_VERSION
|
||||
#endif
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
/* SDL 1.2 constants removed from SDL 2 */
|
||||
typedef enum {
|
||||
SDL_HWSURFACE = 0,
|
||||
SDL_RESIZABLE = SDL_WINDOW_RESIZABLE,
|
||||
SDL_ASYNCBLIT = 0,
|
||||
SDL_OPENGL = SDL_WINDOW_OPENGL,
|
||||
SDL_OPENGLBLIT = 0,
|
||||
SDL_ANYFORMAT = 0,
|
||||
SDL_HWPALETTE = 0,
|
||||
SDL_DOUBLEBUF = 0,
|
||||
SDL_FULLSCREEN = SDL_WINDOW_FULLSCREEN,
|
||||
SDL_HWACCEL = 0,
|
||||
SDL_SRCCOLORKEY = 0,
|
||||
SDL_RLEACCELOK = 0,
|
||||
SDL_SRCALPHA = 0,
|
||||
SDL_NOFRAME = SDL_WINDOW_BORDERLESS,
|
||||
SDL_GL_SWAP_CONTROL = 0,
|
||||
TIMER_RESOLUTION = 0
|
||||
} PygameVideoFlags;
|
||||
|
||||
/* the wheel button constants were removed from SDL 2 */
|
||||
typedef enum {
|
||||
PGM_BUTTON_LEFT = SDL_BUTTON_LEFT,
|
||||
PGM_BUTTON_RIGHT = SDL_BUTTON_RIGHT,
|
||||
PGM_BUTTON_MIDDLE = SDL_BUTTON_MIDDLE,
|
||||
PGM_BUTTON_WHEELUP = 4,
|
||||
PGM_BUTTON_WHEELDOWN = 5,
|
||||
PGM_BUTTON_X1 = SDL_BUTTON_X1 + 2,
|
||||
PGM_BUTTON_X2 = SDL_BUTTON_X2 + 2,
|
||||
PGM_BUTTON_KEEP = 0x80
|
||||
} PygameMouseFlags;
|
||||
|
||||
typedef enum {
|
||||
/* Any SDL_* events here are for backward compatibility. */
|
||||
SDL_NOEVENT = 0,
|
||||
|
||||
SDL_ACTIVEEVENT = SDL_USEREVENT,
|
||||
SDL_VIDEORESIZE,
|
||||
SDL_VIDEOEXPOSE,
|
||||
|
||||
PGE_MIDIIN,
|
||||
PGE_MIDIOUT,
|
||||
PGE_KEYREPEAT, /* Special internal pygame event, for managing key-presses
|
||||
*/
|
||||
|
||||
/* DO NOT CHANGE THE ORDER OF EVENTS HERE */
|
||||
PGE_WINDOWSHOWN,
|
||||
PGE_WINDOWHIDDEN,
|
||||
PGE_WINDOWEXPOSED,
|
||||
PGE_WINDOWMOVED,
|
||||
PGE_WINDOWRESIZED,
|
||||
PGE_WINDOWSIZECHANGED,
|
||||
PGE_WINDOWMINIMIZED,
|
||||
PGE_WINDOWMAXIMIZED,
|
||||
PGE_WINDOWRESTORED,
|
||||
PGE_WINDOWENTER,
|
||||
PGE_WINDOWLEAVE,
|
||||
PGE_WINDOWFOCUSGAINED,
|
||||
PGE_WINDOWFOCUSLOST,
|
||||
PGE_WINDOWCLOSE,
|
||||
PGE_WINDOWTAKEFOCUS,
|
||||
PGE_WINDOWHITTEST,
|
||||
|
||||
/* Here we define PGPOST_* events, events that act as a one-to-one
|
||||
* proxy for SDL events (and some extra events too!), the proxy is used
|
||||
* internally when pygame users use event.post()
|
||||
*
|
||||
* At a first glance, these may look redundant, but they are really
|
||||
* important, especially with event blocking. If proxy events are
|
||||
* not there, blocked events dont make it to our event filter, and
|
||||
* that can break a lot of stuff.
|
||||
*
|
||||
* IMPORTANT NOTE: Do not post events directly with these proxy types,
|
||||
* use the appropriate functions from event.c, that handle these proxy
|
||||
* events for you.
|
||||
* Proxy events are for internal use only */
|
||||
PGPOST_EVENTBEGIN, /* mark start of proxy-events */
|
||||
PGPOST_ACTIVEEVENT = PGPOST_EVENTBEGIN,
|
||||
PGPOST_AUDIODEVICEADDED,
|
||||
PGPOST_AUDIODEVICEREMOVED,
|
||||
PGPOST_CONTROLLERAXISMOTION,
|
||||
PGPOST_CONTROLLERBUTTONDOWN,
|
||||
PGPOST_CONTROLLERBUTTONUP,
|
||||
PGPOST_CONTROLLERDEVICEADDED,
|
||||
PGPOST_CONTROLLERDEVICEREMOVED,
|
||||
PGPOST_CONTROLLERDEVICEREMAPPED,
|
||||
PGPOST_CONTROLLERTOUCHPADDOWN,
|
||||
PGPOST_CONTROLLERTOUCHPADMOTION,
|
||||
PGPOST_CONTROLLERTOUCHPADUP,
|
||||
PGPOST_DOLLARGESTURE,
|
||||
PGPOST_DOLLARRECORD,
|
||||
PGPOST_DROPFILE,
|
||||
PGPOST_DROPTEXT,
|
||||
PGPOST_DROPBEGIN,
|
||||
PGPOST_DROPCOMPLETE,
|
||||
PGPOST_FINGERMOTION,
|
||||
PGPOST_FINGERDOWN,
|
||||
PGPOST_FINGERUP,
|
||||
PGPOST_KEYDOWN,
|
||||
PGPOST_KEYUP,
|
||||
PGPOST_JOYAXISMOTION,
|
||||
PGPOST_JOYBALLMOTION,
|
||||
PGPOST_JOYHATMOTION,
|
||||
PGPOST_JOYBUTTONDOWN,
|
||||
PGPOST_JOYBUTTONUP,
|
||||
PGPOST_JOYDEVICEADDED,
|
||||
PGPOST_JOYDEVICEREMOVED,
|
||||
PGPOST_MIDIIN,
|
||||
PGPOST_MIDIOUT,
|
||||
PGPOST_MOUSEMOTION,
|
||||
PGPOST_MOUSEBUTTONDOWN,
|
||||
PGPOST_MOUSEBUTTONUP,
|
||||
PGPOST_MOUSEWHEEL,
|
||||
PGPOST_MULTIGESTURE,
|
||||
PGPOST_NOEVENT,
|
||||
PGPOST_QUIT,
|
||||
PGPOST_SYSWMEVENT,
|
||||
PGPOST_TEXTEDITING,
|
||||
PGPOST_TEXTINPUT,
|
||||
PGPOST_VIDEORESIZE,
|
||||
PGPOST_VIDEOEXPOSE,
|
||||
PGPOST_WINDOWSHOWN,
|
||||
PGPOST_WINDOWHIDDEN,
|
||||
PGPOST_WINDOWEXPOSED,
|
||||
PGPOST_WINDOWMOVED,
|
||||
PGPOST_WINDOWRESIZED,
|
||||
PGPOST_WINDOWSIZECHANGED,
|
||||
PGPOST_WINDOWMINIMIZED,
|
||||
PGPOST_WINDOWMAXIMIZED,
|
||||
PGPOST_WINDOWRESTORED,
|
||||
PGPOST_WINDOWENTER,
|
||||
PGPOST_WINDOWLEAVE,
|
||||
PGPOST_WINDOWFOCUSGAINED,
|
||||
PGPOST_WINDOWFOCUSLOST,
|
||||
PGPOST_WINDOWCLOSE,
|
||||
PGPOST_WINDOWTAKEFOCUS,
|
||||
PGPOST_WINDOWHITTEST,
|
||||
|
||||
PGE_USEREVENT, /* this event must stay in this position only */
|
||||
|
||||
PG_NUMEVENTS =
|
||||
SDL_LASTEVENT /* Not an event. Indicates end of user events. */
|
||||
} PygameEventCode;
|
||||
|
||||
typedef enum {
|
||||
SDL_APPFOCUSMOUSE,
|
||||
SDL_APPINPUTFOCUS,
|
||||
SDL_APPACTIVE
|
||||
} PygameAppCode;
|
||||
|
||||
/* Surface flags: based on SDL 1.2 flags */
|
||||
typedef enum {
|
||||
PGS_SWSURFACE = 0x00000000,
|
||||
PGS_HWSURFACE = 0x00000001,
|
||||
PGS_ASYNCBLIT = 0x00000004,
|
||||
|
||||
PGS_ANYFORMAT = 0x10000000,
|
||||
PGS_HWPALETTE = 0x20000000,
|
||||
PGS_DOUBLEBUF = 0x40000000,
|
||||
PGS_FULLSCREEN = 0x80000000,
|
||||
PGS_SCALED = 0x00000200,
|
||||
|
||||
PGS_OPENGL = 0x00000002,
|
||||
PGS_OPENGLBLIT = 0x0000000A,
|
||||
PGS_RESIZABLE = 0x00000010,
|
||||
PGS_NOFRAME = 0x00000020,
|
||||
PGS_SHOWN = 0x00000040, /* Added from SDL 2 */
|
||||
PGS_HIDDEN = 0x00000080, /* Added from SDL 2 */
|
||||
|
||||
PGS_HWACCEL = 0x00000100,
|
||||
PGS_SRCCOLORKEY = 0x00001000,
|
||||
PGS_RLEACCELOK = 0x00002000,
|
||||
PGS_RLEACCEL = 0x00004000,
|
||||
PGS_SRCALPHA = 0x00010000,
|
||||
PGS_PREALLOC = 0x01000000
|
||||
} PygameSurfaceFlags;
|
||||
|
||||
// TODO Implement check below in a way that does not break CI
|
||||
/* New buffer protocol (PEP 3118) implemented on all supported Py versions.
|
||||
#if !defined(Py_TPFLAGS_HAVE_NEWBUFFER)
|
||||
#error No support for PEP 3118/Py_TPFLAGS_HAVE_NEWBUFFER. Please use a
|
||||
supported Python version. #endif */
|
||||
|
||||
#define RAISE(x, y) (PyErr_SetString((x), (y)), (PyObject *)NULL)
|
||||
#define DEL_ATTR_NOT_SUPPORTED_CHECK(name, value) \
|
||||
do { \
|
||||
if (!value) { \
|
||||
if (name) { \
|
||||
PyErr_Format(PyExc_AttributeError, \
|
||||
"Cannot delete attribute %s", name); \
|
||||
} \
|
||||
else { \
|
||||
PyErr_SetString(PyExc_AttributeError, \
|
||||
"Cannot delete attribute"); \
|
||||
} \
|
||||
return -1; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Initialization checks
|
||||
*/
|
||||
|
||||
#define VIDEO_INIT_CHECK() \
|
||||
if (!SDL_WasInit(SDL_INIT_VIDEO)) \
|
||||
return RAISE(pgExc_SDLError, "video system not initialized")
|
||||
|
||||
#define CDROM_INIT_CHECK() \
|
||||
if (!SDL_WasInit(SDL_INIT_CDROM)) \
|
||||
return RAISE(pgExc_SDLError, "cdrom system not initialized")
|
||||
|
||||
#define JOYSTICK_INIT_CHECK() \
|
||||
if (!SDL_WasInit(SDL_INIT_JOYSTICK)) \
|
||||
return RAISE(pgExc_SDLError, "joystick system not initialized")
|
||||
|
||||
/* thread check */
|
||||
#ifdef WITH_THREAD
|
||||
#define PG_CHECK_THREADS() (1)
|
||||
#else /* ~WITH_THREAD */
|
||||
#define PG_CHECK_THREADS() \
|
||||
(RAISE(PyExc_NotImplementedError, "Python built without thread support"))
|
||||
#endif /* ~WITH_THREAD */
|
||||
|
||||
#define PyType_Init(x) (((x).ob_type) = &PyType_Type)
|
||||
|
||||
/*
|
||||
* event module internals
|
||||
*/
|
||||
struct pgEventObject {
|
||||
PyObject_HEAD int type;
|
||||
PyObject *dict;
|
||||
};
|
||||
|
||||
/*
|
||||
* surflock module internals
|
||||
*/
|
||||
typedef struct {
|
||||
PyObject_HEAD PyObject *surface;
|
||||
PyObject *lockobj;
|
||||
PyObject *weakrefs;
|
||||
} pgLifetimeLockObject;
|
||||
|
||||
/*
|
||||
* surface module internals
|
||||
*/
|
||||
struct pgSubSurface_Data {
|
||||
PyObject *owner;
|
||||
int pixeloffset;
|
||||
int offsetx, offsety;
|
||||
};
|
||||
|
||||
/*
|
||||
* color module internals
|
||||
*/
|
||||
struct pgColorObject {
|
||||
PyObject_HEAD Uint8 data[4];
|
||||
Uint8 len;
|
||||
};
|
||||
|
||||
/*
|
||||
* include public API
|
||||
*/
|
||||
#include "include/_pygame.h"
|
||||
|
||||
/* Slot counts.
|
||||
* Remember to keep these constants up to date.
|
||||
*/
|
||||
|
||||
#define PYGAMEAPI_RECT_NUMSLOTS 5
|
||||
#define PYGAMEAPI_JOYSTICK_NUMSLOTS 2
|
||||
#define PYGAMEAPI_DISPLAY_NUMSLOTS 2
|
||||
#define PYGAMEAPI_SURFACE_NUMSLOTS 4
|
||||
#define PYGAMEAPI_SURFLOCK_NUMSLOTS 8
|
||||
#define PYGAMEAPI_RWOBJECT_NUMSLOTS 7
|
||||
#define PYGAMEAPI_PIXELARRAY_NUMSLOTS 2
|
||||
#define PYGAMEAPI_COLOR_NUMSLOTS 5
|
||||
#define PYGAMEAPI_MATH_NUMSLOTS 2
|
||||
#define PYGAMEAPI_CDROM_NUMSLOTS 2
|
||||
#define PYGAMEAPI_BASE_NUMSLOTS 24
|
||||
#define PYGAMEAPI_EVENT_NUMSLOTS 6
|
||||
|
||||
#endif /* _PYGAME_INTERNAL_H */
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
Copyright (C) 2007 Marcus von Appen
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
#ifndef _SURFACE_H
|
||||
#define _SURFACE_H
|
||||
|
||||
#include "_pygame.h"
|
||||
#include "surface.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,252 +0,0 @@
|
|||
#ifndef CAMERA_H
|
||||
#define CAMERA_H
|
||||
/*
|
||||
pygame - Python Game Library
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "pygame.h"
|
||||
#include "pgcompat.h"
|
||||
#include "doc/camera_doc.h"
|
||||
|
||||
#if defined(__unix__)
|
||||
#include <structmember.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <fcntl.h> /* low-level i/o */
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/* on freebsd there is no asm/types */
|
||||
#ifdef linux
|
||||
#include <asm/types.h> /* for videodev2.h */
|
||||
#endif
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#define PYGAME_WINDOWS_CAMERA 1
|
||||
|
||||
#include <mfapi.h>
|
||||
#include <mfobjects.h>
|
||||
#include <mfidl.h>
|
||||
#include <mfreadwrite.h>
|
||||
#include <combaseapi.h>
|
||||
#include <mftransform.h>
|
||||
#endif
|
||||
|
||||
/* some constants used which are not defined on non-v4l machines. */
|
||||
#ifndef V4L2_PIX_FMT_RGB24
|
||||
#define V4L2_PIX_FMT_RGB24 'RGB3'
|
||||
#endif
|
||||
#ifndef V4L2_PIX_FMT_RGB444
|
||||
#define V4L2_PIX_FMT_RGB444 'R444'
|
||||
#endif
|
||||
#ifndef V4L2_PIX_FMT_YUYV
|
||||
#define V4L2_PIX_FMT_YUYV 'YUYV'
|
||||
#endif
|
||||
#ifndef V4L2_PIX_FMT_XBGR32
|
||||
#define V4L2_PIX_FMT_XBGR32 'XR24'
|
||||
#endif
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
#define SAT(c) \
|
||||
if (c & (~255)) { \
|
||||
if (c < 0) \
|
||||
c = 0; \
|
||||
else \
|
||||
c = 255; \
|
||||
}
|
||||
#define SAT2(c) ((c) & (~255) ? ((c) < 0 ? 0 : 255) : (c))
|
||||
#define DEFAULT_WIDTH 640
|
||||
#define DEFAULT_HEIGHT 480
|
||||
#define RGB_OUT 1
|
||||
#define YUV_OUT 2
|
||||
#define HSV_OUT 4
|
||||
#define CAM_V4L \
|
||||
1 /* deprecated. the incomplete support in pygame was removed */
|
||||
#define CAM_V4L2 2
|
||||
|
||||
struct buffer {
|
||||
void *start;
|
||||
size_t length;
|
||||
};
|
||||
|
||||
#if defined(__unix__)
|
||||
typedef struct pgCameraObject {
|
||||
PyObject_HEAD char *device_name;
|
||||
int camera_type;
|
||||
unsigned long pixelformat;
|
||||
unsigned int color_out;
|
||||
struct buffer *buffers;
|
||||
unsigned int n_buffers;
|
||||
int width;
|
||||
int height;
|
||||
int size;
|
||||
int hflip;
|
||||
int vflip;
|
||||
int brightness;
|
||||
int fd;
|
||||
} pgCameraObject;
|
||||
#elif defined(PYGAME_WINDOWS_CAMERA)
|
||||
typedef struct pgCameraObject {
|
||||
PyObject_HEAD WCHAR *device_name;
|
||||
IMFSourceReader *reader;
|
||||
IMFTransform *transform;
|
||||
IMFVideoProcessorControl *control;
|
||||
IMFMediaBuffer *buf;
|
||||
IMFMediaBuffer *raw_buf;
|
||||
int buffer_ready;
|
||||
short open; /* used to signal the update_function to exit */
|
||||
HANDLE t_handle;
|
||||
HRESULT t_error;
|
||||
int t_error_line;
|
||||
int width;
|
||||
int height;
|
||||
int hflip;
|
||||
int vflip;
|
||||
int last_vflip;
|
||||
int color_out;
|
||||
unsigned long pixelformat;
|
||||
} pgCameraObject;
|
||||
|
||||
#else
|
||||
/* generic definition.
|
||||
*/
|
||||
|
||||
typedef struct pgCameraObject {
|
||||
PyObject_HEAD char *device_name;
|
||||
int camera_type;
|
||||
unsigned long pixelformat;
|
||||
unsigned int color_out;
|
||||
struct buffer *buffers;
|
||||
unsigned int n_buffers;
|
||||
int width;
|
||||
int height;
|
||||
int size;
|
||||
int hflip;
|
||||
int vflip;
|
||||
int brightness;
|
||||
int fd;
|
||||
} pgCameraObject;
|
||||
#endif
|
||||
|
||||
/* internal functions for colorspace conversion */
|
||||
void
|
||||
colorspace(SDL_Surface *src, SDL_Surface *dst, int cspace);
|
||||
void
|
||||
rgb24_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
|
||||
void
|
||||
bgr32_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
|
||||
void
|
||||
rgb444_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
|
||||
void
|
||||
rgb_to_yuv(const void *src, void *dst, int length, unsigned long source,
|
||||
SDL_PixelFormat *format);
|
||||
void
|
||||
rgb_to_hsv(const void *src, void *dst, int length, unsigned long source,
|
||||
SDL_PixelFormat *format);
|
||||
void
|
||||
yuyv_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
|
||||
void
|
||||
yuyv_to_yuv(const void *src, void *dst, int length, SDL_PixelFormat *format);
|
||||
void
|
||||
uyvy_to_rgb(const void *src, void *dst, int length, SDL_PixelFormat *format);
|
||||
void
|
||||
uyvy_to_yuv(const void *src, void *dst, int length, SDL_PixelFormat *format);
|
||||
void
|
||||
sbggr8_to_rgb(const void *src, void *dst, int width, int height,
|
||||
SDL_PixelFormat *format);
|
||||
void
|
||||
yuv420_to_rgb(const void *src, void *dst, int width, int height,
|
||||
SDL_PixelFormat *format);
|
||||
void
|
||||
yuv420_to_yuv(const void *src, void *dst, int width, int height,
|
||||
SDL_PixelFormat *format);
|
||||
|
||||
#if defined(__unix__)
|
||||
/* internal functions specific to v4l2 */
|
||||
char **
|
||||
v4l2_list_cameras(int *num_devices);
|
||||
int
|
||||
v4l2_get_control(int fd, int id, int *value);
|
||||
int
|
||||
v4l2_set_control(int fd, int id, int value);
|
||||
PyObject *
|
||||
v4l2_read_raw(pgCameraObject *self);
|
||||
int
|
||||
v4l2_xioctl(int fd, int request, void *arg);
|
||||
int
|
||||
v4l2_process_image(pgCameraObject *self, const void *image,
|
||||
unsigned int buffer_size, SDL_Surface *surf);
|
||||
int
|
||||
v4l2_query_buffer(pgCameraObject *self);
|
||||
int
|
||||
v4l2_read_frame(pgCameraObject *self, SDL_Surface *surf);
|
||||
int
|
||||
v4l2_stop_capturing(pgCameraObject *self);
|
||||
int
|
||||
v4l2_start_capturing(pgCameraObject *self);
|
||||
int
|
||||
v4l2_uninit_device(pgCameraObject *self);
|
||||
int
|
||||
v4l2_init_mmap(pgCameraObject *self);
|
||||
int
|
||||
v4l2_init_device(pgCameraObject *self);
|
||||
int
|
||||
v4l2_close_device(pgCameraObject *self);
|
||||
int
|
||||
v4l2_open_device(pgCameraObject *self);
|
||||
|
||||
#elif defined(PYGAME_WINDOWS_CAMERA)
|
||||
/* internal functions specific to WINDOWS */
|
||||
WCHAR **
|
||||
windows_list_cameras(int *num_devices);
|
||||
int
|
||||
windows_init_device(pgCameraObject *self);
|
||||
int
|
||||
windows_open_device(pgCameraObject *self);
|
||||
IMFActivate *
|
||||
windows_device_from_name(WCHAR *device_name);
|
||||
int
|
||||
windows_close_device(pgCameraObject *self);
|
||||
int
|
||||
windows_read_frame(pgCameraObject *self, SDL_Surface *surf);
|
||||
int
|
||||
windows_frame_ready(pgCameraObject *self, int *result);
|
||||
PyObject *
|
||||
windows_read_raw(pgCameraObject *self);
|
||||
int
|
||||
windows_process_image(pgCameraObject *self, BYTE *data, DWORD buffer_size,
|
||||
SDL_Surface *surf);
|
||||
void
|
||||
windows_dealloc_device(pgCameraObject *self);
|
||||
int
|
||||
windows_init_device(pgCameraObject *self);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !CAMERA_H */
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef PGFONT_INTERNAL_H
|
||||
#define PGFONT_INTERNAL_H
|
||||
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
/* test font initialization */
|
||||
#define FONT_INIT_CHECK() \
|
||||
if (!(*(int *)PyFONT_C_API[2])) \
|
||||
return RAISE(pgExc_SDLError, "font system not initialized")
|
||||
|
||||
#include "include/pygame_font.h"
|
||||
|
||||
#define PYGAMEAPI_FONT_NUMSLOTS 3
|
||||
|
||||
#endif /* ~PGFONT_INTERNAL_H */
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2009 Vicent Marti
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#ifndef _PYGAME_FREETYPE_INTERNAL_H_
|
||||
#define _PYGAME_FREETYPE_INTERNAL_H_
|
||||
|
||||
#include "pgcompat.h"
|
||||
#include "pgplatform.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_CACHE_H
|
||||
#include FT_XFREE86_H
|
||||
#include FT_TRIGONOMETRY_H
|
||||
|
||||
/**********************************************************
|
||||
* Global module constants
|
||||
**********************************************************/
|
||||
|
||||
/* Render styles */
|
||||
#define FT_STYLE_NORMAL 0x00
|
||||
#define FT_STYLE_STRONG 0x01
|
||||
#define FT_STYLE_OBLIQUE 0x02
|
||||
#define FT_STYLE_UNDERLINE 0x04
|
||||
#define FT_STYLE_WIDE 0x08
|
||||
#define FT_STYLE_DEFAULT 0xFF
|
||||
|
||||
/* Bounding box modes */
|
||||
#define FT_BBOX_EXACT FT_GLYPH_BBOX_SUBPIXELS
|
||||
#define FT_BBOX_EXACT_GRIDFIT FT_GLYPH_BBOX_GRIDFIT
|
||||
#define FT_BBOX_PIXEL FT_GLYPH_BBOX_TRUNCATE
|
||||
#define FT_BBOX_PIXEL_GRIDFIT FT_GLYPH_BBOX_PIXELS
|
||||
|
||||
/* Rendering flags */
|
||||
#define FT_RFLAG_NONE (0)
|
||||
#define FT_RFLAG_ANTIALIAS (1 << 0)
|
||||
#define FT_RFLAG_AUTOHINT (1 << 1)
|
||||
#define FT_RFLAG_VERTICAL (1 << 2)
|
||||
#define FT_RFLAG_HINTED (1 << 3)
|
||||
#define FT_RFLAG_KERNING (1 << 4)
|
||||
#define FT_RFLAG_TRANSFORM (1 << 5)
|
||||
#define FT_RFLAG_PAD (1 << 6)
|
||||
#define FT_RFLAG_ORIGIN (1 << 7)
|
||||
#define FT_RFLAG_UCS4 (1 << 8)
|
||||
#define FT_RFLAG_USE_BITMAP_STRIKES (1 << 9)
|
||||
#define FT_RFLAG_DEFAULTS \
|
||||
(FT_RFLAG_HINTED | FT_RFLAG_USE_BITMAP_STRIKES | FT_RFLAG_ANTIALIAS)
|
||||
|
||||
#define FT_RENDER_NEWBYTEARRAY 0x0
|
||||
#define FT_RENDER_NEWSURFACE 0x1
|
||||
#define FT_RENDER_EXISTINGSURFACE 0x2
|
||||
|
||||
/**********************************************************
|
||||
* Global module types
|
||||
**********************************************************/
|
||||
|
||||
typedef struct _scale_s {
|
||||
FT_UInt x, y;
|
||||
} Scale_t;
|
||||
typedef FT_Angle Angle_t;
|
||||
|
||||
struct fontinternals_;
|
||||
struct freetypeinstance_;
|
||||
|
||||
typedef struct {
|
||||
FT_Long font_index;
|
||||
FT_Open_Args open_args;
|
||||
} pgFontId;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD pgFontId id;
|
||||
PyObject *path;
|
||||
int is_scalable;
|
||||
int is_bg_col_set;
|
||||
|
||||
Scale_t face_size;
|
||||
FT_Int16 style;
|
||||
FT_Int16 render_flags;
|
||||
double strength;
|
||||
double underline_adjustment;
|
||||
FT_UInt resolution;
|
||||
Angle_t rotation;
|
||||
FT_Matrix transform;
|
||||
FT_Byte fgcolor[4];
|
||||
FT_Byte bgcolor[4];
|
||||
|
||||
struct freetypeinstance_ *freetype; /* Personal reference */
|
||||
struct fontinternals_ *_internals;
|
||||
} pgFontObject;
|
||||
|
||||
#define pgFont_IS_ALIVE(o) (((pgFontObject *)(o))->_internals != 0)
|
||||
|
||||
/* import public API */
|
||||
#include "include/pygame_freetype.h"
|
||||
|
||||
#define PYGAMEAPI_FREETYPE_NUMSLOTS 2
|
||||
|
||||
#endif /* ~_PYGAME_FREETYPE_INTERNAL_H_ */
|
||||
|
|
@ -1,497 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
#ifndef _PYGAME_H
|
||||
#define _PYGAME_H
|
||||
|
||||
/** This header file includes all the definitions for the
|
||||
** base pygame extensions. This header only requires
|
||||
** Python includes (and SDL.h for functions that use SDL types).
|
||||
** The reason for functions prototyped with #define's is
|
||||
** to allow for maximum Python portability. It also uses
|
||||
** Python as the runtime linker, which allows for late binding.
|
||||
'' For more information on this style of development, read
|
||||
** the Python docs on this subject.
|
||||
** http://www.python.org/doc/current/ext/using-cobjects.html
|
||||
**
|
||||
** If using this to build your own derived extensions,
|
||||
** you'll see that the functions available here are mainly
|
||||
** used to help convert between python objects and SDL objects.
|
||||
** Since this library doesn't add a lot of functionality to
|
||||
** the SDL library, it doesn't need to offer a lot either.
|
||||
**
|
||||
** When initializing your extension module, you must manually
|
||||
** import the modules you want to use. (this is the part about
|
||||
** using python as the runtime linker). Each module has its
|
||||
** own import_xxx() routine. You need to perform this import
|
||||
** after you have initialized your own module, and before
|
||||
** you call any routines from that module. Since every module
|
||||
** in pygame does this, there are plenty of examples.
|
||||
**
|
||||
** The base module does include some useful conversion routines
|
||||
** that you are free to use in your own extension.
|
||||
**/
|
||||
|
||||
#include "pgplatform.h"
|
||||
#include <Python.h>
|
||||
|
||||
/* version macros (defined since version 1.9.5) */
|
||||
#define PG_MAJOR_VERSION 2
|
||||
#define PG_MINOR_VERSION 1
|
||||
#define PG_PATCH_VERSION 2
|
||||
#define PG_VERSIONNUM(MAJOR, MINOR, PATCH) \
|
||||
(1000 * (MAJOR) + 100 * (MINOR) + (PATCH))
|
||||
#define PG_VERSION_ATLEAST(MAJOR, MINOR, PATCH) \
|
||||
(PG_VERSIONNUM(PG_MAJOR_VERSION, PG_MINOR_VERSION, PG_PATCH_VERSION) >= \
|
||||
PG_VERSIONNUM(MAJOR, MINOR, PATCH))
|
||||
|
||||
#include "pgcompat.h"
|
||||
|
||||
/* Flag indicating a pg_buffer; used for assertions within callbacks */
|
||||
#ifndef NDEBUG
|
||||
#define PyBUF_PYGAME 0x4000
|
||||
#endif
|
||||
#define PyBUF_HAS_FLAG(f, F) (((f) & (F)) == (F))
|
||||
|
||||
/* Array information exchange struct C type; inherits from Py_buffer
|
||||
*
|
||||
* Pygame uses its own Py_buffer derived C struct as an internal representation
|
||||
* of an imported array buffer. The extended Py_buffer allows for a
|
||||
* per-instance release callback,
|
||||
*/
|
||||
typedef void (*pybuffer_releaseproc)(Py_buffer *);
|
||||
|
||||
typedef struct pg_bufferinfo_s {
|
||||
Py_buffer view;
|
||||
PyObject *consumer; /* Input: Borrowed reference */
|
||||
pybuffer_releaseproc release_buffer;
|
||||
} pg_buffer;
|
||||
|
||||
#include "pgimport.h"
|
||||
|
||||
/*
|
||||
* BASE module
|
||||
*/
|
||||
#ifndef PYGAMEAPI_BASE_INTERNAL
|
||||
#define pgExc_SDLError ((PyObject *)PYGAMEAPI_GET_SLOT(base, 0))
|
||||
|
||||
#define pg_RegisterQuit \
|
||||
(*(void (*)(void (*)(void)))PYGAMEAPI_GET_SLOT(base, 1))
|
||||
|
||||
#define pg_IntFromObj \
|
||||
(*(int (*)(PyObject *, int *))PYGAMEAPI_GET_SLOT(base, 2))
|
||||
|
||||
#define pg_IntFromObjIndex \
|
||||
(*(int (*)(PyObject *, int, int *))PYGAMEAPI_GET_SLOT(base, 3))
|
||||
|
||||
#define pg_TwoIntsFromObj \
|
||||
(*(int (*)(PyObject *, int *, int *))PYGAMEAPI_GET_SLOT(base, 4))
|
||||
|
||||
#define pg_FloatFromObj \
|
||||
(*(int (*)(PyObject *, float *))PYGAMEAPI_GET_SLOT(base, 5))
|
||||
|
||||
#define pg_FloatFromObjIndex \
|
||||
(*(int (*)(PyObject *, int, float *))PYGAMEAPI_GET_SLOT(base, 6))
|
||||
|
||||
#define pg_TwoFloatsFromObj \
|
||||
(*(int (*)(PyObject *, float *, float *))PYGAMEAPI_GET_SLOT(base, 7))
|
||||
|
||||
#define pg_UintFromObj \
|
||||
(*(int (*)(PyObject *, Uint32 *))PYGAMEAPI_GET_SLOT(base, 8))
|
||||
|
||||
#define pg_UintFromObjIndex \
|
||||
(*(int (*)(PyObject *, int, Uint32 *))PYGAMEAPI_GET_SLOT(base, 9))
|
||||
|
||||
#define pg_mod_autoinit (*(int (*)(const char *))PYGAMEAPI_GET_SLOT(base, 10))
|
||||
|
||||
#define pg_mod_autoquit (*(void (*)(const char *))PYGAMEAPI_GET_SLOT(base, 11))
|
||||
|
||||
#define pg_RGBAFromObj \
|
||||
(*(int (*)(PyObject *, Uint8 *))PYGAMEAPI_GET_SLOT(base, 12))
|
||||
|
||||
#define pgBuffer_AsArrayInterface \
|
||||
(*(PyObject * (*)(Py_buffer *)) PYGAMEAPI_GET_SLOT(base, 13))
|
||||
|
||||
#define pgBuffer_AsArrayStruct \
|
||||
(*(PyObject * (*)(Py_buffer *)) PYGAMEAPI_GET_SLOT(base, 14))
|
||||
|
||||
#define pgObject_GetBuffer \
|
||||
(*(int (*)(PyObject *, pg_buffer *, int))PYGAMEAPI_GET_SLOT(base, 15))
|
||||
|
||||
#define pgBuffer_Release (*(void (*)(pg_buffer *))PYGAMEAPI_GET_SLOT(base, 16))
|
||||
|
||||
#define pgDict_AsBuffer \
|
||||
(*(int (*)(pg_buffer *, PyObject *, int))PYGAMEAPI_GET_SLOT(base, 17))
|
||||
|
||||
#define pgExc_BufferError ((PyObject *)PYGAMEAPI_GET_SLOT(base, 18))
|
||||
|
||||
#define pg_GetDefaultWindow \
|
||||
(*(SDL_Window * (*)(void)) PYGAMEAPI_GET_SLOT(base, 19))
|
||||
|
||||
#define pg_SetDefaultWindow \
|
||||
(*(void (*)(SDL_Window *))PYGAMEAPI_GET_SLOT(base, 20))
|
||||
|
||||
#define pg_GetDefaultWindowSurface \
|
||||
(*(pgSurfaceObject * (*)(void)) PYGAMEAPI_GET_SLOT(base, 21))
|
||||
|
||||
#define pg_SetDefaultWindowSurface \
|
||||
(*(void (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(base, 22))
|
||||
|
||||
#define pg_EnvShouldBlendAlphaSDL2 \
|
||||
(*(char *(*)(void))PYGAMEAPI_GET_SLOT(base, 23))
|
||||
|
||||
#define import_pygame_base() IMPORT_PYGAME_MODULE(base)
|
||||
#endif /* ~PYGAMEAPI_BASE_INTERNAL */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD SDL_Rect r;
|
||||
PyObject *weakreflist;
|
||||
} pgRectObject;
|
||||
|
||||
#define pgRect_AsRect(x) (((pgRectObject *)x)->r)
|
||||
#ifndef PYGAMEAPI_RECT_INTERNAL
|
||||
#define pgRect_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(rect, 0))
|
||||
|
||||
#define pgRect_Check(x) ((x)->ob_type == &pgRect_Type)
|
||||
#define pgRect_New (*(PyObject * (*)(SDL_Rect *)) PYGAMEAPI_GET_SLOT(rect, 1))
|
||||
|
||||
#define pgRect_New4 \
|
||||
(*(PyObject * (*)(int, int, int, int)) PYGAMEAPI_GET_SLOT(rect, 2))
|
||||
|
||||
#define pgRect_FromObject \
|
||||
(*(SDL_Rect * (*)(PyObject *, SDL_Rect *)) PYGAMEAPI_GET_SLOT(rect, 3))
|
||||
|
||||
#define pgRect_Normalize (*(void (*)(SDL_Rect *))PYGAMEAPI_GET_SLOT(rect, 4))
|
||||
|
||||
#define import_pygame_rect() IMPORT_PYGAME_MODULE(rect)
|
||||
#endif /* ~PYGAMEAPI_RECT_INTERNAL */
|
||||
|
||||
/*
|
||||
* CDROM module
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD int id;
|
||||
} pgCDObject;
|
||||
|
||||
#define pgCD_AsID(x) (((pgCDObject *)x)->id)
|
||||
#ifndef PYGAMEAPI_CDROM_INTERNAL
|
||||
#define pgCD_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(cdrom, 0))
|
||||
|
||||
#define pgCD_Check(x) ((x)->ob_type == &pgCD_Type)
|
||||
#define pgCD_New (*(PyObject * (*)(int)) PYGAMEAPI_GET_SLOT(cdrom, 1))
|
||||
|
||||
#define import_pygame_cd() IMPORT_PYGAME_MODULE(cdrom)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* JOYSTICK module
|
||||
*/
|
||||
typedef struct pgJoystickObject {
|
||||
PyObject_HEAD int id;
|
||||
SDL_Joystick *joy;
|
||||
|
||||
/* Joysticks form an intrusive linked list.
|
||||
*
|
||||
* Note that we don't maintain refcounts for these so they are weakrefs
|
||||
* from the Python side.
|
||||
*/
|
||||
struct pgJoystickObject *next;
|
||||
struct pgJoystickObject *prev;
|
||||
} pgJoystickObject;
|
||||
|
||||
#define pgJoystick_AsID(x) (((pgJoystickObject *)x)->id)
|
||||
#define pgJoystick_AsSDL(x) (((pgJoystickObject *)x)->joy)
|
||||
|
||||
#ifndef PYGAMEAPI_JOYSTICK_INTERNAL
|
||||
#define pgJoystick_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(joystick, 0))
|
||||
|
||||
#define pgJoystick_Check(x) ((x)->ob_type == &pgJoystick_Type)
|
||||
#define pgJoystick_New (*(PyObject * (*)(int)) PYGAMEAPI_GET_SLOT(joystick, 1))
|
||||
|
||||
#define import_pygame_joystick() IMPORT_PYGAME_MODULE(joystick)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* DISPLAY module
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
Uint32 hw_available : 1;
|
||||
Uint32 wm_available : 1;
|
||||
Uint32 blit_hw : 1;
|
||||
Uint32 blit_hw_CC : 1;
|
||||
Uint32 blit_hw_A : 1;
|
||||
Uint32 blit_sw : 1;
|
||||
Uint32 blit_sw_CC : 1;
|
||||
Uint32 blit_sw_A : 1;
|
||||
Uint32 blit_fill : 1;
|
||||
Uint32 video_mem;
|
||||
SDL_PixelFormat *vfmt;
|
||||
SDL_PixelFormat vfmt_data;
|
||||
int current_w;
|
||||
int current_h;
|
||||
} pg_VideoInfo;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD pg_VideoInfo info;
|
||||
} pgVidInfoObject;
|
||||
|
||||
#define pgVidInfo_AsVidInfo(x) (((pgVidInfoObject *)x)->info)
|
||||
|
||||
#ifndef PYGAMEAPI_DISPLAY_INTERNAL
|
||||
#define pgVidInfo_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(display, 0))
|
||||
|
||||
#define pgVidInfo_Check(x) ((x)->ob_type == &pgVidInfo_Type)
|
||||
#define pgVidInfo_New \
|
||||
(*(PyObject * (*)(pg_VideoInfo *)) PYGAMEAPI_GET_SLOT(display, 1))
|
||||
|
||||
#define import_pygame_display() IMPORT_PYGAME_MODULE(display)
|
||||
#endif /* ~PYGAMEAPI_DISPLAY_INTERNAL */
|
||||
|
||||
/*
|
||||
* SURFACE module
|
||||
*/
|
||||
struct pgSubSurface_Data;
|
||||
struct SDL_Surface;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD struct SDL_Surface *surf;
|
||||
int owner;
|
||||
struct pgSubSurface_Data *subsurface; /* ptr to subsurface data (if a
|
||||
* subsurface)*/
|
||||
PyObject *weakreflist;
|
||||
PyObject *locklist;
|
||||
PyObject *dependency;
|
||||
} pgSurfaceObject;
|
||||
#define pgSurface_AsSurface(x) (((pgSurfaceObject *)x)->surf)
|
||||
|
||||
#ifndef PYGAMEAPI_SURFACE_INTERNAL
|
||||
#define pgSurface_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(surface, 0))
|
||||
|
||||
#define pgSurface_Check(x) \
|
||||
(PyObject_IsInstance((x), (PyObject *)&pgSurface_Type))
|
||||
#define pgSurface_New2 \
|
||||
(*(pgSurfaceObject * (*)(SDL_Surface *, int)) \
|
||||
PYGAMEAPI_GET_SLOT(surface, 1))
|
||||
|
||||
#define pgSurface_SetSurface \
|
||||
(*(int (*)(pgSurfaceObject *, SDL_Surface *, int))PYGAMEAPI_GET_SLOT( \
|
||||
surface, 3))
|
||||
|
||||
#define pgSurface_Blit \
|
||||
(*(int (*)(pgSurfaceObject *, pgSurfaceObject *, SDL_Rect *, SDL_Rect *, \
|
||||
int))PYGAMEAPI_GET_SLOT(surface, 2))
|
||||
|
||||
#define import_pygame_surface() \
|
||||
do { \
|
||||
IMPORT_PYGAME_MODULE(surface); \
|
||||
if (PyErr_Occurred() != NULL) \
|
||||
break; \
|
||||
IMPORT_PYGAME_MODULE(surflock); \
|
||||
} while (0)
|
||||
|
||||
#define pgSurface_New(surface) pgSurface_New2((surface), 1)
|
||||
#define pgSurface_NewNoOwn(surface) pgSurface_New2((surface), 0)
|
||||
|
||||
#endif /* ~PYGAMEAPI_SURFACE_INTERNAL */
|
||||
|
||||
/*
|
||||
* SURFLOCK module
|
||||
* auto imported/initialized by surface
|
||||
*/
|
||||
#ifndef PYGAMEAPI_SURFLOCK_INTERNAL
|
||||
#define pgLifetimeLock_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(surflock, 0))
|
||||
|
||||
#define pgLifetimeLock_Check(x) ((x)->ob_type == &pgLifetimeLock_Type)
|
||||
|
||||
#define pgSurface_Prep(x) \
|
||||
if ((x)->subsurface) \
|
||||
(*(*(void (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(surflock, 1)))(x)
|
||||
|
||||
#define pgSurface_Unprep(x) \
|
||||
if ((x)->subsurface) \
|
||||
(*(*(void (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(surflock, 2)))(x)
|
||||
|
||||
#define pgSurface_Lock \
|
||||
(*(int (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(surflock, 3))
|
||||
|
||||
#define pgSurface_Unlock \
|
||||
(*(int (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(surflock, 4))
|
||||
|
||||
#define pgSurface_LockBy \
|
||||
(*(int (*)(pgSurfaceObject *, PyObject *))PYGAMEAPI_GET_SLOT(surflock, 5))
|
||||
|
||||
#define pgSurface_UnlockBy \
|
||||
(*(int (*)(pgSurfaceObject *, PyObject *))PYGAMEAPI_GET_SLOT(surflock, 6))
|
||||
|
||||
#define pgSurface_LockLifetime \
|
||||
(*(PyObject * (*)(PyObject *, PyObject *)) PYGAMEAPI_GET_SLOT(surflock, 7))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* EVENT module
|
||||
*/
|
||||
typedef struct pgEventObject pgEventObject;
|
||||
|
||||
#ifndef PYGAMEAPI_EVENT_INTERNAL
|
||||
#define pgEvent_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(event, 0))
|
||||
|
||||
#define pgEvent_Check(x) ((x)->ob_type == &pgEvent_Type)
|
||||
|
||||
#define pgEvent_New \
|
||||
(*(PyObject * (*)(SDL_Event *)) PYGAMEAPI_GET_SLOT(event, 1))
|
||||
|
||||
#define pgEvent_New2 \
|
||||
(*(PyObject * (*)(int, PyObject *)) PYGAMEAPI_GET_SLOT(event, 2))
|
||||
|
||||
#define pgEvent_FillUserEvent \
|
||||
(*(int (*)(pgEventObject *, SDL_Event *))PYGAMEAPI_GET_SLOT(event, 3))
|
||||
|
||||
#define pg_EnableKeyRepeat (*(int (*)(int, int))PYGAMEAPI_GET_SLOT(event, 4))
|
||||
|
||||
#define pg_GetKeyRepeat (*(void (*)(int *, int *))PYGAMEAPI_GET_SLOT(event, 5))
|
||||
|
||||
#define import_pygame_event() IMPORT_PYGAME_MODULE(event)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* RWOBJECT module
|
||||
* the rwobject are only needed for C side work, not accessable from python.
|
||||
*/
|
||||
#ifndef PYGAMEAPI_RWOBJECT_INTERNAL
|
||||
#define pgRWops_FromObject \
|
||||
(*(SDL_RWops * (*)(PyObject *)) PYGAMEAPI_GET_SLOT(rwobject, 0))
|
||||
|
||||
#define pgRWops_IsFileObject \
|
||||
(*(int (*)(SDL_RWops *))PYGAMEAPI_GET_SLOT(rwobject, 1))
|
||||
|
||||
#define pg_EncodeFilePath \
|
||||
(*(PyObject * (*)(PyObject *, PyObject *)) PYGAMEAPI_GET_SLOT(rwobject, 2))
|
||||
|
||||
#define pg_EncodeString \
|
||||
(*(PyObject * (*)(PyObject *, const char *, const char *, PyObject *)) \
|
||||
PYGAMEAPI_GET_SLOT(rwobject, 3))
|
||||
|
||||
#define pgRWops_FromFileObject \
|
||||
(*(SDL_RWops * (*)(PyObject *)) PYGAMEAPI_GET_SLOT(rwobject, 4))
|
||||
|
||||
#define pgRWops_ReleaseObject \
|
||||
(*(int (*)(SDL_RWops *))PYGAMEAPI_GET_SLOT(rwobject, 5))
|
||||
|
||||
#define pgRWops_GetFileExtension \
|
||||
(*(char *(*)(SDL_RWops *))PYGAMEAPI_GET_SLOT(rwobject, 6))
|
||||
|
||||
#define import_pygame_rwobject() IMPORT_PYGAME_MODULE(rwobject)
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PixelArray module
|
||||
*/
|
||||
#ifndef PYGAMEAPI_PIXELARRAY_INTERNAL
|
||||
#define PyPixelArray_Type ((PyTypeObject *)PYGAMEAPI_GET_SLOT(pixelarray, 0))
|
||||
|
||||
#define PyPixelArray_Check(x) ((x)->ob_type == &PyPixelArray_Type)
|
||||
#define PyPixelArray_New (*(PyObject * (*)) PYGAMEAPI_GET_SLOT(pixelarray, 1))
|
||||
|
||||
#define import_pygame_pixelarray() IMPORT_PYGAME_MODULE(pixelarray)
|
||||
#endif /* PYGAMEAPI_PIXELARRAY_INTERNAL */
|
||||
|
||||
/*
|
||||
* Color module
|
||||
*/
|
||||
typedef struct pgColorObject pgColorObject;
|
||||
|
||||
#ifndef PYGAMEAPI_COLOR_INTERNAL
|
||||
#define pgColor_Type (*(PyObject *)PYGAMEAPI_GET_SLOT(color, 0))
|
||||
|
||||
#define pgColor_Check(x) ((x)->ob_type == &pgColor_Type)
|
||||
#define pgColor_New (*(PyObject * (*)(Uint8 *)) PYGAMEAPI_GET_SLOT(color, 1))
|
||||
|
||||
#define pgColor_NewLength \
|
||||
(*(PyObject * (*)(Uint8 *, Uint8)) PYGAMEAPI_GET_SLOT(color, 3))
|
||||
|
||||
#define pg_RGBAFromColorObj \
|
||||
(*(int (*)(PyObject *, Uint8 *))PYGAMEAPI_GET_SLOT(color, 2))
|
||||
|
||||
#define pg_RGBAFromFuzzyColorObj \
|
||||
(*(int (*)(PyObject *, Uint8 *))PYGAMEAPI_GET_SLOT(color, 4))
|
||||
|
||||
#define pgColor_AsArray(x) (((pgColorObject *)x)->data)
|
||||
#define pgColor_NumComponents(x) (((pgColorObject *)x)->len)
|
||||
|
||||
#define import_pygame_color() IMPORT_PYGAME_MODULE(color)
|
||||
#endif /* PYGAMEAPI_COLOR_INTERNAL */
|
||||
|
||||
/*
|
||||
* Math module
|
||||
*/
|
||||
#ifndef PYGAMEAPI_MATH_INTERNAL
|
||||
#define pgVector2_Check(x) \
|
||||
((x)->ob_type == (PyTypeObject *)PYGAMEAPI_GET_SLOT(math, 0))
|
||||
|
||||
#define pgVector3_Check(x) \
|
||||
((x)->ob_type == (PyTypeObject *)PYGAMEAPI_GET_SLOT(math, 1))
|
||||
/*
|
||||
#define pgVector2_New \
|
||||
(*(PyObject*(*)) \
|
||||
PYGAMEAPI_GET_SLOT(PyGAME_C_API, 1))
|
||||
*/
|
||||
#define import_pygame_math() IMPORT_PYGAME_MODULE(math)
|
||||
#endif /* PYGAMEAPI_MATH_INTERNAL */
|
||||
|
||||
#define IMPORT_PYGAME_MODULE _IMPORT_PYGAME_MODULE
|
||||
|
||||
/*
|
||||
* base pygame API slots
|
||||
* disable slots with NO_PYGAME_C_API
|
||||
*/
|
||||
#ifdef PYGAME_H
|
||||
PYGAMEAPI_DEFINE_SLOTS(base);
|
||||
PYGAMEAPI_DEFINE_SLOTS(rect);
|
||||
PYGAMEAPI_DEFINE_SLOTS(cdrom);
|
||||
PYGAMEAPI_DEFINE_SLOTS(joystick);
|
||||
PYGAMEAPI_DEFINE_SLOTS(display);
|
||||
PYGAMEAPI_DEFINE_SLOTS(surface);
|
||||
PYGAMEAPI_DEFINE_SLOTS(surflock);
|
||||
PYGAMEAPI_DEFINE_SLOTS(event);
|
||||
PYGAMEAPI_DEFINE_SLOTS(rwobject);
|
||||
PYGAMEAPI_DEFINE_SLOTS(pixelarray);
|
||||
PYGAMEAPI_DEFINE_SLOTS(color);
|
||||
PYGAMEAPI_DEFINE_SLOTS(math);
|
||||
#else /* ~PYGAME_H */
|
||||
PYGAMEAPI_EXTERN_SLOTS(base);
|
||||
PYGAMEAPI_EXTERN_SLOTS(rect);
|
||||
PYGAMEAPI_EXTERN_SLOTS(cdrom);
|
||||
PYGAMEAPI_EXTERN_SLOTS(joystick);
|
||||
PYGAMEAPI_EXTERN_SLOTS(display);
|
||||
PYGAMEAPI_EXTERN_SLOTS(surface);
|
||||
PYGAMEAPI_EXTERN_SLOTS(surflock);
|
||||
PYGAMEAPI_EXTERN_SLOTS(event);
|
||||
PYGAMEAPI_EXTERN_SLOTS(rwobject);
|
||||
PYGAMEAPI_EXTERN_SLOTS(pixelarray);
|
||||
PYGAMEAPI_EXTERN_SLOTS(color);
|
||||
PYGAMEAPI_EXTERN_SLOTS(math);
|
||||
#endif /* ~PYGAME_H */
|
||||
|
||||
#endif /* PYGAME_H */
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
/*
|
||||
Bitmask 1.7 - A pixel-perfect collision detection library.
|
||||
|
||||
Copyright (C) 2002-2005 Ulf Ekstrom except for the bitcount
|
||||
function which is copyright (C) Donald W. Gillies, 1992.
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef BITMASK_H
|
||||
#define BITMASK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
/* Define INLINE for different compilers. If your compiler does not
|
||||
support inlining then there might be a performance hit in
|
||||
bitmask_overlap_area().
|
||||
*/
|
||||
#ifndef INLINE
|
||||
#ifdef __GNUC__
|
||||
#define INLINE inline
|
||||
#else
|
||||
#ifdef _MSC_VER
|
||||
#define INLINE __inline
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BITMASK_W unsigned long int
|
||||
#define BITMASK_W_LEN (sizeof(BITMASK_W) * CHAR_BIT)
|
||||
#define BITMASK_W_MASK (BITMASK_W_LEN - 1)
|
||||
#define BITMASK_N(n) ((BITMASK_W)1 << (n))
|
||||
|
||||
typedef struct bitmask {
|
||||
int w, h;
|
||||
BITMASK_W bits[1];
|
||||
} bitmask_t;
|
||||
|
||||
/* Creates a bitmask of width w and height h, where
|
||||
w and h must both be greater than or equal to 0.
|
||||
The mask is automatically cleared when created.
|
||||
*/
|
||||
bitmask_t *
|
||||
bitmask_create(int w, int h);
|
||||
|
||||
/* Frees all the memory allocated by bitmask_create for m. */
|
||||
void
|
||||
bitmask_free(bitmask_t *m);
|
||||
|
||||
/* Create a copy of the given bitmask. */
|
||||
bitmask_t *
|
||||
bitmask_copy(bitmask_t *m);
|
||||
|
||||
/* Clears all bits in the mask */
|
||||
void
|
||||
bitmask_clear(bitmask_t *m);
|
||||
|
||||
/* Sets all bits in the mask */
|
||||
void
|
||||
bitmask_fill(bitmask_t *m);
|
||||
|
||||
/* Flips all bits in the mask */
|
||||
void
|
||||
bitmask_invert(bitmask_t *m);
|
||||
|
||||
/* Counts the bits in the mask */
|
||||
unsigned int
|
||||
bitmask_count(bitmask_t *m);
|
||||
|
||||
/* Returns nonzero if the bit at (x,y) is set. Coordinates start at
|
||||
(0,0) */
|
||||
static INLINE int
|
||||
bitmask_getbit(const bitmask_t *m, int x, int y)
|
||||
{
|
||||
return (m->bits[x / BITMASK_W_LEN * m->h + y] &
|
||||
BITMASK_N(x & BITMASK_W_MASK)) != 0;
|
||||
}
|
||||
|
||||
/* Sets the bit at (x,y) */
|
||||
static INLINE void
|
||||
bitmask_setbit(bitmask_t *m, int x, int y)
|
||||
{
|
||||
m->bits[x / BITMASK_W_LEN * m->h + y] |= BITMASK_N(x & BITMASK_W_MASK);
|
||||
}
|
||||
|
||||
/* Clears the bit at (x,y) */
|
||||
static INLINE void
|
||||
bitmask_clearbit(bitmask_t *m, int x, int y)
|
||||
{
|
||||
m->bits[x / BITMASK_W_LEN * m->h + y] &= ~BITMASK_N(x & BITMASK_W_MASK);
|
||||
}
|
||||
|
||||
/* Returns nonzero if the masks overlap with the given offset.
|
||||
The overlap tests uses the following offsets (which may be negative):
|
||||
|
||||
+----+----------..
|
||||
|A | yoffset
|
||||
| +-+----------..
|
||||
+--|B
|
||||
|xoffset
|
||||
| |
|
||||
: :
|
||||
*/
|
||||
int
|
||||
bitmask_overlap(const bitmask_t *a, const bitmask_t *b, int xoffset,
|
||||
int yoffset);
|
||||
|
||||
/* Like bitmask_overlap(), but will also give a point of intersection.
|
||||
x and y are given in the coordinates of mask a, and are untouched
|
||||
if there is no overlap. */
|
||||
int
|
||||
bitmask_overlap_pos(const bitmask_t *a, const bitmask_t *b, int xoffset,
|
||||
int yoffset, int *x, int *y);
|
||||
|
||||
/* Returns the number of overlapping 'pixels' */
|
||||
int
|
||||
bitmask_overlap_area(const bitmask_t *a, const bitmask_t *b, int xoffset,
|
||||
int yoffset);
|
||||
|
||||
/* Fills a mask with the overlap of two other masks. A bitwise AND. */
|
||||
void
|
||||
bitmask_overlap_mask(const bitmask_t *a, const bitmask_t *b, bitmask_t *c,
|
||||
int xoffset, int yoffset);
|
||||
|
||||
/* Draws mask b onto mask a (bitwise OR). Can be used to compose large
|
||||
(game background?) mask from several submasks, which may speed up
|
||||
the testing. */
|
||||
|
||||
void
|
||||
bitmask_draw(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset);
|
||||
|
||||
void
|
||||
bitmask_erase(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset);
|
||||
|
||||
/* Return a new scaled bitmask, with dimensions w*h. The quality of the
|
||||
scaling may not be perfect for all circumstances, but it should
|
||||
be reasonable. If either w or h is 0 a clear 1x1 mask is returned. */
|
||||
bitmask_t *
|
||||
bitmask_scale(const bitmask_t *m, int w, int h);
|
||||
|
||||
/* Convolve b into a, drawing the output into o, shifted by offset. If offset
|
||||
* is 0, then the (x,y) bit will be set if and only if
|
||||
* bitmask_overlap(a, b, x - b->w - 1, y - b->h - 1) returns true.
|
||||
*
|
||||
* Modifies bits o[xoffset ... xoffset + a->w + b->w - 1)
|
||||
* [yoffset ... yoffset + a->h + b->h - 1). */
|
||||
void
|
||||
bitmask_convolve(const bitmask_t *a, const bitmask_t *b, bitmask_t *o,
|
||||
int xoffset, int yoffset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* End of extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
/* Python 2.x/3.x and SDL compatibility tools
|
||||
*/
|
||||
|
||||
#if !defined(PGCOMPAT_H)
|
||||
#define PGCOMPAT_H
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
/* define common types where SDL is not included */
|
||||
#ifndef SDL_VERSION_ATLEAST
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
typedef uint32_t Uint32;
|
||||
typedef uint8_t Uint8;
|
||||
#endif /* no SDL */
|
||||
|
||||
#if defined(SDL_VERSION_ATLEAST)
|
||||
|
||||
#ifndef SDL_WINDOW_VULKAN
|
||||
#define SDL_WINDOW_VULKAN 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_ALWAYS_ON_TOP
|
||||
#define SDL_WINDOW_ALWAYS_ON_TOP 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_SKIP_TASKBAR
|
||||
#define SDL_WINDOW_SKIP_TASKBAR 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_UTILITY
|
||||
#define SDL_WINDOW_UTILITY 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_TOOLTIP
|
||||
#define SDL_WINDOW_TOOLTIP 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_POPUP_MENU
|
||||
#define SDL_WINDOW_POPUP_MENU 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_INPUT_GRABBED
|
||||
#define SDL_WINDOW_INPUT_GRABBED 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_INPUT_FOCUS
|
||||
#define SDL_WINDOW_INPUT_FOCUS 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_MOUSE_FOCUS
|
||||
#define SDL_WINDOW_MOUSE_FOCUS 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_FOREIGN
|
||||
#define SDL_WINDOW_FOREIGN 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_ALLOW_HIGHDPI
|
||||
#define SDL_WINDOW_ALLOW_HIGHDPI 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_MOUSE_CAPTURE
|
||||
#define SDL_WINDOW_MOUSE_CAPTURE 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_ALWAYS_ON_TOP
|
||||
#define SDL_WINDOW_ALWAYS_ON_TOP 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_SKIP_TASKBAR
|
||||
#define SDL_WINDOW_SKIP_TASKBAR 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_UTILITY
|
||||
#define SDL_WINDOW_UTILITY 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_TOOLTIP
|
||||
#define SDL_WINDOW_TOOLTIP 0
|
||||
#endif
|
||||
|
||||
#ifndef SDL_WINDOW_POPUP_MENU
|
||||
#define SDL_WINDOW_POPUP_MENU 0
|
||||
#endif
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 4)
|
||||
/* To control the use of:
|
||||
* SDL_AUDIODEVICEADDED
|
||||
* SDL_AUDIODEVICEREMOVED
|
||||
*
|
||||
* Ref: https://wiki.libsdl.org/SDL_EventType
|
||||
* Ref: https://wiki.libsdl.org/SDL_AudioDeviceEvent
|
||||
*/
|
||||
#define SDL2_AUDIODEVICE_SUPPORTED
|
||||
#endif
|
||||
|
||||
#ifndef SDL_MOUSEWHEEL_FLIPPED
|
||||
#define NO_SDL_MOUSEWHEEL_FLIPPED
|
||||
#endif
|
||||
|
||||
#endif /* defined(SDL_VERSION_ATLEAST) */
|
||||
|
||||
#endif /* ~defined(PGCOMPAT_H) */
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
#ifndef PGIMPORT_H
|
||||
#define PGIMPORT_H
|
||||
|
||||
/* Prefix when initializing module */
|
||||
#define MODPREFIX ""
|
||||
/* Prefix when importing module */
|
||||
#define IMPPREFIX "pygame."
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
|
||||
/* On Symbian there is no pygame package. The extensions are built-in or in
|
||||
* sys\bin. */
|
||||
#undef MODPREFIX
|
||||
#undef IMPPREFIX
|
||||
#define MODPREFIX "pygame_"
|
||||
#define IMPPREFIX "pygame_"
|
||||
|
||||
#endif /* __SYMBIAN32__ */
|
||||
|
||||
#include "pgcompat.h"
|
||||
|
||||
#define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API"
|
||||
#define PG_CAPSULE_NAME(m) (IMPPREFIX m "." PYGAMEAPI_LOCAL_ENTRY)
|
||||
|
||||
/*
|
||||
* fill API slots defined by PYGAMEAPI_DEFINE_SLOTS/PYGAMEAPI_EXTERN_SLOTS
|
||||
*/
|
||||
#define _IMPORT_PYGAME_MODULE(module) \
|
||||
{ \
|
||||
PyObject *_mod_##module = PyImport_ImportModule(IMPPREFIX #module); \
|
||||
\
|
||||
if (_mod_##module != NULL) { \
|
||||
PyObject *_c_api = \
|
||||
PyObject_GetAttrString(_mod_##module, PYGAMEAPI_LOCAL_ENTRY); \
|
||||
\
|
||||
Py_DECREF(_mod_##module); \
|
||||
if (_c_api != NULL && PyCapsule_CheckExact(_c_api)) { \
|
||||
void **localptr = (void **)PyCapsule_GetPointer( \
|
||||
_c_api, PG_CAPSULE_NAME(#module)); \
|
||||
_PGSLOTS_##module = localptr; \
|
||||
} \
|
||||
Py_XDECREF(_c_api); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PYGAMEAPI_IS_IMPORTED(module) (_PGSLOTS_##module != NULL)
|
||||
|
||||
/*
|
||||
* source file must include one of these in order to use _IMPORT_PYGAME_MODULE.
|
||||
* this is set by import_pygame_*() functions.
|
||||
* disable with NO_PYGAME_C_API
|
||||
*/
|
||||
#define PYGAMEAPI_DEFINE_SLOTS(module) void **_PGSLOTS_##module = NULL
|
||||
#define PYGAMEAPI_EXTERN_SLOTS(module) extern void **_PGSLOTS_##module
|
||||
#define PYGAMEAPI_GET_SLOT(module, index) _PGSLOTS_##module[(index)]
|
||||
|
||||
/*
|
||||
* disabled API with NO_PYGAME_C_API; do nothing instead
|
||||
*/
|
||||
#ifdef NO_PYGAME_C_API
|
||||
|
||||
#undef PYGAMEAPI_DEFINE_SLOTS
|
||||
#undef PYGAMEAPI_EXTERN_SLOTS
|
||||
|
||||
#define PYGAMEAPI_DEFINE_SLOTS(module)
|
||||
#define PYGAMEAPI_EXTERN_SLOTS(module)
|
||||
|
||||
/* intentionally leave this defined to cause a compiler error *
|
||||
#define PYGAMEAPI_GET_SLOT(api_root, index)
|
||||
#undef PYGAMEAPI_GET_SLOT*/
|
||||
|
||||
#undef _IMPORT_PYGAME_MODULE
|
||||
#define _IMPORT_PYGAME_MODULE(module)
|
||||
|
||||
#endif /* NO_PYGAME_C_API */
|
||||
|
||||
#define encapsulate_api(ptr, module) \
|
||||
PyCapsule_New(ptr, PG_CAPSULE_NAME(module), NULL)
|
||||
|
||||
#endif /* ~PGIMPORT_H */
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* platform/compiler adjustments */
|
||||
#ifndef PG_PLATFORM_H
|
||||
#define PG_PLATFORM_H
|
||||
|
||||
#if defined(HAVE_SNPRINTF) /* defined in python.h (pyerrors.h) and SDL.h \
|
||||
(SDL_config.h) */
|
||||
#undef HAVE_SNPRINTF /* remove GCC redefine warning */
|
||||
#endif /* HAVE_SNPRINTF */
|
||||
|
||||
#ifndef PG_INLINE
|
||||
#if defined(__clang__)
|
||||
#define PG_INLINE __inline__ __attribute__((__unused__))
|
||||
#elif defined(__GNUC__)
|
||||
#define PG_INLINE __inline__
|
||||
#elif defined(_MSC_VER)
|
||||
#define PG_INLINE __inline
|
||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
#define PG_INLINE inline
|
||||
#else
|
||||
#define PG_INLINE
|
||||
#endif
|
||||
#endif /* ~PG_INLINE */
|
||||
|
||||
// Worth trying this on MSVC/win32 builds to see if provides any speed up
|
||||
#ifndef PG_FORCEINLINE
|
||||
#if defined(__clang__)
|
||||
#define PG_FORCEINLINE __inline__ __attribute__((__unused__))
|
||||
#elif defined(__GNUC__)
|
||||
#define PG_FORCEINLINE __inline__
|
||||
#elif defined(_MSC_VER)
|
||||
#define PG_FORCEINLINE __forceinline
|
||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
#define PG_FORCEINLINE inline
|
||||
#else
|
||||
#define PG_FORCEINLINE
|
||||
#endif
|
||||
#endif /* ~PG_FORCEINLINE */
|
||||
|
||||
/* This is unconditionally defined in Python.h */
|
||||
#if defined(_POSIX_C_SOURCE)
|
||||
#undef _POSIX_C_SOURCE
|
||||
#endif
|
||||
|
||||
/* No signal() */
|
||||
#if defined(__SYMBIAN32__) && defined(HAVE_SIGNAL_H)
|
||||
#undef HAVE_SIGNAL_H
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SNPRINTF)
|
||||
#undef HAVE_SNPRINTF
|
||||
#endif
|
||||
|
||||
/* SDL needs WIN32 */
|
||||
#if !defined(WIN32) && \
|
||||
(defined(MS_WIN32) || defined(_WIN32) || defined(__WIN32) || \
|
||||
defined(__WIN32__) || defined(_WINDOWS))
|
||||
#define WIN32
|
||||
#endif
|
||||
|
||||
/* Commenting out SSE4_2 stuff because it does not do runtime detection.
|
||||
#ifndef PG_TARGET_SSE4_2
|
||||
#if defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ == 4 &&
|
||||
__GNUC_MINOR__ >= 9) || __GNUC__ >= 5 ))
|
||||
//The old gcc 4.8 on centos used by manylinux1 does not seem to get sse4.2
|
||||
intrinsics #define PG_FUNCTION_TARGET_SSE4_2 __attribute__((target("sse4.2")))
|
||||
// No else; we define the fallback later
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
/* ~PG_TARGET_SSE4_2 */
|
||||
|
||||
/*
|
||||
#ifdef PG_FUNCTION_TARGET_SSE4_2
|
||||
#if !defined(__SSE4_2__) && !defined(PG_COMPILE_SSE4_2)
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#define PG_COMPILE_SSE4_2 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
/* ~PG_TARGET_SSE4_2 */
|
||||
|
||||
/* Fallback definition of target attribute */
|
||||
#ifndef PG_FUNCTION_TARGET_SSE4_2
|
||||
#define PG_FUNCTION_TARGET_SSE4_2
|
||||
#endif
|
||||
|
||||
#ifndef PG_COMPILE_SSE4_2
|
||||
#define PG_COMPILE_SSE4_2 0
|
||||
#endif
|
||||
|
||||
#endif /* ~PG_PLATFORM_H */
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
/* To allow the Pygame C api to be globally shared by all code within an
|
||||
* extension module built from multiple C files, only include the pygame.h
|
||||
* header within the top level C file, the one which calls the
|
||||
* 'import_pygame_*' macros. All other C source files of the module should
|
||||
* include _pygame.h instead.
|
||||
*/
|
||||
#ifndef PYGAME_H
|
||||
#define PYGAME_H
|
||||
|
||||
#include "_pygame.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
Copyright (C) 2007 Rene Dudfield, Richard Goedeken
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
/* Bufferproxy module C api. */
|
||||
#if !defined(PG_BUFPROXY_HEADER)
|
||||
#define PG_BUFPROXY_HEADER
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
typedef PyObject *(*_pgbufproxy_new_t)(PyObject *, getbufferproc);
|
||||
typedef PyObject *(*_pgbufproxy_get_obj_t)(PyObject *);
|
||||
typedef int (*_pgbufproxy_trip_t)(PyObject *);
|
||||
|
||||
#ifndef PYGAMEAPI_BUFPROXY_INTERNAL
|
||||
|
||||
#include "pgimport.h"
|
||||
|
||||
PYGAMEAPI_DEFINE_SLOTS(bufferproxy);
|
||||
|
||||
#define pgBufproxy_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(bufferproxy, 0))
|
||||
|
||||
#define pgBufproxy_Check(x) ((x)->ob_type == &pgBufproxy_Type)
|
||||
|
||||
#define pgBufproxy_New (*(_pgbufproxy_new_t)PYGAMEAPI_GET_SLOT(bufferproxy, 1))
|
||||
|
||||
#define pgBufproxy_GetParent \
|
||||
(*(_pgbufproxy_get_obj_t)PYGAMEAPI_GET_SLOT(bufferproxy, 2))
|
||||
|
||||
#define pgBufproxy_Trip \
|
||||
(*(_pgbufproxy_trip_t)PYGAMEAPI_GET_SLOT(bufferproxy, 3))
|
||||
|
||||
#define import_pygame_bufferproxy() _IMPORT_PYGAME_MODULE(bufferproxy)
|
||||
|
||||
#endif /* ~PYGAMEAPI_BUFPROXY_INTERNAL */
|
||||
|
||||
#endif /* ~defined(PG_BUFPROXY_HEADER) */
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include "pgplatform.h"
|
||||
|
||||
struct TTF_Font;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD TTF_Font *font;
|
||||
PyObject *weakreflist;
|
||||
unsigned int ttf_init_generation;
|
||||
} PyFontObject;
|
||||
#define PyFont_AsFont(x) (((PyFontObject *)x)->font)
|
||||
|
||||
#ifndef PYGAMEAPI_FONT_INTERNAL
|
||||
|
||||
#include "pgimport.h"
|
||||
|
||||
PYGAMEAPI_DEFINE_SLOTS(font);
|
||||
|
||||
#define PyFont_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(font, 0))
|
||||
#define PyFont_Check(x) ((x)->ob_type == &PyFont_Type)
|
||||
|
||||
#define PyFont_New (*(PyObject * (*)(TTF_Font *)) PYGAMEAPI_GET_SLOT(font, 1))
|
||||
|
||||
/*slot 2 taken by FONT_INIT_CHECK*/
|
||||
|
||||
#define import_pygame_font() _IMPORT_PYGAME_MODULE(font)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2009 Vicent Marti
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
#ifndef PYGAME_FREETYPE_H_
|
||||
#define PYGAME_FREETYPE_H_
|
||||
|
||||
#include "pgplatform.h"
|
||||
#include "pgimport.h"
|
||||
#include "pgcompat.h"
|
||||
|
||||
#ifndef PYGAME_FREETYPE_INTERNAL
|
||||
|
||||
PYGAMEAPI_DEFINE_SLOTS(_freetype);
|
||||
|
||||
#define pgFont_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(_freetype, 0))
|
||||
|
||||
#define pgFont_Check(x) ((x)->ob_type == &pgFont_Type)
|
||||
|
||||
#define pgFont_New \
|
||||
(*(PyObject * (*)(const char *, long)) PYGAMEAPI_GET_SLOT(_freetype, 1))
|
||||
|
||||
#define import_pygame_freetype() _IMPORT_PYGAME_MODULE(_freetype)
|
||||
|
||||
#endif /* PYGAME_FREETYPE_INTERNAL */
|
||||
|
||||
#endif /* PYGAME_FREETYPE_H_ */
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PGMASK_H
|
||||
#define PGMASK_H
|
||||
|
||||
#include <Python.h>
|
||||
#include "bitmask.h"
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD bitmask_t *mask;
|
||||
void *bufdata;
|
||||
} pgMaskObject;
|
||||
|
||||
#define pgMask_AsBitmap(x) (((pgMaskObject *)x)->mask)
|
||||
|
||||
#ifndef PYGAMEAPI_MASK_INTERNAL
|
||||
|
||||
#include "pgimport.h"
|
||||
|
||||
PYGAMEAPI_DEFINE_SLOTS(mask);
|
||||
|
||||
#define pgMask_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(mask, 0))
|
||||
#define pgMask_Check(x) ((x)->ob_type == &pgMask_Type)
|
||||
|
||||
#define import_pygame_mask() _IMPORT_PYGAME_MODULE(mask)
|
||||
|
||||
#endif /* ~PYGAMEAPI_MASK_INTERNAL */
|
||||
|
||||
#endif /* ~PGMASK_H */
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
#ifndef PGMIXER_H
|
||||
#define PGMIXER_H
|
||||
|
||||
#include <Python.h>
|
||||
#include <structmember.h>
|
||||
|
||||
#include "pgcompat.h"
|
||||
|
||||
struct Mix_Chunk;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD Mix_Chunk *chunk;
|
||||
Uint8 *mem;
|
||||
PyObject *weakreflist;
|
||||
} pgSoundObject;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD int chan;
|
||||
} pgChannelObject;
|
||||
|
||||
#define pgSound_AsChunk(x) (((pgSoundObject *)x)->chunk)
|
||||
#define pgChannel_AsInt(x) (((pgChannelObject *)x)->chan)
|
||||
|
||||
#include "pgimport.h"
|
||||
|
||||
#ifndef PYGAMEAPI_MIXER_INTERNAL
|
||||
|
||||
PYGAMEAPI_DEFINE_SLOTS(mixer);
|
||||
|
||||
#define pgSound_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(mixer, 0))
|
||||
|
||||
#define pgSound_Check(x) ((x)->ob_type == &pgSound_Type)
|
||||
|
||||
#define pgSound_New \
|
||||
(*(PyObject * (*)(Mix_Chunk *)) PYGAMEAPI_GET_SLOT(mixer, 1))
|
||||
|
||||
#define pgSound_Play \
|
||||
(*(PyObject * (*)(PyObject *, PyObject *)) PYGAMEAPI_GET_SLOT(mixer, 2))
|
||||
|
||||
#define pgChannel_Type (*(PyTypeObject *)PYGAMEAPI_GET_SLOT(mixer, 3))
|
||||
#define pgChannel_Check(x) ((x)->ob_type == &pgChannel_Type)
|
||||
|
||||
#define pgChannel_New (*(PyObject * (*)(int)) PYGAMEAPI_GET_SLOT(mixer, 4))
|
||||
|
||||
#define import_pygame_mixer() _IMPORT_PYGAME_MODULE(mixer)
|
||||
|
||||
#endif /* PYGAMEAPI_MIXER_INTERNAL */
|
||||
|
||||
#endif /* ~PGMIXER_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +0,0 @@
|
|||
#ifndef PGMASK_INTERNAL_H
|
||||
#define PGMASK_INTERNAL_H
|
||||
|
||||
#include "include/pygame_mask.h"
|
||||
#define PYGAMEAPI_MASK_NUMSLOTS 1
|
||||
|
||||
#endif /* ~PGMASK_INTERNAL_H */
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef MIXER_INTERNAL_H
|
||||
#define MIXER_INTERNAL_H
|
||||
|
||||
#include <SDL_mixer.h>
|
||||
|
||||
/* test mixer initializations */
|
||||
#define MIXER_INIT_CHECK() \
|
||||
if (!SDL_WasInit(SDL_INIT_AUDIO)) \
|
||||
return RAISE(pgExc_SDLError, "mixer not initialized")
|
||||
|
||||
#define PYGAMEAPI_MIXER_NUMSLOTS 5
|
||||
#include "include/pygame_mixer.h"
|
||||
|
||||
#endif /* ~MIXER_INTERNAL_H */
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
#ifndef PALETTE_H
|
||||
#define PALETTE_H
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
/* SDL 2 does not assign a default palette color scheme to a new 8 bit
|
||||
* surface. Instead, the palette is set all white. This defines the SDL 1.2
|
||||
* default palette.
|
||||
*/
|
||||
static const SDL_Color default_palette_colors[] = {
|
||||
{0, 0, 0, 255}, {0, 0, 85, 255}, {0, 0, 170, 255},
|
||||
{0, 0, 255, 255}, {0, 36, 0, 255}, {0, 36, 85, 255},
|
||||
{0, 36, 170, 255}, {0, 36, 255, 255}, {0, 73, 0, 255},
|
||||
{0, 73, 85, 255}, {0, 73, 170, 255}, {0, 73, 255, 255},
|
||||
{0, 109, 0, 255}, {0, 109, 85, 255}, {0, 109, 170, 255},
|
||||
{0, 109, 255, 255}, {0, 146, 0, 255}, {0, 146, 85, 255},
|
||||
{0, 146, 170, 255}, {0, 146, 255, 255}, {0, 182, 0, 255},
|
||||
{0, 182, 85, 255}, {0, 182, 170, 255}, {0, 182, 255, 255},
|
||||
{0, 219, 0, 255}, {0, 219, 85, 255}, {0, 219, 170, 255},
|
||||
{0, 219, 255, 255}, {0, 255, 0, 255}, {0, 255, 85, 255},
|
||||
{0, 255, 170, 255}, {0, 255, 255, 255}, {85, 0, 0, 255},
|
||||
{85, 0, 85, 255}, {85, 0, 170, 255}, {85, 0, 255, 255},
|
||||
{85, 36, 0, 255}, {85, 36, 85, 255}, {85, 36, 170, 255},
|
||||
{85, 36, 255, 255}, {85, 73, 0, 255}, {85, 73, 85, 255},
|
||||
{85, 73, 170, 255}, {85, 73, 255, 255}, {85, 109, 0, 255},
|
||||
{85, 109, 85, 255}, {85, 109, 170, 255}, {85, 109, 255, 255},
|
||||
{85, 146, 0, 255}, {85, 146, 85, 255}, {85, 146, 170, 255},
|
||||
{85, 146, 255, 255}, {85, 182, 0, 255}, {85, 182, 85, 255},
|
||||
{85, 182, 170, 255}, {85, 182, 255, 255}, {85, 219, 0, 255},
|
||||
{85, 219, 85, 255}, {85, 219, 170, 255}, {85, 219, 255, 255},
|
||||
{85, 255, 0, 255}, {85, 255, 85, 255}, {85, 255, 170, 255},
|
||||
{85, 255, 255, 255}, {170, 0, 0, 255}, {170, 0, 85, 255},
|
||||
{170, 0, 170, 255}, {170, 0, 255, 255}, {170, 36, 0, 255},
|
||||
{170, 36, 85, 255}, {170, 36, 170, 255}, {170, 36, 255, 255},
|
||||
{170, 73, 0, 255}, {170, 73, 85, 255}, {170, 73, 170, 255},
|
||||
{170, 73, 255, 255}, {170, 109, 0, 255}, {170, 109, 85, 255},
|
||||
{170, 109, 170, 255}, {170, 109, 255, 255}, {170, 146, 0, 255},
|
||||
{170, 146, 85, 255}, {170, 146, 170, 255}, {170, 146, 255, 255},
|
||||
{170, 182, 0, 255}, {170, 182, 85, 255}, {170, 182, 170, 255},
|
||||
{170, 182, 255, 255}, {170, 219, 0, 255}, {170, 219, 85, 255},
|
||||
{170, 219, 170, 255}, {170, 219, 255, 255}, {170, 255, 0, 255},
|
||||
{170, 255, 85, 255}, {170, 255, 170, 255}, {170, 255, 255, 255},
|
||||
{255, 0, 0, 255}, {255, 0, 85, 255}, {255, 0, 170, 255},
|
||||
{255, 0, 255, 255}, {255, 36, 0, 255}, {255, 36, 85, 255},
|
||||
{255, 36, 170, 255}, {255, 36, 255, 255}, {255, 73, 0, 255},
|
||||
{255, 73, 85, 255}, {255, 73, 170, 255}, {255, 73, 255, 255},
|
||||
{255, 109, 0, 255}, {255, 109, 85, 255}, {255, 109, 170, 255},
|
||||
{255, 109, 255, 255}, {255, 146, 0, 255}, {255, 146, 85, 255},
|
||||
{255, 146, 170, 255}, {255, 146, 255, 255}, {255, 182, 0, 255},
|
||||
{255, 182, 85, 255}, {255, 182, 170, 255}, {255, 182, 255, 255},
|
||||
{255, 219, 0, 255}, {255, 219, 85, 255}, {255, 219, 170, 255},
|
||||
{255, 219, 255, 255}, {255, 255, 0, 255}, {255, 255, 85, 255},
|
||||
{255, 255, 170, 255}, {255, 255, 255, 255}, {0, 0, 0, 255},
|
||||
{0, 0, 85, 255}, {0, 0, 170, 255}, {0, 0, 255, 255},
|
||||
{0, 36, 0, 255}, {0, 36, 85, 255}, {0, 36, 170, 255},
|
||||
{0, 36, 255, 255}, {0, 73, 0, 255}, {0, 73, 85, 255},
|
||||
{0, 73, 170, 255}, {0, 73, 255, 255}, {0, 109, 0, 255},
|
||||
{0, 109, 85, 255}, {0, 109, 170, 255}, {0, 109, 255, 255},
|
||||
{0, 146, 0, 255}, {0, 146, 85, 255}, {0, 146, 170, 255},
|
||||
{0, 146, 255, 255}, {0, 182, 0, 255}, {0, 182, 85, 255},
|
||||
{0, 182, 170, 255}, {0, 182, 255, 255}, {0, 219, 0, 255},
|
||||
{0, 219, 85, 255}, {0, 219, 170, 255}, {0, 219, 255, 255},
|
||||
{0, 255, 0, 255}, {0, 255, 85, 255}, {0, 255, 170, 255},
|
||||
{0, 255, 255, 255}, {85, 0, 0, 255}, {85, 0, 85, 255},
|
||||
{85, 0, 170, 255}, {85, 0, 255, 255}, {85, 36, 0, 255},
|
||||
{85, 36, 85, 255}, {85, 36, 170, 255}, {85, 36, 255, 255},
|
||||
{85, 73, 0, 255}, {85, 73, 85, 255}, {85, 73, 170, 255},
|
||||
{85, 73, 255, 255}, {85, 109, 0, 255}, {85, 109, 85, 255},
|
||||
{85, 109, 170, 255}, {85, 109, 255, 255}, {85, 146, 0, 255},
|
||||
{85, 146, 85, 255}, {85, 146, 170, 255}, {85, 146, 255, 255},
|
||||
{85, 182, 0, 255}, {85, 182, 85, 255}, {85, 182, 170, 255},
|
||||
{85, 182, 255, 255}, {85, 219, 0, 255}, {85, 219, 85, 255},
|
||||
{85, 219, 170, 255}, {85, 219, 255, 255}, {85, 255, 0, 255},
|
||||
{85, 255, 85, 255}, {85, 255, 170, 255}, {85, 255, 255, 255},
|
||||
{170, 0, 0, 255}, {170, 0, 85, 255}, {170, 0, 170, 255},
|
||||
{170, 0, 255, 255}, {170, 36, 0, 255}, {170, 36, 85, 255},
|
||||
{170, 36, 170, 255}, {170, 36, 255, 255}, {170, 73, 0, 255},
|
||||
{170, 73, 85, 255}, {170, 73, 170, 255}, {170, 73, 255, 255},
|
||||
{170, 109, 0, 255}, {170, 109, 85, 255}, {170, 109, 170, 255},
|
||||
{170, 109, 255, 255}, {170, 146, 0, 255}, {170, 146, 85, 255},
|
||||
{170, 146, 170, 255}, {170, 146, 255, 255}, {170, 182, 0, 255},
|
||||
{170, 182, 85, 255}, {170, 182, 170, 255}, {170, 182, 255, 255},
|
||||
{170, 219, 0, 255}, {170, 219, 85, 255}, {170, 219, 170, 255},
|
||||
{170, 219, 255, 255}, {170, 255, 0, 255}, {170, 255, 85, 255},
|
||||
{170, 255, 170, 255}, {170, 255, 255, 255}, {255, 0, 0, 255},
|
||||
{255, 0, 85, 255}, {255, 0, 170, 255}, {255, 0, 255, 255},
|
||||
{255, 36, 0, 255}, {255, 36, 85, 255}, {255, 36, 170, 255},
|
||||
{255, 36, 255, 255}, {255, 73, 0, 255}, {255, 73, 85, 255},
|
||||
{255, 73, 170, 255}, {255, 73, 255, 255}, {255, 109, 0, 255},
|
||||
{255, 109, 85, 255}, {255, 109, 170, 255}, {255, 109, 255, 255},
|
||||
{255, 146, 0, 255}, {255, 146, 85, 255}, {255, 146, 170, 255},
|
||||
{255, 146, 255, 255}, {255, 182, 0, 255}, {255, 182, 85, 255},
|
||||
{255, 182, 170, 255}, {255, 182, 255, 255}, {255, 219, 0, 255},
|
||||
{255, 219, 85, 255}, {255, 219, 170, 255}, {255, 219, 255, 255},
|
||||
{255, 255, 0, 255}, {255, 255, 85, 255}, {255, 255, 170, 255},
|
||||
{255, 255, 255, 255}};
|
||||
|
||||
static const int default_palette_size =
|
||||
(int)(sizeof(default_palette_colors) / sizeof(SDL_Color));
|
||||
|
||||
#endif
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
/* array structure interface version 3 declarations */
|
||||
|
||||
#if !defined(PG_ARRAYINTER_HEADER)
|
||||
#define PG_ARRAYINTER_HEADER
|
||||
|
||||
static const int PAI_CONTIGUOUS = 0x01;
|
||||
static const int PAI_FORTRAN = 0x02;
|
||||
static const int PAI_ALIGNED = 0x100;
|
||||
static const int PAI_NOTSWAPPED = 0x200;
|
||||
static const int PAI_WRITEABLE = 0x400;
|
||||
static const int PAI_ARR_HAS_DESCR = 0x800;
|
||||
|
||||
typedef struct {
|
||||
int two; /* contains the integer 2 -- simple sanity check */
|
||||
int nd; /* number of dimensions */
|
||||
char typekind; /* kind in array -- character code of typestr */
|
||||
int itemsize; /* size of each element */
|
||||
int flags; /* flags indicating how the data should be */
|
||||
/* interpreted */
|
||||
Py_intptr_t *shape; /* A length-nd array of shape information */
|
||||
Py_intptr_t *strides; /* A length-nd array of stride information */
|
||||
void *data; /* A pointer to the first element of the array */
|
||||
PyObject *descr; /* NULL or a data-description */
|
||||
} PyArrayInterface;
|
||||
|
||||
#endif
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
#ifndef PG_BUFPROXY_INTERNAL_H
|
||||
#define PG_BUFPROXY_INTERNAL_H
|
||||
|
||||
#include "include/pygame_bufferproxy.h"
|
||||
#define PYGAMEAPI_BUFPROXY_NUMSLOTS 4
|
||||
|
||||
#endif /* ~PG_BUFPROXY_INTERNAL_H */
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/* Python 2.x/3.x compatibility tools (internal)
|
||||
*/
|
||||
#ifndef PGCOMPAT_INTERNAL_H
|
||||
#define PGCOMPAT_INTERNAL_H
|
||||
|
||||
#include "include/pgcompat.h"
|
||||
|
||||
/* Module init function returns new module instance. */
|
||||
#define MODINIT_DEFINE(mod_name) PyMODINIT_FUNC PyInit_##mod_name(void)
|
||||
|
||||
/* Defaults for unicode file path encoding */
|
||||
#if defined(MS_WIN32)
|
||||
#define UNICODE_DEF_FS_ERROR "replace"
|
||||
#else
|
||||
#define UNICODE_DEF_FS_ERROR "surrogateescape"
|
||||
#endif
|
||||
|
||||
#define RELATIVE_MODULE(m) ("." m)
|
||||
|
||||
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
|
||||
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
|
||||
#endif
|
||||
|
||||
#ifndef Py_TPFLAGS_HAVE_CLASS
|
||||
#define Py_TPFLAGS_HAVE_CLASS 0
|
||||
#endif
|
||||
|
||||
#ifndef Py_TPFLAGS_CHECKTYPES
|
||||
#define Py_TPFLAGS_CHECKTYPES 0
|
||||
#endif
|
||||
|
||||
#define Slice_GET_INDICES_EX(slice, length, start, stop, step, slicelength) \
|
||||
PySlice_GetIndicesEx(slice, length, start, stop, step, slicelength)
|
||||
|
||||
#if defined(SDL_VERSION_ATLEAST)
|
||||
#if !(SDL_VERSION_ATLEAST(2, 0, 5))
|
||||
/* These functions require SDL 2.0.5 or greater.
|
||||
|
||||
https://wiki.libsdl.org/SDL_SetWindowResizable
|
||||
*/
|
||||
void
|
||||
SDL_SetWindowResizable(SDL_Window *window, SDL_bool resizable);
|
||||
int
|
||||
SDL_GetWindowOpacity(SDL_Window *window, float *opacity);
|
||||
int
|
||||
SDL_SetWindowOpacity(SDL_Window *window, float opacity);
|
||||
int
|
||||
SDL_SetWindowModalFor(SDL_Window *modal_window, SDL_Window *parent_window);
|
||||
int
|
||||
SDL_SetWindowInputFocus(SDL_Window *window);
|
||||
SDL_Surface *
|
||||
SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 format);
|
||||
#endif /* !(SDL_VERSION_ATLEAST(2, 0, 5)) */
|
||||
#endif /* defined(SDL_VERSION_ATLEAST) */
|
||||
|
||||
#endif /* ~PGCOMPAT_INTERNAL_H */
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#if !defined(PGOPENGL_H)
|
||||
#define PGOPENGL_H
|
||||
|
||||
/** This header includes definitions of Opengl functions as pointer types for
|
||||
** use with the SDL function SDL_GL_GetProcAddress.
|
||||
**/
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define GL_APIENTRY __stdcall
|
||||
#else
|
||||
#define GL_APIENTRY
|
||||
#endif
|
||||
|
||||
typedef void(GL_APIENTRY *GL_glReadPixels_Func)(int, int, int, int,
|
||||
unsigned int, unsigned int,
|
||||
void *);
|
||||
|
||||
typedef void(GL_APIENTRY *GL_glViewport_Func)(int, int, unsigned int,
|
||||
unsigned int);
|
||||
#endif
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/* platform/compiler adjustments (internal) */
|
||||
#ifndef PG_PLATFORM_INTERNAL_H
|
||||
#define PG_PLATFORM_INTERNAL_H
|
||||
|
||||
/* This must be before all else */
|
||||
#if defined(__SYMBIAN32__) && defined(OPENC)
|
||||
#include <sys/types.h>
|
||||
#if defined(__WINS__)
|
||||
void *
|
||||
_alloca(size_t size);
|
||||
#define alloca _alloca
|
||||
#endif /* __WINS__ */
|
||||
#endif /* defined(__SYMBIAN32__) && defined(OPENC) */
|
||||
|
||||
#include "include/pgplatform.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef ABS
|
||||
#define ABS(a) (((a) < 0) ? -(a) : (a))
|
||||
#endif
|
||||
|
||||
#if defined(macintosh) && defined(__MWERKS__) || defined(__SYMBIAN32__)
|
||||
#define PYGAME_EXPORT __declspec(export)
|
||||
#else
|
||||
#define PYGAME_EXPORT
|
||||
#endif
|
||||
|
||||
/* warnings */
|
||||
#define PG_STRINGIZE_HELPER(x) #x
|
||||
#define PG_STRINGIZE(x) PG_STRINGIZE_HELPER(x)
|
||||
#define PG_WARN(desc) \
|
||||
message(__FILE__ "(" PG_STRINGIZE(__LINE__) "): WARNING: " #desc)
|
||||
|
||||
#endif /* ~PG_PLATFORM_INTERNAL_H */
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
/* This will use PYGAMEAPI_DEFINE_SLOTS instead
|
||||
* of PYGAMEAPI_EXTERN_SLOTS for base modules.
|
||||
*/
|
||||
#ifndef PYGAME_INTERNAL_H
|
||||
#define PYGAME_INTERNAL_H
|
||||
|
||||
#define PYGAME_H
|
||||
#include "_pygame.h"
|
||||
|
||||
#endif /* ~PYGAME_INTERNAL_H */
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2006, 2007 Rene Dudfield, Marcus von Appen
|
||||
|
||||
Originally put in the public domain by Sam Lantinga.
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef SCRAP_H
|
||||
#define SCRAP_H
|
||||
|
||||
/* This is unconditionally defined in Python.h */
|
||||
#if defined(_POSIX_C_SOURCE)
|
||||
#undef _POSIX_C_SOURCE
|
||||
#endif
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
/* Handle clipboard text and data in arbitrary formats */
|
||||
|
||||
/**
|
||||
* Predefined supported pygame scrap types.
|
||||
*/
|
||||
#define PYGAME_SCRAP_TEXT "text/plain"
|
||||
#define PYGAME_SCRAP_BMP "image/bmp"
|
||||
#define PYGAME_SCRAP_PPM "image/ppm"
|
||||
#define PYGAME_SCRAP_PBM "image/pbm"
|
||||
|
||||
/**
|
||||
* The supported scrap clipboard types.
|
||||
*
|
||||
* This is only relevant in a X11 environment, which supports mouse
|
||||
* selections as well. For Win32 and MacOS environments the default
|
||||
* clipboard is used, no matter what value is passed.
|
||||
*/
|
||||
typedef enum {
|
||||
SCRAP_CLIPBOARD,
|
||||
SCRAP_SELECTION /* only supported in X11 environments. */
|
||||
} ScrapClipType;
|
||||
|
||||
/**
|
||||
* Macro for initialization checks.
|
||||
*/
|
||||
#define PYGAME_SCRAP_INIT_CHECK() \
|
||||
if (!pygame_scrap_initialized()) \
|
||||
return (PyErr_SetString(pgExc_SDLError, "scrap system not initialized."), \
|
||||
NULL)
|
||||
|
||||
/**
|
||||
* \brief Checks, whether the pygame scrap module was initialized.
|
||||
*
|
||||
* \return 1 if the modules was initialized, 0 otherwise.
|
||||
*/
|
||||
extern int
|
||||
pygame_scrap_initialized(void);
|
||||
|
||||
/**
|
||||
* \brief Initializes the pygame scrap module internals. Call this before any
|
||||
* other method.
|
||||
*
|
||||
* \return 1 on successful initialization, 0 otherwise.
|
||||
*/
|
||||
extern int
|
||||
pygame_scrap_init(void);
|
||||
|
||||
/**
|
||||
* \brief Checks, whether the pygame window lost the clipboard focus or not.
|
||||
*
|
||||
* \return 1 if the window lost the focus, 0 otherwise.
|
||||
*/
|
||||
extern int
|
||||
pygame_scrap_lost(void);
|
||||
|
||||
/**
|
||||
* \brief Places content of a specific type into the clipboard.
|
||||
*
|
||||
* \note For X11 the following notes are important: The following types
|
||||
* are reserved for internal usage and thus will throw an error on
|
||||
* setting them: "TIMESTAMP", "TARGETS", "SDL_SELECTION".
|
||||
* Setting PYGAME_SCRAP_TEXT ("text/plain") will also automatically
|
||||
* set the X11 types "STRING" (XA_STRING), "TEXT" and "UTF8_STRING".
|
||||
*
|
||||
* For Win32 the following notes are important: Setting
|
||||
* PYGAME_SCRAP_TEXT ("text/plain") will also automatically set
|
||||
* the Win32 type "TEXT" (CF_TEXT).
|
||||
*
|
||||
* For QNX the following notes are important: Setting
|
||||
* PYGAME_SCRAP_TEXT ("text/plain") will also automatically set
|
||||
* the QNX type "TEXT" (Ph_CL_TEXT).
|
||||
*
|
||||
* \param type The type of the content.
|
||||
* \param srclen The length of the content.
|
||||
* \param src The NULL terminated content.
|
||||
* \return 1, if the content could be successfully pasted into the clipboard,
|
||||
* 0 otherwise.
|
||||
*/
|
||||
extern int
|
||||
pygame_scrap_put(char *type, int srclen, char *src);
|
||||
|
||||
/**
|
||||
* \brief Gets the current content from the clipboard.
|
||||
*
|
||||
* \note The received content does not need to be the content previously
|
||||
* placed in the clipboard using pygame_put_scrap(). See the
|
||||
* pygame_put_scrap() notes for more details.
|
||||
*
|
||||
* \param type The type of the content to receive.
|
||||
* \param count The size of the returned content.
|
||||
* \return The content or NULL in case of an error or if no content of the
|
||||
* specified type was available.
|
||||
*/
|
||||
extern char *
|
||||
pygame_scrap_get(char *type, unsigned long *count);
|
||||
|
||||
/**
|
||||
* \brief Gets the currently available content types from the clipboard.
|
||||
*
|
||||
* \return The different available content types or NULL in case of an
|
||||
* error or if no content type is available.
|
||||
*/
|
||||
extern char **
|
||||
pygame_scrap_get_types(void);
|
||||
|
||||
/**
|
||||
* \brief Checks whether content for the specified scrap type is currently
|
||||
* available in the clipboard.
|
||||
*
|
||||
* \param type The type to check for.
|
||||
* \return 1, if there is content and 0 otherwise.
|
||||
*/
|
||||
extern int
|
||||
pygame_scrap_contains(char *type);
|
||||
|
||||
#endif /* SCRAP_H */
|
||||
|
|
@ -1,355 +0,0 @@
|
|||
/*
|
||||
pygame - Python Game Library
|
||||
Copyright (C) 2000-2001 Pete Shinners
|
||||
Copyright (C) 2007 Marcus von Appen
|
||||
|
||||
This library 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 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Pete Shinners
|
||||
pete@shinners.org
|
||||
*/
|
||||
|
||||
#ifndef SURFACE_H
|
||||
#define SURFACE_H
|
||||
|
||||
/* This is defined in SDL.h */
|
||||
#if defined(_POSIX_C_SOURCE)
|
||||
#undef _POSIX_C_SOURCE
|
||||
#endif
|
||||
|
||||
#include <SDL.h>
|
||||
#include "pygame.h"
|
||||
|
||||
/* Blend modes */
|
||||
#define PYGAME_BLEND_ADD 0x1
|
||||
#define PYGAME_BLEND_SUB 0x2
|
||||
#define PYGAME_BLEND_MULT 0x3
|
||||
#define PYGAME_BLEND_MIN 0x4
|
||||
#define PYGAME_BLEND_MAX 0x5
|
||||
|
||||
#define PYGAME_BLEND_RGB_ADD 0x1
|
||||
#define PYGAME_BLEND_RGB_SUB 0x2
|
||||
#define PYGAME_BLEND_RGB_MULT 0x3
|
||||
#define PYGAME_BLEND_RGB_MIN 0x4
|
||||
#define PYGAME_BLEND_RGB_MAX 0x5
|
||||
|
||||
#define PYGAME_BLEND_RGBA_ADD 0x6
|
||||
#define PYGAME_BLEND_RGBA_SUB 0x7
|
||||
#define PYGAME_BLEND_RGBA_MULT 0x8
|
||||
#define PYGAME_BLEND_RGBA_MIN 0x9
|
||||
#define PYGAME_BLEND_RGBA_MAX 0x10
|
||||
#define PYGAME_BLEND_PREMULTIPLIED 0x11
|
||||
#define PYGAME_BLEND_ALPHA_SDL2 0x12
|
||||
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define GET_PIXEL_24(b) (b[0] + (b[1] << 8) + (b[2] << 16))
|
||||
#else
|
||||
#define GET_PIXEL_24(b) (b[2] + (b[1] << 8) + (b[0] << 16))
|
||||
#endif
|
||||
|
||||
#define GET_PIXEL(pxl, bpp, source) \
|
||||
switch (bpp) { \
|
||||
case 2: \
|
||||
pxl = *((Uint16 *)(source)); \
|
||||
break; \
|
||||
case 4: \
|
||||
pxl = *((Uint32 *)(source)); \
|
||||
break; \
|
||||
default: { \
|
||||
Uint8 *b = (Uint8 *)source; \
|
||||
pxl = GET_PIXEL_24(b); \
|
||||
} break; \
|
||||
}
|
||||
|
||||
#define GET_PIXELVALS(_sR, _sG, _sB, _sA, px, fmt, ppa) \
|
||||
SDL_GetRGBA(px, fmt, &(_sR), &(_sG), &(_sB), &(_sA)); \
|
||||
if (!ppa) { \
|
||||
_sA = 255; \
|
||||
}
|
||||
|
||||
#define GET_PIXELVALS_1(sr, sg, sb, sa, _src, _fmt) \
|
||||
sr = _fmt->palette->colors[*((Uint8 *)(_src))].r; \
|
||||
sg = _fmt->palette->colors[*((Uint8 *)(_src))].g; \
|
||||
sb = _fmt->palette->colors[*((Uint8 *)(_src))].b; \
|
||||
sa = 255;
|
||||
|
||||
/* For 1 byte palette pixels */
|
||||
#define SET_PIXELVAL(px, fmt, _dR, _dG, _dB, _dA) \
|
||||
*(px) = (Uint8)SDL_MapRGBA(fmt, _dR, _dG, _dB, _dA)
|
||||
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
#define SET_OFFSETS_24(or, og, ob, fmt) \
|
||||
{ \
|
||||
or = (fmt->Rshift == 0 ? 0 : fmt->Rshift == 8 ? 1 : 2); \
|
||||
og = (fmt->Gshift == 0 ? 0 : fmt->Gshift == 8 ? 1 : 2); \
|
||||
ob = (fmt->Bshift == 0 ? 0 : fmt->Bshift == 8 ? 1 : 2); \
|
||||
}
|
||||
|
||||
#define SET_OFFSETS_32(or, og, ob, fmt) \
|
||||
{ \
|
||||
or = (fmt->Rshift == 0 ? 0 \
|
||||
: fmt->Rshift == 8 ? 1 \
|
||||
: fmt->Rshift == 16 ? 2 \
|
||||
: 3); \
|
||||
og = (fmt->Gshift == 0 ? 0 \
|
||||
: fmt->Gshift == 8 ? 1 \
|
||||
: fmt->Gshift == 16 ? 2 \
|
||||
: 3); \
|
||||
ob = (fmt->Bshift == 0 ? 0 \
|
||||
: fmt->Bshift == 8 ? 1 \
|
||||
: fmt->Bshift == 16 ? 2 \
|
||||
: 3); \
|
||||
}
|
||||
#else
|
||||
#define SET_OFFSETS_24(or, og, ob, fmt) \
|
||||
{ \
|
||||
or = (fmt->Rshift == 0 ? 2 : fmt->Rshift == 8 ? 1 : 0); \
|
||||
og = (fmt->Gshift == 0 ? 2 : fmt->Gshift == 8 ? 1 : 0); \
|
||||
ob = (fmt->Bshift == 0 ? 2 : fmt->Bshift == 8 ? 1 : 0); \
|
||||
}
|
||||
|
||||
#define SET_OFFSETS_32(or, og, ob, fmt) \
|
||||
{ \
|
||||
or = (fmt->Rshift == 0 ? 3 \
|
||||
: fmt->Rshift == 8 ? 2 \
|
||||
: fmt->Rshift == 16 ? 1 \
|
||||
: 0); \
|
||||
og = (fmt->Gshift == 0 ? 3 \
|
||||
: fmt->Gshift == 8 ? 2 \
|
||||
: fmt->Gshift == 16 ? 1 \
|
||||
: 0); \
|
||||
ob = (fmt->Bshift == 0 ? 3 \
|
||||
: fmt->Bshift == 8 ? 2 \
|
||||
: fmt->Bshift == 16 ? 1 \
|
||||
: 0); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CREATE_PIXEL(buf, r, g, b, a, bp, ft) \
|
||||
switch (bp) { \
|
||||
case 2: \
|
||||
*((Uint16 *)(buf)) = ((r >> ft->Rloss) << ft->Rshift) | \
|
||||
((g >> ft->Gloss) << ft->Gshift) | \
|
||||
((b >> ft->Bloss) << ft->Bshift) | \
|
||||
((a >> ft->Aloss) << ft->Ashift); \
|
||||
break; \
|
||||
case 4: \
|
||||
*((Uint32 *)(buf)) = ((r >> ft->Rloss) << ft->Rshift) | \
|
||||
((g >> ft->Gloss) << ft->Gshift) | \
|
||||
((b >> ft->Bloss) << ft->Bshift) | \
|
||||
((a >> ft->Aloss) << ft->Ashift); \
|
||||
break; \
|
||||
}
|
||||
|
||||
/* Pretty good idea from Tom Duff :-). */
|
||||
#define LOOP_UNROLLED4(code, n, width) \
|
||||
n = (width + 3) / 4; \
|
||||
switch (width & 3) { \
|
||||
case 0: \
|
||||
do { \
|
||||
code; \
|
||||
case 3: \
|
||||
code; \
|
||||
case 2: \
|
||||
code; \
|
||||
case 1: \
|
||||
code; \
|
||||
} while (--n > 0); \
|
||||
}
|
||||
|
||||
/* Used in the srcbpp == dstbpp == 1 blend functions */
|
||||
#define REPEAT_3(code) \
|
||||
code; \
|
||||
code; \
|
||||
code;
|
||||
|
||||
#define REPEAT_4(code) \
|
||||
code; \
|
||||
code; \
|
||||
code; \
|
||||
code;
|
||||
|
||||
#define BLEND_ADD(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
tmp = dR + sR; \
|
||||
dR = (tmp <= 255 ? tmp : 255); \
|
||||
tmp = dG + sG; \
|
||||
dG = (tmp <= 255 ? tmp : 255); \
|
||||
tmp = dB + sB; \
|
||||
dB = (tmp <= 255 ? tmp : 255);
|
||||
|
||||
#define BLEND_SUB(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
tmp = dR - sR; \
|
||||
dR = (tmp >= 0 ? tmp : 0); \
|
||||
tmp = dG - sG; \
|
||||
dG = (tmp >= 0 ? tmp : 0); \
|
||||
tmp = dB - sB; \
|
||||
dB = (tmp >= 0 ? tmp : 0);
|
||||
|
||||
#define BLEND_MULT(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
dR = (dR && sR) ? (dR * sR) >> 8 : 0; \
|
||||
dG = (dG && sG) ? (dG * sG) >> 8 : 0; \
|
||||
dB = (dB && sB) ? (dB * sB) >> 8 : 0;
|
||||
|
||||
#define BLEND_MIN(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
if (sR < dR) { \
|
||||
dR = sR; \
|
||||
} \
|
||||
if (sG < dG) { \
|
||||
dG = sG; \
|
||||
} \
|
||||
if (sB < dB) { \
|
||||
dB = sB; \
|
||||
}
|
||||
|
||||
#define BLEND_MAX(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
if (sR > dR) { \
|
||||
dR = sR; \
|
||||
} \
|
||||
if (sG > dG) { \
|
||||
dG = sG; \
|
||||
} \
|
||||
if (sB > dB) { \
|
||||
dB = sB; \
|
||||
}
|
||||
|
||||
#define BLEND_RGBA_ADD(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
tmp = dR + sR; \
|
||||
dR = (tmp <= 255 ? tmp : 255); \
|
||||
tmp = dG + sG; \
|
||||
dG = (tmp <= 255 ? tmp : 255); \
|
||||
tmp = dB + sB; \
|
||||
dB = (tmp <= 255 ? tmp : 255); \
|
||||
tmp = dA + sA; \
|
||||
dA = (tmp <= 255 ? tmp : 255);
|
||||
|
||||
#define BLEND_RGBA_SUB(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
tmp = dR - sR; \
|
||||
dR = (tmp >= 0 ? tmp : 0); \
|
||||
tmp = dG - sG; \
|
||||
dG = (tmp >= 0 ? tmp : 0); \
|
||||
tmp = dB - sB; \
|
||||
dB = (tmp >= 0 ? tmp : 0); \
|
||||
tmp = dA - sA; \
|
||||
dA = (tmp >= 0 ? tmp : 0);
|
||||
|
||||
#define BLEND_RGBA_MULT(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
dR = (dR && sR) ? (dR * sR) >> 8 : 0; \
|
||||
dG = (dG && sG) ? (dG * sG) >> 8 : 0; \
|
||||
dB = (dB && sB) ? (dB * sB) >> 8 : 0; \
|
||||
dA = (dA && sA) ? (dA * sA) >> 8 : 0;
|
||||
|
||||
#define BLEND_RGBA_MIN(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
if (sR < dR) { \
|
||||
dR = sR; \
|
||||
} \
|
||||
if (sG < dG) { \
|
||||
dG = sG; \
|
||||
} \
|
||||
if (sB < dB) { \
|
||||
dB = sB; \
|
||||
} \
|
||||
if (sA < dA) { \
|
||||
dA = sA; \
|
||||
}
|
||||
|
||||
#define BLEND_RGBA_MAX(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
if (sR > dR) { \
|
||||
dR = sR; \
|
||||
} \
|
||||
if (sG > dG) { \
|
||||
dG = sG; \
|
||||
} \
|
||||
if (sB > dB) { \
|
||||
dB = sB; \
|
||||
} \
|
||||
if (sA > dA) { \
|
||||
dA = sA; \
|
||||
}
|
||||
|
||||
#if 1
|
||||
/* Choose an alpha blend equation. If the sign is preserved on a right shift
|
||||
* then use a specialized, faster, equation. Otherwise a more general form,
|
||||
* where all additions are done before the shift, is needed.
|
||||
*/
|
||||
#if (-1 >> 1) < 0
|
||||
#define ALPHA_BLEND_COMP(sC, dC, sA) ((((sC - dC) * sA + sC) >> 8) + dC)
|
||||
#else
|
||||
#define ALPHA_BLEND_COMP(sC, dC, sA) (((dC << 8) + (sC - dC) * sA + sC) >> 8)
|
||||
#endif
|
||||
|
||||
#define ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
do { \
|
||||
if (dA) { \
|
||||
dR = ALPHA_BLEND_COMP(sR, dR, sA); \
|
||||
dG = ALPHA_BLEND_COMP(sG, dG, sA); \
|
||||
dB = ALPHA_BLEND_COMP(sB, dB, sA); \
|
||||
dA = sA + dA - ((sA * dA) / 255); \
|
||||
} \
|
||||
else { \
|
||||
dR = sR; \
|
||||
dG = sG; \
|
||||
dB = sB; \
|
||||
dA = sA; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define ALPHA_BLEND_PREMULTIPLIED_COMP(sC, dC, sA) \
|
||||
(sC + dC - ((dC + 1) * sA >> 8))
|
||||
|
||||
#define ALPHA_BLEND_PREMULTIPLIED(tmp, sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
do { \
|
||||
dR = ALPHA_BLEND_PREMULTIPLIED_COMP(sR, dR, sA); \
|
||||
dG = ALPHA_BLEND_PREMULTIPLIED_COMP(sG, dG, sA); \
|
||||
dB = ALPHA_BLEND_PREMULTIPLIED_COMP(sB, dB, sA); \
|
||||
dA = ALPHA_BLEND_PREMULTIPLIED_COMP(sA, dA, sA); \
|
||||
} while (0)
|
||||
#elif 0
|
||||
|
||||
#define ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB, dA) \
|
||||
do { \
|
||||
if (sA) { \
|
||||
if (dA && sA < 255) { \
|
||||
int dContrib = dA * (255 - sA) / 255; \
|
||||
dA = sA + dA - ((sA * dA) / 255); \
|
||||
dR = (dR * dContrib + sR * sA) / dA; \
|
||||
dG = (dG * dContrib + sG * sA) / dA; \
|
||||
dB = (dB * dContrib + sB * sA) / dA; \
|
||||
} \
|
||||
else { \
|
||||
dR = sR; \
|
||||
dG = sG; \
|
||||
dB = sB; \
|
||||
dA = sA; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
int
|
||||
surface_fill_blend(SDL_Surface *surface, SDL_Rect *rect, Uint32 color,
|
||||
int blendargs);
|
||||
|
||||
void
|
||||
surface_respect_clip_rect(SDL_Surface *surface, SDL_Rect *rect);
|
||||
|
||||
int
|
||||
pygame_AlphaBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
|
||||
SDL_Rect *dstrect, int the_args);
|
||||
|
||||
int
|
||||
pygame_Blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
|
||||
SDL_Rect *dstrect, int the_args);
|
||||
|
||||
#endif /* SURFACE_H */
|
||||
Binary file not shown.
|
|
@ -1,155 +0,0 @@
|
|||
"""
|
||||
IPython: tools for interactive and parallel computing in Python.
|
||||
|
||||
https://ipython.org
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2008-2011, IPython Development Team.
|
||||
# Copyright (c) 2001-2007, Fernando Perez <fernando.perez@colorado.edu>
|
||||
# Copyright (c) 2001, Janko Hauser <jhauser@zscout.de>
|
||||
# Copyright (c) 2001, Nathaniel Gray <n8gray@caltech.edu>
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Setup everything
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# Don't forget to also update setup.py when this changes!
|
||||
if sys.version_info < (3, 8):
|
||||
raise ImportError(
|
||||
"""
|
||||
IPython 8+ supports Python 3.8 and above, following NEP 29.
|
||||
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
|
||||
Python 3.3 and 3.4 were supported up to IPython 6.x.
|
||||
Python 3.5 was supported with IPython 7.0 to 7.9.
|
||||
Python 3.6 was supported with IPython up to 7.16.
|
||||
Python 3.7 was still supported with the 7.x branch.
|
||||
|
||||
See IPython `README.rst` file for more information:
|
||||
|
||||
https://github.com/ipython/ipython/blob/master/README.rst
|
||||
|
||||
""")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Setup the top level names
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
from .core.getipython import get_ipython
|
||||
from .core import release
|
||||
from .core.application import Application
|
||||
from .terminal.embed import embed
|
||||
|
||||
from .core.interactiveshell import InteractiveShell
|
||||
from .utils.sysinfo import sys_info
|
||||
from .utils.frame import extract_module_locals
|
||||
|
||||
# Release data
|
||||
__author__ = '%s <%s>' % (release.author, release.author_email)
|
||||
__license__ = release.license
|
||||
__version__ = release.version
|
||||
version_info = release.version_info
|
||||
# list of CVEs that should have been patched in this release.
|
||||
# this is informational and should not be relied upon.
|
||||
__patched_cves__ = {"CVE-2022-21699"}
|
||||
|
||||
|
||||
def embed_kernel(module=None, local_ns=None, **kwargs):
|
||||
"""Embed and start an IPython kernel in a given scope.
|
||||
|
||||
If you don't want the kernel to initialize the namespace
|
||||
from the scope of the surrounding function,
|
||||
and/or you want to load full IPython configuration,
|
||||
you probably want `IPython.start_kernel()` instead.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
module : types.ModuleType, optional
|
||||
The module to load into IPython globals (default: caller)
|
||||
local_ns : dict, optional
|
||||
The namespace to load into IPython user namespace (default: caller)
|
||||
**kwargs : various, optional
|
||||
Further keyword args are relayed to the IPKernelApp constructor,
|
||||
allowing configuration of the Kernel. Will only have an effect
|
||||
on the first embed_kernel call for a given process.
|
||||
"""
|
||||
|
||||
(caller_module, caller_locals) = extract_module_locals(1)
|
||||
if module is None:
|
||||
module = caller_module
|
||||
if local_ns is None:
|
||||
local_ns = caller_locals
|
||||
|
||||
# Only import .zmq when we really need it
|
||||
from ipykernel.embed import embed_kernel as real_embed_kernel
|
||||
real_embed_kernel(module=module, local_ns=local_ns, **kwargs)
|
||||
|
||||
def start_ipython(argv=None, **kwargs):
|
||||
"""Launch a normal IPython instance (as opposed to embedded)
|
||||
|
||||
`IPython.embed()` puts a shell in a particular calling scope,
|
||||
such as a function or method for debugging purposes,
|
||||
which is often not desirable.
|
||||
|
||||
`start_ipython()` does full, regular IPython initialization,
|
||||
including loading startup files, configuration, etc.
|
||||
much of which is skipped by `embed()`.
|
||||
|
||||
This is a public API method, and will survive implementation changes.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
argv : list or None, optional
|
||||
If unspecified or None, IPython will parse command-line options from sys.argv.
|
||||
To prevent any command-line parsing, pass an empty list: `argv=[]`.
|
||||
user_ns : dict, optional
|
||||
specify this dictionary to initialize the IPython user namespace with particular values.
|
||||
**kwargs : various, optional
|
||||
Any other kwargs will be passed to the Application constructor,
|
||||
such as `config`.
|
||||
"""
|
||||
from IPython.terminal.ipapp import launch_new_instance
|
||||
return launch_new_instance(argv=argv, **kwargs)
|
||||
|
||||
def start_kernel(argv=None, **kwargs):
|
||||
"""Launch a normal IPython kernel instance (as opposed to embedded)
|
||||
|
||||
`IPython.embed_kernel()` puts a shell in a particular calling scope,
|
||||
such as a function or method for debugging purposes,
|
||||
which is often not desirable.
|
||||
|
||||
`start_kernel()` does full, regular IPython initialization,
|
||||
including loading startup files, configuration, etc.
|
||||
much of which is skipped by `embed()`.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
argv : list or None, optional
|
||||
If unspecified or None, IPython will parse command-line options from sys.argv.
|
||||
To prevent any command-line parsing, pass an empty list: `argv=[]`.
|
||||
user_ns : dict, optional
|
||||
specify this dictionary to initialize the IPython user namespace with particular values.
|
||||
**kwargs : various, optional
|
||||
Any other kwargs will be passed to the Application constructor,
|
||||
such as `config`.
|
||||
"""
|
||||
import warnings
|
||||
|
||||
warnings.warn(
|
||||
"start_kernel is deprecated since IPython 8.0, use from `ipykernel.kernelapp.launch_new_instance`",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
from ipykernel.kernelapp import launch_new_instance
|
||||
return launch_new_instance(argv=argv, **kwargs)
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
# encoding: utf-8
|
||||
"""Terminal-based IPython entry point.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2012, IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
from IPython import start_ipython
|
||||
|
||||
start_ipython()
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,87 +0,0 @@
|
|||
import builtins
|
||||
import inspect
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import sys
|
||||
import types
|
||||
|
||||
import pytest
|
||||
|
||||
# Must register before it gets imported
|
||||
pytest.register_assert_rewrite("IPython.testing.tools")
|
||||
|
||||
from .testing import tools
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(items):
|
||||
"""This function is automatically run by pytest passing all collected test
|
||||
functions.
|
||||
|
||||
We use it to add asyncio marker to all async tests and assert we don't use
|
||||
test functions that are async generators which wouldn't make sense.
|
||||
"""
|
||||
for item in items:
|
||||
if inspect.iscoroutinefunction(item.obj):
|
||||
item.add_marker("asyncio")
|
||||
assert not inspect.isasyncgenfunction(item.obj)
|
||||
|
||||
|
||||
def get_ipython():
|
||||
from .terminal.interactiveshell import TerminalInteractiveShell
|
||||
if TerminalInteractiveShell._instance:
|
||||
return TerminalInteractiveShell.instance()
|
||||
|
||||
config = tools.default_config()
|
||||
config.TerminalInteractiveShell.simple_prompt = True
|
||||
|
||||
# Create and initialize our test-friendly IPython instance.
|
||||
shell = TerminalInteractiveShell.instance(config=config)
|
||||
return shell
|
||||
|
||||
|
||||
@pytest.fixture(scope='session', autouse=True)
|
||||
def work_path():
|
||||
path = pathlib.Path("./tmp-ipython-pytest-profiledir")
|
||||
os.environ["IPYTHONDIR"] = str(path.absolute())
|
||||
if path.exists():
|
||||
raise ValueError('IPython dir temporary path already exists ! Did previous test run exit successfully ?')
|
||||
path.mkdir()
|
||||
yield
|
||||
shutil.rmtree(str(path.resolve()))
|
||||
|
||||
|
||||
def nopage(strng, start=0, screen_lines=0, pager_cmd=None):
|
||||
if isinstance(strng, dict):
|
||||
strng = strng.get("text/plain", "")
|
||||
print(strng)
|
||||
|
||||
|
||||
def xsys(self, cmd):
|
||||
"""Replace the default system call with a capturing one for doctest.
|
||||
"""
|
||||
# We use getoutput, but we need to strip it because pexpect captures
|
||||
# the trailing newline differently from commands.getoutput
|
||||
print(self.getoutput(cmd, split=False, depth=1).rstrip(), end="", file=sys.stdout)
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
# for things to work correctly we would need this as a session fixture;
|
||||
# unfortunately this will fail on some test that get executed as _collection_
|
||||
# time (before the fixture run), in particular parametrized test that contain
|
||||
# yields. so for now execute at import time.
|
||||
#@pytest.fixture(autouse=True, scope='session')
|
||||
def inject():
|
||||
|
||||
builtins.get_ipython = get_ipython
|
||||
builtins._ip = get_ipython()
|
||||
builtins.ip = get_ipython()
|
||||
builtins.ip.system = types.MethodType(xsys, ip)
|
||||
builtins.ip.builtin_trap.activate()
|
||||
from .core import page
|
||||
|
||||
page.pager_page = nopage
|
||||
# yield
|
||||
|
||||
|
||||
inject()
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
"""
|
||||
Shim to maintain backwards compatibility with old IPython.consoleapp imports.
|
||||
"""
|
||||
# Copyright (c) IPython Development Team.
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
from warnings import warn
|
||||
|
||||
warn("The `IPython.consoleapp` package has been deprecated since IPython 4.0."
|
||||
"You should import from jupyter_client.consoleapp instead.", stacklevel=2)
|
||||
|
||||
from jupyter_client.consoleapp import *
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue