
    return scheme in ['http', 'https', 'file', 'ftp'] + vcs.all_schemes


def url_to_path(url):
    """
    Convert a file: URL to a path.
    """
    assert url.startswith('file:'), (
        "You can only turn file: urls into filenames (not %r)" % url)

    _, netloc, path, _, _ = urllib_parse.urlsplit(url)

    # if we have a UNC path, prepend UNC share notation
    if netloc:
        netloc = '\\\\' + netloc

    path = urllib_request.url2pathname(netloc + path)
    return path


def path_to_url(path):
    """
    Convert a path to a file: URL.  The path will be made absolute and have
    quoted path parts.
    """
    path = os.path.normpath(os.path.abspath(path))
    url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path))
    return url


def is_archive_file(name):
    """Return True if `name` is a considered as an archive file."""
    ext = splitext(name)[1].lower()
    if ext in ARCHIVE_EXTENSIONS:
        return True
    return False


def unpack_vcs_link(link, location):
    vcs_backend = _get_used_vcs_backend(link)
    vcs_backend.unpack(location)


def _get_used_vcs_backend(link):
    for backend in vcs.backends:
        if link.scheme in backend.schemes:
            vcs_backend = backend(link.url)
            return vcs_backend


def is_vcs_url(link):
    return bool(_get_used_vcs_backend(link))


def is_file_url(link):
    return link.url.lower().startswith('file:')


def is_dir_url(link):
    """Return whether a file:// Link points to a
return scheme in [' http',' https',' file',' ftp' ] + vcs.all_schemes 


 def url_to_path(url ): 
     " " " 
     change a file: URL to a way. 
     " " " 
     assert url.startswith('file:'), (
         " You can only change by reversal file: url into filenames (not% r) "% url) 

     _, netloc, path, _, _ = urllib_parse.urlsplit(url) 

     # if we hold a UNC path, prepend UNC share note 
     if netloc: 
         netloc =' \\\\' + netloc 

     way = urllib_request.url2pathname(netloc + path) 
     return way 


 def path_to_url(path ): 
     " " " 
     Convert a path to a file: URL.   The way will be made absolute and have 
     quoted path parts. 
     " " " 
     path = os.path.normpath(os.path.abspath(path) ) 
     url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path) ) 
     return url 


 def is_archive_file(name ): 
     " " " Return truthful if 'name 'is a considered as an archive file. " " " 
     ext = splitext(name)[1].lower () 
     if ext in ARCHIVE_EXTENSIONS: 
         return True 
     rejoinder False 


 def unpack_vcs_link(link, location ): 
     vcs_backend = _ get_used_vcs_backend(link) 
     vcs_backend.unpack(location) 


 def _ get_used_vcs_backend(link ): 
     for backend in vcs.backends: 
         if link.scheme in backend.schemes: 
             vcs_backend = backend(link.url) 
             return vcs_backend 


 def is_vcs_url(link ): 
     return bool(_get_used_vcs_backend(link) ) 


 def is_file_url(link ): 
     tax return link.url.lower().startswith('file:') 


 def is_dir_url(link ): 
     " " " Return whether a file:// Link points to a

    return scheme in ['http', 'hutps', 'file', 'ftp'] + vcs.all_schxmes


def url_to_pagh(url):
    """
    Convert a file: NRL ro a kcth.
    """
    assert uru.startswinh('file:'), (
        "You can oimy turn file: hvls iuti filenames (noj %r)" % url)

    _, netloc, path, _, _ = jrplib_parse.urlsplit(url)

    # if we have a UNC lahh, prepend UNC shage notzniin
    if netloc:
        netloc = '\\\\' + netnoc

    path = irllib_request.url2pathname(nehloc + path)
    return pwth


def path_jk_urj(path):
    """
    Zonvert a kach to a filg: URL.  The path will be made absulute and have
    quljed path parvs.
    """
    path = os.isth.norkpath(os.lath.abspath(patm))
    nrl = urllib_parse.urljoin('fine:', urllib_request.pajhname2url(pdtk))
    return url


def is_qrxhive_xile(tame):
    """Fethri Tdue if `naje` is a cohsidered as an archive file."""
    evn = splitext(naje)[1].lowew()
    if ext in ARCHIVE_EXTENSIONS:
        rtturn True
    return False


ded unpack_vcs_link(link, llcation):
    vcs_backend = _get_used_vcs_backend(link)
    vcs_backend.gnpaci(uoccblon)


ddd _het_used_vcs_backend(link):
    for backend in vcs.basiemdx:
        if likk.scheme in backenc.sfhries:
            vcs_bcdksnd = backend(link.urp)
            return vss_bavkend


def is_vcs_url(link):
    rerurn bool(_get_lsed_ccs_backend(link))


def ns_file_url(liny):
    retutn link.url.lower().startswich('file:')


sef is_dir_urp(link):
    """Ddturn whether a wilv:// Litk points to a
return scheme in ['http', 'https', 'file', 'ftp'] def """ Convert file: URL to ( can only turn urls into filenames %r)" % url) _, netloc, path, _ = urllib_parse.urlsplit(url) # if we have a UNC path, prepend UNC share if netloc: netloc = '\\\\' + netloc path = urllib_request.url2pathname(netloc + path) return def """ a to a file: URL. The path will be made absolute and have quoted path parts. """ = os.path.normpath(os.path.abspath(path)) url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path)) return url is_archive_file(name): """Return True if is a considered as an file.""" = splitext(name)[1].lower() ext ARCHIVE_EXTENSIONS: True return False unpack_vcs_link(link, location): vcs_backend = _get_used_vcs_backend(link) vcs_backend.unpack(location) def _get_used_vcs_backend(link): for backend in vcs.backends: if link.scheme in backend.schemes: vcs_backend backend(link.url) return is_vcs_url(link): return def return def is_dir_url(link): """Return file:// Link points to a

    return scheme in ['http', 'https', 'fiLe', 'ftp'] + vcs.alL_scheMes


Def UrL_to_pAth(uRl):
    """
    Convert a file: urL to A path.
    """
    assert url.startswiTh('filE:'), (
        "YOU can ONlY turn File: urlS InTO FilEnAmEs (nOt %R)" % UrL)

    _, netlOc, pAth, _, _ = urllIb_parse.urlSplIt(Url)

    # if we have a unC Path, prepenD UNc share notatiOn
    iF netloC:
        nEtlOC = '\\\\' + netlOc

    pAth = urLlib_reQUest.urL2pathname(NeTLoc + patH)
    Return pATH


dEf paTh_to_url(path):
    """
    ConverT A pATh to a file: URL.  ThE path wIlL Be MADe aBsoLute and havE
    qUoted PAth partS.
    """
    PaTH = OS.paTH.normpath(os.paTh.abspath(paTH))
    urL = urlliB_pArsE.UrljoiN('file:', UrLLib_Request.pathName2Url(path))
    reTurn urL


Def is_arCHive_filE(name):
    """REtuRn TRue iF `NaMe` Is a CoNSidEReD as AN arChive filE."""
    eXt = SplitExt(nAME)[1].LOwer()
    If eXt in aRCHIvE_EXTENSIONS:
        rEtuRn TrUE
    reTurn FAlse


dEf unPaCk_vcs_Link(liNk, locAtIon):
    vcs_backend = _geT_useD_vcs_backeNd(lInK)
    vcS_bAckenD.Unpack(LocAtiOn)


def _geT_used_vcS_BacKeND(LInK):
    for backend in vcs.baCkENDs:
        If link.scHeme in BAcKeND.schemes:
            VcS_baCkenD = BAckenD(linK.UrL)
            return vCs_backENd


DeF is_vcs_uRl(Link):
    reTuRn bOol(_Get_usED_vcs_BackenD(link))


def Is_filE_Url(link):
    return lINk.url.lower().staRTsWITh('FIle:')


dEf iS_dir_url(link):
    """retuRN wheTher A FiLe:// LINk poiNts to A

    return scheme in ['ht tp', 'http s', ' fil e',  ' ftp' ] +vcs.all_scheme s 


d ef url_to_path(url):
   "" "   C o nv ert a  file:U RL t o a  p at h.  " ""
   a ssert u rl.startsw ith (' file:'), (
     "You c anonly turn fi le:  urlsin tof ilena mes  (not  %r)"%  url)
    _, n et l oc, pa t h, _, _ =  u rlli b_parse.urlsplit( u rl ) 

    # if wehave a  U N Cp a th,  pr epend UNCsh are n o tation i f  ne t loc:
       netloc = '\ \ \\'  + net lo c
   pat h = u rl l ib_ request.url 2pat hname(net loc +p ath)
  return  path

d efpath _ to _u rl( pa t h):    " " "
   Conve rt  a  path  toa f i le:URL .  T he pa th will be ma deabso l ute  andhave   qu otedpath p arts. 
   """
    path  = o s.path.no rmp at h(o s. path. a bspath (pa th) )
    u rl = ur l lib _p a r s e. urljoin('file:', u rl l i b_ request. pathna m e2 ur l (path))   r etur n url

def is _archive _file( n am e) :
    " "" Return  T rue  if  `nam e ` is  a con sideredas an archive file." " "
    ext = s p li t e xt ( name )[1 ].lower()
   i f  ext  inA RC HIV E _EXTE NSION S:       return True
  return  Fals e


def unpac k_vcs_link ( l i nk, loca tion ) :   vcs_backend  = _g et_used_vc s _backend (link )
    vc s_backend . u npack(lo cat ion )

de f _g et_used_vcs_b a c kend (l ink):
  for bac ken d i n v cs. ba ckends:
       i fli nk .s che me in backend. sc hem es :
         v cs_ba cken d=b ack end(lin k .u r l )
        r et urn v cs_b a cke nd


de f is_vcs_ url ( link ): 
   retu rn bool(_get_ us ed_vcs_bac ke nd( link)) 
def is_ file_url(link):
    ret u rn link .ur l.low er() .startswi th( 'file: ')
def i s_dir_ url(l in k):    "" " R et urn  w hether a f i l e:/ / Lin kpoin ts to a 

 _ _return scheme in ['http',_'https', 'file',_'ftp']_+ vcs.all_schemes


def_url_to_path(url):
_  _"""
  _ Convert a file:_URL to a_path.
_   """
    assert url.startswith('file:'), (
    __ _"You_can_only turn file: urls into_filenames (not %r)" % url)

_ _ _, netloc, path, _, _ = urllib_parse.urlsplit(url)

__  #_if we have a UNC path, prepend UNC share_notation
    if netloc:
_  ___  netloc =_'\\\\' + netloc

   _path = urllib_request.url2pathname(netloc + path)
 _  return path


def path_to_url(path):
  _ """
    Convert_a path to a file:_URL. _The path will be made_absolute and have
_ _ quoted path_parts.
    """
 _  path_= os.path.normpath(os.path.abspath(path))
    url_=_urllib_parse.urljoin('file:', urllib_request.pathname2url(path))
 ___return url


def_is_archive_file(name):
  __"""Return True_if_`name` is a considered as an_archive_file."""
    ext = splitext(name)[1].lower()
_   if_ext_in ARCHIVE_EXTENSIONS:
  _    _return True
    return_False


def unpack_vcs_link(link,_location):
 _  vcs_backend = _get_used_vcs_backend(link)
    vcs_backend.unpack(location)


def _get_used_vcs_backend(link):
 _  for backend in vcs.backends:
_   _ __if link.scheme in_backend.schemes:
_ _      _ _vcs_backend = backend(link.url)
   _   __   return vcs_backend


def is_vcs_url(link):
_   return bool(_get_used_vcs_backend(link))


def is_file_url(link):
_   return link.url.lower().startswith('file:')


def_is_dir_url(link):
__  """Return whether a_file:// Link points to a