Skip to content

Instantly share code, notes, and snippets.

@evansd
Created June 18, 2014 10:45
Show Gist options
  • Select an option

  • Save evansd/5e20e3c4aed9933eafe8 to your computer and use it in GitHub Desktop.

Select an option

Save evansd/5e20e3c4aed9933eafe8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import fileinput, re
for line in fileinput.input(inplace=True):
if fileinput.isfirstline():
future_load = '{% load url from future %}'
if '{% extends' in line:
print line,
print future_load
else:
print future_load
print line,
else:
print re.sub(r'{% *url +([a-zA-Z0-9_.:-]+)', r"{% url '\1'", line),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment