Allow generator as input to utils.print_list.

Once the table is built, the length of the prettytable's internal array
is checked rather than re-iterrating over the input.

Adds tests for utils.print_list with list and generator input.

Fixes: bug #1180059