summaryrefslogtreecommitdiffstats
path: root/util/bin/urlparse
blob: 3767b92985f3f9124b48eacc00363ed7eb4fb0f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python
import os
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('USERNAME="%s"' % u.username)
    print('PASSWORD="%s"' % u.password)
    print('HOSTNAME="%s"' % u.hostname)
    print('URIPATH="%s"' % u.path)