Skip to content

Instantly share code, notes, and snippets.

Avatar

Jacob Rief jrief

  • https://www.awesto.com/
  • Innsbruck, Tirol, Austria
View GitHub Profile
@jrief
jrief / gist:0e6b97be132452a511eae81d54ca01ae
Last active Feb 2, 2021
Checklist for dropping Python-2 support
View gist:0e6b97be132452a511eae81d54ca01ae
* Remove all occurences of `# -*- coding: utf-8 -*-`.
* Remove all imports `unicode_literals`.
* Search for all occurences of `super(MyClass, self).` and replace by `super()`. **Check for grandparent super()!**.
* Search for all occurences of `six` and remove compatibility checks.
* Replace `ugettext` by `gettext`.
* Search for all occurences of `@python_2_unicode_compatible` and remove it.
* Search for all occurences of `__unicode__` and replace by `__str__`.
* Search for all occurences of `__nonzero__` and replace by `__bool__`
* Replace `from django.conf.urls import url` by `from django.urls import re_path`.
* Remove inheritance from `...(object)`.
View gist:25962a9194ec1c6c3c590bf8977fd0ff
from reportlab.graphics import renderSVG
from svglib.svglib import svg2rlg
"""
The input file circle.svg contains this content:
<svg viewBox="0 0 300 300">
<circle r="100" fill="red" transform="translate(150,150)"></circle>
<rect x="-25" y="-25" width="50" height="50" fill="green" transform="translate(150,150)"></rect>
</svg>
"""
@jrief
jrief / finders.py
Created Nov 28, 2015
Replacement for django.contrib.staticfiles.finders.FileSystemFinder
View finders.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
from django.conf import settings
from django.contrib.staticfiles.finders import FileSystemFinder
class ServeUnminimizedFinder(FileSystemFinder):
"""
In debug mode, serve /static/any/asset.min.ext as /static/any/asset.ext