flake8/flake8/compat.py
Ian Cordasco 0e2b873c38 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.
2015-03-06 23:43:36 -06:00

12 lines
347 B
Python

# -*- coding: utf-8 -*-
"""Compatibility shims for Flake8."""
import os.path
import sys
def relpath(path, start='.'):
"""Wallpaper over the differences between 2.6 and newer versions."""
if sys.version_info < (2, 7) and path.startswith(start):
return path[len(start):]
else:
return os.path.relpath(path, start=start)