docs: def get_number_footer_lines(docbody, page_break_posns):
      """Try to guess the number of footer lines each page of a document has.
         The positions of the page breaks in the document are used to try to guess
         the number of footer lines.
         @param docbody: (list) of strings - each string being a line in the
          document
         @param page_break_posns: (list) of integers - each integer is the
          position of a page break in the document.
         @return: (int) the number of lines that make up the footer of each page.
      """
      num_breaks = len(page_break_posns)
      num_footer_lines = 0
      empty_line = 0
      keep_checking = 1
      p_wordSearch = re.compile(unicode(r'([A-Za-z0-9-]+)'), re.UNICODE)
      if num_breaks > 2:
          while keep_checking:
              cur_break = 1
              if page_break_posns[cur_break] - num_footer_lines - 1 < 0 or \
                 page_break_posns[cur_break] - num_footer_lines - 1 > \
                 len(docbody) - 1:
                  # Be sure that the docbody list boundary wasn't overstepped:
                  break
              if docbody[(page_break_posns[cur_break] -
                          num_footer_lines - 1)].isspace():
                  empty_line = 1
              grps_headLineWords = \
                  p_wordSearch.findall(docbody[(page_break_posns[cur_break] -
                                                num_footer_lines - 1)])
              cur_break = cur_break + 1
              while (cur_break < num_breaks) and keep_checking:
                  grps_thisLineWords = \
                      p_wordSearch.findall(docbody[(page_break_posns[cur_break] -
                                                    num_footer_lines - 1)])
                  if empty_line:
                      if len(grps_thisLineWords) != 0:
                          # this line should be empty, but isn't
                          keep_checking = 0
                  else:
                      if (len(grps_thisLineWords) == 0) or \
                              (len(grps_headLineWords) != len(grps_thisLineWords)):
                          # Not same num 'words' as equivilent line
                          # in 1st footer:
                          keep_checking = 0
                      else:
                          keep_checking = \
                              check_boundary_lines_similar(grps_headLineWords,
                                                           grps_thisLineWords)
                  # Update cur_break for nxt line to check
                  cur_break = cur_break + 1
              if keep_checking:
                  # Line is a footer line: check next
                  num_footer_lines = num_footer_lines + 1
              empty_line = 0
      return num_footer_lines