advertools.ad_from_string module — advertools 0.1a1 documentation

# advertools.ad_from_string module

`advertools.ad_from_string.` `ad_from_string`(s, slots=(30, 30, 80, 15, 15), sep=None, capitalize=False)

  Convert string s to an ad by splitting it into groups of words. Each group would have a length of at most the allowed length for that slot.

  If the total length of s exceeds the total allowed length, all remaining characters would be grouped in the last element of the returned list.

  s : a string of characters, with no restrictions on length. slots : an iterable of integers for the maximum lengths for each slot sep : by which character to split s capitalize : whether or not to capitalize each word after grouping. Setting

  > it as False would leave the input string as is.

  text ad : a list of strings

      >>> ad_from_string('this is a short ad')
      ... ['This Is A Short Ad', '', '', '', '', '']

      >>> ad_from_string('this is a longer ad and would take two of the first slots')
      ... ['This Is A Longer Ad And Would', 'Take Two Of The First Slots', '', '', '', '']