Skip to content

Commit

Permalink
Merge pull request #13 from ghickman/patch-1
Browse files Browse the repository at this point in the history
Add equality method to PathSpec
  • Loading branch information
cpburnz committed Apr 5, 2017
2 parents 6efce03 + 8cdc7cf commit 78ad596
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pathspec/pathspec.py
Original file line number Diff line number Diff line change
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

0 comments on commit 78ad596

Please sign in to comment.