Skip to content

Instantly share code, notes, and snippets.

View jrief's full-sized avatar

Jacob Rief jrief

View GitHub Profile
jrief / gist:0e6b97be132452a511eae81d54ca01ae
Last active February 2, 2021 14:27
Checklist for dropping Python-2 support
* 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)`.
from 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>
jrief /
Created November 28, 2015 22:19
Replacement for django.contrib.staticfiles.finders.FileSystemFinder
# -*- 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