mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 05:54:17 +00:00
Add compatibility layer for Python 2.6
os.path.relpath on Python 2.6 returns slightly different output than it does on 2.7. Rather than try to write tests around the behaviour, it makes sense to have a common relpath function that behaves the same on every version.
This commit is contained in:
parent
7ab30a747f
commit
0e2b873c38
3 changed files with 18 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ try:
|
|||
except ImportError: # Python 2
|
||||
from ConfigParser import ConfigParser
|
||||
|
||||
from flake8 import compat
|
||||
from flake8.engine import get_parser, get_style_guide
|
||||
from flake8.main import DEFAULT_CONFIG
|
||||
|
||||
|
|
@ -65,7 +66,7 @@ def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
|
|||
# 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 = compat.relpath(dirname, start=prefix)
|
||||
dirname = os.path.join(tmpdir, dirname)
|
||||
if not os.path.isdir(dirname):
|
||||
os.makedirs(dirname)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue