class documentation

class PathComparer:

View In Hierarchy

OS-independent path comparison.

Windows path sep and posix path sep:

>>> '\to\index' == PathComparer('/to/index')
True
>>> '\to\index' == PathComparer('/to/index2')
False

Windows path with drive letters

>>> 'C:\to\index' == PathComparer('/to/index')
True
>>> 'C:\to\index' == PathComparer('C:/to/index')
True
>>> 'C:\to\index' == PathComparer('D:/to/index')
False
Method __eq__ Undocumented
Method __init__
Method __repr__ Undocumented
Method __str__ Undocumented
Method ​_diff Undocumented
Method diff compare self and other.
Method ldiff Undocumented
Method rdiff Undocumented
Instance Variable path Undocumented
def __eq__(self, other):

Undocumented

Parameters
other:Union[str, pathlib.Path]Undocumented
Returns
boolUndocumented
def __init__(self, path):
Parameters
path:Union[str, pathlib.Path]Undocumented
str pathpath string, it will be cast as pathlib.Path.
def __repr__(self):

Undocumented

Returns
strUndocumented
def __str__(self):

Undocumented

Returns
strUndocumented
def _diff(self, lhs, rhs):

Undocumented

Parameters
lhs:pathlib.PathUndocumented
rhs:pathlib.PathUndocumented
Returns
List[str]Undocumented
def diff(self, other):

compare self and other.

When different is not exist, return empty list.

>>> PathComparer('/to/index').diff('C:\to\index')
[]

When different is exist, return unified diff style list as:

>>> PathComparer('/to/index').diff('C:\to\index2')
[
   '- C:/to/index'
   '+ C:/to/index2'
   '?            +'
]
Parameters
other:Union[str, pathlib.Path]Undocumented
Returns
List[str]Undocumented
def ldiff(self, other):

Undocumented

Parameters
other:Union[str, pathlib.Path]Undocumented
Returns
List[str]Undocumented
def rdiff(self, other):

Undocumented

Parameters
other:Union[str, pathlib.Path]Undocumented
Returns
List[str]Undocumented
path =

Undocumented