bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: tagName = self._current_context[uri] + ":" + localname node = self.document.createElementNS(uri, tagName) else: # When the tagname is not prefixed, it just appears as # localname node = self.document.createElement(localname)
|
def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: tagName = self._current_context[uri] + ":" + localname node = self.document.createElementNS(uri, tagName) else: # When the tagname is not prefixed, it just appears as # localname node = self.document.createElement(localname)
| 7,100
|
def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: tagName = self._current_context[uri] + ":" + localname node = self.document.createElementNS(uri, tagName) else: # When the tagname is not prefixed, it just appears as # localname node = self.document.createElement(localname)
|
defself.push(node) startElementNS(self,self.push(node) name,self.push(node) tagNameself.push(node) ,self.push(node) attrs):self.push(node) uri,self.push(node) localnameself.push(node) =self.push(node) nameself.push(node) ifself.push(node) uri:self.push(node) #self.push(node) Whenself.push(node) usingself.push(node) namespaces,self.push(node) theself.push(node) readerself.push(node) mayself.push(node) orself.push(node) mayself.push(node) notself.push(node) #self.push(node) provideself.push(node) usself.push(node) withself.push(node) theself.push(node) originalself.push(node) name.self.push(node) Ifself.push(node) not,self.push(node) createself.push(node) #self.push(node) *a*self.push(node) validself.push(node) tagNameself.push(node) fromself.push(node) theself.push(node) currentself.push(node) context.self.push(node) ifself.push(node) tagNameself.push(node) isself.push(node) None:self.push(node) tagNameself.push(node) =self.push(node) self._current_context[uri]self.push(node) +self.push(node) ":"self.push(node) +self.push(node) localnameself.push(node) nodeself.push(node) =self.push(node) self.document.createElementNS(uri,self.push(node) tagName)self.push(node) else:self.push(node) #self.push(node) Whenself.push(node) theself.push(node) tagnameself.push(node) isself.push(node) notself.push(node) prefixed,self.push(node) itself.push(node) justself.push(node) appearsself.push(node) asself.push(node) #self.push(node) localnameself.push(node) nodeself.push(node) =self.push(node) self.document.createElement(localname)
| 7,101
|
def endElementNS(self, name, tagName): node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((END_ELEMENT, node)) self.curNode = self.curNode.parentNode
|
def endElementNS(self, name, tagName): node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((END_ELEMENT, node)) self.curNode = self.curNode.parentNode
| 7,102
|
def startElement(self, name, attrs): node = self.document.createElement(name)
|
def startElement(self, name, attrs): node = self.document.createElement(name)
| 7,103
|
def startElement(self, name, attrs): node = self.document.createElement(name)
|
defself.push(node) startElement(self,self.push(node) name,self.push(node) attrs):self.push(node) nodeself.push(node) =self.push(node) self.document.createElement(name)
| 7,104
|
def endElement(self, name): node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((END_ELEMENT, node)) self.curNode = node.parentNode
|
def endElement(self, name): node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((END_ELEMENT, node)) self.curNode = node.parentNode
| 7,105
|
def comment(self, s): node = self.document.createComment(s) self.curNode.appendChild(node)
|
def comment(self, s): node = self.document.createComment(s) self.curNode.appendChild(node)
| 7,106
|
def comment(self, s): node = self.document.createComment(s) self.curNode.appendChild(node)
|
defcomment(self,s):node=self.document.createComment(s)self.curNode.appendChild(node)
| 7,107
|
def processingInstruction(self, target, data): node = self.document.createProcessingInstruction(target, data)
|
def processingInstruction(self, target, data): node = self.document.createProcessingInstruction(target, data)
| 7,108
|
def processingInstruction(self, target, data): node = self.document.createProcessingInstruction(target, data)
|
defprocessingInstruction(self,target,data):node=self.document.createProcessingInstruction(target,data)
| 7,109
|
def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) self.curNode.appendChild(node)
|
def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) self.curNode.appendChild(node)
| 7,110
|
def ignorableWhitespace(self, chars): node = self.document.createTextNode(chars) self.curNode.appendChild(node)
|
defignorableWhitespace(self,chars):node=self.document.createTextNode(chars)self.curNode.appendChild(node)
| 7,111
|
def characters(self, chars): node = self.document.createTextNode(chars) self.curNode.appendChild(node)
|
def characters(self, chars): node = self.document.createTextNode(chars) self.curNode.appendChild(node)
| 7,112
|
def startDocument(self): publicId = systemId = None if self._locator: publicId = self._locator.getPublicId() systemId = self._locator.getSystemId() if self.documentFactory is None: import xml.dom.minidom self.documentFactory = xml.dom.minidom.Document.implementation node = self.documentFactory.createDocument(None, publicId, systemId) self.curNode = self.document = node self.lastEvent[1] = [(START_DOCUMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((START_DOCUMENT, node))
|
def startDocument(self): publicId = systemId = None if self._locator: publicId = self._locator.getPublicId() systemId = self._locator.getSystemId() if self.documentFactory is None: import xml.dom.minidom self.documentFactory = xml.dom.minidom.Document.implementation node = self.documentFactory.createDocument(None, publicId, systemId) self.document = node self.lastEvent[1] = [(START_DOCUMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((START_DOCUMENT, node))
| 7,113
|
def startDocument(self): publicId = systemId = None if self._locator: publicId = self._locator.getPublicId() systemId = self._locator.getSystemId() if self.documentFactory is None: import xml.dom.minidom self.documentFactory = xml.dom.minidom.Document.implementation node = self.documentFactory.createDocument(None, publicId, systemId) self.curNode = self.document = node self.lastEvent[1] = [(START_DOCUMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((START_DOCUMENT, node))
|
defself.push(node) startDocument(self):self.push(node) publicIdself.push(node) =self.push(node) systemIdself.push(node) =self.push(node) Noneself.push(node) ifself.push(node) self._locator:self.push(node) publicIdself.push(node) =self.push(node) self._locator.getPublicId()self.push(node) systemIdself.push(node) =self.push(node) self._locator.getSystemId()self.push(node) ifself.push(node) self.documentFactoryself.push(node) isself.push(node) None:self.push(node) importself.push(node) xml.dom.minidomself.push(node) self.documentFactoryself.push(node) =self.push(node) xml.dom.minidom.Document.implementationself.push(node) nodeself.push(node) =self.push(node) self.documentFactory.createDocument(None,self.push(node) publicId,self.push(node) systemId)self.push(node) self.curNodeself.push(node) =self.push(node) self.documentself.push(node) =self.push(node) nodeself.push(node) self.lastEvent[1]self.push(node) =self.push(node) [(START_DOCUMENT,self.push(node) node),self.push(node) None]self.push(node) self.lastEventself.push(node) =self.push(node) self.lastEvent[1]self.push(node) #self.events.append((START_DOCUMENT,self.push(node) node))
| 7,114
|
def endDocument(self): assert self.curNode.parentNode is None, \ "not all elements have been properly closed" assert self.curNode.documentElement is not None, \ "document does not contain a root element" node = self.curNode.documentElement self.lastEvent[1] = [(END_DOCUMENT, node), None] #self.events.append((END_DOCUMENT, self.curNode))
|
def endDocument(self): assert self.curNode.parentNode is None, \ "not all elements have been properly closed" assert self.curNode.documentElement is not None, \ "document does not contain a root element" node = self.curNode.documentElement self.lastEvent[1] = [(END_DOCUMENT, node), None] #self.events.append((END_DOCUMENT, self.curNode))
| 7,115
|
def expandNode(self, node): event = self.getEvent() while event: token, cur_node = event if cur_node is node: return if token != END_ELEMENT: cur_node.parentNode.appendChild(cur_node) event = self.getEvent()
|
def expandNode(self, node): event = self.getEvent() while event: token, cur_node = event if cur_node is node: return if token != END_ELEMENT: parents[-1].appendChild(cur_node) if token == START_ELEMENT: parents.append(cur_node) elif token == END_ELEMENT: del parents[-1] event = self.getEvent()
| 7,116
|
def startElementNS(self, name, tagName , attrs): PullDOM.startElementNS(self, name, tagName, attrs) self.curNode.parentNode.appendChild(self.curNode)
|
def startElementNS(self, name, tagName , attrs): PullDOM.startElementNS(self, name, tagName, attrs) self.curNode.parentNode.appendChild(self.curNode)
| 7,117
|
def startElement(self, name, attrs): PullDOM.startElement(self, name, attrs) self.curNode.parentNode.appendChild(self.curNode)
|
def startElement(self, name, attrs): PullDOM.startElement(self, name, attrs) self.curNode.parentNode.appendChild(self.curNode)
| 7,118
|
def processingInstruction(self, target, data): PullDOM.processingInstruction(self, target, data) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
|
def processingInstruction(self, target, data): PullDOM.processingInstruction(self, target, data) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
| 7,119
|
def ignorableWhitespace(self, chars): PullDOM.ignorableWhitespace(self, chars) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
|
def ignorableWhitespace(self, chars): PullDOM.ignorableWhitespace(self, chars) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
| 7,120
|
def characters(self, chars): PullDOM.characters(self, chars) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
|
def characters(self, chars): PullDOM.characters(self, chars) node = self.lastEvent[0][1] node.parentNode.appendChild(node)
| 7,121
|
... def tail(g):
|
... def tail(g):
| 7,122
|
... def _m235():
|
... def _m235():
| 7,123
|
... def _m235():
|
... def _m235():
| 7,124
|
... def _fib():
|
... def _fib():
| 7,125
|
def get_inidata (self): # Return data describing the installation.
|
def get_inidata (self): # Return data describing the installation.
| 7,126
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 7,127
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 7,128
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 7,129
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 7,130
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
|
def get_exe_bytes (self): import base64 return base64.decodestring (EXEDATA)
| 7,131
|
def failUnlessEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '!=' operator. """ if first != second: raise self.failureException, (msg or '%s != %s' % (first, second))
|
def failUnlessEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '!=' operator. """ if first != second: raise self.failureException, (msg or '%s != %s' % (first, second))
| 7,132
|
def failIfEqual(self, first, second, msg=None): """Fail if the two objects are equal as determined by the '==' operator. """ if first == second: raise self.failureException, (msg or '%s == %s' % (first, second))
|
def failIfEqual(self, first, second, msg=None): """Fail if the two objects are equal as determined by the '==' operator. """ if first == second: raise self.failureException, (msg or '%s == %s' % (first, second))
| 7,133
|
def addError(self, test, err): TestResult.addError(self, test, err) if self.showAll: self.stream.writeln("ERROR") elif self.dots: self.stream.write('E') if err[0] is KeyboardInterrupt: self.shouldStop = 1
|
def addError(self, test, err): TestResult.addError(self, test, err) if self.showAll: self.stream.writeln("ERROR") elif self.dots: self.stream.write('E') if err[0] is KeyboardInterrupt: self.shouldStop = 1
| 7,134
|
>>> def m235():
|
>>> def m235():
| 7,135
|
>>> def f():
|
>>> def f():
| 7,136
|
def test_main(): import doctest, test_generators if 0: # Temporary block to help track down leaks. So far, the blame # has fallen mostly on doctest. for i in range(1000): doctest.master = None doctest.testmod(test_generators) else: doctest.testmod(test_generators)
|
def test_main(): import doctest, test_generators if 0: # Temporary block to help track down leaks. So far, the blame # has fallen mostly on doctest. for i in range(5000): doctest.master = None doctest.testmod(test_generators) else: doctest.testmod(test_generators)
| 7,137
|
def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
|
def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40)
| 7,138
|
def isTestMethod(attrname, testCaseClass=testCaseClass, prefix=self.testMethodPrefix): return attrname[:len(prefix)] == prefix and callable(getattr(testCaseClass, attrname))
|
def isTestMethod(attrname, testCaseClass=testCaseClass, prefix=self.testMethodPrefix): return attrname[:len(prefix)] == prefix and callable(getattr(testCaseClass, attrname))
| 7,139
|
def Node(*args): kind = args[0] if nodes.has_key(kind): try: return nodes[kind](*args[1:]) except TypeError: print nodes[kind], len(args), args raise else: raise WalkerEror, "Can't find appropriate Node type: %s" % str(args) #return apply(ast.Node, args)
|
def Node(*args): kind = args[0] if nodes.has_key(kind): try: return nodes[kind](*args[1:]) except TypeError: print nodes[kind], len(args), args raise else: raise WalkerError, "Can't find appropriate Node type: %s" % str(args) #return apply(ast.Node, args)
| 7,140
|
def compile_node(self, node): ### emit a line-number node? n = node[0]
|
def compile_node(self, node): ### emit a line-number node? n = node[0]
| 7,141
|
def parameters(self, nodelist): raise WalkerEror
|
def parameters(self, nodelist): raise WalkerEror
| 7,142
|
def varargslist(self, nodelist): raise WalkerEror
|
def varargslist(self, nodelist): raise WalkerEror
| 7,143
|
def fpdef(self, nodelist): raise WalkerEror
|
def fpdef(self, nodelist): raise WalkerEror
| 7,144
|
def fplist(self, nodelist): raise WalkerEror
|
def fplist(self, nodelist): raise WalkerEror
| 7,145
|
def dotted_name(self, nodelist): raise WalkerEror
|
def dotted_name(self, nodelist): raise WalkerEror
| 7,146
|
def comp_op(self, nodelist): raise WalkerEror
|
def comp_op(self, nodelist): raise WalkerEror
| 7,147
|
def trailer(self, nodelist): raise WalkerEror
|
def trailer(self, nodelist): raise WalkerEror
| 7,148
|
def sliceop(self, nodelist): raise WalkerEror
|
def sliceop(self, nodelist): raise WalkerEror
| 7,149
|
def argument(self, nodelist): raise WalkerEror
|
def argument(self, nodelist): raise WalkerEror
| 7,150
|
def is_empty (self): return self.list == []
|
def is_empty (self): return self.list == []
| 7,151
|
def update(self, dict): if isinstance(dict, UserDict): self.data.update(dict.data) elif isinstance(dict, type(self.data)): self.data.update(dict) else: for k, v in dict.items(): self.data[k] = v
|
def update(self, dict): if isinstance(dict, UserDict): self.data.update(dict.data) elif isinstance(dict, type(self.data)): self.data.update(dict) else: for k, v in dict.items(): self.data[k] = v
| 7,152
|
def get(self, key, failobj=None): return self.data.get(key, failobj)
|
def get(self, key, failobj=None): return self.data.get(key, failobj)
| 7,153
|
def setdefault(self, key, failobj=None): if not self.data.has_key(key): self.data[key] = failobj return self.data[key]
|
def setdefault(self, key, failobj=None): if not self.data.has_key(key): self.data[key] = failobj return self.data[key]
| 7,154
|
def __delattr__(self, name): log.append(("delattr", name)) MT.__delattr__(self, name)
|
def __delattr__(self, name): log.append(("delattr", name)) MT.__delattr__(self, name)
| 7,155
|
def __delattr__(self, name): log.append(("delattr", name)) MT.__delattr__(self, name)
|
def __delattr__(self, name): log.append(("delattr", name)) MT.__delattr__(self, name)
| 7,156
|
def find_all_submodules(self, m): if not m.__path__: return modules = {} suffixes = [".py", ".pyc", ".pyo"] for dir in m.__path__: try: names = os.listdir(dir) except os.error: self.msg(2, "can't list directory", dir) continue for name in names: mod = None for suff in suffixes: n = len(suff) if name[-n:] == suff: mod = name[:-n] break if mod and mod != "__init__": modules[mod] = mod return modules.keys()
|
def find_all_submodules(self, m): if not m.__path__: return modules = {} suffixes = [] for triple in imp.get_suffixes(): suffixes.append(triple[0]) for dir in m.__path__: try: names = os.listdir(dir) except os.error: self.msg(2, "can't list directory", dir) continue for name in names: mod = None for suff in suffixes: n = len(suff) if name[-n:] == suff: mod = name[:-n] break if mod and mod != "__init__": modules[mod] = mod return modules.keys()
| 7,157
|
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
|
def readline(self, size=-1): if size < 0: size = sys.maxint readsize = self.min_readsize else: readsize = size bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
| 7,158
|
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
|
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
| 7,159
|
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
|
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
| 7,160
|
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
|
def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line
| 7,161
|
def guess_type(self, path): """Guess the type of a file.
|
def guess_type(self, path): """Guess the type of a file.
| 7,162
|
def pathdirs(): """Convert sys.path into a list of absolute, existing, unique paths.""" dirs = [] for dir in sys.path: dir = os.path.abspath(dir or '.') if dir not in dirs and os.path.isdir(dir): dirs.append(dir) return dirs
|
def pathdirs(): """Convert sys.path into a list of absolute, existing, unique paths.""" dirs = [] for dir in sys.path: dir = os.path.abspath(dir or '.') normdir = os.path.normcase(dir) if normdir not in normdirs and os.path.isdir(dir): dirs.append(dir) return dirs
| 7,163
|
def cleanid(text): """Remove the hexadecimal id from a Python object representation.""" return re.sub(' at 0x[0-9a-f]{5,}>$', '>', text)
|
def stripid(text): """Remove the hexadecimal id from a Python object representation.""" return re.sub(' at 0x[0-9a-f]{5,}>$', '>', text)
| 7,164
|
def cleanid(text): """Remove the hexadecimal id from a Python object representation.""" return re.sub(' at 0x[0-9a-f]{5,}>$', '>', text)
|
def cleanid(text): """Remove the hexadecimal id from a Python object representation.""" for pattern in [' at 0x[0-9a-f]{6,}>$', ' at [0-9A-F]{8,}>$']: if re.search(pattern, repr(Exception)): return re.sub(pattern, '>', text) return text
| 7,165
|
def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return self.escape(cram(cleanid(repr(x)), self.maxother))
|
def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return self.escape(cram(cleanid(repr(x)), self.maxother))
| 7,166
|
def repr_instance(self, x, level): try: return cram(cleanid(repr(x)), self.maxstring) except: return self.escape('<%s instance>' % x.__class__.__name__)
|
def repr_instance(self, x, level): try: return cram(stripid(repr(x)), self.maxstring) except: return self.escape('<%s instance>' % x.__class__.__name__)
| 7,167
|
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong> %s</strong></big></big>' % name try: file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version: %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
|
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong> %s</strong></big></big>' % name try: path = os.path.abspath(inspect.getfile(object)) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version: %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
| 7,168
|
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong> %s</strong></big></big>' % name try: file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version: %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
|
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong> %s</strong></big></big>' % name try: file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
| 7,169
|
def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return cram(cleanid(repr(x)), self.maxother)
|
def repr1(self, x, level): methodname = 'repr_' + join(split(type(x).__name__), '_') if hasattr(self, methodname): return getattr(self, methodname)(x, level) else: return cram(cleanid(repr(x)), self.maxother)
| 7,170
|
def repr_instance(self, x, level): try: return cram(cleanid(repr(x)), self.maxstring) except: return '<%s instance>' % x.__class__.__name__
|
def repr_instance(self, x, level): try: return cram(stripid(repr(x)), self.maxstring) except: return '<%s instance>' % x.__class__.__name__
| 7,171
|
def docmodule(self, object): """Produce text documentation for a given module object.""" result = ''
|
def docmodule(self, object): """Produce text documentation for a given module object.""" result = ''
| 7,172
|
def server_activate(self): self.base.server_activate(self) if self.callback: self.callback()
|
def server_activate(self): self.base.server_activate(self) if self.callback: self.callback()
| 7,173
|
def test_format(self, size): s = '-' * size sf = '%s' % (s,) self.failUnless(s == sf) del sf sf = '..%s..' % (s,) self.assertEquals(len(sf), len(s) + 4) self.failUnless(sf.startswith('..-')) self.failUnless(sf.endswith('-..')) del s, sf
|
def test_format(self, size): s = '-' * size sf = '%s' % (s,) self.failUnless(s == sf) del sf sf = '..%s..' % (s,) self.assertEquals(len(sf), len(s) + 4) self.failUnless(sf.startswith('..-')) self.failUnless(sf.endswith('-..')) del s, sf
| 7,174
|
def test_concat_large(self, size): return self.basic_concat_test(size)
|
def test_concat_large(self, size): return self.basic_concat_test(size)
| 7,175
|
def basic_test_repr(self, size): t = (0,) * size s = repr(t) # The repr of a tuple of 0's is exactly three times the tuple length. self.assertEquals(len(s), size * 3) self.assertEquals(s[:5], '(0, 0') self.assertEquals(s[-5:], '0, 0)') self.assertEquals(s.count('0'), size)
|
def basic_test_repr(self, size): t = (0,) * size s = repr(t) # The repr of a tuple of 0's is exactly three times the tuple length. self.assertEquals(len(s), size * 3) self.assertEquals(s[:5], '(0, 0') self.assertEquals(s[-5:], '0, 0)') self.assertEquals(s.count('0'), size)
| 7,176
|
def test_repr_small(self, size): return self.basic_test_repr(size)
|
def test_repr_small(self, size): return self.basic_test_repr(size)
| 7,177
|
def test_inplace_concat_large(self, size): return self.basic_test_inplace_concat(size)
|
def test_inplace_concat_large(self, size): return self.basic_test_inplace_concat(size)
| 7,178
|
def test_extend_large(self, size): return self.basic_test_extend(size)
|
def test_extend_large(self, size): return self.basic_test_extend(size)
| 7,179
|
def test_index(self, size): l = [1L, 2L, 3L, 4L, 5L] * (size // 5) self.assertEquals(l.index(1), 0) self.assertEquals(l.index(5, size - 5), size - 1) self.assertEquals(l.index(5, size - 5, size), size - 1) self.assertRaises(ValueError, l.index, 1, size - 4, size) self.assertRaises(ValueError, l.index, 6L)
|
def test_index(self, size): l = [1L, 2L, 3L, 4L, 5L] * size size *= 5 self.assertEquals(l.index(1), 0) self.assertEquals(l.index(5, size - 5), size - 1) self.assertEquals(l.index(5, size - 5, size), size - 1) self.assertRaises(ValueError, l.index, 1, size - 4, size) self.assertRaises(ValueError, l.index, 6L)
| 7,180
|
def test_insert(self, size): l = [1.0] * size l.insert(size - 1, "A") size += 1 self.assertEquals(len(l), size) self.assertEquals(l[-3:], [1.0, "A", 1.0])
|
def test_insert(self, size): l = [1.0] * size l.insert(size - 1, "A") size += 1 self.assertEquals(len(l), size) self.assertEquals(l[-3:], [1.0, "A", 1.0])
| 7,181
|
def test_pop(self, size): l = [u"a", u"b", u"c", u"d", u"e"] * (size // 5) self.assertEquals(len(l), size)
|
def test_pop(self, size): l = [u"a", u"b", u"c", u"d", u"e"] * size size *= 5 self.assertEquals(len(l), size)
| 7,182
|
def test_remove(self, size): l = [10] * size self.assertEquals(len(l), size)
|
def test_remove(self, size): l = [10] * size self.assertEquals(len(l), size)
| 7,183
|
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1])
|
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * size l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1])
| 7,184
|
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1])
|
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size * 5) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1])
| 7,185
|
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1])
|
def test_reverse(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.reverse() self.assertEquals(len(l), size) self.assertEquals(l[-5:], [5, 4, 3, 2, 1]) self.assertEquals(l[:5], [5, 4, 3, 2, 1])
| 7,186
|
def test_sort(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.sort() self.assertEquals(len(l), size) self.assertEquals(l.count(1), size // 5) self.assertEquals(l[:10], [1] * 10) self.assertEquals(l[-10:], [5] * 10)
|
def test_sort(self, size): l = [1, 2, 3, 4, 5] * size l.sort() self.assertEquals(len(l), size) self.assertEquals(l.count(1), size // 5) self.assertEquals(l[:10], [1] * 10) self.assertEquals(l[-10:], [5] * 10)
| 7,187
|
def test_sort(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.sort() self.assertEquals(len(l), size) self.assertEquals(l.count(1), size // 5) self.assertEquals(l[:10], [1] * 10) self.assertEquals(l[-10:], [5] * 10)
|
def test_sort(self, size): l = [1, 2, 3, 4, 5] * (size // 5) l.sort() self.assertEquals(len(l), size * 5) self.assertEquals(l.count(1), size) self.assertEquals(l[:10], [1] * 10) self.assertEquals(l[-10:], [5] * 10)
| 7,188
|
def getargsCheck(self, name): pass
|
def getargsCheck(self, name): pass
| 7,189
|
def test_both(): "Test mmap module on Unix systems and Windows" # Create an mmap'ed file f = open('foo', 'w+') # Write 2 pages worth of data to the file f.write('\0'* PAGESIZE) f.write('foo') f.write('\0'* (PAGESIZE-3) ) m = mmap.mmap(f.fileno(), 2 * PAGESIZE) f.close() # Simple sanity checks print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages' assert string.find(m, 'foo') == PAGESIZE print ' Length of file:', len(m) / float(PAGESIZE), 'pages' assert len(m) == 2*PAGESIZE print ' Contents of byte 0:', repr(m[0]) assert m[0] == '\0' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '\0\0\0' # Modify the file's content print "\n Modifying file's content..." m[0] = '3' m[PAGESIZE +3: PAGESIZE +3+3]='bar' # Check that the modification worked print ' Contents of byte 0:', repr(m[0]) assert m[0] == '3' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '3\0\0' print ' Contents of second page:', m[PAGESIZE-1 : PAGESIZE + 7] assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0' m.flush() # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) if match == None: print ' ERROR: regex match on mmap failed!' else: start, end = match.span(0) length = end - start print ' Regex match on mmap (page start, length of match):', print start / float(PAGESIZE), length assert start == PAGESIZE assert end == PAGESIZE + 6 # test seeking around (try to overflow the seek implementation) m.seek(0,0) print ' Seek to zeroth byte' assert m.tell() == 0 m.seek(42,1) print ' Seek to 42nd byte' assert m.tell() == 42 m.seek(0,2) print ' Seek to last byte' assert m.tell() == len(m) print ' Try to seek to negative position...' try: m.seek(-1) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek beyond end of mmap...' try: m.seek(1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek to negative position...' try: m.seek(-len(m)-1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' # Try resizing map print ' Attempting resize()' try: m.resize( 512 ) except SystemError: # resize() not supported # No messages are printed, since the output of this test suite # would then be different across platforms. pass else: # resize() is supported assert len(m) == 512, "len(m) is %d, but expecting 512" % (len(m),) # Check that we can no longer seek beyond the new size. try: m.seek(513,0) except ValueError: pass else: assert 0, 'Could seek beyond the new size' m.close() os.unlink("foo") print ' Test passed'
|
def test_both(): "Test mmap module on Unix systems and Windows" # Create an mmap'ed file f = open('foo', 'w+') # Write 2 pages worth of data to the file f.write('\0'* PAGESIZE) f.write('foo') f.write('\0'* (PAGESIZE-3) ) m = mmap.mmap(f.fileno(), 2 * PAGESIZE) f.close() # Simple sanity checks print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages' assert string.find(m, 'foo') == PAGESIZE print ' Length of file:', len(m) / float(PAGESIZE), 'pages' assert len(m) == 2*PAGESIZE print ' Contents of byte 0:', repr(m[0]) assert m[0] == '\0' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '\0\0\0' # Modify the file's content print "\n Modifying file's content..." m[0] = '3' m[PAGESIZE +3: PAGESIZE +3+3]='bar' # Check that the modification worked print ' Contents of byte 0:', repr(m[0]) assert m[0] == '3' print ' Contents of first 3 bytes:', repr(m[0:3]) assert m[0:3] == '3\0\0' print ' Contents of second page:', m[PAGESIZE-1 : PAGESIZE + 7] assert m[PAGESIZE-1 : PAGESIZE + 7] == '\0foobar\0' m.flush() # Test doing a regular expression match in an mmap'ed file match=re.search('[A-Za-z]+', m) if match == None: print ' ERROR: regex match on mmap failed!' else: start, end = match.span(0) length = end - start print ' Regex match on mmap (page start, length of match):', print start / float(PAGESIZE), length assert start == PAGESIZE assert end == PAGESIZE + 6 # test seeking around (try to overflow the seek implementation) m.seek(0,0) print ' Seek to zeroth byte' assert m.tell() == 0 m.seek(42,1) print ' Seek to 42nd byte' assert m.tell() == 42 m.seek(0,2) print ' Seek to last byte' assert m.tell() == len(m) print ' Try to seek to negative position...' try: m.seek(-1) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek beyond end of mmap...' try: m.seek(1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' print ' Try to seek to negative position...' try: m.seek(-len(m)-1,2) except ValueError: pass else: assert 0, 'expected a ValueError but did not get it' # Try resizing map print ' Attempting resize()' try: m.resize( 512 ) except SystemError: # resize() not supported # No messages are printed, since the output of this test suite # would then be different across platforms. pass else: # resize() is supported assert len(m) == 512, "len(m) is %d, but expecting 512" % (len(m),) # Check that we can no longer seek beyond the new size. try: m.seek(513,0) except ValueError: pass else: assert 0, 'Could seek beyond the new size' m.close() os.unlink("foo") print ' Test passed'
| 7,190
|
def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir self.mofile = MOFILE gettext.install('gettext', self.localedir)
|
def setUp(self): GettextBaseTest.setUp(self) self.localedir = os.curdir self.mofile = MOFILE gettext.install('gettext', self.localedir)
| 7,191
|
def tearDown(self): GettextBaseTest.tearDown(self)
|
def tearDown(self): GettextBaseTest.tearDown(self)
| 7,192
|
def tearDown(self): GettextBaseTest.tearDown(self)
|
def tearDown(self): GettextBaseTest.tearDown(self)
| 7,193
|
def tearDown(self): GettextBaseTest.tearDown(self)
|
def tearDown(self): GettextBaseTest.tearDown(self)
| 7,194
|
def msvc_prelink_hack (self, sources, ext, extra_args):
|
def msvc_prelink_hack (self, sources, ext, extra_args):
| 7,195
|
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
|
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + str(done[n]) + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
| 7,196
|
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
|
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: done[name] = string.strip(value) else: done[name] = value del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: done[name] = string.strip(value) else: done[name] = value del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
| 7,197
|
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
|
def parse_makefile(fn, g=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ from distutils.text_file import TextFile fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1) if g is None: g = {} done = {} notdone = {} while 1: line = fp.readline() if line is None: # eof break m = _variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here while notdone: for name in notdone.keys(): value = notdone[name] m = _findvar1_rx.search(value) or _findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: done[name] = string.strip(value) else: done[name] = value del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: done[name] = string.strip(value) else: done[name] = value del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] fp.close() # save the results in the global dictionary g.update(done) return g
| 7,198
|
def decode(input, output): """Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods.""" new = '' while 1: line = input.readline() if not line: break i, n = 0, len(line) if n > 0 and line[n-1] == '\n': partial = 0; n = n-1 # Strip trailing whitespace while n > 0 and line[n-1] in (' ', '\t'): n = n-1 else: partial = 1 while i < n: c = line[i] if c != ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: partial = 1; break elif i+1 < n and line[i+1] == ESCAPE: new = new + ESCAPE; i = i+2 elif i+2 < n and ishex(line[i+1]) and ishex(line[i+2]): new = new + chr(unhex(line[i+1:i+3])); i = i+3 else: # Bad escape sequence -- leave it in new = new + c; i = i+1 if not partial: output.write(new + '\n') new = '' if new: output.write(new)
|
def decode(input, output): """Read 'input', apply quoted-printable decoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods.""" new = '' while 1: line = input.readline() if not line: break i, n = 0, len(line) if n > 0 and line[n-1] == '\n': partial = 0; n = n-1 # Strip trailing whitespace while n > 0 and line[n-1] in " \t\r": n = n-1 else: partial = 1 while i < n: c = line[i] if c != ESCAPE: new = new + c; i = i+1 elif i+1 == n and not partial: partial = 1; break elif i+1 < n and line[i+1] == ESCAPE: new = new + ESCAPE; i = i+2 elif i+2 < n and ishex(line[i+1]) and ishex(line[i+2]): new = new + chr(unhex(line[i+1:i+3])); i = i+3 else: # Bad escape sequence -- leave it in new = new + c; i = i+1 if not partial: output.write(new + '\n') new = '' if new: output.write(new)
| 7,199
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.