# Path: speriment/utils.py
# def exactly_one(obj, attributes):
#     found = [attribute for attribute in attributes if hasattr(obj, attribute)]
#     if len(found) != 1:
#         raise ValueError, '''{} must have exactly one of the following attributes:
# 
# {}
# 
# but it has:
# 
# {}.'''.format(obj, attributes, found)


from speriment.utils import exactly_one

        page: Page, the Page to look at to see which answer was given.

        option: Option, optional. If given, the block containing this RunIf will
        only run if this Option was chosen the last time page was displayed.

        regex: string, optional. If given, the block containing this RunIf will
        only run if a response matching a regular expression made from the
        string regex was given the last time page was displayed.

        permutation: integer, optional. If given, the block containing this
        RunIf will only run if PsiTurk gives the experiment a permutation
        variable matching this integer. This requires editing the counterbalance
        setting in config.txt.

        The reason RunIfs depend on "the last time" their page was displayed is
        that Pages can display multiple times if they are in Blocks with a
        criterion.'''
        if item != None:
            self.item = item
        if page != None:
            self.page = page
        if option != None:
            self.option = option
        elif regex != None:
            self.regex = regex
        if permutation != None:
            self.permutation = permutation

    def _validate(self):

# Path: speriment/utils.py
# def exactly_one(obj, attributes):
#     found = [attribute for attribute in attributes if hasattr(obj, attribute)]
#     if len(found) != 1:
#         raise ValueError, '''{} must have exactly one of the following attributes:
# 
# {}
# 
# but it has:
# 
# {}.'''.format(obj, attributes, found)


# Path: speriment/components/run_if.py
from speriment.utils import exactly_one


        page: Page, the Page to look at to see which answer was given.

        option: Option, optional. If given, the block containing this RunIf will
        only run if this Option was chosen the last time page was displayed.

        regex: string, optional. If given, the block containing this RunIf will
        only run if a response matching a regular expression made from the
        string regex was given the last time page was displayed.

        permutation: integer, optional. If given, the block containing this
        RunIf will only run if PsiTurk gives the experiment a permutation
        variable matching this integer. This requires editing the counterbalance
        setting in config.txt.

        The reason RunIfs depend on "the last time" their page was displayed is
        that Pages can display multiple times if they are in Blocks with a
        criterion.'''
        if item != None:
            self.item = item
        if page != None:
            self.page = page
        if option != None:
            self.option = option
        elif regex != None:
            self.regex = regex
        if permutation != None:
            self.permutation = permutation

    def _validate(self):

        exactly_one(self, ['item', 'page', 'permutation'])