text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.05.03 at 03:15:27 PM EDT
//

package API.amazon.mws.xml.JAXB;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for EnergyUnitOfMeasure.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *

 *

 * <simpleType name="EnergyUnitOfMeasure">
 *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
 *     <enumeration value="BTU"/>
 *     <enumeration value="watts"/>
 *     <enumeration value="joules"/>
 *     <enumeration value="kilojoules"/>
 *   </restriction>
 * </simpleType>
 *

 *
 */
@XmlType(name = "EnergyUnitOfMeasure")
@XmlEnum
public enum EnergyUnitOfMeasure {

    BTU("BTU"),
    @XmlEnumValue("watts")
    WATTS("watts"),
    @XmlEnumValue("joules")
    JOULES("joules"),
    @XmlEnumValue("kilojoules")
    KILOJOULES("kilojoules");
    private final String value;

    EnergyUnitOfMeasure(String v) {
        value = v;
    }

    public String value() {
        return value;
    }

    public static EnergyUnitOfMeasure fromValue(String v) {
        for (EnergyUnitOfMeasure c: EnergyUnitOfMeasure.values()) {
            if (c.value.equals(v)) {
                return c;
            }
        }
        throw new IllegalArgumentException(v);
    }

}


text:
require("faketorio.helper")

function faketorio.prepare_tests()
    faketorio.print_message("Integrating tests.")

    faketorio.copy_test_infrastructure()
    faketorio.copy_tests()
    faketorio.integrate_tests()
end

function faketorio.copy_test_infrastructure()
    -- config has been loaded
    local src = faketorio.faketorio_path.."/ingame"
    local dest = faketorio.output_folder.."/faketorio"
    faketorio.copy_directory(src, dest)
end

function faketorio.copy_tests()
    faketorio.copy_directory("spec", faketorio.output_folder.."/faketorio/features", "feature")
end

function faketorio.integrate_tests()
    faketorio.print_message("Integrating tests with the mod.")
    local control = io.open(faketorio.output_folder .. "/control.lua", "a")

    control:write("\nrequire(\"faketorio.command\")\n")

    for file in faketorio.lfs.dir(faketorio.output_folder .. "/faketorio/features") do
        if (string.find(file, "_feature.lua")) then
            file = string.sub(file, 1, -5)
            faketorio.print_message("Integrating test file [" .. file .. "].")
            control:write("\nrequire(\"faketorio.features." .. file .. "\")\n")
        end
    end

    control:close()
    faketorio.print_message("Integrating tests finished.")

end

redpajama_set_name: RedPajamaGithub


text:
namespace base {
namespace trace_event {

namespace {

const char kDefaultTraceConfigString[] =
  "{"
    "\"enable_argument_filter\":false,"
    "\"enable_sampling\":false,"
    "\"enable_systrace\":false,"
    "\"excluded_categories\":[\"*Debug\",\"*Test\"],"
    "\"record_mode\":\"record-until-full\""
  "}";

const char kCustomTraceConfigString[] =
  "{"
    "\"enable_argument_filter\":true,"
    "\"enable_sampling\":true,"
    "\"enable_systrace\":true,"
    "\"excluded_categories\":[\"excluded\",\"exc_pattern*\"],"
    "\"included_categories\":[\"included\","
                            "\"inc_pattern*\","
                            "\"disabled-by-default-cc\","
                            "\"disabled-by-default-memory-infra\"],"
    "\"memory_dump_config\":{"
      "\"triggers\":["
        "{\"mode\":\"light\",\"periodic_interval_ms\":50},"
        "{\"mode\":\"detailed\",\"periodic_interval_ms\":1000}"
      "]"
    "},"
    "\"record_mode\":\"record-continuously\","
    "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]"
  "}";

}  // namespace

TEST(TraceConfigTest, TraceConfigFromValidLegacyFormat) {
  // From trace options strings
  TraceConfig config("", "record-until-full");
  EXPECT_EQ(RECORD_UNTIL_FULL, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-until-full", config.ToTraceOptionsString().c_str());

  config = TraceConfig("", "record-continuously");
  EXPECT_EQ(RECORD_CONTINUOUSLY, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-continuously", config.ToTraceOptionsString().c_str());

  config = TraceConfig("", "trace-to-console");
  EXPECT_EQ(ECHO_TO_CONSOLE, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("trace-to-console", config.ToTraceOptionsString().c_str());

  config = TraceConfig("", "record-as-much-as-possible");
  EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-as-much-as-possible",
               config.ToTraceOptionsString().c_str());

  config = TraceConfig("", "record-until-full, enable-sampling");
  EXPECT_EQ(RECORD_UNTIL_FULL, config.GetTraceRecordMode());
  EXPECT_TRUE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-until-full,enable-sampling",
               config.ToTraceOptionsString().c_str());

  config = TraceConfig("", "enable-systrace, record-continuously");
  EXPECT_EQ(RECORD_CONTINUOUSLY, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_TRUE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-continuously,enable-systrace",
               config.ToTraceOptionsString().c_str());

  config = TraceConfig("", "enable-argument-filter,record-as-much-as-possible");
  EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_TRUE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-as-much-as-possible,enable-argument-filter",
               config.ToTraceOptionsString().c_str());

  config = TraceConfig(
    "",
    "enable-systrace,trace-to-console,enable-sampling,enable-argument-filter");
  EXPECT_EQ(ECHO_TO_CONSOLE, config.GetTraceRecordMode());
  EXPECT_TRUE(config.IsSamplingEnabled());
  EXPECT_TRUE(config.IsSystraceEnabled());
  EXPECT_TRUE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ(
    "trace-to-console,enable-sampling,enable-systrace,enable-argument-filter",
    config.ToTraceOptionsString().c_str());

  config = TraceConfig(
    "", "record-continuously, record-until-full, trace-to-console");
  EXPECT_EQ(ECHO_TO_CONSOLE, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("trace-to-console", config.ToTraceOptionsString().c_str());

  // From TraceRecordMode
  config = TraceConfig("", RECORD_UNTIL_FULL);
  EXPECT_EQ(RECORD_UNTIL_FULL, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-until-full", config.ToTraceOptionsString().c_str());

  config = TraceConfig("", RECORD_CONTINUOUSLY);
  EXPECT_EQ(RECORD_CONTINUOUSLY, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-continuously", config.ToTraceOptionsString().c_str());

  config = TraceConfig("", ECHO_TO_CONSOLE);
  EXPECT_EQ(ECHO_TO_CONSOLE, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("trace-to-console", config.ToTraceOptionsString().c_str());

  config = TraceConfig("", RECORD_AS_MUCH_AS_POSSIBLE);
  EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("record-as-much-as-possible",
               config.ToTraceOptionsString().c_str());

  // From category filter strings
  config = TraceConfig("-*Debug,-*Test", "");
  EXPECT_STREQ("-*Debug,-*Test", config.ToCategoryFilterString().c_str());

  config = TraceConfig("included,-excluded,inc_pattern*,-exc_pattern*", "");
  EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*",
               config.ToCategoryFilterString().c_str());

  config = TraceConfig("only_inc_cat", "");
  EXPECT_STREQ("only_inc_cat", config.ToCategoryFilterString().c_str());

  config = TraceConfig("-only_exc_cat", "");
  EXPECT_STREQ("-only_exc_cat", config.ToCategoryFilterString().c_str());

  config = TraceConfig("disabled-by-default-cc,-excluded", "");
  EXPECT_STREQ("disabled-by-default-cc,-excluded",
               config.ToCategoryFilterString().c_str());

  config = TraceConfig("disabled-by-default-cc,included", "");
  EXPECT_STREQ("included,disabled-by-default-cc",
               config.ToCategoryFilterString().c_str());

  config = TraceConfig("DELAY(test.Delay1;16),included", "");
  EXPECT_STREQ("included,DELAY(test.Delay1;16)",
               config.ToCategoryFilterString().c_str());

  // From both trace options and category filter strings
  config = TraceConfig("", "");
  EXPECT_EQ(RECORD_UNTIL_FULL, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("", config.ToCategoryFilterString().c_str());
  EXPECT_STREQ("record-until-full", config.ToTraceOptionsString().c_str());

  config = TraceConfig("included,-excluded,inc_pattern*,-exc_pattern*",
                       "enable-systrace, trace-to-console, enable-sampling");
  EXPECT_EQ(ECHO_TO_CONSOLE, config.GetTraceRecordMode());
  EXPECT_TRUE(config.IsSamplingEnabled());
  EXPECT_TRUE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*",
               config.ToCategoryFilterString().c_str());
  EXPECT_STREQ("trace-to-console,enable-sampling,enable-systrace",
               config.ToTraceOptionsString().c_str());

  // From both trace options and category filter strings with spaces.
  config = TraceConfig(" included , -excluded, inc_pattern*, ,-exc_pattern*   ",
                       "enable-systrace, ,trace-to-console, enable-sampling  ");
  EXPECT_EQ(ECHO_TO_CONSOLE, config.GetTraceRecordMode());
  EXPECT_TRUE(config.IsSamplingEnabled());
  EXPECT_TRUE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*",
               config.ToCategoryFilterString().c_str());
  EXPECT_STREQ("trace-to-console,enable-sampling,enable-systrace",
               config.ToTraceOptionsString().c_str());

  // From category filter string and TraceRecordMode
  config = TraceConfig("included,-excluded,inc_pattern*,-exc_pattern*",
                       RECORD_CONTINUOUSLY);
  EXPECT_EQ(RECORD_CONTINUOUSLY, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("included,inc_pattern*,-excluded,-exc_pattern*",
               config.ToCategoryFilterString().c_str());
  EXPECT_STREQ("record-continuously", config.ToTraceOptionsString().c_str());
}

TEST(TraceConfigTest, TraceConfigFromInvalidLegacyStrings) {
  TraceConfig config("", "foo-bar-baz");
  EXPECT_EQ(RECORD_UNTIL_FULL, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_FALSE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("", config.ToCategoryFilterString().c_str());
  EXPECT_STREQ("record-until-full", config.ToTraceOptionsString().c_str());

  config = TraceConfig("arbitrary-category", "foo-bar-baz, enable-systrace");
  EXPECT_EQ(RECORD_UNTIL_FULL, config.GetTraceRecordMode());
  EXPECT_FALSE(config.IsSamplingEnabled());
  EXPECT_TRUE(config.IsSystraceEnabled());
  EXPECT_FALSE(config.IsArgumentFilterEnabled());
  EXPECT_STREQ("arbitrary-category", config.ToCategoryFilterString().c_str());
  EXPECT_STREQ("record-until-full,enable-systrace",
               config.ToTraceOptionsString().c_str());

  const char* const configs[] = {
    "",
    "DELAY(",
    "DELAY(;",
    "DELAY(;)",
    "DELAY(test.Delay)",
    "DELAY(test.Delay;)"
  };
  for (size_t i = 0; i < arraysize(configs); i++) {
    TraceConfig tc(configs[i], "");
    EXPECT_EQ(0u, tc.GetSyntheticDelayValues().size());
  }
}

TEST(TraceConfigTest, ConstructDefaultTraceConfig) {
  // Make sure that upon an empty string, we fall back to the default config.
  TraceConfig tc;
  EXPECT_STREQ(kDefaultTraceConfigString, tc.ToString().c_str());
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("-*Debug,-*Test", tc.ToCategoryFilterString().c_str());

  EXPECT_FALSE(tc.IsCategoryEnabled("Category1"));
  EXPECT_FALSE(tc.IsCategoryEnabled("not-excluded-category"));
  EXPECT_FALSE(tc.IsCategoryEnabled("CategoryTest"));
  EXPECT_FALSE(tc.IsCategoryEnabled("CategoryDebug"));
  EXPECT_FALSE(tc.IsCategoryEnabled("disabled-by-default-cc"));

  EXPECT_TRUE(tc.IsCategoryGroupEnabled("Category1"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("not-excluded-category"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("CategoryTest"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("CategoryDebug"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("disabled-by-default-cc"));

  EXPECT_TRUE(tc.IsCategoryGroupEnabled("Category1,CategoryDebug"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("CategoryDebug,Category1"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("CategoryTest,not-excluded-category"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("CategoryDebug,CategoryTest"));
}

TEST(TraceConfigTest, TraceConfigFromDict) {
  // Passing in empty dictionary will not result in default trace config.
  DictionaryValue dict;
  TraceConfig tc(dict);
  EXPECT_STRNE(kDefaultTraceConfigString, tc.ToString().c_str());
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("", tc.ToCategoryFilterString().c_str());

  scoped_ptr<Value> default_value(JSONReader::Read(kDefaultTraceConfigString));
  DCHECK(default_value);
  const DictionaryValue* default_dict = nullptr;
  bool is_dict = default_value->GetAsDictionary(&default_dict);
  DCHECK(is_dict);
  TraceConfig default_tc(*default_dict);
  EXPECT_STREQ(kDefaultTraceConfigString, default_tc.ToString().c_str());
  EXPECT_EQ(RECORD_UNTIL_FULL, default_tc.GetTraceRecordMode());
  EXPECT_FALSE(default_tc.IsSamplingEnabled());
  EXPECT_FALSE(default_tc.IsSystraceEnabled());
  EXPECT_FALSE(default_tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("-*Debug,-*Test", default_tc.ToCategoryFilterString().c_str());

  scoped_ptr<Value> custom_value(JSONReader::Read(kCustomTraceConfigString));
  DCHECK(custom_value);
  const DictionaryValue* custom_dict = nullptr;
  is_dict = custom_value->GetAsDictionary(&custom_dict);
  DCHECK(is_dict);
  TraceConfig custom_tc(*custom_dict);
  EXPECT_STREQ(kCustomTraceConfigString, custom_tc.ToString().c_str());
  EXPECT_EQ(RECORD_CONTINUOUSLY, custom_tc.GetTraceRecordMode());
  EXPECT_TRUE(custom_tc.IsSamplingEnabled());
  EXPECT_TRUE(custom_tc.IsSystraceEnabled());
  EXPECT_TRUE(custom_tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("included,inc_pattern*,"
               "disabled-by-default-cc,disabled-by-default-memory-infra,"
               "-excluded,-exc_pattern*,"
               "DELAY(test.Delay1;16),DELAY(test.Delay2;32)",
               custom_tc.ToCategoryFilterString().c_str());
}

TEST(TraceConfigTest, TraceConfigFromValidString) {
  // Using some non-empty config string.
  const char config_string[] =
    "{"
      "\"enable_argument_filter\":true,"
      "\"enable_sampling\":true,"
      "\"enable_systrace\":true,"
      "\"excluded_categories\":[\"excluded\",\"exc_pattern*\"],"
      "\"included_categories\":[\"included\","
                               "\"inc_pattern*\","
                               "\"disabled-by-default-cc\"],"
      "\"record_mode\":\"record-continuously\","
      "\"synthetic_delays\":[\"test.Delay1;16\",\"test.Delay2;32\"]"
    "}";
  TraceConfig tc(config_string);

  EXPECT_STREQ(config_string, tc.ToString().c_str());
  EXPECT_EQ(RECORD_CONTINUOUSLY, tc.GetTraceRecordMode());
  EXPECT_TRUE(tc.IsSamplingEnabled());
  EXPECT_TRUE(tc.IsSystraceEnabled());
  EXPECT_TRUE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("included,inc_pattern*,disabled-by-default-cc,-excluded,"
               "-exc_pattern*,DELAY(test.Delay1;16),DELAY(test.Delay2;32)",
               tc.ToCategoryFilterString().c_str());

  EXPECT_TRUE(tc.IsCategoryEnabled("included"));
  EXPECT_TRUE(tc.IsCategoryEnabled("inc_pattern_category"));
  EXPECT_TRUE(tc.IsCategoryEnabled("disabled-by-default-cc"));
  EXPECT_FALSE(tc.IsCategoryEnabled("excluded"));
  EXPECT_FALSE(tc.IsCategoryEnabled("exc_pattern_category"));
  EXPECT_FALSE(tc.IsCategoryEnabled("disabled-by-default-others"));
  EXPECT_FALSE(tc.IsCategoryEnabled("not-excluded-nor-included"));

  EXPECT_TRUE(tc.IsCategoryGroupEnabled("included"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("inc_pattern_category"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("disabled-by-default-cc"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("excluded"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("exc_pattern_category"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("disabled-by-default-others"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("not-excluded-nor-included"));

  EXPECT_TRUE(tc.IsCategoryGroupEnabled("included,excluded"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("excluded,exc_pattern_category"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("included,DELAY(test.Delay1;16)"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("DELAY(test.Delay1;16)"));

  EXPECT_EQ(2u, tc.GetSyntheticDelayValues().size());
  EXPECT_STREQ("test.Delay1;16", tc.GetSyntheticDelayValues()[0].c_str());
  EXPECT_STREQ("test.Delay2;32", tc.GetSyntheticDelayValues()[1].c_str());

  const char config_string_2[] = "{\"included_categories\":[\"*\"]}";
  TraceConfig tc2(config_string_2);
  EXPECT_TRUE(tc2.IsCategoryEnabled("non-disabled-by-default-pattern"));
  EXPECT_FALSE(tc2.IsCategoryEnabled("disabled-by-default-pattern"));
  EXPECT_TRUE(tc2.IsCategoryGroupEnabled("non-disabled-by-default-pattern"));
  EXPECT_FALSE(tc2.IsCategoryGroupEnabled("disabled-by-default-pattern"));

  // Clear
  tc.Clear();
  EXPECT_STREQ(tc.ToString().c_str(),
               "{"
                 "\"enable_argument_filter\":false,"
                 "\"enable_sampling\":false,"
                 "\"enable_systrace\":false,"
                 "\"record_mode\":\"record-until-full\""
               "}");
}

TEST(TraceConfigTest, TraceConfigFromInvalidString) {
  // The config string needs to be a dictionary correctly formatted as a JSON
  // string. Otherwise, it will fall back to the default initialization.
  TraceConfig tc("");
  EXPECT_STREQ(kDefaultTraceConfigString, tc.ToString().c_str());
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("-*Debug,-*Test", tc.ToCategoryFilterString().c_str());

  tc = TraceConfig("This is an invalid config string.");
  EXPECT_STREQ(kDefaultTraceConfigString, tc.ToString().c_str());
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("-*Debug,-*Test", tc.ToCategoryFilterString().c_str());

  tc = TraceConfig("[\"This\", \"is\", \"not\", \"a\", \"dictionary\"]");
  EXPECT_STREQ(kDefaultTraceConfigString, tc.ToString().c_str());
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("-*Debug,-*Test", tc.ToCategoryFilterString().c_str());

  tc = TraceConfig("{\"record_mode\": invalid-value-needs-double-quote}");
  EXPECT_STREQ(kDefaultTraceConfigString, tc.ToString().c_str());
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("-*Debug,-*Test", tc.ToCategoryFilterString().c_str());

  // If the config string a dictionary formatted as a JSON string, it will
  // initialize TraceConfig with best effort.
  tc = TraceConfig("{}");
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("", tc.ToCategoryFilterString().c_str());

  tc = TraceConfig("{\"arbitrary-key\":\"arbitrary-value\"}");
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("", tc.ToCategoryFilterString().c_str());

  const char invalid_config_string[] =
    "{"
      "\"enable_sampling\":\"true\","
      "\"enable_systrace\":1,"
      "\"excluded_categories\":[\"excluded\"],"
      "\"included_categories\":\"not a list\","
      "\"record_mode\":\"arbitrary-mode\","
      "\"synthetic_delays\":[\"test.Delay1;16\","
                            "\"invalid-delay\","
                            "\"test.Delay2;32\"]"
    "}";
  tc = TraceConfig(invalid_config_string);
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());
  EXPECT_FALSE(tc.IsArgumentFilterEnabled());
  EXPECT_STREQ("-excluded,DELAY(test.Delay1;16),DELAY(test.Delay2;32)",
               tc.ToCategoryFilterString().c_str());

  const char invalid_config_string_2[] =
    "{"
      "\"included_categories\":[\"category\",\"disabled-by-default-pattern\"],"
      "\"excluded_categories\":[\"category\",\"disabled-by-default-pattern\"]"
    "}";
  tc = TraceConfig(invalid_config_string_2);
  EXPECT_TRUE(tc.IsCategoryEnabled("category"));
  EXPECT_TRUE(tc.IsCategoryEnabled("disabled-by-default-pattern"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("category"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("disabled-by-default-pattern"));
}

TEST(TraceConfigTest, MergingTraceConfigs) {
  // Merge
  TraceConfig tc;
  TraceConfig tc2("included,-excluded,inc_pattern*,-exc_pattern*", "");
  tc.Merge(tc2);
  EXPECT_STREQ("{"
                 "\"enable_argument_filter\":false,"
                 "\"enable_sampling\":false,"
                 "\"enable_systrace\":false,"
                 "\"excluded_categories\":["
                   "\"*Debug\",\"*Test\",\"excluded\",\"exc_pattern*\""
                 "],"
                 "\"record_mode\":\"record-until-full\""
               "}",
               tc.ToString().c_str());

  tc = TraceConfig("DELAY(test.Delay1;16)", "");
  tc2 = TraceConfig("DELAY(test.Delay2;32)", "");
  tc.Merge(tc2);
  EXPECT_EQ(2u, tc.GetSyntheticDelayValues().size());
  EXPECT_STREQ("test.Delay1;16", tc.GetSyntheticDelayValues()[0].c_str());
  EXPECT_STREQ("test.Delay2;32", tc.GetSyntheticDelayValues()[1].c_str());
}

TEST(TraceConfigTest, IsCategoryGroupEnabled) {
  // Enabling a disabled- category does not require all categories to be traced
  // to be included.
  TraceConfig tc("disabled-by-default-cc,-excluded", "");
  EXPECT_STREQ("disabled-by-default-cc,-excluded",
               tc.ToCategoryFilterString().c_str());
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("disabled-by-default-cc"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("some_other_group"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("excluded"));

  // Enabled a disabled- category and also including makes all categories to
  // be traced require including.
  tc = TraceConfig("disabled-by-default-cc,included", "");
  EXPECT_STREQ("included,disabled-by-default-cc",
               tc.ToCategoryFilterString().c_str());
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("disabled-by-default-cc"));
  EXPECT_TRUE(tc.IsCategoryGroupEnabled("included"));
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("other_included"));

  // Excluding categories won't enable disabled-by-default ones with the
  // excluded category is also present in the group.
  tc = TraceConfig("-excluded", "");
  EXPECT_STREQ("-excluded", tc.ToCategoryFilterString().c_str());
  EXPECT_FALSE(tc.IsCategoryGroupEnabled("excluded,disabled-by-default-cc"));
}

TEST(TraceConfigTest, IsEmptyOrContainsLeadingOrTrailingWhitespace) {
  // Test that IsEmptyOrContainsLeadingOrTrailingWhitespace actually catches
  // categories that are explicitly forbidden.
  // This method is called in a DCHECK to assert that we don't have these types
  // of strings as categories.
  EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
      " bad_category "));
  EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
      " bad_category"));
  EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
      "bad_category "));
  EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
      "   bad_category"));
  EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
      "bad_category   "));
  EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
      "   bad_category   "));
  EXPECT_TRUE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
      ""));
  EXPECT_FALSE(TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
      "good_category"));
}

TEST(TraceConfigTest, SetTraceOptionValues) {
  TraceConfig tc;
  EXPECT_EQ(RECORD_UNTIL_FULL, tc.GetTraceRecordMode());
  EXPECT_FALSE(tc.IsSamplingEnabled());
  EXPECT_FALSE(tc.IsSystraceEnabled());

  tc.SetTraceRecordMode(RECORD_AS_MUCH_AS_POSSIBLE);
  EXPECT_EQ(RECORD_AS_MUCH_AS_POSSIBLE, tc.GetTraceRecordMode());

  tc.EnableSampling();
  EXPECT_TRUE(tc.IsSamplingEnabled());

  tc.EnableSystrace();
  EXPECT_TRUE(tc.IsSystraceEnabled());
}

TEST(TraceConfigTest, TraceConfigFromMemoryConfigString) {
  std::string tc_str =
      TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(200, 2000);
  TraceConfig tc(tc_str);
  EXPECT_EQ(tc_str, tc.ToString());
  EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory));
  EXPECT_EQ(2u, tc.memory_dump_config_.size());

  EXPECT_EQ(200u, tc.memory_dump_config_[0].periodic_interval_ms);
  EXPECT_EQ(MemoryDumpLevelOfDetail::LIGHT,
            tc.memory_dump_config_[0].level_of_detail);

  EXPECT_EQ(2000u, tc.memory_dump_config_[1].periodic_interval_ms);
  EXPECT_EQ(MemoryDumpLevelOfDetail::DETAILED,
            tc.memory_dump_config_[1].level_of_detail);
}

TEST(TraceConfigTest, EmptyMemoryDumpConfigTest) {
  // Empty trigger list should also be specified when converting back to string.
  TraceConfig tc(TraceConfigMemoryTestUtil::GetTraceConfig_EmptyTriggers());
  EXPECT_EQ(TraceConfigMemoryTestUtil::GetTraceConfig_EmptyTriggers(),
            tc.ToString());
  EXPECT_EQ(0u, tc.memory_dump_config_.size());
}

TEST(TraceConfigTest, LegacyStringToMemoryDumpConfig) {
  TraceConfig tc(MemoryDumpManager::kTraceCategory, "");
  EXPECT_TRUE(tc.IsCategoryGroupEnabled(MemoryDumpManager::kTraceCategory));
  EXPECT_NE(std::string::npos, tc.ToString().find("memory_dump_config"));
  EXPECT_EQ(2u, tc.memory_dump_config_.size());
}

}  // namespace trace_event
}  // namespace base


text:
package com.google.zetasketch.testing;

import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.Subject;
import com.google.common.truth.Truth;
import java.util.Iterator;
import javax.annotation.Nullable;

/**
 * A truth subject that renders iterables of integers in binary rather than in decimal form. This is
 * useful as it can be hard to see what failed in a bit twiddling method from the decimal integer
 * representation (e.g. "[791] is not equal to [919]" vs. "[0b1100010111] is not equal to
 * [0b1110010111]").
 *
 * <p>The subject also adds support for integer iterators in addition to iterables. If an iterator
 * appears as subject or comparison object, it is consumed and internally converted to an iterable.
 */
public class IntegerBitIterableSubject extends Subject {

  private static final Subject.Factory<IntegerBitIterableSubject, Iterable<Integer>> FACTORY =
      IntegerBitIterableSubject::new;

  public static IntegerBitIterableSubject assertThat(Iterable<Integer> value) {
    return Truth.assertAbout(FACTORY).that(value);
  }

  public static IntegerBitIterableSubject assertThat(Iterator<Integer> value) {
    return Truth.assertAbout(FACTORY).that(Lists.newArrayList(value));
  }

  private final Iterable<Integer> actual;

  private IntegerBitIterableSubject(FailureMetadata failureMetadata, Iterable<Integer> subject) {
    super(failureMetadata, subject);
    this.actual = subject;
  }

  @Override
  public void isEqualTo(@Nullable Object other) {
    if (other instanceof Iterable<?>) {
      internalIsEqualTo((Iterable<?>) other);
    } else if (other instanceof Iterator<?>) {
      internalIsEqualTo(Lists.newArrayList((Iterator<?>) other));
    } else {
      failWithActual("expected to be equal to", other);
    }
  }

  private void internalIsEqualTo(Iterable<?> other) {
    if (!Iterables.elementsEqual(this.actual, other)) {
      this.failWithActual("expected to be equal to", toString(other));
    }
  }

  @Override
  protected String actualCustomStringRepresentation() {
    return toString(actual);
  }

  private static String toString(Iterable<?> list) {
    StringBuilder builder = new StringBuilder("[");
    boolean first = true;
    for (Object value : list) {
      if (!first) {
        builder.append(", ");
      }
      first = false;

      if (value instanceof Integer) {
        builder.append("0b").append(Integer.toBinaryString(((Integer) value).intValue()));
      } else {
        builder.append(value);
      }
    }
    builder.append("]");
    return builder.toString();
  }
}


text:
package com.tonybeltramelli.desktop.core.classifier.binary

class LogisticRegressionBinary extends ABinaryLinearClassifier
{
  protected override def _gradient(theta: Map[String, Double], documentFeatures: Map[String, Double], isRelated: Boolean) : Map[String, Double] =
  {
    val lossChain = if(isRelated) 1 - _sigmoid(theta, documentFeatures) else -_sigmoid(theta, documentFeatures)

    val grad = _scalarMultiplication(documentFeatures, lossChain)

    _combine(grad, theta)
  }
}


text:
namespace CLICore
{
	Ground::Ground() : mpInstance(new CGround)
	{

	}
	Ground::~Ground()
	{
		if (mpInstance)
		{
			mpInstance->OnRelease();
			delete mpInstance;
			mpInstance = nullptr;
		}
	}

	void Ground::Create(CLICore::Core ^core, int nRow, int nCol, float fSize)
	{
		mpInstance->Create(core->GetDeveice(), nRow, nCol, fSize);
	}

	void Ground::Render()
	{
		mpInstance->OnRender();
	}
}


text:
package org.apache.geronimo.gshell.wisdom.plugin;

import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileType;
import org.apache.geronimo.gshell.application.plugin.Plugin;
import org.apache.geronimo.gshell.event.Event;
import org.apache.geronimo.gshell.event.EventListener;
import org.apache.geronimo.gshell.event.EventManager;
import org.apache.geronimo.gshell.vfs.provider.meta.MetaFileNameParser;
import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;

/**
 * Handles mapping of plugins under <tt>meta:/plugins</tt>.
 *
 * @version $Rev$ $Date$
 */
public class PluginMetaMapper
    implements EventListener
{
    private final EventManager eventManager;

    private final MetaDataRegistry metaRegistry;

    private final MetaFileNameParser nameParser = new MetaFileNameParser();

    public PluginMetaMapper(final EventManager eventManager, final MetaDataRegistry metaRegistry) {
        assert eventManager != null;
        this.eventManager = eventManager;

        assert metaRegistry != null;
        this.metaRegistry = metaRegistry;
    }

    // @PostConstruct
    public synchronized void init() {
        // TODO: add any existing plugins which may have been configured before we loaded

        eventManager.addListener(this);
    }

    public synchronized void onEvent(final Event event) throws Exception {
        assert event != null;

        if (event instanceof PluginLoadedEvent) {
            PluginLoadedEvent targetEvent = (PluginLoadedEvent)event;
            add(targetEvent.getPlugin());
        }

        // TODO: Handle removing meta:/plugins/<name>
    }

    private FileName createName(final String name) throws FileSystemException {
        assert name != null;
        return nameParser.parseUri("/plugins/" + name);
    }

    private void add(final Plugin plugin) throws Exception {
        assert plugin != null;

        FileName fileName = createName(plugin.getName());
        MetaData data = new MetaData(fileName, FileType.FILE);
        data.addAttribute("PLUGIN", plugin);

        metaRegistry.registerData(fileName, data);
    }

    private void remove(final String name) throws Exception {
        assert name != null;

        FileName fileName = createName(name);

        metaRegistry.removeData(fileName);
    }
}


text:
import { didLogin } from "../auth/actions";
import { Thunk } from "../redux/interfaces";
import { Session } from "../session";

/** Lets Redux know that the app is ready to bootstrap. */
export function ready(): Thunk {
  return (dispatch, getState) => {
    let state = Session.get() || getState().auth;
    if (state) { didLogin(state, dispatch); }
  };
}


text:
. ../scripts/envsetup.sh

$RUN_DEBUG$BIN_HOME/dmzAppQt -f config/resource.xml config/runtime.xml config/common.xml config/net.xml  config/mcp.xml config/js.xml $*


text:
class AddRestaurantTable < ActiveRecord::Migration
  def change
    create_table :restaurants do |t|
      t.string :name, null: false, unique: true
      t.integer :owner_id, null: false
      t.integer :manager_id, null: false
      t.timestamps null: false
    end
  end
end


text:
@{

# Script module or binary module file associated with this manifest.
# RootModule = ''

# Version number of this module.
ModuleVersion = '4.1.5'

# Supported PSEditions
# CompatiblePSEditions = @()

# ID used to uniquely identify this module
GUID = 'a8f00f40-1c1a-49b5-9db3-24076b75c3cf'

# Author of this module
Author = 'Microsoft Corporation'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = 'Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
Description = 'Microsoft Azure PowerShell - Batch service cmdlets for Azure Resource Manager'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
DotNetFrameworkVersion = '4.5.2'

# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
CLRVersion = '4.0'

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.8.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Batch.dll',
               '.\Microsoft.Azure.Management.Batch.dll',
               '.\Microsoft.Data.Edm.dll', '.\Microsoft.Data.OData.dll',
               '.\Microsoft.Data.Services.Client.dll',
               '.\Microsoft.WindowsAzure.Storage.dll', '.\System.Spatial.dll'

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = '.\Microsoft.Azure.Commands.Batch.format.ps1xml'

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @('.\Microsoft.Azure.Commands.Batch.dll')

# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @()

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = 'Remove-AzureRmBatchAccount', 'Get-AzureRmBatchAccount',
               'Get-AzureRmBatchAccountKeys', 'New-AzureRmBatchAccount',
               'New-AzureRmBatchAccountKey', 'Set-AzureRmBatchAccount',
               'New-AzureRmBatchApplicationPackage', 'Get-AzureBatchJobStatistics',
               'Remove-AzureRmBatchApplication',
               'Remove-AzureRmBatchApplicationPackage',
               'Get-AzureRmBatchApplicationPackage', 'Get-AzureRmBatchApplication',
               'Set-AzureRmBatchApplication', 'New-AzureRmBatchApplication',
               'Get-AzureBatchCertificate', 'Remove-AzureBatchCertificate',
               'New-AzureBatchCertificate', 'Stop-AzureBatchCertificateDeletion',
               'Disable-AzureBatchComputeNodeScheduling',
               'Enable-AzureBatchComputeNodeScheduling',
               'Get-AzureBatchRemoteLoginSettings', 'Remove-AzureBatchComputeNode',
               'Reset-AzureBatchComputeNode', 'Restart-AzureBatchComputeNode',
               'Set-AzureBatchComputeNodeUser', 'Get-AzureBatchNodeFile',
               'Get-AzureBatchNodeFileContent',
               'Get-AzureBatchRemoteDesktopProtocolFile',
               'Remove-AzureBatchNodeFile', 'Disable-AzureBatchJobSchedule',
               'Enable-AzureBatchJobSchedule', 'Set-AzureBatchJobSchedule',
               'Stop-AzureBatchJobSchedule', 'Disable-AzureBatchJob',
               'Enable-AzureBatchJob', 'New-AzureBatchJob', 'Remove-AzureBatchJob',
               'Set-AzureBatchJob', 'Stop-AzureBatchJob', 'Get-AzureBatchJob',
               'Get-AzureBatchJobPreparationAndReleaseTaskStatus',
               'Disable-AzureBatchAutoScale', 'Enable-AzureBatchAutoScale',
               'Get-AzureBatchPoolStatistics', 'Get-AzureBatchPoolUsageMetrics',
               'Get-AzureBatchPool', 'Get-AzureBatchNodeAgentSku',
               'New-AzureBatchPool', 'Remove-AzureBatchPool', 'Set-AzureBatchPool',
               'Set-AzureBatchPoolOSVersion', 'Start-AzureBatchPoolResize',
               'Stop-AzureBatchPoolResize', 'Test-AzureBatchAutoScale',
               'Get-AzureRmBatchLocationQuotas', 'Get-AzureBatchSubtask',
               'Get-AzureBatchTask', 'New-AzureBatchTask', 'Remove-AzureBatchTask',
               'New-AzureBatchComputeNodeUser', 'Remove-AzureBatchComputeNodeUser',
               'Enable-AzureBatchTask', 'Set-AzureBatchTask', 'Stop-AzureBatchTask',
               'Get-AzureBatchComputeNode', 'Get-AzureBatchJobSchedule',
               'New-AzureBatchJobSchedule', 'Remove-AzureBatchJobSchedule',
               'Get-AzureBatchTaskCounts', 'Get-AzureBatchPoolNodeCounts',
               'Start-AzureBatchComputeNodeServiceLogUpload'

# Variables to export from this module
# VariablesToExport = @()

# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = 'Reactivate-AzureBatchTask', 'Get-AzureRmBatchSubscriptionQuotas'

# DSC resources to export from this module
# DscResourcesToExport = @()

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

    PSData = @{

        # Tags applied to this module. These help with module discovery in online galleries.
        Tags = 'Azure','ResourceManager','ARM','Batch'

        # A URL to the license for this module.
        LicenseUri = 'https://aka.ms/azps-license'

        # A URL to the main website for this project.
        ProjectUri = 'https://github.com/Azure/azure-powershell'

        # A URL to an icon representing this module.
        # IconUri = ''

        # ReleaseNotes of this module
        ReleaseNotes = '* Fixed issue with default resource groups not being set.
* Updated common runtime assemblies'

        # Prerelease string of this module
        # Prerelease = ''

        # Flag to indicate whether the module requires explicit user acceptance for install/update
        # RequireLicenseAcceptance = $false

        # External dependent modules of this module
        # ExternalModuleDependencies = @()

    } # End of PSData hashtable

 } # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}


text:
FROM node:latest

RUN mkdir /bot && cd /bot

ADD . /bot

EXPOSE 9999

WORKDIR /bot

CMD ["bin/hubot", "--adapter", "slack"]


text:
package com.julianpeeters.avro.annotations
package record
package schemagen

import scala.reflect.macros.blackbox.Context

import collection.JavaConversions._
import java.util.{Arrays => JArrays}
import org.apache.avro.Schema
import org.apache.avro.Schema.Field
import org.apache.avro.Schema.{Type => AvroType}
import org.apache.avro.util.Utf8

abstract class FieldSchemaGenerator {

  //necessary for type refinement when trying to pass dependent types
  val context: Context

  import context.universe._
  import Flag._

  //map is from https://github.com/radlab/avro-scala-compiler-plugin/blob/master/src/main/scala/plugin/SchemaGen.scala
  val primitiveClasses: Map[Type, Schema] = Map(
    /** Primitives in the Scala and Avro sense */
    typeOf[Int]     -> Schema.create(AvroType.INT),
    typeOf[Float]   -> Schema.create(AvroType.FLOAT),
    typeOf[Long]    -> Schema.create(AvroType.LONG),
    typeOf[Double]  -> Schema.create(AvroType.DOUBLE),
    typeOf[Boolean] -> Schema.create(AvroType.BOOLEAN),
    typeOf[String]  -> Schema.create(AvroType.STRING),
    typeOf[Null]    -> Schema.create(AvroType.NULL),
    /** Primitives in the Avro sense */
    typeOf[java.nio.ByteBuffer] -> Schema.create(AvroType.BYTES),
    typeOf[Utf8]    -> Schema.create(AvroType.STRING)
  )

  def createSchema(tpe: context.universe.Type) : Schema = {
    tpe match {
      case x if (primitiveClasses.contains(x)) => primitiveClasses(x)
      case x @ TypeRef(pre, symbol, args) if (x <:< typeOf[List[Any]] && args.length == 1)  => {
        Schema.createArray(createSchema(args.head))
      }
      case x @ TypeRef(pre, symbol, args) if (x <:< typeOf[Option[Any]] && args.length == 1) => {
        if (args.head <:< typeOf[Option[Any]]) {
          throw new UnsupportedOperationException("Implementation limitation: Cannot immediately nest Option types")
        }
        else Schema.createUnion(JArrays.asList(Array(createSchema(typeOf[Null]), createSchema(args.head)):_*))
      }
      case x @ TypeRef(pre, symbol, args) if (x <:< typeOf[Map[String, Any]] && args.length == 2)  => {
        Schema.createMap(createSchema(args(1)))
      }
      case x @ TypeRef(pre, symbol, args) if (x <:< typeOf[Product with Serializable] ) => {
        // if a case class (a nested record) is found, reuse the schema that was made and stored when its macro was expanded.
        // unsuccessful alternatives: reflectively getting the schema from its companion (can't get a tree from a Symbol),
        // or regenerating the schema (no way to get default param values from outside the current at compile time).
        SchemaStore.schemas(x.toString)
      }
      case x => throw new UnsupportedOperationException("Could not generate schema. Cannot support yet: " + x )
    }
  }

  def toAvroField(namespace: String, nme: TermName, tpe: Type, dv: Tree) = {
    val toJsonMatcher = new {val c: context.type = context; val ns: String = namespace} with ToJsonMatcher

    new Field(
      nme.toString.trim,
      createSchema(tpe),
      "Auto-Generated Field",
      toJsonMatcher.toJsonNode(dv)
    )
  }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".MainActivity">

    <group android:id="@+id/grouptWhatIf">
        <item android:id="@+id/action_unread"
            android:title="@string/action_unread"
            app:showAsAction="never" />

        <item android:id="@+id/action_all_read"
            android:title="@string/action_all_read"
            app:showAsAction="never" />

        <item android:id="@+id/action_hide_read"
            android:title="@string/action_hide_read_articles"
            android:checkable="true"
            app:showAsAction="never" />

    </group>
</menu>


text:
#ifndef DOKAN_H_
#define DOKAN_H_

/** Do not include NTSTATUS. Fix  duplicate preprocessor definitions */
#define WIN32_NO_STATUS
#include <windows.h>
#undef WIN32_NO_STATUS
#include <ntstatus.h>

#include "fileinfo.h"
#include "public.h"

#ifdef _EXPORTING
/** Export dokan API see also dokan.def for export */
#define DOKANAPI __stdcall
#else
/** Import dokan API */
#define DOKANAPI __declspec(dllimport) __stdcall
#endif

/** Change calling convention to standard call */
#define DOKAN_CALLBACK __stdcall

#ifdef __cplusplus
extern "C" {
#endif

/** @file */

/**
 * \defgroup Dokan Dokan
 * \brief Dokan Library const and methods
 */
/** @{ */

/** The current Dokan version (ver 1.2.0). \ref DOKAN_OPTIONS.Version */
#define DOKAN_VERSION 120
/** Minimum Dokan version (ver 1.1.0) accepted. */
#define DOKAN_MINIMUM_COMPATIBLE_VERSION 110
/** Maximum number of dokan instances.*/
#define DOKAN_MAX_INSTANCES 32
/** Driver file name including the DOKAN_MAJOR_API_VERSION */
#define DOKAN_DRIVER_NAME L"dokan" DOKAN_MAJOR_API_VERSION L".sys"
/** Network provider name including the DOKAN_MAJOR_API_VERSION */
#define DOKAN_NP_NAME L"Dokan" DOKAN_MAJOR_API_VERSION

/** @} */

/**
 * \defgroup DOKAN_OPTION DOKAN_OPTION
 * \brief All DOKAN_OPTION flags used in DOKAN_OPTIONS.Options
 * \see DOKAN_FILE_INFO
 */
/** @{ */

/** Enable ouput debug message */
#define DOKAN_OPTION_DEBUG 1
/** Enable ouput debug message to stderr */
#define DOKAN_OPTION_STDERR 2
/** Use alternate stream */
#define DOKAN_OPTION_ALT_STREAM 4
/** Enable mount drive as write-protected */
#define DOKAN_OPTION_WRITE_PROTECT 8
/** Use network drive - Dokan network provider needs to be installed */
#define DOKAN_OPTION_NETWORK 16
/** Use removable drive */
#define DOKAN_OPTION_REMOVABLE 32
/** Use mount manager */
#define DOKAN_OPTION_MOUNT_MANAGER 64
/** Mount the drive on current session only */
#define DOKAN_OPTION_CURRENT_SESSION 128
/** Enable Lockfile/Unlockfile operations. Otherwise Dokan will take care of it */
#define DOKAN_OPTION_FILELOCK_USER_MODE 256

/** @} */

/**
 * \struct DOKAN_OPTIONS
 * \brief Dokan mount options used to describe Dokan device behavior.
 * \see DokanMain
 */
typedef struct _DOKAN_OPTIONS {
  /** Version of the Dokan features requested (version "123" is equal to Dokan version 1.2.3). */
  USHORT Version;
  /** Number of threads to be used internally by Dokan library. More threads will handle more events at the same time. */
  USHORT ThreadCount;
  /** Features enabled for the mount. See \ref DOKAN_OPTION. */
  ULONG Options;
  /** FileSystem can store anything here. */
  ULONG64 GlobalContext;
  /** Mount point. Can be "M:\" (drive letter) or "C:\mount\dokan" (path in NTFS). */
  LPCWSTR MountPoint;
  /**
  * UNC Name for the Network Redirector
  * \see Support for UNC Naming
  */
  LPCWSTR UNCName;
  /** Max timeout in milliseconds of each request before Dokan gives up. */
  ULONG Timeout;
  /** Allocation Unit Size of the volume. This will affect the file size. */
  ULONG AllocationUnitSize;
  /** Sector Size of the volume. This will affect the file size. */
  ULONG SectorSize;
} DOKAN_OPTIONS, *PDOKAN_OPTIONS;

/**
 * \struct DOKAN_FILE_INFO
 * \brief Dokan file information on the current operation.
 */
typedef struct _DOKAN_FILE_INFO {
  /**
   * Context that can be used to carry information between operations.
   * The context can carry whatever type like \c HANDLE, struct, int,
   * internal reference that will help the implementation understand the request context of the event.
   */
  ULONG64 Context;
  /** Reserved. Used internally by Dokan library. Never modify. */
  ULONG64 DokanContext;
  /** A pointer to DOKAN_OPTIONS which was passed to DokanMain. */
  PDOKAN_OPTIONS DokanOptions;
  /**
   * Process ID for the thread that originally requested a given I/O operation.
   */
  ULONG ProcessId;
  /**
   * Requesting a directory file.
   * Must be set in \ref DOKAN_OPERATIONS.ZwCreateFile if the file appears to be a folder.
   */
  UCHAR IsDirectory;
  /** Flag if the file has to be deleted during DOKAN_OPERATIONS. Cleanup event. */
  UCHAR DeleteOnClose;
  /** Read or write is paging IO. */
  UCHAR PagingIo;
  /** Read or write is synchronous IO. */
  UCHAR SynchronousIo;
  /** Read or write directly from data source without cache */
  UCHAR Nocache;
  /**  If \c TRUE, write to the current end of file instead of using the Offset parameter. */
  UCHAR WriteToEndOfFile;
} DOKAN_FILE_INFO, *PDOKAN_FILE_INFO;

/**
 * \brief FillFindData Used to add an entry in FindFiles operation
 * \return 1 if buffer is full, otherwise 0 (currently it never returns 1)
 */
typedef int(WINAPI *PFillFindData)(PWIN32_FIND_DATAW, PDOKAN_FILE_INFO);

/**
 * \brief FillFindStreamData Used to add an entry in FindStreams
 * \return 1 if buffer is full, otherwise 0 (currently it never returns 1)
 */
typedef int(WINAPI *PFillFindStreamData)(PWIN32_FIND_STREAM_DATA,
                                         PDOKAN_FILE_INFO);

// clang-format off

/**
 * \struct DOKAN_OPERATIONS
 * \brief Dokan API callbacks interface
 *
 * DOKAN_OPERATIONS is a struct of callbacks that describe all Dokan API operations
 * that will be called when Windows access to the filesystem.
 *
 * If an error occurs, return NTSTATUS (https://support.microsoft.com/en-us/kb/113996).
 * Win32 Error can be converted to \c NTSTATUS with \ref DokanNtStatusFromWin32
 *
 * All callbacks can be set to \c NULL or return \c STATUS_NOT_IMPLEMENTED
 * if supporting one of them is not desired. Be aware that returning such values to important callbacks
 * such as DOKAN_OPERATIONS.ZwCreateFile / DOKAN_OPERATIONS.ReadFile / ... would make the filesystem not work or become unstable.
 */
typedef struct _DOKAN_OPERATIONS {
  /**
  * \brief CreateFile Dokan API callback
  *
  * CreateFile is called each time a request is made on a file system object.
  *
  * In case \c OPEN_ALWAYS & \c CREATE_ALWAYS are successfully opening an
  * existing file, \c STATUS_OBJECT_NAME_COLLISION should be returned instead of \c STATUS_SUCCESS .
  * This will inform Dokan that the file has been opened and not created during the request.
  *
  * If the file is a directory, CreateFile is also called.
  * In this case, CreateFile should return \c STATUS_SUCCESS when that directory
  * can be opened and DOKAN_FILE_INFO.IsDirectory has to be set to \c TRUE.
  * On the other hand, if DOKAN_FILE_INFO.IsDirectory is set to \c TRUE
  * but the path targets a file, \c STATUS_NOT_A_DIRECTORY must be returned.
  *
  * DOKAN_FILE_INFO.Context can be used to store Data (like \c HANDLE)
  * that can be retrieved in all other requests related to the Context.
  * To avoid memory leak, Context needs to be released in DOKAN_OPERATIONS.Cleanup.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param SecurityContext SecurityContext, see https://msdn.microsoft.com/en-us/library/windows/hardware/ff550613(v=vs.85).aspx
  * \param DesiredAccess Specifies an ACCESS_MASK value that determines the requested access to the object.
  * \param FileAttributes Specifies one or more FILE_ATTRIBUTE_XXX flags, which represent the file attributes to set if a file is created or overwritten.
  * \param ShareAccess Type of share access, which is specified as zero or any combination of FILE_SHARE_* flags.
  * \param CreateDisposition Specifies the action to perform if the file does or does not exist.
  * \param CreateOptions Specifies the options to apply when the driver creates or opens the file.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see See ZwCreateFile for more information about the parameters of this callback (MSDN).
  * \see DokanMapKernelToUserCreateFileFlags
  */
  NTSTATUS(DOKAN_CALLBACK *ZwCreateFile)(LPCWSTR FileName,
      PDOKAN_IO_SECURITY_CONTEXT SecurityContext,
      ACCESS_MASK DesiredAccess,
      ULONG FileAttributes,
      ULONG ShareAccess,
      ULONG CreateDisposition,
      ULONG CreateOptions,
      PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief Cleanup Dokan API callback
  *
  * Cleanup request before \ref CloseFile is called.
  *
  * When DOKAN_FILE_INFO.DeleteOnClose is \c TRUE, the file in Cleanup must be deleted.
  * See DeleteFile documentation for explanation.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param DokanFileInfo Information about the file or directory.
  * \see DeleteFile
  * \see DeleteDirectory
  */
  void(DOKAN_CALLBACK *Cleanup)(LPCWSTR FileName,
                                PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief CloseFile Dokan API callback
  *
  * Clean remaining Context
  *
  * CloseFile is called at the end of the life of the context.
  * Anything remaining in \ref DOKAN_FILE_INFO.Context must be cleared before returning.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param DokanFileInfo Information about the file or directory.
  */
  void(DOKAN_CALLBACK *CloseFile)(LPCWSTR FileName,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief ReadFile Dokan API callback
  *
  * ReadFile callback on the file previously opened in DOKAN_OPERATIONS.ZwCreateFile.
  * It can be called by different threads at the same time, so the read/context has to be thread safe.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param Buffer Read buffer that has to be filled with the read result.
  * \param BufferLength Buffer length and read size to continue with.
  * \param ReadLength Total data size that has been read.
  * \param Offset Offset from where the read has to be continued.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see WriteFile
  */
  NTSTATUS(DOKAN_CALLBACK *ReadFile)(LPCWSTR FileName,
    LPVOID Buffer,
    DWORD BufferLength,
    LPDWORD ReadLength,
    LONGLONG Offset,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief WriteFile Dokan API callback
  *
  * WriteFile callback on the file previously opened in DOKAN_OPERATIONS.ZwCreateFile
  * It can be called by different threads at the same time, sp the write/context has to be thread safe.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param Buffer Data that has to be written.
  * \param NumberOfBytesToWrite Buffer length and write size to continue with.
  * \param NumberOfBytesWritten Total number of bytes that have been written.
  * \param Offset Offset from where the write has to be continued.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see ReadFile
  */
  NTSTATUS(DOKAN_CALLBACK *WriteFile)(LPCWSTR FileName,
    LPCVOID Buffer,
    DWORD NumberOfBytesToWrite,
    LPDWORD NumberOfBytesWritten,
    LONGLONG Offset,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief FlushFileBuffers Dokan API callback
  *
  * Clears buffers for this context and causes any buffered data to be written to the file.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  */
  NTSTATUS(DOKAN_CALLBACK *FlushFileBuffers)(LPCWSTR FileName,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief GetFileInformation Dokan API callback
  *
  * Get specific information on a file.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param Buffer BY_HANDLE_FILE_INFORMATION struct to fill.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  */
  NTSTATUS(DOKAN_CALLBACK *GetFileInformation)(LPCWSTR FileName,
    LPBY_HANDLE_FILE_INFORMATION Buffer,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief FindFiles Dokan API callback
  *
  * List all files in the requested path
  * \ref DOKAN_OPERATIONS.FindFilesWithPattern is checked first. If it is not implemented or
  * returns \c STATUS_NOT_IMPLEMENTED, then FindFiles is called, if implemented.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param FillFindData Callback that has to be called with PWIN32_FIND_DATAW that contain file information.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see FindFilesWithPattern
  */
  NTSTATUS(DOKAN_CALLBACK *FindFiles)(LPCWSTR FileName,
    PFillFindData FillFindData,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief FindFilesWithPattern Dokan API callback
  *
  * Same as \ref DOKAN_OPERATIONS.FindFiles but with a search pattern.
  *
  * \param PathName Path requested by the Kernel on the FileSystem.
  * \param SearchPattern Search pattern.
  * \param FillFindData Callback that has to be called with PWIN32_FIND_DATAW that contains file information.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see FindFiles
  */
  NTSTATUS(DOKAN_CALLBACK *FindFilesWithPattern)(LPCWSTR PathName,
    LPCWSTR SearchPattern,
    PFillFindData FillFindData,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief SetFileAttributes Dokan API callback
  *
  * Set file attributes on a specific file
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param FileAttributes FileAttributes to set on file.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  */
  NTSTATUS(DOKAN_CALLBACK *SetFileAttributes)(LPCWSTR FileName,
    DWORD FileAttributes,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief SetFileTime Dokan API callback
  *
  * Set file attributes on a specific file
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param CreationTime Creation FILETIME.
  * \param LastAccessTime LastAccess FILETIME.
  * \param LastWriteTime LastWrite FILETIME.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  */
  NTSTATUS(DOKAN_CALLBACK *SetFileTime)(LPCWSTR FileName,
    CONST FILETIME *CreationTime,
    CONST FILETIME *LastAccessTime,
    CONST FILETIME *LastWriteTime,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief DeleteFile Dokan API callback
  *
  * Check if it is possible to delete a file.
  *
  * DeleteFile will also be called with DOKAN_FILE_INFO.DeleteOnClose set to \c FALSE
  * to notify the driver when the file is no longer requested to be deleted.
  *
  * The file in DeleteFile should not be deleted, but instead the file
  * must be checked as to whether or not it can be deleted,
  * and \c STATUS_SUCCESS should be returned (when it can be deleted) or
  * appropriate error codes, such as \c STATUS_ACCESS_DENIED or
  * \c STATUS_OBJECT_NAME_NOT_FOUND, should be returned.
  *
  * When \c STATUS_SUCCESS is returned, a Cleanup call is received afterwards with
  * DOKAN_FILE_INFO.DeleteOnClose set to \c TRUE. Only then must the closing file
  * be deleted.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see DeleteDirectory
  * \see Cleanup
  */
  NTSTATUS(DOKAN_CALLBACK *DeleteFile)(LPCWSTR FileName,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief DeleteDirectory Dokan API callback
  *
  * Check if it is possible to delete a directory.
  *
  * DeleteDirectory will also be called with DOKAN_FILE_INFO.DeleteOnClose set to \c FALSE
  * to notify the driver when the file is no longer requested to be deleted.
  *
  * The Directory in DeleteDirectory should not be deleted, but instead
  * must be checked as to whether or not it can be deleted,
  * and \c STATUS_SUCCESS should be returned (when it can be deleted) or
  * appropriate error codes, such as \c STATUS_ACCESS_DENIED,
  * \c STATUS_OBJECT_PATH_NOT_FOUND, or \c STATUS_DIRECTORY_NOT_EMPTY, should
  * be returned.
  *
  * When \c STATUS_SUCCESS is returned, a Cleanup call is received afterwards with
  * DOKAN_FILE_INFO.DeleteOnClose set to \c TRUE. Only then must the closing file
  * be deleted.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or \c NTSTATUS appropriate to the request result.
  * \ref DeleteFile
  * \ref Cleanup
  */
  NTSTATUS(DOKAN_CALLBACK *DeleteDirectory)(LPCWSTR FileName,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief MoveFile Dokan API callback
  *
  * Move a file or directory to a new destination
  *
  * \param FileName Path for the file to be moved.
  * \param NewFileName Path for the new location of the file.
  * \param ReplaceIfExisting If destination already exists, can it be replaced?
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  */
  NTSTATUS(DOKAN_CALLBACK *MoveFile)(LPCWSTR FileName,
    LPCWSTR NewFileName,
    BOOL ReplaceIfExisting,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief SetEndOfFile Dokan API callback
  *
  * SetEndOfFile is used to truncate or extend a file (physical file size).
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param ByteOffset File length to set.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  */
  NTSTATUS(DOKAN_CALLBACK *SetEndOfFile)(LPCWSTR FileName,
    LONGLONG ByteOffset,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief SetAllocationSize Dokan API callback
  *
  * SetAllocationSize is used to truncate or extend a file.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param AllocSize File length to set.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  */
  NTSTATUS(DOKAN_CALLBACK *SetAllocationSize)(LPCWSTR FileName,
    LONGLONG AllocSize,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief LockFile Dokan API callback
  *
  * Lock file at a specific offset and data length.
  * This is only used if \ref DOKAN_OPTION_FILELOCK_USER_MODE is enabled.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param ByteOffset Offset from where the lock has to be continued.
  * \param Length Data length to lock.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see UnlockFile
  */
  NTSTATUS(DOKAN_CALLBACK *LockFile)(LPCWSTR FileName,
    LONGLONG ByteOffset,
    LONGLONG Length,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief UnlockFile Dokan API callback
  *
  * Unlock file at a specific offset and data length.
  * This is only used if \ref DOKAN_OPTION_FILELOCK_USER_MODE is enabled.
  *
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param ByteOffset Offset from where the lock has to be continued.
  * \param Length Data length to lock.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see LockFile
  */
  NTSTATUS(DOKAN_CALLBACK *UnlockFile)(LPCWSTR FileName,
    LONGLONG ByteOffset,
    LONGLONG Length,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief GetDiskFreeSpace Dokan API callback
  *
  * Retrieves information about the amount of space that is available on a disk volume.
  * It consits of the total amount of space, the total amount of free space, and
  * the total amount of free space available to the user that is associated with the calling thread.
  *
  * Neither GetDiskFreeSpace nor \ref GetVolumeInformation
  * save the  DOKAN_FILE_INFO.Context.
  * Before these methods are called, \ref ZwCreateFile may not be called.
  * (ditto \ref CloseFile and \ref Cleanup)
  *
  * \param FreeBytesAvailable Amount of available space.
  * \param TotalNumberOfBytes Total size of storage space
  * \param TotalNumberOfFreeBytes Amount of free space
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or \c NTSTATUS appropriate to the request result.
  * \see  GetDiskFreeSpaceEx function (MSDN)
  * \see GetVolumeInformation
  */
  NTSTATUS(DOKAN_CALLBACK *GetDiskFreeSpace)(PULONGLONG FreeBytesAvailable,
    PULONGLONG TotalNumberOfBytes,
    PULONGLONG TotalNumberOfFreeBytes,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief GetVolumeInformation Dokan API callback
  *
  * Retrieves information about the file system and volume associated with the specified root directory.
  *
  * Neither GetVolumeInformation nor GetDiskFreeSpace
  * save the \ref DOKAN_FILE_INFO#Context.
  * Before these methods are called, \ref ZwCreateFile may not be called.
  * (ditto \ref CloseFile and \ref Cleanup)
  *
  * FileSystemName could be anything up to 10 characters.
  * But Windows check few feature availability based on file system name.
  * For this, it is recommended to set NTFS or FAT here.
  *
  * \c FILE_READ_ONLY_VOLUME is automatically added to the
  * FileSystemFlags if \ref DOKAN_OPTION_WRITE_PROTECT was
  * specified in DOKAN_OPTIONS when the volume was mounted.
  *
  * \param VolumeNameBuffer A pointer to a buffer that receives the name of a specified volume.
  * \param VolumeNameSize The length of a volume name buffer.
  * \param VolumeSerialNumber A pointer to a variable that receives the volume serial number.
  * \param MaximumComponentLength A pointer to a variable that receives the maximum length.
  * \param FileSystemFlags A pointer to a variable that receives flags associated with the specified file system.
  * \param FileSystemNameBuffer A pointer to a buffer that receives the name of the file system.
  * \param FileSystemNameSize The length of the file system name buffer.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see  GetVolumeInformation function (MSDN)
  * \see GetDiskFreeSpace
  */
  NTSTATUS(DOKAN_CALLBACK *GetVolumeInformation)(LPWSTR VolumeNameBuffer,
    DWORD VolumeNameSize,
    LPDWORD VolumeSerialNumber,
    LPDWORD MaximumComponentLength,
    LPDWORD FileSystemFlags,
    LPWSTR FileSystemNameBuffer,
    DWORD FileSystemNameSize,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief Mounted Dokan API callback
  *
  * Called when Dokan successfully mounts the volume.
  *
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see Unmounted
  */
  NTSTATUS(DOKAN_CALLBACK *Mounted)(PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief Unmounted Dokan API callback
  *
  * Called when Dokan is unmounting the volume.
  *
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or \c NTSTATUS appropriate to the request result.
  * \see Unmounted
  */
  NTSTATUS(DOKAN_CALLBACK *Unmounted)(PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief GetFileSecurity Dokan API callback
  *
  * Get specified information about the security of a file or directory.
  *
  * Return \c STATUS_NOT_IMPLEMENTED to let dokan library build a sddl of the current process user with authenticate user rights for context menu.
  * Return \c STATUS_BUFFER_OVERFLOW if buffer size is too small.
  *
  * \since Supported since version 0.6.0. The version must be specified in \ref DOKAN_OPTIONS.Version.
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param SecurityInformation A SECURITY_INFORMATION value that identifies the security information being requested.
  * \param SecurityDescriptor A pointer to a buffer that receives a copy of the security descriptor of the requested file.
  * \param BufferLength Specifies the size, in bytes, of the buffer.
  * \param LengthNeeded A pointer to the variable that receives the number of bytes necessary to store the complete security descriptor.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see SetFileSecurity
  * \see GetFileSecurity function (MSDN)
  */
  NTSTATUS(DOKAN_CALLBACK *GetFileSecurity)(LPCWSTR FileName,
    PSECURITY_INFORMATION SecurityInformation,
    PSECURITY_DESCRIPTOR SecurityDescriptor,
    ULONG BufferLength,
    PULONG LengthNeeded,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief SetFileSecurity Dokan API callback
  *
  * Sets the security of a file or directory object.
  *
  * \since Supported since version 0.6.0. The version must be specified in \ref DOKAN_OPTIONS.Version.
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param SecurityInformation Structure that identifies the contents of the security descriptor pointed by \a SecurityDescriptor param.
  * \param SecurityDescriptor A pointer to a SECURITY_DESCRIPTOR structure.
  * \param BufferLength Specifies the size, in bytes, of the buffer.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  * \see GetFileSecurity
  * \see SetFileSecurity function (MSDN)
  */
  NTSTATUS(DOKAN_CALLBACK *SetFileSecurity)(LPCWSTR FileName,
    PSECURITY_INFORMATION SecurityInformation,
    PSECURITY_DESCRIPTOR SecurityDescriptor,
    ULONG BufferLength,
    PDOKAN_FILE_INFO DokanFileInfo);

  /**
  * \brief FindStreams Dokan API callback
  *
  * Retrieve all NTFS Streams informations on the file.
  * This is only called if \ref DOKAN_OPTION_ALT_STREAM is enabled.
  *
  * \since Supported since version 0.8.0. The version must be specified in \ref DOKAN_OPTIONS.Version.
  * \param FileName File path requested by the Kernel on the FileSystem.
  * \param FillFindStreamData Callback that has to be called with PWIN32_FIND_STREAM_DATA that contain stream information.
  * \param DokanFileInfo Information about the file or directory.
  * \return \c STATUS_SUCCESS on success or NTSTATUS appropriate to the request result.
  */
  NTSTATUS(DOKAN_CALLBACK *FindStreams)(LPCWSTR FileName,
    PFillFindStreamData FillFindStreamData,
    PDOKAN_FILE_INFO DokanFileInfo);

} DOKAN_OPERATIONS, *PDOKAN_OPERATIONS;

// clang-format on

/**
 * \defgroup DokanMainResult DokanMainResult
 * \brief \ref DokanMain returns error codes
 */
/** @{ */

/** Dokan mount succeed. */
#define DOKAN_SUCCESS 0
/** Dokan mount error. */
#define DOKAN_ERROR -1
/** Dokan mount failed - Bad drive letter. */
#define DOKAN_DRIVE_LETTER_ERROR -2
/** Dokan mount failed - Can't install driver.  */
#define DOKAN_DRIVER_INSTALL_ERROR -3
/** Dokan mount failed - Driver answer that something is wrong. */
#define DOKAN_START_ERROR -4
/**
 * Dokan mount failed.
 * Can't assign a drive letter or mount point.
 * Probably already used by another volume.
 */
#define DOKAN_MOUNT_ERROR -5
/**
 * Dokan mount failed.
 * Mount point is invalid.
 */
#define DOKAN_MOUNT_POINT_ERROR -6
/**
 * Dokan mount failed.
 * Requested an incompatible version.
 */
#define DOKAN_VERSION_ERROR -7

/** @} */

/**
 * \defgroup Dokan Dokan
 */
/** @{ */

/**
 * \brief Mount a new Dokan Volume.
 *
 * This function block until the device is unmounted.
 * If the mount fails, it will directly return a \ref DokanMainResult error.
 *
 * \param DokanOptions a \ref DOKAN_OPTIONS that describe the mount.
 * \param DokanOperations Instance of \ref DOKAN_OPERATIONS that will be called for each request made by the kernel.
 * \return \ref DokanMainResult status.
 */
int DOKANAPI DokanMain(PDOKAN_OPTIONS DokanOptions,
                       PDOKAN_OPERATIONS DokanOperations);

/**
 * \brief Unmount a Dokan device from a driver letter.
 *
 * \param DriveLetter Dokan driver letter to unmount.
 * \return \c TRUE if device was unmounted or False in case of failure or device not found.
 */
BOOL DOKANAPI DokanUnmount(WCHAR DriveLetter);

/**
 * \brief Unmount a Dokan device from a mount point
 *
 * \param MountPoint Mount point to unmount ("Z", "Z:", "Z:\", "Z:\MyMountPoint").
 * \return \c TRUE if device was unmounted or False in case of failure or device not found.
 */
BOOL DOKANAPI DokanRemoveMountPoint(LPCWSTR MountPoint);

/**
 * \brief Unmount a Dokan device from a mount point
 *
 * Same as \ref DokanRemoveMountPoint
 * If Safe is \c TRUE, it will broadcast to all desktops and Shells
 * Safe should not be used during DLL_PROCESS_DETACH
 *
 * \see DokanRemoveMountPoint
 *
 * \param MountPoint Mount point to unmount ("Z", "Z:", "Z:\", "Z:\MyMountPoint").
 * \param Safe Process is not in DLL_PROCESS_DETACH state.
 * \return True if device was unmounted or False in case of failure or device not found.
 */
BOOL DOKANAPI DokanRemoveMountPointEx(LPCWSTR MountPoint, BOOL Safe);

/**
 * \brief Checks whether Name matches Expression
 *
 * \param Expression Expression can contain wildcard characters (? and *)
 * \param Name Name to check
 * \param IgnoreCase Case sensitive or not
 * \return result if name matches the expression
 */
BOOL DOKANAPI DokanIsNameInExpression(LPCWSTR Expression, LPCWSTR Name,
                                      BOOL IgnoreCase);

/**
 * \brief Get the version of Dokan.
 * The returned ULONG is the version number without the dots.
 * \return The version of Dokan
 */
ULONG DOKANAPI DokanVersion();

/**
 * \brief Get the version of the Dokan driver.
 * The returned ULONG is the version number without the dots.
 * \return The version of Dokan driver.
 */
ULONG DOKANAPI DokanDriverVersion();

/**
 * \brief Extends the timeout of the current IO operation in driver.
 *
 * \param Timeout Extended time in milliseconds requested.
 * \param DokanFileInfo \ref DOKAN_FILE_INFO of the operation to extend.
 * \return If the operation was successful.
 */
BOOL DOKANAPI DokanResetTimeout(ULONG Timeout, PDOKAN_FILE_INFO DokanFileInfo);

/**
 * \brief Get the handle to Access Token.
 *
 * This method needs be called in CreateFile callback.
 * The caller must call CloseHandle
 * for the returned handle.
 *
 * \param DokanFileInfo \ref DOKAN_FILE_INFO of the operation to extend.
 * \return A handle to the account token for the user on whose behalf the code is running.
 */
HANDLE DOKANAPI DokanOpenRequestorToken(PDOKAN_FILE_INFO DokanFileInfo);

/**
 * \brief Get active Dokan mount points.
 *
 * \param list Allocate array of DOKAN_CONTROL.
 * \param length Number of \ref DOKAN_CONTROL instances in list.
 * \param uncOnly Get only instances that have UNC Name.
 * \param nbRead Number of instances successfully retrieved.
 * \return List retrieved or not.
 */
//BOOL DOKANAPI DokanGetMountPointList(PDOKAN_CONTROL list, ULONG length,
//                                     BOOL uncOnly, PULONG nbRead);

/**
 * \brief Convert \ref DOKAN_OPERATIONS.ZwCreateFile parameters to CreateFile parameters.
 *
 * Dokan Kernel forward the DesiredAccess directly from the IRP_MJ_CREATE.
 * This DesiredAccess has been converted from generic rights (user CreateFile request) to standard rights and will be converted back here.
 * https://msdn.microsoft.com/windows/hardware/drivers/ifs/access-mask
 *
 * \param DesiredAccess DesiredAccess from \ref DOKAN_OPERATIONS.ZwCreateFile.
 * \param FileAttributes FileAttributes from \ref DOKAN_OPERATIONS.ZwCreateFile.
 * \param CreateOptions CreateOptions from \ref DOKAN_OPERATIONS.ZwCreateFile.
 * \param CreateDisposition CreateDisposition from \ref DOKAN_OPERATIONS.ZwCreateFile.
 * \param outDesiredAccess New CreateFile dwDesiredAccess.
 * \param outFileAttributesAndFlags New CreateFile dwFlagsAndAttributes.
 * \param outCreationDisposition New CreateFile dwCreationDisposition.
 * \see CreateFile function (MSDN)
 */
void DOKANAPI DokanMapKernelToUserCreateFileFlags(
	ACCESS_MASK DesiredAccess, ULONG FileAttributes, ULONG CreateOptions, ULONG CreateDisposition,
	ACCESS_MASK* outDesiredAccess, DWORD *outFileAttributesAndFlags, DWORD *outCreationDisposition);

/**
 * \brief Convert WIN32 error to NTSTATUS
 *
 * https://support.microsoft.com/en-us/kb/113996
 *
 * \param Error Win32 Error to convert
 * \return NTSTATUS associate to the ERROR.
 */
NTSTATUS DOKANAPI DokanNtStatusFromWin32(DWORD Error);

/** @} */

#ifdef __cplusplus
}
#endif

#endif // DOKAN_H_


text:
.. include:: _includes/_replacements.rst

Results
=======

Pliers is meant to provide a unified interface to a wide range of feature extraction tools and services, so it's imperative that the results we get back from different extractors can also be represented and accessed in a standardized way. In this section, we provide a detailed description of the pliers |ExtractorResult| class and the various options available for exporting results to pandas DataFrames. In many typical workflows, the export process will be done implicitly, so that all a user has to worry about is making sure to specify appropriate formatting arguments. In particular, if you only ever work with the :ref:`Graph API <graphs>`, you may want to skip down to the :ref:`Graph results` section.

The ExtractorResult class
-------------------------
Calling ``transform()`` on an instantiated |Extractor| returns an object of class |ExtractorResult|. This is a lightweight container that contains all of the extracted feature information returned by the |Extractor|, references to the |Stim| and |Extractor| objects used to generate the result, and both "raw" and processed forms of the results returned by the |Extractor| (though note that many Extractors don't set a ``.raw`` property). For example:

::

    >>> from pliers.extractors import FaceRecognitionFaceLocationsExtractor
    >>> ext = FaceRecognitionFaceLocationsExtractor()
    >>> result = ext.transform(image)

    >>> result.stim.name
    'obama.jpg'

    >>> result.extractor.name
    'FaceRecognitionFaceLocationsExtractor'

    >>> result.raw
    [(142, 349, 409, 82)]

.. _results-to-df:

Exporting results to pandas DataFrames
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Typically, we'll want to work with the data in a more convenient form. Fortunately, every |ExtractorResult| instance provides a .to_df() method that returns a pandas DataFrame:

::
    >>> result.to_df()
    onset   duration   object_id   face_locations
    NaN     NaN        0           (142, 349, 409, 82)

Here, the ``'face_locations'`` column is properly labeled with the name of the feature returned by the |Extractor|. Not surprisingly, you'll still need to know something about the feature extraction tool you're using in order to understand what you're getting back. In this case, consulting the documentation for the face_recognition package's `face_locations <http://pythonhosted.org/face_recognition/face_recognition.html#face_recognition.api.face_locations>`_ function reveals that the values ``(142, 349, 409, 82)`` give us the bounding box coordinates of the detected face in CSS order (i.e., top, right, bottom, left).

Timing columns
##############

You're probably wondering what the other columns are. The ``'onset'`` and ``'duration'`` columns providing timing information for the event in question, if applicable. In this case, because our source |Stim| was a static image, there's no meaningful timing information to be had. But ``to_df()`` still returns these columns by default. This becomes important in cases where we want to preserve some temporal context as we pass |Stim| objects through a feature extraction pipeline:

::

    >>> ext = FaceRecognitionFaceLocationsExtractor()
    >>> image = Stim('obama.jpg', onset=14, duration=1)
    >>> result = ext.transform(image)
    >>> result.to_df()
    onset   duration    object_id   face_locations
    14      1           0           (142, 349, 409, 82)

Of course, if we really don't want the timing columns, we can easily suppress them:

::

    >>> result.to_df(timing=False)
    object_id   face_locations
    0           (142, 349, 409, 82)

We could also pass ``timing='auto'``, which would drop the ``'onset'`` and ``'duration'`` columns if and only if all values are ``NaN``.

Understanding object_ids
########################

What about the ``'object_id'`` column? This one's not so intuitive, but can in some cases be very important. Consider a situation where there are multiple valid results objects in a single |Stim|. For example, suppose we feed an image to our |FaceRecognitionFaceLocationsExtractor| that contains multiple faces. How are we supposed to keep track of these different faces in the results? They come from the same |Stim| and share the same timing parameters (e.g., in the last example, where we explicitly specified the onset and duration, all detected faces will have ``onset=14`` and ``duration=1``). But we obviously need to have *some* way of distinguishing distinct records.

The solution is to serially assign each distinct result object a different ``object_id``. Let's modify the last example to feed in an image that contains 4 separate faces:

::

    >>> ext = FaceRecognitionFaceLocationsExtractor()
    >>> image = Stim('obama.jpg', onset=14, duration=1)

    >>> result = ext.transform(image)
    onset   duration    object_id   face_locations
    14      1           0           (236, 862, 325, 772)
    14      1           1           (104, 581, 211, 474)
    14      1           2           (365, 782, 454, 693)
    14      1           3           (265, 444, 355, 354)

As with the ``timing`` columns, if we don't want to see the ``object_id`` column, we can suppress it by calling ``.to_df(object_id=False)`` or ``.to_df(object_id='auto')``. In the latter case, the ``object_id`` column will be included if and only if the values are non-constant (i.e., there is some value other than 0 somewhere in the DataFrame).

Displaying metadata
###################

Although not displayed by default, it's also possible to include additional metadata about the |Stim| and |Extractor| in the DataFrame returned by ``to_df``:

::

    >>> result = ext.transform('obama.jpg')
    >>> result.to_df(timing=False, object_id=False, metadata=True)
    face_locations      stim_name   class       filename    history     source_file
    (142, 349, 409, 82) obama.jpg   ImageStim   obama.jpg               obama.jpg

Here we get columns for the |Stim| name (typically just the filename, unless we explicitly specified a different name), the current filename, the |Stim| history, and the source filename. In the above example, ``stim_name``, ``filename`` and ``source_file`` are identical, but this won't always be the case. For example, if the images we're running through the |FaceRecognitionFaceLocationsExtractor| had been extracted from frames of video, the ``source_file`` would point to the original video, while the ``filename`` would point to (temporary) image files corresponding to the extracted frames.

The ``history`` column contains a text summary of the |Stim| transformation history; for more details, see the :ref:`Transformation history` section.

Display mode
############
By default, DataFrames are in 'wide' format. That is, each row represents a single event, and all features are contained in columns. To get a better sense of what this means, it's helpful to look at an extractor that returns more than one feature:

::

    >>> from pliers.extractors import GoogleVisionAPILabelExtractor
    >>> ext = GoogleVisionAPILabelExtractor()
    >>> result = ext.transform('apple.jpg')

    >>> result.to_df()
    onset   duration    object_id   fruit   apple   produce food    natural foods   mcintosh    diet food
    NaN     NaN         0           0.968   0.966   0.959   0.824   0.801           0.629   0.607

Here we fed in an image of an apple, and the |GoogleVisionAPILabelExtractor| automatically returned 7 different high-probability labels ('fruit', 'apple', etc.)--each one represented as a separate feature in our results.

While there's nothing at all wrong with this format (indeed, it's the default!), sometimes we prefer to get back our data in 'long' format, where each row represents the intersection of a single event and a single feature:

::

    >>> result.to_df(format='long', timing=False, object_id=False)
    feature         value
    fruit           0.968
    apple           0.966
    produce         0.959
    food            0.824
    natural foods   0.801
    mcintosh        0.629
    diet food       0.607

Now, the feature names are specified in the ``'feature'`` column, and the extracted values are provided in the ``'value'`` column.

Displaying Extractor names
##########################

If we only ever worked with results generated by a single |Extractor| for a single |Stim|, we'd rarely have any problems figuring out where our results are coming from. But as we'll see momentarily, a more common use case is that we want to combine results from multiple Extractors and/or Stims into a single, possibly very large, DataFrame. In this case, figuring out the source of particular features can quickly get confusing--especially because different Extractors can potentially have similar or even identical feature names.

We can ensure that the name of the current |Extractor| is explicitly added to our results via the ``extractor_name`` argument. The precise behavior of ``extractor_name=True`` will depend on the ``format`` argument. When ``format='wide'``, the name will be added as the first level in a pandas MultiIndex; when ``format='long'``, a new column will be added. Examples:

::

    >>> results.to_df(format='long', timing=False, object_id=False, extractor_name=True)
    feature         value   extractor
    fruit           0.968   GoogleVisionAPILabelExtractor
    apple           0.966   GoogleVisionAPILabelExtractor
    produce         0.959   GoogleVisionAPILabelExtractor
    food            0.824   GoogleVisionAPILabelExtractor
    natural foods   0.801   GoogleVisionAPILabelExtractor
    mcintosh        0.629   GoogleVisionAPILabelExtractor
    diet food       0.607   GoogleVisionAPILabelExtractor

    >>> results.to_df(timing=False, object_id=False, extractor_name=True)
    GoogleVisionAPILabelExtractor
    fruit   apple   produce food    natural foods   mcintosh    diet food
    0.968   0.966   0.959   0.824   0.801           0.629       0.607

Merging Extractor results
-------------------------
In most cases, we'll want to do more than just apply a single |Extractor| to a single |Stim|. We might want to apply one |Extractor| to a set of stims, several different Extractors to a single |Stim|, or many Extractors to many Stims. As described (in the section on :ref:`graphs`, pliers makes it easy to build such workflows--and to automatically merge the extracted feature data into one big pandas DataFrame. But in cases where we're working with multiple results manually, or wish to exercise a little more control over the output format, we can still merge the results ourselves, using the appropriately named ``merge_results`` function.

Suppose we have a list of images, and we want to run both face recognition and object labeling on each image. Then we can do the following:

::

    from pliers.extractors import (GoogleVisionAPIFaceExtractor, GoogleVisionAPILabelExtractor)
    my_images = ['file1.jpg', 'file2.jpg', ...]

    face_ext = GoogleVisionAPIFaceExtractor()
    face_feats = face_ext.transform(my_images)

    lab_ext = GoogleVisionAPILabelExtractor()
    lab_feats = lab_ext.transform(my_images)

Now each of ``face_feats`` and ``lab_feats`` is a list of |ExtractorResult| objects. We could explicitly convert each element in each list to a pandas DataFrame (by calling ``.to_df()``), but then we'd still need to figure out how to merge all those DataFrames in a sensible way. Fortunately, :func:`merge_results` can do the heavy lifting for us:

::

    from pliers.extractors import merge_results
    # merge_results expects a single list, so we concatenate our two lists
    df = merge_results(face_feats + lab_feats, timing=False, metadata=True,
                       object_id='auto', format='long',
                       extractor_names='column')

Nearly all of the arguments to ``merge_results`` match the ones :ref:`we saw above<results-to-df>` when calling ``to_df`` on individual |ExtractorResult| instances. We can control the output shape ('wide' vs. 'long') with the ``format`` argument, and indicate whether which optional columns to include via the ``metadata``, ``timing``, and ``object_id`` flags.

The only notable exception in terms of argument behavior is that the ``extractor_names`` argument has different semantics from ``extractor_name`` in ``to_df()``. Specifically, rather than just specifying whether or not to include the names of Extractors, we can now also control exactly how they're displayed (e.g., whether they're prepended to the feature names, added as a level in a pandas MultiIndex, etc.). Full details can be found in the :func:`merge_results` function reference.

In all other respects, the outputs of ``merge_results`` should look just like those generated by ``to_df`` calls--except of course that the results for different Extractors and Stims are now concatenated together along either the row or the column axes (depending on the ``format`` argument). As a general rule of thumb, we recommend using the default format ('wide') in cases where one is working with a small number of different Extractors and/or features, and switching to ``format='long'`` when the number of Extractors and/or features gets large. (The main reason for this recommendation is that the merged DataFrames are typically sparse, so in 'wide' format, one can end up with a very large number of ``NaN`` values when working with many Extractors at once. In 'long' format, there are virtually no missing values.)

Converting results to SeriesStim
-------------------------
|ExtractorResult| can be converted into instances of |SeriesStim| using |ExtractorResultToSeriesConverter|. This way, results from an Extractor can be fed to |MetricExtractor|, which enables extraction of summary metrics (computed with any arbitrary function) across features.

Graph results
-------------
In practice, many users will primarily rely on the :ref:`Graph API <graphs>` for feature extraction. Since standard |Graph| execution merges results by default, using a |Graph| means that you probably won't need to worry about calling ``to_df`` or ``merge_results`` explicitly. You'll just get a single, already-merged pandas DataFrame as the result of a ``Graph.transform`` call.

The main thing to be aware of in this case is that the ``.transform`` call takes any of the keyword arguments supported by ``merge_results``, and simply passes them through. This means you can control the output format and inclusion of various columns exactly as documented above for ``merge_results`` (and ``to_df``). Here's a minimalistic example to illustrate:

::

    from pliers.graph import Graph
    from pliers.filters import FrameSamplingFilter
    from pliers.extractors import FaceRecognitionFaceLandmarksExtractor
    from pliers.tests.utils import get_test_data_path
    from os.path import join

    # Use a short video from the pliers test suite
    video = join(get_test_data_path(), 'video', 'obama_speech.mp4')

    # Sample image frames from video, then apply face recognition
    nodes = [
        (FrameSamplingFilter(hertz=2), ['FaceRecognitionFaceLocationsExtractor'])
    ]

    # Construct and run Graph
    g = Graph(nodes)
    df = g.transform(video, metadata=False, format='long', extractor_names='column')

    ''' Outputs:

    object_id   duration    onset   feature         value               extractor
    0           0.50        0.0     face_locations  (36, 223, 79, 180)  FaceRecognitionFaceLocationsExtractor
    1           0.50        0.0     face_locations  (58, 101, 94, 65)   FaceRecognitionFaceLocationsExtractor
    0           0.50        0.5     face_locations  (26, 213, 70, 170)  FaceRecognitionFaceLocationsExtractor
    1           0.50        0.5     face_locations  (58, 101, 94, 65)   FaceRecognitionFaceLocationsExtractor
    ...         ...         ...     ...             ...                 ...

If you don't explicitly specify any formatting arguments, you'll get the same sane defaults used in :py:func:`merge_results`, which should work well in most cases.


text:
<?php

namespace AppBundle\Command\Project;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;

/**
 * Deploy command
 *
 *  @author Antonio Pastorino <antonio.pastorino@gmail.com>
 */
class DeployCommand extends ContainerAwareCommand {

  protected function configure() {
    $this
            ->setName('project:deploy')
            ->setDescription('Deploys a project')
            ->addArgument(
                    'name', InputArgument::OPTIONAL, 'Project you want to deploy'
            )
            ->addArgument(
                    'branch', InputArgument::OPTIONAL, 'If set, we will deploy this instead of a default one'
            )
            ->addOption(
                    'grunt', null, InputOption::VALUE_NONE, 'If set, after the deploy grunt will be ran'
            )
    ;
  }

  protected function execute(InputInterface $input, OutputInterface $output) {
    $deploymanager = $this->getContainer()->get('app.deploy.manager');
    $name = $input->getArgument('name');
    if (!$name) {
      $output->writeln(sprintf('<error>%s</error>', "Missing project name parameter"));
      $projects = $deploymanager->listProjects();
      if (count($projects)) {
        $output->writeln(sprintf('<comment>%s</comment>', "Available projects are:"));
        foreach ($projects as $p) {
          $output->writeln(sprintf('<comment>%s</comment>', $p->getName()));
        }
      } else {
        $output->writeln(sprintf('<comment>%s</comment>', "No projects available"));
      }
      return;
    }

    $branch = $input->getArgument('branch');
    if ($branch) {
      $output->writeln('Deploying [' . $name . '] with [' . $branch . ']');
    } else {
      $output->writeln('Deploying [' . $name . '] with [default branch]');
      $branch = NULL;
    }
    $usegrunt = FALSE;
    if ($input->getOption('grunt')) {
      $usegrunt = TRUE;
    }

    $deploymanager->deploy($name, $branch, $usegrunt);

    if (!$deploymanager->hasErrors()) {
      $output->writeln('Done!');
    } else {
      foreach ($deploymanager->getErrors() as $error)
        $output->writeln(sprintf('<error>%s</error>', $error->getMessage()));
    }
  }

}