text:
// Copyright (c) DNN Software. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;

namespace DotNetNuke.Web.Mvc.Helpers
{
    /// <summary>
    /// Represents support for making selections in a list.
    /// </summary>
    public static class HtmlSelectExtensions
    {
        // DropDownList

        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper and the name of the form field.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString DropDownList(this DnnHtmlHelper html, string name)
        {
            return html.HtmlHelper.DropDownList(name);
        }

        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper, the name of the form field, and an option label.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString DropDownList(this DnnHtmlHelper html, string name, string optionLabel)
        {
            return html.HtmlHelper.DropDownList(name, optionLabel);
        }

        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper, the name of the form field, and the specified list items.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString DropDownList(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList)
        {
            return html.HtmlHelper.DropDownList(name, selectList);
        }

        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString DropDownList(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList, object htmlAttributes)
        {
            return html.HtmlHelper.DropDownList(name, selectList, htmlAttributes);
        }

        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString DropDownList(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes)
        {
            return html.HtmlHelper.DropDownList(name, selectList, htmlAttributes);
        }

        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, and an option label.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString DropDownList(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList, string optionLabel)
        {
            return html.HtmlHelper.DropDownList(name, selectList, optionLabel);
        }

        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, an option label, and the specified HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString DropDownList(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes)
        {
            return html.HtmlHelper.DropDownList(name, selectList, optionLabel, htmlAttributes);
        }

        /// <summary>
        /// Returns a single-selection select element using the specified HTML helper, the name of the form field, the specified list items, an option label, and the specified HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString DropDownList(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes)
        {
            return html.HtmlHelper.DropDownList(name, selectList, optionLabel, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the value.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList)
        {
            return html.HtmlHelper.DropDownListFor(expression, selectList);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the value.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
        {
            return html.HtmlHelper.DropDownListFor(expression, selectList, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the value.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes)
        {
            return html.HtmlHelper.DropDownListFor(expression, selectList, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and option label.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the value.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel)
        {
            return html.HtmlHelper.DropDownListFor(expression, selectList, optionLabel);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items, option label, and HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the value.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes)
        {
            return html.HtmlHelper.DropDownListFor(expression, selectList, optionLabel, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items, option label, and HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the value.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString DropDownListFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes)
        {
            return html.HtmlHelper.DropDownListFor(expression, selectList, optionLabel, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each value in the enumeration that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the values to display.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TEnum">The type of the value.</typeparam>
        public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TEnum>> expression)
        {
            return html.HtmlHelper.EnumDropDownListFor<TModel, TEnum>(expression);
        }

        /// <summary>
        /// Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each value in the enumeration that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the values to display.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TEnum">The type of the value.</typeparam>
        public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TEnum>> expression, object htmlAttributes)
        {
            return html.HtmlHelper.EnumDropDownListFor<TModel, TEnum>(expression, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each value in the enumeration that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the values to display.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TEnum">The type of the value.</typeparam>
        public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TEnum>> expression, IDictionary<string, object> htmlAttributes)
        {
            return html.HtmlHelper.EnumDropDownListFor<TModel, TEnum>(expression, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each value in the enumeration that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the values to display.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TEnum">The type of the value.</typeparam>
        public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TEnum>> expression, string optionLabel)
        {
            return html.HtmlHelper.EnumDropDownListFor<TModel, TEnum>(expression, optionLabel);
        }

        /// <summary>
        /// Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each value in the enumeration that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the values to display.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TEnum">The type of the value.</typeparam>
        public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TEnum>> expression, string optionLabel, object htmlAttributes)
        {
            return html.HtmlHelper.EnumDropDownListFor<TModel, TEnum>(expression, optionLabel, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each value in the enumeration that is represented by the specified expression.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each value in the enumeration that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the values to display.</param><param name="optionLabel">The text for a default empty item. This parameter can be null.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TEnum">The type of the value.</typeparam>
        public static MvcHtmlString EnumDropDownListFor<TModel, TEnum>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TEnum>> expression, string optionLabel, IDictionary<string, object> htmlAttributes)
        {
            return html.HtmlHelper.EnumDropDownListFor<TModel, TEnum>(expression, optionLabel, htmlAttributes);
        }

        // ListBox

        /// <summary>
        /// Returns a multi-select select element using the specified HTML helper and the name of the form field.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString ListBox(this DnnHtmlHelper html, string name)
        {
            return html.HtmlHelper.ListBox(name);
        }

        /// <summary>
        /// Returns a multi-select select element using the specified HTML helper, the name of the form field, and the specified list items.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString ListBox(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList)
        {
            return html.HtmlHelper.ListBox(name, selectList);
        }

        /// <summary>
        /// Returns a multi-select select element using the specified HTML helper, the name of the form field, and the specified list items.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list..
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString ListBox(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList, object htmlAttributes)
        {
            return html.HtmlHelper.ListBox(name, selectList, htmlAttributes);
        }

        /// <summary>
        /// Returns a multi-select select element using the specified HTML helper, the name of the form field, the specified list items, and the specified HMTL attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element with an option subelement for each item in the list..
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="name">The name of the form field to return.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><exception cref="T:System.ArgumentException">The <paramref name="name"/> parameter is null or empty.</exception>
        public static MvcHtmlString ListBox(this DnnHtmlHelper html, string name, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes)
        {
            return html.HtmlHelper.ListBox(name, selectList, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression and using the specified list items.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the property.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString ListBoxFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList)
        {
            return html.HtmlHelper.ListBoxFor(expression, selectList);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the property.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString ListBoxFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
        {
            return html.HtmlHelper.ListBoxFor(expression, selectList, htmlAttributes);
        }

        /// <summary>
        /// Returns an HTML select element for each property in the object that is represented by the specified expression using the specified list items and HTML attributes.
        /// </summary>
        ///
        /// <returns>
        /// An HTML select element for each property in the object that is represented by the expression.
        /// </returns>
        /// <param name="html">The HTML helper instance that this method extends.</param><param name="expression">An expression that identifies the object that contains the properties to display.</param><param name="selectList">A collection of <see cref="T:System.Web.Mvc.SelectListItem"/> objects that are used to populate the drop-down list.</param><param name="htmlAttributes">An object that contains the HTML attributes to set for the element.</param><typeparam name="TModel">The type of the model.</typeparam><typeparam name="TProperty">The type of the property.</typeparam><exception cref="T:System.ArgumentNullException">The <paramref name="expression"/> parameter is null.</exception>
        public static MvcHtmlString ListBoxFor<TModel, TProperty>(this DnnHtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes)
        {
            return html.HtmlHelper.ListBoxFor(expression, selectList, htmlAttributes);
        }

    }
}


text:
package xlog

import (
	"fmt"
	"io"
	"os"
	"runtime"
	"sync"
	"time"
)

// The flags define what information is prefixed to each log entry
// generated by the Logger. The Lno* versions allow the suppression of
// specific output. The bits are or'ed together to control what will be
// printed. There is no control over the order of the items printed and
// the format. The full format is:
//
//   2009-01-23 01:23:23.123123 /a/b/c/d.go:23: message
//
const (
	Ldate         = 1 << iota     // the date: 2009-01-23
	Ltime                         // the time: 01:23:23
	Lmicroseconds                 // microsecond resolution: 01:23:23.123123
	Llongfile                     // full file name and line number: /a/b/c/d.go:23
	Lshortfile                    // final file name element and line number: d.go:23
	Lnopanic                      // suppresses output from Panic[f|ln] but not the panic call
	Lnofatal                      // suppresses output from Fatal[f|ln] but not the exit
	Lnowarn                       // suppresses output from Warn[f|ln]
	Lnoprint                      // suppresses output from Print[f|ln]
	Lnodebug                      // suppresses output from Debug[f|ln]
	Lstdflags     = Ldate | Ltime // initial values for the standard logger
)

// A Logger represents an active logging object that generates lines of
// output to an io.Writer. Each logging operation if not suppressed
// makes a single call to the Writer's Write method. A Logger can be
// used simultaneously from multiple goroutines; it guarantees to
// serialize access to the Writer.
type Logger struct {
	mu sync.Mutex // ensures atomic writes; and protects the following
	// fields
	prefix string    // prefix to write at beginning of each line
	flag   int       // properties
	out    io.Writer // destination for output
	buf    []byte    // for accumulating text to write
}

// New creates a new Logger. The out argument sets the destination to
// which the log output will be written. The prefix appears at the
// beginning of each log line. The flag argument defines the logging
// properties.
func New(out io.Writer, prefix string, flag int) *Logger {
	return &Logger{out: out, prefix: prefix, flag: flag}
}

// std is the standard logger used by the package scope functions.
var std = New(os.Stderr, "", Lstdflags)

// itoa converts the integer to ASCII. A negative widths will avoid
// zero-padding. The function supports only non-negative integers.
func itoa(buf *[]byte, i int, wid int) {
	var u = uint(i)
	if u == 0 && wid <= 1 {
		*buf = append(*buf, '0')
		return
	}
	var b [32]byte
	bp := len(b)
	for ; u > 0 || wid > 0; u /= 10 {
		bp--
		wid--
		b[bp] = byte(u%10) + '0'
	}
	*buf = append(*buf, b[bp:]...)
}

// formatHeader puts the header into the buf field of the buffer.
func (l *Logger) formatHeader(t time.Time, file string, line int) {
	l.buf = append(l.buf, l.prefix...)
	if l.flag&(Ldate|Ltime|Lmicroseconds) != 0 {
		if l.flag&Ldate != 0 {
			year, month, day := t.Date()
			itoa(&l.buf, year, 4)
			l.buf = append(l.buf, '-')
			itoa(&l.buf, int(month), 2)
			l.buf = append(l.buf, '-')
			itoa(&l.buf, day, 2)
			l.buf = append(l.buf, ' ')
		}
		if l.flag&(Ltime|Lmicroseconds) != 0 {
			hour, min, sec := t.Clock()
			itoa(&l.buf, hour, 2)
			l.buf = append(l.buf, ':')
			itoa(&l.buf, min, 2)
			l.buf = append(l.buf, ':')
			itoa(&l.buf, sec, 2)
			if l.flag&Lmicroseconds != 0 {
				l.buf = append(l.buf, '.')
				itoa(&l.buf, t.Nanosecond()/1e3, 6)
			}
			l.buf = append(l.buf, ' ')
		}
	}
	if l.flag&(Lshortfile|Llongfile) != 0 {
		if l.flag&Lshortfile != 0 {
			short := file
			for i := len(file) - 1; i > 0; i-- {
				if file[i] == '/' {
					short = file[i+1:]
					break
				}
			}
			file = short
		}
		l.buf = append(l.buf, file...)
		l.buf = append(l.buf, ':')
		itoa(&l.buf, line, -1)
		l.buf = append(l.buf, ": "...)
	}
}

func (l *Logger) output(calldepth int, now time.Time, s string) error {
	var file string
	var line int
	if l.flag&(Lshortfile|Llongfile) != 0 {
		l.mu.Unlock()
		var ok bool
		_, file, line, ok = runtime.Caller(calldepth)
		if !ok {
			file = "???"
			line = 0
		}
		l.mu.Lock()
	}
	l.buf = l.buf[:0]
	l.formatHeader(now, file, line)
	l.buf = append(l.buf, s...)
	if len(s) == 0 || s[len(s)-1] != '\n' {
		l.buf = append(l.buf, '\n')
	}
	_, err := l.out.Write(l.buf)
	return err
}

// Output writes the string s with the header controlled by the flags to
// the l.out writer. A newline will be appended if s doesn't end in a
// newline. Calldepth is used to recover the PC, although all current
// calls of Output use the call depth 2. Access to the function is serialized.
func (l *Logger) Output(calldepth, noflag int, v ...interface{}) error {
	now := time.Now()
	l.mu.Lock()
	defer l.mu.Unlock()
	if l.flag&noflag != 0 {
		return nil
	}
	s := fmt.Sprint(v...)
	return l.output(calldepth+1, now, s)
}

// Outputf works like output but formats the output like Printf.
func (l *Logger) Outputf(calldepth int, noflag int, format string, v ...interface{}) error {
	now := time.Now()
	l.mu.Lock()
	defer l.mu.Unlock()
	if l.flag&noflag != 0 {
		return nil
	}
	s := fmt.Sprintf(format, v...)
	return l.output(calldepth+1, now, s)
}

// Outputln works like output but formats the output like Println.
func (l *Logger) Outputln(calldepth int, noflag int, v ...interface{}) error {
	now := time.Now()
	l.mu.Lock()
	defer l.mu.Unlock()
	if l.flag&noflag != 0 {
		return nil
	}
	s := fmt.Sprintln(v...)
	return l.output(calldepth+1, now, s)
}

// Panic prints the message like Print and calls panic. The printing
// might be suppressed by the flag Lnopanic.
func (l *Logger) Panic(v ...interface{}) {
	l.Output(2, Lnopanic, v...)
	s := fmt.Sprint(v...)
	panic(s)
}

// Panic prints the message like Print and calls panic. The printing
// might be suppressed by the flag Lnopanic.
func Panic(v ...interface{}) {
	std.Output(2, Lnopanic, v...)
	s := fmt.Sprint(v...)
	panic(s)
}

// Panicf prints the message like Printf and calls panic. The printing
// might be suppressed by the flag Lnopanic.
func (l *Logger) Panicf(format string, v ...interface{}) {
	l.Outputf(2, Lnopanic, format, v...)
	s := fmt.Sprintf(format, v...)
	panic(s)
}

// Panicf prints the message like Printf and calls panic. The printing
// might be suppressed by the flag Lnopanic.
func Panicf(format string, v ...interface{}) {
	std.Outputf(2, Lnopanic, format, v...)
	s := fmt.Sprintf(format, v...)
	panic(s)
}

// Panicln prints the message like Println and calls panic. The printing
// might be suppressed by the flag Lnopanic.
func (l *Logger) Panicln(v ...interface{}) {
	l.Outputln(2, Lnopanic, v...)
	s := fmt.Sprintln(v...)
	panic(s)
}

// Panicln prints the message like Println and calls panic. The printing
// might be suppressed by the flag Lnopanic.
func Panicln(v ...interface{}) {
	std.Outputln(2, Lnopanic, v...)
	s := fmt.Sprintln(v...)
	panic(s)
}

// Fatal prints the message like Print and calls os.Exit(1). The
// printing might be suppressed by the flag Lnofatal.
func (l *Logger) Fatal(v ...interface{}) {
	l.Output(2, Lnofatal, v...)
	os.Exit(1)
}

// Fatal prints the message like Print and calls os.Exit(1). The
// printing might be suppressed by the flag Lnofatal.
func Fatal(v ...interface{}) {
	std.Output(2, Lnofatal, v...)
	os.Exit(1)
}

// Fatalf prints the message like Printf and calls os.Exit(1). The
// printing might be suppressed by the flag Lnofatal.
func (l *Logger) Fatalf(format string, v ...interface{}) {
	l.Outputf(2, Lnofatal, format, v...)
	os.Exit(1)
}

// Fatalf prints the message like Printf and calls os.Exit(1). The
// printing might be suppressed by the flag Lnofatal.
func Fatalf(format string, v ...interface{}) {
	std.Outputf(2, Lnofatal, format, v...)
	os.Exit(1)
}

// Fatalln prints the message like Println and calls os.Exit(1). The
// printing might be suppressed by the flag Lnofatal.
func (l *Logger) Fatalln(format string, v ...interface{}) {
	l.Outputln(2, Lnofatal, v...)
	os.Exit(1)
}

// Fatalln prints the message like Println and calls os.Exit(1). The
// printing might be suppressed by the flag Lnofatal.
func Fatalln(format string, v ...interface{}) {
	std.Outputln(2, Lnofatal, v...)
	os.Exit(1)
}

// Warn prints the message like Print. The printing might be suppressed
// by the flag Lnowarn.
func (l *Logger) Warn(v ...interface{}) {
	l.Output(2, Lnowarn, v...)
}

// Warn prints the message like Print. The printing might be suppressed
// by the flag Lnowarn.
func Warn(v ...interface{}) {
	std.Output(2, Lnowarn, v...)
}

// Warnf prints the message like Printf. The printing might be suppressed
// by the flag Lnowarn.
func (l *Logger) Warnf(format string, v ...interface{}) {
	l.Outputf(2, Lnowarn, format, v...)
}

// Warnf prints the message like Printf. The printing might be suppressed
// by the flag Lnowarn.
func Warnf(format string, v ...interface{}) {
	std.Outputf(2, Lnowarn, format, v...)
}

// Warnln prints the message like Println. The printing might be suppressed
// by the flag Lnowarn.
func (l *Logger) Warnln(v ...interface{}) {
	l.Outputln(2, Lnowarn, v...)
}

// Warnln prints the message like Println. The printing might be suppressed
// by the flag Lnowarn.
func Warnln(v ...interface{}) {
	std.Outputln(2, Lnowarn, v...)
}

// Print prints the message like fmt.Print. The printing might be suppressed
// by the flag Lnoprint.
func (l *Logger) Print(v ...interface{}) {
	l.Output(2, Lnoprint, v...)
}

// Print prints the message like fmt.Print. The printing might be suppressed
// by the flag Lnoprint.
func Print(v ...interface{}) {
	std.Output(2, Lnoprint, v...)
}

// Printf prints the message like fmt.Printf. The printing might be suppressed
// by the flag Lnoprint.
func (l *Logger) Printf(format string, v ...interface{}) {
	l.Outputf(2, Lnoprint, format, v...)
}

// Printf prints the message like fmt.Printf. The printing might be suppressed
// by the flag Lnoprint.
func Printf(format string, v ...interface{}) {
	std.Outputf(2, Lnoprint, format, v...)
}

// Println prints the message like fmt.Println. The printing might be
// suppressed by the flag Lnoprint.
func (l *Logger) Println(v ...interface{}) {
	l.Outputln(2, Lnoprint, v...)
}

// Println prints the message like fmt.Println. The printing might be
// suppressed by the flag Lnoprint.
func Println(v ...interface{}) {
	std.Outputln(2, Lnoprint, v...)
}

// Debug prints the message like Print. The printing might be suppressed
// by the flag Lnodebug.
func (l *Logger) Debug(v ...interface{}) {
	l.Output(2, Lnodebug, v...)
}

// Debug prints the message like Print. The printing might be suppressed
// by the flag Lnodebug.
func Debug(v ...interface{}) {
	std.Output(2, Lnodebug, v...)
}

// Debugf prints the message like Printf. The printing might be suppressed
// by the flag Lnodebug.
func (l *Logger) Debugf(format string, v ...interface{}) {
	l.Outputf(2, Lnodebug, format, v...)
}

// Debugf prints the message like Printf. The printing might be suppressed
// by the flag Lnodebug.
func Debugf(format string, v ...interface{}) {
	std.Outputf(2, Lnodebug, format, v...)
}

// Debugln prints the message like Println. The printing might be suppressed
// by the flag Lnodebug.
func (l *Logger) Debugln(v ...interface{}) {
	l.Outputln(2, Lnodebug, v...)
}

// Debugln prints the message like Println. The printing might be suppressed
// by the flag Lnodebug.
func Debugln(v ...interface{}) {
	std.Outputln(2, Lnodebug, v...)
}

// Flags returns the current flags used by the logger.
func (l *Logger) Flags() int {
	l.mu.Lock()
	defer l.mu.Unlock()
	return l.flag
}

// Flags returns the current flags used by the standard logger.
func Flags() int {
	return std.Flags()
}

// SetFlags sets the flags of the logger.
func (l *Logger) SetFlags(flag int) {
	l.mu.Lock()
	defer l.mu.Unlock()
	l.flag = flag
}

// SetFlags sets the flags for the standard logger.
func SetFlags(flag int) {
	std.SetFlags(flag)
}

// Prefix returns the prefix used by the logger.
func (l *Logger) Prefix() string {
	l.mu.Lock()
	defer l.mu.Unlock()
	return l.prefix
}

// Prefix returns the prefix used by the standard logger of the package.
func Prefix() string {
	return std.Prefix()
}

// SetPrefix sets the prefix for the logger.
func (l *Logger) SetPrefix(prefix string) {
	l.mu.Lock()
	defer l.mu.Unlock()
	l.prefix = prefix
}

// SetPrefix sets the prefix of the standard logger of the package.
func SetPrefix(prefix string) {
	std.SetPrefix(prefix)
}

// SetOutput sets the output of the logger.
func (l *Logger) SetOutput(w io.Writer) {
	l.mu.Lock()
	defer l.mu.Unlock()
	l.out = w
}

// SetOutput sets the output for the standard logger of the package.
func SetOutput(w io.Writer) {
	std.SetOutput(w)
}

redpajama_set_name: RedPajamaGithub


text:
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Thorn.Config
{
	internal class RoutingInfo
	{
		private string _defaultNamespace;
		private readonly IDictionary<string, IList<Export>> _exports = new Dictionary<string, IList<Export>>();

		public RoutingInfo(IEnumerable<Export> exports, string defaultNamespace = null)
		{
			_defaultNamespace = defaultNamespace;
			foreach (var export in exports)
			{
				AddExport(export);
			}
		}

		public string DefaultNamespace
		{
			get { return _defaultNamespace; }
		}

		public IEnumerable<Export> Exports
		{
			get
			{
				return from list in _exports.Values
				       from export in list
				       select export;
			}
		}

		public IEnumerable<Export> ExportsInNamespace(string ns)
		{
			return _exports[ns];
		}

		private void AddExport(Export export)
		{
			if (!_exports.ContainsKey(export.Namespace))
			{
				_exports[export.Namespace] = new List<Export>();
			}
			_exports[export.Namespace].Add(export);
		}

		public void Validate()
		{
			if (_exports.Values.Sum(list => list.Count) == 0)
				throw new ConfigurationException("Nothing has been exported. Did you mark your class with a [ThornExport] attribute?");

			foreach (var export in Exports)
			{
				export.Validate();
			}

			CheckForNameCollisions();
		}

		private void CheckForNameCollisions()
		{
			foreach (var key in _exports.Keys)
			{
				foreach (var name in _exports[key].Select(export => export.Name).Distinct())
				{
					if (_exports[key].Count(export => export.Name == name) > 1)
					{
						var sb = new StringBuilder();
						sb.AppendLine("Exported names must be unique within a namespace. The following conflict:");

						foreach (var export in _exports[key].Where(export => export.Name == name))
						{
							sb.AppendFormat("{0}\n", export);
						}

						throw new ConfigurationException(sb.ToString());
					}
				}
			}
		}
	}
}


text:
import ray
from ray.test_utils import run_string_as_driver

# This tests the queue transitions for infeasible tasks. This has been an issue
# in the past, e.g., https://github.com/ray-project/ray/issues/3275.
def test_infeasible_tasks(ray_start_cluster):
    cluster = ray_start_cluster

    @ray.remote
    def f():
        return

    cluster.add_node(resources={str(0): 100})
    ray.init(address=cluster.address)

    # Submit an infeasible task.
    x_id = f._submit(args=[], kwargs={}, resources={str(1): 1})

    # Add a node that makes the task feasible and make sure we can get the
    # result.
    cluster.add_node(resources={str(1): 100})
    ray.get(x_id)

    # Start a driver that submits an infeasible task and then let it exit.
    driver_script = """
import ray

ray.init(address="{}")

@ray.remote(resources={})
def f():
{}pass  # This is a weird hack to insert some blank space.

f.remote()
""".format(cluster.address, "{str(2): 1}", "    ")

    run_string_as_driver(driver_script)

    # Now add a new node that makes the task feasible.
    cluster.add_node(resources={str(2): 100})

    # Make sure we can still run tasks on all nodes.
    ray.get([
        f._submit(args=[], kwargs={}, resources={str(i): 1}) for i in range(3)
    ])

if __name__ == "__main__":
    import pytest
    import sys
    sys.exit(pytest.main(["-v", __file__]))


text:
package @packageName@.service;

  import static org.junit.Assert.assertTrue;

  import org.junit.After;
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.test.context.ContextConfiguration;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

  import com.netflix.config.ConfigurationManager;
  import com.netflix.hystrix.Hystrix;
  import com.officedepot.servicecore.model.CoreServiceResponse;
  import@packageName @.model.ExampleRequest;
  import@packageName @.model.ExampleTO;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = TestContext.class)
public class ExampleServiceGetApiTest {

  @Before
  public void setUp() {
    //If you need to mock the services, make sure to reset before next test
    //Mockito.reset(exampleServiceGetApiMock);

  }

  @After
  public void reset() {
    ConfigurationManager.getConfigInstance()
      .setProperty("hystrix.command.default.circuitBreaker.forceOpen",
        false);

    Hystrix.reset();
  }

  @Test
  public void testServiceGetCall() throws Exception {
    ExampleServiceGetApi<ExampleRequest, CoreServiceResponse<ExampleRequest, ExampleTO>> exampleServiceGetApi = new ExampleServiceGetApi<>();
    ExampleRequest er = new ExampleRequest();
    er.setName("test");
    exampleServiceGetApi.setRequest(er);
    exampleServiceGetApi.getProperties().circuitBreakerForceClosed();
    assertTrue(exampleServiceGetApi.execute().getResponseObject().getName().contains("successful"));
  }

  @Test
  public void testServiceGetFallbackCall() throws Exception {
    //force circuit breaker open so fallback is invoked
    ConfigurationManager.getConfigInstance()
      .setProperty("hystrix.command.default.circuitBreaker.forceOpen",
        true);
    ExampleServiceGetApi<ExampleRequest, CoreServiceResponse<ExampleRequest, ExampleTO>> exampleServiceGetApi = new ExampleServiceGetApi<>();
    ExampleRequest er = new ExampleRequest();
    er.setName("failtest");
    exampleServiceGetApi.setRequest(er);

    assertTrue(exampleServiceGetApi.execute().getResponseObject().getName().contains("failed"));
  }
}


text:
/**
 */
package CIM.IEC61970.Informative.InfOperations.impl;

import CIM.IEC61970.Core.CorePackage;
import CIM.IEC61970.Core.PowerSystemResource;

import CIM.IEC61970.Core.impl.IdentifiedObjectImpl;

import CIM.IEC61970.Informative.InfAssets.ConductorAsset;
import CIM.IEC61970.Informative.InfAssets.InfAssetsPackage;

import CIM.IEC61970.Informative.InfOperations.Circuit;
import CIM.IEC61970.Informative.InfOperations.CircuitConnectionKind;
import CIM.IEC61970.Informative.InfOperations.CircuitSection;
import CIM.IEC61970.Informative.InfOperations.InfOperationsPackage;
import CIM.IEC61970.Informative.InfOperations.NetworkDataSet;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 *
 * An implementation of the model object 'Circuit Section'.
 *
 *

 * The following features are implemented:
 *

 *

 *
{@link CIM.IEC61970.Informative.InfOperations.impl.CircuitSectionImpl#getCircuits Circuits}

 *
{@link CIM.IEC61970.Informative.InfOperations.impl.CircuitSectionImpl#getNetworkDataSets Network Data Sets}

 *
{@link CIM.IEC61970.Informative.InfOperations.impl.CircuitSectionImpl#getPowerSystemResources Power System Resources}

 *
{@link CIM.IEC61970.Informative.InfOperations.impl.CircuitSectionImpl#getConnectionKind Connection Kind}

 *
{@link CIM.IEC61970.Informative.InfOperations.impl.CircuitSectionImpl#getConductorAssets Conductor Assets}

 *

 *
 * @generated
 */
public class CircuitSectionImpl extends IdentifiedObjectImpl implements CircuitSection {
	/**
	 * The cached value of the '{@link #getCircuits() Circuits}' reference list.
	 *
	 *
	 * @see #getCircuits()
	 * @generated
	 * @ordered
	 */
	protected EList<Circuit> circuits;

	/**
	 * The cached value of the '{@link #getNetworkDataSets() Network Data Sets}' reference list.
	 *
	 *
	 * @see #getNetworkDataSets()
	 * @generated
	 * @ordered
	 */
	protected EList<NetworkDataSet> networkDataSets;

	/**
	 * The cached value of the '{@link #getPowerSystemResources() Power System Resources}' reference list.
	 *
	 *
	 * @see #getPowerSystemResources()
	 * @generated
	 * @ordered
	 */
	protected EList<PowerSystemResource> powerSystemResources;

	/**
	 * The default value of the '{@link #getConnectionKind() Connection Kind}' attribute.
	 *
	 *
	 * @see #getConnectionKind()
	 * @generated
	 * @ordered
	 */
	protected static final CircuitConnectionKind CONNECTION_KIND_EDEFAULT = CircuitConnectionKind.OTHER;

	/**
	 * The cached value of the '{@link #getConnectionKind() Connection Kind}' attribute.
	 *
	 *
	 * @see #getConnectionKind()
	 * @generated
	 * @ordered
	 */
	protected CircuitConnectionKind connectionKind = CONNECTION_KIND_EDEFAULT;

	/**
	 * The cached value of the '{@link #getConductorAssets() Conductor Assets}' reference list.
	 *
	 *
	 * @see #getConductorAssets()
	 * @generated
	 * @ordered
	 */
	protected EList<ConductorAsset> conductorAssets;

	/**
	 *
	 *
	 * @generated
	 */
	protected CircuitSectionImpl() {
		super();
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return InfOperationsPackage.Literals.CIRCUIT_SECTION;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EList<Circuit> getCircuits() {
		if (circuits == null) {
			circuits = new EObjectResolvingEList<Circuit>(Circuit.class, this, InfOperationsPackage.CIRCUIT_SECTION__CIRCUITS);
		}
		return circuits;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EList<NetworkDataSet> getNetworkDataSets() {
		if (networkDataSets == null) {
			networkDataSets = new EObjectWithInverseResolvingEList.ManyInverse<NetworkDataSet>(NetworkDataSet.class, this, InfOperationsPackage.CIRCUIT_SECTION__NETWORK_DATA_SETS, InfOperationsPackage.NETWORK_DATA_SET__CIRCUIT_SECTIONS);
		}
		return networkDataSets;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EList<PowerSystemResource> getPowerSystemResources() {
		if (powerSystemResources == null) {
			powerSystemResources = new EObjectWithInverseResolvingEList.ManyInverse<PowerSystemResource>(PowerSystemResource.class, this, InfOperationsPackage.CIRCUIT_SECTION__POWER_SYSTEM_RESOURCES, CorePackage.POWER_SYSTEM_RESOURCE__CIRCUIT_SECTIONS);
		}
		return powerSystemResources;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public CircuitConnectionKind getConnectionKind() {
		return connectionKind;
	}

	/**
	 *
	 *
	 * @generated
	 */
	public void setConnectionKind(CircuitConnectionKind newConnectionKind) {
		CircuitConnectionKind oldConnectionKind = connectionKind;
		connectionKind = newConnectionKind == null ? CONNECTION_KIND_EDEFAULT : newConnectionKind;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InfOperationsPackage.CIRCUIT_SECTION__CONNECTION_KIND, oldConnectionKind, connectionKind));
	}

	/**
	 *
	 *
	 * @generated
	 */
	public EList<ConductorAsset> getConductorAssets() {
		if (conductorAssets == null) {
			conductorAssets = new EObjectWithInverseResolvingEList<ConductorAsset>(ConductorAsset.class, this, InfOperationsPackage.CIRCUIT_SECTION__CONDUCTOR_ASSETS, InfAssetsPackage.CONDUCTOR_ASSET__CIRCUIT_SECTION);
		}
		return conductorAssets;
	}

	/**
	 *
	 *
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case InfOperationsPackage.CIRCUIT_SECTION__NETWORK_DATA_SETS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getNetworkDataSets()).basicAdd(otherEnd, msgs);
			case InfOperationsPackage.CIRCUIT_SECTION__POWER_SYSTEM_RESOURCES:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getPowerSystemResources()).basicAdd(otherEnd, msgs);
			case InfOperationsPackage.CIRCUIT_SECTION__CONDUCTOR_ASSETS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getConductorAssets()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case InfOperationsPackage.CIRCUIT_SECTION__NETWORK_DATA_SETS:
				return ((InternalEList<?>)getNetworkDataSets()).basicRemove(otherEnd, msgs);
			case InfOperationsPackage.CIRCUIT_SECTION__POWER_SYSTEM_RESOURCES:
				return ((InternalEList<?>)getPowerSystemResources()).basicRemove(otherEnd, msgs);
			case InfOperationsPackage.CIRCUIT_SECTION__CONDUCTOR_ASSETS:
				return ((InternalEList<?>)getConductorAssets()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case InfOperationsPackage.CIRCUIT_SECTION__CIRCUITS:
				return getCircuits();
			case InfOperationsPackage.CIRCUIT_SECTION__NETWORK_DATA_SETS:
				return getNetworkDataSets();
			case InfOperationsPackage.CIRCUIT_SECTION__POWER_SYSTEM_RESOURCES:
				return getPowerSystemResources();
			case InfOperationsPackage.CIRCUIT_SECTION__CONNECTION_KIND:
				return getConnectionKind();
			case InfOperationsPackage.CIRCUIT_SECTION__CONDUCTOR_ASSETS:
				return getConductorAssets();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case InfOperationsPackage.CIRCUIT_SECTION__CIRCUITS:
				getCircuits().clear();
				getCircuits().addAll((Collection<? extends Circuit>)newValue);
				return;
			case InfOperationsPackage.CIRCUIT_SECTION__NETWORK_DATA_SETS:
				getNetworkDataSets().clear();
				getNetworkDataSets().addAll((Collection<? extends NetworkDataSet>)newValue);
				return;
			case InfOperationsPackage.CIRCUIT_SECTION__POWER_SYSTEM_RESOURCES:
				getPowerSystemResources().clear();
				getPowerSystemResources().addAll((Collection<? extends PowerSystemResource>)newValue);
				return;
			case InfOperationsPackage.CIRCUIT_SECTION__CONNECTION_KIND:
				setConnectionKind((CircuitConnectionKind)newValue);
				return;
			case InfOperationsPackage.CIRCUIT_SECTION__CONDUCTOR_ASSETS:
				getConductorAssets().clear();
				getConductorAssets().addAll((Collection<? extends ConductorAsset>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case InfOperationsPackage.CIRCUIT_SECTION__CIRCUITS:
				getCircuits().clear();
				return;
			case InfOperationsPackage.CIRCUIT_SECTION__NETWORK_DATA_SETS:
				getNetworkDataSets().clear();
				return;
			case InfOperationsPackage.CIRCUIT_SECTION__POWER_SYSTEM_RESOURCES:
				getPowerSystemResources().clear();
				return;
			case InfOperationsPackage.CIRCUIT_SECTION__CONNECTION_KIND:
				setConnectionKind(CONNECTION_KIND_EDEFAULT);
				return;
			case InfOperationsPackage.CIRCUIT_SECTION__CONDUCTOR_ASSETS:
				getConductorAssets().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case InfOperationsPackage.CIRCUIT_SECTION__CIRCUITS:
				return circuits != null && !circuits.isEmpty();
			case InfOperationsPackage.CIRCUIT_SECTION__NETWORK_DATA_SETS:
				return networkDataSets != null && !networkDataSets.isEmpty();
			case InfOperationsPackage.CIRCUIT_SECTION__POWER_SYSTEM_RESOURCES:
				return powerSystemResources != null && !powerSystemResources.isEmpty();
			case InfOperationsPackage.CIRCUIT_SECTION__CONNECTION_KIND:
				return connectionKind != CONNECTION_KIND_EDEFAULT;
			case InfOperationsPackage.CIRCUIT_SECTION__CONDUCTOR_ASSETS:
				return conductorAssets != null && !conductorAssets.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 *
	 *
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (connectionKind: ");
		result.append(connectionKind);
		result.append(')');
		return result.toString();
	}

} //CircuitSectionImpl


text:
<?php

namespace Webmozart\Console\Tests\Api\IO;

use PHPUnit_Framework_TestCase;
use Webmozart\Console\Api\Formatter\Formatter;
use Webmozart\Console\Api\IO\IO;
use Webmozart\Console\Api\IO\Output;
use Webmozart\Console\Formatter\NullFormatter;
use Webmozart\Console\IO\OutputStream\BufferedOutputStream;

/**
 * @since  1.0
 *
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
class OutputTest extends PHPUnit_Framework_TestCase
{
    /**
     * @var NullFormatter
     */
    private $formatter;

    /**
     * @var BufferedOutputStream
     */
    private $stream;

    /**
     * @var Output
     */
    private $output;

    protected function setUp()
    {
        $this->formatter = new NullFormatter();
        $this->stream = new BufferedOutputStream();
        $this->output = new Output($this->stream);
    }

    public function testWriteWhenNotVerbose()
    {
        $this->output->setVerbosity(IO::NORMAL);

        $this->output->write('Lorem ipsum ');
        $this->output->write('dolor sit amet ', IO::VERBOSE);
        $this->output->write('consetetur ', IO::VERY_VERBOSE);
        $this->output->write('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum ', $this->stream->fetch());
    }

    public function testWriteWhenVerbose()
    {
        $this->output->setVerbosity(IO::VERBOSE);

        $this->output->write('Lorem ipsum ');
        $this->output->write('dolor sit amet ', IO::VERBOSE);
        $this->output->write('consetetur ', IO::VERY_VERBOSE);
        $this->output->write('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum dolor sit amet ', $this->stream->fetch());
    }

    public function testWriteWhenVeryVerbose()
    {
        $this->output->setVerbosity(IO::VERY_VERBOSE);

        $this->output->write('Lorem ipsum ');
        $this->output->write('dolor sit amet ', IO::VERBOSE);
        $this->output->write('consetetur ', IO::VERY_VERBOSE);
        $this->output->write('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum dolor sit amet consetetur ', $this->stream->fetch());
    }

    public function testWriteWhenDebug()
    {
        $this->output->setVerbosity(IO::DEBUG);

        $this->output->write('Lorem ipsum ');
        $this->output->write('dolor sit amet ', IO::VERBOSE);
        $this->output->write('consetetur ', IO::VERY_VERBOSE);
        $this->output->write('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum dolor sit amet consetetur sadipscing elitr', $this->stream->fetch());
    }

    public function testWriteFormatsText()
    {
        $formatter = $this->getMock('Webmozart\Console\Api\Formatter\Formatter');

        $formatter->expects($this->once())
            ->method('format')
            ->with('<tag>text</tag>')
            ->willReturn('<formatted>text</formatted>');

        $this->output->setFormatter($formatter);
        $this->output->write('<tag>text</tag>');

        $this->assertSame('<formatted>text</formatted>', $this->stream->fetch());
    }

    public function testWriteSupportsAnsiFormats()
    {
        $stream = $this->getMockBuilder('Webmozart\Console\IO\OutputStream\BufferedOutputStream')
            ->setMethods(array('supportsAnsi'))
            ->getMock();

        $stream->expects($this->any())
            ->method('supportsAnsi')
            ->willReturn(true);

        $ansiFormatter = $this->getMockBuilder('Webmozart\Console\Formatter\AnsiFormatter')
            ->setMethods(array('format', 'removeFormat'))
            ->getMock();

        $ansiFormatter->expects($this->once())
            ->method('format')
            ->with('<tag>text</tag>')
            ->willReturn('<formatted>text</formatted>');

        $this->output->setStream($stream);
        $this->output->setFormatter($ansiFormatter);
        $this->output->write('<tag>text</tag>');

        $this->assertSame('<formatted>text</formatted>', $stream->fetch());
    }

    public function testWriteRemovesTagsIfAnsiNotSupported()
    {
        $stream = $this->getMockBuilder('Webmozart\Console\IO\OutputStream\BufferedOutputStream')
            ->setMethods(array('supportsAnsi'))
            ->getMock();

        $stream->expects($this->any())
            ->method('supportsAnsi')
            ->willReturn(false);

        $ansiFormatter = $this->getMockBuilder('Webmozart\Console\Formatter\AnsiFormatter')
            ->setMethods(array('format', 'removeFormat'))
            ->getMock();

        $ansiFormatter->expects($this->once())
            ->method('removeFormat')
            ->with('<tag>text</tag>')
            ->willReturn('text');

        $this->output->setStream($stream);
        $this->output->setFormatter($ansiFormatter);
        $this->output->write('<tag>text</tag>');

        $this->assertSame('text', $stream->fetch());
    }

    public function testWriteLineWhenNotVerbose()
    {
        $this->output->setVerbosity(IO::NORMAL);

        $this->output->writeLine('Lorem ipsum');
        $this->output->writeLine('dolor sit amet', IO::VERBOSE);
        $this->output->writeLine('consetetur', IO::VERY_VERBOSE);
        $this->output->writeLine('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineWhenVerbose()
    {
        $this->output->setVerbosity(IO::VERBOSE);

        $this->output->writeLine('Lorem ipsum');
        $this->output->writeLine('dolor sit amet', IO::VERBOSE);
        $this->output->writeLine('consetetur', IO::VERY_VERBOSE);
        $this->output->writeLine('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum'.PHP_EOL.'dolor sit amet'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineWhenVeryVerbose()
    {
        $this->output->setVerbosity(IO::VERY_VERBOSE);

        $this->output->writeLine('Lorem ipsum');
        $this->output->writeLine('dolor sit amet', IO::VERBOSE);
        $this->output->writeLine('consetetur', IO::VERY_VERBOSE);
        $this->output->writeLine('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum'.PHP_EOL.'dolor sit amet'.PHP_EOL.'consetetur'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineWhenDebug()
    {
        $this->output->setVerbosity(IO::DEBUG);

        $this->output->writeLine('Lorem ipsum');
        $this->output->writeLine('dolor sit amet', IO::VERBOSE);
        $this->output->writeLine('consetetur', IO::VERY_VERBOSE);
        $this->output->writeLine('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum'.PHP_EOL.'dolor sit amet'.PHP_EOL.'consetetur'.PHP_EOL.'sadipscing elitr'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineTrimsTrailingNewlines()
    {
        $this->output->writeLine('Lorem ipsum'.PHP_EOL);

        $this->assertSame('Lorem ipsum'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineDoesNotTrimTrailingSpaces()
    {
        $this->output->writeLine('Lorem ipsum   '.PHP_EOL);

        $this->assertSame('Lorem ipsum   '.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineFormatsText()
    {
        $formatter = $this->getMock('Webmozart\Console\Api\Formatter\Formatter');

        $formatter->expects($this->once())
            ->method('format')
            ->with('<tag>text</tag>')
            ->willReturn('<formatted>text</formatted>');

        $this->output->setFormatter($formatter);
        $this->output->writeLine('<tag>text</tag>');

        $this->assertSame('<formatted>text</formatted>'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineSupportsAnsiFormats()
    {
        $stream = $this->getMockBuilder('Webmozart\Console\IO\OutputStream\BufferedOutputStream')
            ->setMethods(array('supportsAnsi'))
            ->getMock();

        $stream->expects($this->any())
            ->method('supportsAnsi')
            ->willReturn(true);

        $ansiFormatter = $this->getMockBuilder('Webmozart\Console\Formatter\AnsiFormatter')
            ->setMethods(array('format', 'removeFormat'))
            ->getMock();

        $ansiFormatter->expects($this->once())
            ->method('format')
            ->with('<tag>text</tag>')
            ->willReturn('<formatted>text</formatted>');

        $this->output->setStream($stream);
        $this->output->setFormatter($ansiFormatter);
        $this->output->writeLine('<tag>text</tag>');

        $this->assertSame('<formatted>text</formatted>'.PHP_EOL, $stream->fetch());
    }

    public function testWriteLineRemovesTagsIfAnsiNotSupported()
    {
        $stream = $this->getMockBuilder('Webmozart\Console\IO\OutputStream\BufferedOutputStream')
            ->setMethods(array('supportsAnsi'))
            ->getMock();

        $stream->expects($this->any())
            ->method('supportsAnsi')
            ->willReturn(false);

        $ansiFormatter = $this->getMockBuilder('Webmozart\Console\Formatter\AnsiFormatter')
            ->setMethods(array('format', 'removeFormat'))
            ->getMock();

        $ansiFormatter->expects($this->once())
            ->method('removeFormat')
            ->with('<tag>text</tag>')
            ->willReturn('text');

        $this->output->setStream($stream);
        $this->output->setFormatter($ansiFormatter);
        $this->output->writeLine('<tag>text</tag>');

        $this->assertSame('text'.PHP_EOL, $stream->fetch());
    }

    public function testWriteRawWhenNotVerbose()
    {
        $this->output->setVerbosity(IO::NORMAL);

        $this->output->writeRaw('Lorem ipsum ');
        $this->output->writeRaw('dolor sit amet ', IO::VERBOSE);
        $this->output->writeRaw('consetetur ', IO::VERY_VERBOSE);
        $this->output->writeRaw('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum ', $this->stream->fetch());
    }

    public function testWriteRawWhenVerbose()
    {
        $this->output->setVerbosity(IO::VERBOSE);

        $this->output->writeRaw('Lorem ipsum ');
        $this->output->writeRaw('dolor sit amet ', IO::VERBOSE);
        $this->output->writeRaw('consetetur ', IO::VERY_VERBOSE);
        $this->output->writeRaw('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum dolor sit amet ', $this->stream->fetch());
    }

    public function testWriteRawWhenVeryVerbose()
    {
        $this->output->setVerbosity(IO::VERY_VERBOSE);

        $this->output->writeRaw('Lorem ipsum ');
        $this->output->writeRaw('dolor sit amet ', IO::VERBOSE);
        $this->output->writeRaw('consetetur ', IO::VERY_VERBOSE);
        $this->output->writeRaw('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum dolor sit amet consetetur ', $this->stream->fetch());
    }

    public function testWriteRawWhenDebug()
    {
        $this->output->setVerbosity(IO::DEBUG);

        $this->output->writeRaw('Lorem ipsum ');
        $this->output->writeRaw('dolor sit amet ', IO::VERBOSE);
        $this->output->writeRaw('consetetur ', IO::VERY_VERBOSE);
        $this->output->writeRaw('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum dolor sit amet consetetur sadipscing elitr', $this->stream->fetch());
    }

    public function testWriteRawDoesNotFormatText()
    {
        $formatter = $this->getMock('Webmozart\Console\Api\Formatter\Formatter');

        $formatter->expects($this->never())
            ->method('format');

        $this->output->setFormatter($formatter);
        $this->output->writeRaw('<tag>text</tag>');

        $this->assertSame('<tag>text</tag>', $this->stream->fetch());
    }

    public function testWriteLineRawWhenNotVerbose()
    {
        $this->output->setVerbosity(IO::NORMAL);

        $this->output->writeLineRaw('Lorem ipsum');
        $this->output->writeLineRaw('dolor sit amet', IO::VERBOSE);
        $this->output->writeLineRaw('consetetur', IO::VERY_VERBOSE);
        $this->output->writeLineRaw('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineRawWhenVerbose()
    {
        $this->output->setVerbosity(IO::VERBOSE);

        $this->output->writeLineRaw('Lorem ipsum');
        $this->output->writeLineRaw('dolor sit amet', IO::VERBOSE);
        $this->output->writeLineRaw('consetetur', IO::VERY_VERBOSE);
        $this->output->writeLineRaw('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum'.PHP_EOL.'dolor sit amet'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineRawWhenVeryVerbose()
    {
        $this->output->setVerbosity(IO::VERY_VERBOSE);

        $this->output->writeLineRaw('Lorem ipsum');
        $this->output->writeLineRaw('dolor sit amet', IO::VERBOSE);
        $this->output->writeLineRaw('consetetur', IO::VERY_VERBOSE);
        $this->output->writeLineRaw('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum'.PHP_EOL.'dolor sit amet'.PHP_EOL.'consetetur'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineRawWhenDebug()
    {
        $this->output->setVerbosity(IO::DEBUG);

        $this->output->writeLineRaw('Lorem ipsum');
        $this->output->writeLineRaw('dolor sit amet', IO::VERBOSE);
        $this->output->writeLineRaw('consetetur', IO::VERY_VERBOSE);
        $this->output->writeLineRaw('sadipscing elitr', IO::DEBUG);

        $this->assertSame('Lorem ipsum'.PHP_EOL.'dolor sit amet'.PHP_EOL.'consetetur'.PHP_EOL.'sadipscing elitr'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineRawTrimsTrailingNewlines()
    {
        $this->output->writeLineRaw('Lorem ipsum'.PHP_EOL);

        $this->assertSame('Lorem ipsum'.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineRawDoesNotTrimTrailingSpaces()
    {
        $this->output->writeLineRaw('Lorem ipsum   '.PHP_EOL);

        $this->assertSame('Lorem ipsum   '.PHP_EOL, $this->stream->fetch());
    }

    public function testWriteLineRawDoesNotFormatText()
    {
        $formatter = $this->getMock('Webmozart\Console\Api\Formatter\Formatter');

        $formatter->expects($this->never())
            ->method('format');

        $this->output->setFormatter($formatter);
        $this->output->writeLineRaw('<tag>text</tag>');

        $this->assertSame('<tag>text</tag>'.PHP_EOL, $this->stream->fetch());
    }

    public function testFlush()
    {
        $stream = $this->getMock('Webmozart\Console\Api\IO\OutputStream');

        $stream->expects($this->once())
            ->method('flush');

        $this->output->setStream($stream);
        $this->output->flush();
    }

    public function testClose()
    {
        $stream = $this->getMock('Webmozart\Console\Api\IO\OutputStream');

        $stream->expects($this->once())
            ->method('close');

        $this->output->setStream($stream);
        $this->output->close();
    }
}


text:
""" A script for testing DraftRegistrationApprovals. Automatically approves all pending
DraftRegistrationApprovals.
"""
import sys
import logging

from framework.celery_tasks.handlers import celery_teardown_request

from website.app import init_app
from website.project.model import DraftRegistration, Sanction

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.WARN)
logging.disable(level=logging.INFO)

def main(dry_run=True):
    if dry_run:
        logger.warn('DRY RUN mode')
    pending_approval_drafts = DraftRegistration.find()
    need_approval_drafts = [draft for draft in pending_approval_drafts
                            if draft.approval and draft.requires_approval and draft.approval.state == Sanction.UNAPPROVED]

    for draft in need_approval_drafts:
        sanction = draft.approval
        try:
            if not dry_run:
                sanction.state = Sanction.APPROVED
                sanction._on_complete(None)
                sanction.save()
            logger.warn('Approved {0}'.format(draft._id))
        except Exception as e:
            logger.error(e)

if __name__ == '__main__':
    dry_run = 'dry' in sys.argv
    app = init_app(routes=False)
    main(dry_run=dry_run)
    celery_teardown_request()


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>ca.ualberta.cs.models</title>
<meta name="date" content="2014-11-10">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

PREV PACKAGE

NEXT PACKAGE

FRAMES

NO FRAMES

All Classes

Package ca.ualberta.cs.models

Class Summary

Class
Description

Answer

This class is an answer to a question in a forum entry.

AuthorModel

Models the person's name who is using the app.

DataManager

Model class for the data saved in memory and/or the remote server.

Entry

Super class of Question and Answer.

ForumEntry

Contains all the information of one forum post.

ForumEntryList

This is the model class for BrowseActivity and QuestionActivity.

JsonDriver

Observable<T extends Observer>

Contains a list of all the views who are "observing" this model.

Question

This class is a question in a forum entry.

Reply

Describes what a reply to an answer or main question looks like.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

PREV PACKAGE

NEXT PACKAGE

FRAMES

NO FRAMES

All Classes


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uma.wdi.fusion.resolution;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.w3c.dom.Node;

import uma.wdi.fusion.input.Dataset;
import uma.wdi.fusion.utils.Pair;
import uma.wdi.fusion.utils.XMLUtils;

/* Conflict resolution function that takes as input an array of trust values for dataset ("source" filed in the provenance element)
 * and selects all the values from a dataset(s) with the highest trust values
 * if selectFirst is true, returns the first of the values from the most trusted dataset(s)
 *
 * Same logic as in MostRecent
 *
 * @author Volha
 * */
public class MostTrusted extends AbstractResolutionFunction
{
	private Map<String,Double> trust = new HashMap<String,Double>();
	private boolean selectFirst = false; // false by default

	public MostTrusted (Map<String,Double> _trust)
	{
		trust = _trust;
		selectFirst = false;
	}

	public MostTrusted (Map<String,Double> _trust, boolean _selectFirst)
	{
		selectFirst = _selectFirst;
		trust = _trust;
	}

	// Select all values from the most trusted dataset(s)
	@Override
	public Set<Pair> applyStrategy(Dataset ds, Node node, String path)
	{
		// get data to fuse:
		Set<Pair> pairs = getValueProvenancePairs(node, path);

		// select most recent value
		Set<Pair> result = new HashSet<Pair>();
		Double maxRank = null;
		for (Pair p : pairs)
		{
			String sSource = ds.getProvenanceAttribute(p.provenance, "source");
			Double r = trust.get(sSource);
			if ((maxRank == null) || (r > maxRank)) maxRank = r;
		}

		// collect all most recent values
		Map<String,String> valueMap= new HashMap<String,String>();
		for (Pair p : pairs)
		{
			String sSource = ds.getProvenanceAttribute(p.provenance, "source");
			if (trust.get(sSource).equals(maxRank))
			{
				//than add a value to a value map
				if (valueMap.containsKey(p.value))
					valueMap.put(p.value, valueMap.get(p.value)+","+p.provenance);
				else
					valueMap.put(p.value, p.provenance);
			}
		}

		// insert the resulting values:
		if (selectFirst)
		{
			// insert the first value
			String v = valueMap.entrySet().iterator().next().getKey();
			result.add(new Pair(v,valueMap.get(v)));
		}
		else
		{
			// insert them all
			for (String v : valueMap.keySet()) result.add(new Pair(v,valueMap.get(v)));
		}

		return result;
	}
}