Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: --url/--urlobject: 'u = url = urlobject.URLObject(l) if l else None' #17

Open
1 of 9 tasks
westurner opened this issue Jul 25, 2015 · 3 comments
Open
1 of 9 tasks

Comments

@westurner
Copy link
Owner

  • ENH,UBY: convenience CLI arguments to cast line to urlobject.URLObject()
    • -u / --url / --urlobject
    • ENH: url = urlobject.URLObject(line)
  • ENH: provide URL = urlobject.URLObject for the expr
  • ENH,UBY: try/import URLObject as URL
    • ENH: URL = urlobject.URLObject
    • 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'
@westurner
Copy link
Owner Author

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)])'
}

@westurner
Copy link
Owner Author

So, ideally:

function git_upgrade_url_to_ssh_pyline {
    echo "${@}" | pyline --url \
    'u and u.with_scheme("ssh").with_username(u.username or "git")'
}

@westurner
Copy link
Owner Author

[edit]
See also:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant