Get the file name from an url
    
    Parameters
    ----------
    url : str

    Returns
    -------
    str
        The file name
164283
def get_url_file_name(url):
    

    assert isinstance(url, (str, _oldstr))
    return urlparse.urlparse(url).path.split('/')[-1]
1034647
def GetFilename(self):
    
    if not self._file_entry:
      return None

    data_stream = getattr(self._file_entry.path_spec, 'data_stream', None)
    if data_stream:
      return '{0:s}:{1:s}'.format(self._file_entry.name, data_stream)

    return self._file_entry.name
873294
private static String getFileName(Context context, Uri uri){
        Cursor c = context.getContentResolver().query(uri, null, null, null, null);
        int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME);
        c.moveToFirst();
        String fileName = c.getString(nameIndex);
        c.close();
        return fileName;
    }
726598
def get_url_file_ext(url):
    """"""
    # get the last part of the path component
    filename = url.split('/')[-1]
    name, ext = os.path.splitext(filename)

    # handle case of files with leading dot
    if not ext and name and name[0] == '.':
        ext = name

    return ext
752361
def url_to_path(url):
    # type: (str) -> ByteString
    
    from .misc import to_bytes

    assert is_file_url(url), "Only file: urls can be converted to local paths"
    _, netloc, path, _, _ = urllib_parse.urlsplit(url)
    # Netlocs are UNC paths
    if netloc:
        netloc = "\\\\" + netloc

    path = urllib_request.url2pathname(netloc + path)
    return to_bytes(path, encoding="utf-8")
490389
def url_to_filename(url):
    
    # remove leading/trailing slash
    if url.startswith('/'):
        url = url[1:]
    if url.endswith('/'):
        url = url[:-1]
    # remove pardir symbols to prevent unwilling filesystem access
    url = remove_pardir_symbols(url)
    # replace dots to underscore in filename part
    url = replace_dots_to_underscores_at_last(url)
    return url
899056
def make_safe_filename_from_url(self, url):
        ''''''
        r = re.compile("([^a-zA-Z0-9_.-])")
        filename = r.sub(lambda m : "%" + str(hex(ord(str(m.group(1))))).upper(), url)
        return filename
573323
public static String getFilename(final URL url) throws UnsupportedEncodingException
	{
		if (isJar(url) || isEar(url))
		{
			String fileName = URLDecoder.decode(url.getFile(), "UTF-8");
			fileName = fileName.substring(5, fileName.indexOf("!"));
			return fileName;
		}
		return URLDecoder.decode(url.getFile(), "UTF-8");
	}
626380
def sanitize_url(url: str) -> str:
    

    for part in reversed(url.split('/')):
        filename = re.sub(r'[^a-zA-Z0-9_.\-]', '', part)
        if len(filename) > 0:
            break
    else:
        raise ValueError('Could not create reasonable name for file from url %s', url)

    return filename
1104965
def get_path(url):
        

        if url not in URLHelper.__cache:
            URLHelper.__cache[url] = urlparse(url)

        return URLHelper.__cache[url].path
225672
def get_url(self, url):
        
        if url.startswith('/'):
            url = '%s%s' % (self.base_url, url)
        return url
1216410
def _compute_filename(self, request: BaseRequest):
        ''''''
        path = self._path_namer.get_filename(request.url_info)

        if os.path.isdir(path):
            path += '.f'
        else:
            dir_name, name = os.path.split(path)
            path = os.path.join(anti_clobber_dir_path(dir_name), name)

        return path
814319
static String getFilenameFromUrl(String url) {
    String filename = md5(url) + ".down";

    int index = url.lastIndexOf("/");
    if (index > 0) {
      String tmpFilename = url.substring(index + 1);
      int qmarkIndex = tmpFilename.indexOf("?");
      if (qmarkIndex > 0) {
        tmpFilename = tmpFilename.substring(0, qmarkIndex - 1);
      }

      /* if filename contains '.', then the filename has file extension */
      if (tmpFilename.contains(".")) {
        filename = tmpFilename;
      }
    }

    return filename;
  }
1059737
def _get_name_from_url(self, request):
        

        format = request.GET.get('format', None)
        if not format:
            match = self._format_query_pattern.match(request.path)
            if match and match.group('format'):
                format = match.group('format')
        return format
681994
def parse_url(url, warning=True):
    
    parsed = urllib_parse.urlparse(url)
    query = urllib_parse.parse_qs(parsed.query)
    is_gdrive = parsed.hostname == 'drive.google.com'
    is_download_link = parsed.path.endswith('/uc')

    file_id = None
    if is_gdrive and 'id' in query:
        file_ids = query['id']
        if len(file_ids) == 1:
            file_id = file_ids[0]
    match = re.match(r'^/file/d/(.*?)/view$', parsed.path)
    if match:
        file_id = match.groups()[0]

    if is_gdrive and not is_download_link:
        warnings.warn(
            'You specified Google Drive Link but it is not the correct link '
            "to download the file. Maybe you should try: {url}"
            .format(url='https://drive.google.com/uc?id={}'.format(file_id))
        )

    return file_id, is_download_link
438883
def get_filename(self, instance):
        
        filename = self.field.getFilename(instance)
        if filename:
            return filename

        fieldname = self.get_field_name()
        content_type = self.get_content_type(instance)
        extension = mimetypes.guess_extension(content_type)

        return fieldname + extension
194784
def get_url(self, fname):
        
        self._assert_file_in_registry(fname)
        return self.urls.get(fname, "".join([self.base_url, fname]))