bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def __abs__(self, round=1, context=None): """Returns the absolute value of self. | def __abs__(self, round=1, context=None): """Returns the absolute value of self. | 21,500 |
def __add__(self, other, context=None): """Returns self + other. | def __add__(self, other, context=None): """Returns self + other. | 21,501 |
def __add__(self, other, context=None): """Returns self + other. | def __add__(self, other, context=None): """Returns self + other. | 21,502 |
def __add__(self, other, context=None): """Returns self + other. | def __add__(self, other, context=None): """Returns self + other. | 21,503 |
def __add__(self, other, context=None): """Returns self + other. | def __add__(self, other, context=None): """Returns self + other. | 21,504 |
def __sub__(self, other, context=None): """Return self + (-other)""" if context is None: context = getcontext() other = self._convert_other(other) | def __sub__(self, other, context=None): """Return self + (-other)""" if context is None: context = getcontext() other = self._convert_other(other) | 21,505 |
def __rsub__(self, other, context=None): """Return other + (-self)""" if context is None: context = getcontext() other = self._convert_other(other) | def __rsub__(self, other, context=None): """Return other + (-self)""" if context is None: context = getcontext() other = self._convert_other(other) | 21,506 |
def _increment(self, round=1, context=None): """Special case of add, adding 1eExponent | def _increment(self, round=1, context=None): """Special case of add, adding 1eExponent | 21,507 |
def __mul__(self, other, context=None): """Return self * other. | def __mul__(self, other, context=None): """Return self * other. | 21,508 |
def __mul__(self, other, context=None): """Return self * other. | def __mul__(self, other, context=None): """Return self * other. | 21,509 |
def __mul__(self, other, context=None): """Return self * other. | def __mul__(self, other, context=None): """Return self * other. | 21,510 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,511 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,512 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,513 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,514 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,515 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,516 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,517 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,518 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,519 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,520 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,521 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,522 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,523 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,524 |
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision. | 21,525 |
def __rdiv__(self, other, context=None): """Swaps self/other and returns __div__.""" other = self._convert_other(other) return other.__div__(self, context=context) | def __rdiv__(self, other, context=None): """Swaps self/other and returns __div__.""" other = _convert_other(other) return other.__div__(self, context=context) | 21,526 |
def __rdivmod__(self, other, context=None): """Swaps self/other and returns __divmod__.""" other = self._convert_other(other) return other.__divmod__(self, context=context) | def __rdivmod__(self, other, context=None): """Swaps self/other and returns __divmod__.""" other = _convert_other(other) return other.__divmod__(self, context=context) | 21,527 |
def __mod__(self, other, context=None): """ self % other """ if context is None: context = getcontext() other = self._convert_other(other) | def __mod__(self, other, context=None): """ self % other """ if context is None: context = getcontext() other = self._convert_other(other) | 21,528 |
def __rfloordiv__(self, other, context=None): """Swaps self/other and returns __floordiv__.""" other = self._convert_other(other) return other.__floordiv__(self, context=context) | def __rfloordiv__(self, other, context=None): """Swaps self/other and returns __floordiv__.""" other = _convert_other(other) return other.__floordiv__(self, context=context) | 21,529 |
def __int__(self): """Converts self to a int, truncating if necessary.""" if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if not self: return 0 sign = '-'*self._sign if self._exp >= 0: s = sign + ''.join... | def __int__(self): """Converts self to a int, truncating if necessary.""" if self._is_special: if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if not self: return 0 sign = '-'*self._sign if self._exp >= ... | 21,530 |
def __int__(self): """Converts self to a int, truncating if necessary.""" if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if not self: return 0 sign = '-'*self._sign if self._exp >= 0: s = sign + ''.join... | def __int__(self): """Converts self to a int, truncating if necessary.""" if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if not self: return 0 sign = '-'*self._sign if self._exp >= 0: s = sign + ''.join... | 21,531 |
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision. | def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision. | 21,532 |
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision. | def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision. | 21,533 |
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, E... | def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._is_special: return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, Ema... | 21,534 |
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, E... | def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin = ... | 21,535 |
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, E... | def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, E... | 21,536 |
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, E... | def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, E... | 21,537 |
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, E... | def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, E... | 21,538 |
def _round(self, prec=None, rounding=None, context=None): """Returns a rounded version of self. | def _round(self, prec=None, rounding=None, context=None): """Returns a rounded version of self. | 21,539 |
def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) | def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) | 21,540 |
def __rpow__(self, other, context=None): """Swaps self/other and returns __pow__.""" other = self._convert_other(other) return other.__pow__(self, context=context) | def __rpow__(self, other, context=None): """Swaps self/other and returns __pow__.""" other = _convert_other(other) return other.__pow__(self, context=context) | 21,541 |
def normalize(self, context=None): """Normalize- strip trailing 0s, change anything equal to 0 to 0e0""" if context is None: context = getcontext() | def normalize(self, context=None): """Normalize- strip trailing 0s, change anything equal to 0 to 0e0""" if context is None: context = getcontext() | 21,542 |
def quantize(self, exp, rounding = None, context=None, watchexp = 1): """Quantize self so its exponent is the same as that of exp. | def quantize(self, exp, rounding = None, context=None, watchexp = 1): """Quantize self so its exponent is the same as that of exp. | 21,543 |
def same_quantum(self, other): """Test whether self and other have the same exponent. | def same_quantum(self, other): """Test whether self and other have the same exponent. | 21,544 |
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp. | def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp. | 21,545 |
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp. | def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp. | 21,546 |
def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp. | def _rescale(self, exp, rounding = None, context=None, watchexp = 1): """Rescales so that the exponent is exp. | 21,547 |
def to_integral(self, rounding = None, context=None): """Rounds to the nearest integer, without raising inexact, rounded.""" if context is None: context = getcontext() ans = self._check_nans(context=context) if ans: return ans if self._exp >= 0: return self flags = context._ignore_flags(Rounded, Inexact) ans = self._re... | def to_integral(self, rounding = None, context=None): """Rounds to the nearest integer, without raising inexact, rounded.""" if context is None: context = getcontext() flags = context._ignore_flags(Rounded, Inexact) ans = self._rescale(0, rounding, context=context) context._regard_flags(flags) return ans | 21,548 |
def sqrt(self, context=None): """Return the square root of self. | def sqrt(self, context=None): """Return the square root of self. | 21,549 |
def sqrt(self, context=None): """Return the square root of self. | def sqrt(self, context=None): """Return the square root of self. | 21,550 |
def max(self, other, context=None): """Returns the larger value. | def max(self, other, context=None): """Returns the larger value. | 21,551 |
def min(self, other, context=None): """Returns the smaller value. | def min(self, other, context=None): """Returns the smaller value. | 21,552 |
def to_integral(self, a): """Rounds to an integer. | def to_integral(self, a): """Rounds to an integer. | 21,553 |
def __init__(self, value=None): if value is None: self.sign = None self.int = [] self.exp = None if isinstance(value, Decimal): if value._sign: self.sign = -1 else: self.sign = 1 self.int = list(value._int) self.exp = value._exp if isinstance(value, tuple): self.sign = value[0] self.int = value[1] self.exp = value[2] | def __init__(self, value=None): if value is None: self.sign = None self.int = 0 self.exp = None if isinstance(value, Decimal): if value._sign: self.sign = -1 else: self.sign = 1 self.int = list(value._int) self.exp = value._exp if isinstance(value, tuple): self.sign = value[0] self.int = value[1] self.exp = value[2] | 21,554 |
def __init__(self, value=None): if value is None: self.sign = None self.int = [] self.exp = None if isinstance(value, Decimal): if value._sign: self.sign = -1 else: self.sign = 1 self.int = list(value._int) self.exp = value._exp if isinstance(value, tuple): self.sign = value[0] self.int = value[1] self.exp = value[2] | def __init__(self, value=None): if value is None: self.sign = None self.int = [] self.exp = None if isinstance(value, Decimal): if value._sign: self.sign = -1 else: self.sign = 1 cum = 0 for digit in value._int: cum = cum * 10 + digit self.int = cum self.exp = value._exp if isinstance(value, tuple): self.sign = value[0... | 21,555 |
def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if len(int1) > len(int2): return direct... | def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if int1 > int2: return direction * 1 if... | 21,556 |
def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if len(int1) > len(int2): return direct... | def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if len(int1) > len(int2): return direct... | 21,557 |
def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if len(int1) > len(int2): return direct... | def __cmp__(self, other): if self.exp != other.exp: raise ValueError("Operands not normalized: %r, %r" % (self, other)) if self.sign != other.sign: if self.sign == -1: return -1 else: return 1 if self.sign == -1: direction = -1 else: direction = 1 int1 = self.int int2 = other.int if len(int1) > len(int2): return direct... | 21,558 |
def _increment(self): curspot = len(self.int) - 1 self.int[curspot]+= 1 while (self.int[curspot] >= 10): self.int[curspot] -= 10 if curspot == 0: self.int[0:0] = [1] break self.int[curspot-1] += 1 curspot -= 1 | def _increment(self): curspot = len(self.int) - 1 self.int[curspot]+= 1 while (self.int[curspot] >= 10): self.int[curspot] -= 10 if curspot == 0: self.int[0:0] = [1] break self.int[curspot-1] += 1 curspot -= 1 | 21,559 |
def _normalize(op1, op2, shouldround = 0, prec = 0): """Normalizes op1, op2 to have the same exp and length of coefficient. Done during addition. """ # Yes, the exponent is a long, but the difference between exponents # must be an int-- otherwise you'd get a big memory problem. numdigits = int(op1.exp - op2.exp) if nu... | def _normalize(op1, op2, shouldround = 0, prec = 0): """Normalizes op1, op2 to have the same exp and length of coefficient. Done during addition. """ # Yes, the exponent is a long, but the difference between exponents # must be an int-- otherwise you'd get a big memory problem. numdigits = int(op1.exp - op2.exp) if nu... | 21,560 |
def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.int... | def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int * 10 > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.in... | 21,561 |
def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.int... | def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.int... | 21,562 |
def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.int... | def _adjust_coefficients(op1, op2): """Adjust op1, op2 so that op2.int+[0] > op1.int >= op2.int. Returns the adjusted op1, op2 as well as the change in op1.exp-op2.exp. Used on _WorkRep instances during division. """ adjust = 0 #If op1 is smaller, get it to same size if len(op2.int) > len(op1.int): diff = len(op2.int... | 21,563 |
def test_boom(): a = Boom() b = Boom() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b # a<->b are in a trash cycle now. Collection will invoke Boom.__getattr__ # (to see whether a and b have __del__ methods), and __getattr__ deletes # the internal "attr" attributes as a side effect. That ca... | def test_boom(): a = Boom() b = Boom() a.attr = b b.attr = a gc.collect() garbagelen = len(gc.garbage) del a, b # a<->b are in a trash cycle now. Collection will invoke Boom.__getattr__ # (to see whether a and b have __del__ methods), and __getattr__ deletes # the internal "attr" attributes as a side effect. That ca... | 21,564 |
def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). | def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). | 21,565 |
def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). | def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). | 21,566 |
def sample(self, population, k, random=None, int=int): """Chooses k unique random elements from a population sequence. | def sample(self, population, k, random=None, int=int): """Chooses k unique random elements from a population sequence. | 21,567 |
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren... | def handle_args(doc): for node in find_all_elements(doc, "args"): parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.removeChild(n) desc.appendChild(n) if node.ch... | 21,568 |
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren... | def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != "args": nodes.append(n) desc = doc.createElement("description") for n in nodes: parent.re... | 21,569 |
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren... | def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren... | 21,570 |
def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren... | def rewrite_desc_entries(doc, argname_gi): argnodes = doc.getElementsByTagName(argname_gi) for node in argnodes: parent = node.parentNode nodes = [] for n in parent.childNodes: if n.nodeType != xml.dom.core.ELEMENT or n.tagName != argname_gi: nodes.append(n) desc = doc.createElement("description") for n in nodes: paren... | 21,571 |
def handle_labels(doc): for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT: labels = node.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.s... | def handle_labels(doc): for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT: labels = node.getElementsByTagName("label") for label in labels: id = label.getAttribute("id") if not id: continue parent = label.parentNode if parent.tagName == "title": parent.parentNode.setAttribute("id", id) else: parent.s... | 21,572 |
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == xml.dom.core.TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extrac... | def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == xml.dom.core.TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extrac... | 21,573 |
def cleanup_synopses(doc): for node in doc.childNodes: if node.nodeType == xml.dom.core.ELEMENT \ and node.tagName == "section": create_module_info(doc, node) | def cleanup_synopses(doc): for node in find_all_elements(doc, "section"): create_module_info(doc, node) | 21,574 |
def fixup_table_structures(doc): # must be done after remap_element_names(), or the tables won't be found for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT: tables = child.getElementsByTagName("table") for table in tables: fixup_table(doc, table) | def fixup_table_structures(doc): # must be done after remap_element_names(), or the tables won't be found for table in find_all_elements(doc, "table"): fixup_table(doc, table) | 21,575 |
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep)) | def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep)) | 21,576 |
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep)) | def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep)) | 21,577 |
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep)) | def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep)) | 21,578 |
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep)) | def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == xml.dom.core.ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep)) | 21,579 |
def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up <descripti... | def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in RECURSE_INTO_PARA_CONTAINERS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up ... | 21,580 |
def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: if DEBUG_PARA_FIXER: sys.stderr.write("-- Fixing up <descripti... | def fixup_paras(doc): for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT \ and child.tagName in FIXUP_PARA_ELEMENTS: fixup_paras_helper(doc, child) descriptions = child.getElementsByTagName("description") for description in descriptions: fixup_paras_helper(doc, description) | 21,581 |
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, sta... | def fixup_paras_helper(doc, container, depth=0): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tag... | 21,582 |
def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, sta... | def fixup_paras_helper(doc, container): # document is already normalized children = container.childNodes start = 0 start_fixed = 0 i = len(children) SKIP_ELEMENTS = PARA_LEVEL_ELEMENTS + PARA_LEVEL_PRECEEDERS if DEBUG_PARA_FIXER: sys.stderr.write("fixup_paras_helper() called on <%s>; %d, %d\n" % (container.tagName, sta... | 21,583 |
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy... | def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy... | 21,584 |
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy... | def build_para(doc, parent, start, i): # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeType = child.nodeType if nodeTy... | 21,585 |
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy... | def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy... | 21,586 |
def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy... | def build_para(doc, parent, start, i): children = parent.childNodes # collect all children until \n\n+ is found in a text node or a # PARA_LEVEL_ELEMENT is found. after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + FIXUP_PARA_ELEMENTS for j in range(start, i): after = j + 1 child = children[j] nodeTy... | 21,587 |
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ... | def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: child = children[start] nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: start = start + 1 elif nodeType == xml.dom.core.TEXT: data = child.data shortened = string.lstrip(dat... | 21,588 |
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ... | def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.TEXT: dat... | 21,589 |
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ... | def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ... | 21,590 |
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ... | def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ... | 21,591 |
def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ... | def skip_leading_nodes(children, start, i): i = min(i, len(children)) while i > start: # skip over leading comments and whitespace: try: child = children[start] except IndexError: sys.stderr.write( "skip_leading_nodes() failed at index %d\n" % start) raise nodeType = child.nodeType if nodeType == xml.dom.core.COMMENT: ... | 21,592 |
def fixup_rfc_references(doc): rfc_nodes = [] for child in doc.childNodes: if child.nodeType == xml.dom.core.ELEMENT: kids = child.getElementsByTagName("rfc") for k in kids: rfc_nodes.append(k) for rfc_node in rfc_nodes: rfc_node.appendChild(doc.createTextNode( "RFC " + rfc_node.getAttribute("num"))) | def fixup_rfc_references(doc): for rfcnode in find_all_elements(doc, "rfc"): rfcnode.appendChild(doc.createTextNode( "RFC " + rfcnode.getAttribute("num"))) | 21,593 |
def end_blockquote(self): self.formatter.end_paragraph(0) self.formatter.pop_margin() | def end_blockquote(self): self.formatter.end_paragraph(1) self.formatter.pop_margin() | 21,594 |
def start_dl(self, attrs): self.formatter.end_paragraph(0) self.list_stack.append(['dl', '', 0]) | def start_dl(self, attrs): self.formatter.end_paragraph(1) self.list_stack.append(['dl', '', 0]) | 21,595 |
def end_dl(self): self.ddpop() if self.list_stack: del self.list_stack[-1] | def end_dl(self): self.ddpop(1) if self.list_stack: del self.list_stack[-1] | 21,596 |
def ddpop(self): self.formatter.end_paragraph(0) if self.list_stack: if self.list_stack[-1][0] == 'dd': | def ddpop(self, bl=0): self.formatter.end_paragraph(bl) if self.list_stack: if self.list_stack[-1][0] == 'dd': | 21,597 |
def start_string(self, attrs): self.start_b(attrs) | def start_string(self, attrs): self.start_b(attrs) | 21,598 |
def end_var(self): self.end_var() | def end_var(self): self.end_var() | 21,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.