'Returns the path in the library directory designated for the
item (i.e., where the file ought to be). fragment makes this
method return just the path fragment underneath the root library
directory; the path is also returned as Unicode instead of
encoded as a bytestring. basedir can override the library\'s base
directory for the destination.'

def destination(self, fragment=False, basedir=None, platform=None, path_formats=None):

    self._check_db()
    platform = (platform or sys.platform)
    basedir = (basedir or self._db.directory)
    path_formats = (path_formats or self._db.path_formats)
    for (query, path_format) in path_formats:
        if (query == PF_KEY_DEFAULT):
            continue
        (query, _) = parse_query_string(query, type(self))
        if query.match(self):
            break
    else:
        for (query, path_format) in path_formats:
            if (query == PF_KEY_DEFAULT):
                break
        else:
            assert False, u'no    default    path    format'
    if isinstance(path_format, Template):
        subpath_tmpl = path_format
    else:
        subpath_tmpl = Template(path_format)
    subpath = self.evaluate_template(subpath_tmpl, True)
    if (platform == 'darwin'):
        subpath = unicodedata.normalize('NFD', subpath)
    else:
        subpath = unicodedata.normalize('NFC', subpath)
    if beets.config['asciify_paths']:
        subpath = util.asciify_path(subpath, beets.config['path_sep_replace'].as_str())
    maxlen = beets.config['max_filename_length'].get(int)
    if (not maxlen):
        maxlen = util.max_filename_length(self._db.directory)
    (subpath, fellback) = util.legalize_path(subpath, self._db.replacements, maxlen, os.path.splitext(self.path)[1], fragment)
    if fellback:
        log.warning(u'Fell    back    to    default    replacements    when    naming    file    {}.    Configure    replacements    to    avoid    lengthening    the    filename.', subpath)
    if fragment:
        return util.as_string(subpath)
    else:
        return normpath(os.path.join(basedir, subpath))
