Printable Mobile Equipment Identifier (MEID) number.

    >>> print(meid(123456789012345678))
    1B 69B4BA 630F34 6
    >>> print(meid('1B69B4BA630F34'))
    1B 69B4BA 630F34 6

def meid(number, separator=u' '):
    '''
    Printable Mobile Equipment Identifier (MEID) number.

    >>> print(meid(123456789012345678))
    1B 69B4BA 630F34 6
    >>> print(meid('1B69B4BA630F34'))
    1B 69B4BA 630F34 6
    '''

    if isinstance(number, six.string_types):
        number = re.sub(r'[\s-]', '', number)

        try:
            number = '%014X' % int(number, 16)
        except ValueError:
            if len(number) < 18 and number.isdigit():
                return meid('%014X' % int(number), separator)
            else:
                raise ValueError(_('Invalid MEID, size mismatch'))
        else:
            if len(number) not in (14, 15):
                raise ValueError(_('Invalid MEID, size mismatch'))

    elif isinstance(number, six.integer_types):
        if number > 0xfffffffffffffff:
                raise ValueError(_('Invalid MEID, size mismatch'))
        return meid(('%014X' % number)[:14], separator)

    else:
        raise TypeError(_('Invalid MEID, input type invalid'))

    number = number.upper()
    region = number[:2]
    manufacturer = number[2:8]
    serial_number = number[8:14]
    check_digit = number[14:]

    if check_digit == '':
        check_digit = luhn_calc(number, chars='0123456789ABCDEF')

    groups = (region, manufacturer, serial_number, check_digit)
    return separator.join(list(filter(None, groups)))