summaryrefslogtreecommitdiffstats
path: root/util/bin/uriparse
diff options
context:
space:
mode:
Diffstat (limited to 'util/bin/uriparse')
-rwxr-xr-xutil/bin/uriparse28
1 files changed, 28 insertions, 0 deletions
diff --git a/util/bin/uriparse b/util/bin/uriparse
new file mode 100755
index 00000000..685b1ab1
--- /dev/null
+++ b/util/bin/uriparse
@@ -0,0 +1,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)