bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def _generate_toc(self): """Generate key-to-(start, stop) table of contents.""" starts, stops = [], [] self._file.seek(0) next_pos = 0 label_lists = [] while True: line_pos = next_pos line = self._file.readline() next_pos = self._file.tell() if line == '\037\014' + os.linesep: if len(stops) < len(starts): stops.append(line_pos - len(os.linesep)) starts.append(next_pos) labels = [label.strip() for label in self._file.readline()[1:].split(',') if label.strip() != ''] label_lists.append(labels) elif line == '\037' or line == '\037' + os.linesep: if len(stops) < len(starts): stops.append(line_pos - len(os.linesep)) elif line == '': stops.append(line_pos - len(os.linesep)) break self._toc = dict(enumerate(zip(starts, stops))) self._labels = dict(enumerate(label_lists)) self._next_key = len(self._toc)
|
defself._file.seek(0, 2) self._file_length = self._file.tell() _generate_toc(self):self._file.seek(0, 2) self._file_length = self._file.tell() """Generateself._file.seek(0, 2) self._file_length = self._file.tell() key-to-(start,self._file.seek(0, 2) self._file_length = self._file.tell() stop)self._file.seek(0, 2) self._file_length = self._file.tell() tableself._file.seek(0, 2) self._file_length = self._file.tell() ofself._file.seek(0, 2) self._file_length = self._file.tell() contents."""self._file.seek(0, 2) self._file_length = self._file.tell() starts,self._file.seek(0, 2) self._file_length = self._file.tell() stopsself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() [],self._file.seek(0, 2) self._file_length = self._file.tell() []self._file.seek(0, 2) self._file_length = self._file.tell() self._file.seek(0)self._file.seek(0, 2) self._file_length = self._file.tell() next_posself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() 0self._file.seek(0, 2) self._file_length = self._file.tell() label_listsself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() []self._file.seek(0, 2) self._file_length = self._file.tell() whileself._file.seek(0, 2) self._file_length = self._file.tell() True:self._file.seek(0, 2) self._file_length = self._file.tell() line_posself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() next_posself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() self._file.readline()self._file.seek(0, 2) self._file_length = self._file.tell() next_posself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() self._file.tell()self._file.seek(0, 2) self._file_length = self._file.tell() ifself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() ==self._file.seek(0, 2) self._file_length = self._file.tell() '\037\014'self._file.seek(0, 2) self._file_length = self._file.tell() +self._file.seek(0, 2) self._file_length = self._file.tell() os.linesep:self._file.seek(0, 2) self._file_length = self._file.tell() ifself._file.seek(0, 2) self._file_length = self._file.tell() len(stops)self._file.seek(0, 2) self._file_length = self._file.tell() <self._file.seek(0, 2) self._file_length = self._file.tell() len(starts):self._file.seek(0, 2) self._file_length = self._file.tell() stops.append(line_posself._file.seek(0, 2) self._file_length = self._file.tell() -self._file.seek(0, 2) self._file_length = self._file.tell() len(os.linesep))self._file.seek(0, 2) self._file_length = self._file.tell() starts.append(next_pos)self._file.seek(0, 2) self._file_length = self._file.tell() labelsself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() [label.strip()self._file.seek(0, 2) self._file_length = self._file.tell() forself._file.seek(0, 2) self._file_length = self._file.tell() labelself._file.seek(0, 2) self._file_length = self._file.tell() inself._file.seek(0, 2) self._file_length = self._file.tell() self._file.readline()[1:].split(',')self._file.seek(0, 2) self._file_length = self._file.tell() ifself._file.seek(0, 2) self._file_length = self._file.tell() label.strip()self._file.seek(0, 2) self._file_length = self._file.tell() !=self._file.seek(0, 2) self._file_length = self._file.tell() '']self._file.seek(0, 2) self._file_length = self._file.tell() label_lists.append(labels)self._file.seek(0, 2) self._file_length = self._file.tell() elifself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() ==self._file.seek(0, 2) self._file_length = self._file.tell() '\037'self._file.seek(0, 2) self._file_length = self._file.tell() orself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() ==self._file.seek(0, 2) self._file_length = self._file.tell() '\037'self._file.seek(0, 2) self._file_length = self._file.tell() +self._file.seek(0, 2) self._file_length = self._file.tell() os.linesep:self._file.seek(0, 2) self._file_length = self._file.tell() ifself._file.seek(0, 2) self._file_length = self._file.tell() len(stops)self._file.seek(0, 2) self._file_length = self._file.tell() <self._file.seek(0, 2) self._file_length = self._file.tell() len(starts):self._file.seek(0, 2) self._file_length = self._file.tell() stops.append(line_posself._file.seek(0, 2) self._file_length = self._file.tell() -self._file.seek(0, 2) self._file_length = self._file.tell() len(os.linesep))self._file.seek(0, 2) self._file_length = self._file.tell() elifself._file.seek(0, 2) self._file_length = self._file.tell() lineself._file.seek(0, 2) self._file_length = self._file.tell() ==self._file.seek(0, 2) self._file_length = self._file.tell() '':self._file.seek(0, 2) self._file_length = self._file.tell() stops.append(line_posself._file.seek(0, 2) self._file_length = self._file.tell() -self._file.seek(0, 2) self._file_length = self._file.tell() len(os.linesep))self._file.seek(0, 2) self._file_length = self._file.tell() breakself._file.seek(0, 2) self._file_length = self._file.tell() self._tocself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() dict(enumerate(zip(starts,self._file.seek(0, 2) self._file_length = self._file.tell() stops)))self._file.seek(0, 2) self._file_length = self._file.tell() self._labelsself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() dict(enumerate(label_lists))self._file.seek(0, 2) self._file_length = self._file.tell() self._next_keyself._file.seek(0, 2) self._file_length = self._file.tell() =self._file.seek(0, 2) self._file_length = self._file.tell() len(self._toc)
| 12,100
|
exec("""def __%(method)s__(self, *args): print "__%(method)s__:", args
|
exec """def __%(method)s__(self, *args): print "__%(method)s__:", args
| 12,101
|
exec("""def __%(method)s__(self, *args): print "__%(method)s__:", args
|
exec("""def __%(method)s__(self, *args): print "__%(method)s__:", args
| 12,102
|
def test_truncate(self): eq = self.assertEqual f = self.MODULE.StringIO() f.write(self._lines) f.seek(10) f.truncate() eq(f.getvalue(), 'abcdefghij') f.seek(0) f.truncate(5) eq(f.getvalue(), 'abcde') f.close() self.assertRaises(ValueError, f.write, 'frobnitz')
|
def test_truncate(self): eq = self.assertEqual f = self.MODULE.StringIO() f.write(self._lines) f.seek(10) f.truncate() eq(f.getvalue(), 'abcdefghij') f.truncate(5) eq(f.getvalue(), 'abcde') f.close() self.assertRaises(ValueError, f.write, 'frobnitz')
| 12,103
|
def testMultiply(self); self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
|
def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
| 12,104
|
def testMultiply(self); self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
|
def testMultiply(self); self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
| 12,105
|
def addError(self, test, err): "Called when an error has occurred" self.errors.append((test, err))
|
def addError(self, test, err): "Called when an error has occurred" self.errors.append((test, err))
| 12,106
|
def addFailure(self, test, err): "Called when a failure has occurred" self.failures.append((test, err))
|
def addFailure(self, test, err): "Called when a failure has occurred" self.failures.append((test, err))
| 12,107
|
def printErrorList(self, flavour, errors): for test, err in errors: self.stream.writeln(self.separator1) self.stream.writeln("%s: %s" % (flavour,self.getDescription(test))) self.stream.writeln(self.separator2) for line in apply(traceback.format_exception, err): for l in string.split(line,"\n")[:-1]: self.stream.writeln("%s" % l)
|
def printErrorList(self, flavour, errors): for test, err in errors: self.stream.writeln(self.separator1) self.stream.writeln("%s: %s" % (flavour,self.getDescription(test))) self.stream.writeln(self.separator2) for line in apply(traceback.format_exception, err): for l in string.split(line,"\n")[:-1]: self.stream.writeln("%s" % l)
| 12,108
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
| 12,109
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
| 12,110
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
|
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), ]
| 12,111
|
def __init__(self, url, data=None, headers={}, origin_req_host=None, unverifiable=False): # unwrap('<URL:type://host/path>') --> 'type://host/path' self.__original = unwrap(url) self.type = None # self.__r_type is what's left after doing the splittype self.host = None self.port = None self.data = data self.headers = {} for key, value in headers.items(): self.add_header(key, value) self.unredirected_hdrs = {} if origin_req_host is None: origin_req_host = cookielib.request_host(self) self.origin_req_host = origin_req_host self.unverifiable = unverifiable
|
def __init__(self, url, data=None, headers={}, origin_req_host=None, unverifiable=False): # unwrap('<URL:type://host/path>') --> 'type://host/path' self.__original = unwrap(url) self.type = None # self.__r_type is what's left after doing the splittype self.host = None self.port = None self.data = data self.headers = {} for key, value in headers.items(): self.add_header(key, value) self.unredirected_hdrs = {} if origin_req_host is None: origin_req_host = request_host(self) self.origin_req_host = origin_req_host self.unverifiable = unverifiable
| 12,112
|
def build_opener(*handlers): """Create an opener object from a list of handlers. The opener will use several default handlers, including support for HTTP and FTP. If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, FTPHandler, FileHandler, HTTPErrorProcessor] if hasattr(httplib, 'HTTPS'): default_classes.append(HTTPSHandler) skip = [] for klass in default_classes: for check in handlers: if inspect.isclass(check): if issubclass(check, klass): skip.append(klass) elif isinstance(check, klass): skip.append(klass) for klass in skip: default_classes.remove(klass) for klass in default_classes: opener.add_handler(klass()) for h in handlers: if inspect.isclass(h): h = h() opener.add_handler(h) return opener
|
def build_opener(*handlers): """Create an opener object from a list of handlers. The opener will use several default handlers, including support for HTTP and FTP. If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, FTPHandler, FileHandler, HTTPErrorProcessor] if hasattr(httplib, 'HTTPS'): default_classes.append(HTTPSHandler) skip = [] for klass in default_classes: for check in handlers: if isclass(check): if issubclass(check, klass): skip.append(klass) elif isinstance(check, klass): skip.append(klass) for klass in skip: default_classes.remove(klass) for klass in default_classes: opener.add_handler(klass()) for h in handlers: if inspect.isclass(h): h = h() opener.add_handler(h) return opener
| 12,113
|
def build_opener(*handlers): """Create an opener object from a list of handlers. The opener will use several default handlers, including support for HTTP and FTP. If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, FTPHandler, FileHandler, HTTPErrorProcessor] if hasattr(httplib, 'HTTPS'): default_classes.append(HTTPSHandler) skip = [] for klass in default_classes: for check in handlers: if inspect.isclass(check): if issubclass(check, klass): skip.append(klass) elif isinstance(check, klass): skip.append(klass) for klass in skip: default_classes.remove(klass) for klass in default_classes: opener.add_handler(klass()) for h in handlers: if inspect.isclass(h): h = h() opener.add_handler(h) return opener
|
def build_opener(*handlers): """Create an opener object from a list of handlers. The opener will use several default handlers, including support for HTTP and FTP. If any of the handlers passed as arguments are subclasses of the default handlers, the default handlers will not be used. """ opener = OpenerDirector() default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, FTPHandler, FileHandler, HTTPErrorProcessor] if hasattr(httplib, 'HTTPS'): default_classes.append(HTTPSHandler) skip = [] for klass in default_classes: for check in handlers: if inspect.isclass(check): if issubclass(check, klass): skip.append(klass) elif isinstance(check, klass): skip.append(klass) for klass in skip: default_classes.remove(klass) for klass in default_classes: opener.add_handler(klass()) for h in handlers: if isclass(h): h = h() opener.add_handler(h) return opener
| 12,114
|
def __init__(self, counts=None, calledfuncs=None, infile=None, outfile=None): self.counts = counts if self.counts is None: self.counts = {} self.counter = self.counts.copy() # map (filename, lineno) to count self.calledfuncs = calledfuncs if self.calledfuncs is None: self.calledfuncs = {} self.calledfuncs = self.calledfuncs.copy() self.infile = infile self.outfile = outfile if self.infile: # Try and merge existing counts file. # This code understand a couple of old trace.py formats. try: thingie = pickle.load(open(self.infile, 'r')) if isinstance(thingie, dict): self.update(self.__class__(thingie)) elif isinstance(thingie, tuple) and len(thingie) == 2: counts, calledfuncs = thingie self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError), err: print >> sys.stderr, ("Skipping counts file %r: %s" % (self.infile, err)) except pickle.UnpicklingError: self.update(self.__class__(marshal.load(open(self.infile))))
|
def __init__(self, counts=None, calledfuncs=None, infile=None, outfile=None): self.counts = counts if self.counts is None: self.counts = {} self.counter = self.counts.copy() # map (filename, lineno) to count self.calledfuncs = calledfuncs if self.calledfuncs is None: self.calledfuncs = {} self.calledfuncs = self.calledfuncs.copy() self.infile = infile self.outfile = outfile if self.infile: # Try and merge existing counts file. # This code understand a couple of old trace.py formats. try: thingie = pickle.load(open(self.infile, 'r')) if isinstance(thingie, dict): self.update(self.__class__(thingie)) elif isinstance(thingie, tuple) and len(thingie) == 2: counts, calledfuncs = thingie self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError), err: print >> sys.stderr, ("Skipping counts file %r: %s" % (self.infile, err)) except pickle.UnpicklingError: self.update(self.__class__(marshal.load(open(self.infile))))
| 12,115
|
def __init__(self, counts=None, calledfuncs=None, infile=None, outfile=None): self.counts = counts if self.counts is None: self.counts = {} self.counter = self.counts.copy() # map (filename, lineno) to count self.calledfuncs = calledfuncs if self.calledfuncs is None: self.calledfuncs = {} self.calledfuncs = self.calledfuncs.copy() self.infile = infile self.outfile = outfile if self.infile: # Try and merge existing counts file. # This code understand a couple of old trace.py formats. try: thingie = pickle.load(open(self.infile, 'r')) if isinstance(thingie, dict): self.update(self.__class__(thingie)) elif isinstance(thingie, tuple) and len(thingie) == 2: counts, calledfuncs = thingie self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError), err: print >> sys.stderr, ("Skipping counts file %r: %s" % (self.infile, err)) except pickle.UnpicklingError: self.update(self.__class__(marshal.load(open(self.infile))))
|
def __init__(self, counts=None, calledfuncs=None, infile=None, outfile=None): self.counts = counts if self.counts is None: self.counts = {} self.counter = self.counts.copy() # map (filename, lineno) to count self.calledfuncs = calledfuncs if self.calledfuncs is None: self.calledfuncs = {} self.calledfuncs = self.calledfuncs.copy() self.infile = infile self.outfile = outfile if self.infile: # Try and merge existing counts file. # This code understand a couple of old trace.py formats. try: counts, calledfuncs = pickle.load(open(self.infile, 'r')) self.update(self.__class__(counts, calledfuncs)) except (IOError, EOFError, ValueError), err: print >> sys.stderr, ("Skipping counts file %r: %s" % (self.infile, err)) except pickle.UnpicklingError: self.update(self.__class__(marshal.load(open(self.infile))))
| 12,116
|
def update(self): self.w.browser.update()
|
def update(self): self.w.browser.update()
| 12,117
|
def unpack_sequence(seq, indent = 0): items = map(None, range(len(seq)), seq) items = map(lambda (k, v), type = type, simp = SIMPLE_TYPES, indent = indent: (k, v, not type(v) in simp, indent), items) return items
|
def unpack_sequence(seq, indent = 0): return [(i, v, not isinstance(v, SIMPLE_TYPES), indent) for i, v in enumerate(seq)]
| 12,118
|
def buildappbundle(executable, output=None, copyfunc=None, creator=None, plist=None, nib=None, resources=None): if not output: output = os.path.split(executable)[1] + '.app' if not copyfunc: copyfunc = shutil.copy2 if not creator: creator='????' if not resources: resources = [] if nib: resources = resources + [nib] # # Create the main directory structure # if not os.path.isdir(output): os.mkdir(output) contents = os.path.join(output, 'Contents') if not os.path.isdir(contents): os.mkdir(contents) macos = os.path.join(contents, 'MacOS') if not os.path.isdir(macos): os.mkdir(macos) # # Create the executable # shortname = os.path.split(executable)[1] execname = os.path.join(macos, shortname) try: os.remove(execname) except OSError: pass copyfunc(executable, execname) # # Create the PkgInfo file # pkginfo = os.path.join(contents, 'PkgInfo') open(pkginfo, 'wb').write('APPL'+creator) if plist: # A plist file is specified. Read it. plistdata = open(plist).read() else: # # If we have a main NIB we create the extra Cocoa specific info for the plist file # if not nib: nibname = "" else: nibname, ext = os.path.splitext(os.path.split(nib)[1]) if ext == '.lproj': # Special case: if the main nib is a .lproj we assum a directory # and use the first nib from there files = os.listdir(nib) for f in files: if f[-4:] == '.nib': nibname = os.path.split(f)[1][:-4] break else: nibname = "" if nibname: cocoainfo = """ <key>NSMainNibFile</key> <string>%s</string> <key>NSPrincipalClass</key> <string>NSApplication</string>""" % nibname else: cocoainfo = "" plistdata = \
|
def buildappbundle(executable, output=None, copyfunc=None, creator=None, plist=None, nib=None, resources=None): if not output: output = os.path.split(executable)[1] + '.app' if not copyfunc: copyfunc = shutil.copy2 if not creator: creator='????' if not resources: resources = [] if nib: resources = resources + [nib] # # Create the main directory structure # if not os.path.isdir(output): os.mkdir(output) contents = os.path.join(output, 'Contents') if not os.path.isdir(contents): os.mkdir(contents) macos = os.path.join(contents, 'MacOS') if not os.path.isdir(macos): os.mkdir(macos) # # Create the executable # shortname = os.path.split(executable)[1] execname = os.path.join(macos, shortname) try: os.remove(execname) except OSError: pass copyfunc(executable, execname) # # Create the PkgInfo file # pkginfo = os.path.join(contents, 'PkgInfo') open(pkginfo, 'wb').write('APPL'+creator) if plist: # A plist file is specified. Read it. plistdata = open(plist).read() else: # # If we have a main NIB we create the extra Cocoa specific info for the plist file # if not nib: nibname = "" else: nibname, ext = os.path.splitext(os.path.split(nib)[1]) if ext == '.lproj': # Special case: if the main nib is a .lproj we assum a directory # and use the first nib from there files = os.listdir(nib) for f in files: if f[-4:] == '.nib': nibname = os.path.split(f)[1][:-4] break else: nibname = "" if nibname: cocoainfo = """ <key>NSMainNibFile</key> <string>%s</string> <key>NSPrincipalClass</key> <string>NSApplication</string>""" % nibname else: cocoainfo = "" plistdata = \
| 12,119
|
def usage(): print "buildappbundle creates an application bundle" print "Usage:" print " buildappbundle [options] executable" print "Options:" print " --output o Output file; default executable with .app appended, short -o" print " --link Symlink the executable (default: copy), short -l" print " --plist file Plist file (default: generate one), short -p" print " --nib file Main nib file or lproj folder for Cocoa program, short -n" print " --resource r Extra resource file to be copied to Resources, short -r" print " --creator c 4-char creator code (default: ????), short -c" print " --help This message, short -?" sys.exit(1)
|
def usage(): print __doc__ sys.exit(1)
| 12,120
|
def main(): output=None copyfunc=None creator=None plist=None nib=None resources=[] SHORTOPTS = "o:ln:r:p:c:?" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): copyfunc = os.symlink elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-?', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
|
def main(): output = None symlink = 0 creator = "????" plist = None nib = None resources = [] verbosity = 0 SHORTOPTS = "o:ln:r:p:c:v?h" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help", "verbose") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): copyfunc = os.symlink elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-?', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
| 12,121
|
def main(): output=None copyfunc=None creator=None plist=None nib=None resources=[] SHORTOPTS = "o:ln:r:p:c:?" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): copyfunc = os.symlink elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-?', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
|
def main(): output=None copyfunc=None creator=None plist=None nib=None resources=[] SHORTOPTS = "o:ln:r:p:c:?" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): symlink = 1 elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-?', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
| 12,122
|
def main(): output=None copyfunc=None creator=None plist=None nib=None resources=[] SHORTOPTS = "o:ln:r:p:c:?" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): copyfunc = os.symlink elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-?', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
|
def main(): output=None copyfunc=None creator=None plist=None nib=None resources=[] SHORTOPTS = "o:ln:r:p:c:?" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): copyfunc = os.symlink elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-v', '--verbose'): verbosity += 1 elif opt in ('-?', '-h', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
| 12,123
|
def main(): output=None copyfunc=None creator=None plist=None nib=None resources=[] SHORTOPTS = "o:ln:r:p:c:?" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): copyfunc = os.symlink elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-?', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
|
def main(): output=None copyfunc=None creator=None plist=None nib=None resources=[] SHORTOPTS = "o:ln:r:p:c:?" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): copyfunc = os.symlink elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-?', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
| 12,124
|
def main(): output=None copyfunc=None creator=None plist=None nib=None resources=[] SHORTOPTS = "o:ln:r:p:c:?" LONGOPTS=("output=", "link", "nib=", "resource=", "plist=", "creator=", "help") try: options, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS) except getopt.error: usage() if len(args) != 1: usage() for opt, arg in options: if opt in ('-o', '--output'): output = arg elif opt in ('-l', '--link'): copyfunc = os.symlink elif opt in ('-n', '--nib'): nib = arg elif opt in ('-r', '--resource'): resources.append(arg) elif opt in ('-c', '--creator'): creator = arg elif opt in ('-p', '--plist'): plist = arg elif opt in ('-?', '--help'): usage() buildappbundle(args[0], output=output, copyfunc=copyfunc, creator=creator, plist=plist, resources=resources)
|
defmain():output=Nonecopyfunc=Nonecreator=Noneplist=Nonenib=Noneresources=[]SHORTOPTS="o:ln:r:p:c:?"LONGOPTS=("output=","link","nib=","resource=","plist=","creator=","help")try:options,args=getopt.getopt(sys.argv[1:],SHORTOPTS,LONGOPTS)exceptgetopt.error:usage()iflen(args)!=1:usage()foropt,arginoptions:ifoptin('-o','--output'):output=argelifoptin('-l','--link'):copyfunc=os.symlinkelifoptin('-n','--nib'):nib=argelifoptin('-r','--resource'):resources.append(arg)elifoptin('-c','--creator'):creator=argelifoptin('-p','--plist'):plist=argelifoptin('-?','--help'):usage()buildappbundle(args[0],output=output,copyfunc=copyfunc,creator=creator,plist=plist,resources=resources)
| 12,125
|
def updatecache(filename): """Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.""" if cache.has_key(filename): del cache[filename] if not filename or filename[0] + filename[-1] == '<>': return [] fullname = filename try: stat = os.stat(fullname) except os.error, msg: # Try looking through the module search path basename = os.path.split(filename)[1] for dirname in sys.path: fullname = os.path.join(dirname, basename) try: stat = os.stat(fullname) break except os.error: pass else: # No luck
|
def updatecache(filename): """Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.""" if cache.has_key(filename): del cache[filename] if not filename or filename[0] + filename[-1] == '<>': return [] fullname = filename try: stat = os.stat(fullname) except os.error, msg: # Try looking through the module search path basename = os.path.split(filename)[1] for dirname in sys.path: fullname = os.path.join(dirname, basename) try: stat = os.stat(fullname) break except os.error: pass else: # No luck
| 12,126
|
def updatecache(filename): """Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.""" if cache.has_key(filename): del cache[filename] if not filename or filename[0] + filename[-1] == '<>': return [] fullname = filename try: stat = os.stat(fullname) except os.error, msg: # Try looking through the module search path basename = os.path.split(filename)[1] for dirname in sys.path: fullname = os.path.join(dirname, basename) try: stat = os.stat(fullname) break except os.error: pass else: # No luck
|
def updatecache(filename): """Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.""" if cache.has_key(filename): del cache[filename] if not filename or filename[0] + filename[-1] == '<>': return [] fullname = filename try: stat = os.stat(fullname) except os.error, msg: # Try looking through the module search path basename = os.path.split(filename)[1] for dirname in sys.path: try: stat = os.stat(fullname) break except os.error: pass else: # No luck
| 12,127
|
def updatecache(filename): """Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.""" if cache.has_key(filename): del cache[filename] if not filename or filename[0] + filename[-1] == '<>': return [] fullname = filename try: stat = os.stat(fullname) except os.error, msg: # Try looking through the module search path basename = os.path.split(filename)[1] for dirname in sys.path: fullname = os.path.join(dirname, basename) try: stat = os.stat(fullname) break except os.error: pass else: # No luck
|
def updatecache(filename): """Update a cache entry and return its list of lines. If something's wrong, print a message, discard the cache entry, and return an empty list.""" if cache.has_key(filename): del cache[filename] if not filename or filename[0] + filename[-1] == '<>': return [] fullname = filename try: stat = os.stat(fullname) except os.error, msg: # Try looking through the module search path basename = os.path.split(filename)[1] for dirname in sys.path: fullname = os.path.join(dirname, basename) try: fullname = os.path.join(dirname, basename) except (TypeError, AttributeError): pass else: # No luck
| 12,128
|
def _run_with_cl_interpreter(self): import Terminal interp_path = os.path.join(sys.exec_prefix, "bin", "python") file_path = self.path if not os.path.exists(interp_path): # This "can happen" if we are running IDE under MacPython-OS9. raise W.AlertError, "Can't find command-line Python" cmd = '"%s" "%s" ; exit' % (interp_path, file_path) t = Terminal.Terminal() t.do_script(with_command=cmd)
|
def _run_with_cl_interpreter(self): import Terminal interp_path = os.path.join(sys.exec_prefix, "Resources", "Python.app", "Contents", "MacOS", "Python") if not os.path.exists(interp_path): interp_path = os.path.join(sys.exec_prefix, "bin", "python") file_path = self.path if not os.path.exists(interp_path): # This "can happen" if we are running IDE under MacPython-OS9. raise W.AlertError, "Can't find command-line Python" cmd = '"%s" "%s" ; exit' % (interp_path, file_path) t = Terminal.Terminal() t.do_script(with_command=cmd)
| 12,129
|
def _run_with_cl_interpreter(self): import Terminal interp_path = os.path.join(sys.exec_prefix, "bin", "python") file_path = self.path if not os.path.exists(interp_path): # This "can happen" if we are running IDE under MacPython-OS9. raise W.AlertError, "Can't find command-line Python" cmd = '"%s" "%s" ; exit' % (interp_path, file_path) t = Terminal.Terminal() t.do_script(with_command=cmd)
|
def _run_with_cl_interpreter(self): import Terminal interp_path = os.path.join(sys.exec_prefix, "bin", "python") file_path = self.path if not os.path.exists(interp_path): # This "can happen" if we are running IDE under MacPython-OS9. raise W.AlertError, "Can't find command-line Python" cmd = '"%s" "%s" ; exit' % (interp_path, file_path) t = Terminal.Terminal() t.do_script(cmd)
| 12,130
|
def __calc_date_time(self): # Set self.date_time, self.date, & self.time by using # time.strftime().
|
def __calc_date_time(self): # Set self.date_time, self.date, & self.time by using # time.strftime().
| 12,131
|
def format_exception_only(etype, value): """Format the exception part of a traceback. The arguments are the exception type and value such as given by sys.last_type and sys.last_value. The return value is a list of strings, each ending in a newline. Normally, the list contains a single string; however, for SyntaxError exceptions, it contains several lines that (when printed) display detailed information about where the syntax error occurred. The message indicating which exception occurred is the always last string in the list.""" list = [] if type(etype) == types.ClassType: stype = etype.__name__ else: stype = etype if value is None: list.append(str(stype) + '\n') else: if etype is SyntaxError: try: msg, (filename, lineno, offset, line) = value except: pass else: if not filename: filename = "<string>" list.append(' File "%s", line %d\n' % (filename, lineno)) i = 0 while i < len(line) and \ line[i] in string.whitespace: i = i+1 list.append(' %s\n' % string.strip(line)) s = ' ' for c in line[i:offset-1]: if c in string.whitespace: s = s + c else: s = s + ' ' list.append('%s^\n' % s) value = msg list.append('%s: %s\n' % (str(stype), str(value))) return list
|
def format_exception_only(etype, value): """Format the exception part of a traceback. The arguments are the exception type and value such as given by sys.last_type and sys.last_value. The return value is a list of strings, each ending in a newline. Normally, the list contains a single string; however, for SyntaxError exceptions, it contains several lines that (when printed) display detailed information about where the syntax error occurred. The message indicating which exception occurred is the always last string in the list.""" list = [] if type(etype) == types.ClassType: stype = etype.__name__ else: stype = etype if value is None: list.append(str(stype) + '\n') else: if etype is SyntaxError: try: msg, (filename, lineno, offset, line) = value except: pass else: if not filename: filename = "<string>" list.append(' File "%s", line %d\n' % (filename, lineno)) i = 0 while i < len(line) and \ line[i] in string.whitespace: i = i+1 list.append(' %s\n' % string.strip(line)) s = ' ' for c in line[i:offset-1]: if c in string.whitespace: s = s + c else: s = s + ' ' list.append('%s^\n' % s) value = msg list.append('%s: %s\n' % (str(stype), _some_str(value))) return list def _some_str(value): try: return str(value) except: return '<unprintable %s object>' % type(value).__name__
| 12,132
|
def loop(timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
|
def loop(timeout=30.0, use_poll=False, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
| 12,133
|
def loop(timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
|
def loop(timeout=30.0, use_poll=0, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map)
| 12,134
|
def __init__(self, sock=None, map=None): if map is None: self._map = socket_map else: self._map = map
|
def __init__(self, sock=None, map=None): if map is None: self._map = socket_map else: self._map = map
| 12,135
|
def listen(self, num): self.accepting = 1 if os.name == 'nt' and num > 5: num = 1 return self.socket.listen(num)
|
def listen(self, num): self.accepting = True if os.name == 'nt' and num > 5: num = 1 return self.socket.listen(num)
| 12,136
|
def connect(self, address): self.connected = 0 err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.connected = 1 self.handle_connect() else: raise socket.error, err
|
def connect(self, address): self.connected = False err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.connected = 1 self.handle_connect() else: raise socket.error, err
| 12,137
|
def connect(self, address): self.connected = 0 err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.connected = 1 self.handle_connect() else: raise socket.error, err
|
def connect(self, address): self.connected = 0 err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): return if err in (0, EISCONN): self.addr = address self.connected = True self.handle_connect() else: raise socket.error, err
| 12,138
|
def handle_read_event(self): if self.accepting: # for an accepting socket, getting a read implies # that we are connected if not self.connected: self.connected = 1 self.handle_accept() elif not self.connected: self.handle_connect() self.connected = 1 self.handle_read() else: self.handle_read()
|
def handle_read_event(self): if self.accepting: # for an accepting socket, getting a read implies # that we are connected if not self.connected: self.connected = True self.handle_accept() elif not self.connected: self.handle_connect() self.connected = True self.handle_read() else: self.handle_read()
| 12,139
|
def handle_read_event(self): if self.accepting: # for an accepting socket, getting a read implies # that we are connected if not self.connected: self.connected = 1 self.handle_accept() elif not self.connected: self.handle_connect() self.connected = 1 self.handle_read() else: self.handle_read()
|
def handle_read_event(self): if self.accepting: # for an accepting socket, getting a read implies # that we are connected if not self.connected: self.connected = True self.handle_accept() elif not self.connected: self.handle_connect() self.connected = True self.handle_read() else: self.handle_read()
| 12,140
|
def handle_write_event(self): # getting a write implies that we are connected if not self.connected: self.handle_connect() self.connected = 1 self.handle_write()
|
def handle_write_event(self): # getting a write implies that we are connected if not self.connected: self.handle_connect() self.connected = True self.handle_write()
| 12,141
|
def __init__(self, fd): dispatcher.__init__(self) self.connected = 1 # set it to non-blocking mode flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) self.set_file(fd)
|
def __init__(self, fd): dispatcher.__init__(self) self.connected = True # set it to non-blocking mode flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) flags = flags | os.O_NONBLOCK fcntl.fcntl(fd, fcntl.F_SETFL, flags) self.set_file(fd)
| 12,142
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" if not _can_read_reg: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
| 12,143
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (_HKEY_CLASSES_ROOT, _HKEY_LOCAL_MACHINE, _HKEY_CURRENT_USER, _HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
| 12,144
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = _RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
| 12,145
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = _RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
| 12,146
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except _RegError: break i = i + 1 except _RegError: pass L.sort() L.reverse() return L
| 12,147
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
|
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found.""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except _RegError: break i = i + 1 except _RegError: pass L.sort() L.reverse() return L
| 12,148
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" if not _can_read_reg: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
| 12,149
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (_HKEY_CLASSES_ROOT, _HKEY_LOCAL_MACHINE, _HKEY_CURRENT_USER, _HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
| 12,150
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = _RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
| 12,151
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = _RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
| 12,152
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except _RegError: break except _RegError: pass return L
| 12,153
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
|
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found.""" try: import win32api import win32con except ImportError: return [] L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except _RegError: break except _RegError: pass return L
| 12,154
|
def setuppimp(self, url): self.pimpprefs = pimp.PimpPreferences() self.pimpdb = pimp.PimpDatabase(self.pimpprefs) self.pimpinstaller = pimp.PimpInstaller(self.pimpdb) if not url: url = self.pimpprefs.pimpDatabase try: self.pimpdb.appendURL(url) except IOError, arg: return "Cannot open %s: %s" % (url, arg) return None
|
def setuppimp(self, url): self.pimpprefs = pimp.PimpPreferences() self.pimpdb = pimp.PimpDatabase(self.pimpprefs) self.pimpinstaller = pimp.PimpInstaller(self.pimpdb) if not url: url = self.pimpprefs.pimpDatabase try: self.pimpdb.appendURL(url) except IOError, arg: return "Cannot open %s: %s" % (url, arg) return self.pimpprefs.check()
| 12,155
|
def choose_boundary(): """Return a random string usable as a multipart boundary. The method used is so that it is *very* unlikely that the same string of characters will every occur again in the Universe, so the caller needn't check the data it is packing for the occurrence of the boundary. The boundary contains dots so you have to quote it in the header.""" global _prefix import time import random if _prefix is None: import socket hostid = socket.gethostbyname(socket.gethostname()) try: uid = `os.getuid()` except AttributeError: uid = '1' try: pid = `os.getpid()` except AttributeError: pid = '1' _prefix = hostid + '.' + uid + '.' + pid timestamp = '%.3f' % time.time() seed = `random.randint(0, 32767)` return _prefix + '.' + timestamp + '.' + seed
|
def choose_boundary(): """Return a string usable as a multipart boundary. The string chosen is unique within a single program run, and incorporates the user id (if available), process id (if available), and current time. So it's very unlikely the returned string appears in message text, but there's no guarantee. The boundary contains dots so you have to quote it in the header.""" global _prefix import time import random if _prefix is None: import socket hostid = socket.gethostbyname(socket.gethostname()) try: uid = `os.getuid()` except AttributeError: uid = '1' try: pid = `os.getpid()` except AttributeError: pid = '1' _prefix = hostid + '.' + uid + '.' + pid timestamp = '%.3f' % time.time() seed = `random.randint(0, 32767)` return _prefix + '.' + timestamp + '.' + seed
| 12,156
|
def choose_boundary(): """Return a random string usable as a multipart boundary. The method used is so that it is *very* unlikely that the same string of characters will every occur again in the Universe, so the caller needn't check the data it is packing for the occurrence of the boundary. The boundary contains dots so you have to quote it in the header.""" global _prefix import time import random if _prefix is None: import socket hostid = socket.gethostbyname(socket.gethostname()) try: uid = `os.getuid()` except AttributeError: uid = '1' try: pid = `os.getpid()` except AttributeError: pid = '1' _prefix = hostid + '.' + uid + '.' + pid timestamp = '%.3f' % time.time() seed = `random.randint(0, 32767)` return _prefix + '.' + timestamp + '.' + seed
|
def choose_boundary(): """Return a random string usable as a multipart boundary. The method used is so that it is *very* unlikely that the same string of characters will every occur again in the Universe, so the caller needn't check the data it is packing for the occurrence of the boundary. The boundary contains dots so you have to quote it in the header.""" global _prefix import time import random if _prefix is None: import socket hostid = socket.gethostbyname(socket.gethostname()) try: uid = `os.getuid()` except AttributeError: uid = '1' try: pid = `os.getpid()` except AttributeError: pid = '1' _prefix = hostid + '.' + uid + '.' + pid return "%s.%.3f.%d" % (_prefix, time.time(), _get_next_counter())
| 12,157
|
def replaceall(self): editor = findeditor(self) if not editor: return if self.visible: self.getparmsfromwindow() W.SetCursor("watch") find = self.parms["find"] if not find: return findlen = len(find) replace = self.parms["replace"] replacelen = len(replace) Text = editor.get() if not self.parms["casesens"]: find = string.lower(find) text = string.lower(Text) else: text = Text newtext = "" pos = 0 counter = 0 while 1: if self.parms["wholeword"]: wholewordRE = _makewholewordpattern(find) match = wholewordRE.search(text, pos) if match: pos = match.start(1) else: pos = -1 else: pos = string.find(text, find, pos) if pos < 0: break counter = counter + 1 text = text[:pos] + replace + text[pos + findlen:] Text = Text[:pos] + replace + Text[pos + findlen:] pos = pos + replacelen W.SetCursor("arrow") if counter: self.hide() import EasyDialogs from Carbon import Res editor.textchanged() editor.selectionchanged() editor.ted.WEUseText(Res.Resource(Text)) editor.ted.WECalText() editor.SetPort() editor.GetWindow().InvalWindowRect(editor._bounds) #editor.ted.WEUpdate(self.w.wid.GetWindowPort().visRgn) EasyDialogs.Message("Replaced %d occurrences" % counter)
|
def replaceall(self): editor = findeditor(self) if not editor: return if self.visible: self.getparmsfromwindow() W.SetCursor("watch") find = self.parms["find"] if not find: return findlen = len(find) replace = self.parms["replace"] replacelen = len(replace) Text = editor.get() if not self.parms["casesens"]: find = string.lower(find) text = string.lower(Text) else: text = Text newtext = "" pos = 0 counter = 0 while 1: if self.parms["wholeword"]: wholewordRE = _makewholewordpattern(find) match = wholewordRE.search(text, pos) if match: pos = match.start(1) else: pos = -1 else: pos = string.find(text, find, pos) if pos < 0: break counter = counter + 1 text = text[:pos] + replace + text[pos + findlen:] Text = Text[:pos] + replace + Text[pos + findlen:] pos = pos + replacelen W.SetCursor("arrow") if counter: self.hide() import EasyDialogs from Carbon import Res editor.textchanged() editor.selectionchanged() editor.ted.WEUseText(Res.Resource(Text)) editor.ted.WECalText() editor.SetPort() editor.GetWindow().InvalWindowRect(editor._bounds) #editor.ted.WEUpdate(self.w.wid.GetWindowPort().visRgn) EasyDialogs.Message("Replaced %d occurrences" % counter)
| 12,158
|
def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") tmpdir = os.path.realpath(tmpdir) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(os.getcwd())'], stdout=subprocess.PIPE, cwd=tmpdir) normcase = os.path.normcase self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir))
|
def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") cwd = os.getcwd() os.chdir(tmpdir) tmpdir = os.getcwd() os.chdir(cwd) p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(os.getcwd())'], stdout=subprocess.PIPE, cwd=tmpdir) normcase = os.path.normcase self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir))
| 12,159
|
def _test(): import doctest import sys verbose = "-v" in sys.argv for mod in modules: doctest.testmod(mod, verbose=verbose, report=0) doctest.master.summarize()
|
def _test(): import doctest import sys verbose = "-v" in sys.argv for mod in modules: doctest.testmod(mod, verbose=verbose, report=0) doctest.master.summarize()
| 12,160
|
def tabnanny(self, filename): import tabnanny import tokenize tabnanny.reset_globals() f = open(filename, 'r') try: tokenize.tokenize(f.readline, tabnanny.tokeneater) except tokenize.TokenError, msg: self.errorbox("Token error", "Token error:\n%s" % str(msg)) return 0 except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return 0 return 1
|
def tabnanny(self, filename): import tabnanny import tokenize f = open(filename, 'r') try: tokenize.tokenize(f.readline, tabnanny.tokeneater) except tokenize.TokenError, msg: self.errorbox("Token error", "Token error:\n%s" % str(msg)) return 0 except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return 0 return 1
| 12,161
|
def tabnanny(self, filename): import tabnanny import tokenize tabnanny.reset_globals() f = open(filename, 'r') try: tokenize.tokenize(f.readline, tabnanny.tokeneater) except tokenize.TokenError, msg: self.errorbox("Token error", "Token error:\n%s" % str(msg)) return 0 except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return 0 return 1
|
def tabnanny(self, filename): import tabnanny import tokenize tabnanny.reset_globals() f = open(filename, 'r') try: tabnanny.process_tokens(tokenize.generate_tokens(f.readline)) except tokenize.TokenError, msg: self.errorbox("Token error", "Token error:\n%s" % str(msg)) return 0 except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return 0 return 1
| 12,162
|
def __init__(self, sock, debuglevel=0): self.fp = sock.makefile('rb', 0) self.debuglevel = debuglevel
|
def __init__(self, sock, debuglevel=0, strict=0): self.fp = sock.makefile('rb', 0) self.debuglevel = debuglevel
| 12,163
|
def _read_status(self): line = self.fp.readline() if self.debuglevel > 0: print "reply:", repr(line) try: [version, status, reason] = line.split(None, 2) except ValueError: try: [version, status] = line.split(None, 1) reason = "" except ValueError: version = "HTTP/0.9" status = "200" reason = "" if version[:5] != 'HTTP/': self.close() raise BadStatusLine(line)
|
def _read_status(self): line = self.fp.readline() if self.debuglevel > 0: print "reply:", repr(line) try: [version, status, reason] = line.split(None, 2) except ValueError: try: [version, status] = line.split(None, 1) reason = "" except ValueError: version = "HTTP/0.9" status = "200" reason = "" if version[:5] != 'HTTP/': self.close() raise BadStatusLine(line)
| 12,164
|
def getheader(self, name, default=None): if self.msg is None: raise ResponseNotReady() return self.msg.getheader(name, default)
|
def getheader(self, name, default=None): if self.msg is None: raise ResponseNotReady() return self.msg.getheader(name, default)
| 12,165
|
def __init__(self, host, port=None): self.sock = None self.__response = None self.__state = _CS_IDLE
|
def __init__(self, host, port=None): self.sock = None self.__response = None self.__state = _CS_IDLE
| 12,166
|
def getresponse(self): "Get the response from the server."
|
def getresponse(self): "Get the response from the server."
| 12,167
|
def __init__(self, host, port=None, key_file=None, cert_file=None): HTTPConnection.__init__(self, host, port) self.key_file = key_file self.cert_file = cert_file
|
def __init__(self, host, port=None, key_file=None, cert_file=None, strict=None): HTTPConnection.__init__(self, host, port, strict) self.key_file = key_file self.cert_file = cert_file
| 12,168
|
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
|
def __init__(self, host='', port=None, strict=None): "Provide a default host, since the superclass requires one."
| 12,169
|
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
|
def __init__(self, host='', port=None): "Provide a default host, since the superclass requires one."
| 12,170
|
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
|
def __init__(self, host='', port=None, key_file=None, cert_file=None, strict=None): # provide a default host, pass the X509 cert info
| 12,171
|
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
|
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
| 12,172
|
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
|
def __init__(self, host='', port=None, **x509): # provide a default host, pass the X509 cert info
| 12,173
|
def dist(distname='',version='',id='', supported_dists=('SuSE','debian','redhat','mandrake')): """ Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. Returns a tuple (distname,version,id) which default to the args given as parameters. """ try: etc = os.listdir('/etc') except os.error: # Probably not a Unix system return distname,version,id for file in etc: m = _release_filename.match(file) if m: _distname,dummy = m.groups() if _distname in supported_dists: distname = _distname break else: return _dist_try_harder(distname,version,id) f = open('/etc/'+file,'r') firstline = f.readline() f.close() m = _release_version.search(firstline) if m: _version,_id = m.groups() if _version: version = _version if _id: id = _id else: # Unkown format... take the first two words l = string.split(string.strip(firstline)) if l: version = l[0] if len(l) > 1: id = l[1] return distname,version,id
|
def dist(distname='',version='',id='', supported_dists=('SuSE', 'debian', 'fedora', 'redhat', 'mandrake')): """ Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. Returns a tuple (distname,version,id) which default to the args given as parameters. """ try: etc = os.listdir('/etc') except os.error: # Probably not a Unix system return distname,version,id for file in etc: m = _release_filename.match(file) if m: _distname,dummy = m.groups() if _distname in supported_dists: distname = _distname break else: return _dist_try_harder(distname,version,id) f = open('/etc/'+file,'r') firstline = f.readline() f.close() m = _release_version.search(firstline) if m: _version,_id = m.groups() if _version: version = _version if _id: id = _id else: # Unkown format... take the first two words l = string.split(string.strip(firstline)) if l: version = l[0] if len(l) > 1: id = l[1] return distname,version,id
| 12,174
|
def run (self):
|
def run (self):
| 12,175
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
| 12,176
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
| 12,177
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
|
def create_inifile (self): # Create an inifile containing data describing the installation. # This could be done without creating a real file, but # a file is (at least) useful for debugging bdist_wininst.
| 12,178
|
def create_exe (self, arcname, fullname): import struct, zlib
|
def create_exe (self, arcname, fullname): import struct, zlib
| 12,179
|
def create_exe (self, arcname, fullname): import struct, zlib
|
def create_exe (self, arcname, fullname): import struct, zlib
| 12,180
|
def create_exe (self, arcname, fullname): import struct, zlib
|
def create_exe (self, arcname, fullname): import struct, zlib
| 12,181
|
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
|
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
| 12,182
|
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
|
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
| 12,183
|
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
|
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
| 12,184
|
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
|
def get_exe_bytes (self): import zlib, base64 return zlib.decompress (base64.decodestring (EXEDATA))
| 12,185
|
def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args)
|
def testboth(formatstr, *args): testformat(formatstr, *args) testformat(unicode(formatstr), *args)
| 12,186
|
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* # Skip the date. /bin/ls # and end with the name of the file. '''
|
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* # Skip the date. /bin/ls # and end with the name of the file. '''
| 12,187
|
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* # Skip the date. /bin/ls # and end with the name of the file. '''
|
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''d......... # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* # Skip the date. /bin/ls # and end with the name of the file. '''
| 12,188
|
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* # Skip the date. /bin/ls # and end with the name of the file. '''
|
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* # Skip the date. /. # and end with the name of the file. '''
| 12,189
|
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* # Skip the date. /bin/ls # and end with the name of the file. '''
|
def test_getstatus(self): # This pattern should match 'ls -ld /bin/ls' on any posix # system, however perversely configured. pat = r'''[l-]..x..x..x # It is executable. (May be a symlink.) \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. [^/]* # Skip the date. /bin/ls # and end with the name of the file. '''
| 12,190
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
| 12,191
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
| 12,192
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
| 12,193
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
| 12,194
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
| 12,195
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
| 12,196
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
| 12,197
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True __getitem__(self,>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True i):>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True if>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True i>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True >=>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True 0>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True and>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True i>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True <>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True 3:>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True return>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True i>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True raise>>> class Seq: ... def __getitem__(self, i): ... if i >= 0 and i < 3: return i ... raise IndexError ... >>> a, b, c = Seq() >>> a == 0 and b == 1 and c == 2 True IndexError
| 12,198
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
|
def __getitem__(self, i): if i >= 0 and i < 3: return i raise IndexError
| 12,199
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.