-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurlDiff.py
More file actions
executable file
·92 lines (76 loc) · 1.76 KB
/
urlDiff.py
File metadata and controls
executable file
·92 lines (76 loc) · 1.76 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/python
import sys
import urlparse
if len(sys.argv) == 1:
print
print "Usage: urlDiff.py firstHTTPURL secondHTTPURL"
print "Output: base - firstHTTPURL"
print " comp - secondHTTPURL"
print
sys.exit(0)
baseline = sys.argv[1]
compare = sys.argv[2]
#print baseline
#print compare
b = urlparse.urlparse(baseline);
c = urlparse.urlparse(compare);
#schema
base_schema = b.scheme
compare_schema = c.scheme
#hostname
base_host = b.hostname
compare_host = c.hostname
#port
base_port = b.port;
compare_port = c.port;
#path
base_path = b.path;
compare_path = c.path;
#fragment
base_frag = b.fragment;
compare_frag = c.fragment;
base_params = b.query;
comp_params = c.query;
D = dict()
def store(params, isBase):
params = urlparse.parse_qs(params)
#print params
for k in params:
#print kv
key = k
value = params[key]
#print key, value
a = ""
b = ""
if D.has_key(key):
a,b = D[key]
if isBase:
a = value
else:
b = value
# store it back
D[key] = a,b
store(base_params, 1)
store(comp_params, 0)
#print D
def printer(param, base, comp):
if base==None:
base = ""
if comp==None:
comp = ""
print '%s %s %s' % (param, base, comp)
if base_schema != compare_schema:
printer("scheme", base_schema, compare_schema);
if base_host != compare_host:
printer("host", base_host, compare_host);
if base_port != compare_port:
printer("port", base_port, compare_port);
if base_path != compare_path:
printer("path", base_path, compare_path);
if base_frag != compare_frag:
printer("fragment", base_frag, compare_frag);
for key, value in D.iteritems():
base, comp = value
if base != comp:
print '%s - %s - %s' % (key, base, comp)
print # to test ajax timeout, comment this out