rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
transform = element._as_immutable except AttributeError: pass else: element = transform() self._data[element] = True
self._data[element] = True except TypeError: transform = getattr(element, "_as_temporary_immutable", None) if transform is None: raise self._data[transform()] = True
def add(self, element): """Add an element to a set.
transform = element._as_temporarily_immutable except AttributeError: pass else: element = transform() del self._data[element]
del self._data[element] except TypeError: transform = getattr(element, "_as_temporary_immutable", None) if transform is None: raise del self._data[transform()]
def remove(self, element): """Remove an element from a set; it must be a member.
gp.pixmode(GL.PM_RTOL, 1)
gl.pixmode(GL.PM_RTOL, 1)
def showpartframe(self, data, chromdata, (x,y,w,h)): pmsize = self.bpp xpf, ypf = self.xpf, self.ypf if self.upside_down: gl.pixmode(GL.PM_TTOB, 1) if self.mirror_image: gp.pixmode(GL.PM_RTOL, 1) if self.format in ('jpeg', 'jpeggrey'): import jpeg data, width, height, bytes = jpeg.decompress(data) pmsize = bytes*8 elif...
Node.debug=open( "debug4.out", "w" )
Node.debug=StringIO()
def __init__( self ): self.childNodes=[] if Node._debug: index=repr( id( self ))+repr( self.__class__ ) Node.allnodes[index]=repr( self.__dict__ ) if Node.debug==None: Node.debug=open( "debug4.out", "w" ) Node.debug.write( "create %s\n"%index )
if type( attname_or_tuple ) == type( () ):
if type( attname_or_tuple ) == types.TupleType:
def __getitem__( self, attname_or_tuple ): if type( attname_or_tuple ) == type( () ): return self._attrsNS[attname_or_tuple] else: return self._attrs[attname_or_tuple]
def __setitem__( self, attname ): raise TypeError, "object does not support item assignment"
def __setitem__( self, attname, value ): if type( value ) == types.StringType: node=Attr( attname ) node.value=value else: assert isinstance( value, Attr ) or type( value )==types.StringType node=value old=self._attrs.get( attname, None) if old: old.unlink() self._attrs[node.name]=node self._attrsNS[(node.namespaceURI,...
def __setitem__( self, attname ): raise TypeError, "object does not support item assignment"
self.assertEqual(0x7fffffff, 2147483647)
if platform_long_is_32_bits: self.assertEqual(0x7fffffff, 2147483647) else: self.assertEqual(0x7fffffffffffffff, 9223372036854775807)
def test_hex_baseline(self): # Baseline tests self.assertEqual(0x0, 0) self.assertEqual(0x10, 16) self.assertEqual(0x7fffffff, 2147483647) # Ditto with a minus sign and parentheses self.assertEqual(-(0x0), 0) self.assertEqual(-(0x10), -16) self.assertEqual(-(0x7fffffff), -2147483647) # Ditto with a minus sign and NO pa...
self.assertEqual(-(0x7fffffff), -2147483647)
if platform_long_is_32_bits: self.assertEqual(-(0x7fffffff), -2147483647) else: self.assertEqual(-(0x7fffffffffffffff), -9223372036854775807)
def test_hex_baseline(self): # Baseline tests self.assertEqual(0x0, 0) self.assertEqual(0x10, 16) self.assertEqual(0x7fffffff, 2147483647) # Ditto with a minus sign and parentheses self.assertEqual(-(0x0), 0) self.assertEqual(-(0x10), -16) self.assertEqual(-(0x7fffffff), -2147483647) # Ditto with a minus sign and NO pa...
self.assertEqual(-0x7fffffff, -2147483647)
if platform_long_is_32_bits: self.assertEqual(-0x7fffffff, -2147483647) else: self.assertEqual(-0x7fffffffffffffff, -9223372036854775807)
def test_hex_baseline(self): # Baseline tests self.assertEqual(0x0, 0) self.assertEqual(0x10, 16) self.assertEqual(0x7fffffff, 2147483647) # Ditto with a minus sign and parentheses self.assertEqual(-(0x0), 0) self.assertEqual(-(0x10), -16) self.assertEqual(-(0x7fffffff), -2147483647) # Ditto with a minus sign and NO pa...
self.assertEqual(0x80000000, -2147483648L) self.assertEqual(0xffffffff, -1) self.assertEqual(-(0x80000000), 2147483648L) self.assertEqual(-(0xffffffff), 1) self.assertEqual(-0x80000000, 2147483648L) self.assertEqual(-0xffffffff, 1)
if platform_long_is_32_bits: self.assertEqual(0x80000000, -2147483648L) self.assertEqual(0xffffffff, -1) self.assertEqual(-(0x80000000), 2147483648L) self.assertEqual(-(0xffffffff), 1) self.assertEqual(-0x80000000, 2147483648L) self.assertEqual(-0xffffffff, 1) else: self.assertEqual(0x8000000000000000, -9223372036...
def test_hex_unsigned(self): # This test is in a <string> so we can ignore the warnings exec """if 1: # Positive-looking constants with negavive values self.assertEqual(0x80000000, -2147483648L) self.assertEqual(0xffffffff, -1) # Ditto with a minus sign and parentheses self.assertEqual(-(0x80000000), 2147483648L) self....
self.assertEqual(017777777777, 2147483647)
if platform_long_is_32_bits: self.assertEqual(017777777777, 2147483647) else: self.assertEqual(0777777777777777777777, 9223372036854775807)
def test_oct_baseline(self): # Baseline tests self.assertEqual(00, 0) self.assertEqual(020, 16) self.assertEqual(017777777777, 2147483647) # Ditto with a minus sign and parentheses self.assertEqual(-(00), 0) self.assertEqual(-(020), -16) self.assertEqual(-(017777777777), -2147483647) # Ditto with a minus sign and NO pa...
self.assertEqual(-(017777777777), -2147483647)
if platform_long_is_32_bits: self.assertEqual(-(017777777777), -2147483647) else: self.assertEqual(-(0777777777777777777777), -9223372036854775807)
def test_oct_baseline(self): # Baseline tests self.assertEqual(00, 0) self.assertEqual(020, 16) self.assertEqual(017777777777, 2147483647) # Ditto with a minus sign and parentheses self.assertEqual(-(00), 0) self.assertEqual(-(020), -16) self.assertEqual(-(017777777777), -2147483647) # Ditto with a minus sign and NO pa...
self.assertEqual(-017777777777, -2147483647)
if platform_long_is_32_bits: self.assertEqual(-017777777777, -2147483647) else: self.assertEqual(-0777777777777777777777, -9223372036854775807)
def test_oct_baseline(self): # Baseline tests self.assertEqual(00, 0) self.assertEqual(020, 16) self.assertEqual(017777777777, 2147483647) # Ditto with a minus sign and parentheses self.assertEqual(-(00), 0) self.assertEqual(-(020), -16) self.assertEqual(-(017777777777), -2147483647) # Ditto with a minus sign and NO pa...
self.assertEqual(020000000000, -2147483648L) self.assertEqual(037777777777, -1) self.assertEqual(-(020000000000), 2147483648L) self.assertEqual(-(037777777777), 1) self.assertEqual(-020000000000, 2147483648L) self.assertEqual(-037777777777, 1)
if platform_long_is_32_bits: self.assertEqual(020000000000, -2147483648L) self.assertEqual(037777777777, -1) self.assertEqual(-(020000000000), 2147483648L) self.assertEqual(-(037777777777), 1) self.assertEqual(-020000000000, 2147483648L) self.assertEqual(-037777777777, 1) else: self.assertEqual(0100000000000000000...
def test_oct_unsigned(self): # This test is in a <string> so we can ignore the warnings exec """if 1: # Positive-looking constants with negavive values self.assertEqual(020000000000, -2147483648L) self.assertEqual(037777777777, -1) # Ditto with a minus sign and parentheses self.assertEqual(-(020000000000), 2147483648L)...
def randrange(n): """Return a random shuffle of range(n)."""
def randfloats(n): """Return a list of n random floats in [0, 1)."""
def randrange(n): """Return a random shuffle of range(n).""" fn = os.path.join(td, "rr%06d" % n) try: fp = open(fn, "rb") except IOError: result = [] for i in range(n): result.append(random.random()) try: try: fp = open(fn, "wb") marshal.dump(result, fp) fp.close() fp = None finally: if fp: try: os.unlink(fn) except os...
result = [] for i in range(n): result.append(random.random())
r = random.random result = [r() for i in xrange(n)]
def randrange(n): """Return a random shuffle of range(n).""" fn = os.path.join(td, "rr%06d" % n) try: fp = open(fn, "rb") except IOError: result = [] for i in range(n): result.append(random.random()) try: try: fp = open(fn, "wb") marshal.dump(result, fp) fp.close() fp = None finally: if fp: try: os.unlink(fn) except os...
i = random.randrange(0, n)
i = random.randrange(n)
def randrange(n): """Return a random shuffle of range(n).""" fn = os.path.join(td, "rr%06d" % n) try: fp = open(fn, "rb") except IOError: result = [] for i in range(n): result.append(random.random()) try: try: fp = open(fn, "wb") marshal.dump(result, fp) fp.close() fp = None finally: if fp: try: os.unlink(fn) except os...
result[len(result):] = temp
result.extend(temp)
def randrange(n): """Return a random shuffle of range(n).""" fn = os.path.join(td, "rr%06d" % n) try: fp = open(fn, "rb") except IOError: result = [] for i in range(n): result.append(random.random()) try: try: fp = open(fn, "wb") marshal.dump(result, fp) fp.close() fp = None finally: if fp: try: os.unlink(fn) except os...
def fl():
def flush():
def fl(): sys.stdout.flush()
fl()
flush()
def doit(L): t0 = time.clock() L.sort() t1 = time.clock() print "%6.2f" % (t1-t0), fl()
-sort: all equal
=sort: all equal
def tabulate(r): """Tabulate sort speed for lists of various sizes. The sizes are 2**i for i in r (the argument, a list). The output displays i, 2**i, and the time to sort arrays of 2**i floating point numbers with the following properties: *sort: random data \sort: descending data /sort: ascending data ~sort: many ...
cases = ("*sort", "\\sort", "/sort", "~sort", "-sort", "!sort") fmt = ("%2s %6s" + " %6s"*len(cases))
cases = ("*sort", "\\sort", "/sort", "~sort", "=sort", "!sort") fmt = ("%2s %7s" + " %6s"*len(cases))
def tabulate(r): """Tabulate sort speed for lists of various sizes. The sizes are 2**i for i in r (the argument, a list). The output displays i, 2**i, and the time to sort arrays of 2**i floating point numbers with the following properties: *sort: random data \sort: descending data /sort: ascending data ~sort: many ...
n = 1<<i L = randrange(n) print "%2d %6d" % (i, n), fl()
n = 1 << i L = randfloats(n) print "%2d %7d" % (i, n), flush()
def tabulate(r): """Tabulate sort speed for lists of various sizes. The sizes are 2**i for i in r (the argument, a list). The output displays i, 2**i, and the time to sort arrays of 2**i floating point numbers with the following properties: *sort: random data \sort: descending data /sort: ascending data ~sort: many ...
L = L*(n/4)
L = L * (n // 4)
def tabulate(r): """Tabulate sort speed for lists of various sizes. The sizes are 2**i for i in r (the argument, a list). The output displays i, 2**i, and the time to sort arrays of 2**i floating point numbers with the following properties: *sort: random data \sort: descending data /sort: ascending data ~sort: many ...
L = map(abs, [-0.5]*n) doit(L) L = range(n/2-1, -1, -1) L[len(L):] = range(n/2)
L = map(abs, [-0.5] * n) doit(L) del L half = n // 2 L = range(half - 1, -1, -1) L.extend(range(half)) L = map(float, L)
def tabulate(r): """Tabulate sort speed for lists of various sizes. The sizes are 2**i for i in r (the argument, a list). The output displays i, 2**i, and the time to sort arrays of 2**i floating point numbers with the following properties: *sort: random data \sort: descending data /sort: ascending data ~sort: many ...
k2 = 19
k2 = 20
def main(): """Main program when invoked as a script. One argument: tabulate a single row. Two arguments: tabulate a range (inclusive). Extra arguments are used to seed the random generator. """ # default range (inclusive) k1 = 15 k2 = 19 if sys.argv[1:]: # one argument: single point k1 = k2 = int(sys.argv[1]) if sys...
x, y, z = 0, 0, 0
x = 1
def main(): """Main program when invoked as a script. One argument: tabulate a single row. Two arguments: tabulate a range (inclusive). Extra arguments are used to seed the random generator. """ # default range (inclusive) k1 = 15 k2 = 19 if sys.argv[1:]: # one argument: single point k1 = k2 = int(sys.argv[1]) if sys...
h = hash(a) h, d = divmod(h, 256) h = h & 0xffffff x = (x^h^d) & 255 h = h>>8 y = (y^h^d) & 255 h = h>>8 z = (z^h^d) & 255 whrandom.seed(x, y, z)
x = 69069 * x + hash(a) random.seed(x)
def main(): """Main program when invoked as a script. One argument: tabulate a single row. Two arguments: tabulate a range (inclusive). Extra arguments are used to seed the random generator. """ # default range (inclusive) k1 = 15 k2 = 19 if sys.argv[1:]: # one argument: single point k1 = k2 = int(sys.argv[1]) if sys...
if (new == Py_None) {
if (new == NULL || new == Py_None) {
def outputFreeIt(self, itselfname): Output("DisposeDialog(%s);", itselfname)
self.recall(sel)
self.recall(sel, event)
def enter_callback(self, event): if self.executing and not self.reading: return # Let the default binding (insert '\n') take over # If some text is selected, recall the selection # (but only if this before the I/O mark) try: sel = self.text.get("sel.first", "sel.last") if sel: if self.text.compare("sel.last", "<=", "io...
self.recall(self.text.get(prev[0], prev[1]))
self.recall(self.text.get(prev[0], prev[1]), event)
def enter_callback(self, event): if self.executing and not self.reading: return # Let the default binding (insert '\n') take over # If some text is selected, recall the selection # (but only if this before the I/O mark) try: sel = self.text.get("sel.first", "sel.last") if sel: if self.text.compare("sel.last", "<=", "io...
self.recall(self.text.get(next[0], next[1]))
self.recall(self.text.get(next[0], next[1]), event)
def enter_callback(self, event): if self.executing and not self.reading: return # Let the default binding (insert '\n') take over # If some text is selected, recall the selection # (but only if this before the I/O mark) try: sel = self.text.get("sel.first", "sel.last") if sel: if self.text.compare("sel.last", "<=", "io...
self.recall(line)
self.recall(line, event)
def enter_callback(self, event): if self.executing and not self.reading: return # Let the default binding (insert '\n') take over # If some text is selected, recall the selection # (but only if this before the I/O mark) try: sel = self.text.get("sel.first", "sel.last") if sel: if self.text.compare("sel.last", "<=", "io...
def recall(self, s): if self.history: self.history.recall(s)
def recall(self, s, event): self.text.undo_block_start() try: self.text.tag_remove("sel", "1.0", "end") self.text.mark_set("insert", "end-1c") s = s.strip() lines = s.split('\n') if lines: prefix = self.text.get("insert linestart","insert").rstrip() if prefix and prefix[-1]==':': self.newline_and_indent_event(event) s...
def recall(self, s): if self.history: self.history.recall(s)
if pathname and pathname[0] == '/':
if not pathname: return pathname if pathname[0] == '/':
def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local conventio...
if pathname and pathname[-1] == '/':
if pathname[-1] == '/':
def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local conventio...
tag = self._command(name, mailbox, flags, date_time, message) return self._command_complete(name, tag)
return self._simple_command(name, mailbox, flags, date_time, message)
def append(self, mailbox, flags, date_time, message): """Append message to named mailbox.
return code, self.untagged_responses.get(code, [None])
return self._untagged_response(code, code)
def response(self, code): """Return data for response 'code' if received, or None.
for r in ('EXISTS', 'READ-WRITE'): if self.untagged_responses.has_key(r): del self.untagged_responses[r]
self.untagged_responses = {}
def select(self, mailbox='INBOX', readonly=None): """Select a mailbox.
command = '%s %s' % (command, flag_list) typ, dat = self._simple_command('STORE', message_set, command)
typ, dat = self._simple_command('STORE', message_set, command, flag_list)
def store(self, message_set, command, flag_list): """Alters flag dispositions for messages in mailbox.
def uid(self, command, args): """Execute "command args" with messages identified by UID,
def uid(self, command, *args): """Execute "command arg ..." with messages identified by UID,
def uid(self, command, args): """Execute "command args" with messages identified by UID, rather than message number.
(typ, [data]) = <instance>.uid(command, args)
(typ, [data]) = <instance>.uid(command, arg1, arg2, ...)
def uid(self, command, args): """Execute "command args" with messages identified by UID, rather than message number.
typ, dat = self._simple_command('UID', command, args)
typ, dat = apply(self._simple_command, ('UID', command) + args)
def uid(self, command, args): """Execute "command args" with messages identified by UID, rather than message number.
def xatom(self, name, arg1=None, arg2=None):
def xatom(self, name, *args):
def xatom(self, name, arg1=None, arg2=None): """Allow simple extension commands notified by server in CAPABILITY response.
(typ, [data]) = <instance>.xatom(name, arg1=None, arg2=None)
(typ, [data]) = <instance>.xatom(name, arg, ...)
def xatom(self, name, arg1=None, arg2=None): """Allow simple extension commands notified by server in CAPABILITY response.
return self._simple_command(name, arg1, arg2)
return apply(self._simple_command, (name,) + args)
def xatom(self, name, arg1=None, arg2=None): """Allow simple extension commands notified by server in CAPABILITY response.
if d is not None: data = '%s %s' % (data, d)
if d is None: continue if type(d) is type(''): l = len(string.split(d)) else: l = 1 if l == 0 or l > 1 and (d[0],d[-1]) not in (('(',')'),('"','"')): data = '%s "%s"' % (data, d) else: data = '%s %s' % (data, d)
def _command(self, name, dat1=None, dat2=None, dat3=None, literal=None):
resp = self._get_line()[:-2]
resp = self._get_line()
def _get_response(self):
dat = self._get_line()[:-2]
dat = self._get_line()
def _get_response(self):
print '\t< %s' % line[:-2]
print '\t< %s' % line
def _get_line(self):
def _simple_command(self, name, dat1=None, dat2=None): return self._command_complete(name, self._command(name, dat1, dat2))
def _simple_command(self, name, *args): return self._command_complete(name, apply(self._command, (name,) + args))
def _simple_command(self, name, dat1=None, dat2=None):
('create', ('/tmp/xxx',)), ('rename', ('/tmp/xxx', '/tmp/yyy')), ('CREATE', ('/tmp/yyz',)), ('append', ('/tmp/yyz', None, None, 'From: anon@x.y.z\n\ndata...')), ('select', ('/tmp/yyz',)), ('recent', ()),
('create', ('/tmp/xxx 1',)), ('rename', ('/tmp/xxx 1', '/tmp/yyy')), ('CREATE', ('/tmp/yyz 2',)), ('append', ('/tmp/yyz 2', None, None, 'From: anon@x.y.z\n\ndata...')), ('select', ('/tmp/yyz 2',)),
def Time2Internaldate(date_time): """Convert 'date_time' to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"' """ dttype = type(date_time) if dttype is type(1): tt = time.localtime(date_time) elif dttype is type(()): tt = date_time elif dttype is type(""): return date_time # As...
('response', ('EXISTS',)),
def Time2Internaldate(date_time): """Convert 'date_time' to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"' """ dttype = type(date_time) if dttype is type(1): tt = time.localtime(date_time) elif dttype is type(()): tt = date_time elif dttype is type(""): return date_time # As...
path = string.split(ml)[-1]
mo = re.match(r'.*"([^"]+)"$', ml) if mo: path = mo.group(1) else: path = string.split(ml)[-1]
def run(cmd, args): typ, dat = apply(eval('M.%s' % cmd), args) print ' %s %s\n => %s %s' % (cmd, args, typ, dat) return dat
run('uid', ('FETCH', '%s (FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822)' % uid))
run('uid', ('FETCH', '%s' % uid, '(FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822)'))
def run(cmd, args): typ, dat = apply(eval('M.%s' % cmd), args) print ' %s %s\n => %s %s' % (cmd, args, typ, dat) return dat
exception = ['<p>%s: %s' % (strong(str(etype)), str(evalue))]
exception = ['<p>%s: %s' % (strong(pydoc.html.escape(str(etype))), pydoc.html.escape(str(evalue)))]
def reader(lnum=[lnum]): highlight[lnum[0]] = 1 try: return linecache.getline(file, lnum[0]) finally: lnum[0] += 1
g = {'c': 0, '__builtins__': __builtins__}
import __builtin__ g = {'c': 0, '__builtins__': __builtin__}
def break_yolks(self): self.yolks = self.yolks - 2
print 'new.code()' d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "", (), ()) d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "") if verbose: print d
if hasattr(new, 'code'): print 'new.code()' d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "", (), ()) d = new.code(3, 3, 3, 3, codestr, (), (), (), "<string>", "<name>", 1, "") if verbose: print d
def break_yolks(self): self.yolks = self.yolks - 2
self.ofp.write(struct.pack('>h', self.crc))
if self.crc < 0: fmt = '>h' else: fmt = '>H' self.ofp.write(struct.pack(fmt, self.crc))
def _writecrc(self): # XXXX Should this be here?? # self.crc = binascii.crc_hqx('\0\0', self.crc) self.ofp.write(struct.pack('>h', self.crc)) self.crc = 0
if (inspect.getmodule(value) or object) is object:
if (all is not None or (inspect.getmodule(value) or object) is object):
def docmodule(self, object, name=None, mod=None, *ignored): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name try: all = object.__all__ except AttributeError: all = None parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.ht...
if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
if (all is not None or inspect.isbuiltin(value) or inspect.getmodule(value) is object):
def docmodule(self, object, name=None, mod=None, *ignored): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name try: all = object.__all__ except AttributeError: all = None parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.ht...
if (inspect.getmodule(value) or object) is object:
if (all is not None or (inspect.getmodule(value) or object) is object):
def docmodule(self, object, name=None, mod=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop))
if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
if (all is not None or inspect.isbuiltin(value) or inspect.getmodule(value) is object):
def docmodule(self, object, name=None, mod=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop))
self.wfile = StringIO.StringIO(self.packet)
self.wfile = StringIO.StringIO()
def setup(self): import StringIO self.packet, self.socket = self.request self.rfile = StringIO.StringIO(self.packet) self.wfile = StringIO.StringIO(self.packet)
print 'XX', dst, '->', (head, tail)
def mkdirs(dst): """Make directories leading to 'dst' if they don't exist yet""" if dst == '' or os.path.exists(dst): return head, tail = os.path.split(dst) print 'XX', dst, '->', (head, tail) # XXXX Is this a bug in os.path.split? if not ':' in head: head = head + ':' mkdirs(head) os.mkdir(dst, 0777)
push('<dl><dt><strong>%s</strong></dt>\n' % name) if value.__doc__ is not None: doc = self.markup(value.__doc__, self.preformat, funcs, classes, mdict) push('<dd><tt>%s</tt></dd>\n' % doc) for attr, tag in [('fget', '<em>get</em>'), ('fset', '<em>set</em>'), ('fdel', '<em>delete</em>')]: func = getattr(value, attr) if ...
push(self._docproperty(name, value, mod))
def spillproperties(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push('<dl><dt><strong>%s</strong></dt>\n' % name) if value.__doc__ is not None: doc = self.markup(value.__doc__, self.preformat, funcs, classes, mdict) push('<dd><tt>%s...
push(name) need_blank_after_doc = 0 doc = getdoc(value) or '' if doc: push(self.indent(doc)) need_blank_after_doc = 1 for attr, tag in [('fget', '<get>'), ('fset', '<set>'), ('fdel', '<delete>')]: func = getattr(value, attr) if func is not None: if need_blank_after_doc: push('') need_blank_after_doc = 0 base = self.doc...
push(self._docproperty(name, value, mod))
def spillproperties(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(name) need_blank_after_doc = 0 doc = getdoc(value) or '' if doc: push(self.indent(doc)) need_blank_after_doc = 1 for attr, tag in [('fget', '<get>'), ('fset', '<se...
path = unquote(path)
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') # XXX handle custom username & password try: host = socket.gethostbyname(host) except socket.error, msg: raise URLError(msg) host, port = splitport(host) if port is None: port = ftplib.FTP_PORT path, attrs = splita...
r, w, x = select.select([self.fileno()], [], [], timeout)
elapsed = time() - time_start if elapsed >= timeout: break s_args = ([self.fileno()], [], [], timeout-elapsed) r, w, x = select.select(*s_args)
def expect(self, list, timeout=None): """Read until one from a list of a regular expressions matches.
(string.capitalize(name), data)) lines.append("%s=%s" % (name, repr(data)[1:-1]))
(string.capitalize(name), escape(data))) lines.append("%s=%s" % (name, escape(data)))
def get_inidata (self): # Return data describing the installation.
lines.append("info=%s" % repr(info)[1:-1])
lines.append("info=%s" % escape(info))
def get_inidata (self): # Return data describing the installation.
lines.append("title=%s" % repr(title)[1:-1])
lines.append("title=%s" % escape(title))
def get_inidata (self): # Return data describing the installation.
if chunks[0].strip() == '':
if chunks[0].strip() == '' and lines:
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
def _init_posix(): import os import re import string import sys
def _init_posix(): import os import re import string import sys g = globals() version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") # load the installed config.h: define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n") undef_rx = re.compile("/[*] #undef ([A-Z][...
g = globals()
def get_config_h_filename(): return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3], "config", "config.h")
def _init_posix(): import os import re import string import sys g = globals() version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") # load the installed config.h: define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n") undef_rx = re.compile("/[*] #undef ([A-Z][...
version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config")
def get_makefile_filename(): return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3], "config", "Makefile")
def _init_posix(): import os import re import string import sys g = globals() version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") # load the installed config.h: define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n") undef_rx = re.compile("/[*] #undef ([A-Z][...
def parse_config_h(fp, g=None): if g is None: g = {}
def _init_posix(): import os import re import string import sys g = globals() version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") # load the installed config.h: define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n") undef_rx = re.compile("/[*] #undef ([A-Z][...
fp = open(os.path.join(config_dir, "config.h"))
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
def parse_makefile(fp, g=None): if g is None: g = {}
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
fp = open(os.path.join(config_dir, "Makefile"))
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
import os exec "_init_%s()" % os.name del os
def _init_posix(): g = globals() parse_config_h(open(get_config_h_filename()), g) parse_makefile(open(get_makefile_filename()), g) try: exec "_init_" + os.name except NameError: pass else: exec "_init_%s()" % os.name
undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n")
assert "'" not in action cmd = "kfmclient '%s' >/dev/null 2>&1" % action
cmd = "kfmclient %s >/dev/null 2>&1" % action
def _remote(self, action): assert "'" not in action cmd = "kfmclient '%s' >/dev/null 2>&1" % action rc = os.system(cmd) if rc: import time if self.basename == "konqueror": os.system(self.name + " --silent &") else: os.system(self.name + " -d &") time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc
if code != 200:
if code not in (200, 206):
def http_response(self, request, response): code, msg, hdrs = response.code, response.msg, response.info()
if r.status == 200:
if r.status in (200, 206):
def do_open(self, http_class, req): """Return an addinfourl object for the request, using http_class.
if parent: self.badmodules[fqname][parent.__name__] = None
def import_module(self, partname, fqname, parent): self.msgin(3, "import_module", partname, fqname, parent) try: m = self.modules[fqname] except KeyError: pass else: self.msgout(3, "import_module ->", m) return m if self.badmodules.has_key(fqname): self.msgout(3, "import_module -> None") if parent: self.badmodules[fqna...
lastname = None
fromlist = None
def scan_code(self, co, m): code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.impo...
if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.import_hook(name, m) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) if not self.badmodules.has_key(name): self.badmodules[name] = {} self.badmodules[name][m.__name__] = None elif op == IMPORT_F...
if op == LOAD_CONST: fromlist = co.co_consts[oparg] elif op == IMPORT_NAME: assert fromlist is None or type(fromlist) is tuple
def scan_code(self, co, m): code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.impo...
assert lastname is not None if not self.badmodules.has_key(lastname): try: self.import_hook(lastname, m, [name]) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) fullname = lastname + "." + name if not self.badmodules.has_key(fullname): self.badmodules[fullname] = {} self.badmodules[fullname][m.__name__] ...
have_star = 0 if fromlist is not None: if "*" in fromlist: have_star = 1 fromlist = [f for f in fromlist if f != "*"] self._safe_import_hook(name, m, fromlist) if have_star: mm = None if m.__path__: mm = self.modules.get(m.__name__ + "." + name) if mm is None: mm = self.modules.get(name) if mm is not None: m.glob...
def scan_code(self, co, m): code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.impo...
pass else: lastname = None
name = co.co_names[oparg] m.globalnames[name] = 1
def scan_code(self, co, m): code = co.co_code n = len(code) i = 0 lastname = None while i < n: c = code[i] i = i+1 op = ord(c) if op >= dis.HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 if op == IMPORT_NAME: name = lastname = co.co_names[oparg] if not self.badmodules.has_key(lastname): try: self.impo...
keys = self.badmodules.keys() keys.sort() for key in keys: if key not in self.excludes: mods = self.badmodules[key].keys()
missing, maybe = self.any_missing_maybe() if missing: print print "Missing modules:" for name in missing: mods = self.badmodules[name].keys()
def report(self): print print " %-25s %s" % ("Name", "File") print " %-25s %s" % ("----", "----") # Print modules found keys = self.modules.keys() keys.sort() for key in keys: m = self.modules[key] if m.__path__: print "P", else: print "m", print "%-25s" % key, m.__file__ or ""
print "?", key, "from", ', '.join(mods)
print "?", name, "imported from", ', '.join(mods) if maybe: print print "Submodules thay appear to be missing, but could also be", print "global names in the parent package:" for name in maybe: mods = self.badmodules[name].keys() mods.sort() print "?", name, "imported from", ', '.join(mods)
def report(self): print print " %-25s %s" % ("Name", "File") print " %-25s %s" % ("----", "----") # Print modules found keys = self.modules.keys() keys.sort() for key in keys: m = self.modules[key] if m.__path__: print "P", else: print "m", print "%-25s" % key, m.__file__ or ""
keys = self.badmodules.keys()
missing, maybe = self.any_missing_maybe() return missing + maybe def any_missing_maybe(self): """Return two lists, one with modules that are certainly missing and one with modules that *may* be missing. The latter names could either be submodules *or* just global names in the package. The reason it can't always be de...
def any_missing(self): keys = self.badmodules.keys() missing = [] for key in keys: if key not in self.excludes: # Missing, and its not supposed to be missing.append(key) return missing
for key in keys: if key not in self.excludes: missing.append(key) return missing
maybe = [] for name in self.badmodules: if name in self.excludes: continue i = name.rfind(".") if i < 0: missing.append(name) continue subname = name[i+1:] pkgname = name[:i] pkg = self.modules.get(pkgname) if pkg is not None: if pkgname in self.badmodules[name]: missing.append(name) elif subname in pkg.globalnames: ...
def any_missing(self): keys = self.badmodules.keys() missing = [] for key in keys: if key not in self.excludes: # Missing, and its not supposed to be missing.append(key) return missing
test()
mf = test()
def test(): # Parse command line import getopt try: opts, args = getopt.getopt(sys.argv[1:], "dmp:qx:") except getopt.error, msg: print msg return # Process options debug = 1 domods = 0 addpath = [] exclude = [] for o, a in opts: if o == '-d': debug = debug + 1 if o == '-m': domods = 1 if o == '-p': addpath = addpath ...
objects = self.object_filenames(sources, 1, outdir)
objects = self.object_filenames(sources, 0, outdir)
def _setup_compile(self, outdir, macros, incdirs, sources, depends, extra): """Process arguments and decide which source files to compile.
objects = self.object_filenames(sources, strip_dir=1,
objects = self.object_filenames(sources, strip_dir=0,
def _prep_compile(self, sources, output_dir, depends=None): """Decide which souce files must be recompiled.
" LettError, Erik van Blokland, for the \n" " Python for Windows graphic.\n" " http://www.letterror.com/\n" "\n"
def add_ui(db): x = y = 50 w = 370 h = 300 title = "[ProductName] Setup" # see "Dialog Style Bits" modal = 3 # visible | modal modeless = 1 # visible track_disk_space = 32 add_data(db, 'ActionText', uisample.ActionText) add_data(db, 'UIText', uisample.UIText) # Bitmaps if not os.path.exists(srcdir+r"\PC\pytho...
folderbox = Listbox(right)
folderbox = Listbox(right, {'exportselection': 0})
def main(): global root, tk, top, mid, bot global folderbox, foldermenu, scanbox, scanmenu, viewer global folder, seq global mh, mhf # Parse command line options folder = 'inbox' seq = 'all' try: opts, args = getopt.getopt(sys.argv[1:], '') except getopt.error, msg: print msg sys.exit(2) for arg in args: if arg[:1] =...
def open_folder(*e):
def open_folder(e=None):
def open_folder(*e): global folder, mhf sel = folderbox.curselection() if len(sel) != 1: if len(sel) > 1: msg = "Please open one folder at a time" else: msg = "Please select a folder to open" dialog(root, "Can't Open Folder", msg, "", 0, "OK") return i = sel[0] folder = folderbox.get(i) mhf = mh.openfolder(folder) resc...
def open_message(*e):
def open_message(e=None):
def open_message(*e): global viewer sel = scanbox.curselection() if len(sel) != 1: if len(sel) > 1: msg = "Please open one message at a time" else: msg = "Please select a message to open" dialog(root, "Can't Open Message", msg, "", 0, "OK") return cursor = scanbox['cursor'] scanbox['cursor'] = 'watch' tk.call('update',...