Prettify path for humans, and make it Unicode.
554006
def pretty_path(path, _home_re=re.compile('^' + re.escape(os.path.expanduser('~') + os.sep))):
    """"""
    path = format_filename(path)
    path = _home_re.sub('~' + os.sep, path)
    return path
149671
function _prettyPath(path) {
  var afterLastSlash = path.substr(path.lastIndexOf('/') + 1);
  var re = /(\s)|(\.)|(-)|\//g; // replace all spaces, periods, and dashes
  // if( !!afterLastSlash.match(/^index\.html$/) ) {
  //   return 'root_index_page';
  // } else {
  //   return path.replace(/\.html/, '').replace(re, '_').toLowerCase();
  // }
  if (typeof _serverRoot !== 'undefined') {
    path = path.replace(_serverRoot, '');
  }
  return path.replace(/\.html/, '').replace(re, '_').toLowerCase();
}
512973
def beautify_xml(path):
    
    with open(path) as f:
        content = f.read()

    pretty_print = lambda data: '\n'.join([line for line in
                                           parseString(data)
                                           .toprettyxml(indent=' ' * 2)
                                           .split('\n')
                                           if line.strip()])
    return pretty_print(content)
621062
def make_readable_path(path):
    """"""
    home = os.path.expanduser("~")
    if path.startswith(home):
        path = "~" + path[len(home):]

    return path
1223899
def path_to_tuple(path, windows=False):
    
    if windows:
        path_tup = tuple(path.split('\\'))
    else:
        path_tup = tuple(path.split('/'))
    #
    # Normalize UTF-8 encoding to consistent form so cache lookups will work, see
    # https://docs.python.org/3.6/library/unicodedata.html#unicodedata.normalize
    path_tup = tuple(normalize('NFD', part) for part in path_tup)
    return path_tup
678295
def normalize_username(text, encoding='utf-8'):
    '''
    '''
    path = percent_encode(text, encoding=encoding, encode_set=USERNAME_ENCODE_SET)
    return uppercase_percent_encoding(path)
875096
def _format_as_url(path):
    """"""
    path = sub(r"\.html$", '', path)  # remove any ending .html

    # Make sure it starts/ends with a slash.
    if not path.startswith("/"):
        path = "/{0}".format(path)
    if not path.endswith("/"):
        path = "{0}/".format(path)

    return path
756023
def prettify(elem):
    
    rough_string = ET.tostring(elem, 'utf-8')
    reparsed = minidom.parseString(rough_string)
    return reparsed.toprettyxml(indent="\t")
1316058
def mark_path(path):
    
    # If given path is not string,
    # or given path is absolute path.
    if not isinstance(path, str) or os.path.isabs(path):
        # Get error message
        msg = 'Error (2D9ZA): Given path is not relative path: {0}.'.format(
            path
        )

        # Raise error
        raise ValueError(msg)

    # If given path is string,
    # and given path is not absolute path.

    # Wrap given path
    return _ItemWrapper(type='path', item=path)
1292247
def symbolize_path(path)
      path.gsub(/.*\/cli\//, '').split('/').map do |path_part|
        path_part.split('_').map{ |e| e.capitalize }.join
      end.map(&:to_sym)
    end
154359
def normalize_path(path):
    
    if path in ['//', '/', '']:
        return '/'
    npath = normpath(unquote(path, exceptions=QUOTE_EXCEPTIONS['path']))
    if path[-1] == '/' and npath != '/':
        npath += '/'
    return npath
882542
def displayable_path(path, separator=u'; '):
    
    if isinstance(path, (list, tuple)):
        return separator.join(displayable_path(p) for p in path)
    elif isinstance(path, six.text_type):
        return path
    elif not isinstance(path, bytes):
        # A non-string object: just get its unicode representation.
        return six.text_type(path)

    try:
        return path.decode(_fsencoding(), 'ignore')
    except (UnicodeError, LookupError):
        return path.decode('utf8', 'ignore')
32385
def _text_to_graphiz(self, text):
        """"""
        dot = Source(text, format='svg')
        return dot.pipe().decode('utf-8')
1038996
def escape_path(path):
    """"""
    # There's no knowing what character encoding was used to create URLs
    # containing %-escapes, but since we have to pick one to escape invalid
    # path characters, we pick UTF-8, as recommended in the HTML 4.0
    # specification:
    # http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1
    # And here, kind of: draft-fielding-uri-rfc2396bis-03
    # (And in draft IRI specification: draft-duerst-iri-05)
    # (And here, for new URI schemes: RFC 2718)
    path = quote(path, HTTP_PATH_SAFE)
    path = ESCAPED_CHAR_RE.sub(uppercase_escaped_char, path)
    return path
1116419
function formatAsElegantPath(path, sep) {
    const packages = path.split(sep);

    // prettier-ignore
    const result = packages.map(item => item.trim()).join(' -> ');
    return result;
}
1088877
def prepare_url(hostname, path, params=None):
        
        url = hostname + path

        if params:
            url = url + '?' + urlencode(params)

        if not url.startswith(('http:', 'https:')):
            url = "http://" + url

        return url.encode('utf-8')
306433
def full_path(self):
        """"""
        return self.path + u"?" + to_unicode(self.query_string, self.url_charset)