Ticket #3840: remove-irc-constant-dups.patch

File remove-irc-constant-dups.patch, 7.7 KB (added by Jonathan Jacobs, 10 years ago)
Line 
1Index: words/protocols/irc.py
2===================================================================
3--- words/protocols/irc.py      (revision 26936)
4+++ words/protocols/irc.py      (working copy)
5+# Constants
6 RPL_WELCOME = '001'
7 RPL_YOURHOST = '002'
8 RPL_CREATED = '003'
9 RPL_MYINFO = '004'
10 RPL_BOUNCE = '005'
11+RPL_BOUNCE = '010'
12+RPL_TRACELINK = '200'
13+RPL_TRACECONNECTING = '201'
14+RPL_TRACEHANDSHAKE = '202'
15+RPL_TRACEUNKNOWN = '203'
16+RPL_TRACEOPERATOR = '204'
17+RPL_TRACEUSER = '205'
18+RPL_TRACESERVER = '206'
19+RPL_TRACESERVICE = '207'
20+RPL_TRACENEWTYPE = '208'
21+RPL_TRACECLASS = '209'
22+RPL_TRACERECONNECT = '210'
23+RPL_STATSLINKINFO = '211'
24+RPL_STATSCOMMANDS = '212'
25+RPL_ENDOFSTATS = '219'
26+RPL_UMODEIS = '221'
27+RPL_SERVLIST = '234'
28+RPL_SERVLISTEND = '235'
29+RPL_STATSUPTIME = '242'
30+RPL_STATSOLINE = '243'
31+RPL_LUSERCLIENT = '251'
32+RPL_LUSEROP = '252'
33+RPL_LUSERUNKNOWN = '253'
34+RPL_LUSERCHANNELS = '254'
35+RPL_LUSERME = '255'
36+RPL_ADMINME = '256'
37+RPL_ADMINLOC = '257'
38+RPL_ADMINLOC = '258'
39+RPL_ADMINEMAIL = '259'
40+RPL_TRACELOG = '261'
41+RPL_TRACEEND = '262'
42+RPL_TRYAGAIN = '263'
43+RPL_AWAY = '301'
44 RPL_USERHOST = '302'
45 RPL_ISON = '303'
46-RPL_AWAY = '301'
47 RPL_UNAWAY = '305'
48 RPL_NOWAWAY = '306'
49 RPL_WHOISUSER = '311'
50 RPL_WHOISSERVER = '312'
51 RPL_WHOISOPERATOR = '313'
52+RPL_WHOWASUSER = '314'
53+RPL_ENDOFWHO = '315'
54 RPL_WHOISIDLE = '317'
55 RPL_ENDOFWHOIS = '318'
56 RPL_WHOISCHANNELS = '319'
57-RPL_WHOWASUSER = '314'
58-RPL_ENDOFWHOWAS = '369'
59 RPL_LISTSTART = '321'
60 RPL_LIST = '322'
61 RPL_LISTEND = '323'
62-RPL_UNIQOPIS = '325'
63 RPL_CHANNELMODEIS = '324'
64+RPL_UNIQOPIS = '325'
65 RPL_NOTOPIC = '331'
66 RPL_TOPIC = '332'
67+RPL_TOPICWHOTIME = '333'
68 RPL_INVITING = '341'
69 RPL_SUMMONING = '342'
70 RPL_INVITELIST = '346'
71@@ -2318,17 +2421,17 @@
72 RPL_ENDOFEXCEPTLIST = '349'
73 RPL_VERSION = '351'
74 RPL_WHOREPLY = '352'
75-RPL_ENDOFWHO = '315'
76 RPL_NAMREPLY = '353'
77-RPL_ENDOFNAMES = '366'
78 RPL_LINKS = '364'
79 RPL_ENDOFLINKS = '365'
80+RPL_ENDOFNAMES = '366'
81 RPL_BANLIST = '367'
82 RPL_ENDOFBANLIST = '368'
83+RPL_ENDOFWHOWAS = '369'
84 RPL_INFO = '371'
85+RPL_MOTD = '372'
86 RPL_ENDOFINFO = '374'
87 RPL_MOTDSTART = '375'
88-RPL_MOTD = '372'
89 RPL_ENDOFMOTD = '376'
90 RPL_YOUREOPER = '381'
91 RPL_REHASHING = '382'
92@@ -2338,37 +2441,6 @@
93 RPL_USERS = '393'
94 RPL_ENDOFUSERS = '394'
95 RPL_NOUSERS = '395'
96-RPL_TRACELINK = '200'
97-RPL_TRACECONNECTING = '201'
98-RPL_TRACEHANDSHAKE = '202'
99-RPL_TRACEUNKNOWN = '203'
100-RPL_TRACEOPERATOR = '204'
101-RPL_TRACEUSER = '205'
102-RPL_TRACESERVER = '206'
103-RPL_TRACESERVICE = '207'
104-RPL_TRACENEWTYPE = '208'
105-RPL_TRACECLASS = '209'
106-RPL_TRACERECONNECT = '210'
107-RPL_TRACELOG = '261'
108-RPL_TRACEEND = '262'
109-RPL_STATSLINKINFO = '211'
110-RPL_STATSCOMMANDS = '212'
111-RPL_ENDOFSTATS = '219'
112-RPL_STATSUPTIME = '242'
113-RPL_STATSOLINE = '243'
114-RPL_UMODEIS = '221'
115-RPL_SERVLIST = '234'
116-RPL_SERVLISTEND = '235'
117-RPL_LUSERCLIENT = '251'
118-RPL_LUSEROP = '252'
119-RPL_LUSERUNKNOWN = '253'
120-RPL_LUSERCHANNELS = '254'
121-RPL_LUSERME = '255'
122-RPL_ADMINME = '256'
123-RPL_ADMINLOC = '257'
124-RPL_ADMINLOC = '258'
125-RPL_ADMINEMAIL = '259'
126-RPL_TRYAGAIN = '263'
127 ERR_NOSUCHNICK = '401'
128 ERR_NOSUCHSERVER = '402'
129 ERR_NOSUCHCHANNEL = '403'
130@@ -2424,148 +2496,8 @@
131 ERR_UMODEUNKNOWNFLAG = '501'
132 ERR_USERSDONTMATCH = '502'
133 
134-# And hey, as long as the strings are already intern'd...
135-symbolic_to_numeric = {
136-    "RPL_WELCOME": '001',
137-    "RPL_YOURHOST": '002',
138-    "RPL_CREATED": '003',
139-    "RPL_MYINFO": '004',
140-    "RPL_BOUNCE": '005',
141-    "RPL_USERHOST": '302',
142-    "RPL_ISON": '303',
143-    "RPL_AWAY": '301',
144-    "RPL_UNAWAY": '305',
145-    "RPL_NOWAWAY": '306',
146-    "RPL_WHOISUSER": '311',
147-    "RPL_WHOISSERVER": '312',
148-    "RPL_WHOISOPERATOR": '313',
149-    "RPL_WHOISIDLE": '317',
150-    "RPL_ENDOFWHOIS": '318',
151-    "RPL_WHOISCHANNELS": '319',
152-    "RPL_WHOWASUSER": '314',
153-    "RPL_ENDOFWHOWAS": '369',
154-    "RPL_LISTSTART": '321',
155-    "RPL_LIST": '322',
156-    "RPL_LISTEND": '323',
157-    "RPL_UNIQOPIS": '325',
158-    "RPL_CHANNELMODEIS": '324',
159-    "RPL_NOTOPIC": '331',
160-    "RPL_TOPIC": '332',
161-    "RPL_INVITING": '341',
162-    "RPL_SUMMONING": '342',
163-    "RPL_INVITELIST": '346',
164-    "RPL_ENDOFINVITELIST": '347',
165-    "RPL_EXCEPTLIST": '348',
166-    "RPL_ENDOFEXCEPTLIST": '349',
167-    "RPL_VERSION": '351',
168-    "RPL_WHOREPLY": '352',
169-    "RPL_ENDOFWHO": '315',
170-    "RPL_NAMREPLY": '353',
171-    "RPL_ENDOFNAMES": '366',
172-    "RPL_LINKS": '364',
173-    "RPL_ENDOFLINKS": '365',
174-    "RPL_BANLIST": '367',
175-    "RPL_ENDOFBANLIST": '368',
176-    "RPL_INFO": '371',
177-    "RPL_ENDOFINFO": '374',
178-    "RPL_MOTDSTART": '375',
179-    "RPL_MOTD": '372',
180-    "RPL_ENDOFMOTD": '376',
181-    "RPL_YOUREOPER": '381',
182-    "RPL_REHASHING": '382',
183-    "RPL_YOURESERVICE": '383',
184-    "RPL_TIME": '391',
185-    "RPL_USERSSTART": '392',
186-    "RPL_USERS": '393',
187-    "RPL_ENDOFUSERS": '394',
188-    "RPL_NOUSERS": '395',
189-    "RPL_TRACELINK": '200',
190-    "RPL_TRACECONNECTING": '201',
191-    "RPL_TRACEHANDSHAKE": '202',
192-    "RPL_TRACEUNKNOWN": '203',
193-    "RPL_TRACEOPERATOR": '204',
194-    "RPL_TRACEUSER": '205',
195-    "RPL_TRACESERVER": '206',
196-    "RPL_TRACESERVICE": '207',
197-    "RPL_TRACENEWTYPE": '208',
198-    "RPL_TRACECLASS": '209',
199-    "RPL_TRACERECONNECT": '210',
200-    "RPL_TRACELOG": '261',
201-    "RPL_TRACEEND": '262',
202-    "RPL_STATSLINKINFO": '211',
203-    "RPL_STATSCOMMANDS": '212',
204-    "RPL_ENDOFSTATS": '219',
205-    "RPL_STATSUPTIME": '242',
206-    "RPL_STATSOLINE": '243',
207-    "RPL_UMODEIS": '221',
208-    "RPL_SERVLIST": '234',
209-    "RPL_SERVLISTEND": '235',
210-    "RPL_LUSERCLIENT": '251',
211-    "RPL_LUSEROP": '252',
212-    "RPL_LUSERUNKNOWN": '253',
213-    "RPL_LUSERCHANNELS": '254',
214-    "RPL_LUSERME": '255',
215-    "RPL_ADMINME": '256',
216-    "RPL_ADMINLOC": '257',
217-    "RPL_ADMINLOC": '258',
218-    "RPL_ADMINEMAIL": '259',
219-    "RPL_TRYAGAIN": '263',
220-    "ERR_NOSUCHNICK": '401',
221-    "ERR_NOSUCHSERVER": '402',
222-    "ERR_NOSUCHCHANNEL": '403',
223-    "ERR_CANNOTSENDTOCHAN": '404',
224-    "ERR_TOOMANYCHANNELS": '405',
225-    "ERR_WASNOSUCHNICK": '406',
226-    "ERR_TOOMANYTARGETS": '407',
227-    "ERR_NOSUCHSERVICE": '408',
228-    "ERR_NOORIGIN": '409',
229-    "ERR_NORECIPIENT": '411',
230-    "ERR_NOTEXTTOSEND": '412',
231-    "ERR_NOTOPLEVEL": '413',
232-    "ERR_WILDTOPLEVEL": '414',
233-    "ERR_BADMASK": '415',
234-    "ERR_UNKNOWNCOMMAND": '421',
235-    "ERR_NOMOTD": '422',
236-    "ERR_NOADMININFO": '423',
237-    "ERR_FILEERROR": '424',
238-    "ERR_NONICKNAMEGIVEN": '431',
239-    "ERR_ERRONEUSNICKNAME": '432',
240-    "ERR_NICKNAMEINUSE": '433',
241-    "ERR_NICKCOLLISION": '436',
242-    "ERR_UNAVAILRESOURCE": '437',
243-    "ERR_USERNOTINCHANNEL": '441',
244-    "ERR_NOTONCHANNEL": '442',
245-    "ERR_USERONCHANNEL": '443',
246-    "ERR_NOLOGIN": '444',
247-    "ERR_SUMMONDISABLED": '445',
248-    "ERR_USERSDISABLED": '446',
249-    "ERR_NOTREGISTERED": '451',
250-    "ERR_NEEDMOREPARAMS": '461',
251-    "ERR_ALREADYREGISTRED": '462',
252-    "ERR_NOPERMFORHOST": '463',
253-    "ERR_PASSWDMISMATCH": '464',
254-    "ERR_YOUREBANNEDCREEP": '465',
255-    "ERR_YOUWILLBEBANNED": '466',
256-    "ERR_KEYSET": '467',
257-    "ERR_CHANNELISFULL": '471',
258-    "ERR_UNKNOWNMODE": '472',
259-    "ERR_INVITEONLYCHAN": '473',
260-    "ERR_BANNEDFROMCHAN": '474',
261-    "ERR_BADCHANNELKEY": '475',
262-    "ERR_BADCHANMASK": '476',
263-    "ERR_NOCHANMODES": '477',
264-    "ERR_BANLISTFULL": '478',
265-    "ERR_NOPRIVILEGES": '481',
266-    "ERR_CHANOPRIVSNEEDED": '482',
267-    "ERR_CANTKILLSERVER": '483',
268-    "ERR_RESTRICTED": '484',
269-    "ERR_UNIQOPPRIVSNEEDED": '485',
270-    "ERR_NOOPERHOST": '491',
271-    "ERR_NOSERVICEHOST": '492',
272-    "ERR_UMODEUNKNOWNFLAG": '501',
273-    "ERR_USERSDONTMATCH": '502',
274-}
275-
276-numeric_to_symbolic = {}
277-for k, v in symbolic_to_numeric.items():
278-    numeric_to_symbolic[v] = k
279+symbolic_to_numeric = dict((key, value) for
280+                           key, value in globals().iteritems()
281+                           if key.startswith('RPL_') or key.startswith('ERR_'))
282+numeric_to_symbolic = dict((value, key) for
283+                           key, value in symbolic_to_numeric.iteritems())