Ejemplo n.º 1
0
    def process_entry(self):
        max_val = int(self.max_val_var.get())
        page_entry_val = self.pages_entry.get()
        interval_gi = ci.GetInput(convertor=IntervalConvertor(min_val=1,
                                                              max_val=max_val),
                                  error_callback=self.tk_error)
        list_gi = ci.GetInput(convertor=ci.ListConvertor(interval_gi),
                              validators=ci.ListValidator(
                                  len_validators=ci.RangeValidator(min_val=1)),
                              error_callback=self.tk_error)
        valid, result = list_gi.process_value(page_entry_val)

        if valid is True:
            page_list = sorted(set(itertools.chain.from_iterable(result)))
            print(f'page_list={page_list}')
            self.root.destroy()
Ejemplo n.º 2
0
import uuid

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 = {
Ejemplo n.º 3
0
import cooked_input as ci
import PIL.Image

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', 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)),