1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import os
17 import pwd
18 import sys
19
21 userid = os.getuid()
22 info = pwd.getpwuid(userid)
23 return info[5]
24
25
26
27
29
30
31 for attr in object1.__dict__.keys():
32
33
34 if not attr or attr[0] == "_":
35 continue
36
37
38 if attr not in object2.__dict__ or object2.__dict__[attr] == '':
39 continue
40
41
42 if isinstance(object1.__dict__[attr], (type(object2.__dict__[attr]), type(None))):
43 if object1.__dict__[attr] != object2.__dict__[attr]:
44 object1.__dict__[attr] = object2.__dict__[attr]
45 else:
46 continue
47 else:
48 continue
49
50 return (object1, object2)
51
52
53
54
56 ret = []
57 if hasattr(urlparse_object, 'scheme'):
58 ret.append(urlparse_object.scheme)
59 ret.append(urlparse_object.netloc)
60 ret.append(urlparse_object.path)
61 ret.append(urlparse_object.params)
62 ret.append(urlparse_object.query)
63 ret.append(urlparse_object.fragment)
64 else:
65 ret = [urlparse_object[i] for i in range(0, 6)]
66
67 if sys.version_info[0] == 3:
68 for i in range(0, 6):
69 if not isinstance(ret[i], str):
70 ret[i] = ret[i].decode('ascii')
71 return tuple(ret)
72
73 if __name__ == "__main__":
74
75
80
85
86 obj1 = class1()
87 obj2 = class2()
88
89 obj1, obj2 = make_common_attr_equal(obj1, obj2)
90
91 print(obj1.a)
92 print(obj2.a)
93