Pads an input string to a given block size.
    :param s: string
    :returns: The padded string.
979446
def old_pad(s):
    
    if len(s) % OLD_BLOCK_SIZE == 0:
        return s

    return Padding.appendPadding(s, blocksize=OLD_BLOCK_SIZE)
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
254327
def _padleft(width, s, has_invisible=True):
    

    def impl(val):
        iwidth = width + len(val) - len(_strip_invisible(val)) if has_invisible else width
        fmt = "{0:>%ds}" % iwidth
        return fmt.format(val)

    num_lines = s.splitlines()
    return len(num_lines) > 1 and '\n'.join(map(impl, num_lines)) or impl(s)
1298371
def pad(text, length):
    """"""
    text_length = wcswidth(text)

    if text_length < length:
        return text + ' ' * (length - text_length)

    return text
746221
function pad(number, size) {
        var stringNum = String(number);

        while (stringNum.length < (size || 2)) {
            stringNum = '0' + stringNum;
        }

        return stringNum;
    }
177993
def pad(s, n, p = " ", sep = "|", align = "left"):
    
    if align == "left":
        return (s + (p * n))[:n] + sep
    elif align == "center":
        pos = n + len(s)/2 - n/2
        return ((p * n) + s + (p * n))[pos:pos + n] + sep
    elif align == "right":
        return ((p * n) + s)[-n:] + sep
412908
def pad(obj, pad_length):
    
    _check_supported(obj)
    copied = deepcopy(obj)
    copied.pad(pad_length)
    return copied
729686
function rpad(str, width) {
    str = String(str);
    var n = width - str.length;
    if (n < 1) return str;
    while (n--) str = str + ' ';
    return str;
}
934444
def left_zero_pad(s, blocksize):
    
    if blocksize > 0 and len(s) % blocksize:
        s = (blocksize - len(s) % blocksize) * b('\000') + s
    return s
441327
function pad (content, length) {
    content = content || ''

    while (content.length < length) {
      content = content + ' '
    }

    return content
  }
265657
def pad(cls, data):
        
        if sys.version_info > (3, 0):
            try:
                data = data.encode("utf-8")
            except AttributeError:
                pass

            length = AES.block_size - (len(data) % AES.block_size)
            data += bytes([length]) * length
            return data
        else:
            return data + (AES.block_size - len(data) % AES.block_size) * chr(AES.block_size - len(data) % AES.block_size)
1296756
def to_bytes(x, blocksize=0):
    
    if isinstance(x, bytearray):
        return left_zero_pad(bytes(x), blocksize)
    elif isinstance(x, basestring):
        return left_zero_pad(x, blocksize)
    elif isinstance(x, (list, tuple)):
        return left_zero_pad(bytes(bytearray(x)), blocksize)
    elif isinstance(x, (long, int)):
        return long_to_bytes(x, blocksize)
    else:
        raise ValueError('Unknown input argument type')
122233
public static String pad(String s, int length)
  {
    if (s.length() < length)
    {
      StringBuffer a = new StringBuffer(length);
      a.append(s);
      for (int i = s.length(); i < length; i++)
      {
        a = a.append(" ");
      }
      return a.toString();
    }
    else if (s.length() > length)
    {
      return s.substring(0, length);
    }
    else
    {
      return s;
    }
  }
1101536
def padStr(s, field=None):
    
    if field is None:
        return s
    else:
      if len(s) >= field:
          return s
      else:
          return " " * (field - len(s)) + s
870248
def removeRandomLenPadding(str, blocksize=AES_blocksize):
  ''
  pad_len = ord(str[-1]) # last byte contains number of padding bytes
  assert pad_len < blocksize, 'padding error' 
  assert pad_len < len(str), 'padding error'
    
  return str[:-pad_len]
889673
def block_size(self):
        
        bs = self.attributes['block_size']
        if isinstance(bs, six.string_types):
            bs = shlex.split(bs)
        bs = [str(e) for e in bs]
        return bs
1144653
function stringPadStart (str, targetLength, padString, UNDEFINED) {
  var rest = '' + str
  targetLength = targetLength >> 0
  padString = padString === UNDEFINED ? ' ' : '' + padString
  if (rest.padStart) {
    return rest.padStart(targetLength, padString)
  }
  if (targetLength > rest.length) {
    targetLength -= rest.length
    if (targetLength > padString.length) {
      padString += stringRepeat(padString, targetLength / padString.length)
    }
    return padString.slice(0, targetLength) + rest
  }
  return rest
}