1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2025-03-10 05:34:36 +00:00

Fixed core.engine.Match docstring

The way it was set made dupeGuru crash under Python 3.2
This commit is contained in:
Virgil Dupras 2013-10-20 13:33:27 -04:00
parent 9ea9f60e92
commit 8e65f15e1a

View File

@ -157,26 +157,31 @@ def reduce_common_words(word_dict, threshold):
else: else:
del word_dict[word] del word_dict[word]
Match = namedtuple('Match', 'first second percentage') # Writing docstrings in a namedtuple is tricky. From Python 3.3, it's possible to set __doc__, but
Match.__doc__ = """Represents a match between two :class:`~core.fs.File`. # some research allowed me to find a more elegant solution, which is what is done here. See
# http://stackoverflow.com/questions/1606436/adding-docstrings-to-namedtuples-in-python
Regarless of the matching method, when two files are determined to match, a Match pair is created, class Match(namedtuple('Match', 'first second percentage')):
which holds, of course, the two matched files, but also their match "level". """Represents a match between two :class:`~core.fs.File`.
.. attribute:: first Regarless of the matching method, when two files are determined to match, a Match pair is created,
which holds, of course, the two matched files, but also their match "level".
first file of the pair. .. attribute:: first
.. attribute:: second first file of the pair.
second file of the pair. .. attribute:: second
.. attribute:: percentage second file of the pair.
their match level according to the scan method which found the match. int from 1 to 100. For .. attribute:: percentage
exact scan methods, such as Contents scans, this will always be 100.
"""
their match level according to the scan method which found the match. int from 1 to 100. For
exact scan methods, such as Contents scans, this will always be 100.
"""
__slots__ = ()
def get_match(first, second, flags=()): def get_match(first, second, flags=()):
#it is assumed here that first and second both have a "words" attribute #it is assumed here that first and second both have a "words" attribute
percentage = compare(first.words, second.words, flags) percentage = compare(first.words, second.words, flags)