pyline
pyline copied to clipboard
ENH: --url/--urlobject: 'u = url = urlobject.URLObject(l) if l else None'
- [ ] ENH,UBY: convenience CLI arguments to cast line to urlobject.URLObject()
-u / --url / --urlobject- ENH:
url = urlobject.URLObject(line)
- [ ] ENH: provide
URL = urlobject.URLObjectfor the expr - [ ] ENH,UBY: try/import URLObject as URL
- [ ] ENH: URL = urlobject.URLObject
- [x] TST:
pyline -m urlobject 'urlobject.URL(w[0])(if URLObject is installed) - [ ] TST:
pyline 'URL(w[0]) - [ ] TST:
pyline "words and URL(w[0])") - [ ] TST:
pyline --urlobject 'url' - [ ] TST:
pyline --urlobject "line and url and url.with_scheme('https')")
- This suggests a need for multiple expressions (e.g. before, kernel, after)
- Or a registry of event handlers with a defined sequence
- Because I want to do
url=URL(words[1]); url- I could either or both parse
;semicolon and eval the expr appropriately - Or require each statement to be a separate argument
e.g. with action='append'
- I could either or both parse
useful e.g. for westurner/dotfiles/scripts/git-upgrade-remote-to-ssh.sh
function git_upgrade_url_to_ssh_pyline {
echo "${@}" | pyline -m urlobject \
'l and ((u.with_scheme("ssh").with_username(u.username or "git")) for u in [urlobject.URLObject(l)])'
}
So, ideally:
function git_upgrade_url_to_ssh_pyline {
echo "${@}" | pyline --url \
'u and u.with_scheme("ssh").with_username(u.username or "git")'
}
[edit] See also:
- ENH: pyline.py: --rgxurl / --rgxuri / --rgxurn to rfc3987 URI/URL regex #20
- ENH: rfc6570 URI templates #21
- ENH: --regex to new regex (if installed) #22