Update of /cvsroot/pydns/pydns/DNS
In directory usw-pr-cvs1:/tmp/cvs-serv32544
Modified Files:
Base.py Lib.py __init__.py
Log Message:
converted to class based exceptions (there goes the python1.4 compatibility :)
removed a quite gross use of 'eval()'.
Index: Base.py
===================================================================
RCS file: /cvsroot/pydns/pydns/DNS/Base.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Base.py 19 Mar 2002 12:41:33 -0000 1.10
--- Base.py 19 Mar 2002 13:05:02 -0000 1.11
***************
*** 12,18 ****
import socket
import string
! import Lib,Type,Class,Opcode
import asyncore
! from DNS import Error as DNSError
defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY,
--- 12,19 ----
import socket
import string
! import Type,Class,Opcode
import asyncore
!
! class DNSError(Exception): pass
defaults= { 'protocol':'udp', 'port':53, 'opcode':Opcode.QUERY,
***************
*** 92,96 ****
def processTCPReply(self):
! import time
self.f = self.s.makefile('r')
header = self.f.read(2)
--- 93,97 ----
def processTCPReply(self):
! import time, Lib
self.f = self.s.makefile('r')
header = self.f.read(2)
***************
*** 106,109 ****
--- 107,111 ----
def processReply(self):
+ import Lib
self.args['elapsed']=(self.time_finish-self.time_start)*1000
u = Lib.Munpacker(self.reply)
***************
*** 136,140 ****
def req(self,*name,**args):
" needs a refactoring "
! import time
self.argparse(name,args)
#if not self.args:
--- 138,142 ----
def req(self,*name,**args):
" needs a refactoring "
! import time, Lib
self.argparse(name,args)
#if not self.args:
***************
*** 147,152 ****
if type(self.args['qtype']) == type('foo'):
try:
! qtype = eval(string.upper(self.args['qtype']),Type.__dict__)
! except (NameError,SyntaxError):
raise DNSError,'unknown query type'
else:
--- 149,154 ----
if type(self.args['qtype']) == type('foo'):
try:
! qtype = getattr(Type, string.upper(self.args['qtype']))
! except AttributeError:
raise DNSError,'unknown query type'
else:
***************
*** 241,244 ****
--- 243,251 ----
#
# $Log$
+ # Revision 1.11 2002/03/19 13:05:02 anthonybaxter
+ # converted to class based exceptions (there goes the python1.4 compatibility :)
+ #
+ # removed a quite gross use of 'eval()'.
+ #
# Revision 1.10 2002/03/19 12:41:33 anthonybaxter
# tabnannied and reindented everything. 4 space indent, no tabs.
Index: Lib.py
===================================================================
RCS file: /cvsroot/pydns/pydns/DNS/Lib.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Lib.py 19 Mar 2002 12:41:33 -0000 1.10
--- Lib.py 19 Mar 2002 13:05:02 -0000 1.11
***************
*** 22,27 ****
# ------------------------------------------------------------------------
- UnpackError = 'DNS.Lib.UnpackError' # Exception
- PackError = 'DNS.Lib.PackError' # Exception
import string, types
--- 22,25 ----
***************
*** 32,35 ****
--- 30,37 ----
import Status
+ from Base import DNSError
+
+ class UnpackError(DNSError): pass
+ class PackError(DNSError): pass
# Low-level 16 and 32 bit integer packing and unpacking
***************
*** 630,633 ****
--- 632,640 ----
#
# $Log$
+ # Revision 1.11 2002/03/19 13:05:02 anthonybaxter
+ # converted to class based exceptions (there goes the python1.4 compatibility :)
+ #
+ # removed a quite gross use of 'eval()'.
+ #
# Revision 1.10 2002/03/19 12:41:33 anthonybaxter
# tabnannied and reindented everything. 4 space indent, no tabs.
Index: __init__.py
===================================================================
RCS file: /cvsroot/pydns/pydns/DNS/__init__.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** __init__.py 19 Mar 2002 12:41:33 -0000 1.5
--- __init__.py 19 Mar 2002 13:05:02 -0000 1.6
***************
*** 11,18 ****
__version__ = '0.0.1'
- Error='DNS API error'
import Type,Opcode,Status,Class
from Base import *
from Lib import *
from lazy import *
Request = DnsRequest
--- 11,20 ----
__version__ = '0.0.1'
import Type,Opcode,Status,Class
+ from Base import DnsRequest, DNSError
+ from Lib import DnsResult
from Base import *
from Lib import *
+ Error=DNSError
from lazy import *
Request = DnsRequest
***************
*** 21,24 ****
--- 23,31 ----
#
# $Log$
+ # Revision 1.6 2002/03/19 13:05:02 anthonybaxter
+ # converted to class based exceptions (there goes the python1.4 compatibility :)
+ #
+ # removed a quite gross use of 'eval()'.
+ #
# Revision 1.5 2002/03/19 12:41:33 anthonybaxter
# tabnannied and reindented everything. 4 space indent, no tabs.
|