docs: def url_download(url, topath=None, create_dirs=True):
      '''
      url_download(url) yields the contents of the given url as a byte-string.
      url_download(url, topath) downloads the given url to the given path, topath and yields that path
        on success.
  
      The option create_dirs (default: True) may be set to False to prevent the topath directory from
      being created.
      '''
      # ensure directory exists
      if topath: topath = os.path.expanduser(os.path.expandvars(topath))
      if create_dirs and topath:
          dnm = os.path.dirname(topath)
          if not os.path.isdir(dnm): os.makedirs(os.path.abspath(dnm), 0o755)
      if six.PY2:
          response = urllib.request.urlopen(url)
          if topath is None: topath = response.read()
          else:
              with open(topath, 'wb') as fl:
                  shutil.copyfileobj(response, fl)
      else:
          with urllib.request.urlopen(url) as response:
              if topath is None: topath = response.read()
              else:
                  with open(topath, 'wb') as fl:
                      shutil.copyfileobj(response, fl)
      return topath