コード例 #1
0
ファイル: post.py プロジェクト: ElucidataInc/knowledge-repo
import cooked_input as ci
import PIL.Image
import six

from .utils.encoding import encode, decode

logger = logging.getLogger(__name__)

# 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)
コード例 #2
0
logger = logging.getLogger(__name__)

# Define available headers, their types, and runtime input specification
Header = namedtuple('Header', ('name', 'type', 'input'))

HEADER_REQUIRED_FIELD_TYPES = [
    Header('title', str, ci.GetInput(prompt='title')),
    Header(
        'authors', list,
        ci.GetInput(prompt='authors (comma separated)',
                    convertor=ci.ListConvertor())),
    Header('tldr', str, 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', 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(),