stdnum.imo

IMO number (International Maritime Organization number).

A number used to uniquely identify ships (the hull) for purposes of registering owners and management companies. The ship identification number consists of a six-digit sequentially assigned number and a check digit. The number is usually prefixed with “IMO”.

Note that there seem to be a large number of ships with an IMO that does not have a valid check digit or even have a different length.

>>> validate('IMO 9319466')
'9319466'
>>> validate('IMO 8814275')
'8814275'
>>> validate('8814274')
Traceback (most recent call last):
    ...
InvalidChecksum: ...
>>> format('8814275')
'IMO 8814275'
stdnum.imo.calc_check_digit(number)

Calculate the check digits for the number.

stdnum.imo.compact(number)

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

stdnum.imo.format(number)

Reformat the number to the standard presentation format.

stdnum.imo.is_valid(number)

Check if the number provided is valid. This checks the length and check digit.

stdnum.imo.validate(number)

Check if the number provided is valid. This checks the length and check digit.