text:
module Mail
  module Multibyte
    module Unicode

      extend self

      # A list of all available normalization forms. See http://www.unicode.org/reports/tr15/tr15-29.html for more
      # information about normalization.
      NORMALIZATION_FORMS = [:c, :kc, :d, :kd]

      # The Unicode version that is supported by the implementation
      UNICODE_VERSION = '5.2.0'

      # The default normalization used for operations that require normalization. It can be set to any of the
      # normalizations in NORMALIZATION_FORMS.
      #
      # Example:
      #   Mail::Multibyte::Unicode.default_normalization_form = :c
      attr_accessor :default_normalization_form
      @default_normalization_form = :kc

      # Hangul character boundaries and properties
      HANGUL_SBASE = 0xAC00
      HANGUL_LBASE = 0x1100
      HANGUL_VBASE = 0x1161
      HANGUL_TBASE = 0x11A7
      HANGUL_LCOUNT = 19
      HANGUL_VCOUNT = 21
      HANGUL_TCOUNT = 28
      HANGUL_NCOUNT = HANGUL_VCOUNT * HANGUL_TCOUNT
      HANGUL_SCOUNT = 11172
      HANGUL_SLAST = HANGUL_SBASE + HANGUL_SCOUNT
      HANGUL_JAMO_FIRST = 0x1100
      HANGUL_JAMO_LAST = 0x11FF

      # All the unicode whitespace
      WHITESPACE = [
        (0x0009..0x000D).to_a, # White_Space # Cc   [5] <control-0009>..<control-000D>
        0x0020,                # White_Space # Zs       SPACE
        0x0085,                # White_Space # Cc       <control-0085>
        0x00A0,                # White_Space # Zs       NO-BREAK SPACE
        0x1680,                # White_Space # Zs       OGHAM SPACE MARK
        0x180E,                # White_Space # Zs       MONGOLIAN VOWEL SEPARATOR
        (0x2000..0x200A).to_a, # White_Space # Zs  [11] EN QUAD..HAIR SPACE
        0x2028,                # White_Space # Zl       LINE SEPARATOR
        0x2029,                # White_Space # Zp       PARAGRAPH SEPARATOR
        0x202F,                # White_Space # Zs       NARROW NO-BREAK SPACE
        0x205F,                # White_Space # Zs       MEDIUM MATHEMATICAL SPACE
        0x3000,                # White_Space # Zs       IDEOGRAPHIC SPACE
      ].flatten.freeze

      # BOM (byte order mark) can also be seen as whitespace, it's a non-rendering character used to distinguish
      # between little and big endian. This is not an issue in utf-8, so it must be ignored.
      LEADERS_AND_TRAILERS = WHITESPACE + [65279] # ZERO-WIDTH NO-BREAK SPACE aka BOM

      # Returns a regular expression pattern that matches the passed Unicode codepoints
      def self.codepoints_to_pattern(array_of_codepoints) #:nodoc:
        array_of_codepoints.collect{ |e| [e].pack 'U*' }.join('|')
      end
      TRAILERS_PAT = /(#{codepoints_to_pattern(LEADERS_AND_TRAILERS)})+\Z/u
      LEADERS_PAT = /\A(#{codepoints_to_pattern(LEADERS_AND_TRAILERS)})+/u

      # Unpack the string at codepoints boundaries. Raises an EncodingError when the encoding of the string isn't
      # valid UTF-8.
      #
      # Example:
      #   Unicode.u_unpack('Café') # => [67, 97, 102, 233]
      def u_unpack(string)
        begin
          string.unpack 'U*'
        rescue ArgumentError
          raise EncodingError, 'malformed UTF-8 character'
        end
      end

      # Detect whether the codepoint is in a certain character class. Returns +true+ when it's in the specified
      # character class and +false+ otherwise. Valid character classes are: <tt>:cr</tt>, <tt>:lf</tt>, <tt>:l</tt>,
      # <tt>:v</tt>, <tt>:lv</tt>, <tt>:lvt</tt> and <tt>:t</tt>.
      #
      # Primarily used by the grapheme cluster support.
      def in_char_class?(codepoint, classes)
        classes.detect { |c| database.boundary[c] === codepoint } ? true : false
      end

      # Unpack the string at grapheme boundaries. Returns a list of character lists.
      #
      # Example:
      #   Unicode.g_unpack('क्षि') # => [[2325, 2381], [2359], [2367]]
      #   Unicode.g_unpack('Café') # => [[67], [97], [102], [233]]
      def g_unpack(string)
        codepoints = u_unpack(string)
        unpacked = []
        pos = 0
        marker = 0
        eoc = codepoints.length
        while(pos < eoc)
          pos += 1
          previous = codepoints[pos-1]
          current = codepoints[pos]
          if (
              # CR X LF
              ( previous == database.boundary[:cr] and current == database.boundary[:lf] ) or
              # L X (L|V|LV|LVT)
              ( database.boundary[:l] === previous and in_char_class?(current, [:l,:v,:lv,:lvt]) ) or
              # (LV|V) X (V|T)
              ( in_char_class?(previous, [:lv,:v]) and in_char_class?(current, [:v,:t]) ) or
              # (LVT|T) X (T)
              ( in_char_class?(previous, [:lvt,:t]) and database.boundary[:t] === current ) or
              # X Extend
              (database.boundary[:extend] === current)
            )
          else
            unpacked << codepoints[marker..pos-1]
            marker = pos
          end
        end
        unpacked
      end

      # Reverse operation of g_unpack.
      #
      # Example:
      #   Unicode.g_pack(Unicode.g_unpack('क्षि')) # => 'क्षि'
      def g_pack(unpacked)
        (unpacked.flatten).pack('U*')
      end

      # Re-order codepoints so the string becomes canonical.
      def reorder_characters(codepoints)
        length = codepoints.length- 1
        pos = 0
        while pos < length do
          cp1, cp2 = database.codepoints[codepoints[pos]], database.codepoints[codepoints[pos+1]]
          if (cp1.combining_class > cp2.combining_class) && (cp2.combining_class > 0)
            codepoints[pos..pos+1] = cp2.code, cp1.code
            pos += (pos > 0 ? -1 : 1)
          else
            pos += 1
          end
        end
        codepoints
      end

      # Decompose composed characters to the decomposed form.
      def decompose_codepoints(type, codepoints)
        codepoints.inject([]) do |decomposed, cp|
          # if it's a hangul syllable starter character
          if HANGUL_SBASE <= cp and cp < HANGUL_SLAST
            sindex = cp - HANGUL_SBASE
            ncp = [] # new codepoints
            ncp << HANGUL_LBASE + sindex / HANGUL_NCOUNT
            ncp << HANGUL_VBASE + (sindex % HANGUL_NCOUNT) / HANGUL_TCOUNT
            tindex = sindex % HANGUL_TCOUNT
            ncp << (HANGUL_TBASE + tindex) unless tindex == 0
            decomposed.concat ncp
          # if the codepoint is decomposable in with the current decomposition type
          elsif (ncp = database.codepoints[cp].decomp_mapping) and (!database.codepoints[cp].decomp_type || type == :compatability)
            decomposed.concat decompose_codepoints(type, ncp.dup)
          else
            decomposed << cp
          end
        end
      end

      # Compose decomposed characters to the composed form.
      def compose_codepoints(codepoints)
        pos = 0
        eoa = codepoints.length - 1
        starter_pos = 0
        starter_char = codepoints[0]
        previous_combining_class = -1
        while pos < eoa
          pos += 1
          lindex = starter_char - HANGUL_LBASE
          # -- Hangul
          if 0 <= lindex and lindex < HANGUL_LCOUNT
            vindex = codepoints[starter_pos+1] - HANGUL_VBASE rescue vindex = -1
            if 0 <= vindex and vindex < HANGUL_VCOUNT
              tindex = codepoints[starter_pos+2] - HANGUL_TBASE rescue tindex = -1
              if 0 <= tindex and tindex < HANGUL_TCOUNT
                j = starter_pos + 2
                eoa -= 2
              else
                tindex = 0
                j = starter_pos + 1
                eoa -= 1
              end
              codepoints[starter_pos..j] = (lindex * HANGUL_VCOUNT + vindex) * HANGUL_TCOUNT + tindex + HANGUL_SBASE
            end
            starter_pos += 1
            starter_char = codepoints[starter_pos]
          # -- Other characters
          else
            current_char = codepoints[pos]
            current = database.codepoints[current_char]
            if current.combining_class > previous_combining_class
              if ref = database.composition_map[starter_char]
                composition = ref[current_char]
              else
                composition = nil
              end
              unless composition.nil?
                codepoints[starter_pos] = composition
                starter_char = composition
                codepoints.delete_at pos
                eoa -= 1
                pos -= 1
                previous_combining_class = -1
              else
                previous_combining_class = current.combining_class
              end
            else
              previous_combining_class = current.combining_class
            end
            if current.combining_class == 0
              starter_pos = pos
              starter_char = codepoints[pos]
            end
          end
        end
        codepoints
      end

      # Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent resulting in a valid UTF-8 string.
      #
      # Passing +true+ will forcibly tidy all bytes, assuming that the string's encoding is entirely CP1252 or ISO-8859-1.
      def tidy_bytes(string, force = false)
        if force
          return string.unpack("C*").map do |b|
            tidy_byte(b)
          end.flatten.compact.pack("C*").unpack("U*").pack("U*")
        end

        bytes = string.unpack("C*")
        conts_expected = 0
        last_lead = 0

        bytes.each_index do |i|

          byte          = bytes[i]
          is_cont       = byte > 127 && byte < 192
          is_lead       = byte > 191 && byte < 245
          is_unused     = byte > 240
          is_restricted = byte > 244

          # Impossible or highly unlikely byte? Clean it.
          if is_unused || is_restricted
            bytes[i] = tidy_byte(byte)
          elsif is_cont
            # Not expecting contination byte? Clean up. Otherwise, now expect one less.
            conts_expected == 0 ? bytes[i] = tidy_byte(byte) : conts_expected -= 1
          else
            if conts_expected > 0
              # Expected continuation, but got ASCII or leading? Clean backwards up to
              # the leading byte.
              (1..(i - last_lead)).each {|j| bytes[i - j] = tidy_byte(bytes[i - j])}
              conts_expected = 0
            end
            if is_lead
              # Final byte is leading? Clean it.
              if i == bytes.length - 1
                bytes[i] = tidy_byte(bytes.last)
              else
                # Valid leading byte? Expect continuations determined by position of
                # first zero bit, with max of 3.
                conts_expected = byte < 224 ? 1 : byte < 240 ? 2 : 3
                last_lead = i
              end
            end
          end
        end
        bytes.empty? ? "" : bytes.flatten.compact.pack("C*").unpack("U*").pack("U*")
      end

      # Returns the KC normalization of the string by default. NFKC is considered the best normalization form for
      # passing strings to databases and validations.
      #
      # * <tt>string</tt> - The string to perform normalization on.
      # * <tt>form</tt> - The form you want to normalize in. Should be one of the following:
      #   <tt>:c</tt>, <tt>:kc</tt>, <tt>:d</tt>, or <tt>:kd</tt>. Default is
      #   Mail::Multibyte.default_normalization_form
      def normalize(string, form=nil)
        form ||= @default_normalization_form
        # See http://www.unicode.org/reports/tr15, Table 1
        codepoints = u_unpack(string)
        case form
          when :d
            reorder_characters(decompose_codepoints(:canonical, codepoints))
          when :c
            compose_codepoints(reorder_characters(decompose_codepoints(:canonical, codepoints)))
          when :kd
            reorder_characters(decompose_codepoints(:compatability, codepoints))
          when :kc
            compose_codepoints(reorder_characters(decompose_codepoints(:compatability, codepoints)))
          else
            raise ArgumentError, "#{form} is not a valid normalization variant", caller
        end.pack('U*')
      end

      def apply_mapping(string, mapping) #:nodoc:
        u_unpack(string).map do |codepoint|
          cp = database.codepoints[codepoint]
          if cp and (ncp = cp.send(mapping)) and ncp > 0
            ncp
          else
            codepoint
          end
        end.pack('U*')
      end

      # Holds data about a codepoint in the Unicode database
      class Codepoint
        attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping
      end

      # Holds static data from the Unicode database
      class UnicodeDatabase
        ATTRIBUTES = :codepoints, :composition_exclusion, :composition_map, :boundary, :cp1252

        attr_writer(*ATTRIBUTES)

        def initialize
          @codepoints = Hash.new(Codepoint.new)
          @composition_exclusion = []
          @composition_map = {}
          @boundary = {}
          @cp1252 = {}
        end

        # Lazy load the Unicode database so it's only loaded when it's actually used
        ATTRIBUTES.each do |attr_name|
          class_eval(<<-EOS, __FILE__, __LINE__ + 1)
            def #{attr_name}     # def codepoints
              load               #   load
              @#{attr_name}      #   @codepoints
            end                  # end
          EOS
        end

        # Loads the Unicode database and returns all the internal objects of UnicodeDatabase.
        def load
          begin
            @codepoints, @composition_exclusion, @composition_map, @boundary, @cp1252 = File.open(self.class.filename, 'rb') { |f| Marshal.load f.read }
          rescue Exception => e
              raise IOError.new("Couldn't load the Unicode tables for UTF8Handler (#{e.message}), Mail::Multibyte is unusable")
          end

          # Redefine the === method so we can write shorter rules for grapheme cluster breaks
          @boundary.each do |k,_|
            @boundary[k].instance_eval do
              def ===(other)
                detect { |i| i === other } ? true : false
              end
            end if @boundary[k].kind_of?(Array)
          end

          # define attr_reader methods for the instance variables
          class << self
            attr_reader(*ATTRIBUTES)
          end
        end

        # Returns the directory in which the data files are stored
        def self.dirname
          File.dirname(__FILE__) + '/../values/'
        end

        # Returns the filename for the data file for this version
        def self.filename
          File.expand_path File.join(dirname, "unicode_tables.dat")
        end
      end

      private

      def tidy_byte(byte)
        if byte < 160
          [database.cp1252[byte] || byte].pack("U").unpack("C*")
        elsif byte < 192
          [194, byte]
        else
          [195, byte - 64]
        end
      end

      def database
        @database ||= UnicodeDatabase.new
      end

    end
  end
end


text:
/* -*- C++ -*- */
// $Id: CommandModule.h 80826 2008-03-04 14:51:23Z wotte $

#ifndef COMMAND_MODULE_H
#define COMMAND_MODULE_H

#include "ace/Module.h"
#include "ace/SOCK_Stream.h"
#include "CommandTask.h"

// Listing 01 code/ch18
class CommandModule : public ACE_Module<ACE_MT_SYNCH>
{
public:
  typedef ACE_Module<ACE_MT_SYNCH> inherited;
  typedef ACE_Task<ACE_MT_SYNCH> Task;

  CommandModule (const ACE_TCHAR *module_name,
                   CommandTask *writer,
                   CommandTask *reader,
                   ACE_SOCK_Stream *peer);

  ACE_SOCK_Stream &peer (void);
};
// Listing 01

#endif /* COMMAND_MODULE_H */

redpajama_set_name: RedPajamaGithub


text:
CKEDITOR.plugins.setLang( 'codemirror', 'sv', {
	toolbar: 'Källa',
	autoFormat: 'Format Selection',
	commentSelectedRange: 'Comment Selection',
	uncommentSelectedRange: 'Uncomment Selection'
});


text:
"""Test reading of BrainVision format."""
# Author: Teon Brooks <teon.brooks@gmail.com>
#         Stefan Appelhoff <stefan.appelhoff@mailbox.org>
#
# License: BSD-3-Clause
import os.path as op
import re
import shutil

import numpy as np
from numpy.testing import (assert_array_almost_equal, assert_array_equal,
                           assert_allclose, assert_equal)
import pytest

import datetime
from mne.utils import _stamp_to_dt, object_diff
from mne import pick_types, read_annotations, concatenate_raws
from mne.io.constants import FIFF
from mne.io import read_raw_fif, read_raw_brainvision
from mne.io.tests.test_raw import _test_raw_reader
from mne.datasets import testing
from mne.annotations import events_from_annotations

data_dir = op.join(op.dirname(__file__), 'data')
vhdr_path = op.join(data_dir, 'test.vhdr')
vmrk_path = op.join(data_dir, 'test.vmrk')
eeg_path = op.join(data_dir, 'test.eeg')

vhdr_partially_disabled_hw_filter_path = op.join(data_dir,
                                                 'test_partially_disabled'
                                                 '_hw_filter.vhdr')

vhdr_old_path = op.join(
    data_dir, 'test_old_layout_latin1_software_filter.vhdr')
vhdr_old_longname_path = op.join(
    data_dir, 'test_old_layout_latin1_software_filter_longname.vhdr')

vhdr_v2_path = op.join(data_dir, 'testv2.vhdr')

vhdr_highpass_path = op.join(data_dir, 'test_highpass.vhdr')
vhdr_mixed_highpass_path = op.join(data_dir, 'test_mixed_highpass.vhdr')
vhdr_highpass_hz_path = op.join(data_dir, 'test_highpass_hz.vhdr')
vhdr_mixed_highpass_hz_path = op.join(data_dir, 'test_mixed_highpass_hz.vhdr')

# Not a typo: we can reuse the highpass file for the lowpass (Hz) test
vhdr_lowpass_path = op.join(data_dir, 'test_highpass.vhdr')
vhdr_mixed_lowpass_path = op.join(data_dir, 'test_mixed_lowpass.vhdr')
vhdr_lowpass_s_path = op.join(data_dir, 'test_lowpass_s.vhdr')
vhdr_mixed_lowpass_s_path = op.join(data_dir, 'test_mixed_lowpass_s.vhdr')

# VHDR exported with neuroone
data_path = testing.data_path(download=False)
neuroone_vhdr = op.join(data_path, 'Brainvision', 'test_NO.vhdr')

# Test for nanovolts as unit
vhdr_units_path = op.join(data_dir, 'test_units.vhdr')

# Test bad date
vhdr_bad_date = op.join(data_dir, 'test_bad_date.vhdr')

eeg_bin = op.join(data_dir, 'test_bin_raw.fif')
eog = ['HL', 'HR', 'Vb']

# XXX: BUG we cannot parse test.hpts FastSCAN file to create a DigMontage
#      (plus I've removed montage from all the read_raw_brainvision and nothing
#       broke, so we were not testing that set_montage in brainvision was
#       working)
#      This should be amend in its own PR.
montage = op.join(data_dir, 'test.hpts')

def test_orig_units(recwarn):
    """Test exposure of original channel units."""
    raw = read_raw_brainvision(vhdr_path)
    orig_units = raw._orig_units
    assert len(orig_units) == 32
    assert orig_units['FP1'] == 'µV'

    # no unit specified in the vhdr, ensure we default to µV here
    assert orig_units['FP2'] == 'µV'
    assert orig_units['F3'] == 'µV'

    sum([v == 'µV' for v in orig_units.values()]) == 26

    assert orig_units['CP5'] == 'n/a'  # originally BS, not a valid unit
    assert orig_units['CP6'] == 'µS'
    assert orig_units['HL'] == 'n/a'  # originally ARU, not a valid unit
    assert orig_units['HR'] == 'n/a'  # originally uS ...
    assert orig_units['Vb'] == 'S'
    assert orig_units['ReRef'] == 'C'

DATE_TEST_CASES = np.array([
    ('Mk1=New Segment,,1,1,0,20131113161403794232\n',  # content
     [1384359243, 794232],  # meas_date internal representation
     '2013-11-13 16:14:03 UTC'),  # meas_date representation

    (('Mk1=New Segment,,1,1,0,20070716122240937454\n'
      'Mk2=New Segment,,2,1,0,20070716122240937455\n'),
     [1184588560, 937454],
     '2007-07-16 12:22:40 UTC'),

    ('Mk1=New Segment,,1,1,0,\nMk2=New Segment,,2,1,0,20070716122240937454\n',
     [1184588560, 937454],
     '2007-07-16 12:22:40 UTC'),

    ('Mk1=STATUS,,1,1,0\n', None, 'unspecified'),
    ('Mk1=New Segment,,1,1,0,\n', None, 'unspecified'),
    ('Mk1=New Segment,,1,1,0\n', None, 'unspecified'),
    ('Mk1=New Segment,,1,1,0,00000000000304125000', None, 'unspecified'),

], dtype=np.dtype({
    'names': ['content', 'meas_date', 'meas_date_repr'],
    'formats': [object, object, 'U22']
}))

@pytest.fixture(scope='session')
def _mocked_meas_date_data(tmp_path_factory):
    """Prepare files for mocked_meas_date_file fixture."""
    # Prepare the files
    tmp_path = str(tmp_path_factory.mktemp('brainvision_mocked_meas_date'))
    vhdr_fname, vmrk_fname, eeg_fname = [
        op.join(tmp_path, op.basename(ff))
        for ff in [vhdr_path, vmrk_path, eeg_path]
    ]
    for orig, dest in zip([vhdr_path, eeg_path], [vhdr_fname, eeg_fname]):
        shutil.copyfile(orig, dest)

    # Get the marker information
    with open(vmrk_path, 'r') as fin:
        lines = fin.readlines()

    return vhdr_fname, vmrk_fname, lines

@pytest.fixture(scope='session', params=[tt for tt in DATE_TEST_CASES])
def mocked_meas_date_file(_mocked_meas_date_data, request):
    """Prepare a generator for use in test_meas_date."""
    MEAS_DATE_LINE = 11  # see test.vmrk file
    vhdr_fname, vmrk_fname, lines = _mocked_meas_date_data

    lines[MEAS_DATE_LINE] = request.param['content']
    with open(vmrk_fname, 'w') as fout:
        fout.writelines(lines)
    meas_date = request.param['meas_date']
    if meas_date is not None:
        meas_date = _stamp_to_dt(meas_date)

    yield vhdr_fname, meas_date, request.param['meas_date_repr']

def test_meas_date(mocked_meas_date_file):
    """Test successful extraction of measurement date."""
    vhdr_f, expected_meas, expected_meas_repr = mocked_meas_date_file
    raw = read_raw_brainvision(vhdr_f)
    assert expected_meas_repr in repr(raw.info)
    if expected_meas is None:
        assert raw.info['meas_date'] is None
    else:
        assert raw.info['meas_date'] == expected_meas

def test_vhdr_codepage_ansi(tmp_path):
    """Test BV reading with ANSI codepage."""
    raw_init = read_raw_brainvision(vhdr_path)
    data_expected, times_expected = raw_init[:]
    tempdir = str(tmp_path)
    ansi_vhdr_path = op.join(tempdir, op.split(vhdr_path)[-1])
    ansi_vmrk_path = op.join(tempdir, op.split(vmrk_path)[-1])
    ansi_eeg_path = op.join(tempdir, op.split(eeg_path)[-1])
    # copy data file
    shutil.copy(eeg_path, ansi_eeg_path)
    # modify header file
    with open(ansi_vhdr_path, 'wb') as fout:
        with open(vhdr_path, 'rb') as fin:
            for line in fin:
                # Common Infos section
                if line.startswith(b'Codepage'):
                    line = b'Codepage=ANSI\n'
                fout.write(line)
    # modify marker file
    with open(ansi_vmrk_path, 'wb') as fout:
        with open(vmrk_path, 'rb') as fin:
            for line in fin:
                # Common Infos section
                if line.startswith(b'Codepage'):
                    line = b'Codepage=ANSI\n'
                fout.write(line)

    raw = read_raw_brainvision(ansi_vhdr_path)
    data_new, times_new = raw[:]

    assert_equal(raw_init.ch_names, raw.ch_names)
    assert_allclose(data_new, data_expected, atol=1e-15)
    assert_allclose(times_new, times_expected, atol=1e-15)

@pytest.mark.parametrize('header', [
    b'BrainVision Data Exchange %s File Version 1.0\n',
    # 2.0, space, core, comma
    b'Brain Vision Core Data Exchange %s File, Version 2.0\n',
    # unsupported version
    b'Brain Vision Core Data Exchange %s File, Version 3.0\n',
    # missing header
    b'\n',
])
def test_vhdr_versions(tmp_path, header):
    """Test BV reading with different header variants."""
    raw_init = read_raw_brainvision(vhdr_path)
    data_expected, times_expected = raw_init[:]
    use_vhdr_path = op.join(tmp_path, op.split(vhdr_path)[-1])
    use_vmrk_path = op.join(tmp_path, op.split(vmrk_path)[-1])
    use_eeg_path = op.join(tmp_path, op.split(eeg_path)[-1])
    shutil.copy(eeg_path, use_eeg_path)
    with open(use_vhdr_path, 'wb') as fout:
        with open(vhdr_path, 'rb') as fin:
            for line in fin:
                # Common Infos section
                if line.startswith(b'Brain'):
                    if header != b'\n':
                        line = header % b'Header'
                    else:
                        line = header
                fout.write(line)
    with open(use_vmrk_path, 'wb') as fout:
        with open(vmrk_path, 'rb') as fin:
            for line in fin:
                # Common Infos section
                if line.startswith(b'Brain'):
                    if header != b'\n':
                        line = header % b'Marker'
                    else:
                        line = header
                fout.write(line)

    if (b'3.0' in header):  # unsupported version
        with pytest.warns(RuntimeWarning, match=r'3\.0.*Contact MNE-Python'):
            read_raw_brainvision(use_vhdr_path)
        return
    elif header == b'\n':  # no version header
        with pytest.warns(RuntimeWarning, match='Missing header'):
            read_raw_brainvision(use_vhdr_path)
        return
    else:
        raw = read_raw_brainvision(use_vhdr_path)
        data_new, _ = raw[:]
        assert_allclose(data_new, data_expected, atol=1e-15)

@pytest.mark.parametrize('data_sep', (b' ', b',', b'+'))
def test_ascii(tmp_path, data_sep):
    """Test ASCII BV reading."""
    raw = read_raw_brainvision(vhdr_path)
    ascii_vhdr_path = op.join(tmp_path, op.split(vhdr_path)[-1])
    # copy marker file
    shutil.copy(vhdr_path.replace('.vhdr', '.vmrk'),
                ascii_vhdr_path.replace('.vhdr', '.vmrk'))
    # modify header file
    skipping = False
    with open(ascii_vhdr_path, 'wb') as fout:
        with open(vhdr_path, 'rb') as fin:
            for line in fin:
                # Common Infos section
                if line.startswith(b'DataFormat'):
                    line = b'DataFormat=ASCII\n'
                elif line.startswith(b'DataFile='):
                    line = b'DataFile=test.dat\n'
                # Replace the "'Binary Infos'" section
                elif line.startswith(b'[Binary Infos]'):
                    skipping = True
                    fout.write(b'[ASCII Infos]\nDecimalSymbol=.\nSkipLines=1\n'
                               b'SkipColumns=0\n\n')
                elif skipping and line.startswith(b'['):
                    skipping = False
                if not skipping:
                    fout.write(line)
    # create the .dat file
    data, times = raw[:]
    with open(ascii_vhdr_path.replace('.vhdr', '.dat'), 'wb') as fid:
        fid.write(data_sep.join(ch_name.encode('ASCII')
                                for ch_name in raw.ch_names) + b'\n')
        fid.write(b'\n'.join(b' '.join(b'%.3f' % dd for dd in d)
                             for d in data.T / raw._cals))

    if data_sep == b';':
        with pytest.raises(RuntimeError, match='Unknown.*data format'):
            read_raw_brainvision(ascii_vhdr_path)
        return

    raw = read_raw_brainvision(ascii_vhdr_path)
    data_new, times_new = raw[:]
    assert_allclose(data_new, data, atol=1e-15)
    assert_allclose(times_new, times)

def test_ch_names_comma(tmp_path):
    """Test that channel names containing commas are properly read."""
    # commas in BV are encoded as \1
    replace_dict = {
        r"^Ch4=F4,": r"Ch4=F4\\1foo,",
        r"^4\s\s\s\s\sF4": "4     F4,foo ",
    }

    # Copy existing vhdr file to tmp_path and manipulate to contain
    # a channel with comma
    for src, dest in zip((vhdr_path, vmrk_path, eeg_path),
                         ('test.vhdr', 'test.vmrk', 'test.eeg')):
        shutil.copyfile(src, tmp_path / dest)

    comma_vhdr = tmp_path / 'test.vhdr'
    with open(comma_vhdr, 'r') as fin:
        lines = fin.readlines()

    new_lines = []
    nperformed_replacements = 0
    for line in lines:
        for to_replace, replacement in replace_dict.items():
            match = re.search(to_replace, line)
            if match is not None:
                new = re.sub(to_replace, replacement, line)
                new_lines.append(new)
                nperformed_replacements += 1
                break
        else:
            new_lines.append(line)
    assert nperformed_replacements == len(replace_dict)

    with open(comma_vhdr, 'w') as fout:
        fout.writelines(new_lines)

    # Read the line containing a "comma channel name"
    raw = read_raw_brainvision(comma_vhdr)
    assert "F4,foo" in raw.ch_names

def test_brainvision_data_highpass_filters():
    """Test reading raw Brain Vision files with amplifier filter settings."""
    # Homogeneous highpass in seconds (default measurement unit)
    raw = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_highpass_path, eog=eog
    )

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 250.)

    # Heterogeneous highpass in seconds (default measurement unit)
    with pytest.warns(RuntimeWarning, match='different .*pass filters') as w:
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_highpass_path,
            eog=eog)

    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(lowpass_warning, highpass_warning)

    assert (all(any([lp, hp]) for lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 250.)

    # Homogeneous highpass in Hertz
    raw = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_highpass_hz_path,
        eog=eog)

    assert_equal(raw.info['highpass'], 10.)
    assert_equal(raw.info['lowpass'], 250.)

    # Heterogeneous highpass in Hertz
    with pytest.warns(RuntimeWarning, match='different .*pass filters') as w:
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_highpass_hz_path,
            eog=eog)

    trigger_warning = ['will be dropped' in str(ww.message)
                       for ww in w]
    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(trigger_warning, lowpass_warning, highpass_warning)

    assert (all(any([trg, lp, hp]) for trg, lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 5.)
    assert_equal(raw.info['lowpass'], 250.)

def test_brainvision_data_lowpass_filters():
    """Test files with amplifier LP filter settings."""
    # Homogeneous lowpass in Hertz (default measurement unit)
    raw = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_lowpass_path, eog=eog
    )

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 250.)

    # Heterogeneous lowpass in Hertz (default measurement unit)
    with pytest.warns(RuntimeWarning) as w:  # event parsing
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_lowpass_path, eog=eog
        )

    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(lowpass_warning, highpass_warning)

    assert (all(any([lp, hp]) for lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 250.)

    # Homogeneous lowpass in seconds
    raw = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_lowpass_s_path, eog=eog
    )

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 1. / (2 * np.pi * 0.004))

    # Heterogeneous lowpass in seconds
    with pytest.warns(RuntimeWarning) as w:  # filter settings
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_mixed_lowpass_s_path, eog=eog
        )

    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(lowpass_warning, highpass_warning)

    assert (all(any([lp, hp]) for lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 10))
    assert_equal(raw.info['lowpass'], 1. / (2 * np.pi * 0.004))

def test_brainvision_data_partially_disabled_hw_filters():
    """Test heterogeneous filter settings including non-numeric values."""
    with pytest.warns(RuntimeWarning) as w:  # event parsing
        raw = _test_raw_reader(
            read_raw_brainvision,
            vhdr_fname=vhdr_partially_disabled_hw_filter_path, eog=eog
        )

    trigger_warning = ['will be dropped' in str(ww.message)
                       for ww in w]
    lowpass_warning = ['different lowpass filters' in str(ww.message)
                       for ww in w]
    highpass_warning = ['different highpass filters' in str(ww.message)
                        for ww in w]

    expected_warnings = zip(trigger_warning, lowpass_warning, highpass_warning)

    assert (all(any([trg, lp, hp]) for trg, lp, hp in expected_warnings))

    assert_equal(raw.info['highpass'], 0.)
    assert_equal(raw.info['lowpass'], 500.)

def test_brainvision_data_software_filters_latin1_global_units():
    """Test reading raw Brain Vision files."""
    with pytest.warns(RuntimeWarning, match='software filter'):
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_old_path,
            eog=("VEOGo", "VEOGu", "HEOGli", "HEOGre"), misc=("A2",))

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 0.9))
    assert_equal(raw.info['lowpass'], 50.)

    # test sensor name with spaces (#9299)
    with pytest.warns(RuntimeWarning, match='software filter'):
        raw = _test_raw_reader(
            read_raw_brainvision, vhdr_fname=vhdr_old_longname_path,
            eog=("VEOGo", "VEOGu", "HEOGli", "HEOGre"), misc=("A2",))

    assert_equal(raw.info['highpass'], 1. / (2 * np.pi * 0.9))
    assert_equal(raw.info['lowpass'], 50.)

def test_brainvision_data():
    """Test reading raw Brain Vision files."""
    pytest.raises(IOError, read_raw_brainvision, vmrk_path)
    pytest.raises(ValueError, read_raw_brainvision, vhdr_path,
                  preload=True, scale="foo")

    raw_py = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_path, eog=eog, misc='auto'
    )

    assert ('RawBrainVision' in repr(raw_py))

    assert_equal(raw_py.info['highpass'], 0.)
    assert_equal(raw_py.info['lowpass'], 250.)

    picks = pick_types(raw_py.info, meg=False, eeg=True, exclude='bads')
    data_py, times_py = raw_py[picks]

    # compare with a file that was generated using MNE-C
    raw_bin = read_raw_fif(eeg_bin, preload=True)
    picks = pick_types(raw_py.info, meg=False, eeg=True, exclude='bads')
    data_bin, times_bin = raw_bin[picks]

    assert_array_almost_equal(data_py, data_bin)
    assert_array_almost_equal(times_py, times_bin)

    # Make sure EOG channels are marked correctly
    for ch in raw_py.info['chs']:
        if ch['ch_name'] in eog:
            assert_equal(ch['kind'], FIFF.FIFFV_EOG_CH)
        elif ch['ch_name'] == 'STI 014':
            assert_equal(ch['kind'], FIFF.FIFFV_STIM_CH)
        elif ch['ch_name'] in ('CP5', 'CP6'):
            assert_equal(ch['kind'], FIFF.FIFFV_MISC_CH)
            assert_equal(ch['unit'], FIFF.FIFF_UNIT_NONE)
        elif ch['ch_name'] == 'ReRef':
            assert_equal(ch['kind'], FIFF.FIFFV_MISC_CH)
            assert_equal(ch['unit'], FIFF.FIFF_UNIT_CEL)
        elif ch['ch_name'] in raw_py.info['ch_names']:
            assert_equal(ch['kind'], FIFF.FIFFV_EEG_CH)
            assert_equal(ch['unit'], FIFF.FIFF_UNIT_V)
        else:
            raise RuntimeError("Unknown Channel: %s" % ch['ch_name'])

    # test loading v2
    read_raw_brainvision(vhdr_v2_path, eog=eog, preload=True,
                         verbose='error')
    # test different units with alternative header file
    raw_units = _test_raw_reader(
        read_raw_brainvision, vhdr_fname=vhdr_units_path, eog=eog, misc='auto'
    )
    assert_equal(raw_units.info['chs'][0]['ch_name'], 'FP1')
    assert_equal(raw_units.info['chs'][0]['kind'], FIFF.FIFFV_EEG_CH)
    data_units, _ = raw_units[0]
    assert_array_almost_equal(data_py[0, :], data_units.squeeze())

    assert_equal(raw_units.info['chs'][1]['ch_name'], 'FP2')
    assert_equal(raw_units.info['chs'][1]['kind'], FIFF.FIFFV_EEG_CH)
    data_units, _ = raw_units[1]
    assert_array_almost_equal(data_py[1, :], data_units.squeeze())

    assert_equal(raw_units.info['chs'][2]['ch_name'], 'F3')
    assert_equal(raw_units.info['chs'][2]['kind'], FIFF.FIFFV_EEG_CH)
    data_units, _ = raw_units[2]
    assert_array_almost_equal(data_py[2, :], data_units.squeeze())

def test_brainvision_vectorized_data():
    """Test reading BrainVision data files with vectorized data."""
    with pytest.warns(RuntimeWarning, match='software filter'):
        raw = read_raw_brainvision(vhdr_old_path, preload=True)

    assert_array_equal(raw._data.shape, (29, 251))

    first_two_samples_all_chs = np.array([[+5.22000008e-06, +5.10000000e-06],
                                          [+2.10000000e-06, +2.27000008e-06],
                                          [+1.15000000e-06, +1.33000002e-06],
                                          [+4.00000000e-07, +4.00000000e-07],
                                          [-3.02999992e-06, -2.82000008e-06],
                                          [+2.71000004e-06, +2.45000000e-06],
                                          [+2.41000004e-06, +2.36000004e-06],
                                          [+1.01999998e-06, +1.18000002e-06],
                                          [-1.33999996e-06, -1.25000000e-06],
                                          [-2.60000000e-06, -2.46000004e-06],
                                          [+6.80000019e-07, +8.00000000e-07],
                                          [+1.48000002e-06, +1.48999996e-06],
                                          [+1.61000004e-06, +1.51000004e-06],
                                          [+7.19999981e-07, +8.60000038e-07],
                                          [-3.00000000e-07, -4.00000006e-08],
                                          [-1.20000005e-07, +6.00000024e-08],
                                          [+8.19999981e-07, +9.89999962e-07],
                                          [+1.13000002e-06, +1.28000002e-06],
                                          [+1.08000002e-06, +1.33999996e-06],
                                          [+2.20000005e-07, +5.69999981e-07],
                                          [-4.09999990e-07, +4.00000006e-08],
                                          [+5.19999981e-07, +9.39999962e-07],
                                          [+1.01000004e-06, +1.51999998e-06],
                                          [+1.01000004e-06, +1.55000000e-06],
                                          [-1.43000002e-06, -1.13999996e-06],
                                          [+3.65000000e-06, +3.65999985e-06],
                                          [+4.15999985e-06, +3.79000015e-06],
                                          [+9.26999969e-06, +8.95999985e-06],
                                          [-7.35999985e-06, -7.18000031e-06],
                                          ])

    assert_array_almost_equal(raw._data[:, :2], first_two_samples_all_chs)

def test_coodinates_extraction():
    """Test reading of [Coordinates] section if present."""
    # vhdr 2 has a Coordinates section
    with pytest.warns(RuntimeWarning, match='coordinate information'):
        raw = read_raw_brainvision(vhdr_v2_path)

    # Basic check of extracted coordinates
    assert raw.info['dig'] is not None
    diglist = raw.info['dig']
    coords = np.array([dig['r'] for dig in diglist])
    EXPECTED_SHAPE = (
        len(raw.ch_names) - 4,  # HL, HR, Vb, ReRef are not set in dig
        3,
    )
    assert coords.shape == EXPECTED_SHAPE

    # Make sure the scaling seems right
    # a coordinate more than 20cm away from origin is implausible
    assert coords.max() < 0.2

    # vhdr 1 does not have a Coordinates section
    raw2 = read_raw_brainvision(vhdr_path)
    assert raw2.info['dig'] is None

@testing.requires_testing_data
def test_brainvision_neuroone_export():
    """Test Brainvision file exported with neuroone system."""
    raw = read_raw_brainvision(neuroone_vhdr, verbose='error')
    assert raw.info['meas_date'] is None
    assert len(raw.info['chs']) == 65
    assert raw.info['sfreq'] == 5000.

@testing.requires_testing_data
def test_read_vmrk_annotations(tmp_path):
    """Test load brainvision annotations."""
    sfreq = 1000.0

    # Test vmrk file without annotations
    # delete=False is for Windows compatibility
    with open(vmrk_path) as myfile:
        head = [next(myfile) for x in range(6)]
    fname = tmp_path / 'temp.vmrk'
    with open(str(fname), 'w') as temp:
        for item in head:
            temp.write(item)
    read_annotations(fname, sfreq=sfreq)

@testing.requires_testing_data
def test_read_vhdr_annotations_and_events(tmp_path):
    """Test load brainvision annotations and parse them to events."""
    # First we add a custom event that contains a comma in its description
    for src, dest in zip((vhdr_path, vmrk_path, eeg_path),
                         ('test.vhdr', 'test.vmrk', 'test.eeg')):
        shutil.copyfile(src, tmp_path / dest)

    # Commas are encoded as "\1"
    with open(tmp_path / 'test.vmrk', 'a') as fout:
        fout.write(r"Mk15=Comma\1Type,CommaValue\11,7800,1,0\n")

    sfreq = 1000.0
    expected_orig_time = _stamp_to_dt((1384359243, 794232))
    expected_onset_latency = np.array(
        [0, 486., 496., 1769., 1779., 3252., 3262., 4935., 4945., 5999., 6619.,
         6629., 7629., 7699., 7799.]
    )
    expected_annot_description = [
        'New Segment/', 'Stimulus/S253', 'Stimulus/S255', 'Event/254',
        'Stimulus/S255', 'Event/254', 'Stimulus/S255', 'Stimulus/S253',
        'Stimulus/S255', 'Response/R255', 'Event/254', 'Stimulus/S255',
        'SyncStatus/Sync On', 'Optic/O  1', 'Comma,Type/CommaValue,1'
    ]
    expected_events = np.stack([
        expected_onset_latency,
        np.zeros_like(expected_onset_latency),
        [99999, 253, 255, 254, 255, 254, 255, 253, 255, 1255, 254, 255, 99998,
         2001, 10001],
    ]).astype('int64').T
    expected_event_id = {'New Segment/': 99999, 'Stimulus/S253': 253,
                         'Stimulus/S255': 255, 'Event/254': 254,
                         'Response/R255': 1255, 'SyncStatus/Sync On': 99998,
                         'Optic/O  1': 2001, 'Comma,Type/CommaValue,1': 10001}

    raw = read_raw_brainvision(tmp_path / 'test.vhdr', eog=eog)

    # validate annotations
    assert raw.annotations.orig_time == expected_orig_time
    assert_allclose(raw.annotations.onset, expected_onset_latency / sfreq)
    assert_array_equal(raw.annotations.description, expected_annot_description)

    # validate event extraction
    events, event_id = events_from_annotations(raw)
    assert_array_equal(events, expected_events)
    assert event_id == expected_event_id

    # validate that None gives us a sorted list
    expected_none_event_id = {desc: idx + 1 for idx, desc in enumerate(sorted(
        event_id.keys()))}
    events, event_id = events_from_annotations(raw, event_id=None)
    assert event_id == expected_none_event_id

    # Add some custom ones, plus a 2-digit one
    s_10 = 'Stimulus/S 10'
    raw.annotations.append([1, 2, 3], 10, ['ZZZ', s_10, 'YYY'])
    # others starting at 10001 ...
    # we already have "Comma,Type/CommaValue,1" as 10001
    expected_event_id.update(YYY=10002, ZZZ=10003)
    expected_event_id[s_10] = 10
    _, event_id = events_from_annotations(raw)
    assert event_id == expected_event_id

    # Concatenating two shouldn't change the resulting event_id
    # (BAD and EDGE should be ignored)
    with pytest.warns(RuntimeWarning, match='expanding outside'):
        raw_concat = concatenate_raws([raw.copy(), raw.copy()])
    _, event_id = events_from_annotations(raw_concat)
    assert event_id == expected_event_id

@testing.requires_testing_data
def test_automatic_vmrk_sfreq_recovery():
    """Test proper sfreq inference by checking the onsets."""
    assert_array_equal(read_annotations(vmrk_path, sfreq='auto'),
                       read_annotations(vmrk_path, sfreq=1000.0))

@testing.requires_testing_data
def test_event_id_stability_when_save_and_fif_reload(tmp_path):
    """Test load events from brainvision annotations when read_raw_fif."""
    fname = tmp_path / 'bv-raw.fif'
    raw = read_raw_brainvision(vhdr_path, eog=eog)
    original_events, original_event_id = events_from_annotations(raw)

    raw.save(fname)
    raw = read_raw_fif(fname)
    events, event_id = events_from_annotations(raw)

    assert event_id == original_event_id
    assert_array_equal(events, original_events)

def test_parse_impedance():
    """Test case for parsing the impedances from header."""
    expected_imp_meas_time = datetime.datetime(2013, 11, 13, 16, 12, 27,
                                               tzinfo=datetime.timezone.utc)
    expected_imp_unit = 'kOhm'
    expected_electrodes = [
        'FP1', 'FP2', 'F3', 'F4', 'C3', 'C4', 'P3', 'P4', 'O1', 'O2', 'F7',
        'F8', 'P7', 'P8', 'Fz', 'FCz', 'Cz', 'CPz', 'Pz', 'POz', 'FC1', 'FC2',
        'CP1', 'CP2', 'FC5', 'FC6', 'CP5', 'CP6', 'HL', 'HR', 'Vb', 'ReRef',
        'Ref', 'Gnd'
    ]
    n_electrodes = len(expected_electrodes)
    expected_imps = [np.nan] * (n_electrodes - 2) + [0., 4.]
    expected_imp_lower_bound = 0.
    expected_imp_upper_bound = [100.] * (n_electrodes - 2) + [10., 10.]

    expected_impedances = {elec: {
        'imp': expected_imps[i],
        'imp_unit': expected_imp_unit,
        'imp_meas_time': expected_imp_meas_time,
        'imp_lower_bound': expected_imp_lower_bound,
        'imp_upper_bound': expected_imp_upper_bound[i],
        'imp_range_unit': expected_imp_unit,
    } for i, elec in enumerate(expected_electrodes)}

    raw = read_raw_brainvision(vhdr_path, eog=eog)
    assert object_diff(expected_impedances, raw.impedances) == ''

    # Test "Impedances Imported from actiCAP Control Software"
    expected_imp_meas_time = expected_imp_meas_time.replace(hour=10,
                                                            minute=17,
                                                            second=2)
    tmpidx = expected_electrodes.index('CP6')
    expected_electrodes = expected_electrodes[:tmpidx] + [
        'CP 6', 'ECG+', 'ECG-', 'HEOG+', 'HEOG-', 'VEOG+', 'VEOG-', 'ReRef',
        'Ref', 'Gnd'
    ]
    n_electrodes = len(expected_electrodes)
    expected_imps = [np.nan] * (n_electrodes - 9) + [
        35., 46., 6., 8., 3., 4., 0., 8., 2.5
    ]
    expected_impedances = {elec: {
        'imp': expected_imps[i],
        'imp_unit': expected_imp_unit,
        'imp_meas_time': expected_imp_meas_time,
    } for i, elec in enumerate(expected_electrodes)}

    with pytest.warns(RuntimeWarning, match='different .*pass filters'):
        raw = read_raw_brainvision(vhdr_mixed_lowpass_path,
                                   eog=['HEOG', 'VEOG'], misc=['ECG'])
    assert object_diff(expected_impedances, raw.impedances) == ''


text:
package org.openbel.framework.ws.model;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
 * TODO - Document
 *
 *
Java class for NamespaceFilterCriteria complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="NamespaceFilterCriteria">
 *   <complexContent>
 *     <extension base="{http://belframework.org/ws/schemas}FilterCriteria">
 *       <sequence>
 *         <element name="valueSet" type="{http://belframework.org/ws/schemas}Namespace" maxOccurs="unbounded"/>
 *       </sequence>
 *     </extension>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NamespaceFilterCriteria", propOrder = {
        "valueSet"
})
public class NamespaceFilterCriteria
        extends FilterCriteria
{

    @XmlElement(required = true)
    protected List<Namespace> valueSet;

    /**
     * Gets the value of the valueSet property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the valueSet property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getValueSet().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Namespace }
     *
     *
     */
    public List<Namespace> getValueSet() {
        if (valueSet == null) {
            valueSet = new ArrayList<Namespace>();
        }
        return this.valueSet;
    }

}


text:
package com.vaadin.server;

import java.io.Serializable;
import java.util.function.ToIntFunction;

/**
 * A {@link ToIntFunction} that is also {@link Serializable}.
 *
 * @see ToIntFunction
 * @author Vaadin Ltd
 * @since 8.0
 *
 * @param <T>
 *            the type of the input for this function
 */
@FunctionalInterface
public interface SerializableToIntFunction<T>
        extends ToIntFunction<T>, Serializable {
    // Only method inherited from ToIntFunction
}


text:
#pragma once

#include <QVariant>
#include <QObject>

#include "src/ljfriend.h"
#include "cachedmodel.h"

namespace Mnemosy
{
class LJFriendsModel : public CachedModel<LJFriend>
{
    Q_OBJECT

public:
    enum LJFriendRoles
    {
        FRAvatar = Qt::UserRole + 1,
        FRFullName,
        FRUserName,
        FRGroupMask,
        FRBirthday,
        FRFriendOf,
        FRMyFriend,
        FRBGColor,
        FRFGColor
    };

    explicit LJFriendsModel(QObject *parent = 0);
    virtual ~LJFriendsModel();

    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
    virtual QHash<int, QByteArray> roleNames() const;

    void AddFriend(const LJFriend& fr);
    void EditFriend(const QString& name, const int groupMask);
    void DeleteFriend(const QString& name);

    void SetFriendAvatar(const QString& userName, const QUrl& avatar);

    Q_INVOKABLE QVariantMap get(int index) const;
};
} // namespace Mnemosy


text:
using System.Collections.Generic;

using DynamicTranslator.Configuration.Startup;
using DynamicTranslator.Constants;
using DynamicTranslator.LanguageManagement;

namespace DynamicTranslator.Application.Zargan.Configuration
{
    public class ZarganTranslatorConfiguration : AbstractTranslatorConfiguration, IZarganTranslatorConfiguration
    {
        public override IList<Language> SupportedLanguages { get; set; }

        public override string Url { get; set; }

        public override TranslatorType TranslatorType => TranslatorType.Zargan;
    }
}


text:
//------------------------------------------------------------------------------
// <copyright file="LineCap.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace System.Drawing.Drawing2D {

    using System.Diagnostics;

    using System;
    using System.Drawing;

    /**
     * Line cap constants
     */
    /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap"]/*' />
    /// <devdoc>
    ///    Specifies the available cap
    ///    styles with which a <see cref='System.Drawing.Pen'/> can end a line.
    /// </devdoc>
    public enum LineCap
    {
        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.Flat"]/*' />
        /// <devdoc>
        ///    Specifies a flat line cap.
        /// </devdoc>
        Flat             = 0,
        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.Square"]/*' />
        /// <devdoc>
        ///    Specifies a square line cap.
        /// </devdoc>
        Square           = 1,
        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.Round"]/*' />
        /// <devdoc>
        ///    Specifies a round line cap.
        /// </devdoc>
        Round            = 2,
        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.Triangle"]/*' />
        /// <devdoc>
        ///    Specifies a triangular line cap.
        /// </devdoc>
        Triangle         = 3,

        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.NoAnchor"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        NoAnchor         = 0x10, // corresponds to flat cap
        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.SquareAnchor"]/*' />
        /// <devdoc>
        ///    Specifies no line cap.
        /// </devdoc>
        SquareAnchor     = 0x11, // corresponds to square cap
        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.RoundAnchor"]/*' />
        /// <devdoc>
        ///    Specifies a round anchor cap.
        /// </devdoc>
        RoundAnchor      = 0x12, // corresponds to round cap
        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.DiamondAnchor"]/*' />
        /// <devdoc>
        ///    Specifies a diamond anchor cap.
        /// </devdoc>
        DiamondAnchor    = 0x13, // corresponds to triangle cap
        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.ArrowAnchor"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Specifies an arrow-shaped anchor cap.
        ///    </para>
        /// </devdoc>
        ArrowAnchor      = 0x14, // no correspondence

        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.Custom"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Specifies a custom line cap.
        ///    </para>
        /// </devdoc>
        Custom           = 0xff, // custom cap

        /// <include file='doc\LineCap.uex' path='docs/doc[@for="LineCap.AnchorMask"]/*' />
        /// <devdoc>
        ///    Specifies a mask used to check whether a
        ///    line cap is an anchor cap.
        /// </devdoc>
        AnchorMask       = 0xf0  // mask to check for anchor or not.
    }

}


text:
namespace _2STBV.Common.Classes
{
    public class Document
    {
        public string file_id { get; set; }

        public PhotoSize thumb { get; set; }

        public string file_name { get; set; }

        public string mime_type { get; set; }

        public int? file_size { get; set; }
    }
}


text:
const url = require('url');
const { expect } = require('chai').use(require('chai-as-promised'));

const meanConfig = require('meanio').loadConfig();

const num = new Date().getTime();
const rootUrl = new url.URL(process.env.ROOT_URL || meanConfig.host);

if(!process.env.ROOT_URL) {
  rootUrl.port = meanConfig.https.port || meanConfig.http.port;
}

describe('Root', function() {

  describe('Authentication', function() {
    it('Navigate to site', function() {
      browser.driver.get(rootUrl.href);
      expect(browser.driver.getTitle()).to.eventually.equal('ICU');
    });

    it('Navigate to registration', function() {
      element(by.css('[class="or-register ng-binding"]')).click();
      expect(browser.getCurrentUrl()).to.eventually.match(/register$/);
    });

    it('Register', function() {
      // fill input fields
      element(by.model('credentials.name')).sendKeys("Test" + num);
      element(by.model('credentials.email')).sendKeys("testsqaqa+" + num + "@gmail.com");
      element(by.model('credentials.username')).sendKeys("Test+" + num);
      element(by.model('credentials.password')).sendKeys("newstrat");
      element(by.model('credentials.confirmPassword')).sendKeys("newstrat");

      // submit
      element(by.className('btn')).click();

      browser.driver.wait(function() {
        return element(by.css('.add-menu')).isPresent();
      }, 5000);
      expect(browser.getCurrentUrl()).to.eventually.match(/tasks$/);
    });

    it('Confirm the "What\'s new" popup', function() {
      //element(by.buttonText('Don\'t show me again')).click();
      element(by.buttonText('אל תראה לי שוב')).click();
      browser.waitForAngular();
    })

    it('Logout', function() {
      element(by.css('.user-menu')).click();
      // element(by.linkText('Logout')).click();
      element(by.linkText('התנתק')).click();
      browser.driver.wait(function() {
        return element(by.className('login-page')).isPresent();
      }, 3000);
      expect(browser.getCurrentUrl()).to.eventually.match(/login$/);
    });

    it('Login again', function() {
      let userIcon = element(by.css('.user-menu .avatar span'));

      // fill input fields
      element(by.model('credentials.email')).sendKeys("testsqaqa+" + num + "@gmail.com");
      element(by.model('credentials.password')).sendKeys("newstrat");

      // submit
      // element(by.buttonText('Login')).click();
      element(by.buttonText('התחבר')).click();

      browser.driver.wait(function() {
        return userIcon.isPresent();
      }, 3000);

      expect(userIcon.getText()).to.eventually.equal('T');
    });
  });

  describe('Project', function() {
    let pName = 'NewProjectTest';
    let tName = 'NewTaskTestForProject';

    it('Create project', function() {
      element(by.css('.add-menu')).click();
      // element(by.cssContainingText('.add-menu a span', 'Project')).click();
      element(by.cssContainingText('.add-menu a span', 'פרויקט')).click();
      browser.waitForAngular();
    });

    it('Set project name', function() {
      element(by.css('.item-title')).sendKeys(pName);
      expect(element(by.css('.projects tr.active td.name')).getText()).to.eventually.equal(pName);
    });

    it('Set project color', function() {
      element(by.css('.select-box .arrow')).click();
      element.all(by.repeater('color in colors')).get(4).click();
      var colorBox = element(by.css('.color-box'));
      expect(colorBox.getAttribute('style')).to.eventually.equal('background-color: rgb(240, 110, 170);');
    });

    it('Create task', function() {
      element(by.css('.add-menu')).click();
      // element(by.cssContainingText('.add-menu a span', 'Task')).click();
      element(by.cssContainingText('.add-menu a span', 'משימה')).click();
      browser.waitForAngular();
    });

    it('Set task name', function() {
      element(by.css('.item-title')).sendKeys(tName);
      expect(element(by.css('.projects tr.active td.name')).getText()).to.eventually.equal(tName);
      expect(element(by.css('.projects tr.active td.project span')).getText()).to.eventually.equal(pName);
    });

    it('Add watcher', function() {
      element(by.css('#addMember')).click();
      let member = element(by.css('.new-member-input'));
      let input = member.element(by.model('$select.search'));

      member.element(by.css('[ng-click="$select.activate()"]')).click();

      input.clear().sendKeys("Test" + num);
      input.sendKeys(protractor.Key.ARROW_DOWN);
      input.sendKeys(protractor.Key.ENTER);
      expect(input.getAttribute('value')).to.eventually.equal("Test" + num);
    });
  });

  describe('Discussion', function() {

    let dName = 'NewDiscussionTest';
    let tName = 'NewTaskTestForDiscussion';

    it('Create disscussion', function() {
      element(by.css('.add-menu')).click();
      // element(by.cssContainingText('.add-menu a span', 'Discussion')).click();
      element(by.cssContainingText('.add-menu a span', 'דיון')).click();
      browser.waitForAngular();
    });

    it('Set discussion name', function() {
      element(by.css('.item-title')).sendKeys(dName);
      expect(element(by.css('.projects tr.active td.name')).getText())
        .to.eventually.equal(dName);
    });

    it('Set assignee', function() {
      let assign = element(by.css('.entity-details detail-assign'));
      let input = assign.element(by.model('$select.search'));

      assign.element(by.css('span[tabindex]')).click();

      input.clear().sendKeys("Test" + num);
      input.sendKeys(protractor.Key.ARROW_DOWN);
      input.sendKeys(protractor.Key.ENTER);
      expect(element(by.css('detail-assign .summary-content')).getText())
        .to.eventually.equal("Test" + num);
    });

    it('Set due date', function() {
      var input = element(by.css('discussion-due .detail-due input'))
      input.click();
      browser.waitForAngular();
      element(by.css('#allDay')).click();
      element(by.css('#startDate')).click();
      element(by.css('.ui-datepicker-next')).click();
      element(by.css('.ui-datepicker')).element(by.linkText('1')).click();
      browser.waitForAngular();

      element(by.css('#firstStr')).getText().then(function(text) {
        // reverse order to YYYY/M/D, in order to get correct date by Date constructor
        text = text.split('/').reverse().join('/');

        let expectedDate = new Date();
        expectedDate.setMonth(expectedDate.getMonth()+1, 1);
        let actualDate = new Date(text);
        expect(actualDate.toDateString()).to.equal(expectedDate.toDateString());
      })
    });

    it('Set location', function() {
      element(by.css('.location input')).sendKeys('Test place');
    });

    it('Schedule discussion', function() {
      // element(by.buttonText('Schedule discussion')).click();
      element(by.buttonText('זמן דיון')).click();
      browser.waitForAngular();
      let status = element(by.css('detail-status .ui-select-match-text span'));
      // expect(status.getText()).to.eventually.equal('Scheduled');
      expect(status.getText()).to.eventually.equal('זומן');
    });

    it('Add watcher', function() {
      element(by.css('#addMember')).click();
      let member = element(by.css('.new-member-input'));
      let input = member.element(by.model('$select.search'));

      member.element(by.css('[ng-click="$select.activate()"]')).click();

      input.clear().sendKeys("Test" + num);
      input.sendKeys(protractor.Key.ARROW_DOWN);
      input.sendKeys(protractor.Key.ENTER);
      expect(input.getAttribute('value')).to.eventually.equal("Test" + num);
    });

    it('Create task', function() {
      // element(by.buttonText('Manage Tasks')).click();
      element(by.css('.detail-tabs-switcher')).element(by.buttonText('משימות')).click();
      // element(by.css('.detail-tabs-switcher')).element(by.buttonText('משימות')).click();
      element(by.buttonText('נהל משימות')).click();
      element(by.css('.projects .create-new-item')).click();
      element(by.css('.item-title')).sendKeys(tName);
      expect(element(by.css('.projects tr.active td.name')).getText()).to.eventually.equal(tName);
    });
  });
});


text:
major_platform_version = node['platform_version'].to_i
key = 'RPM-GPG-KEY'

# Ensure that we have the proper LWRPs available
case node['platform_family']
when 'rhel'
  include_recipe 'yum'
when 'debian'
  include_recipe 'apt'
end

# Set defaults for version, based on distribution
node.default['hadoop']['distribution_version'] =
  if node['hadoop']['distribution'] == 'hdp'
    '2.1'
  elsif node['hadoop']['distribution'] == 'cdh'
    '5'
  elsif node['hadoop']['distribution'] == 'bigtop'
    '0.8.0'
  end

case node['hadoop']['distribution']
when 'hdp'
  case node['hadoop']['distribution_version']
  when '2.0.5.0', '2.0.6.0', '2.0.6.1', '2.0.10.0', '2.0.11.0', '2.0.12.0', '2.0.13.0'
    hdp_version = '2.0.4.0'
    hdp_update_version = node['hadoop']['distribution_version']
  when '2.0'
    hdp_version = '2.0.4.0'
    hdp_update_version = '2.0.13.0'
  when '2.1.1.0', '2.0.4.0'
    hdp_version = node['hadoop']['distribution_version']
    hdp_update_version = nil
  when '2.1.2.0', '2.1.2.1', '2.1.3.0', '2.1.4.0', '2.1.5.0', '2.1.7.0'
    hdp_version = '2.1.1.0'
    hdp_update_version = node['hadoop']['distribution_version']
  when '2.1'
    hdp_version = '2.1.1.0'
    hdp_update_version = '2.1.7.0'
  when '2.2.0.0', '2.2', '2'
    hdp_version = '2.2.0.0'
    hdp_update_version = nil
  else
    Chef::Application.fatal!('This cookbook only supports HDP 2.x')
  end

  hdp_utils_version = '1.1.0.20'

  case node['platform_family']
  when 'rhel'
    yum_base_url = 'http://public-repo-1.hortonworks.com/HDP'
    if major_platform_version == 5
      os = "centos#{major_platform_version}"
    else
      os = 'centos6'
    end

    yum_repo_url = node['hadoop']['yum_repo_url'] ? node['hadoop']['yum_repo_url'] : "#{yum_base_url}/#{os}/2.x/GA/#{hdp_version}"
    yum_repo_key_url = node['hadoop']['yum_repo_key_url'] ? node['hadoop']['yum_repo_key_url'] : "#{yum_base_url}/#{os}/#{key}/#{key}-Jenkins"

    yum_repository 'hdp' do
      name 'HDP-2.x'
      description 'Hortonworks Data Platform Version - HDP-2.x'
      url yum_repo_url
      gpgkey yum_repo_key_url
      action :add
    end
    if hdp_update_version.nil?
      yum_repository 'hdp-updates' do
        name 'Updates-HDP-2.x'
        description 'Updates for Hortonworks Data Platform Version - HDP-2.x'
        url "#{yum_base_url}/#{os}/2.x/updates"
        gpgkey yum_repo_key_url
        action :add
      end
    else
      yum_repository 'hdp-updates' do
        name 'Updates-HDP-2.x'
        description 'Updates for Hortonworks Data Platform Version - HDP-2.x'
        url "#{yum_base_url}/#{os}/2.x/updates/#{hdp_update_version}"
        gpgkey yum_repo_key_url
        action :add
      end
    end
    yum_repository 'hdp-utils' do
      name "HDP-UTILS-#{hdp_utils_version}"
      description "Hortonworks Data Platform Utils Version - HDP-UTILS-#{hdp_utils_version}"
      url "#{yum_base_url}-UTILS-#{hdp_utils_version}/repos/#{os}"
      gpgkey yum_repo_key_url
      action :add
    end

  when 'debian'
    apt_base_url = 'http://public-repo-1.hortonworks.com/HDP'
    # HDP only supports Debian 6 and Ubuntu 12
    case node['platform']
    when 'debian'
      os = "#{node['platform']}6"
    else
      os = "#{node['platform']}12"
    end
    hdp_update_version = hdp_version if hdp_update_version.nil?
    apt_repo_url = node['hadoop']['apt_repo_url'] ? node['hadoop']['apt_repo_url'] : "#{apt_base_url}/#{os}/#{hdp_update_version}"
    # Hortonworks don't know how to provide a key, but we do
    apt_repo_key_url = node['hadoop']['apt_repo_key_url'] ? node['hadoop']['apt_repo_key_url'] : "#{apt_base_url}/centos6/#{key}/#{key}-Jenkins"

    apt_repository 'hdp' do
      uri apt_repo_url
      key apt_repo_key_url
      distribution 'HDP'
      trusted true
      components ['main']
      action :add
    end
    apt_repository 'hdp-utils' do
      uri "#{apt_base_url}-UTILS-#{hdp_utils_version}/repos/#{os}"
      key apt_repo_key_url
      distribution 'HDP-UTILS'
      components ['main']
      action :add
    end
  end # End hdp

when 'cdh'
  cdh_release = node['hadoop']['distribution_version'].to_i
  if node['hadoop']['distribution_version'].to_f >= 5.3 && node.key?('java') && node['java'].key?('jdk_version') && node['java']['jdk_version'] < 7
    Chef::Application.fatal!('CDH 5.3 and above require Java 7 or higher')
  end
  case node['platform_family']
  when 'rhel'
    yum_base_url = "http://archive.cloudera.com/cdh#{cdh_release}/redhat"
    yum_repo_url = node['hadoop']['yum_repo_url'] ? node['hadoop']['yum_repo_url'] : "#{yum_base_url}/#{major_platform_version}/#{node['kernel']['machine']}/cdh/#{node['hadoop']['distribution_version']}"
    yum_repo_key_url = node['hadoop']['yum_repo_key_url'] ? node['hadoop']['yum_repo_key_url'] : "#{yum_base_url}/#{major_platform_version}/#{node['kernel']['machine']}/cdh/#{key}-cloudera"

    yum_repository "cloudera-cdh#{cdh_release}" do
      name "cloudera-cdh#{cdh_release}"
      description "Cloudera's Distribution for Hadoop, Version #{cdh_release}"
      url yum_repo_url
      gpgkey yum_repo_key_url
      action :add
    end

  when 'debian'
    codename = node['lsb']['codename']

    # rubocop: disable Metrics/BlockNesting
    case codename
    when 'raring', 'saucy', 'trusty'
      Chef::Log.warn('This version of Ubuntu is unsupported by Cloudera! Bug reports should include patches.')
      codename = 'precise'
    when 'trusty'
      unless cdh_release >= 5
        Chef::Log.warn('This version of Ubuntu is unsupported by Cloudera! Bug reports should include patches.')
        codename = 'precise'
      end
    end
    # rubocop: enable Metrics/BlockNesting

    apt_base_url = "http://archive.cloudera.com/cdh#{cdh_release}/#{node['platform']}"
    apt_repo_url = node['hadoop']['apt_repo_url'] ? node['hadoop']['apt_repo_url'] : "#{apt_base_url}/#{codename}/amd64/cdh"
    apt_repo_key_url = node['hadoop']['apt_repo_key_url'] ? node['hadoop']['apt_repo_key_url'] : "#{apt_base_url}/#{codename}/amd64/cdh/archive.key"

    apt_repository "cloudera-cdh#{cdh_release}" do
      uri apt_repo_url
      key apt_repo_key_url
      distribution "#{codename}-cdh#{node['hadoop']['distribution_version']}"
      components ['contrib']
      arch 'amd64'
      action :add
    end
  end # End cdh

when 'bigtop'
  bigtop_release = node['hadoop']['distribution_version']

  # allow a developer mode for use when developing against bigtop, see https://issues.cask.co/browse/COOK-1
  if bigtop_release.downcase == 'develop' && !(node['hadoop'].key?('yum_repo_url') || node['hadoop'].key?('apt_repo_url'))
    Chef::Application.fatal!("You must set node['hadoop']['yum_repo_url'] or node['hadoop']['apt_repo_url'] when specifying node['hadoop']['distribution_version'] == 'develop'")
  end

  # do not validate gpg repo keys when in develop mode
  validate_repo_key =  bigtop_release.downcase == 'develop' ? false : true
  Chef::Log.warn('Allowing install of unsigned binaries') unless validate_repo_key

  case node['platform_family']
  when 'rhel'

    case major_platform_version
    when 5, 6
      yum_platform_version = major_platform_version
    when 2014 # Amazon linux, point to redhat/6 bigtop repo
      yum_platform_version = 6
    else
      Chef::Log.warn('Unsupported platform detected, use at your own risk')
      yum_platform_version = major_platform_version
    end

    yum_base_url = "http://bigtop.s3.amazonaws.com/releases/#{bigtop_release}/redhat"
    yum_repo_url = node['hadoop']['yum_repo_url'] ? node['hadoop']['yum_repo_url'] : "#{yum_base_url}/#{yum_platform_version}/#{node['kernel']['machine']}"
    yum_repo_key_url = node['hadoop']['yum_repo_key_url'] ? node['hadoop']['yum_repo_key_url'] : 'http://archive.apache.org/dist/bigtop/KEYS'

    yum_repository "bigtop-#{bigtop_release}" do
      name "bigtop-#{bigtop_release}"
      description "Apache Bigtop Distribution for Hadoop, Version #{bigtop_release}"
      url yum_repo_url
      gpgkey yum_repo_key_url
      gpgcheck validate_repo_key
      action :add
    end

  when 'debian'
    # for bigtop, we do not validate codename, to support developing against custom repositories
    codename = node['lsb']['codename']

    apt_base_url = "http://bigtop.s3.amazonaws.com/releases/#{bigtop_release}/#{node['platform']}"
    apt_repo_url = node['hadoop']['apt_repo_url'] ? node['hadoop']['apt_repo_url'] : "#{apt_base_url}/#{codename}/#{node['kernel']['machine']}"
    apt_repo_key_url = node['hadoop']['apt_repo_key_url'] ? node['hadoop']['apt_repo_key_url'] : 'http://archive.apache.org/dist/bigtop/KEYS'

    apt_repository "bigtop-#{bigtop_release}" do
      uri apt_repo_url
      key apt_repo_key_url
      trusted !validate_repo_key
      distribution 'bigtop'
      components ['contrib']
      action :add
    end
  end
else
  # COOK-25 fail fast
  Chef::Application.fatal!("Invalid node['hadoop']['distribution'] (#{node['hadoop']['distribution']}) specified!")
end


text:
RSpec.configure do |config|
  # == Mock Framework
  config.mock_with :rspec
end


text:
package stream.flarebot.flarebot.commands.secret;

import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import net.dv8tion.jda.core.entities.Member;
import net.dv8tion.jda.core.entities.Message;
import net.dv8tion.jda.core.entities.TextChannel;
import net.dv8tion.jda.core.entities.User;
import org.apache.commons.codec.binary.StringUtils;
import stream.flarebot.flarebot.commands.CommandType;
import stream.flarebot.flarebot.commands.InternalCommand;
import stream.flarebot.flarebot.database.CassandraController;
import stream.flarebot.flarebot.objects.GuildWrapper;
import stream.flarebot.flarebot.util.MessageUtils;

import java.util.Arrays;
import java.util.Base64;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class EvalCommand implements InternalCommand {

    private static PreparedStatement insertSnippet;

    private ScriptEngineManager manager = new ScriptEngineManager();
    private static final ThreadGroup EVAL_POOL = new ThreadGroup("EvalCommand Thread Pool");
    private static final ExecutorService POOL = Executors.newCachedThreadPool(r -> new Thread(EVAL_POOL, r,
            EVAL_POOL.getName() + EVAL_POOL.activeCount()));
    private static final List<String> IMPORTS = Arrays.asList("stream.flarebot.flarebot",
            "stream.flarebot.flarebot.music",
            "stream.flarebot.flarebot.util",
            "stream.flarebot.flarebot.util.general",
            "stream.flarebot.flarebot.util.currency",
            "stream.flarebot.flarebot.util.objects",
            "stream.flarebot.flarebot.objects",
            "stream.flarebot.flarebot.web",
            "stream.flarebot.flarebot.mod",
            "stream.flarebot.flarebot.mod.modlog",
            "stream.flarebot.flarebot.mod.automod",
            "stream.flarebot.flarebot.mod.events",
            "stream.flarebot.flarebot.scheduler",
            "stream.flarebot.flarebot.database",
            "stream.flarebot.flarebot.permissions",
            "stream.flarebot.flarebot.commands",
            "stream.flarebot.flarebot.music.extractors",
            "net.dv8tion.jda.core",
            "net.dv8tion.jda.core.managers",
            "net.dv8tion.jda.core.entities.impl",
            "net.dv8tion.jda.core.entities",
            "net.dv8tion.jda.core.utils",
            "java.util.streams",
            "java.util",
            "java.lang",
            "java.text",
            "java.lang",
            "java.math",
            "java.time",
            "java.io",
            "java.nio",
            "java.nio.files",
            "java.util.stream",
            "org.json");

    @Override
    public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
        if (args.length == 0) {
            channel.sendMessage("Eval something at least smh!").queue();
            return;
        }
        String imports = IMPORTS.stream().map(s -> "import " + s + ".*;").collect(Collectors.joining("\n"));
        ScriptEngine engine = manager.getEngineByName("groovy");
        engine.put("channel", channel);
        engine.put("guild", guild);
        engine.put("message", message);
        engine.put("jda", sender.getJDA());
        engine.put("sender", sender);

        String msg = MessageUtils.getMessage(args);
        final String[] code = {getCode(args)};

        boolean silent = hasOption(Options.SILENT, msg);
        if (hasOption(Options.SNIPPET, msg)) {
            String snippetName = MessageUtils.getNextArgument(msg, Options.SNIPPET.getAsArgument());
            if (snippetName == null) {
                MessageUtils.sendErrorMessage("Please specify the snippet you wish to run! Do `-snippet (name)`", channel);
                return;
            }

            CassandraController.runTask(session -> {
                ResultSet set = session.execute("SELECT encoded_code FROM flarebot.eval_snippets WHERE snippet_name = '"
                        + snippetName + "'");
                Row row = set.one();
                if (row != null) {
                    code[0] =
                            StringUtils.newStringUtf8(Base64.getDecoder().decode(row.getString("encoded_code").getBytes()));
                } else {
                    MessageUtils.sendErrorMessage("That eval snippet does not exist!", channel);
                    code[0] = null;
                }
            });
        }

        if (hasOption(Options.SAVE, msg)) {
            String base64 = Base64.getEncoder().encodeToString(code[0].getBytes());
            CassandraController.runTask(session -> {
                String snippetName = MessageUtils.getNextArgument(msg, Options.SAVE.getAsArgument());
                if (snippetName == null) {
                    MessageUtils.sendErrorMessage("Please specify the name of the snippet to save! Do `-save (name)`", channel);
                    return;
                }
                if (insertSnippet == null)
                    insertSnippet =
                            session.prepare("UPDATE flarebot.eval_snippets SET encoded_code = ? WHERE snippet_name = ?");

                session.execute(insertSnippet.bind().setString(0, base64).setString(1, snippetName));
                MessageUtils.sendSuccessMessage("Saved the snippet `" + snippetName + "`!", channel);
            });
            return;
        }

        if (hasOption(Options.LIST, msg)) {
            ResultSet set = CassandraController.execute("SELECT snippet_name FROM flarebot.eval_snippets");
            if (set == null) return;
            MessageUtils.sendInfoMessage("**Available eval snippets**\n" +
                            set.all().stream().map(row -> "`" + row.getString("snippet_name") + "`")
                                    .collect(Collectors.joining(", "))
                    , channel);
            return;
        }

        if (code[0] == null)
            return;
        final String finalCode = code[0];

        POOL.submit(() -> {
            try {
                String eResult = String.valueOf(engine.eval(imports + '\n' + finalCode));
                if (eResult.length() > 2000) {
                    eResult = String.format("Eval too large, result pasted: %s", MessageUtils.paste(eResult));
                }
                if (!silent)
                    channel.sendMessage(eResult).queue();
            } catch (Exception e) {
                //FlareBot.LOGGER.error("Error occurred in the evaluator thread pool! " + e.getMessage(), e, Markers.NO_ANNOUNCE);
                channel.sendMessage(MessageUtils.getEmbed(sender)
                        .addField("Result: ", "```bf\n" + e.getMessage() + "```", false).build()).queue();
            }
        });
    }

    @Override
    public String getCommand() {
        return "eval";
    }

    @Override
    public String getDescription() {
        return "";
    }

    @Override
    public String getUsage() {
        return "";
    }

    @Override
    public CommandType getType() {
        return CommandType.SECRET;
    }

    @Override
    public boolean deleteMessage() {
        return false;
    }

    enum Options {
        SILENT("s"),
        SNIPPET("snippet"),
        SAVE("save"),
        LIST("list");

        private String key;

        Options(String key) {
            this.key = key;
        }

        public String getKey() {
            return key;
        }

        public String getAsArgument() {
            return "-" + key;
        }
    }

    private boolean hasOption(Options option, String message) {
        return Pattern.compile("(.^ *)*-\\b" + option.getKey() + "\\b( \\w+)?(.^ )*").matcher(message).find();
    }

    private Pattern getRegex(Options option) {
        return Pattern.compile("(.^ )*-\\b" + option.getKey() + "\\b( \\w+)?(.^ )*");
    }

    private String getCode(String[] args) {
        String code = MessageUtils.getMessage(args);
        for (Options option : Options.values()) {
            if (hasOption(option, code)) {
                Matcher matcher = getRegex(option).matcher(code);
                code = matcher.replaceAll("");
            }
        }
        return code;
    }
}


text:
package co.jagu.data.entity.mapper;

import java.util.Collection;
import java.util.List;

/**
 * Mapper classed user to transform Entity to domain layer
 */
public interface EntityDataMapper<E, D> {

    E mapping(D domain);

    D transform(E entity);

    List<D> transform(Collection<E> entities);

}


text:
using Mono.Cecil;
using Mono.Cecil.Rocks;
using System.Linq;

namespace Diversion.Cecil
{
    public static class CecilExtensions
    {
        public static TypeDefinition GetBaseDeclaringType(this IMemberDefinition member)
        {
            return member.GetBaseMember().DeclaringType;
        }

        public static IMemberDefinition GetBaseMember(this IMemberDefinition member)
        {
            switch (member)
            {
                case EventDefinition m:
                    {
                        var baseType = GetBaseMember(m.AddMethod ?? m.RemoveMethod).DeclaringType;
                        return Equals(baseType, member.DeclaringType) ? m : baseType.Events.FirstOrDefault(b => b.Name == m.Name);
                    }
                case MethodDefinition m:
                    return m.GetOriginalBaseMethod() ?? m;
                case PropertyDefinition m:
                    {
                        var baseType = GetBaseMember(m.GetMethod ?? m.SetMethod).DeclaringType;
                        return Equals(baseType, member.DeclaringType) ? m : baseType.Properties.FirstOrDefault(b => b.Name == m.Name);
                    }
            }
            return member;
        }
    }
}


text:
"""
Membership App Config
"""
from django.apps import AppConfig

class MembershipConfig(AppConfig):
    """
    Membership App Config
    """
    name = 'membership'


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

<!--
  ~ Copyright 2015-present Open Networking Laboratory
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.onosproject</groupId>
        <artifactId>onos-base</artifactId>
        <version>1</version>
    </parent>

    <groupId>org.onosproject</groupId>
    <artifactId>onos-assembly</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <description>ONOS Apache Karaf assembly definitions</description>

    <!-- FIXME this is necessary until snmp moves to release artifacts ONOS-3646 -->
    <repositories>
        <repository>
            <id>snapshot</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>
    </repositories>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <configuration>
                            <target>
                                <exec executable="python">
                                    <arg value="${basedir}/onos-assembly.py"/>
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <version>3.0.8</version>

                <executions>
                    <execution>
                        <id>features-add-to-repo</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>features-add-to-repository</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>file:${basedir}/target/staged-repos.xml</descriptor>
                            </descriptors>
                            <features>
                                <feature>onos-uber-synthetic</feature>
                            </features>
                            <repository>target/repo</repository>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>


text:
#import "CC3Layer.h"

/**
 * A sample application-specific CC3Layer subclass that is touch-enabled
 * and forwards touch events, including touch-move events, to the CC3World.
 */
@interface TileLayer : CC3Layer
@end


text:
// CHECKSTYLE:OFF
/**
 * Autogenerated by Avro
 *
 * DO NOT EDIT DIRECTLY
 */
package org.apache.camel.avro.generated;

@SuppressWarnings("all")
public interface KeyValueProtocol {
  public static final org.apache.avro.Protocol PROTOCOL = org.apache.avro.Protocol.parse("{\"protocol\":\"KeyValueProtocol\",\"namespace\":\"org.apache.camel.avro.generated\",\"types\":[{\"type\":\"record\",\"name\":\"Key\",\"fields\":[{\"name\":\"key\",\"type\":\"string\"}]},{\"type\":\"record\",\"name\":\"Value\",\"fields\":[{\"name\":\"value\",\"type\":\"string\"}]}],\"messages\":{\"put\":{\"request\":[{\"name\":\"key\",\"type\":\"Key\"},{\"name\":\"value\",\"type\":\"Value\"}],\"response\":\"null\"},\"get\":{\"request\":[{\"name\":\"key\",\"type\":\"Key\"}],\"response\":\"Value\"}}}");
  java.lang.Void put(org.apache.camel.avro.generated.Key key, org.apache.camel.avro.generated.Value value) throws org.apache.avro.AvroRemoteException;
  org.apache.camel.avro.generated.Value get(org.apache.camel.avro.generated.Key key) throws org.apache.avro.AvroRemoteException;

  @SuppressWarnings("all")
  public interface Callback extends KeyValueProtocol {
    public static final org.apache.avro.Protocol PROTOCOL = org.apache.camel.avro.generated.KeyValueProtocol.PROTOCOL;
    void put(org.apache.camel.avro.generated.Key key, org.apache.camel.avro.generated.Value value, org.apache.avro.ipc.Callback<java.lang.Void> callback) throws java.io.IOException;
    void get(org.apache.camel.avro.generated.Key key, org.apache.avro.ipc.Callback<org.apache.camel.avro.generated.Value> callback) throws java.io.IOException;
  }
}


text:
Tasks = new Meteor.Collection('tasks');

// allow rules
Tasks.allow({
  insert: function (userId, doc) {
    return false; //  must insert through a meteor method
  },
  update: function (userId, doc, fields, modifier) {
    for (var i = 0; i < docs.length; i++) {
      if (docs[i].user_id !== userId) {
        return false;
      };
    };
    return true;
  },
  remove: function (userId, doc) {
    for (var i = 0; i < docs.length; i++) {
      if (docs[i].user_id !== userId) {
        return false;
      };
    };
    return true;
  }
});