Commit 745dc150 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

Initial revision

parents
# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
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.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# pyenv
.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
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# End of https://www.gitignore.io/api/python
from lib2to3.main import main
import sys
sys.exit(main('my2to3.fixers'))
# https://lab.nexedi.com/nexedi/erp5/snippets/475
import lib2to3.fixer_base
import lib2to3.fixer_util
import lib2to3.pgen2
import sys
class FixRewriteDiv(lib2to3.fixer_base.BaseFix):
"""Rewrites a/b into division_traced(a, b)
division_traced can be a function that looks up the stack and record the operand types, for example:
def division_traced(dividend, divisor):
import inspect
previous_frame = inspect.currentframe().f_back
print ("{}:{} {} / {}".format(
previous_frame.f_code.co_filename,
previous_frame.f_lineno,
type(dividend),
type(divisor)
))
return dividend / divisor
import __builtin__
__builtin__.division_traced = division_traced
"""
def match(self, node):
return (
len(node.children) == 3 and
node.children[1].type == lib2to3.pgen2.token.SLASH)
def transform(self, node, results):
node.replace(
lib2to3.fixer_util.Call(
lib2to3.fixer_util.Name("division_traced"),
args=(
node.children[0].clone(),
lib2to3.fixer_util.Comma(),
node.children[2].clone(),
),
prefix=node.prefix))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment