bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp != RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
10,600
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog != self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
10,601
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers != self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
10,602
def session(self): call, host_port = self.sock.recvfrom(8192) reply = self.handle(call) if reply <> None: self.sock.sendto(reply, host_port)
def session(self): call, host_port = self.sock.recvfrom(8192) reply = self.handle(call) if reply != None: self.sock.sendto(reply, host_port)
10,603
def _calcbounds(self): # calculate absolute bounds relative to the window origin from our # abstract _possize attribute, which is either a 4-tuple or a callable object oldbounds = self._bounds pl, pt, pr, pb = self._parent._bounds if callable(self._possize): # _possize is callable, let it figure it out by itself: it should return # the bounds relative to our parent widget. width = pr - pl height = pb - pt self._bounds = Qd.OffsetRect(self._possize(width, height), pl, pt) else: # _possize must be a 4-tuple. This is where the algorithm by Peter Kriens and # Petr van Blokland kicks in. (*** Parts of this algorithm are applied for # patents by Ericsson, Sweden ***) l, t, r, b = self._possize # depending on the values of l(eft), t(op), r(right) and b(ottom), # they mean different things: if l < -1: # l is less than -1, this mean it measures from the *right* of it's parent l = pr + l else: # l is -1 or greater, this mean it measures from the *left* of it's parent l = pl + l if t < -1: # t is less than -1, this mean it measures from the *bottom* of it's parent t = pb + t else: # t is -1 or greater, this mean it measures from the *top* of it's parent t = pt + t if r > 1: # r is greater than 1, this means r is the *width* of the widget r = l + r else: # r is less than 1, this means it measures from the *right* of it's parent r = pr + r if b > 1: # b is greater than 1, this means b is the *height* of the widget b = t + b else: # b is less than 1, this means it measures from the *bottom* of it's parent b = pb + b self._bounds = (l, t, r, b) if oldbounds and oldbounds <> self._bounds: self.adjust(oldbounds) for w in self._widgets: w._calcbounds()
def _calcbounds(self): # calculate absolute bounds relative to the window origin from our # abstract _possize attribute, which is either a 4-tuple or a callable object oldbounds = self._bounds pl, pt, pr, pb = self._parent._bounds if callable(self._possize): # _possize is callable, let it figure it out by itself: it should return # the bounds relative to our parent widget. width = pr - pl height = pb - pt self._bounds = Qd.OffsetRect(_intRect(self._possize(width, height)), pl, pt) else: # _possize must be a 4-tuple. This is where the algorithm by Peter Kriens and # Petr van Blokland kicks in. (*** Parts of this algorithm are applied for # patents by Ericsson, Sweden ***) l, t, r, b = self._possize # depending on the values of l(eft), t(op), r(right) and b(ottom), # they mean different things: if l < -1: # l is less than -1, this mean it measures from the *right* of it's parent l = pr + l else: # l is -1 or greater, this mean it measures from the *left* of it's parent l = pl + l if t < -1: # t is less than -1, this mean it measures from the *bottom* of it's parent t = pb + t else: # t is -1 or greater, this mean it measures from the *top* of it's parent t = pt + t if r > 1: # r is greater than 1, this means r is the *width* of the widget r = l + r else: # r is less than 1, this means it measures from the *right* of it's parent r = pr + r if b > 1: # b is greater than 1, this means b is the *height* of the widget b = t + b else: # b is less than 1, this means it measures from the *bottom* of it's parent b = pb + b self._bounds = (l, t, r, b) if oldbounds and oldbounds <> self._bounds: self.adjust(oldbounds) for w in self._widgets: w._calcbounds()
10,604
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i+1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(rect) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i+1] = newpos, self._panesizes[i+1][1] self.makepanebounds() self.installbounds() self._calcbounds()
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i+1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(_intRect(rect)) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i+1] = newpos, self._panesizes[i+1][1] self.makepanebounds() self.installbounds() self._calcbounds()
10,605
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i+1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(rect) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i+1] = newpos, self._panesizes[i+1][1] self.makepanebounds() self.installbounds() self._calcbounds()
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i+1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(_intRect(rect)) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i+1] = newpos, self._panesizes[i+1][1] self.makepanebounds() self.installbounds() self._calcbounds()
10,606
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i+1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(rect) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i+1] = newpos, self._panesizes[i+1][1] self.makepanebounds() self.installbounds() self._calcbounds()
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i+1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(_intRect(rect)) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i+1] = newpos, self._panesizes[i+1][1] self.makepanebounds() self.installbounds() self._calcbounds()
10,607
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i+1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(rect) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(rect) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i+1] = newpos, self._panesizes[i+1][1] self.makepanebounds() self.installbounds() self._calcbounds()
def click(self, point, modifiers): # what a mess... orgmouse = point[self._direction] halfgutter = self._gutter / 2 l, t, r, b = self._bounds if self._direction: begin, end = t, b else: begin, end = l, r i = self.findgutter(orgmouse, begin, end) if i is None: return pos = orgpos = begin + (end - begin) * self._gutters[i] # init pos too, for fast click on border, bug done by Petr minpos = self._panesizes[i][0] maxpos = self._panesizes[i+1][1] minpos = begin + (end - begin) * minpos + 64 maxpos = begin + (end - begin) * maxpos - 64 if minpos > orgpos and maxpos < orgpos: return #SetCursor("fist") self.SetPort() if self._direction: rect = l, orgpos - 1, r, orgpos else: rect = orgpos - 1, t, orgpos, b # track mouse --- XXX move to separate method? Qd.PenMode(QuickDraw.srcXor) Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = None while Evt.Button(): pos = orgpos - orgmouse + Evt.GetMouse()[self._direction] pos = max(pos, minpos) pos = min(pos, maxpos) if pos == lastpos: continue Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) if self._direction: rect = l, pos - 1, r, pos else: rect = pos - 1, t, pos, b Qd.PenPat(Qd.GetQDGlobalsGray()) Qd.PaintRect(_intRect(rect)) lastpos = pos self._parentwindow.wid.GetWindowPort().QDFlushPortBuffer(None) Evt.WaitNextEvent(0, 3) Qd.PaintRect(_intRect(rect)) Qd.PenNormal() SetCursor("watch") newpos = (pos - begin) / float(end - begin) self._gutters[i] = newpos self._panesizes[i] = self._panesizes[i][0], newpos self._panesizes[i+1] = newpos, self._panesizes[i+1][1] self.makepanebounds() self.installbounds() self._calcbounds()
10,608
def initpatterns(self): Scanner.initpatterns(self) self.head_pat = "^EXTERN_API(_C)?" self.type_pat = "EXTERN_API(_C)?" + \ "[ \t\n]*\([ \t\n]*" + \ "(?P<type>[a-zA-Z0-9_* \t]*[a-zA-Z0-9_*])" + \ "[ \t\n]*\)[ \t\n]*" self.whole_pat = self.type_pat + self.name_pat + self.args_pat self.sym_pat = "^[ \t]*(?P<name>[a-zA-Z0-9_]+)[ \t]*=" + \ "[ \t]*(?P<defn>[-0-9_a-zA-Z'\"\(][^\t\n,;}]*),?"
def _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s initpatterns(self): _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s Scanner.initpatterns(self) _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s self.head_pat _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s = _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s "^EXTERN_API(_C)?" _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s self.type_pat _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s = _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s "EXTERN_API(_C)?" _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s + _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s "[ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \t\n]*\([ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \t\n]*" _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s + _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s "(?P<type>[a-zA-Z0-9_* _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \t]*[a-zA-Z0-9_*])" _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s + _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s "[ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \t\n]*\)[ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \t\n]*" _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s self.whole_pat _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s = _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s self.type_pat _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s + _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s self.name_pat _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s + _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s self.args_pat _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s self.sym_pat _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s = _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s "^[ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \t]*(?P<name>[a-zA-Z0-9_]+)[ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \t]*=" _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s + _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s "[ _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s \t]*(?P<defn>[-0-9_a-zA-Z'\"\(][^\t\n,;}]*),?" _8bit = re.compile(r"[\200-\377]") def escape8bit(s): if _8bit.search(s) is not None: out = [] for c in s: o = ord(c) if o >= 128: out.append("\\" + hex(o)[1:]) else: out.append(c) s = "".join(out) return s
10,609
def open_file(self, _object=None, **args): for alias in _object: fss = alias.Resolve()[0] pathname = fss.as_pathname() sys.argv.append(pathname) self._quit()
def open_file(self, _object=None, **args): for alias in _object: fsr = alias.FSResolveAlias(None)[0] pathname = fsr.as_pathname() sys.argv.append(pathname) self._quit()
10,610
def has_section(self, section): """Indicate whether the named section is present in the configuration.
def has_section(self, section): """Indicate whether the named section is present in the configuration.
10,611
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
10,612
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
10,613
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
10,614
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
10,615
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
10,616
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
10,617
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
10,618
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
10,619
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
def getboolean(self, section, option): v = self.get(section, option) if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
10,620
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if v.lower() not in self._boolean_states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
10,621
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
def getboolean(self, section, option): states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not v.lower() in states: raise ValueError, 'Not a boolean: %s' % v return states[v.lower()]
10,622
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) return option in self.__sections[section]
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == DEFAULTSECT: option = self.optionxform(option) return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) return option in self.__sections[section]
10,623
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) return option in self.__sections[section]
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": return option in self.__defaults elif section not in self.__sections: return 0 else: option = self.optionxform(option) return option in self.__sections[section]
10,624
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) return option in self.__sections[section]
def has_option(self, section, option): """Check for the existence of a given option in a given section.""" if not section or section == "DEFAULT": return option in self.__defaults elif not self.has_section(section): return 0 else: option = self.optionxform(option) return option in self.__sections[section]
10,625
def set(self, section, option, value): """Set an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) sectdict[option] = value
def set(self, section, option, value): """Set an option.""" if not section or section == DEFAULTSECT: sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) sectdict[option] = value
10,626
def set(self, section, option, value): """Set an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) sectdict[option] = value
def set(self, section, option, value): """Set an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) sectdict[option] = value
10,627
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n")
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[%s]\n" % DEFAULTSECT) for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n")
10,628
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sections[section] for (key, value) in sectdict.items(): if key == "__name__": continue fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n")
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n") for section in self.__sections: fp.write("[%s]\n" % section) for (key, value) in self.__sections[section].items(): if key != "__name__": fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t'))) fp.write("\n")
10,629
def remove_option(self, section, option): """Remove an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) existed = option in sectdict if existed: del sectdict[option] return existed
def remove_option(self, section, option): """Remove an option.""" if not section or section == DEFAULTSECT: sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) option = self.optionxform(option) existed = option in sectdict if existed: del sectdict[option] return existed
10,630
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
def remove_section(self, section): """Remove a file section.""" existed = section in self.__sections if existed: del self.__sections[section] return True else: return False
10,631
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
10,632
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
10,633
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
def remove_section(self, section): """Remove a file section.""" if section in self.__sections: del self.__sections[section] return True else: return False
10,634
def __read(self, fp, fpname): """Parse a sectioned setup file.
def __read(self, fp, fpname): """Parse a sectioned setup file.
10,635
def __read(self, fp, fpname): """Parse a sectioned setup file.
def __read(self, fp, fpname): """Parse a sectioned setup file.
10,636
def __read(self, fp, fpname): """Parse a sectioned setup file.
def __read(self, fp, fpname): """Parse a sectioned setup file.
10,637
def __read(self, fp, fpname): """Parse a sectioned setup file.
def __read(self, fp, fpname): """Parse a sectioned setup file.
10,638
def __read(self, fp, fpname): """Parse a sectioned setup file.
def __read(self, fp, fpname): """Parse a sectioned setup file.
10,639
def test_open_existing_hash(self): "verify we can open a file known to be a hash v2 file" db = bsddb185.hashopen(findfile("185test.db")) self.assertEqual(db["1"], "1") db.close()
def test_open_existing_hash(self): db = bsddb185.hashopen(findfile("185test.db")) self.assertEqual(db["1"], "1") db.close()
10,640
def test_whichdb(self): "verify that whichdb correctly sniffs the known hash v2 file" self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185")
def test_whichdb(self): self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185")
10,641
def test_anydbm_create(self): "verify that anydbm.open does *not* create a bsddb185 file" tmpdir = tempfile.mkdtemp() try: try: dbfile = os.path.join(tmpdir, "foo.db") anydbm.open(dbfile, "c").close() ftype = whichdb.whichdb(findfile("foo.db")) self.assertNotEqual(ftype, "bsddb185") finally: os.unlink(dbfile) finally: os.rmdir(tmpdir)
def test_anydbm_create(self): tmpdir = tempfile.mkdtemp() try: try: dbfile = os.path.join(tmpdir, "foo.db") anydbm.open(dbfile, "c").close() ftype = whichdb.whichdb(findfile("foo.db")) self.assertNotEqual(ftype, "bsddb185") finally: os.unlink(dbfile) finally: os.rmdir(tmpdir)
10,642
def test_anydbm_create(self): "verify that anydbm.open does *not* create a bsddb185 file" tmpdir = tempfile.mkdtemp() try: try: dbfile = os.path.join(tmpdir, "foo.db") anydbm.open(dbfile, "c").close() ftype = whichdb.whichdb(findfile("foo.db")) self.assertNotEqual(ftype, "bsddb185") finally: os.unlink(dbfile) finally: os.rmdir(tmpdir)
def test_anydbm_create(self): "verify that anydbm.open does *not* create a bsddb185 file" tmpdir = tempfile.mkdtemp() try: try: dbfile = os.path.join(tmpdir, "foo.db") anydbm.open(os.path.splitext(dbfile)[0], "c").close() ftype = whichdb.whichdb(dbfile) self.assertNotEqual(ftype, "bsddb185") finally: os.unlink(dbfile) finally: os.rmdir(tmpdir)
10,643
def execvpe(file, args, env): """execv(file, args, env) Execute the executable file (which is searched for along $PATH) with argument list args and environment env , replacing the current process. args may be a list or tuple of strings. """ _execvpe(file, args, env)
def execvpe(file, args, env): """execvpe(file, args, env) Execute the executable file (which is searched for along $PATH) with argument list args and environment env , replacing the current process. args may be a list or tuple of strings. """ _execvpe(file, args, env)
10,644
def _execvpe(file, args, env=None): from errno import ENOENT, ENOTDIR if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, (errno, msg): if errno != ENOENT and errno != ENOTDIR: raise raise error, (errno, msg)
def _execvpe(file, args, env=None): from errno import ENOENT, ENOTDIR if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) for dir in PATH: fullname = path.join(dir, file) try: apply(func, (fullname,) + argrest) except error, e: tb = sys.exc_info()[2] if (e.errno != ENOENT and e.errno != ENOTDIR and saved_exc is None): saved_exc = e saved_tb = tb if saved_exc: raise error, saved_exc, saved_tb raise error, e, tb
10,645
def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): return eval("self.%s" % attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): return getattr(self, attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
10,646
def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): return eval("self.%s" % attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
def __getattr__(self, attr): # Allow UPPERCASE variants of IMAP4 command methods. if Commands.has_key(attr): return eval("self.%s" % attr.lower()) raise AttributeError("Unknown IMAP4 command: '%s'" % attr)
10,647
def open(self, host, port): """Setup 'self.sock' and 'self.file'.""" self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) self.file = self.sock.makefile('r')
def open(self, host, port): """Setup connection to remote server on "host:port". This connection will be used by the routines: read, readline, send, shutdown. """ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) self.file = self.sock.makefile('r')
10,648
def response(self, code): """Return data for response 'code' if received, or None.
def response(self, code): """Return data for response 'code' if received, or None.
10,649
def logout(self): """Shutdown connection to server.
def logout(self): """Shutdown connection to server.
10,650
def search(self, charset, *criteria): """Search mailbox for matching messages.
def search(self, charset, *criteria): """Search mailbox for matching messages.
10,651
def status(self, mailbox, names): """Request named status conditions for mailbox.
def status(self, mailbox, names): """Request named status conditions for mailbox.
10,652
def uid(self, command, *args): """Execute "command arg ..." with messages identified by UID, rather than message number.
def uid(self, command, *args): """Execute "command arg ..." with messages identified by UID, rather than message number.
10,653
def xatom(self, name, *args): """Allow simple extension commands notified by server in CAPABILITY response.
def xatom(self, name, *args): """Allow simple extension commands notified by server in CAPABILITY response.
10,654
def namespace(self): """ Returns IMAP namespaces ala rfc2342 """ name = 'NAMESPACE' typ, dat = self._simple_command(name) return self._untagged_response(typ, dat, name)
def namespace(self): """ Returns IMAP namespaces ala rfc2342 """ name = 'NAMESPACE' typ, dat = self._simple_command(name) return self._untagged_response(typ, dat, name)
10,655
def _command(self, name, *args):
def _command(self, name, *args):
10,656
def _command(self, name, *args):
def _command(self, name, *args):
10,657
def _get_response(self):
def _get_response(self):
10,658
def _get_line(self):
def _get_line(self):
10,659
def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs)
def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs)
10,660
def run(cmd, args): _mesg('%s %s' % (cmd, args)) typ, dat = apply(eval('M.%s' % cmd), args) _mesg('%s => %s %s' % (cmd, typ, dat)) return dat
def run(cmd, args): _mesg('%s %s' % (cmd, args)) typ, dat = apply(getattr(M, cmd), args) _mesg('%s => %s %s' % (cmd, typ, dat)) return dat
10,661
def show_compilers (): from distutils.ccompiler import show_compilers show_compilers()
def show_compilers (): from distutils.ccompiler import show_compilers show_compilers()
10,662
def check_extensions_list (self, extensions): """Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension instances here.
def check_extensions_list (self, extensions): """Ensure that the list of extensions (presumably provided as a command option 'extensions') is valid, i.e. it is a list of Extension objects. We also support the old-style list of 2-tuples, where the tuples are (ext_name, build_info), which are converted to Extension instances here.
10,663
def build_extensions (self):
def build_extensions (self):
10,664
def build_extensions (self):
def build_extensions (self):
10,665
def find_swig (self): """Return the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows. """
def find_swig (self): """Return the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows. """
10,666
def _lock_file(f, dotlock=True): """Lock file f using lockf, flock, and dot locking.""" dotlock_done = False try: if fcntl: try: fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EAGAIN: raise ExternalClashError('lockf: lock unavailable: %s' % f.name) else: raise try: fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EWOULDBLOCK: raise ExternalClashError('flock: lock unavailable: %s' % f.name) else: raise if dotlock: try: pre_lock = _create_temporary(f.name + '.lock') pre_lock.close() except IOError, e: if e.errno == errno.EACCES: return # Without write access, just skip dotlocking. else: raise try: if hasattr(os, 'link'): os.link(pre_lock.name, f.name + '.lock') dotlock_done = True os.unlink(pre_lock.name) else: os.rename(pre_lock.name, f.name + '.lock') dotlock_done = True except OSError, e: if e.errno == errno.EEXIST: os.remove(pre_lock.name) raise ExternalClashError('dot lock unavailable: %s' % f.name) else: raise except: if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) fcntl.flock(f, fcntl.LOCK_UN) if dotlock_done: os.remove(f.name + '.lock') raise
def _lock_file(f, dotlock=True): """Lock file f using lockf and dot locking.""" dotlock_done = False try: if fcntl: try: fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EAGAIN: raise ExternalClashError('lockf: lock unavailable: %s' % f.name) else: raise try: fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EWOULDBLOCK: raise ExternalClashError('flock: lock unavailable: %s' % f.name) else: raise if dotlock: try: pre_lock = _create_temporary(f.name + '.lock') pre_lock.close() except IOError, e: if e.errno == errno.EACCES: return # Without write access, just skip dotlocking. else: raise try: if hasattr(os, 'link'): os.link(pre_lock.name, f.name + '.lock') dotlock_done = True os.unlink(pre_lock.name) else: os.rename(pre_lock.name, f.name + '.lock') dotlock_done = True except OSError, e: if e.errno == errno.EEXIST: os.remove(pre_lock.name) raise ExternalClashError('dot lock unavailable: %s' % f.name) else: raise except: if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) fcntl.flock(f, fcntl.LOCK_UN) if dotlock_done: os.remove(f.name + '.lock') raise
10,667
def _lock_file(f, dotlock=True): """Lock file f using lockf, flock, and dot locking.""" dotlock_done = False try: if fcntl: try: fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EAGAIN: raise ExternalClashError('lockf: lock unavailable: %s' % f.name) else: raise try: fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EWOULDBLOCK: raise ExternalClashError('flock: lock unavailable: %s' % f.name) else: raise if dotlock: try: pre_lock = _create_temporary(f.name + '.lock') pre_lock.close() except IOError, e: if e.errno == errno.EACCES: return # Without write access, just skip dotlocking. else: raise try: if hasattr(os, 'link'): os.link(pre_lock.name, f.name + '.lock') dotlock_done = True os.unlink(pre_lock.name) else: os.rename(pre_lock.name, f.name + '.lock') dotlock_done = True except OSError, e: if e.errno == errno.EEXIST: os.remove(pre_lock.name) raise ExternalClashError('dot lock unavailable: %s' % f.name) else: raise except: if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) fcntl.flock(f, fcntl.LOCK_UN) if dotlock_done: os.remove(f.name + '.lock') raise
def _lock_file(f, dotlock=True): """Lock file f using lockf, flock, and dot locking.""" dotlock_done = False try: if fcntl: try: fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EAGAIN: raise ExternalClashError('lockf: lock unavailable: %s' % f.name) else: raise if dotlock: try: pre_lock = _create_temporary(f.name + '.lock') pre_lock.close() except IOError, e: if e.errno == errno.EACCES: return # Without write access, just skip dotlocking. else: raise try: if hasattr(os, 'link'): os.link(pre_lock.name, f.name + '.lock') dotlock_done = True os.unlink(pre_lock.name) else: os.rename(pre_lock.name, f.name + '.lock') dotlock_done = True except OSError, e: if e.errno == errno.EEXIST: os.remove(pre_lock.name) raise ExternalClashError('dot lock unavailable: %s' % f.name) else: raise except: if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) fcntl.flock(f, fcntl.LOCK_UN) if dotlock_done: os.remove(f.name + '.lock') raise
10,668
def _lock_file(f, dotlock=True): """Lock file f using lockf, flock, and dot locking.""" dotlock_done = False try: if fcntl: try: fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EAGAIN: raise ExternalClashError('lockf: lock unavailable: %s' % f.name) else: raise try: fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EWOULDBLOCK: raise ExternalClashError('flock: lock unavailable: %s' % f.name) else: raise if dotlock: try: pre_lock = _create_temporary(f.name + '.lock') pre_lock.close() except IOError, e: if e.errno == errno.EACCES: return # Without write access, just skip dotlocking. else: raise try: if hasattr(os, 'link'): os.link(pre_lock.name, f.name + '.lock') dotlock_done = True os.unlink(pre_lock.name) else: os.rename(pre_lock.name, f.name + '.lock') dotlock_done = True except OSError, e: if e.errno == errno.EEXIST: os.remove(pre_lock.name) raise ExternalClashError('dot lock unavailable: %s' % f.name) else: raise except: if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) fcntl.flock(f, fcntl.LOCK_UN) if dotlock_done: os.remove(f.name + '.lock') raise
def _lock_file(f, dotlock=True): """Lock file f using lockf, flock, and dot locking.""" dotlock_done = False try: if fcntl: try: fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EAGAIN: raise ExternalClashError('lockf: lock unavailable: %s' % f.name) else: raise try: fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError, e: if e.errno == errno.EWOULDBLOCK: raise ExternalClashError('flock: lock unavailable: %s' % f.name) else: raise if dotlock: try: pre_lock = _create_temporary(f.name + '.lock') pre_lock.close() except IOError, e: if e.errno == errno.EACCES: return # Without write access, just skip dotlocking. else: raise try: if hasattr(os, 'link'): os.link(pre_lock.name, f.name + '.lock') dotlock_done = True os.unlink(pre_lock.name) else: os.rename(pre_lock.name, f.name + '.lock') dotlock_done = True except OSError, e: if e.errno == errno.EEXIST: os.remove(pre_lock.name) raise ExternalClashError('dot lock unavailable: %s' % f.name) else: raise except: if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) if dotlock_done: os.remove(f.name + '.lock') raise
10,669
def _unlock_file(f): """Unlock file f using lockf, flock, and dot locking.""" if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) fcntl.flock(f, fcntl.LOCK_UN) if os.path.exists(f.name + '.lock'): os.remove(f.name + '.lock')
def _unlock_file(f): """Unlock file f using lockf and dot locking.""" if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) fcntl.flock(f, fcntl.LOCK_UN) if os.path.exists(f.name + '.lock'): os.remove(f.name + '.lock')
10,670
def _unlock_file(f): """Unlock file f using lockf, flock, and dot locking.""" if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) fcntl.flock(f, fcntl.LOCK_UN) if os.path.exists(f.name + '.lock'): os.remove(f.name + '.lock')
def _unlock_file(f): """Unlock file f using lockf, flock, and dot locking.""" if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) if os.path.exists(f.name + '.lock'): os.remove(f.name + '.lock')
10,671
def winfo_children(self): """Return a list of all widgets which are children of this widget.""" return map(self._nametowidget, self.tk.splitlist(self.tk.call( 'winfo', 'children', self._w)))
def winfo_children(self): """Return a list of all widgets which are children of this widget.""" return map(self._nametowidget, self.tk.splitlist(self.tk.call( 'winfo', 'children', self._w)))
10,672
def open_http(self, url, data=None): import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'http': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization', 'Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, self.openedurl) else: return self.http_error(url, fp, errcode, errmsg, headers)
def open_http(self, url, data=None): import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'http': realhost, rest = splithost(rest) user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization', 'Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, self.openedurl) else: return self.http_error(url, fp, errcode, errmsg, headers)
10,673
def add_cookie_header(self, request): """Add correct Cookie: header to request (urllib2.Request object).
def add_cookie_header(self, request): """Add correct Cookie: header to request (urllib2.Request object).
10,674
def waitchild(options): pid, sts = os.wait(G.busy, options) if pid == G.busy: G.busy = 0 G.stop.enable(0)
def waitchild(options): pid, sts = os.waitpid(G.busy, options) if pid == G.busy: G.busy = 0 G.stop.enable(0)
10,675
def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.scrollbars() self.changed = 0 self.do_postopen() self.do_activate(1, None)
def open(self, path, name, data): self.path = path self.name = name r = windowbounds(400, 400) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.scrollbars() self.changed = 0 self.do_postopen() self.do_activate(1, None)
10,676
def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.scrollbars() self.changed = 0 self.do_postopen() self.do_activate(1, None)
def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w vr = 0, 0, r[2]-r[0]-15, r[3]-r[1]-15 dr = (0, 0, vr[2], 0) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.scrollbars() self.changed = 0 self.do_postopen() self.do_activate(1, None)
10,677
def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(r2, r2) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.scrollbars() self.changed = 0 self.do_postopen() self.do_activate(1, None)
def open(self, path, name, data): self.path = path self.name = name r = (40, 40, 400, 300) w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555) self.wid = w r2 = (0, 0, 345, 245) Qd.SetPort(w) Qd.TextFont(4) Qd.TextSize(9) self.ted = TE.TENew(dr, vr) self.ted.TEAutoView(1) self.ted.TESetText(data) w.DrawGrowIcon() self.scrollbars() self.changed = 0 self.do_postopen() self.do_activate(1, None)
10,678
def getscrollbarvalues(self): dr = self.ted.destRect vr = self.ted.viewRect height = self.ted.nLines * self.ted.lineHeight vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2]) vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3]) print dr, vr, height, vx, vy return vx, vy
def getscrollbarvalues(self): dr = self.ted.destRect vr = self.ted.viewRect height = self.ted.nLines * self.ted.lineHeight vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2]) vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3]) print dr, vr, height, vx, vy return None, vy
10,679
def scrollbar_callback(self, which, what, value): if which == 'y': if what == 'set': height = self.ted.nLines * self.ted.lineHeight cur = self.getscrollbarvalues()[1] delta = (cur-value)*height/32767 if what == '-': delta = self.ted.lineHeight elif what == '--': delta = (self.ted.viewRect[3]-self.ted.lineHeight) if delta <= 0: delta = self.ted.lineHeight elif what == '+': delta = -self.ted.lineHeight elif what == '++': delta = -(self.ted.viewRect[3]-self.ted.lineHeight) if delta >= 0: delta = -self.ted.lineHeight self.ted.TEPinScroll(0, delta) print 'SCROLL Y', delta else: if what == 'set': return # XXXX if what == '-': delta = self.ted.viewRect[2]/10 elif what == '--': delta = self.ted.viewRect[2]/2 elif what == '+': delta = +self.ted.viewRect[2]/10 elif what == '++': delta = +self.ted.viewRect[2]/2 self.ted.TEPinScroll(delta, 0)
def scrollbar_callback(self, which, what, value): if which == 'y': if what == 'set': height = self.ted.nLines * self.ted.lineHeight cur = self.getscrollbarvalues()[1] delta = (cur-value)*height/32767 if what == '-': delta = self.ted.lineHeight elif what == '--': delta = (self.ted.viewRect[3]-self.ted.lineHeight) if delta <= 0: delta = self.ted.lineHeight elif what == '+': delta = -self.ted.lineHeight elif what == '++': delta = -(self.ted.viewRect[3]-self.ted.lineHeight) if delta >= 0: delta = -self.ted.lineHeight self.ted.TEPinScroll(0, delta) print 'SCROLL Y', delta else: if what == 'set': return # XXXX if what == '-': delta = self.ted.viewRect[2]/10 elif what == '--': delta = self.ted.viewRect[2]/2 elif what == '+': delta = +self.ted.viewRect[2]/10 elif what == '++': delta = +self.ted.viewRect[2]/2 self.ted.TEPinScroll(delta, 0)
10,680
def idle(self, *args): for l in self._windows.values(): l.do_idle()
def idle(self, *args): for l in self._windows.values(): l.do_idle()
10,681
def spam(self): return 42
defspam(self):return42
10,682
def __new__(metaclass, name, bases, dict): # XXX Should check that name isn't already a base class name dict["__dynamic__"] = 1 cls = super(autosuper, metaclass).__new__(metaclass, name, bases, dict) # Name mangling for __super removes leading underscores while name[:1] == "_": name = name[1:] if name: name = "_%s__super" % name else: name = "__super" setattr(cls, name, super(cls)) return cls
def __new__(metaclass, name, bases, dict): # XXX Should check that name isn't already a base class nameassert dict.get("__dynamic__", 1) cls = super(autosuper, metaclass).__new__(metaclass, name, bases, dict) # Name mangling for __super removes leading underscores while name[:1] == "_": name = name[1:] if name: name = "_%s__super" % name else: name = "__super" setattr(cls, name, super(cls)) return cls
10,683
def mysetattr(self, name, value): if name == "spam": raise AttributeError return object.__setattr__(self, name, value)
def mysetattr(self, name, value): if name == "spam": raise AttributeError return object.__setattr__(self, name, value)
10,684
def mysetattr(self, name, value): if name == "spam": raise AttributeError return object.__setattr__(self, name, value)
def mysetattr(self, name, value): if name == "spam": raise AttributeError return object.__setattr__(self, name, value)
10,685
def mysetattr(self, name, value): if name == "spam": raise AttributeError return object.__setattr__(self, name, value)
def mysetattr(self, name, value): if name == "spam": raise AttributeError return object.__setattr__(self, name, value)
10,686
def __getitem__(self, i): if 0 <= i < 10: return i raise IndexError
def __getitem__(self, i): if 0 <= i < 10: return i raise IndexError
10,687
def __repr__(self): return "%.*g" % (self.prec, self)
def __repr__(self): return "%.*g" % (self.prec, self)
10,688
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
10,689
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
10,690
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
10,691
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
10,692
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
10,693
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
10,694
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
def __repr__(self): return "%.17gj%+.17g" % (self.imag, self.real)
10,695
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
10,696
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
10,697
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
10,698
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise NNTPTemporaryError(resp) if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp
10,699