messageboard-2021-05-27-1916.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789









265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703              2704270527062707270827092710271127122713271427152716271727182719272027212722272327242725











                            <----SKIPPED LINES---->




  bottom of the message.

  Args:
    lines: list of strings that comprise the message
    splitflap: boolean, True if directed for splitflap display; false if
    directed to screen

  Returns:
    String - which includes embedded new line characters, borders, etc. as
    described above, that can be printed to screen as the message.
  """
  divider = '+' + '-'*SPLITFLAP_CHARS_PER_LINE + '+'
  border_character = '|'
  append_character = '\n'

  if splitflap:
    border_character = ''
    # vestaboard tries to line wrap so adding a space ensures that it does not
    # interpret a pair of lines that end and begin with characters as one
    # contiguous string
    append_character = ' '

  # Create blank lines up to the required number of lines
  for unused_n in range(SPLITFLAP_LINE_COUNT-len(lines)):
    lines.append('')

  # convert escaped character codes potentially embedded in personal
  # message to something that can be displayed well on screen, albeit
  # the colors for {63}..{69} aren't captured in plain text
  # see https://docs.vestaboard.com/characters
  escaped_characters = (
      ('{62}', u'\u00b0'),
      ('{63}', u'\u2588'),  # red
      ('{64}', u'\u2588'),  # orange
      ('{65}', u'\u2588'),  # yellow
      ('{66}', u'\u2588'),  # green
      ('{67}', u'\u2588'),  # blue
      ('{68}', u'\u2588'),  # violet
      ('{69}', u'\u2588'))  # red

  lines = [
      border_character +
      line.ljust(SPLITFLAP_CHARS_PER_LINE).upper() +
      border_character
      for line in lines]

  if not splitflap:
    lines.insert(0, divider)
    lines.append(divider)

  message = append_character.join(lines)














  for code, character in escaped_characters:
    message = message.replace(code, character)

  return message


def FlightInsightLastSeen(flights, days_ago=2):
  """Generates string indicating when flight was last seen.

  Generates text of the following form.
  - KAL214 was last seen 2d0h ago

  Args:
    flights: the list of the raw data from which the insights will be generated,
      where the flights are listed in order of observation - i.e.: flights[0]
      was the earliest seen, and flights[-1] is the most recent flight for
      which we are attempting to generate an insight.
    days_ago: the minimum time difference for which a message should be
      generated - i.e.: many flights are daily, and so we are not necessarily
      interested to see about every daily flight that it was seen yesterday.
      However, more infrequent flights might be of interest.





                            <----SKIPPED LINES---->





01234567890123456789012345678901234567890123456789012345678901234567890123456789









2653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677              267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725











                            <----SKIPPED LINES---->




  bottom of the message.

  Args:
    lines: list of strings that comprise the message
    splitflap: boolean, True if directed for splitflap display; false if
    directed to screen

  Returns:
    String - which includes embedded new line characters, borders, etc. as
    described above, that can be printed to screen as the message.
  """
  divider = '+' + '-'*SPLITFLAP_CHARS_PER_LINE + '+'
  border_character = '|'
  append_character = '\n'

  if splitflap:
    border_character = ''
    # vestaboard tries to line wrap so adding a space ensures that it does not
    # interpret a pair of lines that end and begin with characters as one
    # contiguous string
    append_character = ''

  # Create blank lines up to the required number of lines
  for unused_n in range(SPLITFLAP_LINE_COUNT-len(lines)):
    lines.append('')















  lines = [
      border_character +
      line.ljust(SPLITFLAP_CHARS_PER_LINE).upper() +
      border_character
      for line in lines]

  if not splitflap:
    lines.insert(0, divider)
    lines.append(divider)

  message = append_character.join(lines)
  if not splitflap:
    # convert escaped character codes potentially embedded in personal
    # message to something that can be displayed well on computer screen, albeit
    # the colors for {63}..{69} aren't captured in plain text
    # see https://docs.vestaboard.com/characters
    escaped_characters = (
        ('{62}', u'\u00b0'),
        ('{63}', u'\u2588'),  # red
        ('{64}', u'\u2588'),  # orange
        ('{65}', u'\u2588'),  # yellow
        ('{66}', u'\u2588'),  # green
        ('{67}', u'\u2588'),  # blue
        ('{68}', u'\u2588'),  # violet
        ('{69}', u'\u2588'))  # red
    for code, character in escaped_characters:
      message = message.replace(code, character)

  return message


def FlightInsightLastSeen(flights, days_ago=2):
  """Generates string indicating when flight was last seen.

  Generates text of the following form.
  - KAL214 was last seen 2d0h ago

  Args:
    flights: the list of the raw data from which the insights will be generated,
      where the flights are listed in order of observation - i.e.: flights[0]
      was the earliest seen, and flights[-1] is the most recent flight for
      which we are attempting to generate an insight.
    days_ago: the minimum time difference for which a message should be
      generated - i.e.: many flights are daily, and so we are not necessarily
      interested to see about every daily flight that it was seen yesterday.
      However, more infrequent flights might be of interest.





                            <----SKIPPED LINES---->