text:
import mock
from neutron_lib import context
from neutron_lib import exceptions as lib_exc
from neutron_lib.plugins import constants as plugins_constants
from neutron_lib.plugins import directory
from neutron_lib.services.qos import constants as qos_consts
from oslo_config import cfg
from oslo_utils import uuidutils

from neutron.common import constants
from neutron.common import exceptions as n_exc
from neutron import manager
from neutron.objects import base as base_object
from neutron.objects.qos import policy as policy_object
from neutron.objects.qos import rule as rule_object
from neutron.services.qos import qos_plugin
from neutron.tests.unit.services.qos import base

DB_PLUGIN_KLASS = 'neutron.db.db_base_plugin_v2.NeutronDbPluginV2'

class TestQosPlugin(base.BaseQosTestCase):

    def setUp(self):
        super(TestQosPlugin, self).setUp()
        self.setup_coreplugin(load_plugins=False)

        mock.patch('neutron.objects.db.api.create_object').start()
        mock.patch('neutron.objects.db.api.update_object').start()
        mock.patch('neutron.objects.db.api.delete_object').start()
        mock.patch('neutron.objects.db.api.get_object').start()
        _mock_qos_load_attr = mock.patch(
            'neutron.objects.qos.policy.QosPolicy.obj_load_attr')
        self.mock_qos_load_attr = _mock_qos_load_attr.start()
        # We don't use real models as per mocks above. We also need to mock-out
        # methods that work with real data types
        mock.patch(
            'neutron.objects.base.NeutronDbObject.modify_fields_from_db'
        ).start()
        mock.patch.object(policy_object.QosPolicy, 'unset_default').start()
        mock.patch.object(policy_object.QosPolicy, 'set_default').start()

        cfg.CONF.set_override("core_plugin", DB_PLUGIN_KLASS)
        cfg.CONF.set_override("service_plugins", ["qos"])

        manager.init()
        self.qos_plugin = directory.get_plugin(plugins_constants.QOS)

        self.qos_plugin.driver_manager = mock.Mock()

        self.rpc_push = mock.patch('neutron.api.rpc.handlers.resources_rpc'
                                   '.ResourcesPushRpcApi.push').start()

        self.ctxt = context.Context('fake_user', 'fake_tenant')
        mock.patch.object(self.ctxt.session, 'refresh').start()
        mock.patch.object(self.ctxt.session, 'expunge').start()

        self.policy_data = {
            'policy': {'id': uuidutils.generate_uuid(),
                       'project_id': uuidutils.generate_uuid(),
                       'name': 'test-policy',
                       'description': 'Test policy description',
                       'shared': True,
                       'is_default': False}}

        self.rule_data = {
            'bandwidth_limit_rule': {'id': uuidutils.generate_uuid(),
                                     'max_kbps': 100,
                                     'max_burst_kbps': 150},
            'dscp_marking_rule': {'id': uuidutils.generate_uuid(),
                                  'dscp_mark': 16},
            'minimum_bandwidth_rule': {
                'id': uuidutils.generate_uuid(),
                'min_kbps': 10}}

        self.policy = policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])

        self.rule = rule_object.QosBandwidthLimitRule(
            self.ctxt, **self.rule_data['bandwidth_limit_rule'])

        self.dscp_rule = rule_object.QosDscpMarkingRule(
            self.ctxt, **self.rule_data['dscp_marking_rule'])

        self.min_rule = rule_object.QosMinimumBandwidthRule(
            self.ctxt, **self.rule_data['minimum_bandwidth_rule'])

    def _validate_driver_params(self, method_name):
        self.assertTrue(self.qos_plugin.driver_manager.call.called)
        self.assertEqual(self.qos_plugin.driver_manager.call.call_args[0][0],
                         method_name)
        self.assertIsInstance(
            self.qos_plugin.driver_manager.call.call_args[0][2],
            policy_object.QosPolicy
        )

    def test_get_ports_with_policy(self):
        network_ports = [
            mock.MagicMock(qos_policy_id=None),
            mock.MagicMock(qos_policy_id=uuidutils.generate_uuid()),
            mock.MagicMock(qos_policy_id=None)
        ]
        ports = [
            mock.MagicMock(qos_policy_id=self.policy.id),
        ]
        expected_network_ports = [
            port for port in network_ports if port.qos_policy_id is None]
        expected_ports = ports + expected_network_ports
        with mock.patch(
            'neutron.objects.ports.Port.get_objects',
            side_effect=[network_ports, ports]
        ), mock.patch.object(
            self.policy, "get_bound_networks"
        ), mock.patch.object(
            self.policy, "get_bound_ports"
        ):
            policy_ports = self.qos_plugin._get_ports_with_policy(
                self.ctxt, self.policy)
            self.assertEqual(
                len(expected_ports), len(policy_ports))
            for port in expected_ports:
                self.assertIn(port, policy_ports)

    def _test_validate_create_port_callback(self, policy_id=None,
                                            network_policy_id=None):
        port_id = uuidutils.generate_uuid()
        kwargs = {
            "context": self.ctxt,
            "port": {"id": port_id}
        }
        port_mock = mock.MagicMock(id=port_id, qos_policy_id=policy_id)
        network_mock = mock.MagicMock(
            id=uuidutils.generate_uuid(), qos_policy_id=network_policy_id)
        policy_mock = mock.MagicMock(id=policy_id)
        expected_policy_id = policy_id or network_policy_id
        with mock.patch(
            'neutron.objects.ports.Port.get_object',
            return_value=port_mock
        ), mock.patch(
            'neutron.objects.network.Network.get_object',
            return_value=network_mock
        ), mock.patch(
            'neutron.objects.qos.policy.QosPolicy.get_object',
            return_value=policy_mock
        ) as get_policy, mock.patch.object(
            self.qos_plugin, "validate_policy_for_port"
        ) as validate_policy_for_port:
            self.qos_plugin._validate_create_port_callback(
                "PORT", "precommit_create", "test_plugin", **kwargs)
            if policy_id or network_policy_id:
                get_policy.assert_called_once_with(self.ctxt,
                                                   id=expected_policy_id)
                validate_policy_for_port.assert_called_once_with(policy_mock,
                                                                 port_mock)
            else:
                get_policy.assert_not_called()
                validate_policy_for_port.assert_not_called()

    def test_validate_create_port_callback_policy_on_port(self):
        self._test_validate_create_port_callback(
            policy_id=uuidutils.generate_uuid())

    def test_validate_create_port_callback_policy_on_port_and_network(self):
        self._test_validate_create_port_callback(
            policy_id=uuidutils.generate_uuid(),
            network_policy_id=uuidutils.generate_uuid())

    def test_validate_create_port_callback_policy_on_network(self):
        self._test_validate_create_port_callback(
            network_policy_id=uuidutils.generate_uuid())

    def test_validate_create_port_callback_no_policy(self):
        self._test_validate_create_port_callback()

    def _test_validate_update_port_callback(self, policy_id=None,
                                            original_policy_id=None):
        port_id = uuidutils.generate_uuid()
        kwargs = {
            "context": self.ctxt,
            "port": {
                "id": port_id,
                qos_consts.QOS_POLICY_ID: policy_id
            },
            "original_port": {
                "id": port_id,
                qos_consts.QOS_POLICY_ID: original_policy_id
            }
        }
        port_mock = mock.MagicMock(id=port_id, qos_policy_id=policy_id)
        policy_mock = mock.MagicMock(id=policy_id)
        with mock.patch(
            'neutron.objects.ports.Port.get_object',
            return_value=port_mock
        ) as get_port, mock.patch(
            'neutron.objects.qos.policy.QosPolicy.get_object',
            return_value=policy_mock
        ) as get_policy, mock.patch.object(
            self.qos_plugin, "validate_policy_for_port"
        ) as validate_policy_for_port:
            self.qos_plugin._validate_update_port_callback(
                "PORT", "precommit_update", "test_plugin", **kwargs)
            if policy_id is None or policy_id == original_policy_id:
                get_port.assert_not_called()
                get_policy.assert_not_called()
                validate_policy_for_port.assert_not_called()
            else:
                get_port.assert_called_once_with(self.ctxt, id=port_id)
                get_policy.assert_called_once_with(self.ctxt, id=policy_id)
                validate_policy_for_port.assert_called_once_with(policy_mock,
                                                                 port_mock)

    def test_validate_update_port_callback_policy_changed(self):
        self._test_validate_update_port_callback(
            policy_id=uuidutils.generate_uuid())

    def test_validate_update_port_callback_policy_not_changed(self):
        policy_id = uuidutils.generate_uuid()
        self._test_validate_update_port_callback(
            policy_id=policy_id, original_policy_id=policy_id)

    def test_validate_update_port_callback_policy_removed(self):
        self._test_validate_update_port_callback(
            policy_id=None, original_policy_id=uuidutils.generate_uuid())

    def _test_validate_update_network_callback(self, policy_id=None,
                                               original_policy_id=None):
        network_id = uuidutils.generate_uuid()
        kwargs = {
            "context": self.ctxt,
            "network": {
                "id": network_id,
                qos_consts.QOS_POLICY_ID: policy_id
            },
            "original_network": {
                "id": network_id,
                qos_consts.QOS_POLICY_ID: original_policy_id
            }
        }
        port_mock_with_own_policy = mock.MagicMock(
            id=uuidutils.generate_uuid(),
            qos_policy_id=uuidutils.generate_uuid())
        port_mock_without_own_policy = mock.MagicMock(
            id=uuidutils.generate_uuid(), qos_policy_id=None)
        ports = [port_mock_with_own_policy, port_mock_without_own_policy]
        policy_mock = mock.MagicMock(id=policy_id)
        with mock.patch(
            'neutron.objects.ports.Port.get_objects',
            return_value=ports
        ) as get_ports, mock.patch(
            'neutron.objects.qos.policy.QosPolicy.get_object',
            return_value=policy_mock
        ) as get_policy, mock.patch.object(
            self.qos_plugin, "validate_policy_for_ports"
        ) as validate_policy_for_ports:
            self.qos_plugin._validate_update_network_callback(
                "NETWORK", "precommit_update", "test_plugin", **kwargs)
            if policy_id is None or policy_id == original_policy_id:
                get_policy.assert_not_called()
                get_ports.assert_not_called()
                validate_policy_for_ports.assert_not_called()
            else:
                get_policy.assert_called_once_with(self.ctxt, id=policy_id)
                get_ports.assert_called_once_with(self.ctxt,
                                                  network_id=network_id)
                validate_policy_for_ports.assert_called_once_with(
                    policy_mock, [port_mock_without_own_policy])

    def test_validate_update_network_callback_policy_changed(self):
        self._test_validate_update_network_callback(
            policy_id=uuidutils.generate_uuid())

    def test_validate_update_network_callback_policy_not_changed(self):
        policy_id = uuidutils.generate_uuid()
        self._test_validate_update_network_callback(
            policy_id=policy_id, original_policy_id=policy_id)

    def test_validate_update_network_callback_policy_removed(self):
        self._test_validate_update_network_callback(
            policy_id=None, original_policy_id=uuidutils.generate_uuid())

    def test_validate_policy_for_port_rule_not_valid(self):
        port = {'id': uuidutils.generate_uuid()}
        with mock.patch.object(
            self.qos_plugin.driver_manager, "validate_rule_for_port",
            return_value=False
        ):
            self.policy.rules = [self.rule]
            self.assertRaises(
                n_exc.QosRuleNotSupported,
                self.qos_plugin.validate_policy_for_port,
                self.policy, port)

    def test_validate_policy_for_port_all_rules_valid(self):
        port = {'id': uuidutils.generate_uuid()}
        with mock.patch.object(
            self.qos_plugin.driver_manager, "validate_rule_for_port",
            return_value=True
        ):
            self.policy.rules = [self.rule]
            try:
                self.qos_plugin.validate_policy_for_port(self.policy, port)
            except n_exc.QosRuleNotSupported:
                self.fail("QosRuleNotSupported exception unexpectedly raised")

    @mock.patch(
        'neutron.objects.rbac_db.RbacNeutronDbObjectMixin'
        '.create_rbac_policy')
    @mock.patch('neutron.objects.qos.policy.QosPolicy')
    def test_add_policy(self, mock_qos_policy, mock_create_rbac_policy):
        mock_manager = mock.Mock()
        mock_manager.attach_mock(mock_qos_policy, 'QosPolicy')
        mock_manager.attach_mock(self.qos_plugin.driver_manager, 'driver')
        mock_manager.reset_mock()

        self.qos_plugin.create_policy(self.ctxt, self.policy_data)

        policy_mock_call = mock.call.QosPolicy().create()
        create_precommit_mock_call = mock.call.driver.call(
            'create_policy_precommit', self.ctxt, mock.ANY)
        create_mock_call = mock.call.driver.call(
            'create_policy', self.ctxt, mock.ANY)
        self.assertTrue(
            mock_manager.mock_calls.index(policy_mock_call) <
            mock_manager.mock_calls.index(create_precommit_mock_call) <
            mock_manager.mock_calls.index(create_mock_call))

    def test_add_policy_with_extra_tenant_keyword(self, *mocks):
        policy_id = uuidutils.generate_uuid()
        project_id = uuidutils.generate_uuid()
        tenant_policy = {
            'policy': {'id': policy_id,
                       'project_id': project_id,
                       'tenant_id': project_id,
                       'name': 'test-policy',
                       'description': 'Test policy description',
                       'shared': True,
                       'is_default': False}}

        policy_details = {'id': policy_id,
                          'project_id': project_id,
                          'name': 'test-policy',
                          'description': 'Test policy description',
                          'shared': True,
                          'is_default': False}

        with mock.patch('neutron.objects.qos.policy.QosPolicy') as QosMocked:
            self.qos_plugin.create_policy(self.ctxt, tenant_policy)

        QosMocked.assert_called_once_with(self.ctxt, **policy_details)

    @mock.patch.object(policy_object.QosPolicy, "get_object")
    @mock.patch(
        'neutron.objects.rbac_db.RbacNeutronDbObjectMixin'
        '.create_rbac_policy')
    @mock.patch.object(policy_object.QosPolicy, 'update')
    def test_update_policy(self, mock_qos_policy_update,
                           mock_create_rbac_policy, mock_qos_policy_get):
        mock_qos_policy_get.return_value = self.policy
        mock_manager = mock.Mock()
        mock_manager.attach_mock(mock_qos_policy_update, 'update')
        mock_manager.attach_mock(self.qos_plugin.driver_manager, 'driver')
        mock_manager.reset_mock()

        fields = base_object.get_updatable_fields(
            policy_object.QosPolicy, self.policy_data['policy'])
        self.qos_plugin.update_policy(
            self.ctxt, self.policy.id, {'policy': fields})
        self._validate_driver_params('update_policy')

        policy_update_mock_call = mock.call.update()
        update_precommit_mock_call = mock.call.driver.call(
            'update_policy_precommit', self.ctxt, mock.ANY)
        update_mock_call = mock.call.driver.call(
            'update_policy', self.ctxt, mock.ANY)
        self.assertTrue(
            mock_manager.mock_calls.index(policy_update_mock_call) <
            mock_manager.mock_calls.index(update_precommit_mock_call) <
            mock_manager.mock_calls.index(update_mock_call))

    @mock.patch('neutron.objects.db.api.get_object', return_value=None)
    @mock.patch.object(policy_object.QosPolicy, 'delete')
    def test_delete_policy(self, mock_qos_policy_delete, mock_api_get_policy):
        mock_manager = mock.Mock()
        mock_manager.attach_mock(mock_qos_policy_delete, 'delete')
        mock_manager.attach_mock(self.qos_plugin.driver_manager, 'driver')
        mock_manager.reset_mock()

        self.qos_plugin.delete_policy(self.ctxt, self.policy.id)
        self._validate_driver_params('delete_policy')

        policy_delete_mock_call = mock.call.delete()
        delete_precommit_mock_call = mock.call.driver.call(
            'delete_policy_precommit', self.ctxt, mock.ANY)
        delete_mock_call = mock.call.driver.call(
            'delete_policy', self.ctxt, mock.ANY)
        self.assertTrue(
            mock_manager.mock_calls.index(policy_delete_mock_call) <
            mock_manager.mock_calls.index(delete_precommit_mock_call) <
            mock_manager.mock_calls.index(delete_mock_call))

    def test_create_policy_rule(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy), mock.patch(
            'neutron.objects.qos.qos_policy_validator'
            '.check_bandwidth_rule_conflict', return_value=None):
            self.qos_plugin.create_policy_bandwidth_limit_rule(
                self.ctxt, self.policy.id, self.rule_data)
            self._validate_driver_params('update_policy')

    def test_create_policy_rule_check_rule_min_less_than_max(self):
        _policy = self._get_policy()
        setattr(_policy, "rules", [self.rule])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy) as mock_qos_get_obj:
            self.qos_plugin.create_policy_minimum_bandwidth_rule(
                self.ctxt, _policy.id, self.rule_data)
            self._validate_driver_params('update_policy')
            self.mock_qos_load_attr.assert_called_once_with('rules')
            mock_qos_get_obj.assert_called_once_with(self.ctxt, id=_policy.id)

    def test_create_policy_rule_check_rule_max_more_than_min(self):
        _policy = self._get_policy()
        setattr(_policy, "rules", [self.min_rule])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy) as mock_qos_get_obj:
            self.qos_plugin.create_policy_bandwidth_limit_rule(
                self.ctxt, _policy.id, self.rule_data)
            self._validate_driver_params('update_policy')
            self.mock_qos_load_attr.assert_called_once_with('rules')
            mock_qos_get_obj.assert_called_once_with(self.ctxt, id=_policy.id)

    def test_create_policy_rule_check_rule_bwlimit_less_than_minbw(self):
        _policy = self._get_policy()
        self.rule_data['bandwidth_limit_rule']['max_kbps'] = 1
        setattr(_policy, "rules", [self.min_rule])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy) as mock_qos_get_obj:
            self.assertRaises(n_exc.QoSRuleParameterConflict,
                self.qos_plugin.create_policy_bandwidth_limit_rule,
                self.ctxt, self.policy.id, self.rule_data)
            mock_qos_get_obj.assert_called_once_with(self.ctxt, id=_policy.id)

    def test_create_policy_rule_check_rule_minbw_gr_than_bwlimit(self):
        _policy = self._get_policy()
        self.rule_data['minimum_bandwidth_rule']['min_kbps'] = 1000000
        setattr(_policy, "rules", [self.rule])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy) as mock_qos_get_obj:
            self.assertRaises(n_exc.QoSRuleParameterConflict,
                self.qos_plugin.create_policy_minimum_bandwidth_rule,
                self.ctxt, self.policy.id, self.rule_data)
            mock_qos_get_obj.assert_called_once_with(self.ctxt, id=_policy.id)

    @mock.patch.object(rule_object.QosBandwidthLimitRule, 'update')
    def test_update_policy_rule(self, mock_qos_rule_update):
        mock_manager = mock.Mock()
        mock_manager.attach_mock(mock_qos_rule_update, 'update')
        mock_manager.attach_mock(self.qos_plugin.driver_manager, 'driver')
        mock_manager.reset_mock()

        _policy = policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            setattr(_policy, "rules", [self.rule])
            self.qos_plugin.update_policy_bandwidth_limit_rule(
                self.ctxt, self.rule.id, self.policy.id, self.rule_data)
            self._validate_driver_params('update_policy')

            rule_update_mock_call = mock.call.update()
            update_precommit_mock_call = mock.call.driver.call(
                'update_policy_precommit', self.ctxt, mock.ANY)
            update_mock_call = mock.call.driver.call(
                'update_policy', self.ctxt, mock.ANY)
            self.assertTrue(
                mock_manager.mock_calls.index(rule_update_mock_call) <
                mock_manager.mock_calls.index(update_precommit_mock_call) <
                mock_manager.mock_calls.index(update_mock_call))

    def test_update_policy_rule_check_rule_min_less_than_max(self):
        _policy = self._get_policy()
        setattr(_policy, "rules", [self.rule])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            self.qos_plugin.update_policy_bandwidth_limit_rule(
                self.ctxt, self.rule.id, self.policy.id, self.rule_data)
            self.mock_qos_load_attr.assert_called_once_with('rules')
            self._validate_driver_params('update_policy')

        rules = [self.rule, self.min_rule]
        setattr(_policy, "rules", rules)
        self.mock_qos_load_attr.reset_mock()
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            self.qos_plugin.update_policy_minimum_bandwidth_rule(
                self.ctxt, self.min_rule.id,
                self.policy.id, self.rule_data)
            self.mock_qos_load_attr.assert_called_once_with('rules')
            self._validate_driver_params('update_policy')

    def test_update_policy_rule_check_rule_bwlimit_less_than_minbw(self):
        _policy = self._get_policy()
        setattr(_policy, "rules", [self.rule])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            self.qos_plugin.update_policy_bandwidth_limit_rule(
                self.ctxt, self.rule.id, self.policy.id, self.rule_data)
            self.mock_qos_load_attr.assert_called_once_with('rules')
            self._validate_driver_params('update_policy')
        self.rule_data['minimum_bandwidth_rule']['min_kbps'] = 1000
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            self.assertRaises(
                n_exc.QoSRuleParameterConflict,
                self.qos_plugin.update_policy_minimum_bandwidth_rule,
                self.ctxt, self.min_rule.id,
                self.policy.id, self.rule_data)

    def test_update_policy_rule_check_rule_minbw_gr_than_bwlimit(self):
        _policy = self._get_policy()
        setattr(_policy, "rules", [self.min_rule])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            self.qos_plugin.update_policy_minimum_bandwidth_rule(
                self.ctxt, self.min_rule.id, self.policy.id, self.rule_data)
            self.mock_qos_load_attr.assert_called_once_with('rules')
            self._validate_driver_params('update_policy')
        self.rule_data['bandwidth_limit_rule']['max_kbps'] = 1
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            self.assertRaises(
                n_exc.QoSRuleParameterConflict,
                self.qos_plugin.update_policy_bandwidth_limit_rule,
                self.ctxt, self.rule.id,
                self.policy.id, self.rule_data)

    def _get_policy(self):
        return policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])

    def test_update_policy_rule_bad_policy(self):
        _policy = policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            setattr(_policy, "rules", [])
            self.assertRaises(
                n_exc.QosRuleNotFound,
                self.qos_plugin.update_policy_bandwidth_limit_rule,
                self.ctxt, self.rule.id, self.policy.id,
                self.rule_data)

    @mock.patch.object(rule_object.QosBandwidthLimitRule, 'delete')
    def test_delete_policy_rule(self, mock_qos_rule_delete):
        mock_manager = mock.Mock()
        mock_manager.attach_mock(mock_qos_rule_delete, 'delete')
        mock_manager.attach_mock(self.qos_plugin.driver_manager, 'driver')
        mock_manager.reset_mock()

        _policy = policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            setattr(_policy, "rules", [self.rule])
            self.qos_plugin.delete_policy_bandwidth_limit_rule(
                        self.ctxt, self.rule.id, _policy.id)
            self._validate_driver_params('update_policy')

            rule_delete_mock_call = mock.call.delete()
            update_precommit_mock_call = mock.call.driver.call(
                'update_policy_precommit', self.ctxt, mock.ANY)
            update_mock_call = mock.call.driver.call(
                'update_policy', self.ctxt, mock.ANY)
            self.assertTrue(
                mock_manager.mock_calls.index(rule_delete_mock_call) <
                mock_manager.mock_calls.index(update_precommit_mock_call) <
                mock_manager.mock_calls.index(update_mock_call))

    def test_delete_policy_rule_bad_policy(self):
        _policy = policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            setattr(_policy, "rules", [])
            self.assertRaises(
                n_exc.QosRuleNotFound,
                self.qos_plugin.delete_policy_bandwidth_limit_rule,
                self.ctxt, self.rule.id, _policy.id)

    def test_get_policy_bandwidth_limit_rule(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy):
            with mock.patch('neutron.objects.qos.rule.'
                            'QosBandwidthLimitRule.'
                            'get_object') as get_object_mock:
                self.qos_plugin.get_policy_bandwidth_limit_rule(
                    self.ctxt, self.rule.id, self.policy.id)
                get_object_mock.assert_called_once_with(self.ctxt,
                    id=self.rule.id)

    def test_get_policy_bandwidth_limit_rules_for_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy):
            with mock.patch('neutron.objects.qos.rule.'
                            'QosBandwidthLimitRule.'
                            'get_objects') as get_objects_mock:
                self.qos_plugin.get_policy_bandwidth_limit_rules(
                    self.ctxt, self.policy.id)
                get_objects_mock.assert_called_once_with(
                    self.ctxt, _pager=mock.ANY, qos_policy_id=self.policy.id)

    def test_get_policy_bandwidth_limit_rules_for_policy_with_filters(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy):
            with mock.patch('neutron.objects.qos.rule.'
                            'QosBandwidthLimitRule.'
                            'get_objects') as get_objects_mock:

                filters = {'filter': 'filter_id'}
                self.qos_plugin.get_policy_bandwidth_limit_rules(
                    self.ctxt, self.policy.id, filters=filters)
                get_objects_mock.assert_called_once_with(
                    self.ctxt, _pager=mock.ANY,
                    qos_policy_id=self.policy.id,
                    filter='filter_id')

    def test_get_policy_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.get_policy,
                self.ctxt, self.policy.id)

    def test_get_policy_bandwidth_limit_rule_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.get_policy_bandwidth_limit_rule,
                self.ctxt, self.rule.id, self.policy.id)

    def test_get_policy_bandwidth_limit_rules_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.get_policy_bandwidth_limit_rules,
                self.ctxt, self.policy.id)

    def test_create_policy_dscp_marking_rule(self):
        _policy = policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            setattr(_policy, "rules", [self.dscp_rule])
            self.qos_plugin.create_policy_dscp_marking_rule(
                self.ctxt, self.policy.id, self.rule_data)
            self._validate_driver_params('update_policy')

    def test_update_policy_dscp_marking_rule(self):
        _policy = policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            setattr(_policy, "rules", [self.dscp_rule])
            self.qos_plugin.update_policy_dscp_marking_rule(
                self.ctxt, self.dscp_rule.id, self.policy.id, self.rule_data)
            self._validate_driver_params('update_policy')

    def test_delete_policy_dscp_marking_rule(self):
        _policy = policy_object.QosPolicy(
            self.ctxt, **self.policy_data['policy'])
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=_policy):
            setattr(_policy, "rules", [self.dscp_rule])
            self.qos_plugin.delete_policy_dscp_marking_rule(
                self.ctxt, self.dscp_rule.id, self.policy.id)
            self._validate_driver_params('update_policy')

    def test_get_policy_dscp_marking_rules(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy):
            with mock.patch('neutron.objects.qos.rule.'
                            'QosDscpMarkingRule.'
                            'get_objects') as get_objects_mock:
                self.qos_plugin.get_policy_dscp_marking_rules(
                    self.ctxt, self.policy.id)
                get_objects_mock.assert_called_once_with(
                    self.ctxt, _pager=mock.ANY, qos_policy_id=self.policy.id)

    def test_get_policy_dscp_marking_rules_for_policy_with_filters(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy):
            with mock.patch('neutron.objects.qos.rule.'
                            'QosDscpMarkingRule.'
                            'get_objects') as get_objects_mock:

                filters = {'filter': 'filter_id'}
                self.qos_plugin.get_policy_dscp_marking_rules(
                    self.ctxt, self.policy.id, filters=filters)
                get_objects_mock.assert_called_once_with(
                    self.ctxt, qos_policy_id=self.policy.id,
                    _pager=mock.ANY, filter='filter_id')

    def test_get_policy_dscp_marking_rule_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.get_policy_dscp_marking_rule,
                self.ctxt, self.dscp_rule.id, self.policy.id)

    def test_get_policy_dscp_marking_rules_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.get_policy_dscp_marking_rules,
                self.ctxt, self.policy.id)

    def test_get_policy_minimum_bandwidth_rule(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy):
            with mock.patch('neutron.objects.qos.rule.'
                            'QosMinimumBandwidthRule.'
                            'get_object') as get_object_mock:
                self.qos_plugin.get_policy_minimum_bandwidth_rule(
                    self.ctxt, self.rule.id, self.policy.id)
                get_object_mock.assert_called_once_with(self.ctxt,
                    id=self.rule.id)

    def test_get_policy_minimum_bandwidth_rules_for_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy):
            with mock.patch('neutron.objects.qos.rule.'
                            'QosMinimumBandwidthRule.'
                            'get_objects') as get_objects_mock:
                self.qos_plugin.get_policy_minimum_bandwidth_rules(
                    self.ctxt, self.policy.id)
                get_objects_mock.assert_called_once_with(
                    self.ctxt, _pager=mock.ANY, qos_policy_id=self.policy.id)

    def test_get_policy_minimum_bandwidth_rules_for_policy_with_filters(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=self.policy):
            with mock.patch('neutron.objects.qos.rule.'
                            'QosMinimumBandwidthRule.'
                            'get_objects') as get_objects_mock:

                filters = {'filter': 'filter_id'}
                self.qos_plugin.get_policy_minimum_bandwidth_rules(
                    self.ctxt, self.policy.id, filters=filters)
                get_objects_mock.assert_called_once_with(
                    self.ctxt, _pager=mock.ANY,
                    qos_policy_id=self.policy.id,
                    filter='filter_id')

    def test_get_policy_minimum_bandwidth_rule_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.get_policy_minimum_bandwidth_rule,
                self.ctxt, self.rule.id, self.policy.id)

    def test_get_policy_minimum_bandwidth_rules_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.get_policy_minimum_bandwidth_rules,
                self.ctxt, self.policy.id)

    def test_create_policy_rule_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.create_policy_bandwidth_limit_rule,
                self.ctxt, self.policy.id, self.rule_data)

    def test_update_policy_rule_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.update_policy_bandwidth_limit_rule,
                self.ctxt, self.rule.id, self.policy.id, self.rule_data)

    def test_delete_policy_rule_for_nonexistent_policy(self):
        with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
                        return_value=None):
            self.assertRaises(
                n_exc.QosPolicyNotFound,
                self.qos_plugin.delete_policy_bandwidth_limit_rule,
                self.ctxt, self.rule.id, self.policy.id)

    def test_verify_bad_method_call(self):
        self.assertRaises(AttributeError, getattr, self.qos_plugin,
                          'create_policy_bandwidth_limit_rules')

    def test_get_rule_type(self):
        admin_ctxt = context.get_admin_context()
        drivers_details = [{
            'name': 'fake-driver',
            'supported_parameters': [{
                'parameter_name': 'max_kbps',
                'parameter_type': constants.VALUES_TYPE_RANGE,
                'parameter_range': {'start': 0, 'end': 100}
            }]
        }]
        with mock.patch.object(
            qos_plugin.QoSPlugin, "supported_rule_type_details",
            return_value=drivers_details
        ):
            rule_type_details = self.qos_plugin.get_rule_type(
                admin_ctxt, qos_consts.RULE_TYPE_BANDWIDTH_LIMIT)
            self.assertEqual(
                qos_consts.RULE_TYPE_BANDWIDTH_LIMIT,
                rule_type_details['type'])
            self.assertEqual(
                drivers_details, rule_type_details['drivers'])

    def test_get_rule_type_as_user(self):
        self.assertRaises(
            lib_exc.NotAuthorized,
            self.qos_plugin.get_rule_type,
            self.ctxt, qos_consts.RULE_TYPE_BANDWIDTH_LIMIT)

    def test_get_rule_types(self):
        rule_types_mock = mock.PropertyMock(
            return_value=qos_consts.VALID_RULE_TYPES)
        filters = {'type': 'type_id'}
        with mock.patch.object(qos_plugin.QoSPlugin, 'supported_rule_types',
                               new_callable=rule_types_mock):
            types = self.qos_plugin.get_rule_types(self.ctxt, filters=filters)
            self.assertEqual(sorted(qos_consts.VALID_RULE_TYPES),
                             sorted(type_['type'] for type_ in types))

    @mock.patch('neutron.objects.ports.Port')
    @mock.patch('neutron.objects.qos.policy.QosPolicy')
    def test_rule_notification_and_driver_ordering(self, qos_policy_mock,
                                                   port_mock):
        rule_cls_mock = mock.Mock()
        rule_cls_mock.rule_type = 'fake'

        rule_actions = {'create': [self.ctxt, rule_cls_mock,
                                   self.policy.id, {'fake_rule': {}}],
                        'update': [self.ctxt, rule_cls_mock,
                                   self.rule.id,
                                   self.policy.id, {'fake_rule': {}}],
                        'delete': [self.ctxt, rule_cls_mock,
                                   self.rule.id, self.policy.id]}

        mock_manager = mock.Mock()
        mock_manager.attach_mock(qos_policy_mock, 'QosPolicy')
        mock_manager.attach_mock(port_mock, 'Port')
        mock_manager.attach_mock(rule_cls_mock, 'RuleCls')
        mock_manager.attach_mock(self.qos_plugin.driver_manager, 'driver')

        for action, arguments in rule_actions.items():
            mock_manager.reset_mock()
            method = getattr(self.qos_plugin, "%s_policy_rule" % action)
            method(*arguments)

            # some actions get rule from policy
            get_rule_mock_call = getattr(
                mock.call.QosPolicy.get_object().get_rule_by_id(), action)()
            # some actions construct rule from class reference
            rule_mock_call = getattr(mock.call.RuleCls(), action)()

            driver_mock_call = mock.call.driver.call('update_policy',
                                                     self.ctxt, mock.ANY)

            if rule_mock_call in mock_manager.mock_calls:
                action_index = mock_manager.mock_calls.index(rule_mock_call)
            else:
                action_index = mock_manager.mock_calls.index(
                    get_rule_mock_call)

            self.assertTrue(
                action_index < mock_manager.mock_calls.index(driver_mock_call))


text:
cask 'phonebrowse' do
  version :latest
  sha256 :no_check

  url 'https://www.imobie.com/product/phonebrowse-mac.dmg'
  name 'PhoneBrowse'
  homepage 'https://www.imobie.com/phonebrowse/'

  app 'PhoneBrowse.app'
end

redpajama_set_name: RedPajamaGithub


text:
package com.example.zjy.controller;

import com.example.zjy.bean.HeadAndTabBean;
import com.example.zjy.fragment.community.api.ServiceAccessor;
import com.example.zjy.rxhelper.RxCallBack;
import com.example.zjy.rxhelper.RxSubscriber;
import com.example.zjy.util.ParseJsonUtils;

import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;

/**
 * Created by zjy on 2017/4/12.
 */

public class HeadController extends BaseRxController {
    public HeadController() {
    }

    public Subscription head(String url, final RxCallBack<HeadAndTabBean> rxCallBack) {
        return rxAdd(ServiceAccessor.getService()
                .getModel(url)
                .subscribeOn(Schedulers.io())
                .map(new Func1<String, HeadAndTabBean>() {
                    @Override
                    public HeadAndTabBean call(String s) {
                        return ParseJsonUtils.parse(s);
                    }
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new RxSubscriber<HeadAndTabBean>(rxCallBack) {
                    @Override
                    public void _onNext(HeadAndTabBean headAndTabBean) {
                        rxCallBack.onNext(headAndTabBean);
                    }

                    @Override
                    public void _onError(String msg, Throwable e) {
                        rxCallBack.onError(msg, e);
                    }
                }));
    }

}


text:
<?php

namespace Zend\Db\Sql;

use Countable;
use Iterator;

/**
 * Aggregate JOIN specifications.
 *
 * Each specification is an array with the following keys:
 *
 * - name: the JOIN name
 * - on: the table on which the JOIN occurs
 * - columns: the columns to include with the JOIN operation; defaults to
 *   `Select::SQL_STAR`.
 * - type: the type of JOIN being performed; see the `JOIN_*` constants;
 *   defaults to `JOIN_INNER`
 */
class Join implements Iterator, Countable
{
    const JOIN_INNER       = 'inner';
    const JOIN_OUTER       = 'outer';
    const JOIN_LEFT        = 'left';
    const JOIN_RIGHT       = 'right';
    const JOIN_RIGHT_OUTER = 'right outer';
    const JOIN_LEFT_OUTER  = 'left outer';

    /**
     * Current iterator position.
     *
     * @var int
     */
    private $position = 0;

    /**
     * JOIN specifications
     *
     * @var array
     */
    protected $joins = [];

    /**
     * Initialize iterator position.
     */
    public function __construct()
    {
        $this->position = 0;
    }

    /**
     * Rewind iterator.
     */
    public function rewind()
    {
        $this->position = 0;
    }

    /**
     * Return current join specification.
     *
     * @return array
     */
    public function current()
    {
        return $this->joins[$this->position];
    }

    /**
     * Return the current iterator index.
     *
     * @return int
     */
    public function key()
    {
        return $this->position;
    }

    /**
     * Advance to the next JOIN specification.
     */
    public function next()
    {
        ++$this->position;
    }

    /**
     * Is the iterator at a valid position?
     *
     * @return bool
     */
    public function valid()
    {
        return isset($this->joins[$this->position]);
    }

    /**
     * @return array
     */
    public function getJoins()
    {
        return $this->joins;
    }

    /**
     * @param string|array|TableIdentifier $name A table name on which to join, or a single
     *     element associative array, of the form alias => table, or TableIdentifier instance
     * @param string $on A string specification describing the fields to join on.
     * @param string|string[]|int|int[] $columns A single column name, an array
     *     of column names, or (a) specification(s) such as SQL_STAR representing
     *     the columns to join.
     * @param string $type The JOIN type to use; see the JOIN_* constants.
     * @return self Provides a fluent interface
     * @throws Exception\InvalidArgumentException for invalid $name values.
     */
    public function join($name, $on, $columns = [Select::SQL_STAR], $type = Join::JOIN_INNER)
    {
        if (is_array($name) && (! is_string(key($name)) || count($name) !== 1)) {
            throw new Exception\InvalidArgumentException(
                sprintf("join() expects '%s' as a single element associative array", array_shift($name))
            );
        }

        if (! is_array($columns)) {
            $columns = [$columns];
        }

        $this->joins[] = [
            'name'    => $name,
            'on'      => $on,
            'columns' => $columns,
            'type'    => $type ? $type : Join::JOIN_INNER
        ];

        return $this;
    }

    /**
     * Reset to an empty list of JOIN specifications.
     *
     * @return self Provides a fluent interface
     */
    public function reset()
    {
        $this->joins = [];
        return $this;
    }

    /**
     * Get count of attached predicates
     *
     * @return int
     */
    public function count()
    {
        return count($this->joins);
    }
}


text:
'use strict';

// MODULES //

var constantFunction = require( '@stdlib/utils/constant-function' );
var degenerate = require( '@stdlib/stats/base/dists/degenerate/cdf' ).factory;
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var exp = require( '@stdlib/math/base/special/exp' );
var pow = require( '@stdlib/math/base/special/pow' );

// MAIN //

/**
* Returns a function for evaluating the cumulative distribution function (CDF) for a Rayleigh distribution with scale parameter `sigma`.
*
* @param {NonNegativeNumber} sigma - scale parameter
* @returns {Function} CDF
*
* @example
* var cdf = factory( 2.0 );
* var y = cdf( 3.0 );
* // returns ~0.675
*
* y = cdf( 1.0 );
* // returns ~0.118
*/
function factory( sigma ) {
	var s2;
	if ( isnan( sigma ) || sigma < 0.0 ) {
		return constantFunction( NaN );
	}
	if ( sigma === 0.0 ) {
		return degenerate( 0.0 );
	}
	s2 = pow( sigma, 2.0 );
	return cdf;

	/**
	* Evaluates the cumulative distribution function (CDF) for a Rayleigh distribution.
	*
	* @private
	* @param {number} x - input value
	* @returns {Probability} evaluated CDF
	*
	* @example
	* var y = cdf( 2 );
	* // returns <number>
	*/
	function cdf( x ) {
		if ( isnan( x ) ) {
			return NaN;
		}
		if ( x < 0.0 ) {
			return 0.0;
		}
		return 1.0 - exp( -pow( x, 2.0 ) / ( 2.0 * s2 ) );
	}
}

// EXPORTS //

module.exports = factory;


text:
require_relative "test_helper"

class JobTest < Minitest::Test
  class SimpleJob < RocketJob::Job
    def perform
    end
  end

  describe RocketJob::Job do
    before do
      @description = "Hello World"
      @job         = SimpleJob.new(description: @description)
      @job2        = SimpleJob.new(description: @description, priority: 52)
    end

    after do
      @job.destroy if @job && !@job.new_record?
      @job2.destroy if @job2 && !@job2.new_record?
    end

    describe "#status" do
      it "return status for a queued job" do
        assert_equal true, @job.queued?
        h = @job.status
        assert_equal :queued, h["state"]
        assert_equal @description, h["description"]
      end

      it "return status for a failed job" do
        @job.start!
        @job.fail!("worker:1234", "oh no")
        assert_equal true, @job.failed?
        h = @job.status
        assert_equal :failed, h["state"]
        assert_equal @description, h["description"]
        assert_equal "RocketJob::JobException", h["exception"]["class_name"], h
        assert_equal "oh no", h["exception"]["message"], h
      end
    end

    describe ".requeue_dead_server" do
      it "requeue jobs from dead workers" do
        assert_equal 52, @job2.priority
        worker_name      = "server:12345"
        @job.worker_name = worker_name
        @job.start!
        assert @job.running?, @job.state

        worker_name2      = "server:76467"
        @job2.worker_name = worker_name2
        @job2.start!
        assert_equal true, @job2.valid?
        assert @job2.running?, @job2.state
        @job2.save!

        RocketJob::Job.requeue_dead_server(worker_name)
        @job.reload

        assert @job.queued?
        assert_nil @job.worker_name

        assert_equal worker_name2, @job2.worker_name
        @job2.reload
        assert_equal worker_name2, @job2.worker_name
        assert @job2.running?, @job2.state
        assert_equal worker_name2, @job2.worker_name
      end
    end
  end
end


text:
package synergyspace.jme.pickingsystem;

import java.util.List;

import com.jme.scene.Node;

import synergyspace.jme.pickingsystem.data.PickRequest;
import synergyspace.jme.pickingsystem.data.PickResultData;

/**
 * Defines the picking system for jMonkeyEngine.  Each pick request
 * should result in a List of pick results for that location.  Each
 * pick result is a spatial that was found to be under the request
 * location.  If the pick request asks for all results to be returned,
 * they will, otherwise, only the closest will be returned.
 *
 * @author dcs0ah1
 */
public interface IJMEMultiTouchPicker {

	public void setPickingRootNode(Node rootNode) throws PickSystemException;
	public void setOrthogonalPickingRoot(Node twod) throws PickSystemException;
	public List<PickResultData> doPick(PickRequest pickRequest) throws PickSystemException;
	public List<PickResultData> doPick(PickRequest pickRequest, boolean worldNodeOnly) throws PickSystemException;

}


text:
from datetime import datetime
import numpy as np

def compute_coastal_change(old_mosaic, new_mosaic, no_data = -9999):
    """Compute the coastal change and coastlines for two mosaics

    Computes the output products and appends them onto the old mosaic as
    coastal_change, coastline_old, coastline_new

    Args:
        old_mosaic, new_mosaic - single timeslice mosaic data.

    Returns:
        Xarray dataset containing all original data with three new variables.

    """
    from .dc_water_classifier import wofs_classify
    from .dc_utilities import create_cfmask_clean_mask, create_bit_mask

    # Create a combined bitmask - cfmask if it exists, otherwise pixel_qa.
    combined_mask = create_cfmask_clean_mask(old_mosaic.cf_mask) & create_cfmask_clean_mask(
        new_mosaic.cf_mask) if 'cf_mask' in old_mosaic else create_bit_mask(
            old_mosaic.pixel_qa, [1, 2]) & create_bit_mask(new_mosaic.pixel_qa, [1, 2])

    old_water = wofs_classify(old_mosaic, mosaic=True, clean_mask=combined_mask, no_data = no_data)
    new_water = wofs_classify(new_mosaic, mosaic=True, clean_mask=combined_mask, no_data = no_data)

    coastal_change = new_water - old_water

    coastal_change = coastal_change.where(coastal_change.wofs != 0)

    new_coastline = _coastline_classification_2(new_water)
    old_coastline = _coastline_classification_2(old_water)

    old_mosaic['coastal_change'] = coastal_change.wofs
    old_mosaic['coastline_old'] = old_coastline.coastline
    old_mosaic['coastline_new'] = new_coastline.coastline

    return old_mosaic

def mask_mosaic_with_coastlines(dataset):
    """Mask a mosaic using old/new coastline"""

    required_measurements = ['red', 'green', 'blue', 'coastline_old', 'coastline_new']
    assert set(required_measurements).issubset(
        set(dataset.data_vars)), "Please include all required bands: Red, green, blue, and coastline masks."

    green = _darken_color([89, 255, 61], .8)
    pink = [[255, 8, 74], [252, 8, 74], [230, 98, 137], [255, 147, 172], [255, 192, 205]][0]
    blue = [[13, 222, 255], [139, 237, 236], [0, 20, 225], [30, 144, 255]][-1]
    dataset_clone = dataset.copy(deep=True)
    # mask the new coastline in blue.
    dataset_clone.red.values[dataset_clone.coastline_new.values == 1] = _adjust_color(blue[0])
    dataset_clone.green.values[dataset_clone.coastline_new.values == 1] = _adjust_color(blue[1])
    dataset_clone.blue.values[dataset_clone.coastline_new.values == 1] = _adjust_color(blue[2])
    #mask the old coastline in green.
    dataset_clone.red.values[dataset_clone.coastline_old.values == 1] = _adjust_color(green[0])
    dataset_clone.green.values[dataset_clone.coastline_old.values == 1] = _adjust_color(green[1])
    dataset_clone.blue.values[dataset_clone.coastline_old.values == 1] = _adjust_color(green[2])

    return dataset_clone

def mask_mosaic_with_coastal_change(dataset):
    """Mask a mosaic with coastal change"""

    required_measurements = ['red', 'green', 'blue', 'coastal_change']
    assert set(required_measurements).issubset(
        set(dataset.data_vars)), "Please include all required bands: Red, green, blue, and coastal change."

    green = _darken_color([89, 255, 61], .8)
    pink = [[255, 8, 74], [252, 8, 74], [230, 98, 137], [255, 147, 172], [255, 192, 205]][0]
    blue = [[13, 222, 255], [139, 237, 236], [0, 20, 225], [30, 144, 255]][-1]
    dataset_clone = dataset.copy(deep=True)
    dataset_clone.red.values[dataset_clone.coastal_change.values == 1] = _adjust_color(pink[0])
    dataset_clone.green.values[dataset_clone.coastal_change.values == 1] = _adjust_color(pink[1])
    dataset_clone.blue.values[dataset_clone.coastal_change.values == 1] = _adjust_color(pink[2])

    dataset_clone.red.values[dataset_clone.coastal_change.values == -1] = _adjust_color(green[0])
    dataset_clone.green.values[dataset_clone.coastal_change.values == -1] = _adjust_color(green[1])
    dataset_clone.blue.values[dataset_clone.coastal_change.values == -1] = _adjust_color(green[2])

    return dataset_clone

def _adjust_color(color, scale=4096):
    return int(float(color * scale) / 255.0)

def _darken_color(color, scale=0.8):
    return [int(float(x * scale)) for x in color]

def _coastline_classification(dataset, water_band='wofs'):
    import scipy.ndimage.filters as conv

    kern = np.array([[1, 1, 1], [1, 0.001, 1], [1, 1, 1]])
    convolved = conv.convolve(dataset[water_band], kern, mode='constant') // 1

    ds = dataset.where(convolved > 0)
    ds = ds.where(convolved < 6)
    ds.wofs.values[~np.isnan(ds.wofs.values)] = 1
    ds.wofs.values[np.isnan(ds.wofs.values)] = 0
    ds = ds.rename({"wofs": "coastline"})

    return ds

def _coastline_classification_2(dataset, water_band='wofs'):
    import scipy.ndimage.filters as conv

    kern = np.array([[1, 1, 1], [1, 0.001, 1], [1, 1, 1]])
    convolved = conv.convolve(dataset[water_band], kern, mode='constant', cval=-999) // 1

    ds = dataset.copy(deep=True)
    ds.wofs.values[(~np.isnan(ds[water_band].values)) & (ds.wofs.values == 1)] = 1
    ds.wofs.values[convolved < 0] = 0
    ds.wofs.values[convolved > 6] = 0
    ds = ds.rename({"wofs": "coastline"})

    return ds


text:
'use strict';

let out = require('./out');
console.log(`out in 2: ${JSON.stringify(out)}`);

let in1 = require('./in1');

console.log(`out in 2 after: ${JSON.stringify(out)}`);


text:
<?php

final class PhabricatorAuthCSRFEngine extends Phobject {

  private $salt;
  private $secret;

  public function setSalt($salt) {
    $this->salt = $salt;
    return $this;
  }

  public function getSalt() {
    return $this->salt;
  }

  public function setSecret(PhutilOpaqueEnvelope $secret) {
    $this->secret = $secret;
    return $this;
  }

  public function getSecret() {
    return $this->secret;
  }

  public function newSalt() {
    $salt_length = $this->getSaltLength();
    return Filesystem::readRandomCharacters($salt_length);
  }

  public function newToken() {
    $salt = $this->getSalt();

    if (!$salt) {
      throw new PhutilInvalidStateException('setSalt');
    }

    $token = $this->newRawToken($salt);
    $prefix = $this->getBREACHPrefix();

    return sprintf('%s%s%s', $prefix, $salt, $token);
  }

  public function isValidToken($token) {
    $salt_length = $this->getSaltLength();

    // We expect a BREACH-mitigating token. See T3684.
    $breach_prefix = $this->getBREACHPrefix();
    $breach_prelen = strlen($breach_prefix);
    if (strncmp($token, $breach_prefix, $breach_prelen) !== 0) {
      return false;
    }

    $salt = substr($token, $breach_prelen, $salt_length);
    $token = substr($token, $breach_prelen + $salt_length);

    foreach ($this->getWindowOffsets() as $offset) {
      $expect_token = $this->newRawToken($salt, $offset);
      if (phutil_hashes_are_identical($expect_token, $token)) {
        return true;
      }
    }

    return false;
  }

  private function newRawToken($salt, $offset = 0) {
    $now = PhabricatorTime::getNow();
    $cycle_frequency = $this->getCycleFrequency();

    $time_block = (int)floor($now / $cycle_frequency);
    $time_block = $time_block + $offset;

    $secret = $this->getSecret();
    if (!$secret) {
      throw new PhutilInvalidStateException('setSecret');
    }
    $secret = $secret->openEnvelope();

    $hash = PhabricatorHash::digestWithNamedKey(
      $secret.$time_block.$salt,
      'csrf');

    return substr($hash, 0, $this->getTokenLength());
  }

  private function getBREACHPrefix() {
    return 'B@';
  }

  private function getSaltLength() {
    return 8;
  }

  private function getTokenLength() {
    return 16;
  }

  private function getCycleFrequency() {
    return phutil_units('1 hour in seconds');
  }

  private function getWindowOffsets() {
    // We accept some tokens from the recent past and near future. Users may
    // have older tokens if they close their laptop and open it up again
    // later. Users may have newer tokens if there are multiple web hosts with
    // a bit of clock skew.

    // Javascript on the client tries to keep CSRF tokens up to date, but
    // it may fail, and it doesn't run if the user closes their laptop.

    // The window during which our tokens remain valid is generally more
    // conservative than other platforms. For example, Rails uses "session
    // duration" and Django uses "forever".

    return range(-6, 1);
  }

}


text:
<!DOCTYPE html>

        <title>Super Simple Flux Example</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta charset="utf-8">
        <meta name="description" content="Super Simple Flux Example">
        <meta name="author" content="Florian Edelmaier">


text:
#ifndef SkTypeface_win_dw_DEFINED
#define SkTypeface_win_dw_DEFINED

#include "SkAdvancedTypefaceMetrics.h"
#include "SkDWrite.h"
#include "SkHRESULT.h"
#include "SkTScopedComPtr.h"
#include "SkTypeface.h"
#include "SkTypefaceCache.h"
#include "SkTypes.h"

#include <dwrite.h>
#if SK_HAS_DWRITE_1_H
#  include <dwrite_1.h>
#endif

class SkFontDescriptor;
struct SkScalerContextRec;

static SkFontStyle get_style(IDWriteFont* font) {
    DWRITE_FONT_STYLE dwStyle = font->GetStyle();
    return SkFontStyle(font->GetWeight(),
                       font->GetStretch(),
                       (DWRITE_FONT_STYLE_OBLIQUE == dwStyle ||
                        DWRITE_FONT_STYLE_ITALIC  == dwStyle)
                                                   ? SkFontStyle::kItalic_Slant
                                                   : SkFontStyle::kUpright_Slant);
}

class DWriteFontTypeface : public SkTypeface {
private:
    DWriteFontTypeface(const SkFontStyle& style, SkFontID fontID,
                       IDWriteFactory* factory,
                       IDWriteFontFace* fontFace,
                       IDWriteFont* font,
                       IDWriteFontFamily* fontFamily,
                       IDWriteFontFileLoader* fontFileLoader = NULL,
                       IDWriteFontCollectionLoader* fontCollectionLoader = NULL)
        : SkTypeface(style, fontID, false)
        , fFactory(SkRefComPtr(factory))
        , fDWriteFontCollectionLoader(SkSafeRefComPtr(fontCollectionLoader))
        , fDWriteFontFileLoader(SkSafeRefComPtr(fontFileLoader))
        , fDWriteFontFamily(SkRefComPtr(fontFamily))
        , fDWriteFont(SkRefComPtr(font))
        , fDWriteFontFace(SkRefComPtr(fontFace))
    {
#if SK_HAS_DWRITE_1_H
        if (!SUCCEEDED(fDWriteFontFace->QueryInterface(&fDWriteFontFace1))) {
            // IUnknown::QueryInterface states that if it fails, punk will be set to NULL.
            // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx
            SK_ALWAYSBREAK(NULL == fDWriteFontFace1.get());
        }
#endif
    }

public:
    SkTScopedComPtr<IDWriteFactory> fFactory;
    SkTScopedComPtr<IDWriteFontCollectionLoader> fDWriteFontCollectionLoader;
    SkTScopedComPtr<IDWriteFontFileLoader> fDWriteFontFileLoader;
    SkTScopedComPtr<IDWriteFontFamily> fDWriteFontFamily;
    SkTScopedComPtr<IDWriteFont> fDWriteFont;
    SkTScopedComPtr<IDWriteFontFace> fDWriteFontFace;
#if SK_HAS_DWRITE_1_H
    SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1;
#endif

    static DWriteFontTypeface* Create(IDWriteFactory* factory,
                                      IDWriteFontFace* fontFace,
                                      IDWriteFont* font,
                                      IDWriteFontFamily* fontFamily,
                                      IDWriteFontFileLoader* fontFileLoader = NULL,
                                      IDWriteFontCollectionLoader* fontCollectionLoader = NULL) {
        SkFontID fontID = SkTypefaceCache::NewFontID();
        return SkNEW_ARGS(DWriteFontTypeface, (get_style(font), fontID,
                                               factory, fontFace, font, fontFamily,
                                               fontFileLoader, fontCollectionLoader));
    }

protected:
    void weak_dispose() const SK_OVERRIDE {
        if (fDWriteFontCollectionLoader.get()) {
            HRV(fFactory->UnregisterFontCollectionLoader(fDWriteFontCollectionLoader.get()));
        }
        if (fDWriteFontFileLoader.get()) {
            HRV(fFactory->UnregisterFontFileLoader(fDWriteFontFileLoader.get()));
        }

        //SkTypefaceCache::Remove(this);
        INHERITED::weak_dispose();
    }

    SkStreamAsset* onOpenStream(int* ttcIndex) const SK_OVERRIDE;
    SkScalerContext* onCreateScalerContext(const SkDescriptor*) const SK_OVERRIDE;
    void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE;
    virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
                                SkAdvancedTypefaceMetrics::PerGlyphInfo,
                                const uint32_t*, uint32_t) const SK_OVERRIDE;
    void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE;
    virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
                                uint16_t glyphs[], int glyphCount) const SK_OVERRIDE;
    int onCountGlyphs() const SK_OVERRIDE;
    int onGetUPEM() const SK_OVERRIDE;
    void onGetFamilyName(SkString* familyName) const SK_OVERRIDE;
    SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_OVERRIDE;
    int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE;
    virtual size_t onGetTableData(SkFontTableTag, size_t offset,
                                  size_t length, void* data) const SK_OVERRIDE;

private:
    typedef SkTypeface INHERITED;
};

#endif


text:
<?xml version="1.0" encoding="UTF-8"?>

<document>
  <segment instanceid="email_lists-003-2152883.txt_1" begin="0" end="25">
    <text>docno="lists-003-2152883"</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_2" begin="26" end="65">
    <text>received="Wed May 19 07:16:36 1993 EST"</text>
    <mainVerb begin="26" end="34">received</mainVerb>
    <mainReferent begin="0" end="5">docno</mainReferent>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="EVENT" mainReferentGenericity="NON-GENERIC" habituality="EPISODIC" mainVerbAspectualClass="DYNAMIC"/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_3" begin="66" end="103">
    <text>sent="Wed, 19 May 1993 10:11:53 -0400</text>
    <mainVerb begin="66" end="70">sent</mainVerb>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="EVENT" mainReferentGenericity="NON-GENERIC" habituality="EPISODIC" mainVerbAspectualClass="DYNAMIC"/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_4" begin="104" end="110">
    <text>(EDT)"</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_5" begin="111" end="129">
    <text>name="Dan Schlitt"</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_6" begin="130" end="167">
    <text>email="dan@ees1a0.engr.ccny.cuny.edu"</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_7" begin="168" end="204">
    <text>subject="Re: CHARSET considerations"</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_8" begin="205" end="270">
    <text>id="Pine.3.05.9305191050.G5139-a100000@ees1a0.engr.ccny.cuny.edu"</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_9" begin="271" end="305">
    <text>inreplyto="CHARSET considerations"</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_10" begin="307" end="372">
    <text>To: Harald Tveit Alvestrand <harald.t.alvestrand@delab.sintef.no></text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_11" begin="373" end="442">
    <text>Cc: scs <scs@adam.mit.edu>, pine-info <pine-info@cac.washington.edu>,</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_12" begin="444" end="461">
    <text>Thank you Harald.</text>
    <mainVerb begin="444" end="449">Thank</mainVerb>
    <mainReferent begin="381" end="399"><scs@adam.mit.edu></mainReferent>
    <annotation annotator="gold" seType="SPEECH_ACT" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="EVENT" mainReferentGenericity="NON-GENERIC" habituality="EPISODIC" mainVerbAspectualClass="DYNAMIC"/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_13" begin="463" end="484">
    <text>MIME is MIME is MIME.</text>
    <mainVerb begin="468" end="470">is</mainVerb>
    <mainReferent begin="463" end="467">MIME</mainReferent>
    <annotation annotator="gold" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="A" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="D" seType="GENERIC_SENTENCE:GENERAL_STATIVE" mainReferentGenericity="GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="B" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_14" begin="486" end="512">
    <text>And if it violates the RFC</text>
    <mainVerb begin="496" end="504">violates</mainVerb>
    <mainReferent begin="493" end="495">it</mainReferent>
    <annotation annotator="gold" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="DYNAMIC"/>
    <annotation annotator="A" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="D" seType="GENERIC_SENTENCE:GENERAL_STATIVE" mainReferentGenericity="GENERIC" habituality="STATIC" mainVerbAspectualClass="DYNAMIC"/>
    <annotation annotator="B" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="DYNAMIC"/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_15" begin="513" end="526">
    <text>it isn't MIME</text>
    <mainVerb begin="516" end="518">is</mainVerb>
    <mainReferent begin="513" end="515">it</mainReferent>
    <annotation annotator="gold" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="A" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="D" seType="GENERIC_SENTENCE:GENERAL_STATIVE" mainReferentGenericity="GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="B" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_16" begin="527" end="555">
    <text>and shouldn't pretend to be.</text>
    <mainVerb begin="541" end="548">pretend</mainVerb>
    <mainReferent begin="522" end="526">MIME</mainReferent>
    <annotation annotator="gold" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="A" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="D" seType="GENERIC_SENTENCE:GENERAL_STATIVE" mainReferentGenericity="GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="B" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="DYNAMIC"/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_17" begin="558" end="608">
    <text>That was the point of my original cryptic comment.</text>
    <mainVerb begin="563" end="566">was</mainVerb>
    <mainReferent begin="558" end="562">That</mainReferent>
    <annotation annotator="gold" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="A" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="D" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
    <annotation annotator="B" seType="STATE" mainReferentGenericity="NON-GENERIC" habituality="STATIC" mainVerbAspectualClass="STATIVE"/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_18" begin="610" end="664">
    <text>Now PLEASE edit my address out of the headers of this.</text>
    <mainVerb begin="621" end="625">edit</mainVerb>
    <mainReferent begin="614" end="620">PLEASE</mainReferent>
    <annotation annotator="gold" seType="IMPERATIVE" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="IMPERATIVE" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="IMPERATIVE" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="IMPERATIVE" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_19" begin="666" end="734">
    <text>And probably all of those other mailinglists and limit to pine-info.</text>
    <annotation annotator="gold" seType="IMPERATIVE" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="IMPERATIVE" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="IMPERATIVE" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="IMPERATIVE" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_20" begin="736" end="743">
    <text>PLEASE.</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_21" begin="746" end="755">
    <text>Thankyou.</text>
    <annotation annotator="gold" seType="SPEECH_ACT" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="EVENT" mainReferentGenericity="NON-GENERIC" habituality="EPISODIC" mainVerbAspectualClass="DYNAMIC"/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
  <segment instanceid="email_lists-003-2152883.txt_22" begin="758" end="954">
    <text>Dan Schlitt School of Engineering Computer Systems dan@ee-mail.engr.ccny.cuny.edu City College of New York (212)650-6760 New York, NY 10031</text>
    <annotation annotator="gold" mainReferentGenericity="CANNOT_DECIDE" mainVerbAspectualClass="CANNOT_DECIDE"/>
    <annotation annotator="A" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="D" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
    <annotation annotator="B" seType="" mainReferentGenericity="" habituality="" mainVerbAspectualClass=""/>
  </segment>
</document>


text:
static Array<HANDLE> runningProcessHandles;
#else
static Map<pid_t, Process*> runningProcesses;
#endif

Process::Process()
{
#ifdef _WIN32
  ASSERT(sizeof(hProcess) >= sizeof(HANDLE));
  hProcess = INVALID_HANDLE_VALUE;
#else
  pid = 0;
  exitCode = 1;
#endif
}

Process::~Process()
{
#ifdef _WIN32
  ASSERT(hProcess ==  INVALID_HANDLE_VALUE);
  if(hProcess != INVALID_HANDLE_VALUE)
  {
    CloseHandle((HANDLE)hProcess);

    ptrdiff_t index = runningProcessHandles.find(hProcess);
    if(index >= 0)
      runningProcessHandles.remove(index);
  }
#else
  ASSERT(pid ==  0);
#endif
}

bool Process::isRunning() const
{
#ifdef _WIN32
  return hProcess != INVALID_HANDLE_VALUE;
#else
  return pid != 0;
#endif
}

unsigned int Process::start(const String& rawCommandLine)
{
  // split commands into words
  List<Word> command;
  Word::split(rawCommandLine, command);

  // separate leading environment variables and the command line
  Map<String, String> environmentVariables;
  for(List<Word>::Node* envNode = command.getFirst(); envNode; envNode = command.getFirst())
  {
    const char* data = envNode->data.getData();
    const char* sep = strchr(data, '=');
    if(sep)
    {
      // load list of existing existing variables
      if(environmentVariables.isEmpty())
      {
        const Map<String, String>& envs = getEnvironmentVariables();
        for(const Map<String, String>::Node* i = envs.getFirst(); i; i = i->getNext())
          environmentVariables.append(i->key, i->data);
      }

      // add or override a variable
      String key(data, sep - data);
      Map<String, String>::Node* existingNode = environmentVariables.find(key);
      if(existingNode)
        existingNode->data = envNode->data;
      else
        environmentVariables.append(key, envNode->data);

      //
      command.removeFirst();
    }
    else
      break;
  }

#ifdef _WIN32
  struct Executable
  {
    static bool fileComplete(const String& searchName, bool testExtensions, String& result)
    {
      if(File::exists(searchName))
      {
        result = searchName;
        return true;
      }
      if(testExtensions)
      {
        String testPath = searchName;
        testPath.append(".exe");
        if(File::exists(testPath))
        {
          result = testPath;
          return true;
        }
        testPath.setLength(searchName.getLength());
        testPath.append(".com");
        if(File::exists(testPath))
        {
          result = testPath;
          return true;
        }
      }
      return false;
    }

    static const List<String>& getPathEnv()
    {
      static List<String> searchPaths;
      static bool loaded = false;
      if(!loaded)
      {
        char* pathVar = (char*)alloca(32767);
        GetEnvironmentVariable("PATH", pathVar, 32767);
        for(const char* str = pathVar; *str;)
        {
          const char* end = strchr(str, ';');
          if(end)
          {
            if(end > str)
              searchPaths.append(String(str, end - str));
            ++end;
            str = end;
          }
          else
          {
            searchPaths.append(String(str, -1));
            break;
          }
        }
        loaded = true;
      }
      return searchPaths;
    }

    static bool resolveSymlink(const String& fileName, String& result)
    {
      String cygwinRoot = File::getDirname(File::getDirname(fileName));
      result = fileName;
      bool success = false;
      for(;;)
      {
        File file;
        if(!file.open(result))
          return success;
        const int len = 12 + MAX_PATH * 2 + 2;
        char buffer[len];
        size_t i = file.read(buffer, len);
        if(i < 12 || strncmp(buffer, "!<symlink>\xff\xfe", 12) != 0)
          return success;
        i &= ~1;
        wchar_t* wdest = (wchar_t*)(buffer + 12);
        wdest[(i - 12) >> 1] = 0;
        String dest;
        dest.format(i - 12, "%S", wdest);
        if(strncmp(dest.getData(), "/usr/bin/", 9) == 0)
        {
          result = cygwinRoot;
          result.append(dest.substr(4));
        }
        else if(dest.getData()[0] == '/')
        {
          result = cygwinRoot;
          result.append(dest);
        }
        else
        {
          result = File::getDirname(result);
          result.append('/');
          result.append(dest);
        }
        success = true;
      }
      return false;
    }

    static String find(const String& program)
    {
      String result = program;
      bool testExtensions = File::getExtension(program).isEmpty();
      // check whether the given path is absolute
      if(program.getData()[0] == '/' || (program.getLength() > 2 && program.getData()[1] == ':'))
      { // absolute
        fileComplete(program, testExtensions, result);
      }
      else
      { // try each search path
        const List<String>& searchPaths = getPathEnv();
        for(const List<String>::Node* i = searchPaths.getFirst(); i; i = i->getNext())
        {
          String testPath = i->data;
          testPath.append('\\');
          testPath.append(program);
          if(fileComplete(testPath, testExtensions, result))
          {
            if(strncmp(program.getData(), "../", 3) == 0 || strncmp(program.getData(), "..\\", 3) == 0)
              result = File::simplifyPath(result);
            break;
          }
        }
      }
      return result;
    }
  };

  String program, programPath;
  static Map<String, String> cachedProgramPaths;
  bool cachedProgramPath = false;
  if(command.isEmpty())
    cachedProgramPath = true;
  else
  {
    program = command.getFirst()->data;
    const Map<String, String>::Node* i = cachedProgramPaths.find(program);
    if(i)
    {
      programPath = i->data;
      cachedProgramPath = true;
    }
    else
      programPath = Executable::find(program);
  }

  String commandLine;
  if(!command.isEmpty())
  {
    if(strncmp(command.getFirst()->data.getData(), "../", 3) == 0 || strncmp(command.getFirst()->data.getData(), "..\\", 3) == 0)
      command.getFirst()->data = programPath;
    Word::append(command, commandLine);
  }
  commandLine.setCapacity(commandLine.getLength()); // enforce detach

  STARTUPINFO si;
  PROCESS_INFORMATION pi;

  ZeroMemory(&si, sizeof(si));
  si.cb = sizeof(si);
  ZeroMemory(&pi, sizeof(pi));

  char* envblock = 0;
  if(!environmentVariables.isEmpty())
  {
    size_t envlen = 1;
    const String** envStrings = (const String**)_alloca(environmentVariables.getSize() * sizeof(String*));
    const String** j = envStrings;
    for(Map<String, String>::Node* i = environmentVariables.getFirst(); i; i = i->getNext())
    {
      envlen += i->data.getLength() + 1;
      *(j++) = &i->data;
    }
    struct SortFunction
    {
      static int cmp(const void* a, const void* b)
      {
        return _stricmp((*(const String**)a)->getData(), (*(const String**)b)->getData());
      }
    };
    qsort(envStrings, environmentVariables.getSize(), sizeof(char*), SortFunction::cmp);

    envblock = (char*)_alloca(envlen);
    char* p = envblock;
    for(const String** i = envStrings, ** end = envStrings + environmentVariables.getSize(); i < end; ++i)
    {
      size_t varlen = (*i)->getLength() + 1;
      memcpy(p, (*i)->getData(), varlen);
      p += varlen;
    }
    *p = '\0';
  }

  if(!CreateProcess(programPath.getData(), (char*)commandLine.getData(), NULL, NULL, FALSE, 0, envblock, NULL, &si, &pi))
  {
    DWORD lastError = GetLastError();
    if(!programPath.isEmpty())
    {
      String resolvedSymlink;
      if(Executable::resolveSymlink(programPath, resolvedSymlink))
      {
        programPath = resolvedSymlink;
        if(CreateProcess(programPath.getData(), (char*)commandLine.getData(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
          goto success;
        else
          lastError = GetLastError();
      }
    }

    if(!cachedProgramPath)
      cachedProgramPaths.append(program, programPath);

    SetLastError(lastError);
    return 0;
  }
success:

  if(!cachedProgramPath)
    cachedProgramPaths.append(program, programPath);

  CloseHandle(pi.hThread);

  ASSERT(pi.hProcess);
  hProcess = pi.hProcess;
  runningProcessHandles.append(pi.hProcess);

  return pi.dwProcessId;
#else

  struct Executable
  {
    static const List<String>& getPathEnv()
    {
      static List<String> searchPaths;
      static bool loaded = false;
      if(!loaded)
      {
        char* pathVar = getenv("PATH");
        for(const char* str = pathVar; *str;)
        {
          const char* end = strchr(str, ':');
          if(end)
          {
            if(end > str)
              searchPaths.append(String(str, end - str));
            ++end;
            str = end;
          }
          else
          {
            searchPaths.append(String(str, -1));
            break;
          }
        }
        loaded = true;
      }
      return searchPaths;
    }

#ifdef __CYGWIN__
    static bool fileComplete(const String& searchName, bool testExtensions, String& result)
    {
      if(File::exists(searchName))
      {
        result = searchName;
        return true;
      }
      if(testExtensions)
      {
        String testPath = searchName;
        testPath.append(".exe");
        if(File::exists(testPath))
        {
          result = testPath;
          return true;
        }
        testPath.setLength(searchName.getLength());
        testPath.append(".com");
        if(File::exists(testPath))
        {
          result = testPath;
          return true;
        }
      }
      return false;
    }
    static String find(const String& program)
    {
      String result = program;
      bool testExtensions = File::getExtension(program).isEmpty();
      // check whether the given path is absolute
      if(program.getData()[0] == '/')
      { // absolute
        fileComplete(program, testExtensions, result);
      }
      else
      { // try each search path
        const List<String>& searchPaths = Executable::getPathEnv();
        for(const List<String>::Node* i = searchPaths.getFirst(); i; i = i->getNext())
        {
          String testPath = i->data;
          testPath.append('/');
          testPath.append(program);
          if(fileComplete(testPath, testExtensions, result))
            break;
        }
      }
      return result;
    }
#else
    static String find(const String& program)
    {
      String result = program;
      // check whether the given path is absolute
      if(program.getData()[0] == '/')
      { // absolute
        return result;
      }
      else
      { // try each search path
        const List<String>& searchPaths = Executable::getPathEnv();
        for(const List<String>::Node* i = searchPaths.getFirst(); i; i = i->getNext())
        {
          String testPath = i->data;
          testPath.append('/');
          testPath.append(program);
          if(File::exists(testPath))
          {
            result = testPath;
            break;
          }
        }
      }
      return result;
    }
#endif
  };

  String program, programPath;
  static Map<String, String> cachedProgramPaths;
  if(!command.isEmpty())
  {
    program = command.getFirst()->data;
    const Map<String, String>::Node* i = cachedProgramPaths.find(program);
    if(i)
      programPath = i->data;
    else
    {
      programPath = Executable::find(program);
      cachedProgramPaths.append(program, programPath);
    }
  }

  int r = vfork();
  if(r == -1)
    return 0;
  else if(r != 0) // parent
  {
    pid = r;
    runningProcesses.append(pid, this);
    return r;
  }
  else // child
  {
    const char** argv = (const char**)alloca(sizeof(const char*) * (command.getSize() + 1));
    int i = 0;
    for(const List<Word>::Node* j = command.getFirst(); j; j = j->getNext())
      argv[i++] = j->data.getData();
    argv[i] = 0;

    const char** envp = (const char**)environ;
    if(!environmentVariables.isEmpty())
    {
      envp = (const char**)alloca(sizeof(const char*) * (environmentVariables.getSize() + 1));
      int i = 0;
      for(const Map<String, String>::Node* j = environmentVariables.getFirst(); j; j = j->getNext())
        envp[i++] = j->data.getData();
      envp[i] = 0;
    }

    const char* executable = programPath.getData();
    if(execve(executable, (char* const*)argv, (char* const*)envp) == -1)
    {
      fprintf(stderr, "%s: %s\n", executable, Error::getString().getData());
      _exit(EXIT_FAILURE);
    }
    ASSERT(false); // unreachable
    return 0;
  }
#endif
}

unsigned int Process::join()
{
#ifdef _WIN32
  if(hProcess == INVALID_HANDLE_VALUE)
  {
    SetLastError(ERROR_INVALID_HANDLE);
    return 0;
  }
  DWORD exitCode = 0;
  GetExitCodeProcess(hProcess, &exitCode);
  CloseHandle((HANDLE)hProcess);
  hProcess = INVALID_HANDLE_VALUE;
  return exitCode;
#else
  if(!pid)
  {
    errno = EINVAL;
    return 0;
  }
  pid = 0;
  return exitCode;
#endif
}

unsigned int Process::waitOne()
{
#ifdef _WIN32
  if(runningProcessHandles.isEmpty())
  {
    SetLastError(ERROR_NOT_READY);
    return 0;
  }
  DWORD index = WaitForMultipleObjects(static_cast<DWORD>(runningProcessHandles.getSize()), runningProcessHandles.getFirst(), FALSE, INFINITE);
  if(index == WAIT_FAILED)
    return 0;
  index -= WAIT_OBJECT_0;
  ASSERT(index >= 0 && index < runningProcessHandles.getSize());

  HANDLE handle = runningProcessHandles.getFirst()[index];
  runningProcessHandles.remove(index);

  return GetProcessId(handle);
#else
  int status;
  pid_t pid = wait(&status);
  if(pid == -1)
    return 0;
  Map<pid_t, Process*>::Node* i = runningProcesses.find(pid);
  if(i)
  {
    i->data->exitCode = WIFEXITED(status) ? WEXITSTATUS(status) : 1;
    runningProcesses.remove(i);
  }
  return pid;
#endif
}

unsigned  int Process::getProcessorCount()
{
#if defined(_WIN32)
  SYSTEM_INFO si;
  GetSystemInfo(&si);
  return si.dwNumberOfProcessors;
//#elif defined(__linux)
#else
  return sysconf(_SC_NPROCESSORS_CONF);
//#else
  //return 1;
#endif
}

String Process::getArchitecture()
{
#ifndef _WIN32
  struct utsname utsn;
  if(uname(&utsn) == 0)
    return String(utsn.machine, -1);
#endif
#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64) | defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
  return String("x86_64");
#elif defined(_WIN32) || defined(__i686__)
#if defined(_WIN32) && !defined(_WIN64)
  BOOL Wow64Process;
  if(IsWow64Process(GetCurrentProcess(), &Wow64Process))
    if(Wow64Process)
      return String("x86_64");
#endif
  return String("i686");
#else
  return String("unknown");
  // add your architecture :)
  // http://predef.sourceforge.net/preos.html
#endif
}

const Map<String, String>& Process::getEnvironmentVariables()
{
  static const Map<String, String>* loadedEnvironmentVariables = 0;
  if(loadedEnvironmentVariables)
    return *loadedEnvironmentVariables;

  static Map<String, String> environmentVariables;
#ifdef _WIN32
  char* existingStrings = GetEnvironmentStrings();
  for(const char* p = existingStrings; *p;)
  {
    size_t len = strlen(p);
    const char* sep = strchr(p, '=');
    if(sep)
      environmentVariables.append(String(p, sep - p), String(p, len));
    p += len + 1;
  }
  FreeEnvironmentStrings(existingStrings);
#else
  for(char** pp = environ; *pp; ++pp)
  {
    const char* p = *pp;
    const char* sep = strchr(p, '=');
    if(sep)
      environmentVariables.append(String(p, sep - p), String(p, strlen(p)));
  }
#endif
  loadedEnvironmentVariables = &environmentVariables;
  return environmentVariables;
}


text:
//----------------------------------------------------------------------------
/** @file GtpInputStream.h
*/
//----------------------------------------------------------------------------

#ifndef GTP_INPUTSTREAM_H
#define GTP_INPUTSTREAM_H

#include <iostream>
#include <string>

//----------------------------------------------------------------------------

/** Base class for input streams used by GtpEngine.
    This implementation only forwards calls to std::istream.
*/
class GtpInputStream
{
public:
    GtpInputStream(std::istream &in);

    virtual ~GtpInputStream();

    virtual bool EndOfInput();

    virtual bool GetLine(std::string &line);

private:
    std::istream &m_in;
};

//----------------------------------------------------------------------------

#endif // GTP_INPUTSTREAM_H


text:
<?php
    include_once 'scheme.css.php';
    header("Content-Type: text/css");
?>
fieldset.settings-widget { border: 1px solid <?php echo $gold ?>; border-radius: 5px; margin: 4px; padding: 6px; }
.settings-widget legend { position: static; top: 0px; left: 20px; cursor: pointer; }
.settings-widget span.tzCheckBox { float: right; margin-bottom: 6px;  }

.settings-widget .indent { margin: 4px; padding: 10px; background-color: <?php echo $white ?>; border-radius: 5px;  }


text:
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Global message</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Log v2">
<link rel="up" href="../../../expressions.html#header.boost.log.expressions.message_hpp" title="Header <boost/log/expressions/message.hpp>">
<link rel="prev" href="wmessage_type.html" title="Type definition wmessage_type">
<link rel="next" href="smessage.html" title="Global smessage">

Global message

boost::log::expressions::message

Synopsis

// In header: <boost/log/expressions/message.hpp>

const message_type message;

Description

Generic message keyword.

Copyright © 2007-2016 Andrey Semashev

        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).


text:
using Nethereum.Hex.HexTypes;
using Nethereum.RPC.Infrastructure;

namespace Nethereum.RPC.Eth.Blocks
{
    public interface IEthBlockNumber:IGenericRpcRequestResponseHandlerNoParam<HexBigInteger>
    {

    }
}


text:
package leveldb

import (
	"fmt"

	"github.com/noypi/kv"
	"github.com/syndtr/goleveldb/leveldb"
)

type _writer struct {
	store *_store
}

func (w *_writer) NewBatch() kv.KVBatch {
	rv := _batch{
		store: w.store,
		merge: kv.NewEmulatedMerge(w.store.mo),
		batch: new(leveldb.Batch),
	}
	return &rv
}

func (w *_writer) NewBatchEx(options kv.KVBatchOptions) ([]byte, kv.KVBatch, error) {
	return make([]byte, options.TotalBytes), w.NewBatch(), nil
}

func (w *_writer) ExecuteBatch(b kv.KVBatch) error {
	batch, ok := b.(*_batch)
	if !ok {
		return fmt.Errorf("wrong type of batch")
	}

	// first process merges
	for k, mergeOps := range batch.merge.Merges {
		kb := []byte(k)
		existingVal, err := w.store.db.Get(kb, w.store.defaultReadOptions)
		if err != nil && err != leveldb.ErrNotFound {
			return err
		}
		mergedVal, fullMergeOk := w.store.mo.FullMerge(kb, existingVal, mergeOps)
		if !fullMergeOk {
			return fmt.Errorf("merge operator returned failure")
		}
		// add the final merge to this batch
		batch.batch.Put(kb, mergedVal)
	}

	// now execute the batch
	return w.store.db.Write(batch.batch, w.store.defaultWriteOptions)
}

func (w *_writer) Close() error {
	return nil
}


text:
namespace TeamProjectManager.Modules.Activity
{
    public enum ActivityComponentType
    {
        Tfvc,
        WorkItemTracking,
        XamlBuild,
        Git,
        Build
    }
}