Commit 48f682f3 authored by SVN-Git Migration's avatar SVN-Git Migration

Imported Upstream version 2.1.0

parent 3fef12d2
CHANGES CHANGES
======= =======
2.0.0 - 2013-02-xx 2.1.0 - 2013-10-26
------------------
- Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and
mercurial hooks
- Force git and mercurial hooks to repsect configuration in setup.cfg
- Only check staged files if that is specified
- Fix hook file permissions
- Fix the git hook on python 3
- Ignore non-python files when running the git hook
- Ignore .tox directories by default
- Flake8 now reports the column number for PyFlakes messages
2.0.0 - 2013-02-23
------------------ ------------------
- Pyflakes errors are prefixed by an ``F`` instead of an ``E`` - Pyflakes errors are prefixed by an ``F`` instead of an ``E``
......
...@@ -19,3 +19,4 @@ Contributors (by order of appearance) : ...@@ -19,3 +19,4 @@ Contributors (by order of appearance) :
- Marc Labbé - Marc Labbé
- Bruno Miguel Custódio - Bruno Miguel Custódio
- Florent Xicluna - Florent Xicluna
- Austin Morton
\ No newline at end of file
== Flake8 License (MIT) == == Flake8 License (MIT) ==
Copyright (C) 2011 Tarek Ziade <tarek@ziade.org> Copyright (C) 2011-2013 Tarek Ziade <tarek@ziade.org>
Copyright (C) 2012-2013 Ian Cordasco <graffatcolmingov@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in
......
include *.rst include *.rst
include CONTRIBUTORS.txt include CONTRIBUTORS.txt
include LICENSE include LICENSE
recursive-include scripts flake8.* recursive-include flake8 *
Metadata-Version: 1.0 Metadata-Version: 1.1
Name: flake8 Name: flake8
Version: 2.0 Version: 2.1.0
Summary: the modular source code checker: pep8, pyflakes and co Summary: the modular source code checker: pep8, pyflakes and co
Home-page: http://bitbucket.org/tarek/flake8 Home-page: http://bitbucket.org/tarek/flake8
Author: Ian Cordasco Author: Ian Cordasco
...@@ -65,6 +65,13 @@ Description: ====== ...@@ -65,6 +65,13 @@ Description: ======
anything that goes beyond 10 is too complex. anything that goes beyond 10 is too complex.
See https://en.wikipedia.org/wiki/Cyclomatic_complexity. See https://en.wikipedia.org/wiki/Cyclomatic_complexity.
Questions or Feedback
=====================
If you have questions you'd like to ask the developers, or feedback you'd like
to provide, feel free to use the mailing list: code-quality@python.org We
would love to hear from you. Additionally, if you have a feature you'd like to
suggest, the mailing list would be the best place for it.
.. _links: .. _links:
...@@ -79,7 +86,20 @@ Description: ====== ...@@ -79,7 +86,20 @@ Description: ======
CHANGES CHANGES
======= =======
2.0.0 - 2013-02-xx 2.1.0 - 2013-10-26
------------------
- Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and
mercurial hooks
- Force git and mercurial hooks to repsect configuration in setup.cfg
- Only check staged files if that is specified
- Fix hook file permissions
- Fix the git hook on python 3
- Ignore non-python files when running the git hook
- Ignore .tox directories by default
- Flake8 now reports the column number for PyFlakes messages
2.0.0 - 2013-02-23
------------------ ------------------
- Pyflakes errors are prefixed by an ``F`` instead of an ``E`` - Pyflakes errors are prefixed by an ``F`` instead of an ``E``
......
...@@ -57,6 +57,13 @@ This feature is quite useful to detect over-complex code. According to McCabe, ...@@ -57,6 +57,13 @@ This feature is quite useful to detect over-complex code. According to McCabe,
anything that goes beyond 10 is too complex. anything that goes beyond 10 is too complex.
See https://en.wikipedia.org/wiki/Cyclomatic_complexity. See https://en.wikipedia.org/wiki/Cyclomatic_complexity.
Questions or Feedback
=====================
If you have questions you'd like to ask the developers, or feedback you'd like
to provide, feel free to use the mailing list: code-quality@python.org We
would love to hear from you. Additionally, if you have a feature you'd like to
suggest, the mailing list would be the best place for it.
.. _links: .. _links:
......
Metadata-Version: 1.0 Metadata-Version: 1.1
Name: flake8 Name: flake8
Version: 2.0 Version: 2.1.0
Summary: the modular source code checker: pep8, pyflakes and co Summary: the modular source code checker: pep8, pyflakes and co
Home-page: http://bitbucket.org/tarek/flake8 Home-page: http://bitbucket.org/tarek/flake8
Author: Ian Cordasco Author: Ian Cordasco
...@@ -65,6 +65,13 @@ Description: ====== ...@@ -65,6 +65,13 @@ Description: ======
anything that goes beyond 10 is too complex. anything that goes beyond 10 is too complex.
See https://en.wikipedia.org/wiki/Cyclomatic_complexity. See https://en.wikipedia.org/wiki/Cyclomatic_complexity.
Questions or Feedback
=====================
If you have questions you'd like to ask the developers, or feedback you'd like
to provide, feel free to use the mailing list: code-quality@python.org We
would love to hear from you. Additionally, if you have a feature you'd like to
suggest, the mailing list would be the best place for it.
.. _links: .. _links:
...@@ -79,7 +86,20 @@ Description: ====== ...@@ -79,7 +86,20 @@ Description: ======
CHANGES CHANGES
======= =======
2.0.0 - 2013-02-xx 2.1.0 - 2013-10-26
------------------
- Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and
mercurial hooks
- Force git and mercurial hooks to repsect configuration in setup.cfg
- Only check staged files if that is specified
- Fix hook file permissions
- Fix the git hook on python 3
- Ignore non-python files when running the git hook
- Ignore .tox directories by default
- Flake8 now reports the column number for PyFlakes messages
2.0.0 - 2013-02-23
------------------ ------------------
- Pyflakes errors are prefixed by an ``F`` instead of an ``E`` - Pyflakes errors are prefixed by an ``F`` instead of an ``E``
......
...@@ -5,18 +5,31 @@ MANIFEST.in ...@@ -5,18 +5,31 @@ MANIFEST.in
README.rst README.rst
setup.py setup.py
flake8/__init__.py flake8/__init__.py
flake8/__init__.pyc
flake8/_pyflakes.py flake8/_pyflakes.py
flake8/_pyflakes.pyc
flake8/engine.py flake8/engine.py
flake8/engine.pyc
flake8/hooks.py flake8/hooks.py
flake8/hooks.py.orig
flake8/hooks.pyc
flake8/main.py flake8/main.py
flake8/main.pyc
flake8/run.py flake8/run.py
flake8/util.py flake8/util.py
flake8/util.pyc
flake8.egg-info/PKG-INFO flake8.egg-info/PKG-INFO
flake8.egg-info/SOURCES.txt flake8.egg-info/SOURCES.txt
flake8.egg-info/dependency_links.txt flake8.egg-info/dependency_links.txt
flake8.egg-info/entry_points.txt flake8.egg-info/entry_points.txt
flake8.egg-info/requires.txt flake8.egg-info/requires.txt
flake8.egg-info/top_level.txt flake8.egg-info/top_level.txt
flake8/__pycache__/__init__.cpython-32.pyc
flake8/__pycache__/_pyflakes.cpython-32.pyc
flake8/__pycache__/engine.cpython-32.pyc
flake8/__pycache__/main.cpython-32.pyc
flake8/__pycache__/util.cpython-32.pyc
flake8/tests/__init__.py flake8/tests/__init__.py
flake8/tests/test_flakes.py flake8/tests/__init__.pyc
scripts/flake8.cmd flake8/tests/test_engine.py
\ No newline at end of file flake8/tests/test_engine.pyc
\ No newline at end of file
setuptools pyflakes >= 0.7.3
pyflakes >= 0.6.1 pep8 >= 1.4.6
pep8 >= 1.4.3 mccabe >= 0.2.1
mccabe >= 0.2 \ No newline at end of file
\ No newline at end of file
__version__ = '2.1.0'
__version__ = '2.0'
...@@ -44,4 +44,5 @@ class FlakesChecker(pyflakes.checker.Checker): ...@@ -44,4 +44,5 @@ class FlakesChecker(pyflakes.checker.Checker):
def run(self): def run(self):
for m in self.messages: for m in self.messages:
yield m.lineno, 0, (m.flake8_msg % m.message_args), m.__class__ col = getattr(m, 'col', 0)
yield m.lineno, col, (m.flake8_msg % m.message_args), m.__class__
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re import re
import platform
import pep8 import pep8
...@@ -37,7 +38,10 @@ def get_parser(): ...@@ -37,7 +38,10 @@ def get_parser():
""" """
(extensions, parser_hooks, options_hooks) = _register_extensions() (extensions, parser_hooks, options_hooks) = _register_extensions()
details = ', '.join(['%s: %s' % ext for ext in extensions]) details = ', '.join(['%s: %s' % ext for ext in extensions])
parser = pep8.get_parser('flake8', '%s (%s)' % (__version__, details)) python_version = get_python_version()
parser = pep8.get_parser('flake8', '%s (%s) %s' % (
__version__, details, python_version
))
for opt in ('--repeat', '--testsuite', '--doctest'): for opt in ('--repeat', '--testsuite', '--doctest'):
try: try:
parser.remove_option(opt) parser.remove_option(opt)
...@@ -78,3 +82,12 @@ def get_style_guide(**kwargs): ...@@ -78,3 +82,12 @@ def get_style_guide(**kwargs):
for options_hook in options_hooks: for options_hook in options_hooks:
options_hook(options) options_hook(options)
return styleguide return styleguide
def get_python_version():
# The implementation isn't all that important.
try:
impl = platform.python_implementation() + " "
except AttributeError: # Python 2.5
impl = ''
return '%s%s on %s' % (impl, platform.python_version(), platform.system())
...@@ -2,7 +2,16 @@ ...@@ -2,7 +2,16 @@
from __future__ import with_statement from __future__ import with_statement
import os import os
import sys import sys
import stat
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import shutil
from tempfile import mkdtemp
try:
# The 'demandimport' breaks pyflakes and flake8._pyflakes
from mercurial import demandimport
demandimport.disable()
except ImportError:
pass
try: try:
from configparser import ConfigParser from configparser import ConfigParser
except ImportError: # Python 2 except ImportError: # Python 2
...@@ -14,7 +23,7 @@ from flake8.main import DEFAULT_CONFIG ...@@ -14,7 +23,7 @@ from flake8.main import DEFAULT_CONFIG
def git_hook(complexity=-1, strict=False, ignore=None, lazy=False): def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
"""This is the function used by the git hook. """This is the function used by the git hook.
:param int complexity: (optional), any value > 0 enables complexity :param int complexity: (optional), any value > 0 enables complexity
checking with mccabe checking with mccabe
:param bool strict: (optional), if True, this returns the total number of :param bool strict: (optional), if True, this returns the total number of
...@@ -25,15 +34,59 @@ def git_hook(complexity=-1, strict=False, ignore=None, lazy=False): ...@@ -25,15 +34,59 @@ def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
the files to the index before running a commit, e.g., git commit -a the files to the index before running a commit, e.g., git commit -a
:returns: total number of errors if strict is True, otherwise 0 :returns: total number of errors if strict is True, otherwise 0
""" """
gitcmd = "git diff-index --cached --name-only HEAD" gitcmd = "git diff-index --cached --name-only --diff-filter=ACMRTUXB HEAD"
if lazy: if lazy:
# Catch all files, including those not added to the index
gitcmd = gitcmd.replace('--cached ', '') gitcmd = gitcmd.replace('--cached ', '')
if hasattr(ignore, 'split'):
ignore = ignore.split(',')
# Returns the exit code, list of files modified, list of error messages
_, files_modified, _ = run(gitcmd) _, files_modified, _ = run(gitcmd)
# We only want to pass ignore and max_complexity if they differ from the
# defaults so that we don't override a local configuration file
options = {}
if ignore:
options['ignore'] = ignore
if complexity > -1:
options['max_complexity'] = complexity
files_modified = [f for f in files_modified if f.endswith('.py')]
flake8_style = get_style_guide( flake8_style = get_style_guide(
config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity) parse_argv=True,
report = flake8_style.check_files(files_modified) config_file=DEFAULT_CONFIG,
**options
)
# Copy staged versions to temporary directory
tmpdir = mkdtemp()
files_to_check = []
try:
for file_ in files_modified:
# get the staged version of the file
gitcmd_getstaged = "git show :%s" % file_
_, out, _ = run(gitcmd_getstaged, raw_output=True, decode=False)
# write the staged version to temp dir with its full path to
# avoid overwriting files with the same name
dirname, filename = os.path.split(os.path.abspath(file_))
prefix = os.path.commonprefix([dirname, tmpdir])
dirname = os.path.relpath(dirname, start=prefix)
dirname = os.path.join(tmpdir, dirname)
if not os.path.isdir(dirname):
os.makedirs(dirname)
filename = os.path.join(dirname, filename)
# write staged version of file to temporary directory
with open(filename, "wb") as fh:
fh.write(out)
files_to_check.append(filename)
# Run the checks
report = flake8_style.check_files(files_to_check)
# remove temporary directory
finally:
shutil.rmtree(tmpdir, ignore_errors=True)
if strict: if strict:
return report.total_errors return report.total_errors
...@@ -49,14 +102,23 @@ def hg_hook(ui, repo, **kwargs): ...@@ -49,14 +102,23 @@ def hg_hook(ui, repo, **kwargs):
""" """
complexity = ui.config('flake8', 'complexity', default=-1) complexity = ui.config('flake8', 'complexity', default=-1)
strict = ui.configbool('flake8', 'strict', default=True) strict = ui.configbool('flake8', 'strict', default=True)
ignore = ui.config('flake8', 'ignore', default=None)
config = ui.config('flake8', 'config', default=True) config = ui.config('flake8', 'config', default=True)
if config is True: if config is True:
config = DEFAULT_CONFIG config = DEFAULT_CONFIG
paths = _get_files(repo, **kwargs) paths = _get_files(repo, **kwargs)
flake8_style = get_style_guide( # We only want to pass ignore and max_complexity if they differ from the
config_file=config, max_complexity=complexity) # defaults so that we don't override a local configuration file
options = {}
if ignore:
options['ignore'] = ignore
if complexity > -1:
options['max_complexity'] = complexity
flake8_style = get_style_guide(parse_argv=True, config_file=config,
**options)
report = flake8_style.check_files(paths) report = flake8_style.check_files(paths)
if strict: if strict:
...@@ -65,11 +127,23 @@ def hg_hook(ui, repo, **kwargs): ...@@ -65,11 +127,23 @@ def hg_hook(ui, repo, **kwargs):
return 0 return 0
def run(command): def run(command, raw_output=False, decode=True):
p = Popen(command.split(), stdout=PIPE, stderr=PIPE) p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
(stdout, stderr) = p.communicate() (stdout, stderr) = p.communicate()
return (p.returncode, [line.strip() for line in stdout.splitlines()], # On python 3, subprocess.Popen returns bytes objects which expect
[line.strip() for line in stderr.splitlines()]) # endswith to be given a bytes object or a tuple of bytes but not native
# string objects. This is simply less mysterious than using b'.py' in the
# endswith method. That should work but might still fail horribly.
if hasattr(stdout, 'decode'):
if decode:
stdout = stdout.decode()
if hasattr(stderr, 'decode'):
if decode:
stderr = stderr.decode()
if not raw_output:
stdout = [line.strip() for line in stdout.splitlines()]
stderr = [line.strip() for line in stderr.splitlines()]
return (p.returncode, stdout, stderr)
def _get_files(repo, **kwargs): def _get_files(repo, **kwargs):
...@@ -85,12 +159,14 @@ def _get_files(repo, **kwargs): ...@@ -85,12 +159,14 @@ def _get_files(repo, **kwargs):
def find_vcs(): def find_vcs():
if os.path.isdir('.git'): _, git_dir, _ = run('git rev-parse --git-dir')
if not os.path.isdir('.git/hooks'): if git_dir and os.path.isdir(git_dir[0]):
os.mkdir('.git/hooks') if not os.path.isdir(os.path.join(git_dir[0], 'hooks')):
return '.git/hooks/pre-commit' os.mkdir(os.path.join(git_dir[0], 'hooks'))
elif os.path.isdir('.hg'): return os.path.join(git_dir[0], 'hooks', 'pre-commit')
return '.hg/hgrc' _, hg_dir, _ = run('hg root')
if hg_dir and os.path.isdir(hg_dir[0]):
return os.path.join(hg_dir[0], '.hg', 'hgrc')
return '' return ''
...@@ -101,14 +177,25 @@ from flake8.hooks import git_hook ...@@ -101,14 +177,25 @@ from flake8.hooks import git_hook
COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10) COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10)
STRICT = os.getenv('FLAKE8_STRICT', False) STRICT = os.getenv('FLAKE8_STRICT', False)
IGNORE = os.getenv('FLAKE8_IGNORE')
LAZY = os.getenv('FLAKE8_LAZY', False)
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT)) sys.exit(git_hook(
complexity=COMPLEXITY,
strict=STRICT,
ignore=IGNORE,
lazy=LAZY,
))
""" """
def _install_hg_hook(path): def _install_hg_hook(path):
if not os.path.isfile(path):
# Make the file so we can avoid IOError's
open(path, 'w+').close()
c = ConfigParser() c = ConfigParser()
c.readfp(open(path, 'r')) c.readfp(open(path, 'r'))
if not c.has_section('hooks'): if not c.has_section('hooks'):
...@@ -129,6 +216,12 @@ def _install_hg_hook(path): ...@@ -129,6 +216,12 @@ def _install_hg_hook(path):
if not c.has_option('flake8', 'strict'): if not c.has_option('flake8', 'strict'):
c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False)) c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False))
if not c.has_option('flake8', 'ignore'):
c.set('flake8', 'ignore', os.getenv('FLAKE8_IGNORE'))
if not c.has_option('flake8', 'lazy'):
c.set('flake8', 'lazy', os.getenv('FLAKE8_LAZY', False))
c.write(open(path, 'w+')) c.write(open(path, 'w+'))
...@@ -136,7 +229,7 @@ def install_hook(): ...@@ -136,7 +229,7 @@ def install_hook():
vcs = find_vcs() vcs = find_vcs()
if not vcs: if not vcs:
p = get_parser() p = get_parser()[0]
sys.stderr.write('Error: could not find either a git or mercurial ' sys.stderr.write('Error: could not find either a git or mercurial '
'directory. Please re-run this in a proper ' 'directory. Please re-run this in a proper '
'repository.') 'repository.')
...@@ -147,7 +240,8 @@ def install_hook(): ...@@ -147,7 +240,8 @@ def install_hook():
if 'git' in vcs: if 'git' in vcs:
with open(vcs, 'w+') as fd: with open(vcs, 'w+') as fd:
fd.write(git_hook_file) fd.write(git_hook_file)
os.chmod(vcs, 744) # rwxr--r--
os.chmod(vcs, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
elif 'hg' in vcs: elif 'hg' in vcs:
_install_hg_hook(vcs) _install_hg_hook(vcs)
else: else:
......
# -*- coding: utf-8 -*-
from __future__ import with_statement
import os
import sys
from subprocess import Popen, PIPE
try:
from mercurial import demandimport
demandimport.disable()
except ImportError:
pass
try:
from configparser import ConfigParser
except ImportError: # Python 2
from ConfigParser import ConfigParser
from flake8.engine import get_parser, get_style_guide
from flake8.main import DEFAULT_CONFIG
def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
"""This is the function used by the git hook.
:param int complexity: (optional), any value > 0 enables complexity
checking with mccabe
:param bool strict: (optional), if True, this returns the total number of
errors which will cause the hook to fail
:param str ignore: (optional), a comma-separated list of errors and
warnings to ignore
:param bool lazy: (optional), allows for the instances where you don't add
the files to the index before running a commit, e.g., git commit -a
:returns: total number of errors if strict is True, otherwise 0
"""
gitcmd = "git diff-index --cached --name-only HEAD"
if lazy:
# Catch all files, including those not added to the index
gitcmd = gitcmd.replace('--cached ', '')
if hasattr(ignore, 'split'):
ignore = ignore.split(',')
# Returns the exit code, list of files modified, list of error messages
_, files_modified, _ = run(gitcmd)
# Run the checks
flake8_style = get_style_guide(
config_file=DEFAULT_CONFIG, ignore=ignore, max_complexity=complexity)
report = flake8_style.check_files([f for f in files_modified if
f.endswith('.py')])
if strict:
return report.total_errors
return 0
def hg_hook(ui, repo, **kwargs):
"""This is the function executed directly by Mercurial as part of the
hook. This is never called directly by the user, so the parameters are
undocumented. If you would like to learn more about them, please feel free
to read the official Mercurial documentation.
"""
complexity = ui.config('flake8', 'complexity', default=-1)
strict = ui.configbool('flake8', 'strict', default=True)
config = ui.config('flake8', 'config', default=True)
if config is True:
config = DEFAULT_CONFIG
paths = _get_files(repo, **kwargs)
flake8_style = get_style_guide(
config_file=config, max_complexity=complexity)
report = flake8_style.check_files(paths)
if strict:
return report.total_errors
return 0
def run(command):
p = Popen(command.split(), stdout=PIPE, stderr=PIPE)
(stdout, stderr) = p.communicate()
return (p.returncode, [line.strip() for line in stdout.splitlines()],
[line.strip() for line in stderr.splitlines()])
def _get_files(repo, **kwargs):
seen = set()
for rev in range(repo[kwargs['node']], len(repo)):
for file_ in repo[rev].files():
file_ = os.path.join(repo.root, file_)
if file_ in seen or not os.path.exists(file_):
continue
seen.add(file_)
if file_.endswith('.py'):
yield file_
def find_vcs():
if os.path.isdir('.git'):
if not os.path.isdir('.git/hooks'):
os.mkdir('.git/hooks')
return '.git/hooks/pre-commit'
elif os.path.isdir('.hg'):
return '.hg/hgrc'
return ''
git_hook_file = """#!/usr/bin/env python
import sys
import os
from flake8.hooks import git_hook
COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10)
STRICT = os.getenv('FLAKE8_STRICT', False)
if __name__ == '__main__':
sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT))
"""
def _install_hg_hook(path):
if not os.path.isfile(path):
# Make the file so we can avoid IOError's
open(path, 'w+').close()
c = ConfigParser()
c.readfp(open(path, 'r'))
if not c.has_section('hooks'):
c.add_section('hooks')
if not c.has_option('hooks', 'commit'):
c.set('hooks', 'commit', 'python:flake8.hooks.hg_hook')
if not c.has_option('hooks', 'qrefresh'):
c.set('hooks', 'qrefresh', 'python:flake8.hooks.hg_hook')
if not c.has_section('flake8'):
c.add_section('flake8')
if not c.has_option('flake8', 'complexity'):
c.set('flake8', 'complexity', str(os.getenv('FLAKE8_COMPLEXITY', 10)))
if not c.has_option('flake8', 'strict'):
c.set('flake8', 'strict', os.getenv('FLAKE8_STRICT', False))
c.write(open(path, 'w+'))
def install_hook():
vcs = find_vcs()
if not vcs:
p = get_parser()
sys.stderr.write('Error: could not find either a git or mercurial '
'directory. Please re-run this in a proper '
'repository.')
p.print_help()
sys.exit(1)
status = 0
if 'git' in vcs:
with open(vcs, 'w+') as fd:
fd.write(git_hook_file)
# 0b111100100 == rwxr--r--
# Python 2.5 doesn't support 0b syntax so note that the above binary
# value is equivalent to 484 in decimal
os.chmod(vcs, 484)
elif 'hg' in vcs:
_install_hg_hook(vcs)
else:
status = 1