#!/usr/bin/python from sys import argv, exit def uri_parser(uri): try: from urlparse import urlparse except: from urllib.parse import urlparse return urlparse(uri) if __name__ == "__main__": try: uri = argv[1] except: print('usage: %s URI') exit(1) u = uri_parser(uri) print("SCHEME='%s'" % u.scheme.replace("'", "'\\''")) if u.username: print("USERNAME='%s'" % u.username.replace("'", "'\\''")) if u.password: print("PASSWORD='%s'" % u.password.replace("'", "'\\''")) if u.path: print("URIPATH='%s'" % u.path.replace("'", "'\\''")) print("HOSTN='%s'" % u.hostname.replace("'", "'\\''"))