summaryrefslogtreecommitdiffstats
path: root/util/bin/uriparse
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2013-09-02 19:34:59 +0200
committermakefu <github@syntax-fehler.de>2013-09-02 19:34:59 +0200
commit4f8ac29f0ca730d48212282605cd61c654a42529 (patch)
tree7b3a6ce5e2d73ce7b495557d0962288047b42770 /util/bin/uriparse
parenta3675799d1d9a0e7879071b23f1cc066c709efd0 (diff)
urlparse ->uriparse
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)