annotate Demo/dns/dnsopcode.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents 78bf675df5e5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1964
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Opcode values in message header (section 4.1.1)
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 QUERY = 0
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 IQUERY = 1
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 STATUS = 2
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 # Construct reverse mapping dictionary
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 _names = dir()
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 opcodemap = {}
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 for _name in _names:
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 if _name[0] != '_': opcodemap[eval(_name)] = _name
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 def opcodestr(opcode):
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 if opcodemap.has_key(opcode): return opcodemap[opcode]
78bf675df5e5 initial checkin
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 else: return `opcode`