Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)

            @staticmethod
    def parse_choices(in_choices, accept_unicode=False):
        choiceset = {}
        choices = []

        # Accumulator for the normalized choices.
        normchoices = []

        if in_choices is not None:
            assert isinstance(in_choices, (list, tuple))

            # Normalize all the choices into pairs.
            for el in in_choices:

                choice = label = None

                # Accept simple choices.
                if isinstance(el, (int, str)):
                    choice = el

                # And of course, a choice-label pair.
                elif isinstance(el, tuple):
                    assert len(el) == 2
                    choice, label = el

                else:
                    raise AtochaError(
                        "Error: wrong type of choice in "
                        "initializer element: %s." % type(el))

                # Convert integer choice into string if necessary.
                if isinstance(choice, int):
                    choice = str(choice)

                # If the label is not set, it takes the same choice as the label
                # (convert to unicode from ascii).
                if label is None:
                    label = choice.decode('ascii')
                else:
                    # Other we check to make sure that the label is of type
                    # msg_type, which is the required type for all the
                    # user-visible choices.
                    if accept_unicode:
                        assert isinstance(label, (msg_type, unicode))
                    else:
                        assert isinstance(label, msg_type)

                # Just more zealous sanity checking.
                assert isinstance(choice, str)

                # We add the new pair to our internal, normalized set of
                # choices.
                choices.append( (choice, label) )
                choiceset[choice] = label

        return choices, choiceset
        


src/a/t/atocha-1.1/lib/python/atocha/fields/temporal.py   atocha(Download)
        # Parse the extra choices and save them for later.
        self.extra_choices, self.extra_choiceset = \
            self.parse_choices(extra_choices)
 
        # Note: The set of dates will be filled in every time we render this