Skip to content
This repository
tree: fc027e5287
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 29 lines (23 sloc) 0.642 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
"""
Misc Utils

See COPYING for license information
"""

import urllib

def unicode_quote(s):
    """ Solves an issue with url-quoting unicode strings"""
    if isinstance(s, unicode):
        return urllib.quote(s.encode("utf-8"))
    else:
        return urllib.quote(str(s))


def get_path(parts=None):
    """
Returns the path to a resource. Parts can be a list of strings or
a string.
"""
    path = parts
    if parts:
        if isinstance(parts, list):
            path = '/'.join(map(unicode_quote, parts))
        else:
            path = '/'.join(map(unicode_quote, path.split('/')))
    return path
Something went wrong with that request. Please try again.