text:
package solidstack.query;

import solidstack.template.TemplateLoader;

/**
 * Reads, compiles and caches the queries.
 *
 * @author René M. de Bloois
 */
public class QueryLoader
{
	private TemplateLoader templateLoader;
	private boolean locked;

	/**
	 * Constructor.
	 */
	public QueryLoader()
	{
		this.templateLoader = new TemplateLoader();
	}

	/**
	 * Constructor which uses an existing TemplateLoader.
	 *
	 * @param templateLoader The template loader to use.
	 */
	public QueryLoader( TemplateLoader templateLoader )
	{
		this.templateLoader = templateLoader;
		this.locked = true;
	}

	/**
	 * Configures the path which acts as the root of the template files.
	 *
	 * @param path The path.
	 */
	public void setTemplatePath( String path )
	{
		checkLock();
		this.templateLoader.setTemplatePath( path );
	}

	/**
	 * Enable or disable reloading. When enabled, the lastModified time stamp of the file is used to check if it needs reloading.
	 *
	 * @param reloading When true, the file is reloaded when updated.
	 */
	// TODO Need reload delay to prevent to much file checking
	public void setReloading( boolean reloading )
	{
		checkLock();
		this.templateLoader.setReloading( reloading );
	}

	/**
	 * Sets the default scripting language of the templates. The default scripting language is used when a "language" directive is missing in the template.
	 *
	 * @param language The default scripting language of the templates.
	 */
	public void setDefaultLanguage( String language )
	{
		checkLock();
		this.templateLoader.setDefaultLanguage( language );
	}

	/**
	 * Returns a {@link Query}.
	 *
	 * @param path The path of the query relative to the configured root package.
	 * @return The {@link Query}.
	 */
	public Query getQuery( String path )
	{
		return new Query( this.templateLoader.getTemplate( path ) );
	}

	private void checkLock()
	{
		if( this.locked )
			throw new IllegalStateException( "Configure the TemplateLoader instead." );
	}

	// TODO Missing defineTemplate()
}


text:
'use strict';

(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    define(['exports'], factory);
  } else if (typeof exports !== 'undefined') {
    factory(exports);
  } else {
    factory((root.asmlikeJsonTreeBuilder = {}));
  }
}(this, function (exports) {
  var jsonTreeBuilder = require("./json-treebuilder.js");
  var JsonTreeBuilder = jsonTreeBuilder.Builder;

  var baseClass = JsonTreeBuilder.prototype;

  function Symbol (text, getBase, id) {
    this.text    = text;
    this.getBase = getBase || null;
    this.id      = id | 0;
  };

  Symbol.prototype.type = "symbol";

  Symbol.prototype.toString = function () {
    return "#" + this.id + " (" + this.text + ")";
  };

  Symbol.prototype.valueOf = function () {
    var base = 0;
    if (this.getBase)
      base = this.getBase() | 0;

    var result = base + this.id;

    return result;
  };

  function AsmlikeJsonTreeBuilder () {
    JsonTreeBuilder.call(this);

    this.operatorTable = Object.create(null);
    this.operatorCount = 0;

    this.externalSymbols = Object.create(null);
    this.externalSymbolCount = 0;

    this.scopeChain = [
      Object.create(null)
    ];

    this.scopeChain[0].$$count = 0;
    this.maxLocalSymbolCount = 0;

    this.internSymbols = false;
    this.localSymbolsBeforeGlobals = false;

    var self = this;

    this.getLocalSymbolBase = function getLocalSymbolBase () {
      if (self.localSymbolsBeforeGlobals)
        return 0;
      else
        return self.externalSymbolCount;
    };

    this.getGlobalSymbolBase = function getGlobalSymbolBase () {
      if (self.localSymbolsBeforeGlobals)
        return self.maxLocalSymbolCount;
      else
        return 0;
    };
  };

  AsmlikeJsonTreeBuilder.prototype = Object.create(JsonTreeBuilder.prototype);

  AsmlikeJsonTreeBuilder.prototype.pushScope = function () {
    var previousScope = this.scopeChain[this.scopeChain.length - 1];
    var newScope = Object.create(previousScope);

    var count = previousScope.$$count;
    Object.defineProperty(newScope, "$$count", {
      value: count,
      configurable: true,
      enumerable: false,
      writable: true
    });

    this.scopeChain.push(newScope);

    baseClass.pushScope.call(this);
  };

  AsmlikeJsonTreeBuilder.prototype.popScope = function () {
    this.scopeChain.pop();

    if (this.scopeChain.length < 1)
      throw new Error("Mismatched scope push/pop");

    baseClass.popScope.call(this);
  };

  // Special-case for operator names
  AsmlikeJsonTreeBuilder.prototype.internOperator = function (operator) {
    if (!this.internSymbols)
      return operator;

    var index = this.operatorTable[operator];

    if (typeof (index) === "undefined") {
      index = this.operatorTable[operator] =
        new Symbol(operator, null, (this.operatorCount++) | 0);
    }

    return index;
  };

  // FIXME: Externally visible names should have their names stored in a table somewhere
  //  in order to accurately capture the cost of those names
  AsmlikeJsonTreeBuilder.prototype.internName = function (name, externallyVisible) {
    if (!this.internSymbols)
      return name;

    if (name === null)
      return 0xFFFFFFFF;

    if (externallyVisible) {
      var index = this.externalSymbols[name];

      if (typeof (index) === "undefined") {
        index = this.externalSymbols[name] =
          new Symbol(name, this.getGlobalSymbolBase, (this.externalSymbolCount++) | 0);
      }
    } else {
      var currentScope = this.scopeChain[this.scopeChain.length - 1];
      var index = currentScope[name];

      if (typeof (index) === "undefined") {
        var i = (currentScope.$$count++);
        this.maxLocalSymbolCount = Math.max(i, this.maxLocalSymbolCount) | 0;

        index = currentScope[name] =
          new Symbol(name, this.getLocalSymbolBase, i | 0);
      }
    }

    // HACK: The shape table lists string for these...
    return index;
  };

  AsmlikeJsonTreeBuilder.prototype.makeUnaryOperatorExpression = function (operator, rhs) {
    if (operator === "+") {
      var result = this.make("ToDouble");
      result.expression = rhs;
      return this.finalize(result);
    } else {
      operator = this.internOperator(operator);

      return baseClass.makeUnaryOperatorExpression.call(this, operator, rhs);
    }
  };

  AsmlikeJsonTreeBuilder.prototype.makeTruncation = function (isSigned, expression) {
    var result = this.make(
      isSigned
        ? "SignedTruncation"
        : "UnsignedTruncation"
    );
    result.expression = expression;
    return this.finalize(result);
  };

  AsmlikeJsonTreeBuilder.prototype.makeBinaryOperatorExpression = function (operator, lhs, rhs) {
    if (
      (
        (operator === ">>>") ||
        (operator === "|")
      ) &&
      (rhs.type === "IntegerLiteral") &&
      (rhs.value === 0)
    ) {
      var isSigned = (operator === "|");
      return this.makeTruncation(isSigned, lhs);
    } else {
      operator = this.internOperator(operator);

      return baseClass.makeBinaryOperatorExpression.call(this, operator, lhs, rhs);
    }
  };

  AsmlikeJsonTreeBuilder.prototype.makePrefixMutationExpression = function (operator, rhs) {
    operator = this.internOperator(operator);

    return baseClass.makePrefixMutationExpression.call(this, operator, rhs);
  };

  AsmlikeJsonTreeBuilder.prototype.makePostfixMutationExpression = function (operator, lhs) {
    operator = this.internOperator(operator);

    return baseClass.makePostfixMutationExpression.call(this, operator, lhs);
  };

  AsmlikeJsonTreeBuilder.prototype.makeAssignmentOperatorExpression = function (operator, lhs, rhs) {
    operator = this.internOperator(operator);

    return baseClass.makeAssignmentOperatorExpression.call(this, operator, lhs, rhs);
  };

  AsmlikeJsonTreeBuilder.prototype.makeExpressionStatement = function (expression) {
    if (
      (expression.type === "StringLiteral") &&
      (expression.value === "use asm")
    ) {
      var result = this.make("UseAsmStatement");
      return this.finalize(result);
    } else {
      return baseClass.makeExpressionStatement.call(this, expression);
    }
  };

  AsmlikeJsonTreeBuilder.prototype.makeLabelStatement = function (labels, labelled) {
    labels = Array.prototype.slice.call(labels);

    for (var i = 0; i < labels.length; i++)
      labels[i] = this.internName(labels[i], false);

    return baseClass.makeLabelStatement.call(this, labels, labelled);
  };

  AsmlikeJsonTreeBuilder.prototype.makeDeclaration = function (name, initialValue) {
    name = this.internName(name, false);

    return baseClass.makeDeclaration.call(this, name, initialValue);
  };

  AsmlikeJsonTreeBuilder.prototype.makeForInDeclaration = function (variableName, sequenceExpression) {
    variableName = this.internName(variableName, false);

    return baseClass.makeForInDeclaration.call(this, variableName, sequenceExpression);
  };

  AsmlikeJsonTreeBuilder.prototype.makeBreakStatement = function (label) {
    label = this.internName(label, false);

    return baseClass.makeBreakStatement.call(this, label);
  };

  AsmlikeJsonTreeBuilder.prototype.makeContinueStatement = function (label) {
    label = this.internName(label, false);

    return baseClass.makeContinueStatement.call(this, label);
  };

  AsmlikeJsonTreeBuilder.prototype.makeFunctionExpression = function (name, argumentNames, body) {
    // FIXME: The name should be interned in the outer scope
    name = this.internName(name, true);
    argumentNames = Array.prototype.slice.call(argumentNames);

    for (var i = 0; i < argumentNames.length; i++)
      argumentNames[i] = this.internName(argumentNames[i], false);

    return baseClass.makeFunctionExpression.call(this, name, argumentNames, body);
  };

  AsmlikeJsonTreeBuilder.prototype.makePair = function (key, value) {
    // FIXME: Identifier vs string literal
    /*
    if (typeof (key) === "string")
      key = this.internName(key, true);
    */

    return baseClass.makePair.call(this, key, value);
  };

  AsmlikeJsonTreeBuilder.prototype.makeIdentifierExpression = function (identifier) {
    identifier = this.internName(identifier, false);

    return baseClass.makeIdentifierExpression.call(this, identifier);
  };

  AsmlikeJsonTreeBuilder.prototype.makeMemberAccessExpression = function (lhs, memberName) {
    memberName = this.internName(memberName, true);

    return baseClass.makeMemberAccessExpression.call(this, lhs, memberName);
  };

  AsmlikeJsonTreeBuilder.prototype.finalize = function (obj) {
    return obj;
  };

  exports.Builder = AsmlikeJsonTreeBuilder;
}));

redpajama_set_name: RedPajamaGithub


text:
package afirsraftgarrier.demoandroid.androidapi.view;

import afirsraftgarrier.demoandroid.R;

import android.app.Activity;
import android.widget.TableLayout;
import android.widget.Button;
import android.os.Bundle;
import android.view.View;

public class TableLayout9 extends Activity {
    private boolean mShrink;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.table_layout_9);

        final TableLayout table = (TableLayout) findViewById(R.id.menu);
        Button button = (Button) findViewById(R.id.toggle);
        button.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                mShrink = !mShrink;
                table.setColumnShrinkable(0, mShrink);
            }
        });

        mShrink = table.isColumnShrinkable(0);
    }
}


text:
using namespace llvm;

Nios2RegisterInfo::Nios2RegisterInfo(const Nios2Subtarget &ST)
    : Nios2GenRegisterInfo(Nios2::RA), Subtarget(ST) {}

const TargetRegisterClass *Nios2RegisterInfo::intRegClass(unsigned Size) const {
  return &Nios2::CPURegsRegClass;
}

const MCPhysReg *
Nios2RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
  return CSR_SaveList;
}

BitVector Nios2RegisterInfo::getReservedRegs(const MachineFunction &MF) const {
  static const MCPhysReg ReservedCPURegs[] = {Nios2::ZERO, Nios2::AT, Nios2::SP,
                                             Nios2::RA,   Nios2::PC, Nios2::GP};
  BitVector Reserved(getNumRegs());

  for (unsigned I = 0; I < array_lengthof(ReservedCPURegs); ++I)
    Reserved.set(ReservedCPURegs[I]);

  return Reserved;
}

void Nios2RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
                                            int SPAdj, unsigned FIOperandNum,
                                            RegScavenger *RS) const {}

unsigned Nios2RegisterInfo::getFrameRegister(const MachineFunction &MF) const {
  return Nios2::SP;
}


text:
<?php

namespace PhpOffice\PhpWord\Element;

use PhpOffice\PhpWord\Style\Paragraph;

/**
 * Endnote element
 *
 * @since 0.10.0
 */
class Endnote extends Footnote
{
    /**
     * @var string Container type
     */
    protected $container = 'Endnote';

    /**
     * Create new instance
     *
     * @param string|array|\PhpOffice\PhpWord\Style\Paragraph $paragraphStyle
     */
    public function __construct($paragraphStyle = null)
    {
        $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
    }
}


text:
/* @flow */

"use strict";

var _classCallCheck = require("babel-runtime/helpers/class-call-check")["default"];

exports.__esModule = true;

/**
 * This class is responsible for a binding inside of a scope.
 *
 * It tracks the following:
 *
 *  * Node path.
 *  * Amount of times referenced by other nodes.
 *  * Paths to nodes that reassign or modify this binding.
 *  * The kind of binding. (Is it a parameter, declaration etc)
 */

/*:: import type NodePath from "../path";*/
var Binding = (function () {
  function Binding(_ref) {
    var existing = _ref.existing;
    var identifier = _ref.identifier;
    var scope = _ref.scope;
    var path = _ref.path;
    var kind = _ref.kind;

    _classCallCheck(this, Binding);

    this.identifier = identifier;
    this.scope = scope;
    this.path = path;
    this.kind = kind;

    this.constantViolations = [];
    this.constant = true;

    this.referencePaths = [];
    this.referenced = false;
    this.references = 0;

    this.clearValue();

    if (existing) {
      this.constantViolations = [].concat(existing.path, existing.constantViolations, this.constantViolations);
    }
  }

  Binding.prototype.deoptValue = function deoptValue() {
    this.clearValue();
    this.hasDeoptedValue = true;
  };

  Binding.prototype.setValue = function setValue(value /*: any*/) {
    if (this.hasDeoptedValue) return;
    this.hasValue = true;
    this.value = value;
  };

  Binding.prototype.clearValue = function clearValue() {
    this.hasDeoptedValue = false;
    this.hasValue = false;
    this.value = null;
  };

  /**
   * Register a constant violation with the provided `path`.
   */

  Binding.prototype.reassign = function reassign(path /*: Object*/) {
    this.constant = false;
    this.constantViolations.push(path);
  };

  /**
   * Increment the amount of references to this binding.
   */

  Binding.prototype.reference = function reference(path /*: NodePath*/) {
    this.referenced = true;
    this.references++;
    this.referencePaths.push(path);
  };

  /**
   * Decrement the amount of references to this binding.
   */

  Binding.prototype.dereference = function dereference() {
    this.references--;
    this.referenced = !!this.references;
  };

  return Binding;
})();

exports["default"] = Binding;
module.exports = exports["default"];


text:
package org.semanticweb.elk.owl.implementation;

import org.semanticweb.elk.owl.interfaces.ElkAnonymousIndividual;
import org.semanticweb.elk.owl.visitors.ElkAnnotationSubjectVisitor;
import org.semanticweb.elk.owl.visitors.ElkAnnotationValueVisitor;
import org.semanticweb.elk.owl.visitors.ElkAnonymousIndividualVisitor;
import org.semanticweb.elk.owl.visitors.ElkIndividualVisitor;
import org.semanticweb.elk.owl.visitors.ElkObjectVisitor;

/**
 * Corresponds to an <a href=
 * "http://www.w3.org/TR/owl2-syntax/#Anonymous_Individuals">Anonymous
 * Individuals<a> in the OWL 2 specification.
 *
 * @author Markus Kroetzsch
 */
public class ElkAnonymousIndividualImpl extends ElkObjectImpl implements
		ElkAnonymousIndividual {

	private final String nodeId_;

	ElkAnonymousIndividualImpl(String nodeId) {
		this.nodeId_ = nodeId;
	}

	@Override
	public String getNodeId() {
		return nodeId_;
	}

	@Override
	public String toString() {
		return nodeId_;
	}

	@Override
	public <O> O accept(ElkIndividualVisitor<O> visitor) {
		return visitor.visit(this);
	}

	@Override
	public <O> O accept(ElkObjectVisitor<O> visitor) {
		return visitor.visit(this);
	}

	@Override
	public <O> O accept(ElkAnnotationValueVisitor<O> visitor) {
		return accept((ElkAnonymousIndividualVisitor<O>) visitor);
	}

	@Override
	public <O> O accept(ElkAnnotationSubjectVisitor<O> visitor) {
		return accept((ElkAnonymousIndividualVisitor<O>) visitor);
	}

	@Override
	public <O> O accept(ElkAnonymousIndividualVisitor<O> visitor) {
		return visitor.visit(this);
	}

}


text:
import os
import hashlib
import binascii

try:
    import pydeep
    HAVE_SSDEEP = True
except ImportError:
    HAVE_SSDEEP = False

try:
    import magic
except ImportError:
    pass

class Singleton(type):
    _instances = {}
    def __call__(cls, *args, **kwargs):
        if cls not in cls._instances:
            cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
        return cls._instances[cls]

class File(object):

    def __init__(self, path):
        self.path = path
        self.name = ''
        self.size = 0
        self.type = ''
        self.mime = ''
        self.md5 = ''
        self.sha1 = ''
        self.sha256 = ''
        self.sha512 = ''
        self.crc32 = ''
        self.ssdeep = ''
        self.tags = ''

        if self.is_valid():
            self.name = os.path.basename(self.path)
            self.size = os.path.getsize(self.path)
            self.type = self.get_type()
            self.mime = self.get_mime()
            self.get_hashes()
            self.ssdeep = self.get_ssdeep()

    @property
    def data(self):
        return open(self.path, 'rb').read()

    def is_valid(self):
        return os.path.exists(self.path) and os.path.isfile(self.path)# and os.path.getsize(self.path) != 0

    def get_chunks(self):
        fd = open(self.path, 'rb')
        while True:
            chunk = fd.read(16 * 1024)
            if not chunk:
                break

            yield chunk

        fd.close()

    def get_hashes(self):
        crc = 0
        md5 = hashlib.md5()
        sha1 = hashlib.sha1()
        sha256 = hashlib.sha256()
        sha512 = hashlib.sha512()

        for chunk in self.get_chunks():
            crc = binascii.crc32(chunk, crc)
            md5.update(chunk)
            sha1.update(chunk)
            sha256.update(chunk)
            sha512.update(chunk)

        self.crc32 = ''.join('%02X' % ((crc>>i)&0xff) for i in [24, 16, 8, 0])
        self.md5 = md5.hexdigest()
        self.sha1 = sha1.hexdigest()
        self.sha256 = sha256.hexdigest()
        self.sha512 = sha512.hexdigest()

    def get_ssdeep(self):
        if not HAVE_SSDEEP:
            return ''

        try:
            return pydeep.hash_file(self.path)
        except Exception:
            return ''

    def get_type(self):
        try:
            ms = magic.open(magic.MAGIC_NONE)
            ms.load()
            file_type = ms.file(self.path)
        except:
            try:
                file_type = magic.from_file(self.path)
            except:
                try:
                    import subprocess
                    file_process = subprocess.Popen(['file', '-b', self.path], stdout = subprocess.PIPE)
                    file_type = file_process.stdout.read().strip()
                except:
                    return ''
        finally:
            try:
                ms.close()
            except:
                pass

        return file_type

    def get_mime(self):
        try:
            ms = magic.open(magic.MIME)
            ms.load()
            mime_type = ms.file(self.path)
        except:
            try:
                mime = magic.Magic(mime=True)
                mime_type = mime.from_file(self.path)
            except:
                return ''

        return mime_type


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

namespace School
{
    public class Student : Person
    {
        // Using static hashset in order to prevent duplicate class numbers
        private static HashSet<int> uniqueClassNumbers;

        static Student()
        {
            uniqueClassNumbers = new HashSet<int>();
        }

        private int classNumber;

        public Student(string name, int classNumber)
        {
            this.Name = name;
            if (classNumber <= 0)
            {
                throw new ArgumentException("The Class number must be positive number.");
            }

            if (!uniqueClassNumbers.Add(classNumber))
            {
                throw new ArgumentException("Duplicate class ID");
            }

            this.classNumber = classNumber;
        }

        public int ClassNumber
        {
            get
            {
                return this.classNumber;
            }
        }

    }
}


text:
module SolidusSlider
  module_function

  # Returns the version of the currently loaded SolidusI18n as a
  # <tt>Gem::Version</tt>.
  def version
    Gem::Version.new VERSION::STRING
  end

  module VERSION
    MAJOR = 1
    MINOR = 1
    TINY  = 1
    PRE   = nil

    STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
  end
end


text:
<?php

declare(strict_types=1);

namespace Sonata\MediaBundle\Tests\Controller;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Sonata\MediaBundle\Action\MediaDownloadAction;
use Sonata\MediaBundle\Model\MediaManagerInterface;
use Sonata\MediaBundle\Provider\MediaProviderInterface;
use Sonata\MediaBundle\Provider\Pool;
use Sonata\MediaBundle\Security\DownloadStrategyInterface;
use Sonata\MediaBundle\Tests\App\Entity\Media;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

final class MediaDownloadActionTest extends TestCase
{
    /**
     * @var MockObject&MediaManagerInterface
     */
    private object $mediaManager;

    private Pool $pool;

    private MediaDownloadAction $mediaDownloadAction;

    protected function setUp(): void
    {
        $this->mediaManager = $this->createMock(MediaManagerInterface::class);
        $this->pool = new Pool('default_context');

        $this->mediaDownloadAction = new MediaDownloadAction($this->mediaManager, $this->pool);
    }

    public function testDownloadActionWithNotFoundMedia(): void
    {
        $this->expectException(NotFoundHttpException::class);

        $this->mediaDownloadAction->__invoke(new Request(), 1);
    }

    public function testDownloadActionAccessDenied(): void
    {
        $this->expectException(AccessDeniedException::class);

        $request = new Request();
        $media = new Media();
        $media->setContext('default_context');

        $this->configureDownloadSecurity($media, $request, false);
        $this->mediaManager->method('find')->with(1)->willReturn($media);

        $this->mediaDownloadAction->__invoke($request, 1);
    }

    public function testDownloadActionBinaryFile(): void
    {
        $media = new Media();
        $media->setContext('default_context');
        $media->setProviderName('provider');

        $request = new Request();

        $provider = $this->createMock(MediaProviderInterface::class);
        $response = $this->createMock(BinaryFileResponse::class);

        $this->configureDownloadSecurity($media, $request, true);

        $this->pool->addProvider('provider', $provider);
        $this->mediaManager->method('find')->with(1)->willReturn($media);
        $provider->method('getDownloadResponse')->with($media, 'format', 'mode')->willReturn($response);
        $response->expects(static::once())->method('prepare')->with($request);

        $result = $this->mediaDownloadAction->__invoke($request, 1, 'format');

        static::assertSame($response, $result);
    }

    private function configureDownloadSecurity(
        Media $media,
        Request $request,
        bool $isGranted
    ): void {
        $strategy = $this->createMock(DownloadStrategyInterface::class);
        $strategy->method('isGranted')->with($media, $request)->willReturn($isGranted);

        $this->pool->addContext('default_context', [], [], [
            'mode' => 'mode',
            'strategy' => 'download_strategy',
        ]);
        $this->pool->addDownloadStrategy('download_strategy', $strategy);
    }
}


text:
using System.Collections.Generic;
using Adaptive.SimpleBinaryEncoding.Util;

namespace Adaptive.SimpleBinaryEncoding.ir
{
    ///
    /// Class to encapsulate a token of information for the message schema stream. This Intermediate Representation (IR)
    /// is intended to be language, schema, platform independent.
    ///

    /// Processing and optimization could be run over a list of Tokens to perform various functions
    ///

    ///
re-ordering of fields based on size

    ///
padding of fields in order to provide expansion room

    ///
computing offsets of individual fields

    ///
etc.

    ///

    ///

    /// IR could be used to generate code or other specifications. It should be possible to do the
    /// following:
    ///

    ///
generate a FIX/SBE schema from IR

    ///
generate an ASN.1 spec from IR

    ///
generate a GPB spec from IR

    ///
etc.

    ///

    ///

    /// IR could be serialized to storage or network via code generated by SBE. Then read back in to
    /// a List of <seealso cref="Token"/>s.
    ///

    /// The entire IR of an entity is a <see cref="List{Token}"/>. The order of this list is
    /// very important. Encoding of fields is done by nodes pointing to specific encoding <seealso cref="PrimitiveType"/>
    /// objects. Each encoding node contains size, offset, byte order, and <seealso cref="Encoding"/>. Entities relevant
    /// to the encoding such as fields, messages, repeating groups, etc. are encapsulated in the list as nodes
    /// themselves. Although, they will in most cases never be serialized. The boundaries of these entities
    /// are delimited by BEGIN and END <seealso cref="Adaptive.SimpleBinaryEncoding.ir.Signal"/> values in the node <seealso cref="Encoding"/>.
    /// A list structure like this allows for each concatenation of encodings as well as easy traversal.
    ///

    /// An example encoding of a message headerStructure might be like this.
    ///

    ///
Token 0 - Signal = BEGIN_MESSAGE, schemaId = 100

    ///
Token 1 - Signal = BEGIN_FIELD, schemaId = 25

    ///
Token 2 - Signal = ENCODING, PrimitiveType = uint32, size = 4, offset = 0

    ///
Token 3 - Signal = END_FIELD

    ///
Token 4 - Signal = END_MESSAGE

    ///

    ///

    ///
    public class Token
    {
        ///
        /// Invalid ID value.
        public const int InvalidId = -1;

        ///
        /// Size not determined
        public const int VariableSize = -1;

        ///
        /// Offset not computed or set
        public const int UnknownOffset = -1;

        private readonly Signal _signal;
        private readonly string _name;
        private readonly int _schemaId;
        private readonly int _version;
        private readonly int _size;
        private readonly int _offset;
        private readonly Encoding _encoding;

        ///
        /// Construct an <seealso cref="Token"/> by providing values for all fields.
        ///
        /// <param name="signal"> for the token role </param>
        /// <param name="name"> of the token in the message </param>
        /// <param name="schemaId"> as the identifier in the message declaration </param>
        /// <param name="version"> application within the template </param>
        /// <param name="size"> of the component part </param>
        /// <param name="offset"> in the underlying message as octets </param>
        /// <param name="encoding"> of the primitive field </param>
        public Token(Signal signal, string name, int schemaId, int version, int size, int offset, Encoding encoding)
        {
            Verify.NotNull(signal, "signal");
            Verify.NotNull(name, "name");
            Verify.NotNull(encoding, "encoding");

            _signal = signal;
            _name = name;
            _schemaId = schemaId;
            _version = version;
            _size = size;
            _offset = offset;
            _encoding = encoding;
        }

        ///
        /// Signal the role of this token.
        ///
        /// <value>the <seealso cref="Signal"/> for the token.</value>
        public Signal Signal
        {
            get { return _signal; }
        }

        ///
        /// Return the name of the token
        ///
        /// <value>name of the token</value>
        public string Name
        {
            get { return _name; }
        }

        ///
        /// Return the ID of the token assigned by the specification
        ///
        /// <value>ID of the token assigned by the specification</value>
        public int SchemaId
        {
            get { return _schemaId; }
        }

        ///
        /// The version context for this token.
        ///
        /// <value>version context for this token.</value>
        public int Version
        {
            get { return _version; }
        }

        ///
        /// The context in which the version field should be interpreted.
        ///
        /// <value>context in which the version field should be interpreted.</value>
        public VersionContext VersionContext
        {
            get
            {
                if (_signal == Signal.BeginMessage || _signal == Signal.EndMessage)
                {
                    return VersionContext.TemplateVersion;
                }
                return VersionContext.SinceTemplateVersion;
            }
        }

        ///
        /// The size of this token in bytes.
        ///
        /// <value>
        ///   the size of this node. A value of 0 means the node has no size when encoded. A value of <seealso cref="
        ///   Token#VARIABLE_SIZE"/> means this node represents a variable length field.
        /// </value>
        public int Size
        {
            get { return _size; }
        }

        ///
        /// The number of encoded primitives in this type.
        ///
        /// <value>number of encoded primitives in this type.</value>
        public int ArrayLength
        {
            get
            {
                if (null == _encoding.PrimitiveType || 0 == _size)
                {
                    return 0;
                }

                return _size / _encoding.PrimitiveType.Size;
            }
        }

        ///
        /// The offset for this token in the message.
        ///
        /// <value>
        ///   the offset of this Token. A value of 0 means the node has no relevant offset. A value of <seealso cref="
        ///   Token#UNKNOWN_OFFSET"/> means this nodes true offset is dependent on variable length fields ahead of it in
        ///   the encoding.
        /// </value>
        public int Offset
        {
            get { return _offset; }
        }

        ///
        /// Return the <seealso cref="Encoding"/> of the <seealso cref="Token"/>.
        ///
        /// <value>encoding of the <seealso cref="Token"/></value>
        public Encoding Encoding
        {
            get { return _encoding; }
        }

        public override string ToString()
        {
            return string.Format("Token{{" + "signal={0}, name='{1}\'" + ", schemaId={2}, version={3}, size={4}, offset={5}, encoding={6}{7}", Signal, Name, SchemaId, _version, _size, _offset, _encoding, '}');
        }

        public class Builder
        {
            private Signal _signal;
            private string _name;
            private int _schemaId = InvalidId;
            private int _version = 0;
            private int _size = 0;
            private int _offset = 0;
            private Encoding _encoding = new Encoding();

            public Builder Signal(Signal signal)
            {
                _signal = signal;
                return this;
            }

            public Builder Name(string name)
            {
                _name = name;
                return this;
            }

            public Builder SchemaId(int schemaId)
            {
                this._schemaId = schemaId;
                return this;
            }

            public Builder Version(int version)
            {
                _version = version;
                return this;
            }

            public Builder Size(int size)
            {
                _size = size;
                return this;
            }

            public Builder Offset(int offset)
            {
                _offset = offset;
                return this;
            }

            public Builder Encoding(Encoding encoding)
            {
                _encoding = encoding;
                return this;
            }

            public Token Build()
            {
                return new Token(_signal, _name, _schemaId, _version, _size, _offset, _encoding);
            }
        }
    }
}


text: - Initial version; simple decoding of (X)HTML entities of event fields


text:
/**
 * A simple test case that determines if elements, specified by a selector,
 * exist or not.
 *
 * The test fails for elements that are found and a case is created for each
 * one. The test passes is the selector finds no matching elements.
 */
var Case = require('Case');
const DOM = require('DOM');
var LabelDoesNotContainInput = {
  run: function (test) {

    var selector = 'label';

    test.get('scope').forEach(function (scope) {
      var candidates = DOM.scry(selector, scope);
      if (!candidates.length) {
        test.add(Case({
          element: undefined,
          status: 'inapplicable'
        }));
      }
      else {
        candidates.forEach(function (element) {
          var status = 'passed';

          if (DOM.scry('input', element).length > 0) {
            status = 'failed';
          }

          test.add(Case({
            element: element,
            status: status
          }));
        });
      }
    });
  },

  meta: {
    testability: 1,
    title: {
      en: 'Label elements should not contain an input element',
      nl: 'Labelelementen moeten geen invoerelementen bevatten'
    },
    description: {
      en: 'Label elements should not wrap around another input element, as this can cause the label to be read twice by screen readers.',
      nl: 'Labelelementen moeten niet om een ander invoerelement heenstaan, omdat dan het label twee keer kan worden voorgelezen door schermlezers.'
    },
    guidelines: [

    ],
    tags: [
      'form',
      'content'
    ]
  }
};
module.exports = LabelDoesNotContainInput;


text:
@font-face {
    font-family: 'Source Sans Pro';
    font-style: normal;
    font-weight: 400;
    src: url('fonts/SourceSansPro-Regular.ttf') format('truetype');
}
@font-face {
    font-family: 'Source Sans Pro';
    font-style: normal;
    font-weight: 700;
    src: url('fonts/SourceSansPro-Bold.ttf') format('truetype');
}

@keyframes scale-up-anim {
    from {
        transform: scale(0.1);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1
    }
}

@keyframes scale-down-anim {
    from {
        transform: scale(1);
        opacity: 1;
    }

    to {
        transform: scale(0.1);
        opacity: 0;
    }
}

body.vfx-allowed, body.vfx-allowed * {
    transition: background 0.5s, box-shadow 0.5s;
}

body, html {
    height: 100%;
    margin: 0;
    padding: 0;
}

body, html, button, input {
    font-family: 'Source Sans Pro', sans-serif;
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    /*-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);*/
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: rgba(100,100,100,0.8);
    box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
	background: rgba(100,100,100,0.4);
}
::-webkit-scrollbar-corner {
    background: white;
}

#dashboard {
    min-width: 100%;
    min-height: 100%;
    position: relative;
    overflow: auto;
}

#entries {
    position: fixed;
    z-index: 99999;
    left: -285px;
    top: 0px;
    height: 100%;
    width: 300px;
    box-sizing: border-box;
    border-right: 1px solid gray;
    box-shadow: 0px 0px 5px black;
    background-color: white;
    padding-left: 30px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.vfx-allowed #entries {
    transition: left 0.5s, background 0.5s, box-shadow 0.5s;
}

#entries:hover {
    left: 0px;
}

#entries .entries-arrow {
    user-select: none;
    -webkit-user-select: none;
    position: absolute;
    right: 2px;
    top: 50%;
    display: block;
    transform: translateY(-50%);
}

#entries h3 {
    margin-bottom: 0;
    border-bottom: 1px solid black;
    width: calc(100% - 20px);
}

#entries ul {
    list-style-type: none;
}

#entries .tab-container {
    padding: 0;
    flex: 1;
    overflow: hidden;
    margin: 0;
    margin-right: 20px;
    position: relative;
}

#entries .tab-content {
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

#entries .tab-container .tab-content {
    width: 100%;
}

.list {
    margin-left: 0;
    padding-left: 0;
}

#entries .entry-add {
    font-size: .8em;
    margin-right: 1em;
    opacity: 0;
    pointer-events: none;
    height: 19px;
    line-height: 19px;
    font-size: 0.6em;
}

#entries .list ul {
    display: block;
    overflow: auto;
    max-height: 0;
    opacity: 0;
}

body.vfx-allowed #entries .list ul {
    transition: transform 0.3s, opacity 0.3s, height 0.3s, max-height 0.3s;
}

#entries .list li {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

#entries .entry-icon {
    font-style: normal;
    display: inline-block;
    margin-right: 0.2em;
    margin-top: 0.2em;
    color: gray;
    border: 1px solid gray;
    border-radius: 0.2em;
    box-sizing: border-box;
    width: 1em;
    text-align: center;
    user-select: none;
    -webkit-user-select: none;
}

#entries .list>li {
    padding-right: 20px;
}

#entries h3 {
    display: flex;
}

#entries h3 input {
    flex: 1;
    margin-left: 1em;
    padding-left: 0.5em;
    height: 1.5em;
    align-self: flex-end;
    min-width: 0px;
}

#entries .list li:not(.none)>.entry-add {
    opacity: 1;
    pointer-events: all;
}

#entries .list li.open>ul {
    max-height: 15000px;
    opacity: 1;
}

#entries .widget-entry {
    display: inline-block;
    width: 100px;
    height: 100px;
    padding-bottom: 0;
    margin: 2px;
    background-size: cover;
    position: relative;
}

#entries .widget-entry span {
    position: absolute;
    bottom: 0px;
    left: 0px;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    white-space: pre;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    color: white;
}

#controls {
    text-align: center;
    border-top: 1px solid black;
}

#place-screen {
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    pointer-events: none;
    opacity: 0;
    z-index: 99999;
    -webkit-user-select: none;
}

body.vfx-allowed #place-screen {
    transition: opacity 0.2s;
}

#place-screen.active {
    pointer-events: all;
    opacity: 1;
}

#place-screen h1 {
    position: absolute;
    top: 50%;
    left: 0px;
    width: 100%;
    text-align: center;
    margin: 0;
    transform: translateY(-50%);
}

#place-screen .place-cancel {
    position: absolute;
    right: 20px;
    bottom: 20px;
}

.widget {
    margin: 2px;
    position: absolute;
    background: white;
    box-sizing: border-box;
    border: 1px solid transparent;
    white-space: nowrap;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.container {
    margin: 2px;
    position: absolute;
    background: white;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    min-width: 100px;
    min-height: 100px;
    border: 1px solid transparent;
}

#dashboard>.widget, #dashboard>.container {
    margin-bottom: 2em;
    margin-right: 2em;
}

body.vfx-allowed .inserted-element {
    -webkit-animation: scale-up-anim 0.3s;
}

body.vfx-allowed .removed-element {
    -webkit-animation: scale-down-anim 0.3s;
}

.widget.drag, .container.drag {
    box-shadow: 2px 2px 2px gray;
}

.widget[data-label=top] {
    flex-direction: column;
}

.widget[data-label=none] label {
    display: none;
}

.widget[data-editable=true], .container[data-editable=true] {
    border: 1px dotted gray;
    border-radius: 2px;
}

.widget[data-editable=true].reorder-widget *, .container[data-editable=true].reorder-widget * {
    opacity: 0;
    background: transparent;
}

.container[data-editable=true]:not([data-editing=true]):not(.not-editing) .widget, .container[data-editable=true]:not([data-editing=true]):not(.not-editing) .container {
    opacity: 0.5;
    pointer-events: none;
}

.container[data-editing=true] {
    border: 1px solid blue;
}

.container[data-editing=true]:not(.not-editing) {
    background: rgb(200, 200, 255);
}

.widget label {
    -webkit-user-select: none;
}

.not-editing {
    background: darkgray;
}

.container.drop-target, .container.drop-target[data-editing=true]:not(.not-editing), .container.drop-target[data-editing=true] {
    border: 1px solid green;
    background: rgb(200, 255, 200);
}

.container.remove-target, .container.remove-target[data-editing=true]:not(.not-editing), .container.remove-target[data-editing=true] {
    border: 1px solid red;
    background: rgb(255, 200, 200);
}

.widget[data-editable=true]:after, .container[data-editable=true]:after {
    content: "";
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 5px;
    height: 5px;
    background: url(assets/resize.png);
    cursor: nwse-resize;
}

.widget[data-editable=true]:hover, .container[data-editable=true]:hover {
    border: 1px solid gray;
}

.widget-input {
    flex: 1;
    min-width: 0;
    resize: none;
}

.widget[data-editable=true] .widget-input {
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}

.widget label, .widget input[type=checkbox], .widget input[type=radio] {
    align-self: center;
}

input[type=checkbox] {
    vertical-align: middle;
}

fieldset {
    border-radius: 5px;
}

button {
    font-size: 1.2em;
}

.widget-array-container {
    border: 1px solid black;
    border-radius: 5px;
    overflow: auto;
    flex: 1;
}

.widget-array-container select {
    width: 100%;
}

.widget-array-container ul {
    list-style-type: none;
    padding: 0;
}

.widget-array-container ul li {
    border-bottom: 1px solid black;
    padding-left: 1em;
    padding-right: 1em;
}

.widget-array-container ul li:nth-child(1) {
    border-top: 1px solid black;
}

.plugin-item {
    border-top: 1px solid gray;
}

.plugin-item .file, .plugin-item .version {
    display: inline-block;
    font-size: 0.8em;
    color: gray;
    padding-right: 1em;
}

.plugin-item .name {
    display: inline-block;
    padding-right: 1em;
}

input[type=checkbox].redgreen {
    -webkit-appearance: none;
    width: 100%;
    height: 100%;
    background: red;
    transition: none;
    border-radius: 2px;
    min-width: 16px;
    min-height: 16px;
}

input[type=checkbox].redgreen:checked {
    background: green;
}

.widget-graph-div {
    width: 100%;
    height: 100%;
    min-width: 300px;
    min-height: 100px;
	position: relative;
}

.widget-graph-div webview {
	width: 100%;
	height: 100%;
	display: block;
	position: absolute;
}

.connection-status {
    margin: 0;
    width: 100%;
    text-align: center;
    background: red;
    color: white;
}

.connection-status::before {
    content: "Not connected";
}

.connection-status.connected {
    background: green;
    color: white;
}

.connection-status.connected::before {
    content: "Connected";
}

.container-FlowContainer {
    white-space: normal;
    word-wrap: normal;
}

.container-FlowContainer>.widget, .container-FlowContainer>.container {
    position: relative;
    top: 0px !important;
    left: 0px !important;
}

.container-FlowContainer>.widget {
    display: inline-flex;
}

.container-FlowContainer>.container {
    display: inline-block;
}

.container-FlowContainer>.container-FlexContainer {
    display: inline-flex;
}

.container-Container .container {
    position: absolute;
}

.widget-Command button {
    -webkit-user-select: none;
}

.widget.hl {
    border: 1px dashed green !important;
}

.container-FlexContainer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 1px;
    min-height: 1px;
}

.container-FlexContainer .widget, .container-FlexContainer .container {
    position: relative;
    top: 0px !important;
    left: 0px !important;
    width: initial !important;
    height: initial !important;
    margin: 0;
}

.profile-container {
    margin-top: 5px;
    display: flex;
    align-items: center;
}

.profile-container .current-profile {
    text-overflow: ellipsis;
    overflow: hidden;
    margin-right: 20px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}

.profile-container * {
    margin-right: 0.2em;
}

.dialog {
    background: white;
    border-radius: 10px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateY(-50%) translateX(-50%) scale(0.1);
    color: black;
    display: flex;
    flex-direction: column;
    max-width: 90%;
    max-height: 90%;
}

body.vfx-allowed .dialog {
    transition: transform 0.3s cubic-bezier(.87,-.41,.19,1.44);
}

.dialog-screen {
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    pointer-events: none;
    opacity: 0;
    z-index: 999999;
}

body.vfx-allowed .dialog-screen {
    transition: opacity 0.3s;
}

.dialog-bg {
    opacity: 0;
    pointer-events: none;
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100%;
    z-index: 99999;
}

.dialog-bg-inner {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
	background-size: contain;
}

body.vfx-allowed .dialog-bg-inner {
    transition: none;
}

body.vfx-allowed .dialog-bg {
    transition: opacity 0.3s;
}

body.vfx-allowed .dialog-bg-inner {
    /*-webkit-filter: blur(3px);*/
}

.dialog-bg.active {
    opacity: 1;
}

.dialog-screen.active {
    pointer-events: all;
    opacity: 1;
}

.dialog-screen.active .dialog {
    transform: translateY(-50%) translateX(-50%) scale(1);
}

#error-screen .dialog {
    background: linear-gradient(
        #f22 0%,
        #f22 20px,
        #fff 20px,
        #fff 100%
    );
}

#error-screen h3 {
    margin-top: 1.5em;
}

#error-screen .dialog .error-details-pre {
    flex: 1;
    overflow: auto;
    background: #ddd;
}

#error-screen .report-error {
    float: left;
    padding-left: 1em;
    line-height: 25px;
}

.dialog .button-pane {
    border-top: 1px solid black;
    width: 100%;
    text-align: right;
    border-bottom-right-radius: 10px;
    border-bottom-left-radius: 10px;
}

.dialog .button-pane button {
    margin-right: 10px;
}

.dialog h3, #error-screen .dialog .error-details-pre {
    padding: 0px 10px;
}

.dialog h3 {
    word-wrap: break-word;
}

#input-screen .dialog {
    min-width: 50%;
}

#input-screen .input-content {
    flex: 1;
}

#input-screen .input-content-input {
    width: calc(100% - 1em);
    box-sizing: border-box;
    margin: 1em 0.5em;
}

#input-screen .input-details {
    margin: 1em 1em;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.widget.widget-StaticImage {
    background-color: transparent;
}

.widget.widget-MjpegStream .stream, .widget.widget-USBCameraStream .stream {
    width: 100%;
    height: 100%;
}

.widget.widget-USBCameraStream .stream, .widget.widget-MjpegStream .stream {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: monospace;
}

.widget-StaticImage .image {
    background-size: cover;
    background-repeat: no-repeat;
    background-position: 50% 50%;
    width: 100%;
    height: 100%;
}

.widget-Meter .widget-input {
    min-width: 100px;
    height: 100%;
    min-height: 20px;
    overflow: hidden;
}

.widget-Dial .dial-container {
    position: relative;
    flex: 1;
    min-width: 205px;
    min-height: 205px;
}

.widget-Meter .widget-input div {
    background: lightblue;
    width: 0;
    height: 100%;
    min-height: 20px;
}

.widget-Dial .widget-input {
    width: 200px;
    height: 200px;
    max-width: 200px;

    position: absolute;
    top: 50%;
    left: 50%;
    margin: -100px 0 0 -100px;

    border: 1px solid black;
    border-radius: 100px;
}

.widget-Dial .widget-input .needle {
    width: 10px;
    height: 100px;
    position: absolute;
    left: calc(50% - 5px);
    transform-origin: bottom;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 100px solid lightblue;
    box-sizing: border-box;
}

body.vfx-allowed .widget-Dial .widget-input .needle {
    transition: transform 0.1s;
}

.widget-Dial .widget-input .tick {
    border-left: 1px solid black;
    height: 20px;
    position: absolute;
    left: 50%;
    top: 0px;
    transform-origin: 0px 100px;
}

.tick.tick-45 {
    transform: rotate(45deg);
}
.tick.tick-90 {
    transform: rotate(90deg);
}
.tick.tick-135 {
    transform: rotate(135deg);
}
.tick.tick-180 {
    transform: rotate(180deg);
}
.tick.tick-225 {
    transform: rotate(225deg);
}
.tick.tick-270 {
    transform: rotate(270deg);
}
.tick.tick-315 {
    transform: rotate(315deg);
}

.tick-label {
    transform-origin: center;
}
.tick.tick-0 .tick-label {
    transform: translateX(-50%) translateY(20px) rotate(0deg);
}
.tick.tick-45 .tick-label {
    transform: translateX(-50%) translateY(20px) rotate(-45deg);
}
.tick.tick-90 .tick-label {
    transform: translateX(-50%) translateY(20px) rotate(-90deg);
}
.tick.tick-135 .tick-label {
    transform: translateX(-50%) translateY(20px) rotate(-135deg);
}
.tick.tick-180 .tick-label {
    transform: translateX(-50%) translateY(20px) rotate(-180deg);
}
.tick.tick-225 .tick-label {
    transform: translateX(-50%) translateY(20px) rotate(-225deg);
}
.tick.tick-270 .tick-label {
    transform: translateX(-50%) translateY(20px) rotate(-270deg);
}
.tick.tick-315 .tick-label {
    transform: translateX(-50%) translateY(20px) rotate(-315deg);
}

.prefs-edit-btn {
    margin-left: 0.5em;
    font-size: 0.7em;
}

.widget-update {
    display: block;
    position: absolute;
    font-size: 0.7em;
    opacity: 0;
    pointer-events: none;
    text-shadow: 0px 0px 5px white, 0px 0px 1px white;
    top: -1000px;
    left: -1000px;
}

body.vfx-allowed .widget-update {
    transition: opacity 0.2s, background 0.5s, box-shadow 0.5s;
}

.widget-update.active {
    opacity: 1;
    pointer-events: all;
}

.widget-drag-image {
    display: block;
    position: fixed;
    opacity: 0;
    pointer-events: none;
    top: -1000px;
    left: -1000px;
}

body.vfx-allowed .widget-drag-image.drop {
    transition: top 0.2s, left 0.2s;
}

.widget-drag-image.active {
    opacity: 1;
}

.reorder-image {
    display: block;
    position: fixed;
}

body.vfx-allowed .reorder-image.active {
    transition: top 0.2s, left 0.2s;
}

#update-screen progress {
    width: 100%;
}

#update-screen .dialog {
    overflow: hidden;
    min-width: 50%;
}

#update-screen pre {
    margin-left: 1em;
    margin-right: 1em;
    word-wrap: break-word;
    white-space: pre-wrap;
}

#update-screen p {
    margin: 0 1em;
}

.widget-trash {
    pointer-events: none;
    font-size: 3em;
    position: fixed;
    left: 30px;
    bottom: -100px;
    z-index: -1;
}

body.vfx-allowed .widget-trash {
    transition: all 0.3s;
}

.widget-trash.active {
    bottom: 20px;
}

.widget-trash.hover {
    text-shadow: 0px 0px 10px red;
    transform: scale(1.1);
}

.connection-status, button, #entries h3, .dialog *:not(pre):not(code), .widget-trash, .widget-update, #controls {
    user-select: none;
    -webkit-user-select: none;
}

.tooltip {
    background: rgba(0, 0, 0, 0.6);
    user-select: none;
    -webkit-user-select: none;
    color: white;
    border-radius: 10px;
    position: absolute;
    top: -1000px;
    left: -1000px;
    opacity: 0;
    pointer-events: none;
    padding: 5px;
    z-index: 999999;
}

.tooltip::after {
    content: "";
    position: absolute;
    top: calc(50% - 8px);
    width: 8px;
    height: 8px;
    box-sizing: border-box;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.tooltip[data-caret=left]::after {
    left: -8px;
    border-right: 8px solid rgba(0, 0, 0, 0.6);
}

.tooltip[data-caret=right]::after {
    right: -8px;
    border-left: 8px solid rgba(0, 0, 0, 0.6);
}

.tooltip[data-caret=top-left]::after {
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid rgba(0, 0, 0, 0.5);
    border-top: none;
    left: 10px;
    top: -8px;
}

body.vfx-allowed .tooltip {
    transition: opacity 0.3s, background 0.3s, box-shadow 0.3s;
}

.tooltip.active {
    opacity: 1;
}

.widget.widget-Scheduler .scheduler-container {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.widget.widget-Scheduler .scheduler-container .running-commands {
    flex: 1;
    overflow: auto;
}

.widget.widget-Scheduler .scheduler-container .cancel {
    min-height: 1.5em;
}

.svg-lazy {
    display: inline-block;
    width: 1em;
    height: 1em;
}

.svg-lazy svg {
    width: 1em;
    height: 1em;
    vertical-align: middle;
}

.tab {
    border: 1px solid black;
    border-bottom: 0;
    border-top-left-radius: 0.5em;
    border-top-right-radius: 0.5em;
    padding: 0.2em;
    margin-right: 0.2em;
    text-align: center;
    position: relative;
    top: 1px;
}

.tab.active {
    background: #ddd;
}

.tab-content {
    position: absolute;
    top: 0px;
    left: 0%;
}

body.vfx-allowed .tab-content {
    transition: opacity 0.3s, left 0.3s;
}

.tab-content:not(.active).before {
    left: -100%;
}

.tab-content:not(.active){
    pointer-events: none;
    opacity: 0;
    left: 100%;
}

.widget-entry-header {
    margin-top: 0.3em;
    margin-bottom: 0.3em;
}

#entries .tab {
    width: 25px;
    white-space: nowrap;
    overflow: hidden;
}

#entries .tab span {
    cursor: default;
}

#entries .tab i {
    width: 25px;
}

#entries .tab .tab-label {
    opacity: 0;
}

.no-entries {
    height: 100%;
    padding-top: 100px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    margin: 0;
}

.preferences-frame {
    flex: 1;
    border: 0;
}


text:
{{light.name}}

On

Off

{{light.type}}

{{light.modelid}}

          Details

{{ light | json }}


text:
The light is:

{{lightStatus}}

<button ng-click="toggle()">toggle</button>


text:
<?php
// Here you can initialize variables that will be available to your tests

function loadMyFakeClasses($class)
{
    if ('Aws\CloudWatch\CloudWatchClient' === $class) {
        require __DIR__ . '/FakeCloudWatchClient.php';
        return true;
    }
}

spl_autoload_register('loadMyFakeClasses', true, true);


text:
.class Landroid/support/v7/widget/gb;
.super Ljava/lang/Object;

# interfaces
.implements Landroid/support/v7/view/menu/x;

# instance fields
.field a:Landroid/support/v7/view/menu/i;

.field b:Landroid/support/v7/view/menu/m;

.field final synthetic c:Landroid/support/v7/widget/Toolbar;

# direct methods
.method private constructor <init>(Landroid/support/v7/widget/Toolbar;)V
    .locals 0

    iput-object p1, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method synthetic constructor <init>(Landroid/support/v7/widget/Toolbar;Landroid/support/v7/widget/fy;)V
    .locals 0

    invoke-direct {p0, p1}, Landroid/support/v7/widget/gb;-><init>(Landroid/support/v7/widget/Toolbar;)V

    return-void
.end method

# virtual methods
.method public a(Landroid/content/Context;Landroid/support/v7/view/menu/i;)V
    .locals 2

    iget-object v0, p0, Landroid/support/v7/widget/gb;->a:Landroid/support/v7/view/menu/i;

    if-eqz v0, :cond_0

    iget-object v0, p0, Landroid/support/v7/widget/gb;->b:Landroid/support/v7/view/menu/m;

    if-eqz v0, :cond_0

    iget-object v0, p0, Landroid/support/v7/widget/gb;->a:Landroid/support/v7/view/menu/i;

    iget-object v1, p0, Landroid/support/v7/widget/gb;->b:Landroid/support/v7/view/menu/m;

    invoke-virtual {v0, v1}, Landroid/support/v7/view/menu/i;->d(Landroid/support/v7/view/menu/m;)Z

    :cond_0
    iput-object p2, p0, Landroid/support/v7/widget/gb;->a:Landroid/support/v7/view/menu/i;

    return-void
.end method

.method public a(Landroid/os/Parcelable;)V
    .locals 0

    return-void
.end method

.method public a(Landroid/support/v7/view/menu/i;Z)V
    .locals 0

    return-void
.end method

.method public a(Z)V
    .locals 5

    const/4 v0, 0x0

    iget-object v1, p0, Landroid/support/v7/widget/gb;->b:Landroid/support/v7/view/menu/m;

    if-eqz v1, :cond_1

    iget-object v1, p0, Landroid/support/v7/widget/gb;->a:Landroid/support/v7/view/menu/i;

    if-eqz v1, :cond_0

    iget-object v1, p0, Landroid/support/v7/widget/gb;->a:Landroid/support/v7/view/menu/i;

    invoke-virtual {v1}, Landroid/support/v7/view/menu/i;->size()I

    move-result v2

    move v1, v0

    :goto_0
    if-ge v1, v2, :cond_0

    iget-object v3, p0, Landroid/support/v7/widget/gb;->a:Landroid/support/v7/view/menu/i;

    invoke-virtual {v3, v1}, Landroid/support/v7/view/menu/i;->getItem(I)Landroid/view/MenuItem;

    move-result-object v3

    iget-object v4, p0, Landroid/support/v7/widget/gb;->b:Landroid/support/v7/view/menu/m;

    if-ne v3, v4, :cond_2

    const/4 v0, 0x1

    :cond_0
    if-nez v0, :cond_1

    iget-object v0, p0, Landroid/support/v7/widget/gb;->a:Landroid/support/v7/view/menu/i;

    iget-object v1, p0, Landroid/support/v7/widget/gb;->b:Landroid/support/v7/view/menu/m;

    invoke-virtual {p0, v0, v1}, Landroid/support/v7/widget/gb;->b(Landroid/support/v7/view/menu/i;Landroid/support/v7/view/menu/m;)Z

    :cond_1
    return-void

    :cond_2
    add-int/lit8 v1, v1, 0x1

    goto :goto_0
.end method

.method public a()Z
    .locals 1

    const/4 v0, 0x0

    return v0
.end method

.method public a(Landroid/support/v7/view/menu/ad;)Z
    .locals 1

    const/4 v0, 0x0

    return v0
.end method

.method public a(Landroid/support/v7/view/menu/i;Landroid/support/v7/view/menu/m;)Z
    .locals 4

    const/4 v3, 0x1

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-static {v0}, Landroid/support/v7/widget/Toolbar;->b(Landroid/support/v7/widget/Toolbar;)V

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-static {v0}, Landroid/support/v7/widget/Toolbar;->c(Landroid/support/v7/widget/Toolbar;)Landroid/widget/ImageButton;

    move-result-object v0

    invoke-virtual {v0}, Landroid/widget/ImageButton;->getParent()Landroid/view/ViewParent;

    move-result-object v0

    iget-object v1, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    if-eq v0, v1, :cond_0

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v1, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-static {v1}, Landroid/support/v7/widget/Toolbar;->c(Landroid/support/v7/widget/Toolbar;)Landroid/widget/ImageButton;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/support/v7/widget/Toolbar;->addView(Landroid/view/View;)V

    :cond_0
    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-virtual {p2}, Landroid/support/v7/view/menu/m;->getActionView()Landroid/view/View;

    move-result-object v1

    iput-object v1, v0, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    iput-object p2, p0, Landroid/support/v7/widget/gb;->b:Landroid/support/v7/view/menu/m;

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v0, v0, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    invoke-virtual {v0}, Landroid/view/View;->getParent()Landroid/view/ViewParent;

    move-result-object v0

    iget-object v1, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    if-eq v0, v1, :cond_1

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-virtual {v0}, Landroid/support/v7/widget/Toolbar;->i()Landroid/support/v7/widget/Toolbar$LayoutParams;

    move-result-object v0

    const v1, 0x800003

    iget-object v2, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-static {v2}, Landroid/support/v7/widget/Toolbar;->d(Landroid/support/v7/widget/Toolbar;)I

    move-result v2

    and-int/lit8 v2, v2, 0x70

    or-int/2addr v1, v2

    iput v1, v0, Landroid/support/v7/widget/Toolbar$LayoutParams;->a:I

    const/4 v1, 0x2

    iput v1, v0, Landroid/support/v7/widget/Toolbar$LayoutParams;->b:I

    iget-object v1, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v1, v1, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    invoke-virtual {v1, v0}, Landroid/view/View;->setLayoutParams(Landroid/view/ViewGroup$LayoutParams;)V

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v1, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v1, v1, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    invoke-virtual {v0, v1}, Landroid/support/v7/widget/Toolbar;->addView(Landroid/view/View;)V

    :cond_1
    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-virtual {v0}, Landroid/support/v7/widget/Toolbar;->j()V

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-virtual {v0}, Landroid/support/v7/widget/Toolbar;->requestLayout()V

    invoke-virtual {p2, v3}, Landroid/support/v7/view/menu/m;->e(Z)V

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v0, v0, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    instance-of v0, v0, Landroid/support/v7/view/d;

    if-eqz v0, :cond_2

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v0, v0, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    check-cast v0, Landroid/support/v7/view/d;

    invoke-interface {v0}, Landroid/support/v7/view/d;->a()V

    :cond_2
    return v3
.end method

.method public b()I
    .locals 1

    const/4 v0, 0x0

    return v0
.end method

.method public b(Landroid/support/v7/view/menu/i;Landroid/support/v7/view/menu/m;)Z
    .locals 3

    const/4 v2, 0x0

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v0, v0, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    instance-of v0, v0, Landroid/support/v7/view/d;

    if-eqz v0, :cond_0

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v0, v0, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    check-cast v0, Landroid/support/v7/view/d;

    invoke-interface {v0}, Landroid/support/v7/view/d;->b()V

    :cond_0
    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v1, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v1, v1, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    invoke-virtual {v0, v1}, Landroid/support/v7/widget/Toolbar;->removeView(Landroid/view/View;)V

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iget-object v1, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-static {v1}, Landroid/support/v7/widget/Toolbar;->c(Landroid/support/v7/widget/Toolbar;)Landroid/widget/ImageButton;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/support/v7/widget/Toolbar;->removeView(Landroid/view/View;)V

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    iput-object v2, v0, Landroid/support/v7/widget/Toolbar;->a:Landroid/view/View;

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-virtual {v0}, Landroid/support/v7/widget/Toolbar;->k()V

    iput-object v2, p0, Landroid/support/v7/widget/gb;->b:Landroid/support/v7/view/menu/m;

    iget-object v0, p0, Landroid/support/v7/widget/gb;->c:Landroid/support/v7/widget/Toolbar;

    invoke-virtual {v0}, Landroid/support/v7/widget/Toolbar;->requestLayout()V

    const/4 v0, 0x0

    invoke-virtual {p2, v0}, Landroid/support/v7/view/menu/m;->e(Z)V

    const/4 v0, 0x1

    return v0
.end method

.method public c()Landroid/os/Parcelable;
    .locals 1

    const/4 v0, 0x0

    return-object v0
.end method


text:
import unittest
import tethys_apps.base.handoff as tethys_handoff
from types import FunctionType
from unittest import mock
from tethys_sdk.testing import TethysTestCase

def test_function(*args):

    if args is not None:
        arg_list = []
        for arg in args:
            arg_list.append(arg)
        return arg_list
    else:
        return ""

class TestHandoffManager(unittest.TestCase):
    def setUp(self):
        self.hm = tethys_handoff.HandoffManager

    def tearDown(self):
        pass

    def test_init(self):
        # Mock app
        app = mock.MagicMock()

        # Mock handoff_handlers
        handlers = mock.MagicMock(name="handler_name")
        app.handoff_handlers.return_value = handlers

        # mock _get_valid_handlers
        self.hm._get_valid_handlers = mock.MagicMock(return_value=["valid_handler"])
        result = tethys_handoff.HandoffManager(app=app)

        # Check result
        self.assertEqual(app, result.app)
        self.assertEqual(handlers, result.handlers)
        self.assertEqual(["valid_handler"], result.valid_handlers)

    def test_repr(self):
        # Mock app
        app = mock.MagicMock()

        # Mock handoff_handlers
        handlers = mock.MagicMock()
        handlers.name = "test_handler"
        app.handoff_handlers.return_value = [handlers]

        # mock _get_valid_handlers
        self.hm._get_valid_handlers = mock.MagicMock(return_value=["valid_handler"])
        result = tethys_handoff.HandoffManager(app=app).__repr__()
        check_string = "<Handoff Manager: app={}, handlers=['{}']>".format(
            app, handlers.name
        )

        self.assertEqual(check_string, result)

    def test_get_capabilities(self):
        # Mock app
        app = mock.MagicMock()

        # Mock _get_handoff_manager_for_app
        manager = mock.MagicMock(valid_handlers="test_handlers")
        self.hm._get_handoff_manager_for_app = mock.MagicMock(return_value=manager)

        result = tethys_handoff.HandoffManager(app=app).get_capabilities(
            app_name="test_app"
        )

        # Check Result
        self.assertEqual("test_handlers", result)

    def test_get_capabilities_external(self):
        # Mock app
        app = mock.MagicMock()

        # Mock _get_handoff_manager_for_app
        handler1 = mock.MagicMock()
        handler1.internal = False
        handler2 = mock.MagicMock()
        # Do not write out handler2
        handler2.internal = True
        manager = mock.MagicMock(valid_handlers=[handler1, handler2])
        self.hm._get_handoff_manager_for_app = mock.MagicMock(return_value=manager)

        result = tethys_handoff.HandoffManager(app=app).get_capabilities(
            app_name="test_app", external_only=True
        )

        # Check Result
        self.assertEqual([handler1], result)

    @mock.patch("tethys_apps.base.handoff.json")
    def test_get_capabilities_json(self, mock_json):
        # Mock app
        app = mock.MagicMock()

        # Mock HandoffHandler.__json

        handler1 = mock.MagicMock(name="test_name")
        manager = mock.MagicMock(valid_handlers=[handler1])
        self.hm._get_handoff_manager_for_app = mock.MagicMock(return_value=manager)

        tethys_handoff.HandoffManager(app=app).get_capabilities(
            app_name="test_app", jsonify=True
        )

        # Check Result
        rts_call_args = mock_json.dumps.call_args_list
        self.assertEqual("test_name", rts_call_args[0][0][0][0]["_mock_name"])

    def test_get_handler(self):
        app = mock.MagicMock()

        # Mock _get_handoff_manager_for_app
        handler1 = mock.MagicMock()
        handler1.name = "handler1"
        manager = mock.MagicMock(valid_handlers=[handler1])
        self.hm._get_handoff_manager_for_app = mock.MagicMock(return_value=manager)

        result = tethys_handoff.HandoffManager(app=app).get_handler(
            handler_name="handler1"
        )

        self.assertEqual("handler1", result.name)

    @mock.patch("tethys_apps.base.handoff.HttpResponseBadRequest")
    def test_handoff_type_error(self, mock_hrbr):
        from django.http import HttpRequest

        request = HttpRequest()

        # Mock app
        app = mock.MagicMock()
        app.name = "test_app_name"

        # Mock _get_handoff_manager_for_app
        handler1 = mock.MagicMock()
        handler1().internal = False
        handler1().side_effect = TypeError("test message")
        manager = mock.MagicMock(get_handler=handler1)
        self.hm._get_handoff_manager_for_app = mock.MagicMock(return_value=manager)

        tethys_handoff.HandoffManager(app=app).handoff(
            request=request, handler_name="test_handler"
        )
        rts_call_args = mock_hrbr.call_args_list

        # Check result
        self.assertIn("HTTP 400 Bad Request: test message.", rts_call_args[0][0][0])

    @mock.patch("tethys_apps.base.handoff.HttpResponseBadRequest")
    def test_handoff_error(self, mock_hrbr):
        from django.http import HttpRequest

        request = HttpRequest()
        #
        # # Mock app
        app = mock.MagicMock()
        app.name = "test_app_name"

        # Mock _get_handoff_manager_for_app
        handler1 = mock.MagicMock()
        # Ask Nathan is this how the test should be. because internal = True has
        # nothing to do with the error message.
        handler1().internal = True
        handler1().side_effect = TypeError("test message")
        mapp = mock.MagicMock()
        mapp.name = "test manager name"
        manager = mock.MagicMock(get_handler=handler1, app=mapp)
        self.hm._get_handoff_manager_for_app = mock.MagicMock(return_value=manager)

        tethys_handoff.HandoffManager(app=app).handoff(
            request=request, handler_name="test_handler"
        )
        rts_call_args = mock_hrbr.call_args_list

        # Check result
        check_message = (
            "HTTP 400 Bad Request: No handoff handler '{0}' for app '{1}' found".format(
                "test manager name", "test_handler"
            )
        )
        self.assertIn(check_message, rts_call_args[0][0][0])

    def test_get_valid_handlers(self):
        app = mock.MagicMock(package="test_app")

        # Mock handoff_handlers
        handler1 = mock.MagicMock(handler="controllers.home", valid=True)

        app.handoff_handlers.return_value = [handler1]

        # mock _get_valid_handlers
        result = tethys_handoff.HandoffManager(app=app)._get_valid_handlers()
        # Check result
        self.assertEqual("controllers.home", result[0].handler)

class TestHandoffHandler(unittest.TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_init(self):
        result = tethys_handoff.HandoffHandler(
            name="test_name", handler="test_app.handoff.csv", internal=True
        )

        # Check Result
        self.assertEqual("test_name", result.name)
        self.assertEqual("test_app.handoff.csv", result.handler)
        self.assertTrue(result.internal)
        self.assertIs(type(result.function), FunctionType)

    def test_repr(self):
        result = tethys_handoff.HandoffHandler(
            name="test_name", handler="test_app.handoff.csv", internal=True
        ).__repr__()

        # Check Result
        check_string = "<Handoff Handler: name=test_name, handler=test_app.handoff.csv>"
        self.assertEqual(check_string, result)

    def test_dict_json_arguments(self):
        tethys_handoff.HandoffHandler.arguments = ["test_json", "request"]
        result = tethys_handoff.HandoffHandler(
            name="test_name", handler="test_app.handoff.csv", internal=True
        ).__dict__()

        # Check Result
        check_dict = {"name": "test_name", "arguments": ["test_json"]}
        self.assertIsInstance(result, dict)
        self.assertEqual(check_dict, result)

    def test_arguments(self):
        result = tethys_handoff.HandoffHandler(
            name="test_name", handler="test_app.handoff.csv", internal=True
        ).arguments

        self.assertEqual(["request", "csv_url"], result)

class TestGetHandoffManagerFroApp(unittest.TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_not_app_name(self):
        app = mock.MagicMock()
        result = tethys_handoff.HandoffManager(app=app)._get_handoff_manager_for_app(
            app_name=None
        )

        self.assertEqual(app, result.app)

    @mock.patch("tethys_apps.base.handoff.tethys_apps")
    def test_with_app(self, mock_ta):
        app = mock.MagicMock(package="test_app")
        app.get_handoff_manager.return_value = "test_manager"
        mock_ta.harvester.SingletonHarvester().apps = [app]
        result = tethys_handoff.HandoffManager(app=app)._get_handoff_manager_for_app(
            app_name="test_app"
        )

        # Check result
        self.assertEqual("test_manager", result)

class TestTestAppHandoff(TethysTestCase):
    def set_up(self):
        self.c = self.get_test_client()
        self.user = self.create_test_user(
            username="joe", password="secret", email="joe@some_site.com"
        )
        self.c.force_login(self.user)

    def tear_down(self):
        self.user.delete()

    def test_test_app_handoff(self):
        response = self.c.get('/handoff/test-app/test_name/?csv_url=""')

        self.assertEqual(302, response.status_code)


text:
from conans.client.graph.graph import BINARY_BUILD, BINARY_CACHE, BINARY_DOWNLOAD, BINARY_MISSING, \
    BINARY_UPDATE
from conans.client.installer import build_id

class Node(object):
    def __init__(self, id, node, is_build_time_node):
        self.id = id
        self._ref = node.ref
        self._conanfile = node.conanfile
        self._is_build_time_node = is_build_time_node
        self.package_id = node.package_id
        self.binary = node.binary

    @property
    def label(self):
        return self._conanfile.display_name

    @property
    def short_label(self):
        if self._ref and self._ref.name:
            return "{}/{}".format(self._ref.name, self._ref.version)
        else:
            return self.label

    @property
    def is_build_requires(self):
        return self._is_build_time_node

    def data(self):

        def ensure_iterable(value):
            if isinstance(value, (list, tuple)):
                return value
            return value,

        return {
            'build_id': build_id(self._conanfile),
            'url': self._conanfile.url,
            'homepage': self._conanfile.homepage,
            'license': self._conanfile.license,
            'author': self._conanfile.author,
            'topics': ensure_iterable(self._conanfile.topics) if self._conanfile.topics else None
        }

class Grapher(object):
    def __init__(self, deps_graph):
        self._deps_graph = deps_graph
        self.nodes, self.edges = self._build_graph()

    def _build_graph(self):
        graph_nodes = self._deps_graph.by_levels()
        build_time_nodes = self._deps_graph.build_time_nodes()
        graph_nodes = reversed([n for level in graph_nodes for n in level])

        _node_map = {}
        for i, node in enumerate(graph_nodes):
            n = Node(i, node, bool(node in build_time_nodes))
            _node_map[node] = n

        edges = []
        for node in self._deps_graph.nodes:
            for node_to in node.neighbors():
                src = _node_map[node]
                dst = _node_map[node_to]
                edges.append((src, dst))

        return _node_map.values(), edges

    def binary_color(self, node):
        assert isinstance(node, Node), "Wrong type '{}'".format(type(node))
        color = {BINARY_CACHE: "SkyBlue",
                 BINARY_DOWNLOAD: "LightGreen",
                 BINARY_BUILD: "Khaki",
                 BINARY_MISSING: "OrangeRed",
                 BINARY_UPDATE: "SeaGreen"}.get(node.binary, "White")
        return color


text:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

#------- Eficiencia Operacional > Eficiencia (FO10) -------#

class LA_AT_10 extends CI_Controller
{
    # Atributos gerais do Controller
    protected $controller;
    protected $index;
    protected $view;
    protected $error;
    protected $alerta;
    # Atributos exclusivos do Controller (Sessao)
    protected $loginIn;

    public function error403()
    {
        $message = "Você nao tem permissão para acessar essa pagina.";
        $status_code = 403;
        show_error($message, $status_code, $heading = 'Desculpe =(');
    }

    public function caracter($var)
    {
        # Retira os acentos
        $from = "ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ";
        $to = "SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy";
        $keys = array();
        $values = array();
        preg_match_all('/./u', $from, $keys);
        preg_match_all('/./u', $to, $values);
        $mapping = array_combine($keys[0], $values[0]);
        return strtr($var, $mapping);
    }

    public function session_projeto_up($array)
    {
        $this->session->set_userdata('projeto', $this->session->userdata('projeto') + $array);
    }

    public function session_projeto_del($dados)
    {
        unset($_SESSION['projeto'][$dados]);
    }

    public function session_projeto_renew()
    {
        $this->session->unset_userdata('projeto');
        $this->session->set_userdata('projeto', array('controller' => $this->controller));
    }

    public function __construct()
    {
        parent:: __construct();
        # Monta os models (bancos)
        $this->load->model('projetos_centralizados/LA_AT_10_model');
        $this->load->model('_app/usuario_model');
        # Monta os atributos gerais
        $this->controller = $this->uri->segment(2); // Pega o nome do controller
        $this->index = 'principal'; // Atribui a pagina inicial
        # Monta os atributos exclusivos
        # Se o usuario estiver ativo na sessao, transfere para o Controller
        if (isset($this->session->usuario['loginIn']) && $this->session->usuario['loginIn'] == true) {
            $this->loginIn = $this->session->usuario['loginIn'];
        } # Se o usuario estiver inativo na sessao, transfere para o Controller
        else {
            $this->loginIn = false;
        }
        # Prepara o template
        $this->view['header'] = array('title' => 'Fusions Mobile'); // Valores header entra aqui
        $this->view['menu'] = $this->menu->menu($this->session->usuario['registro'], $this->session->usuario['perfil'], $this->controller);
        $this->view['view'] = array(); // Valores view entra aqui
        $this->view['footer'] = array(); // Valores footer entra aqui
    }

    public function index()
    {
        # Se o usuario estiver logado
        if ($this->loginIn) {
            # Renova o projeto
            $this->session_projeto_renew();
            # Continua o fluxo
            redirect(base_url('projetos_centralizados/LA_AT_10/P1'));
        } else {
            redirect(base_url($this->index));
        }
    }

    public function P1()
    {
        # Se o usuario estiver logado
        if ($this->loginIn && $this->session->projeto['controller'] == $this->controller) {
            # Recebe o relatorio conforme o filtro
            $res = $this->LA_AT_10_model->listar_ordens($this->session->usuario['empresa'], $this->session->usuario['regional'], $this->session->usuario['contrato']);
            # Monta a
 na VIEW
            $this->view['table'] = $res[0];
            $this->view['table_num'] = $res[1];
            # Carrega o template e roda a VIEW
            $this->load->view('_app/template/header', $this->view['header']);
            $this->load->view('_app/template/menu', $this->view['menu']);
            $this->load->view('projetos_centralizados/LA_AT_10_view1', $this->view);
            $this->load->view('_app/template/footer', $this->view['footer']);
        } else {
            redirect(base_url($this->index));
        }
    }

    public function P1_return()
    {
        # Se o usuario estiver logado
        if ($this->loginIn && $this->session->projeto['controller'] == $this->controller) {
            # Se o vistoriado foi passado na URL
            if ($this->uri->segment(4) == true) {
                #Salva na sessao e redireciona
                $this->session->set_userdata('id', $this->uri->segment(4));
                redirect(base_url('projetos_centralizados/LA_AT_10/P3'));
            } else {
                redirect(base_url('projetos_centralizados/LA_AT_10/P2'));
            }
        } else {
            redirect(base_url($this->index));
        }
    }

    public function P2()
    {
        # Se o usuario estiver logado
        if ($this->loginIn && $this->session->projeto['controller'] == $this->controller) {
            # Carrega o template e roda a VIEW
            $this->load->view('_app/template/header', $this->view['header']);
            $this->load->view('_app/template/menu', $this->view['menu']);
            $this->load->view('projetos_centralizados/LA_AT_10_view2', $this->view);
            $this->load->view('_app/template/footer', $this->view['footer']);
        } else {
            redirect(base_url($this->index));
        }
    }

    public function P2_return()
    {
        # Se o usuario estiver logado
        if ($this->loginIn && $this->session->projeto['controller'] == $this->controller) {
            if ($this->input->post() == false || isset($this->view['alerta'])) {
                # Volta ao fluxo
                redirect(base_url('projetos_centralizados/LA_AT_10/P2'));
            } else {
                # Valida o formulario
                $this->form_validation->set_rules('cliente', 'Cliente', 'required|min_length[3]');
                $this->form_validation->set_rules('endereco', 'Endereco', 'required');
                # Se a validação estiver OK
                if ($this->form_validation->run() == true) {
                    # Prepara os valores armazenados

                    $status = ($this->input->post('data_agenda') != "") ? 'AGENDADA' : 'PENDENTE';

                    $dados = array(
                        'ordem' => ucwords(strtoupper($this->input->post('ordem'))),
                        'terminal' => ucwords(strtoupper($this->input->post('terminal'))),
                        'tipo' => $this->input->post('tipo'),
                        'pacote_banda' => $this->input->post('pacote_banda'),
                        'pacote_tv' => ucwords(strtoupper($this->input->post('pacote_tv'))),
                        'cliente' => ucwords(strtoupper($this->input->post('cliente'))),
                        'cpf' => ucwords(strtoupper($this->input->post('n_cpf'))),
                        'contato_nom' => ucwords(strtoupper($this->input->post('contato_nom'))),
                        'contato_tel' => ucwords(strtoupper($this->input->post('contato_tel'))),
                        'endereco' => ucwords(strtoupper($this->input->post('endereco'))),
                        'empresa' => 'VIVO',
                        'regional' => 'SPI',
                        'contrato' => 'PC/SC',
                        'data_agenda' => $this->input->post('data_agenda'),
                        'fila_re' => "PENDENTE",
                        'fila_ri' => "PENDENTE",
                        'stt_cliente' => "PENDENTE",
                        'stt_cliente_order' => 6,
                        'obs_re' => "",
                        'obs_ri' => "",
                        'obs_comercial' => "",
                        'obs_associacao' => "",
                        'obs_agenda' => ""
                    );
                    # Envia os dados para o Banco
                    if ($this->LA_AT_10_model->inserirDados($dados)) {
                        redirect(base_url('projetos_centralizados/LA_AT_10/P1'));
                    } # Senao, gera o erro para o usuario
                    else {
                        $this->view['alerta'] = array("css_class" => 'alert-warning', "msg" => 'Ocorreu um erro ao efetuar o cadastro. Tente novamente.');
                        $this->P2();
                    }
                } # Senao, gera o erro para o usuario
                else {
                    $this->view['alerta'] = array("css_class" => 'alert-warning', "msg" => validation_errors());
                    $this->P2();
                }
            }
        }
    }

    public function P3()
    {
        # Se o usuario estiver logado
        if ($this->loginIn && $this->session->projeto['controller'] == $this->controller) {
            # Pega os dados do cliente
            $this->view['consulta'] = $this->LA_AT_10_model->consultar_ordem($this->session->id);

            # Carrega o template e roda a VIEW
            $this->load->view('_app/template/header', $this->view['header']);
            $this->load->view('_app/template/menu', $this->view['menu']);
            $this->load->view('projetos_centralizados/LA_AT_10_view3', $this->view);
            $this->load->view('_app/template/footer', $this->view['footer']);
        } else {
            redirect(base_url($this->index));
        }
    }

    public function P3_return()
    {
        # Se o usuario estiver logado
        if ($this->loginIn && $this->session->projeto['controller'] == $this->controller) {
            # Se o usuario fez requisição via POST
            if ($this->input->post() == false || isset($this->view['alerta'])) {
                # Volta ao fluxo
                redirect(base_url('projetos_centralizados/LA_AT_10/P3'));
            } else {
                # Valida o formulario
                $this->form_validation->set_rules('cliente', 'Cliente', 'required|min_length[3]');
                # Se a validação estiver OK
                if ($this->form_validation->run() == true) {
                    # Prepara os valores armazenados
                    $consulta = $this->LA_AT_10_model->consultar_ordem($this->session->id);
                    $obs_re = $consulta[0]->obs_re;
                    $obs_ri = $consulta[0]->obs_ri;

                    $temp = explode('&',$this->input->post('stt_cliente'));
                    $stt_cliente = $temp[0];
                    $stt_cliente_order = $temp[1];

                    $dados = array(
                        'ordem' => $this->input->post('ordem'),
                        'terminal' => $this->input->post('terminal'),
                        'tipo' => $this->input->post('tipo'),
                        'pacote_banda' => $this->input->post('pacote_banda'),
                        'pacote_tv' => ucwords(strtoupper($this->input->post('pacote_tv'))),
                        'cliente' => $this->input->post('cliente'),
                        'cpf' => ucwords(strtoupper($this->input->post('n_cpf'))),
                        'contato_nom' => $this->input->post('contato_nom'),
                        'contato_tel' => $this->input->post('contato_tel'),
                        'endereco' => $this->input->post('endereco'),
                        'data_agenda' => $this->input->post('data_agenda'),
                        'fila_re' => $this->input->post('fila_re'),
                        'fila_ri' => $this->input->post('fila_ri'),
                        'stt_cliente' => $stt_cliente,
                        'stt_cliente_order' => $stt_cliente_order,
                        'obs_re' => $this->session->usuario['registro'] . ": " . $this->input->post('obs_re') . " // " . $obs_re,
                        'obs_ri' => $this->session->usuario['registro'] . ": " . $this->input->post('obs_ri') . " // " . $obs_ri,
                    );
                    $where_dados = "id = '" . $this->session->id . "'";
                    # Atualiza os dados no banco
                    if ($this->LA_AT_10_model->atualizarDados($dados, $where_dados)) {
                        redirect(base_url('projetos_centralizados/LA_AT_10/P1'));
                    } # Senao, gera o erro para o usuario
                    else {
                        $this->view['alerta'] = array("css_class" => 'alert-warning', "msg" => 'Ocorreu um erro ao efetuar o cadastro. Tente novamente.');
                        $this->P3();
                    }
                } # Senao, gera o erro para o usuario
                else {
                    $this->view['alerta'] = array("css_class" => 'alert-warning', "msg" => validation_errors());
                    $this->P3();
                }
            }
        }
    }

    public function delete()
    {
        # Se o usuario estiver logado
        if ($this->loginIn && $this->session->projeto['controller'] == $this->controller) {
            # Se o vistoriado foi passado na URL
            if ($this->uri->segment(4) == true) {
                #Deleta o registro
                $this->LA_AT_10_model->deletarDado($this->uri->segment(4));
                redirect(base_url('projetos_centralizados/LA_AT_10/P1'));
            } else {
                $this->view['alerta'] = array("css_class" => 'alert-warning', "msg" => 'Ocorreu um erro ao deletar o cadastro. Tente novamente.');
                $this->P3();
            }
        } else {
            redirect(base_url($this->index));
        }
    }

    public function logout()
    {
        # Renova o projeto e manda para a tela inicial
        $this->session_projeto_renew();
        redirect(base_url($this->index));
    }
}


text:
'use strict';

describeComponent('component/data-groups', function () {
  var server;

  // Initialize the component and attach it to the DOM
  beforeEach(function () {
    setupComponent();
    server = sinon.fakeServer.create();
  });

  afterEach(function() {
    server.restore();
  });

  it('should be defined', function () {
    expect(this.component).toBeDefined();
  });

  describe('after initialize', function() {
    it('should call getGroups() to update the group form', function() {
    });
  });

  describe('on ui-add_group', function() {
    var testGroup;

    beforeEach(function() {
      this.component.groups = []; // Clear the components memory of groups.
      testGroup = {
        name: 'TST'
      };
    });
    it('should trigger data-invalid_group with message: empty name if group in '+
       'data doesn\'t have a name', function() {
      var eventSpy,
          testGroup,
          expected;

      testGroup = {};
      expected = {
        message: 'empty',
        group: testGroup
      };
      eventSpy = spyOnEvent(document, 'data-invalid_group');

      this.component.trigger('ui-add_group', {group: testGroup});

      expect(eventSpy).toHaveBeenTriggeredOn(document);
      expect(eventSpy.mostRecentCall.data).toEqual(expected);
    });
    it('should trigger data-invalid_add_group with message: duplicate if the '+
       'group is a duplicate', function() {
      var eventSpy,
          expected;

      expected = {
        message: 'duplicate',
        group: testGroup
      };
      eventSpy = spyOnEvent(document, 'data-invalid_group');
      this.component.groups.push(testGroup);

      this.component.trigger('ui-add_group', {group: testGroup});

      expect(eventSpy).toHaveBeenTriggeredOn(document);
      expect(eventSpy.mostRecentCall.data).toEqual(expected);
    });
    it('should trigger data-loading_group', function() {
      var eventSpy;

      eventSpy = spyOnEvent(document, 'data-loading_group');

      this.component.trigger('ui-add_group', {group: 'newGroup'});

      expect(eventSpy).toHaveBeenTriggeredOn(document);
    });
    it('should trigger data-added_group if adding was successful', function() {
      var eventSpy,
          expected = 'newGroup';

      expected = {name: 'TestGroup1'};
      eventSpy = spyOnEvent(document, 'data-added_group');

      this.component.trigger('ui-add_group', {group: expected});

      expect(eventSpy).toHaveBeenTriggeredOn(document);
      expect(eventSpy.mostRecentCall.data).toEqual({group: expected});
    });
    it('should trigger data-loaded_group with new group on success', function() {
      var eventSpy;

      eventSpy = spyOnEvent(document, 'data-loaded_group');

      this.component.trigger('ui-add_group', {group: testGroup});

      expect(eventSpy).toHaveBeenTriggeredOn(document);
    });
  });

  describe('getGroups()', function() {
    it('should default to no callbacks if options is not passed in', function() {
      server.respondWith('GET', '/groups',
                              [500, { 'Content-Type': 'application/json' },
                               '{}']);
      this.component.getGroups();
      server.respond();
    });
    it('should make an ajax request to /groups', function() {
      this.component.getGroups({});

      expect(server.requests[0].url).toEqual('/groups');
    });
    it('should execute the success callback passed in if request successful',
       function() {
      var cbSpy = sinon.spy(),
          expected = '[{"id": 1}]';

      server.respondWith('GET', '/groups',
                              [200, { 'Content-Type': 'application/json' },
                               expected]);

      this.component.getGroups({success: cbSpy});
      server.respond();

      expect(cbSpy).toHaveBeenCalledWith(JSON.parse(expected));
    });
    it('should execute the error callback passed in if request unsuccessful',
       function() {
      var cbSpy = sinon.spy();

      server.respondWith('GET', '/groups',
                              [500, { 'Content-Type': 'application/json' },
                               '']);

      this.component.getGroups({error: cbSpy});
      server.respond();

      expect(cbSpy).toHaveBeenCalled();
    });
  });

  describe('on ui-wanted_new_group', function() {
    it('should trigger a data-wanted_new_group event on document', function() {
      var eventSpy;

      eventSpy = spyOnEvent(document, 'data-wanted_new_group');

      this.component.trigger('ui-wanted_new_group');

      expect(eventSpy).toHaveBeenTriggeredOn(document);
    });
  });

  describe('on ui-deactivate_group_add', function() {
    it('should trigger data-deactivate_group_add on document', function() {
      var eventSpy;

      eventSpy = spyOnEvent(document, 'data-deactivate_group_add');

      this.component.trigger('ui-deactivate_group_add');

      expect(eventSpy).toHaveBeenTriggeredOn(document);
    });
  });
});


text: Small project to build a Java based machine learning model that reads hand writtendigits


text:
var express = require('express');
var router = express.Router();
var elasticsearch = require('elasticsearch');

/* GET home page. */
router.get('/', function(req, res) {
    var client = new elasticsearch.Client({
        host: 'localhost:9200'
    });
    client.search({
        q: 'pants'
    }).then(function (body) {
        console.log(body);
        res.render('index', { title: 'Express' });
    });
});

router.post('/search', function (req, res) {
    var client = new elasticsearch.Client({
        host: 'localhost:9200'
    });

    client.search({
        index: 'artists',
        q: req.body.query
    }).then(function (body) {
        console.log(body);
        res.render('search', { results: body });
    });
})

module.exports = router;


text:
/**
 * Created by anhle on 7/12/17.
 */
export interface Expertise {
    icon: string,
    category: string,
    description: string
}


text:
#include "config.h"

#if ENABLE(WEBGL)
#include "WebGLQuery.h"

#include "WebGLContextGroup.h"
#include "WebGLRenderingContextBase.h"

namespace WebCore {

Ref<WebGLQuery> WebGLQuery::create(WebGLRenderingContextBase& ctx)
{
    return adoptRef(*new WebGLQuery(ctx));
}

WebGLQuery::~WebGLQuery()
{
    deleteObject(0);
}

WebGLQuery::WebGLQuery(WebGLRenderingContextBase& ctx)
    : WebGLSharedObject(ctx)
{
    // FIXME: Call createQuery from GraphicsContext3D.
}

void WebGLQuery::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObject object)
{
    UNUSED_PARAM(context3d);
    UNUSED_PARAM(object);
    // FIXME: Call deleteQuery from GraphicsContext3D.
}

}

#endif // ENABLE(WEBGL)


text:
<?xml version="1.0" encoding="UTF-8"?>
<actions>
        <action>
            <actionName>CUSTOM-install (skip tests)</actionName>
            <displayName>install (skip tests)</displayName>
            <goals>
                <goal>clean</goal>
                <goal>install</goal>
            </goals>
            <properties>
                <skipTests>true</skipTests>
            </properties>
        </action>
    </actions>


text:
!< FOODIE error codes list.

module foodie_error_codes
!< FOODIE error codes list.

use penf, only : I_P

implicit none
private
public :: ERROR_UNSUPPORTED_SCHEME

integer(I_P), parameter :: ERROR_UNSUPPORTED_SCHEME = 1 !< Error unsupported scheme.
endmodule foodie_error_codes


text:
package butterknife;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.CLASS;

/**
 * Bind a field to the specified dimension resource ID. Type can be {@code int} for pixel size or
 * {@code float} for exact amount.
 *

 * {@literal @}ResourceDimen(R.dimen.horizontal_gap) int gapPx;
 * {@literal @}ResourceDimen(R.dimen.horizontal_gap) float gap;
 *

 */
@Retention(CLASS) @Target(FIELD)
public @interface BindDimen {
  /** Dimension resource ID to which the field will be bound. */
  int value();
}