Skip to content

Instantly share code, notes, and snippets.

@oleiade
Created February 23, 2012 17:47
Show Gist options
  • Save oleiade/1893994 to your computer and use it in GitHub Desktop.
Save oleiade/1893994 to your computer and use it in GitHub Desktop.
requirements.txt package blacklisting git pre-commit hook
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
MANUAL_PACKAGES = dict.fromkeys([
'leveldb',
])
# Compile blacklisted packages regexp
for name in MANUAL_PACKAGES.keys():
MANUAL_PACKAGES[name] = re.compile(r'^%s*' % name)
for line in open('requirements.txt', 'r'):
for r in MANUAL_PACKAGES.values():
if r.match(line):
print "Error : Requirements.txt contains prohibited packages references"
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment