text:
<?xml version="1.0" encoding="UTF-8"?>
<interface>
  <!-- interface-requires gtk+ 3.0 -->
  <object class="GtkListStore" id="Frequencies">
    <columns>
      <!-- column-name Display -->
      <column type="gchararray"/>
      <!-- column-name Frequency -->
      <column type="gfloat"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes">Stop</col>
        <col id="1">0</col>
      </row>
      <row>
        <col id="0">0,5 Hz</col>
        <col id="1">0.5</col>
      </row>
      <row>
        <col id="0">1 Hz</col>
        <col id="1">1</col>
      </row>
      <row>
        <col id="0">10 Hz</col>
        <col id="1">10</col>
      </row>
      <row>
        <col id="0">20 Hz</col>
        <col id="1">20</col>
      </row>
      <row>
        <col id="0">50 Hz</col>
        <col id="1">50</col>
      </row>
      <row>
        <col id="0">100 Hz</col>
        <col id="1">100</col>
      </row>
      <row>
        <col id="0">200 Hz</col>
        <col id="1">200</col>
      </row>
      <row>
        <col id="0">500 Hz</col>
        <col id="1">500</col>
      </row>
    </data>
  </object>
  <object class="GtkWindow" id="analog">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="title" translatable="yes">Analog</property>
    <child>
      <object class="GtkBox" id="box3">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <property name="homogeneous">True</property>
        <child>
          <object class="GtkScale" id="analog 1">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 1</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="analog 2">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 2</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="analog 3">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 3</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="analog 4">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 4</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="analog 5">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 5</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">4</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="analog 6">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 6</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">5</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="analog 7">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 7</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">6</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="analog 8">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 8</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">7</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="analog 9">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">v analog 9</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">8</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
  <object class="GtkWindow" id="button">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="title" translatable="yes">Button</property>
    <child>
      <object class="GtkGrid" id="grid1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="row_homogeneous">True</property>
        <property name="column_homogeneous">True</property>
        <child>
          <object class="GtkToggleButton" id="button 1">
            <property name="label" translatable="yes">Button 1</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToggleButton" id="button 2">
            <property name="label" translatable="yes">Button 2</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToggleButton" id="button 3">
            <property name="label" translatable="yes">Button 3</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">0</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToggleButton" id="button 4">
            <property name="label" translatable="yes">Button 4</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">1</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToggleButton" id="button 5">
            <property name="label" translatable="yes">Button 5</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">1</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToggleButton" id="button 6">
            <property name="label" translatable="yes">Button 6</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">1</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToggleButton" id="button 7">
            <property name="label" translatable="yes">Button 7</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">0</property>
            <property name="top_attach">2</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToggleButton" id="button 8">
            <property name="label" translatable="yes">Button 8</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">1</property>
            <property name="top_attach">2</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkToggleButton" id="button 9">
            <property name="label" translatable="yes">Button 9</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
            <property name="use_action_appearance">False</property>
          </object>
          <packing>
            <property name="left_attach">2</property>
            <property name="top_attach">2</property>
            <property name="width">1</property>
            <property name="height">1</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
  <object class="GtkAdjustment" id="target">
    <property name="upper">10</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkWindow" id="tracker">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="title" translatable="yes">Tracker</property>
    <child>
      <object class="GtkBox" id="box1">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <property name="homogeneous">True</property>
        <child>
          <object class="GtkBox" id="box2">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <child>
              <object class="GtkLabel" id="label2">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Frequency:</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">0</property>
              </packing>
            </child>
            <child>
              <object class="GtkComboBox" id="Frequency box">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="model">Frequencies</property>
                <property name="has_entry">True</property>
                <property name="entry_text_column">0</property>
                <property name="id_column">1</property>
                <child internal-child="entry">
                  <object class="GtkEntry" id="combobox-entry">
                    <property name="can_focus">False</property>
                    <property name="invisible_char">●</property>
                  </object>
                </child>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">1</property>
              </packing>
            </child>
            <child>
              <object class="GtkButton" id="reset">
                <property name="label" translatable="yes">Reset the values</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="receives_default">True</property>
                <property name="use_action_appearance">False</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">2</property>
              </packing>
            </child>
            <child>
              <object class="GtkLabel" id="label1">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">Sensor number:</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">3</property>
              </packing>
            </child>
            <child>
              <object class="GtkSpinButton" id="spinbutton1">
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="invisible_char">●</property>
                <property name="invisible_char_set">True</property>
                <property name="adjustment">target</property>
                <property name="numeric">True</property>
                <property name="wrap">True</property>
              </object>
              <packing>
                <property name="expand">False</property>
                <property name="fill">True</property>
                <property name="position">4</property>
              </packing>
            </child>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="scale1">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">x position</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="scale2">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">y position</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">2</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="scale3">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">z position</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">3</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="scale4">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">x orientation</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">4</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="scale5">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">y orientation</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">5</property>
          </packing>
        </child>
        <child>
          <object class="GtkScale" id="scale6">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="adjustment">z orientation</property>
            <property name="round_digits">1</property>
            <property name="value_pos">left</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">6</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
  <object class="GtkAdjustment" id="v analog 1">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="v analog 2">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="v analog 3">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="v analog 4">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="v analog 5">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="v analog 6">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="v analog 7">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="v analog 8">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="v analog 9">
    <property name="lower">-1</property>
    <property name="upper">1</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="x orientation">
    <property name="lower">-3.1415926000000001</property>
    <property name="upper">3.1415926000000001</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="x position">
    <property name="lower">-3</property>
    <property name="upper">3</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="y orientation">
    <property name="lower">-3.1415926000000001</property>
    <property name="upper">3.1415926000000001</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="y position">
    <property name="lower">-3</property>
    <property name="upper">3</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="z orientation">
    <property name="lower">-3.1415926000000001</property>
    <property name="upper">3.1415926000000001</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
  <object class="GtkAdjustment" id="z position">
    <property name="lower">-3</property>
    <property name="upper">3</property>
    <property name="step_increment">0.10000000000000001</property>
    <property name="page_increment">1</property>
  </object>
</interface>


text:
from nose.tools import assert_greater
from .... import make
from ....core.mod import mod
from ...ut import need_scrapyd
from .. import name

@need_scrapyd
def test_spy_query():
    app = make()
    with app.app_context():
        d = mod(name).spy('language:chinese', 60)
        assert_greater(len(d.posts), 0)
        d = mod(name).spy('http://g.e-hentai.org/?f_search=language%3Achinese', 60)
        assert_greater(len(d.posts), 0)

redpajama_set_name: RedPajamaGithub


text:
This is a port of the [halpert library](https://github.com/smizell/halpert) to be used in the browser
with jQuery.

## Usage

```javascript
// This will parse the HTML for RDFa and generate a HAL object
var hal = Halpert();
```


text:
using System.Collections.Generic;
using Abp.AutoMapper;
using NorthLion.Zero.Authorization.Roles;

namespace NorthLion.Zero.Roles.Dto
{
    [AutoMap(typeof(Role))]
    public class CreateRoleInput
    {
        public string Name { get; set; }
        public string DisplayName { get; set; }
        public List<AssignedPermission> Permissions { get; set; } = new List<AssignedPermission>();
        public bool IsDefault { get; set; }
    }
}


text:
"use strict";

const runPrettier = require("../runPrettier");

test("infers postcss parser", () => {
  const result = runPrettier("cli/with-parser-inference", ["*"]);

  expect(result.stdout).toMatchSnapshot();
  expect(result.status).toEqual(0);
});

test("infers postcss parser with --list-different", () => {
  const result = runPrettier("cli/with-parser-inference", [
    "--list-different",
    "*"
  ]);

  expect(result.stdout).toMatchSnapshot();
  expect(result.status).toEqual(0);
});


text:
@interface SearchConditionCell : UITableViewCell

@property (weak, nonatomic) IBOutlet UIView *viewCell;
@property (weak, nonatomic) IBOutlet UILabel *lblSearch;
@property (weak, nonatomic) IBOutlet UILabel *lblSearchOption;
@property (weak, nonatomic) IBOutlet UIImageView *imgArrow;

@end


text:
Some projects using Pylint
--------------------------
The following projects are known to use Pylint to help develop better
code:

* OSAF Chandler (http://www.osafoundation.org/)
* Xen (http://www.xensource.com/)
* CPS (http://www.nuxeo.org)
* ERP5 (http://www.erp5.org/)
* pyxmpp (http://pyxmpp.jabberstudio.org/)
* mercurial
* eXe (http://exelearning.org/)
* PrimaGIS (http://www.primagis.org)
* python-cdd (https://projetos.ossystems.com.br/projects/python-cdd)
* CDSWare (http://cdsware.cern.ch/)
* ASE (http://dcwww.camp.dtu.dk/campos/ASE/intro.html)
* RunJob (http://projects.fnal.gov/runjob/)
* Slugathon (http://slugathon.python-hosting.com/)
* Topographica (http://topographica.org/Home/index.html) (at least they intend to do so)
* http://browsershots.org
* many more...

Also notice that the CheeseCake_ kwalitee reporting tool uses Pylint to
analyze the source code.

.. _CheeseCake: http://cheesecake.sourceforge.net/


text:
package com.nrh.api.module.nr.config;

import com.nrh.api.APIApplication;
import com.typesafe.config.Config;

/**
 * The API Keyset class holds a set of keys for a single account
 *
 * @author kahrens
 *
 */
public class APIKeyset {
	private String accountName;
	private String adminName;
	private String accountId;
	private String licenseKey;
	private String restKey;
	private String adminKey;
	private String insightsQueryKey;
	private String insightsInsertKey;

	/**
	 * Populate
	 *
	 * @param conf the config for the whole API project
	 * @param accountName the name of the account to pull from the config
	 */
	public APIKeyset(Config conf, String account) {

		// Set all the local values from the config
		String prefix = "newrelic-api-client.accounts." + account;
		this.accountName = APIApplication.getConfString(prefix + ".accountName");
		this.adminName = APIApplication.getConfString(prefix + ".adminName");
		this.accountId = APIApplication.getConfString(prefix + ".accountId");
		this.licenseKey = APIApplication.getConfString(prefix + ".licenseKey");
		this.restKey = APIApplication.getConfString(prefix + ".restKey");
		this.adminKey = APIApplication.getConfString(prefix + ".adminKey");
		this.insightsQueryKey = APIApplication.getConfString(prefix + ".insightsQueryKey");
		this.insightsInsertKey = APIApplication.getConfString(prefix + ".insightsInsertKey");
	}

	public String getAccountName() {
		return accountName;
	}
	public void setAccountName(String accountName) {
		this.accountName = accountName;
	}
	public String getAdminName() {
		return adminName;
	}
	public void setAdminName(String adminName) {
		this.adminName = adminName;
	}
	public String getAccountId() {
		return accountId;
	}
	public void setAccountId(String accountId) {
		this.accountId = accountId;
	}
	public String getLicenseKey() {
		return licenseKey;
	}
	public void setLicenseKey(String licenseKey) {
		this.licenseKey = licenseKey;
	}
	public String getRestKey() {
		return restKey;
	}
	public void setRestKey(String restKey) {
		this.restKey = restKey;
	}
	public String getAdminKey() {
		return adminKey;
	}
	public void setAdminKey(String adminKey) {
		this.adminKey = adminKey;
	}
	public String getInsightsQueryKey() {
		return insightsQueryKey;
	}
	public void setInsightsQueryKey(String insightsQueryKey) {
		this.insightsQueryKey = insightsQueryKey;
	}
	public String getInsightsInsertKey() {
		return insightsInsertKey;
	}
	public void setInsightsInsertKey(String insightsInsertKey) {
		this.insightsInsertKey = insightsInsertKey;
	}
}


text:
<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

  <!-- Managed XML resource -->

  <bean id="managedXmlResource" parent="primaryResourceType">
    <property name="name" value="managed-xml" />
    <property name="namespace" ref="DEFAULT_NAMESPACE" />
    <property name="parentTypeDefinition" ref="xmlResource" />
    <property name="mixinTypeDefinitions">
      <list>
        <ref bean="ssiMixinResourceTypeDef" />
      </list>
    </property>
    <property name="assertions">
      <list>
        <ref bean="schemaPropSet" />
      </list>
    </property>
    <property name="propertyTypeDefinitions">
      <list>
        <ref bean="plaintextEditPropDef" />
        <ref bean="managedXmlTitlePropDef" />
        <ref bean="managedXmlOverriddenTitlePropDef" />
      </list>
    </property>
  </bean>

  <bean id="resourceTypeIsManagedXml" class="vtk.repository.resourcetype.ResourceTypeAssertion"
        parent="repositoryAware">
    <property name="resourceTypeDefinition" ref="managedXmlResource" />
  </bean>

  <bean id="plaintextEditPropDef" class="vtk.repository.resourcetype.PropertyTypeDefinitionImpl" parent="abstractPropDef">
    <property name="name" value="plaintext-edit" />
    <property name="type" value="BOOLEAN" />
    <property name="protectionLevel" ref="PROTECTION_LEVEL_ACL_WRITE" />
    <property name="mandatory" value="false" />
    <property name="valueFormatter">
      <bean class="vtk.repository.resourcetype.MessageSourceValueFormatter">
        <constructor-arg value="BOOLEAN"/>
        <constructor-arg value="vtk.beans.content.resource-types.mixins.properties.plaintext-edit"/>
      </bean>
    </property>
    <property name="vocabulary">
      <bean class="vtk.repository.resourcetype.ValueVocabulary">
        <constructor-arg value="BOOLEAN"/>
        <property name="values">
          <list>
            <ref bean="VALUE_TRUE" />
          </list>
        </property>
      </bean>
    </property>
  </bean>

  <bean id="managedXmlTitlePropDef" class="vtk.repository.resourcetype.PropertyTypeDefinitionImpl" parent="abstractPropDef">
    <property name="name" value="managedXmlTitle" />
    <property name="protectionLevel" ref="PROTECTION_LEVEL_UNEDITABLE" />
    <property name="mandatory" value="false" />
    <property name="propertyEvaluator" ref="managedXmlTitlePropertyEvaluator" />
  </bean>

  <bean id="managedXmlOverriddenTitlePropDef"
    class="vtk.repository.resourcetype.OverridingPropertyTypeDefinitionImpl">
    <property name="overriddenPropDef" ref="titlePropDef" />
    <property name="propertyEvaluator" ref="managedXmlOverriddenTitlePropertyEvaluator" />
  </bean>

  <bean id="managedXmlOverriddenTitlePropertyEvaluator" parent="titleEvaluator">
    <property name="fallbackTitlePropDef" ref="managedXmlTitlePropDef" />
  </bean>

  <bean id="schemaPropSet" class="vtk.repository.resourcetype.ResourcePropertyAssertion">
    <property name="namespace" ref="DEFAULT_NAMESPACE" />
    <property name="name" value="schema" />
    <property name="checkExistenceOnly" value="true" />
  </bean>

  <bean parent="messageSource.addBasenames">
    <property name="arguments" value="vtk.i18n.xmlprops" />
  </bean>

  <bean id="managedXmlTitlePropertyEvaluator"
    class="vtk.repository.resourcetype.property.PropertyValueConditionalEvaluator">
    <property name="propertyDefinition" ref="schemaPropDef" />
    <property name="conditionalValueEvaluatorMap">
      <map>

        <!-- jus -->
        <entry key="http://www.uio.no/xsd/jus/treaty/v00./treaty.xsd">
          <bean parent="abstractXPathEvaluator">
            <property name="expression" value="/treaty/title" />
          </bean>
        </entry>

        <!-- lcms -->
        <entry key="http://www.uio.no/xsd/lcms/course/v00./course.xsd">
          <bean parent="abstractXPathEvaluator">
            <property name="expression" value="/course/title" />
          </bean>
        </entry>
        <entry key="http://www.uio.no/xsd/lcms/published/v00./published.xsd">
          <bean parent="abstractXPathEvaluator">
            <property name="expression" value="/published-course/title" />
          </bean>
        </entry>
        <entry key="http://www.uio.no/xsd/lcms/simple-quiz-node/v00./simple-quiz-node.xsd">
          <bean parent="abstractXPathEvaluator">
            <property name="expression" value="/simple-quiz-node/title" />
          </bean>
        </entry>
      </map>
    </property>
  </bean>
</beans>


text:
import os
import subprocess
import sys

def untar(file, output_dir):
    subprocess.check_call("tar -xf {file} -C {output_dir}".format(file=file, output_dir=output_dir).split())

for dataset in ["ILSVRC2012_img_train.tar", "ILSVRC2012_img_val.tar"]:
    dataset_name, _ = dataset.split(".")
    os.mkdir("{dset}".format(dset=dataset_name))

    print("Unpacking {tar}".format(tar=dataset))
    untar(dataset, dataset_name)

    classes = os.listdir("./{dir}".format(dir=dataset_name))

    if "train" in dataset:
        # Recursively unpack tars
        for cls in classes:
            print("Unpacking file {name}".format(name=cls))
            label, _ = cls.split(".")
            output_dir = "./{dir}/{label}".format(dir=dataset_name, label=label)
            os.mkdir(output_dir)
            tar_file = "./{dir}/{file}".format(dir=dataset_name, file=cls)
            untar(tar_file, output_dir)
            os.remove(tar_file)


text:
package com.winginno.charitynow;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import java.util.Set;
import java.util.HashSet;

public class NotiHistoryStorage {
    private static final String PREFS_NAME = "HISTORY";
    private static final String KEY = "notiHistory";
    private SharedPreferences appSharedPrefs;
    private SharedPreferences.Editor prefsEditor;

    public NotiHistoryStorage() {
        Context context = ApplicationContextProvider.getContext();

        this.appSharedPrefs = context.getSharedPreferences(PREFS_NAME, Activity.MODE_PRIVATE);
        this.prefsEditor = appSharedPrefs.edit();
    }

    public boolean isInHistory(String id) {
        Set<String> set = appSharedPrefs.getStringSet(KEY, new HashSet<String>());
        return set.contains(id);
    }

    public void addToHistory(String id) {
        Set<String> set = (Set<String>) ((HashSet<String>)appSharedPrefs.getStringSet(KEY, new HashSet<String>())).clone();
        set.add(id);
        prefsEditor.putStringSet(KEY, set).commit();
    }

    public void clear() {
        prefsEditor.putStringSet(KEY, new HashSet<String>()).commit();
    }

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Utils;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osuTK;

namespace osu.Game.Rulesets.Catch.Objects
{
    /// <summary>
    /// Represents the path of a juice stream.
    /// <para>
    /// A <see cref="JuiceStream"/> holds a legacy <see cref="SliderPath"/> as the representation of the path.
    /// However, the <see cref="SliderPath"/> representation is difficult to work with.
    /// This <see cref="JuiceStreamPath"/> represents the path in a more convenient way, a polyline connecting list of <see cref="JuiceStreamPathVertex"/>s.
    /// </para>
    /// </summary>
    public class JuiceStreamPath
    {
        /// <summary>
        /// The height of legacy osu!standard playfield.
        /// The sliders converted by <see cref="ConvertToSliderPath"/> are vertically contained in this height.
        /// </summary>
        internal const float OSU_PLAYFIELD_HEIGHT = 384;

        /// <summary>
        /// The list of vertices of the path, which is represented as a polyline connecting the vertices.
        /// </summary>
        public IReadOnlyList<JuiceStreamPathVertex> Vertices => vertices;

        /// <summary>
        /// The current version number.
        /// This starts from <c>1</c> and incremented whenever this <see cref="JuiceStreamPath"/> is modified.
        /// </summary>
        public int InvalidationID { get; private set; } = 1;

        /// <summary>
        /// The difference between first vertex's <see cref="JuiceStreamPathVertex.Time"/> and last vertex's <see cref="JuiceStreamPathVertex.Time"/>.
        /// </summary>
        public double Duration => vertices[^1].Time - vertices[0].Time;

        /// <remarks>
        /// This list should always be non-empty.
        /// </remarks>
        private readonly List<JuiceStreamPathVertex> vertices = new List<JuiceStreamPathVertex>
        {
            new JuiceStreamPathVertex()
        };

        /// <summary>
        /// Compute the x-position of the path at the given <paramref name="time"/>.
        /// </summary>
        /// <remarks>
        /// When the given time is outside of the path, the x position at the corresponding endpoint is returned,
        /// </remarks>
        public float PositionAtTime(double time)
        {
            int index = vertexIndexAtTime(time);
            return positionAtTime(time, index);
        }

        /// <summary>
        /// Remove all vertices of this path, then add a new vertex <c>(0, 0)</c>.
        /// </summary>
        public void Clear()
        {
            vertices.Clear();
            vertices.Add(new JuiceStreamPathVertex());
            invalidate();
        }

        /// <summary>
        /// Insert a vertex at given <paramref name="time"/>.
        /// The <see cref="PositionAtTime"/> is used as the position of the new vertex.
        /// Thus, the set of points of the path is not changed (up to floating-point precision).
        /// </summary>
        /// <returns>The index of the new vertex.</returns>
        public int InsertVertex(double time)
        {
            if (!double.IsFinite(time))
                throw new ArgumentOutOfRangeException(nameof(time));

            int index = vertexIndexAtTime(time);
            float x = positionAtTime(time, index);
            vertices.Insert(index, new JuiceStreamPathVertex(time, x));

            invalidate();
            return index;
        }

        /// <summary>
        /// Move the vertex of given <paramref name="index"/> to the given position <paramref name="newX"/>.
        /// </summary>
        public void SetVertexPosition(int index, float newX)
        {
            if (index < 0 || index >= vertices.Count)
                throw new ArgumentOutOfRangeException(nameof(index));

            if (!float.IsFinite(newX))
                throw new ArgumentOutOfRangeException(nameof(newX));

            vertices[index] = new JuiceStreamPathVertex(vertices[index].Time, newX);

            invalidate();
        }

        /// <summary>
        /// Add a new vertex at given <paramref name="time"/> and position.
        /// </summary>
        public void Add(double time, float x)
        {
            int index = InsertVertex(time);
            SetVertexPosition(index, x);
        }

        /// <summary>
        /// Remove all vertices that satisfy the given <paramref name="predicate"/>.
        /// </summary>
        /// <remarks>
        /// If all vertices are removed, a new vertex <c>(0, 0)</c> is added.
        /// </remarks>
        /// <param name="predicate">The predicate to determine whether a vertex should be removed given the vertex and its index in the path.</param>
        /// <returns>The number of removed vertices.</returns>
        public int RemoveVertices(Func<JuiceStreamPathVertex, int, bool> predicate)
        {
            int index = 0;
            int removeCount = vertices.RemoveAll(vertex => predicate(vertex, index++));

            if (vertices.Count == 0)
                vertices.Add(new JuiceStreamPathVertex());

            if (removeCount != 0)
                invalidate();

            return removeCount;
        }

        /// <summary>
        /// Recreate this path by using difference set of vertices at given time points.
        /// In addition to the given <paramref name="sampleTimes"/>, the first vertex and the last vertex are always added to the new path.
        /// New vertices use the positions on the original path. Thus, <see cref="PositionAtTime"/>s at <paramref name="sampleTimes"/> are preserved.
        /// </summary>
        public void ResampleVertices(IEnumerable<double> sampleTimes)
        {
            var sampledVertices = new List<JuiceStreamPathVertex>();

            foreach (double time in sampleTimes)
            {
                if (!double.IsFinite(time))
                    throw new ArgumentOutOfRangeException(nameof(sampleTimes));

                double clampedTime = Math.Clamp(time, vertices[0].Time, vertices[^1].Time);
                float x = PositionAtTime(clampedTime);
                sampledVertices.Add(new JuiceStreamPathVertex(clampedTime, x));
            }

            sampledVertices.Sort();

            // The first vertex and the last vertex are always used in the result.
            vertices.RemoveRange(1, vertices.Count - (vertices.Count == 1 ? 1 : 2));
            vertices.InsertRange(1, sampledVertices);

            invalidate();
        }

        /// <summary>
        /// Convert a <see cref="SliderPath"/> to list of vertices and write the result to this <see cref="JuiceStreamPath"/>.
        /// </summary>
        /// <remarks>
        /// Duplicated vertices are automatically removed.
        /// </remarks>
        public void ConvertFromSliderPath(SliderPath sliderPath, double velocity)
        {
            var sliderPathVertices = new List<Vector2>();
            sliderPath.GetPathToProgress(sliderPathVertices, 0, 1);

            double time = 0;

            vertices.Clear();
            vertices.Add(new JuiceStreamPathVertex(0, sliderPathVertices.FirstOrDefault().X));

            for (int i = 1; i < sliderPathVertices.Count; i++)
            {
                time += Vector2.Distance(sliderPathVertices[i - 1], sliderPathVertices[i]) / velocity;

                if (!Precision.AlmostEquals(vertices[^1].Time, time))
                    Add(time, sliderPathVertices[i].X);
            }

            invalidate();
        }

        /// <summary>
        /// Computes the minimum slider velocity required to convert this path to a <see cref="SliderPath"/>.
        /// </summary>
        public double ComputeRequiredVelocity()
        {
            double maximumSlope = 0;

            for (int i = 1; i < vertices.Count; i++)
            {
                double xDifference = Math.Abs((double)vertices[i].X - vertices[i - 1].X);
                double timeDifference = vertices[i].Time - vertices[i - 1].Time;

                // A short segment won't affect the resulting path much anyways so ignore it to avoid divide-by-zero.
                if (Precision.AlmostEquals(timeDifference, 0))
                    continue;

                maximumSlope = Math.Max(maximumSlope, xDifference / timeDifference);
            }

            return maximumSlope;
        }

        /// <summary>
        /// Convert the path of this <see cref="JuiceStreamPath"/> to a <see cref="SliderPath"/> and write the result to <paramref name="sliderPath"/>.
        /// The resulting slider is "folded" to make it vertically contained in the playfield `(0..<see cref="OSU_PLAYFIELD_HEIGHT"/>)` assuming the slider start position is <paramref name="sliderStartY"/>.
        ///
        /// The velocity of the converted slider is assumed to be <paramref name="velocity"/>.
        /// To preserve the path, <paramref name="velocity"/> should be at least the value returned by <see cref="ComputeRequiredVelocity"/>.
        /// </summary>
        public void ConvertToSliderPath(SliderPath sliderPath, float sliderStartY, double velocity)
        {
            const float margin = 1;

            // Note: these two variables and `sliderPath` are modified by the local functions.
            double currentTime = 0;
            Vector2 lastPosition = new Vector2(vertices[0].X, 0);

            sliderPath.ControlPoints.Clear();
            sliderPath.ControlPoints.Add(new PathControlPoint(lastPosition));

            for (int i = 1; i < vertices.Count; i++)
            {
                sliderPath.ControlPoints[^1].Type = PathType.Linear;

                float deltaX = vertices[i].X - lastPosition.X;
                double length = (vertices[i].Time - currentTime) * velocity;

                // Should satisfy `deltaX^2 + deltaY^2 = length^2`.
                // The expression inside the `sqrt` is (almost) non-negative if the slider velocity is large enough.
                double deltaY = Math.Sqrt(Math.Max(0, length * length - (double)deltaX * deltaX));

                // When `deltaY` is small, one segment is always enough.
                // This case is handled separately to prevent divide-by-zero.
                if (deltaY <= OSU_PLAYFIELD_HEIGHT / 2 - margin)
                {
                    float nextX = vertices[i].X;
                    float nextY = (float)(lastPosition.Y + getYDirection() * deltaY);
                    addControlPoint(nextX, nextY);
                    continue;
                }

                // When `deltaY` is large or when the slider velocity is fast, the segment must be partitioned to subsegments to stay in bounds.
                for (double currentProgress = 0; currentProgress < deltaY;)
                {
                    double nextProgress = Math.Min(currentProgress + getMaxDeltaY(), deltaY);
                    float nextX = (float)(vertices[i - 1].X + nextProgress / deltaY * deltaX);
                    float nextY = (float)(lastPosition.Y + getYDirection() * (nextProgress - currentProgress));
                    addControlPoint(nextX, nextY);
                    currentProgress = nextProgress;
                }
            }

            int getYDirection()
            {
                float lastSliderY = sliderStartY + lastPosition.Y;
                return lastSliderY < OSU_PLAYFIELD_HEIGHT / 2 ? 1 : -1;
            }

            float getMaxDeltaY()
            {
                float lastSliderY = sliderStartY + lastPosition.Y;
                return Math.Max(lastSliderY, OSU_PLAYFIELD_HEIGHT - lastSliderY) - margin;
            }

            void addControlPoint(float nextX, float nextY)
            {
                Vector2 nextPosition = new Vector2(nextX, nextY);
                sliderPath.ControlPoints.Add(new PathControlPoint(nextPosition));
                currentTime += Vector2.Distance(lastPosition, nextPosition) / velocity;
                lastPosition = nextPosition;
            }
        }

        /// <summary>
        /// Find the index at which a new vertex with <paramref name="time"/> can be inserted.
        /// </summary>
        private int vertexIndexAtTime(double time)
        {
            // The position of `(time, Infinity)` is uniquely determined because infinite positions are not allowed.
            int i = vertices.BinarySearch(new JuiceStreamPathVertex(time, float.PositiveInfinity));
            return i < 0 ? ~i : i;
        }

        /// <summary>
        /// Compute the position at the given <paramref name="time"/>, assuming <paramref name="index"/> is the vertex index returned by <see cref="vertexIndexAtTime"/>.
        /// </summary>
        private float positionAtTime(double time, int index)
        {
            if (index <= 0)
                return vertices[0].X;
            if (index >= vertices.Count)
                return vertices[^1].X;

            double duration = vertices[index].Time - vertices[index - 1].Time;
            if (Precision.AlmostEquals(duration, 0))
                return vertices[index].X;

            float deltaX = vertices[index].X - vertices[index - 1].X;

            return (float)(vertices[index - 1].X + deltaX * ((time - vertices[index - 1].Time) / duration));
        }

        private void invalidate() => InvalidationID++;
    }
}


text:
<!DOCTYPE html>

  <meta charset="utf-8" />

  <title>{{ page.ttl }} - {{ page.conf_data }}</title>

  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">

  <meta property="og:url"             content="{{ page.base_url }}" />
  <meta property="og:title"           content="SymfonyDay {{ page.conf_data }} - Conference e Workshop" />
  <meta property="og:description"     content="Symfony 2 è uno dei framework PHP più apprezzati sul mercato. Il SymfonyDay è l'evento di riferimento su Symfony in Italia, ne introduce le best practices e ne mostra case studies ad alto livello." />
  <meta property="og:image"           content="{{ page.base_url }}/img/confs/sfday/symfonyday_it_minimal.jpg" />

  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:site" content="@SymfonyDayIt">
  <meta name="twitter:creator" content="@SymfonyDayIt">
  <meta name="twitter:title" content="SymfonyDay {{ page.conf_data }} - Conference e Workshop">
  <meta name="twitter:description" content="Symfony 2 è uno dei framework PHP più apprezzati sul mercato. Il SymfonyDay è l'evento di riferimento su Symfony in Italia, ne introduce le best practices e ne mostra case studies ad alto livello.">
  <meta name="twitter:image" content="{{ page.base_url }}/img/confs/sfday/twitter-card-2015.jpg">

  <link href='http://fonts.googleapis.com/css?family=Exo:200,900,700,400|Pacifico' rel='stylesheet' type='text/css'>

  <link rel="stylesheet" href="/css/reset.css">
  <link rel="stylesheet" href="/css/grid_12_percent.css">
  <link rel="stylesheet" href="/css/main.css">
  <link rel="stylesheet" href="/css/tooltip.css">

{{ page.title }}

La conferenza

            {% if page.cfp %}
Call for paper
 {% endif %}
            {% if page.tickets %}
Registrati
 {% endif %}
            {% if page.speakers %}
Programma
 {% endif %}

La location

            {% if page.speakers %}
I workshop
 {% endif %}

Gli sponsor

Associazione Gruppo Utenti Sviluppatori PHP Italiani

          PHP User Group di Modena e Reggio Emilia

presentano

{{ page.ttl }}

{{ page.conf_data }}

Share

      {{ content }}

            © 2012-{{ site.time | date: '%Y' }} Grusp. Tutti i diritti riservati.

Cos'è il Grusp?

Contattaci

          Torna su


text:
"""Manila base exception handling.

Includes decorator for re-raising Manila-type exceptions.

SHOULD include dedicated exception logging.

"""
import re

from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_log import log
import six
import webob.exc

from manila.i18n import _
from manila.i18n import _LE

LOG = log.getLogger(__name__)

exc_log_opts = [
    cfg.BoolOpt('fatal_exception_format_errors',
                default=False,
                help='Whether to make exception message format errors fatal.'),
]

CONF = cfg.CONF
CONF.register_opts(exc_log_opts)

ProcessExecutionError = processutils.ProcessExecutionError

class ConvertedException(webob.exc.WSGIHTTPException):
    def __init__(self, code=400, title="", explanation=""):
        self.code = code
        self.title = title
        self.explanation = explanation
        super(ConvertedException, self).__init__()

class Error(Exception):
    pass

class ManilaException(Exception):
    """Base Manila Exception

    To correctly use this class, inherit from it and define
    a 'message' property. That message will get printf'd
    with the keyword arguments provided to the constructor.

    """
    message = _("An unknown exception occurred.")
    code = 500
    headers = {}
    safe = False

    def __init__(self, message=None, detail_data={}, **kwargs):
        self.kwargs = kwargs
        self.detail_data = detail_data

        if 'code' not in self.kwargs:
            try:
                self.kwargs['code'] = self.code
            except AttributeError:
                pass
        for k, v in self.kwargs.items():
            if isinstance(v, Exception):
                self.kwargs[k] = six.text_type(v)

        if not message:
            try:
                message = self.message % kwargs

            except Exception as e:
                # kwargs doesn't match a variable in the message
                # log the issue and the kwargs
                LOG.exception(_LE('Exception in string format operation.'))
                for name, value in kwargs.items():
                    LOG.error(_LE("%(name)s: %(value)s"), {
                        'name': name, 'value': value})
                if CONF.fatal_exception_format_errors:
                    raise e
                else:
                    # at least get the core message out if something happened
                    message = self.message
        elif isinstance(message, Exception):
            message = six.text_type(message)

        if re.match('.*[^\.]\.\.$', message):
            message = message[:-1]
        self.msg = message
        super(ManilaException, self).__init__(message)

class NetworkException(ManilaException):
    message = _("Exception due to network failure.")

class NetworkBadConfigurationException(NetworkException):
    message = _("Bad network configuration: %(reason)s.")

class NotAuthorized(ManilaException):
    message = _("Not authorized.")
    code = 403

class AdminRequired(NotAuthorized):
    message = _("User does not have admin privileges.")

class PolicyNotAuthorized(NotAuthorized):
    message = _("Policy doesn't allow %(action)s to be performed.")

class Conflict(ManilaException):
    message = _("%(err)s")
    code = 409

class Invalid(ManilaException):
    message = _("Unacceptable parameters.")
    code = 400

class InvalidRequest(Invalid):
    message = _("The request is invalid.")

class InvalidResults(Invalid):
    message = _("The results are invalid.")

class InvalidInput(Invalid):
    message = _("Invalid input received: %(reason)s.")

class InvalidContentType(Invalid):
    message = _("Invalid content type %(content_type)s.")

class InvalidHost(Invalid):
    message = _("Invalid host: %(reason)s")

# Cannot be templated as the error syntax varies.
# msg needs to be constructed when raised.
class InvalidParameterValue(Invalid):
    message = _("%(err)s")

class InvalidUUID(Invalid):
    message = _("Expected a uuid but received %(uuid)s.")

class InvalidDriverMode(Invalid):
    message = _("Invalid driver mode: %(driver_mode)s.")

class InvalidAPIVersionString(Invalid):
    message = _("API Version String %(version)s is of invalid format. Must "
                "be of format MajorNum.MinorNum.")

class VersionNotFoundForAPIMethod(Invalid):
    message = _("API version %(version)s is not supported on this method.")

class InvalidGlobalAPIVersion(Invalid):
    message = _("Version %(req_ver)s is not supported by the API. Minimum "
                "is %(min_ver)s and maximum is %(max_ver)s.")

class InvalidCapacity(Invalid):
    message = _("Invalid capacity: %(name)s = %(value)s.")

class NotFound(ManilaException):
    message = _("Resource could not be found.")
    code = 404
    safe = True

class InUse(ManilaException):
    message = _("Resource is in use.")

class AvailabilityZoneNotFound(NotFound):
    message = _("Availability zone %(id)s could not be found.")

class ShareNetworkNotFound(NotFound):
    message = _("Share network %(share_network_id)s could not be found.")

class ShareServerNotFound(NotFound):
    message = _("Share server %(share_server_id)s could not be found.")

class ShareServerNotFoundByFilters(ShareServerNotFound):
    message = _("Share server could not be found by "
                "filters: %(filters_description)s.")

class ShareServerInUse(InUse):
    message = _("Share server %(share_server_id)s is in use.")

class InvalidShareServer(Invalid):
    message = _("Share server %(share_server_id)s is not valid.")

class ShareMigrationFailed(ManilaException):
    message = _("Share migration failed: %(reason)s")

class ServiceIPNotFound(ManilaException):
    message = _("Share migration failed: %(reason)s")

class ShareServerNotCreated(ManilaException):
    message = _("Share server %(share_server_id)s failed on creation.")

class ServiceNotFound(NotFound):
    message = _("Service %(service_id)s could not be found.")

class ServiceIsDown(Invalid):
    message = _("Service %(service)s is down.")

class HostNotFound(NotFound):
    message = _("Host %(host)s could not be found.")

class SchedulerHostFilterNotFound(NotFound):
    message = _("Scheduler host filter %(filter_name)s could not be found.")

class SchedulerHostWeigherNotFound(NotFound):
    message = _("Scheduler host weigher %(weigher_name)s could not be found.")

class HostBinaryNotFound(NotFound):
    message = _("Could not find binary %(binary)s on host %(host)s.")

class InvalidReservationExpiration(Invalid):
    message = _("Invalid reservation expiration %(expire)s.")

class InvalidQuotaValue(Invalid):
    message = _("Change would make usage less than 0 for the following "
                "resources: %(unders)s.")

class QuotaNotFound(NotFound):
    message = _("Quota could not be found.")

class QuotaExists(ManilaException):
    message = _("Quota exists for project %(project_id)s, "
                "resource %(resource)s.")

class QuotaResourceUnknown(QuotaNotFound):
    message = _("Unknown quota resources %(unknown)s.")

class ProjectUserQuotaNotFound(QuotaNotFound):
    message = _("Quota for user %(user_id)s in project %(project_id)s "
                "could not be found.")

class ProjectQuotaNotFound(QuotaNotFound):
    message = _("Quota for project %(project_id)s could not be found.")

class QuotaClassNotFound(QuotaNotFound):
    message = _("Quota class %(class_name)s could not be found.")

class QuotaUsageNotFound(QuotaNotFound):
    message = _("Quota usage for project %(project_id)s could not be found.")

class ReservationNotFound(QuotaNotFound):
    message = _("Quota reservation %(uuid)s could not be found.")

class OverQuota(ManilaException):
    message = _("Quota exceeded for resources: %(overs)s.")

class MigrationNotFound(NotFound):
    message = _("Migration %(migration_id)s could not be found.")

class MigrationNotFoundByStatus(MigrationNotFound):
    message = _("Migration not found for instance %(instance_id)s "
                "with status %(status)s.")

class FileNotFound(NotFound):
    message = _("File %(file_path)s could not be found.")

class MigrationError(ManilaException):
    message = _("Migration error: %(reason)s.")

class MalformedRequestBody(ManilaException):
    message = _("Malformed message body: %(reason)s.")

class ConfigNotFound(NotFound):
    message = _("Could not find config at %(path)s.")

class PasteAppNotFound(NotFound):
    message = _("Could not load paste app '%(name)s' from %(path)s.")

class NoValidHost(ManilaException):
    message = _("No valid host was found. %(reason)s.")

class WillNotSchedule(ManilaException):
    message = _("Host %(host)s is not up or doesn't exist.")

class QuotaError(ManilaException):
    message = _("Quota exceeded: code=%(code)s.")
    code = 413
    headers = {'Retry-After': 0}
    safe = True

class ShareSizeExceedsAvailableQuota(QuotaError):
    message = _("Requested share exceeds allowed gigabytes quota.")

class SnapshotSizeExceedsAvailableQuota(QuotaError):
    message = _("Requested snapshot exceeds allowed gigabytes quota.")

class ShareLimitExceeded(QuotaError):
    message = _("Maximum number of shares allowed (%(allowed)d) exceeded.")

class SnapshotLimitExceeded(QuotaError):
    message = _("Maximum number of snapshots allowed (%(allowed)d) exceeded.")

class ShareNetworksLimitExceeded(QuotaError):
    message = _("Maximum number of share-networks "
                "allowed (%(allowed)d) exceeded.")

class GlusterfsException(ManilaException):
    message = _("Unknown Gluster exception.")

class InvalidShare(Invalid):
    message = _("Invalid share: %(reason)s.")

class ShareBusyException(Invalid):
    message = _("Share is busy with an active task: %(reason)s.")

class InvalidShareInstance(Invalid):
    message = _("Invalid share instance: %(reason)s.")

class ManageInvalidShare(InvalidShare):
    message = _("Manage existing share failed due to "
                "invalid share: %(reason)s")

class UnmanageInvalidShare(InvalidShare):
    message = _("Unmanage existing share failed due to "
                "invalid share: %(reason)s")

class PortLimitExceeded(QuotaError):
    message = _("Maximum number of ports exceeded.")

class ShareAccessExists(ManilaException):
    message = _("Share access %(access_type)s:%(access)s exists.")

class InvalidShareAccess(Invalid):
    message = _("Invalid access_rule: %(reason)s.")

class InvalidShareAccessLevel(Invalid):
    message = _("Invalid or unsupported share access level: %(level)s.")

class ShareBackendException(ManilaException):
    message = _("Share backend error: %(msg)s.")

class ExportLocationNotFound(NotFound):
    message = _("Export location %(uuid)s could not be found.")

class ShareSnapshotNotFound(NotFound):
    message = _("Snapshot %(snapshot_id)s could not be found.")

class ShareSnapshotNotSupported(ManilaException):
    message = _("Share %(share_name)s does not support snapshots.")

class ShareSnapshotIsBusy(ManilaException):
    message = _("Deleting snapshot %(snapshot_name)s that has "
                "dependent shares.")

class InvalidShareSnapshot(Invalid):
    message = _("Invalid share snapshot: %(reason)s.")

class ShareMetadataNotFound(NotFound):
    message = _("Metadata item is not found.")

class InvalidShareMetadata(Invalid):
    message = _("Invalid metadata.")

class InvalidShareMetadataSize(Invalid):
    message = _("Invalid metadata size.")

class SecurityServiceNotFound(NotFound):
    message = _("Security service %(security_service_id)s could not be found.")

class ShareNetworkSecurityServiceAssociationError(ManilaException):
    message = _("Failed to associate share network %(share_network_id)s"
                " and security service %(security_service_id)s: %(reason)s.")

class ShareNetworkSecurityServiceDissociationError(ManilaException):
    message = _("Failed to dissociate share network %(share_network_id)s"
                " and security service %(security_service_id)s: %(reason)s.")

class InvalidVolume(Invalid):
    message = _("Invalid volume.")

class InvalidShareType(Invalid):
    message = _("Invalid share type: %(reason)s.")

class InvalidExtraSpec(Invalid):
    message = _("Invalid extra_spec: %(reason)s.")

class VolumeNotFound(NotFound):
    message = _("Volume %(volume_id)s could not be found.")

class VolumeSnapshotNotFound(NotFound):
    message = _("Snapshot %(snapshot_id)s could not be found.")

class ShareTypeNotFound(NotFound):
    message = _("Share type %(share_type_id)s could not be found.")

class ShareTypeAccessNotFound(NotFound):
    message = _("Share type access not found for %(share_type_id)s / "
                "%(project_id)s combination.")

class ShareTypeNotFoundByName(ShareTypeNotFound):
    message = _("Share type with name %(share_type_name)s "
                "could not be found.")

class ShareTypeExtraSpecsNotFound(NotFound):
    message = _("Share Type %(share_type_id)s has no extra specs with "
                "key %(extra_specs_key)s.")

class ShareTypeInUse(ManilaException):
    message = _("Share Type %(share_type_id)s deletion is not allowed with "
                "shares present with the type.")

class ShareTypeExists(ManilaException):
    message = _("Share Type %(id)s already exists.")

class ShareTypeAccessExists(ManilaException):
    message = _("Share type access for %(share_type_id)s / "
                "%(project_id)s combination already exists.")

class ShareTypeCreateFailed(ManilaException):
    message = _("Cannot create share_type with "
                "name %(name)s and specs %(extra_specs)s.")

class ManageExistingShareTypeMismatch(ManilaException):
    message = _("Manage existing share failed due to share type mismatch: "
                "%(reason)s")

class ShareExtendingError(ManilaException):
    message = _("Share %(share_id)s could not be extended due to error "
                "in the driver: %(reason)s")

class ShareShrinkingError(ManilaException):
    message = _("Share %(share_id)s could not be shrunk due to error "
                "in the driver: %(reason)s")

class ShareShrinkingPossibleDataLoss(ManilaException):
    message = _("Share %(share_id)s could not be shrunk due to "
                "possible data loss")

class InstanceNotFound(NotFound):
    message = _("Instance %(instance_id)s could not be found.")

class BridgeDoesNotExist(ManilaException):
    message = _("Bridge %(bridge)s does not exist.")

class ServiceInstanceException(ManilaException):
    message = _("Exception in service instance manager occurred.")

class ServiceInstanceUnavailable(ServiceInstanceException):
    message = _("Service instance is not available.")

class StorageResourceException(ManilaException):
    message = _("Storage resource exception.")

class StorageResourceNotFound(StorageResourceException):
    message = _("Storage resource %(name)s not found.")
    code = 404

class SnapshotNotFound(StorageResourceNotFound):
    message = _("Snapshot %(name)s not found.")

class SnapshotUnavailable(StorageResourceException):
    message = _("Snapshot %(name)s info not available.")

class NetAppException(ManilaException):
    message = _("Exception due to NetApp failure.")

class VserverNotFound(NetAppException):
    message = _("Vserver %(vserver)s not found.")

class VserverNotSpecified(NetAppException):
    message = _("Vserver not specified.")

class EMCVnxXMLAPIError(Invalid):
    message = _("%(err)s")

class EMCVnxLockRequiredException(ManilaException):
    message = _("Unable to acquire lock(s).")

class EMCVnxInvalidMoverID(ManilaException):
    message = _("Invalid mover or vdm %(id)s.")

class HPE3ParInvalidClient(Invalid):
    message = _("%(err)s")

class HPE3ParInvalid(Invalid):
    message = _("%(err)s")

class HPE3ParUnexpectedError(ManilaException):
    message = _("%(err)s")

class GPFSException(ManilaException):
    message = _("GPFS exception occurred.")

class GPFSGaneshaException(ManilaException):
    message = _("GPFS Ganesha exception occurred.")

class GaneshaCommandFailure(ProcessExecutionError):
    _description = _("Ganesha management command failed.")

    def __init__(self, **kw):
        if 'description' not in kw:
            kw['description'] = self._description
        super(GaneshaCommandFailure, self).__init__(**kw)

class InvalidSqliteDB(Invalid):
    message = _("Invalid Sqlite database.")

class SSHException(ManilaException):
    message = _("Exception in SSH protocol negotiation or logic.")

class HDFSException(ManilaException):
    message = _("HDFS exception occurred!")

class QBException(ManilaException):
    message = _("Quobyte exception occurred: %(msg)s")

class QBRpcException(ManilaException):
    """Quobyte backend specific exception."""
    message = _("Quobyte JsonRpc call to backend raised "
                "an exception: %(result)s, Quobyte error"
                " code %(qbcode)s")

class SSHInjectionThreat(ManilaException):
    message = _("SSH command injection detected: %(command)s")

class HNASBackendException(ManilaException):
    message = _("HNAS Backend Exception: %(msg)s")

class HNASConnException(ManilaException):
    message = _("HNAS Connection Exception: %(msg)s")

class HNASItemNotFoundException(StorageResourceNotFound):
    message = _("HNAS Item Not Found Exception: %(msg)s")

class HNASNothingToCloneException(ManilaException):
    message = _("HNAS Nothing To Clone Exception: %(msg)s")

# ConsistencyGroup
class ConsistencyGroupNotFound(NotFound):
    message = _("ConsistencyGroup %(consistency_group_id)s could not be "
                "found.")

class CGSnapshotNotFound(NotFound):
    message = _("Consistency group snapshot %(cgsnapshot_id)s could not be "
                "found.")

class CGSnapshotMemberNotFound(NotFound):
    message = _("CG snapshot %(member_id)s could not be found.")

class InvalidConsistencyGroup(Invalid):
    message = _("Invalid ConsistencyGroup: %(reason)s")

class InvalidCGSnapshot(Invalid):
    message = _("Invalid CGSnapshot: %(reason)s")

class DriverNotInitialized(ManilaException):
    message = _("Share driver '%(driver)s' not initialized.")

class ShareResourceNotFound(StorageResourceNotFound):
    message = _("Share id %(share_id)s could not be found "
                "in storage backend.")


text:
<?php

class Pix_Table_TableTest_TableRow extends Pix_Table_Row
{
    public function getTable2()
    {
    }
}

class Pix_Table_TableTest_Table extends Pix_Table
{
    public function init()
    {
        $this->_name = 'table';
        $this->_primary = 't1_id';
        $this->_rowClass = 'Pix_Table_TableTest_TableRow';

        $this->_columns['t1_id'] = array('type' => 'int', 'auto_increment' => true);
        $this->_columns['value'] = array('type' => 'text', 'default' => 'default');

        $this->_relations['table3s'] = array('rel' => 'has_many', 'type' => 'Pix_Table_TableTest_Table3', 'foreign_key' => 't1_id');
        $this->_relations['table2'] = array('rel' => 'has_one', 'type' => 'Pix_Table_TableTest_Table2', 'foreign_key' => 't1_id');
        $this->_relations['nf_table3s'] = array('rel' => 'has_many', 'type' => 'Pix_Table_TableTest_Table3');
        $this->_relations['nf_table2'] = array('rel' => 'has_one', 'type' => 'Pix_Table_TableTest_Table2');
        $this->_relations['table_error'] = array('rel' => 'xxx');

        $this->_hooks['hook_table2'] = array('get' => 'getTable2', 'set' => 'setTable2');
    }
}

class Pix_Table_TableTest_Table2 extends Pix_Table
{
    public function init()
    {
        $this->_name = 'table2';
        $this->_primary = 't2_id';

        $this->_columns['t2_id'] = array('type' => 'int', 'auto_increment' => true);
        $this->_columns['value'] = array('type' => 'text');

        $this->addFilter('filter_default', array());
    }
}

class Pix_Table_TableTest_Table3 extends Pix_Table
{
    public function init()
    {
        $this->_name = 'table3';
        $this->_primary = array('t3_id', 't3_id2');

        $this->_columns['t3_id'] = array('type' => 'int');
        $this->_columns['t3_id2'] = array('type' => 'int');
        $this->_columns['value'] = array('type' => 'text');
    }
}

class Pix_Table_TableTest_TableContstructFailed extends Pix_Table
{
    public function __construct()
    {
        // 在 __construct 用 $this->xxx function 會 failed, 要在 init 才行...
        $this->createTable();
    }
}

/**
 * Test class for Pix_Table.
 * Generated by PHPUnit on 2011-11-04 at 16:41:48.
 */
class Pix_Table_TableTest extends PHPUnit_Framework_TestCase
{
    /**
     * @var Pix_Table
     */
    protected $object;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    protected function tearDown()
    {
    }

    /**
     * 測試 QueryComment 能不能正常被寫入
     */
    public function testSetQueryComment()
    {
        Pix_Table::setQueryComment('test');
        $this->assertEquals(Pix_Table::getQueryComment(), 'test');

        Pix_Table::setQueryComment();
        $this->assertEquals(Pix_Table::getQueryComment(), null);
    }

    /**
     * 未設定過 LongQueryTime 時,應該要傳回 0
     */
    public function testGetLongQueryTimeInitialValue()
    {
        $this->assertEquals(0, Pix_Table::getLongQueryTime());
    }

    /**
     * 測試 LongQueryTime 是否能正常讀取寫入
     */
    public function testSetLongQueryTime()
    {
        Pix_Table::setLongQueryTime();
        $this->assertEquals(Pix_Table::getLongQueryTime(), 1);

        Pix_Table::setLongQueryTime(100);
        $this->assertEquals(Pix_Table::getLongQueryTime(), 100);

        Pix_Table::setLongQueryTime(0);
        $this->assertEquals(Pix_Table::getLongQueryTime(), 0);

        Pix_Table::setLongQueryTime();
        $this->assertEquals(Pix_Table::getLongQueryTime(), 1);
    }

    /**
     * 測試增加 filter 和取得 filter
     */
    public function testAddFilter()
    {
        $this->assertEquals(count(Pix_Table::getTable('Pix_Table_TableTest_Table')->getFilters()), 0);
        $this->assertEquals(count(Pix_Table::getTable('Pix_Table_TableTest_Table2')->getFilters()), 1);
    }

    /**
     * 測試 ForceMaster 參數的設定和取得
     */
    public function testSetForceMaster()
    {
        Pix_Table::setForceMaster(1);
        $this->assertEquals(Pix_Table::getForceMaster(), 1);

        Pix_Table::setForceMaster(0);
        $this->assertEquals(Pix_Table::getForceMaster(), 0);
    }

    /**
     * 測試 Cache 相關
     */
    public function testSetCache()
    {
        Pix_Table::setCache(null);
        $this->assertEquals(Pix_Table::getCache(), null);

        $cache = new Pix_Cache;
        Pix_Table::setCache($cache);
        $this->assertEquals(Pix_Table::getCache(), $cache);

        Pix_Table::setCache(null);
        $this->assertEquals(Pix_Table::getCache(), null);
    }

    /**
     * 測試 setCache 傳入不正確的東西
     * @expectedException           Pix_Table_Exception
     */
    public function testSetCacheException()
    {
        Pix_Table::setCache(123);
    }

    /**
     * Log Group 狀態
     */
    public function testEnableLog()
    {
        Pix_Table::enableLog(Pix_Table::LOG_CACHE);
        $this->assertEquals(Pix_Table::getLogStatus(Pix_Table::LOG_CACHE), true);

        Pix_Table::disableLog(Pix_Table::LOG_CACHE);
        $this->assertEquals(Pix_Table::getLogStatus(Pix_Table::LOG_CACHE), null);
    }

    /**
     * 設定 CACHE 狀態
     */
    public function testEnableCache()
    {
        Pix_Table::enableCache(Pix_Table::CACHE_ALL);
        $this->assertEquals(Pix_Table::getCacheStatus(Pix_Table::CACHE_ALL), true);

        Pix_Table::disableCache(Pix_Table::CACHE_ALL);
        $this->assertEquals(Pix_Table::getCacheStatus(Pix_Table::CACHE_ALL), null);
    }

    /**
     * 測試 getDb 找不到 Db 應該要 Pix_Table_Exception
     * @expectedException Pix_Table_Exception
     */
    public function testGetDbException()
    {
        Pix_Table::setDefaultDb(null);
        Pix_Table::getTable('Pix_Table_TableTest_Table2')->getDb();
    }

    /**
     * 測試 getDb , 如果 Table 有指定應該要傳回 Table 指定的,沒有就是 default
     */
    public function testGetDb()
    {
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract');
        Pix_Table::setDefaultDb($db);

        $this->assertEquals(Pix_Table::getTable('Pix_Table_TableTest_Table2')->getDb(), $db);
    }

    /**
     * 測試 is_a
     */
    public function testIs_a()
    {
        $this->assertEquals(Pix_Table::is_a('123', 'Pix_Table_TableTest_Table'), false);
        $this->assertEquals(Pix_Table::is_a(123, 'Pix_Table_TableTest_Table'), false);
        $this->assertEquals(Pix_Table::is_a(array(123), 'Pix_Table_TableTest_Table'), false);
        $this->assertEquals(Pix_Table::is_a(new StdClass, 'Pix_Table_TableTest_Table'), false);

        $row = Pix_Table_TableTest_Table::createRow();
        $this->assertEquals(Pix_Table::is_a($row, 'Pix_Table_TableTest_Table'), true);

        $row = Pix_Table_TableTest_Table2::createRow();
        $this->assertEquals(Pix_Table::is_a($row, 'Pix_Table_TableTest_Table2'), true);
    }

    /**
     * Pix_Table::getTable 各種用法
     */
    public function testGetTable()
    {
        $table = Pix_Table_TableTest_Table::getTable();
        $this->assertEquals(get_class($table), 'Pix_Table_TableTest_Table');

        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');
        $this->assertEquals(get_class($table), 'Pix_Table_TableTest_Table');

        $table = Pix_Table::getTable($table);
        $this->assertEquals(get_class($table), 'Pix_Table_TableTest_Table');
    }

    /**
     * 測試 get 不存在的 Table
     * @expectedException Pix_Table_Exception
     */
    public function testGetTableExceptionNotFound()
    {
        Pix_Table::getTable('Pix_Table_TableTest_NotFound');
    }

    /**
     * 測試 get 不存在的 Table
     * @expectedException Pix_Table_Exception
     */
    public function testGetTableExceptionCallStaticFunctionInConstruct()
    {
        Pix_Table::getTable('Pix_Table_TableTest_CallStaticFunctionInConstruct');
    }

    /**
     * 測試連接到 adapter 的部分
     */
    public function testCreateTable()
    {
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('createTable'));
        Pix_Table_TableTest_Table::setDb($db);
        $db->expects($this->once())
            ->method('createTable')
            ->will($this->returnValue(true));
        $this->assertEquals(Pix_Table_TableTest_Table::createTable(), true);
    }

    public function testCheckTable()
    {
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('checkTable', 'support'));
        Pix_Table_TableTest_Table::setDb($db);
        $db->expects($this->once())
            ->method('checkTable')
            ->will($this->returnValue(true));

        $db->expects($this->any())
            ->method('support')
            ->with($this->logicalOr('check_table'))
            ->will($this->returnValue(true));
        $this->assertEquals(Pix_Table_TableTest_Table::checkTable(), true);
    }

    public function testDropTable()
    {
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('dropTable'));
        Pix_Table_TableTest_Table::setDb($db);

        $old_value = Pix_Setting::get('Table:DropTableEnable');
        $db->expects($this->once())
            ->method('dropTable')
            ->will($this->returnValue(true));
        Pix_Setting::set('Table:DropTableEnable', true);
        $this->assertEquals(Pix_Table_TableTest_Table::dropTable(), true);
        Pix_Setting::set('Table:DropTableEnable', $old_value);
    }

    /**
     * 測試未指定 DropTableEnable 必需要 dropTable 失敗
     *
     * @access public
     */
    public function testDropTableProtect()
    {
        $old_value = Pix_Setting::get('Table:DropTableEnable');
        Pix_Setting::set('Table:DropTableEnable', false);
        try {
            Pix_Table_TableTest_Table::dropTable();
            $this->assertTrue(false);
        } catch (Pix_Table_Exception $e) {
            $this->assertTrue(true);
        }
        Pix_Setting::set('Table:DropTableEnable', $old_value);
    }

    public function testSearch()
    {
        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');

        // search(all)
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('fetch'));
        Pix_Table_TableTest_Table::setDb($db);
        $search = Pix_Table_Search::factory()->limit(1);
        $db->expects($this->at(0))
            ->method('fetch')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), $search, '*')
            ->will($this->returnValue(array(array('t1_id' => 3, 'value' => 'abc'))));

        $row = Pix_Table_TableTest_Table::search(1)->first();

        $this->assertEquals($row->t1_id , 3);
        $this->assertEquals($row->value, 'abc');

        // search(array())
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('fetch'));
        Pix_Table_TableTest_Table::setDb($db);
        $search = Pix_Table_Search::factory()->limit(1);
        $search = $search->search(array('value' => 5));
        $db->expects($this->once())
            ->method('fetch')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table', $search, '*'))
            ->will($this->returnValue(array(array('t1_id' => 5, 'value' => '5'))));

        $row = Pix_Table_TableTest_Table::search(array('value' => 5))->first();

        $this->assertEquals($row->t1_id , 5);
        $this->assertEquals($row->value, '5');

        // search(string)
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('fetch'));
        Pix_Table_TableTest_Table::setDb($db);
        $search = Pix_Table_Search::factory();
        $search = $search->search("t1_id > 3");
        $db->expects($this->once())
            ->method('fetch')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), $search, '*')
            ->will($this->returnValue(array(
                    array('t1_id' => 4, 'value' => 4),
                    array('t1_id' => 5, 'value' => 5),
                )));

        $array = Pix_Table_TableTest_Table::search("t1_id > 3")->toArray();

        $this->assertEquals($array, array(
            4 => array('t1_id' => 4, 'value' => 4),
            5 => array('t1_id' => 5, 'value' => 5),
        ));

        // search PK
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('fetchOne'));
        Pix_Table_TableTest_Table::setDb($db);
        $db->expects($this->once())
            ->method('fetchOne')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), array(6))
            ->will($this->returnValue(array('t1_id' => 6, 'value' => 'abc')));

        $row = Pix_Table_TableTest_Table::search(array('t1_id' => 6, 'value' => 'abc'))->first();
        $this->assertEquals($row->t1_id, 6);
        $this->assertEquals($row->value, 'abc');

        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('fetchOne'));
        Pix_Table_TableTest_Table::setDb($db);
        $search = Pix_Table_Search::factory();
        $search = $search->search(array("t1_id" => 7, "value" => "def"));
        $db->expects($this->once())
            ->method('fetchOne')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), array(7))
            ->will($this->returnValue(array('t1_id' => 7, 'value' => 'abc')));

        $row = Pix_Table_TableTest_Table::search(array('t1_id' => 7, 'value' => 'def'))->first();
        $this->assertEquals($row, null);
    }

    public function testFind()
    {
        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('fetchOne'));
        Pix_Table_TableTest_Table::setDb($db);
        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');

        $db->expects($this->at(0))
            ->method('fetchOne')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), array(1))
            ->will($this->returnValue(null));

        $db->expects($this->at(1))
            ->method('fetchOne')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), array(2))
            ->will($this->returnValue(array('t1_id' => 2, 'value' => 'abc')));

        $this->assertEquals(Pix_Table_TableTest_Table::find(1), null);

        $row = Pix_Table_TableTest_Table::find(2);
        $this->assertEquals($row->t1_id, 2);
        $this->assertEquals($row->value, 'abc');

        $row = Pix_Table_TableTest_Table::find(array(2));
        $this->assertEquals($row->t1_id, 2);
        $this->assertEquals($row->value, 'abc');
    }

    public function testFind_by()
    {
        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');

        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('fetch'));
        Pix_Table_TableTest_Table::setDb($db);
        $search = Pix_Table_Search::factory()->limit(1);
        $search = $search->search(array('value' => '999'));
        $db->expects($this->once())
            ->method('fetch')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), $search, '*')
            ->will($this->returnValue(array(
                    array('t1_id' => 8, 'value' => 999),
            )));

        $row = Pix_Table_TableTest_Table::find_by_value(999);
        $this->assertEquals($row->t1_id, 8);
        $this->assertEquals($row->value, 999);
    }

    public function testCreateRow()
    {
        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');

        $db = $this->getMock('Pix_Table_Db_Adapter', array('insertOne', 'support'));
        Pix_Table_TableTest_Table::setDb($db);

        $db->expects($this->once())
            ->method('insertOne')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), array('value' => 3))
            ->will($this->returnValue(10));

        $row = Pix_Table_TableTest_Table::createRow();
        $row->value = 3;
        $row->save();

        $this->assertEquals($row->t1_id, 10);
        $this->assertEquals($row->value, 3);

        $db = $this->getMock('Pix_Table_Db_Adapter', array('insertOne', 'support'));
        Pix_Table_TableTest_Table::setDb($db);

        $db->expects($this->once())
            ->method('insertOne')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), array('value' => 'default'))
            ->will($this->returnValue(11));

        $row = Pix_Table_TableTest_Table::createRow();
        $row->save();

        $this->assertEquals($row->t1_id, 11);
        $this->assertEquals($row->value, 'default');
    }

    public function testInsert()
    {
        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');

        $db = $this->getMock('Pix_Table_Db_Adapter_Abstract', array('insertOne'));
        Pix_Table_TableTest_Table::setDb($db);

        $db->expects($this->once())
            ->method('insertOne')
            ->with($this->isInstanceOf('Pix_Table_TableTest_Table'), array('value' => '999'))
            ->will($this->returnValue(12));

        $row = Pix_Table_TableTest_Table::insert(array('value' => 999));

        $this->assertEquals($row->t1_id, 12);
        $this->assertEquals($row->value, 999);
    }

    public function testGetPrimaryColumns()
    {
        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');
        $this->assertEquals($table->getPrimaryColumns(), array('t1_id'));

        $table = Pix_Table::getTable('Pix_Table_TableTest_Table3');
        $this->assertEquals($table->getPrimaryColumns(), array('t3_id', 't3_id2'));
    }

    public function testIsNumbericColumn()
    {
        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');
        $this->assertEquals($table->isNumbericColumn('t1_id'), true);
        $this->assertEquals($table->isNumbericColumn('value'), false);
    }

    /**
     * 呼叫到不存在的 function
     * @expectedException Pix_Table_Exception
     */
    public function test__callFailed()
    {
        Pix_Table_TableTest_Table::not_exists();
    }

    public function testGetClass()
    {
        $this->assertEquals(Pix_Table::getTable('Pix_Table_TableTest_Table')->getClass(), 'Pix_Table_TableTest_Table');
        $this->assertEquals(Pix_Table::getTable('Pix_Table_TableTest_Table2')->getClass(), 'Pix_Table_TableTest_Table2');
        $this->assertEquals(Pix_Table::getTable('Pix_Table_TableTest_Table3')->getClass(), 'Pix_Table_TableTest_Table3');
    }

    public function testGetRelationForeignTable()
    {
        $this->assertEquals(get_class(Pix_Table_TableTest_Table::getRelationForeignTable('table2')), 'Pix_Table_TableTest_Table2');
        $this->assertEquals(get_class(Pix_Table_TableTest_Table::getRelationForeignTable('table3s')), 'Pix_Table_TableTest_Table3');
    }

    /**
     * 測試 get 不存在的 relation
     * @expectedException Pix_Table_Exception
     */
    public function testGetRelationForeignTableNotFound()
    {
        Pix_Table_TableTest_Table::getRelationForeignTable('relation_not_found');
    }

    /**
     * 測試忘了指定 type 的 relation
     * @expectedException Pix_Table_Exception
     */
    public function testGetRelationForeignTableNoType()
    {
        Pix_Table_TableTest_Table::getRelationForeignTable('table_error');
    }

    public function testGetRelationForeignKeys()
    {
        $this->assertEquals(Pix_Table_TableTest_Table::getRelationForeignKeys('table2'), array('t1_id'));
        $this->assertEquals(Pix_Table_TableTest_Table::getRelationForeignKeys('table3s'), array('t1_id'));
        // A has_one B 未指定的話,預設是 B 的 pk
        $this->assertEquals(Pix_Table_TableTest_Table::getRelationForeignKeys('nf_table2'), array('t2_id'));
        // A has_many B 未指定的話,預設是 A 的 pk
        $this->assertEquals(Pix_Table_TableTest_Table::getRelationForeignKeys('nf_table3s'), array('t1_id'));
    }

    /**
     * 測試 get 不存在的 relation
     * @expectedException Pix_Table_Exception
     */
    public function testGetRelationForeignKeysNotFound()
    {
        Pix_Table_TableTest_Table::getRelationForeignKeys('relation_not_found');
    }

    /**
     * 測試忘了指定 type 的 relation
     * @expectedException Pix_Table_Exception
     */
    public function testGetRelationForeignKeysNoType()
    {
        Pix_Table_TableTest_Table::getRelationForeignKeys('table_error');
    }

    /**
     * 測試忘了指定 has_one or has_many 的 relation
     * @expectedException Pix_Table_Exception
     */
    public function testGetRelationForeignKeysNoRel()
    {
        Pix_Table_TableTest_Table::getRelationForeignKeys('table_error');
    }

    public function testGetTableName()
    {
        $table = Pix_Table::getTable('Pix_Table_TableTest_Table');
        $this->assertEquals($table->getTableName(), 'table');

        $table = Pix_Table::getTable('Pix_Table_TableTest_Table2');
        $this->assertEquals($table->getTableName(), 'table2');
    }

    /**
     * 如果在 __construct 呼叫 $this->xxx() 會 failed 的測試
     * @expectedException Pix_Table_Exception
     */
    public function testGetTableConstructFailed()
    {
        Pix_Table::getTable('Pix_Table_TableTest_TableContstructFailed');
    }

    public function testIsEditableKey()
    {
        // column
        $this->assertEquals(Pix_Table_TableTest_Table::isEditableKey('t1_id'), true);
        // relation
        $this->assertEquals(Pix_Table_TableTest_Table::isEditableKey('table2'), true);
        // hook
        $this->assertEquals(Pix_Table_TableTest_Table::isEditableKey('hook_table2'), true);
        // _
        $this->assertEquals(Pix_Table_TableTest_Table::isEditableKey('_foo'), true);
        // other false
        $this->assertEquals(Pix_Table_TableTest_Table::isEditableKey('not_exists'), false);
    }
}


text:
package org.apache.kafka.streams.processor.internals;

import org.apache.kafka.streams.processor.RecordContext;
import org.apache.kafka.streams.processor.TopicNameExtractor;

/**
 * Static topic name extractor
 */
public class StaticTopicNameExtractor<K, V> implements TopicNameExtractor<K, V> {

    public final String topicName;

    public StaticTopicNameExtractor(final String topicName) {
        this.topicName = topicName;
    }

    public String extract(final K key, final V value, final RecordContext recordContext) {
        return topicName;
    }

    @Override
    public String toString() {
        return "StaticTopicNameExtractor(" + topicName + ")";
    }
}