mirror of https://github.com/cool-RR/PySnooper.git
33 lines
854 B
Python
33 lines
854 B
Python
# Copyright 2019 Ram Rachum and collaborators.
|
|
# This program is distributed under the MIT license.
|
|
'''Python 2/3 compatibility'''
|
|
|
|
import abc
|
|
import os
|
|
|
|
if hasattr(abc, 'ABC'):
|
|
ABC = abc.ABC
|
|
else:
|
|
class ABC(object):
|
|
"""Helper class that provides a standard way to create an ABC using
|
|
inheritance.
|
|
"""
|
|
__metaclass__ = abc.ABCMeta
|
|
__slots__ = ()
|
|
|
|
|
|
if hasattr(os, 'PathLike'):
|
|
PathLike = os.PathLike
|
|
else:
|
|
class PathLike(ABC):
|
|
"""Abstract base class for implementing the file system path protocol."""
|
|
|
|
@abc.abstractmethod
|
|
def __fspath__(self):
|
|
"""Return the file system path representation of the object."""
|
|
raise NotImplementedError
|
|
|
|
@classmethod
|
|
def __subclasshook__(cls, subclass):
|
|
return hasattr(subclass, '__fspath__')
|