Plugin dev: check if a match is applied automatically in `before_choose_candidate`

I’m writing a plugin that’s supposed to notify me if there’s a beet import command that failed to find a match with more then 95% similarity.

Hence I use:

        self.register_listener('before_choose_candidate',
                               self.before_choose_candidate_event)

I currently use:

        if str(task.rec) == "Recommendation.strong":
            self._log.info("discarding notifying")
            return

Is this the best way to check task.rec's value? I’m just not sure how to handle that type, i.e:

<Recommendation.strong: 3>

Or:

<Recommendation.low: 1>

That’s an enumeration:

You can compare directly to its members using ==. The enum module docs may help:
https://docs.python.org/3/library/enum.html

1 Like

Thanks @adrian. You are the best :).

2 Likes