# Define available headers, their types, and runtime input specification Header = namedtuple('Header', ('name', 'type', 'input')) HEADER_REQUIRED_FIELD_TYPES = [ Header('title', six.string_types, ci.GetInput(prompt='title')), Header('authors', list, ci.GetInput(prompt='authors (comma separated)', convertor=ci.ListConvertor())), Header('tldr', six.string_types, ci.GetInput(prompt='tldr')), Header('created_at', datetime.datetime, ci.GetInput(prompt='created_at', convertor=ci.DateConvertor(), default=datetime.date.today())), ] HEADER_OPTIONAL_FIELD_TYPES = [ Header('subtitle', six.string_types, ci.GetInput(prompt='subtitle', required=False)), Header('tags', list, ci.GetInput(prompt='tags (comma separated)', convertor=ci.ListConvertor(), required=False)), Header('path', six.string_types, ci.GetInput(prompt='path', required=False)), Header('updated_at', datetime.datetime, ci.GetInput(prompt='updated_at', convertor=ci.DateConvertor(), default=datetime.datetime.now())), Header('private', bool, ci.GetInput(prompt='private', convertor=ci.BooleanConvertor(), required=False)), # If true, this post starts out private Header('allowed_groups', list, ci.GetInput(prompt='allowed_groups (comma separated)', convertor=ci.ListConvertor(), required=False)), Header('thumbnail', (int, ) + six.string_types, ci.GetInput(prompt='thumbnail', required=False)), ] HEADERS_ALL = { header.name: header for header in itertools.chain(HEADER_REQUIRED_FIELD_TYPES, HEADER_OPTIONAL_FIELD_TYPES) } # Headers to prompt for if missing when in interactive mode HEADERS_INTERACTIVE = ['title', 'subtitle', 'authors', 'tldr', 'created_at', 'tags'] HEADER_SAMPLE = """ ---
Header('subtitle', str, ci.GetInput(prompt='subtitle', required=False)), Header( 'tags', list, ci.GetInput(prompt='tags (comma separated)', convertor=ci.ListConvertor(), required=False)), Header('path', str, ci.GetInput(prompt='path', required=False)), Header( 'updated_at', datetime.datetime, ci.GetInput(prompt='updated_at', convertor=ci.DateConvertor(), default=datetime.datetime.now())), Header( 'private', bool, ci.GetInput(prompt='private', convertor=ci.BooleanConvertor(), required=False)), # If true, this post starts out private Header( 'allowed_groups', list, ci.GetInput(prompt='allowed_groups (comma separated)', convertor=ci.ListConvertor(), required=False)), Header('thumbnail', (int, str), ci.GetInput(prompt='thumbnail', required=False)), ] HEADERS_ALL = { header.name: header for header in itertools.chain(HEADER_REQUIRED_FIELD_TYPES, HEADER_OPTIONAL_FIELD_TYPES) }