Did I find the right examples for you? yes no

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
Convert different kinds of input into a list of bi-tuples, both strings.
    

        def vocabulary(definition):
    """Convert different kinds of input into a list of bi-tuples, both strings.
    """
    if callable(definition):
        definition = definition()
    if isinstance(definition, basestring):
        return [(definition, definition), ]
    # dict-like
    if hasattr(definition, '__getitem__') and hasattr(definition, 'keys'):
        return [(_, definition[_]) for _ in definition.keys()]

    # iterable
    if hasattr(definition, '__iter__'):
        new_vocab = []
        for entry in definition:
            if isinstance(entry, basestring):
                # entry is a string
                new_vocab.append((entry, entry))
            elif hasattr(entry, '__iter__'):
                # entry is a sequence
                parts = [_ for _ in entry]
                if len(parts) > 1:
                    # take first two parts and skips others
                    new_vocab.append(entry[0:2])
                else:
                    # rare case, inner has one value only
                    new_vocab.append((entry[0], entry[0]))
        return new_vocab
    return definition
        


src/y/a/yafowil-2.0.2/src/yafowil/common.py   yafowil(Download)
    fetch_value
)
from .utils import (
    UNSET,
    attr_value,
        content = value
    else:
        vocab = dict(vocabulary(attr_value('vocabulary', widget, data, [])))
        content = vocab[bool(value)]
        if data.tag.translate:
        optiontags = []
        vocab = attr_value('vocabulary', widget, data, [])
        for key, term in vocabulary(vocab):
            attrs = {
                'selected': (key in value) and 'selected' or None,
            tagclass = attr_value('label_checkbox_class', widget, data)
        vocab = attr_value('vocabulary', widget, data, [])
        for key, term in vocabulary(vocab):
            input_attrs = {
                'type': tagtype,
    tags = []
    vocab = attr_value('vocabulary', widget, data, [])
    for key, term in vocabulary(vocab):
        attrs = {
            'type': 'radio',