Skip to content

Instantly share code, notes, and snippets.

View agmond's full-sized avatar

Dotan Agmon agmond

View GitHub Profile
@agmond
agmond / django_dry_run.py
Created January 2, 2018 16:19
Interactively dry-run Django code that changes data in the DB, with ability to commit at the end
from django.db import transaction
t = transaction.atomic()
t.__enter__()
# Do your stuff here...
pass
# If you want to *rollback* you changes:
t.__exit__('temp', 'temp', 'temp')
@agmond
agmond / py3_fix_super_calls.py
Last active January 25, 2021 18:48
Fix `super()` calls after migration to Python3
"""
The following script fixes `super()` calls after migration from Python 2 to Python 3.
The script edits the code automatically. Upon completion, the following steps are recommended:
- Search for the regex `super\([^\)]` and fix manually those places (if needed)
- Search for the regex `super\(\s[^\)]` and fix manually those places (if needed)
- Run Flake8 and manually fix styling problems
"""
import ast