-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Hager
committed
Dec 23, 2011
1 parent
6975ca6
commit 7fae3cb
Showing
2 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,16 +1,22 @@ | |||
#Boilerplate Collection | # Boilerplate Collection | ||
|
|
||
Boilerplates are basic setups with best practices. Just take the parts you like. | Boilerplates are basic setups with best practices. Just take the parts you like. | ||
|
|
||
###Python | ### Python | ||
|
|
||
* [Python Script](https://github.com/metachris/boilerplates/tree/master/python) | * [Python Script](https://github.com/metachris/boilerplates/tree/master/python) | ||
* [Tornado Website](https://github.com/metachris/tornado-boilerplate) | * [Tornado Website](https://github.com/metachris/tornado-boilerplate) | ||
* [App Engine Website](https://github.com/metachris/appengine-boilerplate) | * [App Engine Website](https://github.com/metachris/appengine-boilerplate) | ||
|
|
||
|
|
||
###Dotfiles | ### PEP8 Pre Commit Hook for Git | ||
|
|||
This [git pre-commit hook](https://github.com/metachris/boilerplates/tree/master/python/pep8-git-pre-commit-hook) checks for pep8 compatibility on committing, and aborts the commit if errors are found. Can be skipped by applying the `--no-verify` flag to `git commit`. This requires the tool `pep8` which can be installed via package managers and homebrew. | |||
|
|||
To use the commit hook in all projects on this system, copy it into the global git hook-templates directory (eg. `/usr/share/git-core/templates/hooks/`) as a file called `pre-commit` and set the permissions to executable. Afterwards you can enable this hook in existing repositories by calling `git init`. New repositories will use it by default. | |||
|
|
||
[Boilerplate dotfiles](https://github.com/metachris/boilerplates/tree/master/dotfiles) is a collection of command line goodness for OSX and Linux. Includes `.bash_profile`, `.aliases`, `.exports`, and others. | |||
|
|
||
### Dotfiles | |||
|
|||
[Boilerplate dotfiles](https://github.com/metachris/boilerplates/tree/master/dotfiles) is a collection of command line goodness for OSX and Linux. Includes `.bash_profile`, `.aliases`, `.exports`, and others. | |||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,36 @@ | |||
#!/usr/bin/env python | |||
from __future__ import with_statement | |||
import os | |||
import shutil | |||
import subprocess | |||
import sys | |||
import tempfile | |||
|
|||
|
|||
def system(*args, **kwargs): | |||
kwargs.setdefault('stdout', subprocess.PIPE) | |||
proc = subprocess.Popen(args, **kwargs) | |||
out, err = proc.communicate() | |||
return out | |||
|
|||
|
|||
def main(): | |||
files = (file for file in system('git', 'diff', '--name-only', '--staged', '--diff-filter=AM').splitlines() if file.endswith('.py')) | |||
|
|||
tempdir = tempfile.mkdtemp() | |||
for name in files: | |||
filename = os.path.join(tempdir, name) | |||
filepath = os.path.dirname(filename) | |||
if not os.path.exists(filepath): | |||
os.makedirs(filepath) | |||
with file(filename, 'w') as f: | |||
system('git', 'show', ':' + name, stdout=f) | |||
output = system('pep8', '.', cwd=tempdir) | |||
shutil.rmtree(tempdir) | |||
if output: | |||
print output, | |||
sys.exit(1) | |||
|
|||
|
|||
if __name__ == '__main__': | |||
main() |