# pylint: disable=line-too-long """Manage the old USCG metadata format. The US Coast Guard's older format consists of comma separated values after the end of the traditional NMEA sentence. The format was never formalized in a standard. The TAG Block format is in NMEA 0183 standard and is now recognized as preferred. Each field (except the timestamp) starts with a letter code followed by the value. The timestamp is a UNIX UTC seconds from the epoch value and must come last. Station name and the timestamp are the only required fields. However, some stations mangle the name field or leave it out, so this module will substitute 'rUnknown' if none is found. It will also accept messages that are missing the timestamp. The timestamp is typically the datalogger's time, not the receiver. This can sometimes be large spans of time before or after the message was received. USCG loggers have been shown to be up to 24 hours off in time. Additionally some dataloggers only get periodic updates from the receivers. Often the time is not derived from the GPS receiver in the AIS transceiver or receiver. Many of the letter codes directly relate to Shine Micro receiver features. See Shine Micro AISRadar documentation for addition details. Example single line AIS NMEA VDM message with USCG metadata: !AIVDM,1,1,,A,35Mqd3POj3rmIpjGSpmeCJaH00Qh,0*34,d-095,S1651,t161344.00,T44.03018211,r3669963,1429287142 Example single line with the minimum metadata: !ANVDM,1,1,,B,15N6CB0000r86SRFAS:[^*]*\*[A-F0-9][A-F0-9]) (?P ( (,S(?P\d*)) | (,s(?P\d*)) # Receiver signal strength indicator. | (,d(?P[-0-9]*)) # dB. | (,t(?P(?P\d\d)(?P\d\d) # UTC time. (?P\d\d.\d*))) | (,T(?P[^,]*)) # Seconds within the minute. | (,x(?P[0-9]*)) | (,(?P(?P[rRbBbD])[a-zA-Z0-9_-]*)) )* ,(?P