summaryrefslogtreecommitdiffstats
path: root/util/bin/urlparse
blob: 685b1ab1f1c1fa3b17de0250b3a5e52965ab94ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/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('SCHEME="%s"' % u.scheme)
    if u.username:
        print('USERNAME="%s"' % u.username)
    if u.password:
        print('PASSWORD="%s"' % u.password)
    if u.path:
        print('URIPATH="%s"' % u.path)
    print('HOSTNAME="%s"' % u.hostname)