Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add equality method to PathSpec #13

Merged
merged 2 commits into from Apr 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions pathspec/pathspec.py
Expand Up @@ -5,6 +5,7 @@
"""

import collections
from itertools import izip_longest

from . import util
from .compat import string_types, viewkeys
Expand All @@ -30,6 +31,14 @@ def __init__(self, patterns):
"""

self.patterns = patterns if isinstance(patterns, collections.Container) else list(patterns)

def __eq__(self, other):
"""
Tests equality of this ``PathSpec`` with ``other`` based on the
regexs contained in their ``patterns``.
"""
paired_patterns = izip_longest(self.patterns, other.patterns)
return all(a.regex == b.regex for a, b in paired_patterns)

def __len__(self):
"""
Expand Down