From 4f8ac29f0ca730d48212282605cd61c654a42529 Mon Sep 17 00:00:00 2001 From: makefu Date: Mon, 2 Sep 2013 19:34:59 +0200 Subject: urlparse ->uriparse --- util/bin/uriparse | 28 ++++++++++++++++++++++++++++ util/bin/urlparse | 28 ---------------------------- util/t/uriparse/parse-url | 12 ++++++++++++ util/t/urlparse/parse-url | 12 ------------ 4 files changed, 40 insertions(+), 40 deletions(-) create mode 100755 util/bin/uriparse delete mode 100755 util/bin/urlparse create mode 100755 util/t/uriparse/parse-url delete mode 100755 util/t/urlparse/parse-url (limited to 'util') 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) diff --git a/util/bin/urlparse b/util/bin/urlparse deleted file mode 100755 index 685b1ab1..00000000 --- a/util/bin/urlparse +++ /dev/null @@ -1,28 +0,0 @@ -#!/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) diff --git a/util/t/uriparse/parse-url b/util/t/uriparse/parse-url new file mode 100755 index 00000000..153afb4a --- /dev/null +++ b/util/t/uriparse/parse-url @@ -0,0 +1,12 @@ +#!/bin/sh +set -euf +tempfile="`mktemp /tmp/test.XXXXXXXX`" +trap "/bin/rm -f $tempfile" EXIT INT + +urlparse "http://user:pass@domain.tld/path" > $tempfile +. $tempfile +[ $HOSTNAME == "domain.tld" ] && \ + [ $USERNAME == "user" ] && \ + [ $PASSWORD == "pass" ] && \ + [ $URIPATH == "/path" ] + diff --git a/util/t/urlparse/parse-url b/util/t/urlparse/parse-url deleted file mode 100755 index 153afb4a..00000000 --- a/util/t/urlparse/parse-url +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -set -euf -tempfile="`mktemp /tmp/test.XXXXXXXX`" -trap "/bin/rm -f $tempfile" EXIT INT - -urlparse "http://user:pass@domain.tld/path" > $tempfile -. $tempfile -[ $HOSTNAME == "domain.tld" ] && \ - [ $USERNAME == "user" ] && \ - [ $PASSWORD == "pass" ] && \ - [ $URIPATH == "/path" ] - -- cgit v1.2.3