'Adds a distance penalty that corresponds to the position at
which `value` appears in `options`. A distance penalty of 0.0
for the first option, or 1.0 if there is no matching option. If
an option is a compiled regular expression, it will be
considered equal if it matches against `value`.'

def add_priority(self, key, value, options):

    if (not isinstance(options, (list, tuple))):
        options = [options]
    unit = (1.0 / (len(options) or 1))
    for (i, opt) in enumerate(options):
        if self._eq(opt, value):
            dist = (i * unit)
            break
    else:
        dist = 1.0
    self.add(key, dist)
