'Returns the custom URL converter for the given file name.'

def url_converter(self, name, template=None):

    if (template is None):
        template = self.default_template
    def converter(matchobj):
        u'\n                                                Converts    the    matched    URL    depending    on    the    parent    level    (`..`)\n                                                and    returns    the    normalized    and    hashed    URL    using    the    url    method\n                                                of    the    storage.\n                                                '
        (matched, url) = matchobj.groups()
        if url.startswith((u'#', u'http:', u'https:', u'data:', u'//')):
            return matched
        name_parts = name.split(os.sep)
        url = posixpath.normpath(url)
        url_parts = url.split(u'/')
        (parent_level, sub_level) = (url.count(u'..'), url.count(u'/'))
        if url.startswith(u'/'):
            sub_level -= 1
            url_parts = url_parts[1:]
        if (parent_level or (not url.startswith(u'/'))):
            (start, end) = ((parent_level + 1), parent_level)
        elif sub_level:
            if (sub_level == 1):
                parent_level -= 1
            (start, end) = (parent_level, 1)
        else:
            (start, end) = (1, (sub_level - 1))
        joined_result = u'/'.join((name_parts[:(- start)] + url_parts[end:]))
        hashed_url = self.url(unquote(joined_result), force=True)
        file_name = hashed_url.split(u'/')[(-1):]
        relative_url = u'/'.join((url.split(u'/')[:(-1)] + file_name))
        return (template % unquote(relative_url))
    return converter
