bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
| 15,100
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
| 15,101
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
|
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', ''))
| 15,102
|
def nts(s): """Convert a null-terminated string buffer to a python string. """ return s.split(NUL, 1)[0]
|
def nts(s): """Convert a null-terminated string buffer to a python string. """ return s.rstrip(NUL)
| 15,103
|
def tobuf(self): """Return a tar header block as a 512 byte string. """ name = self.name
|
def tobuf(self): """Return a tar header block as a 512 byte string. """ name = self.name
| 15,104
|
def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ self.name = name
|
def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ self.name = name
| 15,105
|
def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw")
|
def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw")
| 15,106
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
| 15,107
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
| 15,108
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
| 15,109
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
| 15,110
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
|
def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m
| 15,111
|
def proc_gnulong(self, tarinfo): """Evaluate the blocks that hold a GNU longname or longlink member. """ buf = "" name = None linkname = None count = tarinfo.size while count > 0: block = self.fileobj.read(BLOCKSIZE) buf += block self.offset += BLOCKSIZE count -= BLOCKSIZE
|
def proc_gnulong(self, tarinfo): """Evaluate the blocks that hold a GNU longname or longlink member. """ buf = "" name = None linkname = None count = tarinfo.size while count > 0: block = self.fileobj.read(BLOCKSIZE) buf += block self.offset += BLOCKSIZE count -= BLOCKSIZE
| 15,112
|
def walk_packages(path=None, prefix='', onerror=None): """Yield submodule names+loaders recursively, for path or sys.path""" def seen(p, m={}): if p in m: return True m[p] = True for importer, name, ispkg in iter_modules(path, prefix): yield importer, name, ispkg if ispkg: try: __import__(name) except ImportError: if onerror is not None: onerror() else: path = getattr(sys.modules[name], '__path__', None) or [] # don't traverse path items we've seen before path = [p for p in path if not seen(p)] for item in walk_packages(path, name+'.'): yield item
|
def walk_packages(path=None, prefix='', onerror=None): """Yields (module_loader, name, ispkg) for all modules recursively on path, or, if path is None, all accessible modules. 'path' should be either None or a list of paths to look for modules in. 'prefix' is a string to output on the front of every module name on output. Note that this function must import all *packages* (NOT all modules!) on the given path, in order to access the __path__ attribute to find submodules. 'onerror' is a function which gets called with one argument (the name of the package which was being imported) if an ImportError occurs trying to import a package. By default the ImportError is caught and ignored. Examples: walk_packages() : list all modules python can access walk_packages(ctypes.__path__, ctypes.__name__+'.') : list all submodules of ctypes """ def seen(p, m={}): if p in m: return True m[p] = True for importer, name, ispkg in iter_modules(path, prefix): yield importer, name, ispkg if ispkg: try: __import__(name) except ImportError: if onerror is not None: onerror() else: path = getattr(sys.modules[name], '__path__', None) or [] # don't traverse path items we've seen before path = [p for p in path if not seen(p)] for item in walk_packages(path, name+'.'): yield item
| 15,113
|
def seen(p, m={}): if p in m: return True m[p] = True
|
def seen(p, m={}): if p in m: return True m[p] = True
| 15,114
|
def seen(p, m={}): if p in m: return True m[p] = True
|
def seen(p, m={}): if p in m: return True m[p] = True
| 15,115
|
def iter_modules(path=None, prefix=''): """Yield submodule names+loaders for path or sys.path""" if path is None: importers = iter_importers() else: importers = map(get_importer, path) yielded = {} for i in importers: for name, ispkg in iter_importer_modules(i, prefix): if name not in yielded: yielded[name] = 1 yield i, name, ispkg
|
def iter_modules(path=None, prefix=''): """Yields (module_loader, name, ispkg) for all submodules on path, or, if path is None, all top-level modules on sys.path. 'path' should be either None or a list of paths to look for modules in. 'prefix' is a string to output on the front of every module name on output. """ if path is None: importers = iter_importers() else: importers = map(get_importer, path) yielded = {} for i in importers: for name, ispkg in iter_importer_modules(i, prefix): if name not in yielded: yielded[name] = 1 yield i, name, ispkg
| 15,116
|
def tell(self): if self.level > 0: return self.lastpos return self.fp.tell() - self.start
|
def tell(self): if self.level > 0: return self.lastpos return self.fp.tell() - self.start
| 15,117
|
def test_main(verbose=None): from test import test_sets test_support.run_unittest( TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, )
|
def test_main(verbose=None): from test import test_sets tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests) if test_support.is_resource_enabled('network'): tests += (NetworkTests,) test_support.run_unittest(*tests)
| 15,118
|
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): assert output_dir is not None obj_names = [] for src_name in source_filenames: base, ext = os.path.splitext(src_name) if ext not in self.src_extensions: raise UnknownFileError, \ "unknown file type '%s' (from '%s')" % (ext, src_name) if strip_dir: base = os.path.basename(base) obj_names.append(os.path.join(output_dir, base + self.obj_extension)) return obj_names
|
def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): if output_dir is None: output_dir = '' obj_names = [] for src_name in source_filenames: base, ext = os.path.splitext(src_name) if ext not in self.src_extensions: raise UnknownFileError, \ "unknown file type '%s' (from '%s')" % (ext, src_name) if strip_dir: base = os.path.basename(base) obj_names.append(os.path.join(output_dir, base + self.obj_extension)) return obj_names
| 15,119
|
def main(): # turn off warnings when deprecated modules are imported import warnings warnings.filterwarnings("ignore",category=DeprecationWarning) setup(# PyPI Metadata (PEP 301) name = "Python", version = sys.version.split()[0], url = "http://www.python.org/%s" % sys.version[:3], maintainer = "Guido van Rossum and the Python community", maintainer_email = "python-dev@python.org", description = "A high-level object-oriented programming language", long_description = SUMMARY.strip(), license = "PSF license", classifiers = filter(None, CLASSIFIERS.split("\n")), platforms = ["Many"], # Build info cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall, 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. ext_modules=[Extension('struct', ['structmodule.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', 'Lib/smtpd.py'] )
|
def main(): # turn off warnings when deprecated modules are imported import warnings warnings.filterwarnings("ignore",category=DeprecationWarning) setup(# PyPI Metadata (PEP 301) name = "Python", version = sys.version.split()[0], url = "http://www.python.org/%s" % sys.version[:3], maintainer = "Guido van Rossum and the Python community", maintainer_email = "python-dev@python.org", description = "A high-level object-oriented programming language", long_description = SUMMARY.strip(), license = "PSF license", classifiers = filter(None, CLASSIFIERS.split("\n")), platforms = ["Many"], # Build info cmdclass = {'build_ext':PyBuildExt, 'install':PyBuildInstall, 'install_lib':PyBuildInstallLib}, # The struct module is defined here, because build_ext won't be # called unless there's at least one extension module defined. ext_modules=[Extension('_struct', ['_struct.c'])], # Scripts to install scripts = ['Tools/scripts/pydoc', 'Tools/scripts/idle', 'Lib/smtpd.py'] )
| 15,120
|
def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None): """Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.""" args = [self._w, 'search'] if forwards: args.append('-forwards') if backwards: args.append('-backwards') if exact: args.append('-exact') if regexp: args.append('-regexp') if nocase: args.append('-nocase') if count: args.append('-count'); args.append(count) if pattern[0] == '-': args.append('--') args.append(pattern) args.append(index) if stopindex: args.append(stopindex) return self.tk.call(tuple(args))
|
def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None, elide=None): """Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.""" args = [self._w, 'search'] if forwards: args.append('-forwards') if backwards: args.append('-backwards') if exact: args.append('-exact') if regexp: args.append('-regexp') if nocase: args.append('-nocase') if count: args.append('-count'); args.append(count) if pattern[0] == '-': args.append('--') args.append(pattern) args.append(index) if stopindex: args.append(stopindex) return self.tk.call(tuple(args))
| 15,121
|
def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish')
|
def test_checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish')
| 15,122
|
def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish')
|
def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish')
| 15,123
|
def checkSetMinor(self): im = MIMEImage(self._imgdata, 'fish') self.assertEqual(im.get_type(), 'image/fish')
|
def test_checkSetMinor(self): im = MIMEImage(self._imgdata, 'fish') self.assertEqual(im.get_type(), 'image/fish')
| 15,124
|
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
|
defredirect_request(self,req,fp,code,msg,headers):"""ReturnaRequestorNoneinresponsetoaredirect.
| 15,125
|
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
|
def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect.
| 15,126
|
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
|
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
| 15,127
|
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
|
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
| 15,128
|
def test_tzinfo_fromtimestamp(self): import time meth = self.theclass.fromtimestamp ts = time.time() # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up). base = meth(ts) # Try with and without naming the keyword. off42 = FixedOffset(42, "42") another = meth(ts, off42) again = meth(ts, tz=off42) self.failUnless(another.tzinfo is again.tzinfo) self.assertEqual(another.utcoffset(), timedelta(minutes=42)) # Bad argument with and w/o naming the keyword. self.assertRaises(TypeError, meth, ts, 16) self.assertRaises(TypeError, meth, ts, tzinfo=16) # Bad keyword name. self.assertRaises(TypeError, meth, ts, tinfo=off42) # Too many args. self.assertRaises(TypeError, meth, ts, off42, off42) # Too few args. self.assertRaises(TypeError, meth)
|
def test_tzinfo_fromtimestamp(self): import time meth = self.theclass.fromtimestamp ts = time.time() # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up). base = meth(ts) # Try with and without naming the keyword. off42 = FixedOffset(42, "42") another = meth(ts, off42) again = meth(ts, tz=off42) self.failUnless(another.tzinfo is again.tzinfo) self.assertEqual(another.utcoffset(), timedelta(minutes=42)) # Bad argument with and w/o naming the keyword. self.assertRaises(TypeError, meth, ts, 16) self.assertRaises(TypeError, meth, ts, tzinfo=16) # Bad keyword name. self.assertRaises(TypeError, meth, ts, tinfo=off42) # Too many args. self.assertRaises(TypeError, meth, ts, off42, off42) # Too few args. self.assertRaises(TypeError, meth)
| 15,129
|
def _draw_turtle(self,position=[]): if not self._tracing: return if position == []: position = self._position x,y = position distance = 8 dx = distance * cos(self._angle*self._invradian) dy = distance * sin(self._angle*self._invradian) self._delete_turtle() self._arrow = _canvas.create_line(x-dx,y+dy,x,y, width=self._width, arrow="last", capstyle="round", fill=self._color) self._canvas.update()
|
def _draw_turtle(self,position=[]): if not self._tracing: return if position == []: position = self._position x,y = position distance = 8 dx = distance * cos(self._angle*self._invradian) dy = distance * sin(self._angle*self._invradian) self._delete_turtle() self._arrow = self._canvas.create_line(x-dx,y+dy,x,y, width=self._width, arrow="last", capstyle="round", fill=self._color) self._canvas.update()
| 15,130
|
def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not gusi_opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, gusi_opr = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away print 'DBG interaction' result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, (options, creator, type, delaycons) = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) id, type, name = gusi_opr.GetResInfo() if gusi_opr.HomeResFile() == app_handle and id == OVERRIDE_GUSI_ID: gusi_opr.data = newdata gusi_opr.ChangedResource() else: ngusi_opr = Resource(newdata) ngusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle)
|
def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_changed = getprefdir(OVERRIDE_DIRECTORY_ID) if fss == None: if notfound: notfound = notfound + ', directory' else: notfound = 'directory' fss, dummy, dummy2 = getprefdir(DIRECTORY_ID) if fss == None: fss = macfs.FSSpec(os.getcwd()) fss_changed = 1 options, opr = getoptions(OVERRIDE_OPTIONS_ID) if not opr: if notfound: notfound = notfound + ', options' else: notfound = 'options' options, dummy = getoptions(OPTIONS_ID) saved_options = options[:] creator, type, delaycons, gusi_opr = getgusioptions(OVERRIDE_GUSI_ID) if not gusi_opr: if notfound: notfound = notfound + ', GUSI options' else: notfound = 'GUSI options' creator, type, delaycons, gusi_opr = getgusioptions(GUSI_ID) saved_gusi_options = creator, type, delaycons dummy = dummy2 = None # Discard them. if notfound: message('Warning: initial %s taken from system-wide defaults'%notfound) # Let the user play away result = interact(l, fss, (options, creator, type, delaycons), name) # See what we have to update, and how if result == None: sys.exit(0) pathlist, nfss, (options, creator, type, delaycons) = result if nfss != fss: fss_changed = 1 if fss_changed: alias = nfss.NewAlias() if dr: dr.data = alias.data dr.ChangedResource() else: dr = Resource(alias.data) dr.AddResource('alis', OVERRIDE_DIRECTORY_ID, '') if pathlist != l: if pathlist == []: if sr.HomeResFile() == app_handle: sr.RemoveResource() elif sr and sr.HomeResFile() == app_handle: sr.data = listtores(pathlist) sr.ChangedResource() else: sr = Resource(listtores(pathlist)) sr.AddResource('STR#', OVERRIDE_PATH_STRINGS_ID, '') if options != saved_options: newdata = reduce(lambda x, y: x+chr(y), options, '') if opr and opr.HomeResFile() == app_handle: opr.data = newdata opr.ChangedResource() else: opr = Resource(newdata) opr.AddResource('Popt', OVERRIDE_OPTIONS_ID, '') if (creator, type, delaycons) != saved_gusi_options: newdata = setgusioptions(gusi_opr, creator, type, delaycons) id, type, name = gusi_opr.GetResInfo() if gusi_opr.HomeResFile() == app_handle and id == OVERRIDE_GUSI_ID: gusi_opr.data = newdata gusi_opr.ChangedResource() else: ngusi_opr = Resource(newdata) ngusi_opr.AddResource('GU\267I', OVERRIDE_GUSI_ID, '') CloseResFile(app_handle)
| 15,131
|
def _read(self, size=1024): if self.fileobj is None: raise EOFError, "Reached EOF"
|
def _read(self, size=1024): if self.fileobj is None: raise EOFError, "Reached EOF"
| 15,132
|
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
|
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
| 15,133
|
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
|
def readline(self): bufs = [] orig_size = size readsize = min(100, size) while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
| 15,134
|
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
|
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
| 15,135
|
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
|
def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2
| 15,136
|
def test_noinherit(self): # _mkstemp_inner file handles are not inherited by child processes if not has_spawnl: return # ugh, can't use TestSkipped.
|
def test_noinherit(self): # _mkstemp_inner file handles are not inherited by child processes if not has_spawnl: return # ugh, can't use TestSkipped.
| 15,137
|
def createMessage(self, dir): t = int(time.time() % 1000000) pid = self._counter self._counter += 1 filename = os.extsep.join((str(t), str(pid), "myhostname", "mydomain")) tmpname = os.path.join(self._dir, "tmp", filename) newname = os.path.join(self._dir, dir, filename) fp = open(tmpname, "w") self._msgfiles.append(tmpname) fp.write(DUMMY_MESSAGE) fp.close() if hasattr(os, "link"): os.link(tmpname, newname) else: fp = open(newname, "w") fp.write(DUMMY_MESSAGE) fp.close() self._msgfiles.append(newname)
|
def createMessage(self, dir, mbox=False): t = int(time.time() % 1000000) pid = self._counter self._counter += 1 filename = os.extsep.join((str(t), str(pid), "myhostname", "mydomain")) tmpname = os.path.join(self._dir, "tmp", filename) newname = os.path.join(self._dir, dir, filename) fp = open(tmpname, "w") self._msgfiles.append(tmpname) fp.write(DUMMY_MESSAGE) fp.close() if hasattr(os, "link"): os.link(tmpname, newname) else: fp = open(newname, "w") fp.write(DUMMY_MESSAGE) fp.close() self._msgfiles.append(newname)
| 15,138
|
def _GetContents(self): "Read in the table of contents for the zip file" fp = self.fp fp.seek(-22, 2) # Start of end-of-archive record filesize = fp.tell() + 22 # Get file size endrec = fp.read(22) # Archive must not end with a comment! if endrec[0:4] != stringEndArchive or endrec[-2:] != "\000\000": raise BadZipfile, "File is not a zip file, or ends with a comment" endrec = struct.unpack(structEndArchive, endrec) if self.debug > 1: print endrec size_cd = endrec[5] # bytes in central directory offset_cd = endrec[6] # offset of central directory x = filesize - 22 - size_cd # "concat" is zero, unless zip was concatenated to another file concat = x - offset_cd if self.debug > 2: print "given, inferred, offset", offset_cd, x, concat # self.start_dir: Position of start of central directory self.start_dir = offset_cd + concat fp.seek(self.start_dir, 0) total = 0 while total < size_cd: centdir = fp.read(46) total = total + 46 if centdir[0:4] != stringCentralDir: raise BadZipfile, "Bad magic number for central directory" centdir = struct.unpack(structCentralDir, centdir) if self.debug > 2: print centdir filename = fp.read(centdir[12]) # Create ZipInfo instance to store file information x = ZipInfo(filename) x.extra = fp.read(centdir[13]) x.comment = fp.read(centdir[14]) total = total + centdir[12] + centdir[13] + centdir[14] x.header_offset = centdir[18] + concat x.file_offset = x.header_offset + 30 + centdir[12] + centdir[13] (x.create_version, x.create_system, x.extract_version, x.reserved, x.flag_bits, x.compress_type, t, d, x.CRC, x.compress_size, x.file_size) = centdir[1:12] x.volume, x.internal_attr, x.external_attr = centdir[15:18] # Convert date/time code to (year, month, day, hour, min, sec) x.date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F, t>>11, (t>>5)&0x3F, t&0x1F * 2 ) self.filelist.append(x) self.NameToInfo[x.filename] = x if self.debug > 2: print "total", total for data in self.filelist: fp.seek(data.header_offset, 0) fheader = fp.read(30) if fheader[0:4] != stringFileHeader: raise BadZipfile, "Bad magic number for file header" fheader = struct.unpack(structFileHeader, fheader) fname = fp.read(fheader[10]) if fname != data.filename: raise RuntimeError, \
|
def _GetContents(self): "Read in the table of contents for the zip file" fp = self.fp fp.seek(-22, 2) # Start of end-of-archive record filesize = fp.tell() + 22 # Get file size endrec = fp.read(22) # Archive must not end with a comment! if endrec[0:4] != stringEndArchive or endrec[-2:] != "\000\000": raise BadZipfile, "File is not a zip file, or ends with a comment" endrec = struct.unpack(structEndArchive, endrec) if self.debug > 1: print endrec size_cd = endrec[5] # bytes in central directory offset_cd = endrec[6] # offset of central directory x = filesize - 22 - size_cd # "concat" is zero, unless zip was concatenated to another file concat = x - offset_cd if self.debug > 2: print "given, inferred, offset", offset_cd, x, concat # self.start_dir: Position of start of central directory self.start_dir = offset_cd + concat fp.seek(self.start_dir, 0) total = 0 while total < size_cd: centdir = fp.read(46) total = total + 46 if centdir[0:4] != stringCentralDir: raise BadZipfile, "Bad magic number for central directory" centdir = struct.unpack(structCentralDir, centdir) if self.debug > 2: print centdir filename = fp.read(centdir[12]) # Create ZipInfo instance to store file information x = ZipInfo(filename) x.extra = fp.read(centdir[13]) x.comment = fp.read(centdir[14]) total = total + centdir[12] + centdir[13] + centdir[14] x.header_offset = centdir[18] + concat x.file_offset = x.header_offset + 30 + centdir[12] + centdir[13] (x.create_version, x.create_system, x.extract_version, x.reserved, x.flag_bits, x.compress_type, t, d, x.CRC, x.compress_size, x.file_size) = centdir[1:12] x.volume, x.internal_attr, x.external_attr = centdir[15:18] # Convert date/time code to (year, month, day, hour, min, sec) x.date_time = ( (d>>9)+1980, (d>>5)&0xF, d&0x1F, t>>11, (t>>5)&0x3F, (t&0x1F) * 2 ) self.filelist.append(x) self.NameToInfo[x.filename] = x if self.debug > 2: print "total", total for data in self.filelist: fp.seek(data.header_offset, 0) fheader = fp.read(30) if fheader[0:4] != stringFileHeader: raise BadZipfile, "Bad magic number for file header" fheader = struct.unpack(structFileHeader, fheader) fname = fp.read(fheader[10]) if fname != data.filename: raise RuntimeError, \
| 15,139
|
def AS_TYPE_64BIT(as_): return \
|
def AS_TYPE_64BIT(as): return \
| 15,140
|
def handle_request (self, request): [path, params, query, fragment] = request.split_uri()
|
def handle_request (self, request): [path, params, query, fragment] = request.split_uri()
| 15,141
|
def wait(self, timeout=None): self.__cond.acquire() if not self.__flag: self.__cond.wait(timeout) self.__cond.release()
|
defwait(self,timeout=None):self.__cond.acquire()ifnotself.__flag:self.__cond.wait(timeout)self.__cond.release()
| 15,142
|
def _fast_quote(s): global _fast_safe if _fast_safe is None: _fast_safe = {} for c in _fast_safe_test: _fast_safe[c] = c res = list(s) for i in range(len(res)): c = res[i] if not _fast_safe.has_key(c): res[i] = '%%%02x' % ord(c) return ''.join(res)
|
def _fast_quote(s): global _fast_safe if _fast_safe is None: _fast_safe = {} for c in _fast_safe_test: _fast_safe[c] = c res = list(s) for i in range(len(res)): c = res[i] if not _fast_safe.has_key(c): res[i] = '%%%02X' % ord(c) return ''.join(res)
| 15,143
|
def quote(s, safe = '/'): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. """ safe = always_safe + safe if _fast_safe_test == safe: return _fast_quote(s) res = list(s) for i in range(len(res)): c = res[i] if c not in safe: res[i] = '%%%02x' % ord(c) return ''.join(res)
|
def quote(s, safe = '/'): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," Each of these characters is reserved in some component of a URL, but not necessarily in all of them. By default, the quote function is intended for quoting the path section of a URL. Thus, it will not encode '/'. This character is reserved, but in typical usage the quote function is being called on a path where the existing slash characters are used as reserved characters. """ safe = always_safe + safe if _fast_safe_test == safe: return _fast_quote(s) res = list(s) for i in range(len(res)): c = res[i] if c not in safe: res[i] = '%%%02X' % ord(c) return ''.join(res)
| 15,144
|
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "asdl.h"\n' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close() if SRC_DIR: p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c") else: p = "%s-ast.c" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "Python.h"' print >> f, '#include "%s-ast.h"' % mod.name print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close()
|
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "asdl.h"\n' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close() if SRC_DIR: p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c") else: p = "%s-ast.c" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "Python.h"' print >> f, '#include "%s-ast.h"' % mod.name print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close()
| 15,145
|
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "asdl.h"\n' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close() if SRC_DIR: p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c") else: p = "%s-ast.c" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "Python.h"' print >> f, '#include "%s-ast.h"' % mod.name print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close()
|
def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "asdl.h"\n' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close() if SRC_DIR: p = os.path.join(SRC_DIR, str(mod.name) + "-ast.c") else: p = "%s-ast.c" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, '#include "Python.h"' print >> f, '#include "%s-ast.h"' % mod.name print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close()
| 15,146
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
| 15,147
|
def minus(a, b): if len(a) < len(b): a, b = b, a # make sure a is the longest res = a[:] # make a copy for i in range(len(b)): res[i] = res[i] - b[i] return normalize(res)
|
def minus(a, b): if len(a) < len(b): a, b = b, a # make sure a is the longest res = a[:] # make a copy for i in range(len(b)): res[i] = res[i] - b[i] return normalize(res)
| 15,148
|
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
|
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
| 15,149
|
def find_modules (self): """Finds individually-specified Python modules, ie. those listed by module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no packages, no dots) module name, and 'filename' is the path to the ".py" file (relative to the distribution root) that implements the module. """
|
def find_modules (self): """Finds individually-specified Python modules, ie. those listed by module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no packages, no dots) module name, and 'filename' is the path to the ".py" file (relative to the distribution root) that implements the module. """
| 15,150
|
def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin("http:" + url, newurl) if data is None: return self.open(newurl) else: return self.open(newurl, data)
|
def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin(self.type + ":" + url, newurl) if data is None: return self.open(newurl) else: return self.open(newurl, data)
| 15,151
|
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
|
def main(): build_all = "-a" in sys.argv if sys.argv[1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
| 15,152
|
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
|
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
| 15,153
|
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
|
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
| 15,154
|
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[-1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
|
def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "VC-WIN64I" do_script = "ms\\do_win64i" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM" elif sys.argv[1] == "ReleaseAMD64": arch="amd64" debug=False configure = "VC-WIN64A" do_script = "ms\\do_win64a" makefile = "ms\\nt.mak" os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON" make_flags = "" if build_all: make_flags = "-a" # perl should be on the path, but we also look in "\perl" and "c:\\perl" # as "well known" locations perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"]) perl = find_working_perl(perls) if perl is None: sys.exit(1) print "Found a working perl at '%s'" % (perl,) # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. ssl_dir = find_best_ssl_dir(("../..",)) if ssl_dir is None: sys.exit(1) old_cd = os.getcwd() try: os.chdir(ssl_dir) # If the ssl makefiles do not exist, we invoke Perl to generate them. if not os.path.isfile(makefile): print "Creating the makefiles..." # Put our working Perl at the front of our path os.environ["PATH"] = os.path.split(perl)[0] + \ os.pathsep + \ os.environ["PATH"] if arch=="x86": run_32all_py() else: run_configure(configure, do_script) # Now run make. print "Executing nmake over the ssl makefiles..." rc = os.system("nmake /nologo -f "+makefile) if rc: print "Executing d32.mak failed" print rc sys.exit(rc) finally: os.chdir(old_cd) # And finally, we can build the _ssl module itself for Python. defs = "SSL_DIR=%s" % (ssl_dir,) if debug: defs = defs + " " + "DEBUG=1" rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) sys.exit(rc)
| 15,155
|
def setup(self): if self.mainprogram is None and self.executable is None: raise TypeError, ("must specify either or both of " "'executable' and 'mainprogram'")
|
def setup(self): if self.mainprogram is None and self.executable is None: raise TypeError, ("must specify either or both of " "'executable' and 'mainprogram'")
| 15,156
|
def __init__(self, file=None): if not file: file = os.path.join(os.environ['HOME'], ".netrc") try: fp = open(file) except: return None self.hosts = {} self.macros = {} lexer = shlex.shlex(fp)
|
def __init__(self, file=None): if not file: file = os.path.join(os.environ['HOME'], ".netrc") fp = open(file) self.hosts = {} self.macros = {} lexer = shlex.shlex(fp)
| 15,157
|
def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == entry.title: self.error("You didn't make any changes!") return
|
def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == entry.title: self.error("You didn't make any changes!") return
| 15,158
|
def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == entry.title: self.error("You didn't make any changes!") return
|
def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == entry.title: self.error("You didn't make any changes!") return
| 15,159
|
def runtest(hier, code): root = tempfile.mktemp() mkhier(root, hier) savepath = sys.path[:] codefile = tempfile.mktemp() f = open(codefile, "w") f.write(code) f.close() try: sys.path.insert(0, root) if verbose: print "sys.path =", sys.path try: execfile(codefile, globals(), {}) except: traceback.print_exc() finally: sys.path[:] = savepath try: cleanout(root) except (os.error, IOError): pass os.remove(codefile)
|
def runtest(hier, code): root = tempfile.mktemp() mkhier(root, hier) savepath = sys.path[:] codefile = tempfile.mktemp() f = open(codefile, "w") f.write(code) f.close() try: sys.path.insert(0, root) if verbose: print "sys.path =", sys.path try: execfile(codefile, globals(), {}) except: traceback.print_exc(file=sys.stdout) finally: sys.path[:] = savepath try: cleanout(root) except (os.error, IOError): pass os.remove(codefile)
| 15,160
|
def runtest(hier, code): root = tempfile.mktemp() mkhier(root, hier) savepath = sys.path[:] codefile = tempfile.mktemp() f = open(codefile, "w") f.write(code) f.close() try: sys.path.insert(0, root) if verbose: print "sys.path =", sys.path try: execfile(codefile, globals(), {}) except: traceback.print_exc() finally: sys.path[:] = savepath try: cleanout(root) except (os.error, IOError): pass os.remove(codefile)
|
def runtest(hier, code): root = tempfile.mktemp() mkhier(root, hier) savepath = sys.path[:] codefile = tempfile.mktemp() f = open(codefile, "w") f.write(code) f.close() try: sys.path.insert(0, root) if verbose: print "sys.path =", sys.path try: execfile(codefile, globals(), {}) except: traceback.print_exc() finally: sys.path[:] = savepath try: cleanout(root) except (os.error, IOError): pass os.remove(codefile)
| 15,161
|
def __getitem__(self, i): return self.seq[i]
|
def __getitem__(self, i): return self.seq[i]
| 15,162
|
def get_platform (): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. for IRIX the architecture isn't particularly important (IRIX only runs on SGI hardware), but for Linux the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u irix-5.3 irix64-6.2 For non-POSIX platforms, currently just returns 'sys.platform'. """ if os.name != "posix" or not hasattr(os, 'uname'): # XXX what about the architecture? NT is Intel or Alpha, # Mac OS is M68k or PPC, etc. return sys.platform # Try to distinguish various flavours of Unix (osname, host, release, version, machine) = os.uname() osname = string.lower(osname) if osname[:5] == "linux": # At least on Linux/Intel, 'machine' is the processor -- # i386, etc. # XXX what about Alpha, SPARC, etc? return "%s-%s" % (osname, machine) elif osname[:5] == "sunos": if release[0] >= "5": # SunOS 5 == Solaris 2 osname = "solaris" release = "%d.%s" % (int(release[0]) - 3, release[2:]) # fall through to standard osname-release-machine representation elif osname[:4] == "irix": # could be "irix64"! return "%s-%s" % (osname, release) elif osname[:3] == "aix": return "%s-%s.%s" % (osname, version, release) elif osname[:6] == "cygwin": rel_re = re.compile (r'[\d.]+') m = rel_re.match(release) if m: release = m.group() return "%s-%s-%s" % (osname, release, machine)
|
def get_platform (): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. for IRIX the architecture isn't particularly important (IRIX only runs on SGI hardware), but for Linux the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u irix-5.3 irix64-6.2 For non-POSIX platforms, currently just returns 'sys.platform'. """ if os.name != "posix" or not hasattr(os, 'uname'): # XXX what about the architecture? NT is Intel or Alpha, # Mac OS is M68k or PPC, etc. return sys.platform # Try to distinguish various flavours of Unix (osname, host, release, version, machine) = os.uname() osname = string.lower(osname) osname = string.replace(osname, '/', '') if osname[:5] == "linux": # At least on Linux/Intel, 'machine' is the processor -- # i386, etc. # XXX what about Alpha, SPARC, etc? return "%s-%s" % (osname, machine) elif osname[:5] == "sunos": if release[0] >= "5": # SunOS 5 == Solaris 2 osname = "solaris" release = "%d.%s" % (int(release[0]) - 3, release[2:]) # fall through to standard osname-release-machine representation elif osname[:4] == "irix": # could be "irix64"! return "%s-%s" % (osname, release) elif osname[:3] == "aix": return "%s-%s.%s" % (osname, version, release) elif osname[:6] == "cygwin": rel_re = re.compile (r'[\d.]+') m = rel_re.match(release) if m: release = m.group() return "%s-%s-%s" % (osname, release, machine)
| 15,163
|
def open(self, fullurl, data=None): # accept a URL or a Request object if isinstance(fullurl, (types.StringType, types.UnicodeType)): req = Request(fullurl, data) else: req = fullurl if data is not None: req.add_data(data) assert isinstance(req, Request) # really only care about interface
|
def open(self, fullurl, data=None): # accept a URL or a Request object if isinstance(fullurl, types.StringTypes): req = Request(fullurl, data) else: req = fullurl if data is not None: req.add_data(data) assert isinstance(req, Request) # really only care about interface
| 15,164
|
def add_password(self, realm, uri, user, passwd): # uri could be a single URI or a sequence if isinstance(uri, (types.StringType, types.UnicodeType)): uri = [uri] uri = tuple(map(self.reduce_uri, uri)) if not self.passwd.has_key(realm): self.passwd[realm] = {} self.passwd[realm][uri] = (user, passwd)
|
def add_password(self, realm, uri, user, passwd): # uri could be a single URI or a sequence if isinstance(uri, types.StringTypes): uri = [uri] uri = tuple(map(self.reduce_uri, uri)) if not self.passwd.has_key(realm): self.passwd[realm] = {} self.passwd[realm][uri] = (user, passwd)
| 15,165
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslashes in! If you # experience strange errors, you may want to join all uncommented # lines and remove the backslashes -- the backslash interpretation is # done by the shell's "read" command and it may not be implemented on # every system.
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslashes in! If you # experience strange errors, you may want to join all uncommented # lines and remove the backslashes -- the backslash interpretation is # done by the shell's "read" command and it may not be implemented on # every system.
| 15,166
|
# Look for a machine, default, or macdef top-level keyword
|
# Look for a machine, default, or macdef top-level keyword
| 15,167
|
# Look for a machine, default, or macdef top-level keyword
|
# Look for a machine, default, or macdef top-level keyword
| 15,168
|
# Look for a machine, default, or macdef top-level keyword
|
# Look for a machine, default, or macdef top-level keyword
| 15,169
|
# Look for a machine, default, or macdef top-level keyword
|
# Look for a machine, default, or macdef top-level keyword
| 15,170
|
# Look for a machine, default, or macdef top-level keyword
|
# Look for a machine, default, or macdef top-level keyword
| 15,171
|
def leapdays(y1, y2): """Return number of leap years in range [y1, y2). Assume y1 <= y2 and no funny (non-leap century) years.""" return (y2+3)/4 - (y1+3)/4
|
def leapdays(y1, y2): """Return number of leap years in range [y1, y2). Assume y1 <= y2.""" y1 -= 1 y2 -= 1 return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400)
| 15,172
|
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(s1.replace("\r\n", "\n")) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(s2.replace("\r\n", "\n")) os.close(slave_fd) os.close(master_fd)
|
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(s1.replace("\r\n", "\n")) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(s2.replace("\r\n", "\n")) os.close(slave_fd) os.close(master_fd)
| 15,173
|
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(s1.replace("\r\n", "\n")) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(s2.replace("\r\n", "\n")) os.close(slave_fd) os.close(master_fd)
|
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(normalize_output(s1)) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(s2.replace("\r\n", "\n")) os.close(slave_fd) os.close(master_fd)
| 15,174
|
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(s1.replace("\r\n", "\n")) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(s2.replace("\r\n", "\n")) os.close(slave_fd) os.close(master_fd)
|
def test_basic_pty(): try: debug("Calling master_open()") master_fd, slave_name = pty.master_open() debug("Got master_fd '%d', slave_name '%s'"%(master_fd, slave_name)) debug("Calling slave_open(%r)"%(slave_name,)) slave_fd = pty.slave_open(slave_name) debug("Got slave_fd '%d'"%slave_fd) except OSError: # " An optional feature could not be imported " ... ? raise TestSkipped, "Pseudo-terminals (seemingly) not functional." if not os.isatty(slave_fd) and sys.platform not in fickle_isatty: raise TestFailed, "slave_fd is not a tty" # IRIX apparently turns \n into \r\n. Allow that, but avoid allowing other # differences (like extra whitespace, trailing garbage, etc.) debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) sys.stdout.write(s1.replace("\r\n", "\n")) debug("Writing chunked output") os.write(slave_fd, TEST_STRING_2[:5]) os.write(slave_fd, TEST_STRING_2[5:]) s2 = os.read(master_fd, 1024) sys.stdout.write(normalize_output(s2)) os.close(slave_fd) os.close(master_fd)
| 15,175
|
def build_libraries (self, libraries):
|
def build_libraries (self, libraries):
| 15,176
|
def __init__(self, editwin): self.editwin = editwin self.text = editwin.text self.textfont = self.text["font"] self.label = None # Dummy line, which starts the "block" of the whole document: self.info = list(self.interesting_lines(1)) self.lastfirstline = 1 visible = idleConf.GetOption("extensions", "CodeContext", "visible", type="bool", default=False) if visible: self.toggle_code_context_event() self.editwin.setvar('<<toggle-code-context>>', True) # Start two update cycles, one for context lines, one for font changes. self.text.after(UPDATEINTERVAL, self.timer_event) self.text.after(FONTUPDATEINTERVAL, self.font_timer_event)
|
def __init__(self, editwin): self.editwin = editwin self.text = editwin.text self.textfont = self.text["font"] self.label = None # Dummy line, which starts the "block" of the whole document: self.info = [(0, -1, "", False)] self.lastfirstline = 1 visible = idleConf.GetOption("extensions", "CodeContext", "visible", type="bool", default=False) if visible: self.toggle_code_context_event() self.editwin.setvar('<<toggle-code-context>>', True) # Start two update cycles, one for context lines, one for font changes. self.text.after(UPDATEINTERVAL, self.timer_event) self.text.after(FONTUPDATEINTERVAL, self.font_timer_event)
| 15,177
|
def get_line_info(self, linenum): """Get the line indent value, text, and any block start keyword
|
def get_line_info(self, linenum): """Get the line indent value, text, and any block start keyword
| 15,178
|
def get_line_info(self, linenum): """Get the line indent value, text, and any block start keyword
|
def get_line_info(self, linenum): """Get the line indent value, text, and any block start keyword
| 15,179
|
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
|
def interesting_lines(self, firstline, stopline=1, stopindent=0): """ Find the context lines, starting at firstline. Will not return lines whose index is smaller than stopline or whose indentation is smaller than stopindent. stopline should always be >= 1, so the dummy block start will never be returned (This function doesn't know what to do about it.) Returns a list with the context lines, starting from the first (top), and a number which all context lines above the inspected region should have a smaller indentation than it. """ lines = [] # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
| 15,180
|
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
|
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, stopline-1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
| 15,181
|
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
|
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
| 15,182
|
def update_label(self): firstline = int(self.text.index("@0,0").split('.')[0]) if self.lastfirstline == firstline: return self.lastfirstline = firstline tmpstack = [] for line_index, text in self.interesting_lines(firstline): # Remove irrelevant self.info items, and when we reach a relevant # item (which must happen because of the dummy element), break. while self.info[-1][0] > line_index: del self.info[-1] if self.info[-1][0] == line_index: break tmpstack.append((line_index, text)) while tmpstack: self.info.append(tmpstack.pop()) lines = [""] * max(0, self.numlines - len(self.info)) + \ [x[1] for x in self.info[-self.numlines:]] self.label["text"] = '\n'.join(lines)
|
def update_label(self): firstline = int(self.text.index("@0,0").split('.')[0]) if self.lastfirstline == firstline: return self.lastfirstline = firstline tmpstack = [] for line_index, text in self.interesting_lines(firstline): # Remove irrelevant self.info items, and when we reach a relevant # item (which must happen because of the dummy element), break. while self.info[-1][0] > line_index: del self.info[-1] if self.info[-1][0] == line_index: break tmpstack.append((line_index, text)) while tmpstack: self.info.append(tmpstack.pop()) lines = [""] * max(0, self.numlines - len(self.info)) + \ [x[1] for x in self.info[-self.numlines:]] self.label["text"] = '\n'.join(lines)
| 15,183
|
def update_label(self): firstline = int(self.text.index("@0,0").split('.')[0]) if self.lastfirstline == firstline: return self.lastfirstline = firstline tmpstack = [] for line_index, text in self.interesting_lines(firstline): # Remove irrelevant self.info items, and when we reach a relevant # item (which must happen because of the dummy element), break. while self.info[-1][0] > line_index: del self.info[-1] if self.info[-1][0] == line_index: break tmpstack.append((line_index, text)) while tmpstack: self.info.append(tmpstack.pop()) lines = [""] * max(0, self.numlines - len(self.info)) + \ [x[1] for x in self.info[-self.numlines:]] self.label["text"] = '\n'.join(lines)
|
def update_label(self): firstline = int(self.text.index("@0,0").split('.')[0]) if self.lastfirstline == firstline: return self.lastfirstline = firstline tmpstack = [] for line_index, text in self.interesting_lines(firstline): # Remove irrelevant self.info items, and when we reach a relevant # item (which must happen because of the dummy element), break. while self.info[-1][0] > line_index: del self.info[-1] if self.info[-1][0] == line_index: break tmpstack.append((line_index, text)) while tmpstack: self.info.append(tmpstack.pop()) lines = [""] * max(0, self.numlines - len(self.info)) + \ [x[2] for x in self.info[-self.numlines:]] self.label["text"] = '\n'.join(lines)
| 15,184
|
def test_input_and_raw_input(self): self.write_testfile() fp = open(TESTFN, 'r') savestdin = sys.stdin savestdout = sys.stdout # Eats the echo try: sys.stdin = fp sys.stdout = BitBucket() self.assertEqual(input(), 2) self.assertEqual(input('testing\n'), 2) self.assertEqual(raw_input(), 'The quick brown fox jumps over the lazy dog.') self.assertEqual(raw_input('testing\n'), 'Dear John') sys.stdin = cStringIO.StringIO("NULL\0") self.assertRaises(TypeError, input, 42, 42) sys.stdin = cStringIO.StringIO(" 'whitespace'") self.assertEqual(input(), 'whitespace') sys.stdin = cStringIO.StringIO() self.assertRaises(EOFError, input)
|
def test_input_and_raw_input(self): self.write_testfile() fp = open(TESTFN, 'r') savestdin = sys.stdin savestdout = sys.stdout # Eats the echo try: sys.stdin = fp sys.stdout = BitBucket() self.assertEqual(input(), 2) self.assertEqual(input('testing\n'), 2) self.assertEqual(raw_input(), 'The quick brown fox jumps over the lazy dog.') self.assertEqual(raw_input('testing\n'), 'Dear John') sys.stdin = cStringIO.StringIO("NULL\0") self.assertRaises(TypeError, input, 42, 42) sys.stdin = cStringIO.StringIO(" 'whitespace'") self.assertEqual(input(), 'whitespace') sys.stdin = cStringIO.StringIO() self.assertRaises(EOFError, input)
| 15,185
|
def message_from_string(s, _class=_Message): return _Parser(_class).parsestr(s)
|
def message_from_string(s, _class=_Message, strict=1): return _Parser(_class, strict=strict).parsestr(s)
| 15,186
|
def parse_starttag(self, i):
|
def parse_starttag(self, i):
| 15,187
|
def test(args = None): import sys if not args: args = sys.argv[1:] if args and args[0] == '-s': args = args[1:] klass = XMLParser else: klass = TestXMLParser if args: file = args[0] else: file = 'test.xml' if file == '-': f = sys.stdin else: try: f = open(file, 'r') except IOError, msg: print file, ":", msg sys.exit(1) data = f.read() if f is not sys.stdin: f.close() x = klass() for c in data: x.feed(c) x.close()
|
deftest(args=None):importsysifnotargs:args=sys.argv[1:]ifargsandargs[0]=='-s':args=args[1:]klass=XMLParserelse:klass=TestXMLParserifargs:file=args[0]else:file='test.xml'iffile=='-':f=sys.stdinelse:try:f=open(file,'r')exceptIOError,msg:printfile,":",msgsys.exit(1)data=f.read()iffisnotsys.stdin:f.close()x=klass()forcindata:x.feed(c)x.close()
| 15,188
|
def asksaveasfilename(**options): "Ask for a filename to save as" return SaveAs(**options).show()
|
defdef askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() asksaveasfilename(**options):def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() "Askdef askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() fordef askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() adef askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() filenamedef askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() todef askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() savedef askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() as"def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() returndef askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split() SaveAs(**options).show()def askopenfilenames(**options): """Ask for multiple filenames to open Returns a list of filenames or empty list if cancel button selected """ options["multiple"]=1 files=Open(**options).show() return files.split()
| 15,189
|
def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path."""
|
def write_results_file(self, path, lines, lnotab, lines_hit): """Return a coverage results file in path."""
| 15,190
|
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
|
def _marshaled_dispatch(self, data, dispatch_method = None): """Dispatches an XML-RPC method from marshalled (XML) data.
| 15,191
|
def sendsms(self):#{{{ baseURLSSL='https://www.orange.pl' baseURL='http://www.orange.pl' length = 634 - len(self.message) cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) # orange index#{{{ request = urllib2.Request(baseURLSSL) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with',baseURLSSL except IOError: print 'Connection with %s failed.' % baseURLSSL#}}} # orange map#{{{ request = urllib2.Request(baseURLSSL + '/portal/map/map/') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with www.orange.pl/portal/map/map' except IOError: print 'Connection with https://www.orange.pl/portal/map/map failed.'#}}} # orange login#{{{ parmdicta = {'_dyncharset': 'UTF-8', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL': '/portal/map/map/signin', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL': ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL': 'http://www.orange.pl/portal/map/map/pim', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL': ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login': self.login, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login': ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password': self.password, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password': ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x': '0', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y': '0', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login': ' ', '_DARGS': '/gear/static/login.jsp'} request = urllib2.Request(baseURLSSL + '/portal/map/map/home?_DARGS=/gear/static/login.jsp') postdata = urllib.unquote(urllib.urlencode(parmdicta)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Logged' except IOError: print 'Not logged'#}}} # orange SMS form#{{{ request = urllib2.Request(baseURL + '/portal/map/map/message_box?mbox_view=newsms&mbox_edit=new') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Opening SMS form' except IOError: print 'Open SMS form failed.'#}}} # Send SMS#{{{ parmdictb = {'_dyncharset': 'UTF-8', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type': 'sms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' : ' ', 'enabled': 'true', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': '/portal/map/map/message_box?mbox_view=newsms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': '/portal/map/map/message_box?mbox_view=messageslist', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': ' ', 'smscounter' : '1', 'counter': length, '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': self.number, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': ' ', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': self.sender+' : '+self.message, '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x': '0', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y': '0', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create': ' ', '_DARGS': '/gear/mapmessagebox/smsform.jsp'} request = urllib2.Request(baseURL + '/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp') postdata = urllib.unquote(urllib.urlencode(parmdictb)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'SMS sended.' except IOError: print 'SMS not send.' smsy = self.zostalo(result.read()) smsy_darmowe = 0 if len(smsy) == 1: smsy_darmowe = smsy[0] smsy_doladowane = 0 if len(smsy) == 2: smsy_darmowe = smsy[0] smsy_doladowane = smsy[1]; if smsy_darmowe and self.debug: print 'Orange -> Zostalo: %s+%s SMS' % (smsy_darmowe, smsy_doladowane) #}}}
|
defprint self.debug sendsms(self):#{{{print self.debug baseURLSSL='https://www.orange.pl'print self.debug baseURL='http://www.orange.pl'print self.debug lengthprint self.debug =print self.debug 634print self.debug -print self.debug len(self.message)print self.debug cjprint self.debug =print self.debug cookielib.CookieJar()print self.debug openerprint self.debug =print self.debug urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))print self.debug print self.debug #print self.debug orangeprint self.debug index#{{{print self.debug requestprint self.debug =print self.debug urllib2.Request(baseURLSSL)print self.debug request.add_header('User-Agent',print self.debug 'Opera/8.00print self.debug (Windowsprint self.debug NTprint self.debug 5.0;print self.debug U;print self.debug en)')print self.debug try:print self.debug resultprint self.debug =print self.debug opener.open(request)print self.debug ifprint self.debug self.debug:print self.debug printprint self.debug 'Connectingprint self.debug with',baseURLSSLprint self.debug exceptprint self.debug IOError:print self.debug printprint self.debug 'Connectionprint self.debug withprint self.debug %sprint self.debug failed.'print self.debug %print self.debug baseURLSSL#}}}print self.debug print self.debug #print self.debug orangeprint self.debug map#{{{print self.debug requestprint self.debug =print self.debug urllib2.Request(baseURLSSLprint self.debug +print self.debug '/portal/map/map/')print self.debug request.add_header('User-Agent',print self.debug 'Opera/8.00print self.debug (Windowsprint self.debug NTprint self.debug 5.0;print self.debug U;print self.debug en)')print self.debug try:print self.debug resultprint self.debug =print self.debug opener.open(request)print self.debug ifprint self.debug self.debug:print self.debug printprint self.debug 'Connectingprint self.debug withprint self.debug www.orange.pl/portal/map/map'print self.debug exceptprint self.debug IOError:print self.debug printprint self.debug 'Connectionprint self.debug withprint self.debug https://www.orange.pl/portal/map/mapprint self.debug failed.'#}}}print self.debug print self.debug #print self.debug orangeprint self.debug login#{{{print self.debug parmdictaprint self.debug =print self.debug {'_dyncharset':print self.debug 'UTF-8',print self.debug '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL':print self.debug '/portal/map/map/signin',print self.debug '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL':print self.debug 'print self.debug ',print self.debug '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL':print self.debug 'http://www.orange.pl/portal/map/map/pim',print self.debug '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL':print self.debug 'print self.debug ',print self.debug '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login':print self.debug self.login,print self.debug '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login':print self.debug 'print self.debug ',print self.debug '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password':print self.debug self.password,print self.debug '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password':print self.debug 'print self.debug ',print self.debug '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x':print self.debug '0',print self.debug '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y':print self.debug '0',print self.debug '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login':print self.debug 'print self.debug ',print self.debug '_DARGS':print self.debug '/gear/static/login.jsp'}print self.debug print self.debug requestprint self.debug =print self.debug urllib2.Request(baseURLSSLprint self.debug +print self.debug '/portal/map/map/home?_DARGS=/gear/static/login.jsp')print self.debug postdataprint self.debug =print self.debug urllib.unquote(urllib.urlencode(parmdicta))print self.debug request.add_data(postdata)print self.debug request.add_header('User-Agent',print self.debug 'Opera/8.00print self.debug (Windowsprint self.debug NTprint self.debug 5.0;print self.debug U;print self.debug en)')print self.debug try:print self.debug resultprint self.debug =print self.debug opener.open(request)print self.debug ifprint self.debug self.debug:print self.debug printprint self.debug 'Logged'print self.debug exceptprint self.debug IOError:print self.debug printprint self.debug 'Notprint self.debug logged'#}}}print self.debug print self.debug #print self.debug orangeprint self.debug SMSprint self.debug form#{{{print self.debug requestprint self.debug =print self.debug urllib2.Request(baseURLprint self.debug +print self.debug '/portal/map/map/message_box?mbox_view=newsms&mbox_edit=new')print self.debug request.add_header('User-Agent',print self.debug 'Opera/8.00print self.debug (Windowsprint self.debug NTprint self.debug 5.0;print self.debug U;print self.debug en)')print self.debug try:print self.debug resultprint self.debug =print self.debug opener.open(request)print self.debug ifprint self.debug self.debug:print self.debug printprint self.debug 'Openingprint self.debug SMSprint self.debug form'print self.debug exceptprint self.debug IOError:print self.debug printprint self.debug 'Openprint self.debug SMSprint self.debug formprint self.debug failed.'#}}}print self.debug print self.debug #print self.debug Sendprint self.debug SMS#{{{print self.debug parmdictbprint self.debug =print self.debug {'_dyncharset':print self.debug 'UTF-8',print self.debug '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type':print self.debug 'sms',print self.debug '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type'print self.debug :print self.debug 'print self.debug ',print self.debug 'enabled':print self.debug 'true',print self.debug '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL':print self.debug '/portal/map/map/message_box?mbox_view=newsms',print self.debug '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL':print self.debug 'print self.debug ',print self.debug '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL':print self.debug '/portal/map/map/message_box?mbox_view=messageslist',print self.debug '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL':print self.debug 'print self.debug ',print self.debug 'smscounter'print self.debug :print self.debug '1',print self.debug 'counter':print self.debug length,print self.debug '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to':print self.debug self.number,print self.debug '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to':print self.debug 'print self.debug ',print self.debug '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body':print self.debug 'print self.debug ',print self.debug '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body':print self.debug self.sender+'print self.debug :print self.debug '+self.message,print self.debug '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x':print self.debug '0',print self.debug '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y':print self.debug '0',print self.debug '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create':print self.debug 'print self.debug ',print self.debug '_DARGS':print self.debug '/gear/mapmessagebox/smsform.jsp'}print self.debug print self.debug requestprint self.debug =print self.debug urllib2.Request(baseURLprint self.debug +print self.debug '/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp')print self.debug postdataprint self.debug =print self.debug urllib.unquote(urllib.urlencode(parmdictb))print self.debug request.add_data(postdata)print self.debug request.add_header('User-Agent',print self.debug 'Opera/8.00print self.debug (Windowsprint self.debug NTprint self.debug 5.0;print self.debug U;print self.debug en)')print self.debug try:print self.debug resultprint self.debug =print self.debug opener.open(request)print self.debug ifprint self.debug self.debug:print self.debug printprint self.debug 'SMSprint self.debug sended.'print self.debug exceptprint self.debug IOError:print self.debug printprint self.debug 'SMSprint self.debug notprint self.debug send.'print self.debug print self.debug smsyprint self.debug =print self.debug self.zostalo(result.read())print self.debug smsy_darmoweprint self.debug =print self.debug 0print self.debug ifprint self.debug len(smsy)print self.debug ==print self.debug 1:print self.debug smsy_darmoweprint self.debug =print self.debug print self.debug smsy[0]print self.debug smsy_doladowaneprint self.debug =print self.debug 0print self.debug ifprint self.debug len(smsy)print self.debug ==print self.debug 2:print self.debug smsy_darmoweprint self.debug =print self.debug print self.debug smsy[0]print self.debug smsy_doladowaneprint self.debug =print self.debug smsy[1];print self.debug ifprint self.debug smsy_darmoweprint self.debug andprint self.debug self.debug:print self.debug printprint self.debug 'Orangeprint self.debug ->print self.debug Zostalo:print self.debug %s+%sprint self.debug SMS'print self.debug %print self.debug (smsy_darmowe,print self.debug smsy_doladowane)print self.debug #}}}
| 15,192
|
def sendsms(self):#{{{ baseURLSSL='https://www.orange.pl' baseURL='http://www.orange.pl' length = 634 - len(self.message) cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) # orange index#{{{ request = urllib2.Request(baseURLSSL) request.add_header('User-Agent', 'Opera/9.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with',baseURLSSL except IOError: print 'Connection with %s failed.' % baseURLSSL#}}} # orange map#{{{ request = urllib2.Request(baseURLSSL + '/portal/map/map/') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with www.orange.pl/portal/map/map' except IOError: print 'Connection with https://www.orange.pl/portal/map/map failed.'#}}} # orange login#{{{ parmdicta = { '_dyncharset' : 'UTF-8', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' : '/portal/map/map/signin', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' : 'http://www.orange.pl/portal/map/map/pim', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' : self.login, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' : self.password, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' : ' ', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' : ' ', '_DARGS' : '/gear/static/home/login.jsp.loginFormId', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x' : '5', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y' : '5'} request = urllib2.Request(baseURLSSL + '/portal/map/map/homeo?_DARGS=/gear/static/home/login.jsp.loginFormId') postdata = urllib.unquote(urllib.urlencode(parmdicta)) request.add_data(postdata) print postdata request.add_header('User-Agent', 'Opera/8.10 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Logged' except IOError: print 'Not logged'#}}} # orange SMS form#{{{ request = urllib2.Request(baseURL + '/portal/map/map/message_box?mbox_view=newsms&mbox_edit=new') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Opening SMS form' except IOError: print 'Open SMS form failed.'#}}} # Send SMS#{{{ parmdictb = {'_dyncharset': 'UTF-8', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type': 'sms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' : ' ', 'enabled': 'true', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': '/portal/map/map/message_box?mbox_view=newsms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': '/portal/map/map/message_box?mbox_view=messageslist', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': ' ', 'smscounter' : '1', 'counter': '630', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': self.number, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': ' ', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': self.sender+' : '+self.message, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create': 'Wylij', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x': '5', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y': '5', '_DARGS': '/gear/mapmessagebox/smsform.jsp'} request = urllib2.Request(baseURL + '/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp') postdata = urllib.unquote(urllib.urlencode(parmdictb)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'SMS sended.' except IOError: print 'SMS not send.' smsy = self.zostalo(result.read()) smsy_darmowe = 0 if len(smsy) == 1: smsy_darmowe = smsy[0] smsy_doladowane = 0 if len(smsy) == 2: smsy_darmowe = smsy[0] smsy_doladowane = smsy[1]; if smsy_darmowe and self.debug: print 'Orange -> Zostalo: %s+%s SMS' % (smsy_darmowe, smsy_doladowane) #}}}
|
def sendsms(self):#{{{ baseURLSSL='https://www.orange.pl' baseURL='http://www.orange.pl' length = 634 - len(self.message) cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) # orange index#{{{ request = urllib2.Request(baseURLSSL) request.add_header('User-Agent', 'Opera/9.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with',baseURLSSL except IOError: print 'Connection with %s failed.' % baseURLSSL#}}} # orange map#{{{ request = urllib2.Request(baseURLSSL + '/portal/map/map/') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Connecting with www.orange.pl/portal/map/map' except IOError: print 'Connection with https://www.orange.pl/portal/map/map failed.'#}}} # orange login#{{{ parmdicta = { '_dyncharset' : 'UTF-8', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' : '/portal/map/map/signin', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginErrorURL' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' : 'http://www.orange.pl/portal/map/map/pim', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.loginSuccessURL' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' : self.login, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' : self.password, '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password' : ' ', '_D:/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' : ' ', '_DARGS' : '/gear/static/home/login.jsp.loginFormId', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login' : ' ', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x' : '5', '/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y' : '5'} request = urllib2.Request(baseURLSSL + '/portal/map/map/homeo?_DARGS=/gear/static/home/login.jsp.loginFormId') postdata = urllib.unquote(urllib.urlencode(parmdicta)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.10 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Logged' except IOError: print 'Not logged'#}}} # orange SMS form#{{{ request = urllib2.Request(baseURL + '/portal/map/map/message_box?mbox_view=newsms&mbox_edit=new') request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'Opening SMS form' except IOError: print 'Open SMS form failed.'#}}} # Send SMS#{{{ parmdictb = {'_dyncharset': 'UTF-8', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type': 'sms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.type' : ' ', 'enabled': 'true', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': '/portal/map/map/message_box?mbox_view=newsms', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.errorURL': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': '/portal/map/map/message_box?mbox_view=messageslist', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.successURL': ' ', 'smscounter' : '1', 'counter': '630', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': self.number, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to': ' ', '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body': self.sender+' : '+self.message, '_D:/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create': ' ', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create': 'Wylij', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x': '5', '/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y': '5', '_DARGS': '/gear/mapmessagebox/smsform.jsp'} request = urllib2.Request(baseURL + '/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp') postdata = urllib.unquote(urllib.urlencode(parmdictb)) request.add_data(postdata) request.add_header('User-Agent', 'Opera/8.00 (Windows NT 5.0; U; en)') try: result = opener.open(request) if self.debug: print 'SMS sended.' except IOError: print 'SMS not send.' smsy = self.zostalo(result.read()) smsy_darmowe = 0 if len(smsy) == 1: smsy_darmowe = smsy[0] smsy_doladowane = 0 if len(smsy) == 2: smsy_darmowe = smsy[0] smsy_doladowane = smsy[1]; if smsy_darmowe and self.debug: print 'Orange -> Zostalo: %s+%s SMS' % (smsy_darmowe, smsy_doladowane) #}}}
| 15,193
|
def sendsms(self):#{{{ baseURL='http://www.eraomnix.pl' cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), moj_redirect_handler) request = urllib2.Request(baseURL + '/msg/api/do/tinker/sponsored') parametry = { 'failure' : baseURL, 'success' : baseURL, 'message' : self.message, 'login' : self.login, 'password' : self.password, 'number' : '48' + self.number, 'mms' : 'false'}
|
def sendsms(self):#{{{ baseURL='http://www.eraomnix.pl' cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), moj_redirect_handler) request = urllib2.Request(baseURL + '/msg/api/do/tinker/sponsored') parametry = { 'failure' : baseURL, 'success' : baseURL, 'message' : self.message, 'login' : self.login, 'password' : self.password, 'number' : '48' + self.number, 'mms' : 'false'}
| 15,194
|
def sendsms(self):#{{{ baseURL='http://www.eraomnix.pl' cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), moj_redirect_handler) request = urllib2.Request(baseURL + '/msg/api/do/tinker/sponsored') parametry = { 'failure' : baseURL, 'success' : baseURL, 'message' : self.message, 'login' : self.login, 'password' : self.password, 'number' : '48' + self.number, 'mms' : 'false'}
|
def sendsms(self):#{{{ baseURL='http://www.eraomnix.pl' cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), moj_redirect_handler) request = urllib2.Request(baseURL + '/msg/api/do/tinker/sponsored') parametry = { 'failure' : baseURL, 'success' : baseURL, 'message' : self.message, 'login' : self.login, 'password' : self.password, 'number' : '48' + self.number, 'mms' : 'false'}
| 15,195
|
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None print "change desc: ``%s''" % changedesc for line in changedesc.split("\n"): print ">> `%s'" % line if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug number result_dict['bugs_closed'] = changedesc_keys['Bug Number'] # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
|
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None for line in changedesc.split("\n"): print ">> `%s'" % line if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug number result_dict['bugs_closed'] = changedesc_keys['Bug Number'] # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
| 15,196
|
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None print "change desc: ``%s''" % changedesc for line in changedesc.split("\n"): print ">> `%s'" % line if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug number result_dict['bugs_closed'] = changedesc_keys['Bug Number'] # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
|
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None print "change desc: ``%s''" % changedesc for line in changedesc.split("\n"): if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug number result_dict['bugs_closed'] = changedesc_keys['Bug Number'] # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
| 15,197
|
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None print "change desc: ``%s''" % changedesc for line in changedesc.split("\n"): print ">> `%s'" % line if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug number result_dict['bugs_closed'] = changedesc_keys['Bug Number'] # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
|
def parse_change_desc(changedesc, result_dict): summary = "" description = "" files = [] changedesc_keys = { 'QA Notes': "", 'Testing Done': "", 'Documentation Notes': "", 'Bug Number': "", 'Reviewed by': "", 'Approved by': "", 'Breaks vmcore compatibility': "", 'Breaks vmkernel compatibility': "", 'Breaks vmkdrivers compatibility': "", 'Mailto': "", } process_summary = False process_description = False process_files = False cur_key = None print "change desc: ``%s''" % changedesc for line in changedesc.split("\n"): print ">> `%s'" % line if line == "Description:": process_summary = True continue elif line == "Files:": process_files = True continue elif line == "" or line == "\t": if process_summary: process_summary = False process_description = True continue line = "" elif line.startswith("\t"): line = line[1:] if process_files: files.append(line) elif line.find(':') != -1: key, value = line.split(':', 2) if changedesc_keys.has_key(key): process_description = False cur_key = key changedesc_keys[key] = value.lstrip() + "\n" continue line += "\n" if process_summary: summary += line elif process_description: description += line elif cur_key != None: changedesc_keys[cur_key] += line result_dict['summary'] = summary result_dict['description'] = description result_dict['testing_done'] = changedesc_keys['Testing Done'] # TODO: Normalize bug numberresult_dict['bugs_closed'] = \ ", ".join(re.split(r"[, ]+", changedesc_keys['Bug Number'])) # This is gross. if len(files) > 0: parts = files[0].split('/') if parts[2] == "depot": result_dict['branch'] = parts[4]
| 15,198
|
def new_review_request(request, template_name='reviews/new.html', changenum_path='changenum'): changedesc = "\
|
def new_review_request(request, template_name='reviews/new.html', changenum_path='changenum'): changedesc = "\
| 15,199
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.