(question, app_id, app_version, repeats)
return items
Creates a list of items from a stock type question
Creates a list of items from a stock type question
Creates a list of items from a stock type question
def _get_stock_items_from_question(question, app_id, app_version, repeats):
        """
        Creates a list of items from a stock type question
        """
        items = []

        # Strips the last value in the path
        # E.G. /data/balance/entry --> /data/balance
        parent_path = question['value'][:question['value'].rfind('/')]
        question_id = question['stock_type_attributes']['type']

        parent_path_and_question_id = '{}:{}'.format(parent_path, question_id)

        for attribute in question['stock_type_attributes']:
            items.append(StockItem.create_from_question(
                question,
                '{}/@{}'.format(parent_path_and_question_id, attribute),
                app_id,
                app_version,
                repeats,
            ))

        for attribute in question['stock_entry_attributes']:
            items.append(StockItem.create_from_question(
                question,
                '{}/{}/@{}'.format(parent_path_and_question_id, 'entry', attribute),
                app_id,
                app_version,
                repeats,
            ))

        return items
def _get_stock_items_from_question ( question , app_id , app_version , repeats ) : items = [ ] # Strips the last value in the path # E.G. /data/balance/entry --> /data/balance parent_path = question [ 'value' ] [ : question [ 'value' ] . rfind ( '/' ) ] question_id = question [ 'stock_type_attributes' ] [ 'type' ] parent_path_and_question_id = '{}:{}' . format ( parent_path , question_id ) for attribute in question [ 'stock_type_attributes' ] : items . append ( StockItem . create_from_question ( question , '{}/@{}' . format ( parent_path_and_question_id , attribute ) , app_id , app_version , repeats , ) ) for attribute in question [ 'stock_entry_attributes' ] : items . append ( StockItem . create_from_question ( question , '{}/{}/@{}' . format ( parent_path_and_question_id , 'entry' , attribute ) , app_id , app_version , repeats , ) ) return items