str: The IBAN formatted in blocks of 4 digits.
4648
def formatted(self):
        """"""
        return ' '.join(self.compact[i:i + 4] for i in range(0, len(self.compact), 4))
1004382
def e164(number):
    '''
    
    '''
    if isinstance(number, six.integer_types):
        return e164('+%s' % number)

    elif isinstance(number, six.string_types):
        number = strip(number, '-. ()')
        if number.startswith('+'):
            number = number[1:]

        return u'+%s' % number
808858
def bytes_to_str(self, b):
        ""
        if PYTHON_MAJOR_VER == 3:
            return b.decode(charset_map.get(self.charset, self.charset))
        return b
222156
def parse_blockwise(value):
    

    length = byte_len(value)
    if length == 1:
        num = value & 0xF0
        num >>= 4
        m = value & 0x08
        m >>= 3
        size = value & 0x07
    elif length == 2:
        num = value & 0xFFF0
        num >>= 4
        m = value & 0x0008
        m >>= 3
        size = value & 0x0007
    else:
        num = value & 0xFFFFF0
        num >>= 4
        m = value & 0x000008
        m >>= 3
        size = value & 0x000007
    return num, int(m), pow(2, (size + 4))
117128
def string_pieces(s, maxlen=1024):
    
    if not s:
        return
    i = 0
    while True:
        j = i + maxlen
        if j >= len(s):
            yield s[i:]
            return
        # Using "j - 1" keeps boundary characters with the left chunk
        while unicodedata.category(s[j - 1]) not in BOUNDARY_CATEGORIES:
            j -= 1
            if j == i:
                # No boundary available; oh well.
                j = i + maxlen
                break
        yield s[i:j]
        i = j
273155
function (n) {
            var nybHexString = '0123456789ABCDEF';
            return (
                String(nybHexString.substr((n >> 4) & 0x0F, 1)) +
                String(nybHexString.substr(n & 0x0F, 1))
            );
        }
950417
def _calculate_german_iban_checksum(iban,
                                    iban_fields='DEkkbbbbbbbbcccccccccc'):
    
    number = [value
              for field_type, value in zip(iban_fields, iban)
              if field_type in ['b', 'c']]
    translate = {'0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5',
                 '6': '6', '7': '7', '8': '8', '9': '9'}
    for i in range(ord('A'), ord('Z') + 1):
        translate[chr(i)] = str(i - ord('A') + 10)
    for val in 'DE00':
        translated = translate[val]
        for char in translated:
            number.append(char)
    number = sum(int(value) * 10**i for i, value in enumerate(number[::-1]))
    checksum = 98 - (number % 97)
    return str(checksum)
494025
def is_uuid4(instr):
  
  v = instr.strip().replace('-','').lower()
  if len(v) != 32: return False
  if not re.match('^[0-9a-f]+$',v): return False
  if v[12] != '4': return False
  if not re.match('[89ab]',v[16]): return False
  return True
1341225
def removeBitPadding(str, blocksize=AES_blocksize):
    ''
    pad_len = 0    
    for char in str[::-1]: # str[::-1] reverses string
        if char == '\0':
            pad_len += 1
        else:
            break
    pad_len += 1
    str = str[:-pad_len]
   
    return str
499572
def parameter_blocks(self):
        ''''''
        bytes = 4. + sum(g.binary_size() for g in self.groups.values())
        return int(np.ceil(bytes / 512))
956227
function generateFrame(str) {
    var i, j, k, m, t, v, x, y;

    // Find the smallest version that fits the string.
    t = str.length;

    version = 0;

    do {
      version++;

      k = (eccLevel - 1) * 4 + (version - 1) * 16;

      neccBlock1 = ECC_BLOCKS[k++];
      neccBlock2 = ECC_BLOCKS[k++];
      dataBlock  = ECC_BLOCKS[k++];
      eccBlock   = ECC_BLOCKS[k];

      k = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (version <= 9);

      if (t <= k) break;
    } while (version < 40);

    // FIXME: Ensure that it fits insted of being truncated.
    width = 17 + 4 * version;

    // Allocate, clear and setup data structures.
    v = dataBlock + (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2;

    for (t = 0; t < v; t++) {
      eccBuffer[t] = 0;
    }

    stringBuffer = str.slice(0);

    for (t = 0; t < width * width; t++) {
      frameBuffer[t] = 0;
    }

    for (t = 0; t < (width * (width + 1) + 1) / 2; t++) {
      frameMask[t] = 0;
    }

    // Insert finders: Foreground colour to frame and background to mask.
    for (t = 0; t < 3; t++) {
      k = y = 0;

      if (t === 1) k = (width - 7);
      if (t === 2) y = (width - 7);

      frameBuffer[(y + 3) + width * (k + 3)] = 1;

      for (x = 0; x < 6; x++) {
        frameBuffer[(y + x) + width * k] = 1;
        frameBuffer[y + width * (k + x + 1)] = 1;
        frameBuffer[(y + 6) + width * (k + x)] = 1;
        frameBuffer[(y + x + 1) + width * (k + 6)] = 1;
      }

      for (x = 1; x < 5; x++) {
        setMask(y + x, k + 1);
        setMask(y + 1, k + x + 1);
        setMask(y + 5, k + x);
        setMask(y + x + 1, k + 5);
      }

      for (x = 2; x < 4; x++) {
        frameBuffer[(y + x) + width * (k + 2)] = 1;
        frameBuffer[(y + 2) + width * (k + x + 1)] = 1;
        frameBuffer[(y + 4) + width * (k + x)] = 1;
        frameBuffer[(y + x + 1) + width * (k + 4)] = 1;
      }
    }

    // Alignment blocks.
    if (version > 1) {
      t = ALIGNMENT_DELTA[version];
      y = width - 7;

      for (;;) {
        x = width - 7;

        while (x > t - 3) {
          addAlignment(x, y);

          if (x < t) break;

          x -= t;
        }

        if (y <= t + 9) break;

        y -= t;

        addAlignment(6, y);
        addAlignment(y, 6);
      }
    }

    // Single foreground cell.
    frameBuffer[8 + width * (width - 8)] = 1;

    // Timing gap (mask only).
    for (y = 0; y < 7; y++) {
      setMask(7, y);
      setMask(width - 8, y);
      setMask(7, y + width - 7);
    }

    for (x = 0; x < 8; x++) {
      setMask(x, 7);
      setMask(x + width - 8, 7);
      setMask(x, width - 8);
    }

    // Reserve mask, format area.
    for (x = 0; x < 9; x++) {
      setMask(x, 8);
    }

    for (x = 0; x < 8; x++) {
      setMask(x + width - 8, 8);
      setMask(8, x);
    }

    for (y = 0; y < 7; y++) {
      setMask(8, y + width - 7);
    }

    // Timing row/column.
    for (x = 0; x < width - 14; x++) {
      if (x & 1) {
        setMask(8 + x, 6);
        setMask(6, 8 + x);
      } else {
        frameBuffer[(8 + x) + width * 6] = 1;
        frameBuffer[6 + width * (8 + x)] = 1;
      }
    }

    // Version block.
    if (version > 6) {
      t = VERSION_BLOCK[version - 7];
      k = 17;

      for (x = 0; x < 6; x++) {
        for (y = 0; y < 3; y++, k--) {
          if (1 & (k > 11 ? version >> (k - 12) : t >> k)) {
            frameBuffer[(5 - x) + width * (2 - y + width - 11)] = 1;
            frameBuffer[(2 - y + width - 11) + width * (5 - x)] = 1;
          } else {
            setMask(5 - x, 2 - y + width - 11);
            setMask(2 - y + width - 11, 5 - x);
          }
        }
      }
    }

    // Sync mask bits. Only set above for background cells, so now add the foreground.
    for (y = 0; y < width; y++) {
      for (x = 0; x <= y; x++) {
        if (frameBuffer[x + width * y]) {
          setMask(x, y);
        }
      }
    }

    // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji
    // not supported).
    v = stringBuffer.length;

    // String to array.
    for (i = 0; i < v; i++) {
      eccBuffer[i] = stringBuffer.charCodeAt(i);
    }

    stringBuffer = eccBuffer.slice(0);

    // Calculate max string length.
    x = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2;

    if (v >= x - 2) {
      v = x - 2;

      if (version > 9) v--;
    }

    // Shift and re-pack to insert length prefix.
    i = v;

    if (version > 9) {
      stringBuffer[i + 2] = 0;
      stringBuffer[i + 3] = 0;

      while (i--) {
        t = stringBuffer[i];

        stringBuffer[i + 3] |= 255 & (t << 4);
        stringBuffer[i + 2] = t >> 4;
      }

      stringBuffer[2] |= 255 & (v << 4);
      stringBuffer[1] = v >> 4;
      stringBuffer[0] = 0x40 | (v >> 12);
    } else {
      stringBuffer[i + 1] = 0;
      stringBuffer[i + 2] = 0;

      while (i--) {
        t = stringBuffer[i];

        stringBuffer[i + 2] |= 255 & (t << 4);
        stringBuffer[i + 1] = t >> 4;
      }

      stringBuffer[1] |= 255 & (v << 4);
      stringBuffer[0] = 0x40 | (v >> 4);
    }

    // Fill to end with pad pattern.
    i = v + 3 - (version < 10);

    while (i < x) {
      stringBuffer[i++] = 0xec;
      stringBuffer[i++] = 0x11;
    }

    // Calculate generator polynomial.
    polynomial[0] = 1;

    for (i = 0; i < eccBlock; i++) {
      polynomial[i + 1] = 1;

      for (j = i; j > 0; j--) {
        polynomial[j] = polynomial[j] ? polynomial[j - 1] ^
            GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[j]] + i)] : polynomial[j - 1];
      }

      polynomial[0] = GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[0]] + i)];
    }

    // Use logs for generator polynomial to save calculation step.
    for (i = 0; i <= eccBlock; i++) {
      polynomial[i] = GALOIS_LOG[polynomial[i]];
    }

    // Append ECC to data buffer.
    k = x;
    y = 0;

    for (i = 0; i < neccBlock1; i++) {
      appendData(y, dataBlock, k, eccBlock);

      y += dataBlock;
      k += eccBlock;
    }

    for (i = 0; i < neccBlock2; i++) {
      appendData(y, dataBlock + 1, k, eccBlock);

      y += dataBlock + 1;
      k += eccBlock;
    }

    // Interleave blocks.
    y = 0;

    for (i = 0; i < dataBlock; i++) {
      for (j = 0; j < neccBlock1; j++) {
        eccBuffer[y++] = stringBuffer[i + j * dataBlock];
      }

      for (j = 0; j < neccBlock2; j++) {
        eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))];
      }
    }

    for (j = 0; j < neccBlock2; j++) {
      eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))];
    }

    for (i = 0; i < eccBlock; i++) {
      for (j = 0; j < neccBlock1 + neccBlock2; j++) {
        eccBuffer[y++] = stringBuffer[x + i + j * eccBlock];
      }
    }

    stringBuffer = eccBuffer;

    // Pack bits into frame avoiding masked area.
    x = y = width - 1;
    k = v = 1;

    // inteleaved data and ECC codes.
    m = (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2;

    for (i = 0; i < m; i++) {
      t = stringBuffer[i];

      for (j = 0; j < 8; j++, t <<= 1) {
        if (0x80 & t) {
          frameBuffer[x + width * y] = 1;
        }

        // Find next fill position.
        do {
          if (v) {
            x--;
          } else {
            x++;

            if (k) {
              if (y !== 0) {
                y--;
              } else {
                x -= 2;
                k  = !k;

                if (x === 6) {
                  x--;
                  y = 9;
                }
              }
            } else {
              if (y !== width - 1) {
                y++;
              } else {
                x -= 2;
                k  = !k;

                if (x === 6) {
                  x--;
                  y -= 8;
                }
              }
            }
          }

          v = !v;
        } while (isMasked(x, y));
      }
    }

    // Save pre-mask copy of frame.
    stringBuffer = frameBuffer.slice(0);

    t = 0;
    y = 30000;

    // Using `for` instead of `while` since in original Arduino code if an early mask was *good
    // enough* it wouldn't try for a better one since they get more complex and take longer.
    for (k = 0; k < 8; k++) {
      // Returns foreground-background imbalance.
      applyMask(k);

      x = checkBadness();

      // Is current mask better than previous best?
      if (x < y) {
        y = x;
        t = k;
      }

      // Don't increment `i` to a void redoing mask.
      if (t === 7) break;

      // Reset for next pass.
      frameBuffer = stringBuffer.slice(0);
    }

    // Redo best mask as none were *good enough* (i.e. last wasn't `t`).
    if (t !== k) {
      applyMask(t);
    }

    // Add in final mask/ECC level bytes.
    y = FINAL_FORMAT[t + ((eccLevel - 1) << 3)];

    // Low byte.
    for (k = 0; k < 8; k++, y >>= 1) {
      if (y & 1) {
        frameBuffer[(width - 1 - k) + width * 8] = 1;

        if (k < 6) {
          frameBuffer[8 + width * k] = 1;
        } else {
          frameBuffer[8 + width * (k + 1)] = 1;
        }
      }
    }

    // High byte.
    for (k = 0; k < 7; k++, y >>= 1) {
      if (y & 1) {
        frameBuffer[8 + width * (width - 7 + k)] = 1;

        if (k) {
          frameBuffer[(6 - k) + width * 8] = 1;
        } else {
          frameBuffer[7 + width * 8] = 1;
        }
      }
    }

    // Finally, return the image data.
    return frameBuffer;
  }
1310111
def create_span(unirange, is_bytes=False):
    """"""

    if len(unirange) < 2:
        unirange.append(unirange[0])
    if is_bytes:
        if unirange[0] > MAXASCII:
            return None
        if unirange[1] > MAXASCII:
            unirange[1] = MAXASCII
    return [x for x in range(unirange[0], unirange[1] + 1)]
1134369
private String digit(Data data) {
	String rtn = "";
	while (data.srcCode.isValidIndex()) {
	    if (!data.srcCode.isCurrentBetween('0', '9')) break;
	    rtn += data.srcCode.getCurrentLower();
	    data.srcCode.next();
	}
	return rtn;
    }
551790
def _si(number):
    """"""
    prefixes = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
    while number > 1024:
        number /= 1024.0
        prefixes.pop(0)
    return '%0.2f%s' % (number, prefixes.pop(0))
1362151
def get_block_indentation(self, block_nb):
        """"""
        text = to_text_string(self.document().findBlockByNumber(block_nb).text())
        text = text.replace("\t", " "*self.tab_stop_width_spaces)
        return len(text)-len(text.lstrip())
355472
def bbox_str(bbox, pad=4, sep=', '):
     """
    if bbox is None:
        return 'None'
    fmtstr = sep.join(['%' + six.text_type(pad) + 'd'] * 4)
    return '(' + fmtstr % tuple(bbox) + ')'
951502
def padding(s, bs=AES.block_size):
    
    
    s = to_bytes(s)

    if len(s) % bs == 0:
        res = s + b''.join(map(to_bytes, [random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(bs - 1)])) + to_bytes(chr(96 - bs))
    elif len(s) % bs > 0 and len(s) > bs:
        res = s + b''.join(map(to_bytes, [random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(bs - len(s) % bs - 1)])) + to_bytes(chr(96 + len(s) % bs - bs))
    else:
        res = s + b''.join(map(to_bytes, [random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(bs - len(s) - 1)])) + to_bytes(chr(96 + len(s) - bs))
    return res