python - Parse a git URL like 'ssh://git@gitlab.org.net:3333/org/repo.git'? -
how extract hostname git url ssh://git@gitlab.org.net:3333/org/repo.git
u = urlparse(s)
gives me
parseresult(scheme='ssh', netloc='git@gitlab.org.net:3333', path='/org/repo.git', params='', query='', fragment='')
which means netloc closest want , leaves disappointing amount of work me.
should do
u.netloc.split('@')[1].split(':')[0]
or there library handles better?
the returned parseresult
has hostname
attribute:
>>> urlparse('ssh://git@gitlab.org.net:3333/org/repo.git').hostname 'gitlab.org.net'
Comments
Post a Comment