text:
/*!!
 * @atlassian/aui - Atlassian User Interface Framework
 * @version v7.7.0
 * @link https://docs.atlassian.com/aui/latest/
 * @license SEE LICENSE IN LICENSE.md
 * @author Atlassian Pty Ltd.
 */
// src/js/aui/internal/deprecation/deprecated-adg2-icons.js
(typeof window === 'undefined' ? global : window).__ac524c2679e70c463a41309e6dacb4bb = (function () {
  var module = {
    exports: {}
  };
  var exports = module.exports;

  'use strict';

  Object.defineProperty(exports, "__esModule", {
      value: true
  });
  var deprecatedIcons = [{
      newName: 'menu',
      oldName: 'appswitcher'
  }, {
      newName: 'refresh',
      oldName: 'build'
  }, {
      newName: 'cross',
      oldName: 'close-dialog'
  }, {
      newName: 'chevron-right',
      oldName: 'collapsed'
  }, {
      newName: 'settings',
      oldName: 'configure'
  }, {
      newName: 'copy',
      oldName: 'copy-clipboard'
  }, {
      newName: 'trash',
      oldName: 'delete'
  }, {
      newName: 'detail-view',
      oldName: 'details'
  }, {
      newName: 'arrow-left',
      oldName: 'devtools-arrow-left'
  }, {
      newName: 'arrow-right',
      oldName: 'devtools-arrow-right'
  }, {
      newName: 'sign-in',
      oldName: 'devtools-checkout'
  }, {
      newName: 'import',
      oldName: 'devtools-clone'
  }, {
      newName: 'folder-filled',
      oldName: 'devtools-folder-closed'
  }, {
      newName: 'export',
      oldName: 'devtools-pull-request'
  }, {
      newName: 'tag',
      oldName: 'devtools-tag'
  }, {
      newName: 'tag',
      oldName: 'devtools-tag-small'
  }, {
      newName: 'menu',
      oldName: 'drag-vertical'
  }, {
      newName: 'edit-filled',
      oldName: 'edit'
  }, {
      newName: 'edit-filled',
      oldName: 'edit-small'
  }, {
      newName: 'chevron-up',
      oldName: 'expanded'
  }, {
      newName: 'vid-full-screen-on',
      oldName: 'focus'
  }, {
      newName: 'more-vertical',
      oldName: 'handle-horizontal'
  }, {
      newName: 'question-circle',
      oldName: 'help'
  }, {
      newName: 'home-circle',
      oldName: 'homepage'
  }, {
      newName: 'image',
      oldName: 'image-extrasmall'
  }, {
      newName: 'info-circle',
      oldName: 'info'
  }, {
      newName: 'world',
      oldName: 'weblink'
  }, {
      newName: 'add-circle',
      oldName: 'list-add'
  }, {
      newName: 'cross-circle',
      oldName: 'list-remove'
  }, {
      newName: 'lock-filled',
      oldName: 'locked'
  }, {
      newName: 'lock-filled',
      oldName: 'locked-small'
  }, {
      newName: 'document',
      oldName: 'page-blank'
  }, {
      newName: 'document',
      oldName: 'doc'
  }, {
      newName: 'documents',
      oldName: 'pages'
  }, {
      newName: 'cross-circle',
      oldName: 'remove'
  }, {
      newName: 'cross-circle',
      oldName: 'remove-label'
  }, {
      newName: 'search',
      oldName: 'search-small'
  }, {
      newName: 'person-circle',
      oldName: 'space-personal'
  }, {
      newName: 'star-filled',
      oldName: 'star'
  }, {
      newName: 'check',
      oldName: 'success'
  }, {
      newName: 'recent',
      oldName: 'time'
  }, {
      newName: 'vid-full-screen-off',
      oldName: 'unfocus'
  }, {
      newName: 'unlock-filled',
      oldName: 'unlocked'
  }, {
      newName: 'star',
      oldName: 'unstar'
  }, {
      newName: 'watch',
      oldName: 'unwatch'
  }, {
      newName: 'arrow-up',
      oldName: 'up'
  }, {
      newName: 'arrow-down',
      oldName: 'down'
  }, {
      newName: 'person',
      oldName: 'user'
  }, {
      newName: 'watch-filled',
      oldName: 'view'
  }, {
      newName: 'room-menu',
      oldName: 'view-list'
  }, {
      newName: 'menu',
      oldName: 'view-table'
  }, {
      newName: 'watch-filled',
      oldName: 'watch'
  }, {
      newName: 'tray',
      oldName: 'workbox'
  }, {
      newName: 'bullet-list',
      oldName: 'configure-columns'
  }, {
      newName: 'image',
      oldName: 'file-image'
  }, {
      newName: 'group',
      oldName: 'admin-roles'
  }, {
      newName: 'vid-pause',
      oldName: 'pause'
  }, {
      newName: 'refresh',
      oldName: 'refresh-small'
  }, {
      newName: 'swap',
      oldName: 'switch-small'
  }, {
      newName: 'arrow-down-small',
      oldName: 'arrow-down'
  }, {
      newName: 'arrow-up-small',
      oldName: 'arrow-up'
  }, {
      newName: 'email',
      oldName: 'email-large'
  }, {
      newName: 'documents',
      oldName: 'pages-large'
  }, {
      newName: 'person',
      oldName: 'user-large'
  }, {
      newName: 'documents',
      oldName: 'bp-decisions'
  }, {
      newName: 'documents',
      oldName: 'bp-default'
  }, {
      newName: 'documents',
      oldName: 'bp-files'
  }, {
      newName: 'documents',
      oldName: 'bp-requirements'
  }, {
      newName: 'documents',
      oldName: 'bp-howto'
  }, {
      newName: 'documents',
      oldName: 'bp-jira'
  }, {
      newName: 'documents',
      oldName: 'bp-meeting'
  }, {
      newName: 'documents',
      oldName: 'bp-retrospective'
  }, {
      newName: 'documents',
      oldName: 'bp-sharedlinks'
  }, {
      newName: 'documents',
      oldName: 'bp-troubleshooting'
  }, {
      newName: 'upload',
      oldName: 'deploy'
  }, {
      newName: 'file',
      oldName: 'page-default'
  }, {
      newName: 'shortcut',
      oldName: 'sidebar-link'
  }, {
      newName: 'shortcut',
      oldName: 'sidebar-link-large'
  }, {
      newName: 'incomplete-build',
      oldName: 'devtools-task-cancelled'
  }, {
      newName: 'plan-disabled',
      oldName: 'devtools-task-disabled'
  }, {
      newName: 'queued-build',
      oldName: 'devtools-task-in-progress'
  }, {
      newName: 'branch',
      oldName: 'devtools-branch'
  }, {
      newName: 'branch',
      oldName: 'devtools-branch-small'
  }, {
      newName: 'commits',
      oldName: 'devtools-commit'
  }, {
      newName: 'create-fork',
      oldName: 'devtools-for'
  }, {
      newName: 'bold',
      oldName: 'editor-bold'
  }, {
      newName: 'italic',
      oldName: 'editor-italic'
  }, {
      newName: 'underline',
      oldName: 'editor-underline'
  }, {
      newName: 'text-color',
      oldName: 'editor-color'
  }, {
      newName: 'left-alignment',
      oldName: 'editor-align-left'
  }, {
      newName: 'right-alignment',
      oldName: 'editor-align-right'
  }, {
      newName: 'center-alignment',
      oldName: 'editor-align-center'
  }, {
      newName: 'indent-left-mall',
      oldName: 'editor-indent'
  }, {
      newName: 'indent-right-mall',
      oldName: 'editor-outdent'
  }, {
      newName: 'number-list-mall',
      oldName: 'editor-list-number'
  }, {
      newName: 'bullet-list-mall',
      oldName: 'editor-list-bullet'
  }, {
      newName: 'mention',
      oldName: 'editor-mention'
  }, {
      newName: 'table-of-contents-mall',
      oldName: 'editor-macro-toc'
  }, {
      newName: 'advanced',
      oldName: 'editor-style'
  }, {
      newName: 'symbol',
      oldName: 'editor-symbol'
  }, {
      newName: 'horizontal-rule',
      oldName: 'editor-hr'
  }, {
      newName: 'page-layout-toggle',
      oldName: 'editor-layout'
  }, {
      newName: 'table',
      oldName: 'editor-table'
  }, {
      newName: 'location',
      oldName: 'nav-children-large'
  }, {
      newName: 'location',
      oldName: 'nav-children'
  }, {
      newName: 'single-column',
      oldName: 'layout-1col-large'
  }, {
      newName: 'two-column',
      oldName: 'layout-2col-large'
  }, {
      newName: 'right-side-bar',
      oldName: 'layout-2col-left-large'
  }, {
      newName: 'left-side-bar',
      oldName: 'layout-2col-right-large'
  }, {
      newName: 'three-column-side-bars',
      oldName: 'layout-3col-center-large'
  }, {
      newName: 'three-column',
      oldName: 'layout-3col-large'
  }, {
      newName: 'heading-column',
      oldName: 'table-header-column'
  }, {
      newName: 'heading-row',
      oldName: 'table-header-row'
  }, {
      newName: 'insert-row-after',
      oldName: 'table-row-down'
  }, {
      newName: 'insert-row-before',
      oldName: 'table-row-up'
  }, {
      newName: 'remove-row',
      oldName: 'table-row-remove'
  }, {
      newName: 'remove-column',
      oldName: 'table-col-remove'
  }, {
      newName: 'insert-column-before',
      oldName: 'table-col-left'
  }, {
      newName: 'insert-column-after',
      oldName: 'table-col-right'
  }, {
      newName: 'remove-table',
      oldName: 'table-remove'
  }, {
      newName: 'merge-table-cells',
      oldName: 'table-merge'
  }, {
      newName: 'split-merged-table-cells',
      oldName: 'table-split'
  }, {
      newName: 'copy-table-row',
      oldName: 'table-copy-row'
  }, {
      newName: 'paste-table-row',
      oldName: 'table-paste-row'
  }, {
      newName: 'cut-table-row',
      oldName: 'table-cut-row'
  }, {
      newName: 'team-calendar',
      oldName: 'teamcals-large'
  }, {
      newName: 'team-calendar',
      oldName: 'teamcals'
  }, {
      newName: 'emoji',
      oldName: 'editor-emoticon'
  }, {
      newName: 'help',
      oldName: 'editor-help'
  }, {
      newName: 'task',
      oldName: 'editor-task'
  }, {
      newName: 'like',
      oldName: 'like-small'
  }, {
      newName: 'submodule',
      oldName: 'devtools-submodule'
  }];

  exports.default = deprecatedIcons;
  module.exports = exports['default'];

  return module.exports;
}).call(this);
// src/js/aui-css-deprecations.js
(typeof window === 'undefined' ? global : window).__48f9de6ee4f409c1b979195c3d533b81 = (function () {
  var module = {
    exports: {}
  };
  var exports = module.exports;

  'use strict';

  var _deprecation = __3632ac12e0e2db0a58ef6348743599e5;

  var _amdify = __fb114d9b531e09c60f5fdf12262b017c;

  var _amdify2 = _interopRequireDefault(_amdify);

  var _deprecatedAdg2Icons = __ac524c2679e70c463a41309e6dacb4bb;

  var _deprecatedAdg2Icons2 = _interopRequireDefault(_deprecatedAdg2Icons);

  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

  (0, _deprecation.css)('.aui-badge', {
      displayName: 'AUI Badges class'
  });
  (0, _deprecation.css)('.aui-dropdown2-trigger.aui-style-dropdown2triggerlegacy1', {
      displayName: 'Dropdown2 legacy trigger'
  });
  (0, _deprecation.css)('.aui-message span.aui-icon', {
      displayName: 'Message icon span'
  });
  (0, _deprecation.css)('.aui-zebra', {
      displayName: 'Zebra table rows'
  });
  (0, _deprecation.css)('.aui-nav-pagination > li.aui-nav-current', {
      alternativeName: 'aui-nav-selected'
  });
  (0, _deprecation.css)('.aui-tabs.vertical-tabs', {
      displayName: 'Vertical tabs'
  });
  (0, _deprecation.css)('form.aui span.content');
  (0, _deprecation.css)(['form.aui .button', 'form.aui .buttons-container'], {
      displayName: 'Unprefixed buttons',
      alternativeName: 'aui-button and aui-buttons'
  });
  (0, _deprecation.css)(['form.aui .icon-date', 'form.aui .icon-range', 'form.aui .icon-help', 'form.aui .icon-required', 'form.aui .icon-inline-help', 'form.aui .icon-users', '.aui-icon-date', '.aui-icon-range', '.aui-icon-help', '.aui-icon-required', '.aui-icon-users', '.aui-icon-inline-help'], {
      displayName: 'Form icons'
  });
  (0, _deprecation.css)(['.aui-icon.icon-move-d', '.aui-icon.icon-move', '.aui-icon.icon-dropdown-d', '.aui-icon.icon-dropdown', '.aui-icon.icon-dropdown-active-d', '.aui-icon.icon-dropdown-active', '.aui-icon.icon-minimize-d', '.aui-icon.icon-minimize', '.aui-icon.icon-maximize-d', '.aui-icon.icon-maximize'], {
      displayName: 'Core icons'
  });
  (0, _deprecation.css)(['.aui-message.error', '.aui-message.warning', '.aui-message.hint', '.aui-message.info', '.aui-message.success'], {
      displayName: 'Unprefixed message types AUI-2150'
  });
  (0, _deprecation.css)(['.aui-dropdown2 .active', '.aui-dropdown2 .checked', '.aui-dropdown2 .disabled', '.aui-dropdown2 .interactive'], {
      displayName: 'Unprefixed dropdown2 css AUI-2150'
  });

  (0, _deprecation.css)(['aui-page-header-marketing', 'aui-page-header-hero'], {
      displayName: 'Marketing style headings'
  });

  // 5.9.0
  // -----

  var fiveNineZero = {
      // Inline Dialog
      'arrow': 'aui-inline-dialog-arrow',
      'contents': 'aui-inline-dialog-contents',

      // Messages
      'error': 'aui-message-error',
      'generic': 'aui-message-generic',
      'hint': 'aui-message-hint',
      'info': 'aui-message-info',
      'success': 'aui-message-success',
      'warning': 'aui-message-warning'
  };
  var name;

  for (name in fiveNineZero) {
      if (Object.hasOwnProperty.call(fiveNineZero, name)) {
          (0, _deprecation.css)(name, {
              alternativeName: fiveNineZero[name],
              removeVersion: '8.0.0',
              sinceVersion: '5.9.0'
          });
      }
  }

  // 6.1.0
  // -----

  (0, _deprecation.css)(['.aui-header-logo-atlassian', '.aui-header-logo-aui', '.aui-header-logo-bamboo', '.aui-header-logo-bitbucket', '.aui-header-logo-stash', '.aui-header-logo-clover', '.aui-header-logo-confluence', '.aui-header-logo-crowd', '.aui-header-logo-crucible', '.aui-header-logo-fecru', '.aui-header-logo-fisheye', '.aui-header-logo-hipchat', '.aui-header-logo-jira', '.aui-header-logo-jira-core', '.aui-header-logo-jira-software', '.aui-header-logo-jira-service-desk', '.aui-header-logo-answer', '.aui-header-logo-community', '.aui-header-logo-developers', '.aui-header-logo-expert', '.aui-header-logo-partner-program', '.aui-header-logo-marketplace', '.aui-header-logo-support', '.aui-header-logo-university', '.aui-header-logo-cloud'], {
      displayName: 'Atlassian Brand Logos'
  });

  // 7.1.0
  // -----

  (0, _deprecation.css)('.aui-badge', {
      displayName: 'AUI Badge CSS class',
      alternativeName: 'aui-badge',
      sinceVersion: '7.1.0',
      extraInfo: 'The badge pattern is best used as a web component instead of a CSS class'
  });

  // 7.5.0
  // -----

  (0, _deprecation.css)(['.aui-iconfont-image-extrasmall'], {
      displayName: 'Special size icon names',
      sinceVersion: '7.5.0',
      extraInfo: 'The only size variant allowed for icon names is `-small`.'
  });

  (0, _deprecation.css)('.aui-icon-dropdown', {
      displayName: 'AUI dropdown icon element',
      alternativeName: '.aui-icon-chevron-down',
      sinceVersion: '7.5.0',
      extraInfo: 'Use of an explicit element for the dropdown icon is part of a ' + 'deprecated markup pattern for dropdowns and should not be used. If you must ' + 'render an explicit icon element for a dropdown trigger, use the new ' + 'alternative class name.'
  });

  // New ADGS names for the old ADG2 icon
  _deprecatedAdg2Icons2.default.forEach(function (_ref) {
      var newName = _ref.newName,
          oldName = _ref.oldName;
      return (0, _deprecation.css)('.aui-iconfont-' + oldName, {
          displayName: 'ADG2 icon',
          alternativeName: '.aui-iconfont-' + newName,
          sinceVersion: '7.5.0',
          removeVersion: '8.0.0',
          extraInfo: 'Use the new ADGS icon CSS class name'
      });
  });

  (0, _amdify2.default)('aui/css-deprecation-warnings');

  return module.exports;
}).call(this);


text:
hiqual
======

Hibernate Query Abstraction Layer

redpajama_set_name: RedPajamaGithub


text:
package org.apache.maven.plugin.internal;

import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.configuration.PlexusConfiguration;

/**
 * Service responsible for validating plugin configuration.
 *
 * @author Slawomir Jaranowski
 */
interface MavenPluginConfigurationValidator
{
    /**
     * Check mojo configuration.
     */
    void validate( MojoDescriptor mojoDescriptor,
                   PlexusConfiguration pomConfiguration,
                   ExpressionEvaluator expressionEvaluator );
}


text:
namespace Microsoft.Azure.Management.Cdn.Models
{
    using Microsoft.Rest;
    using Newtonsoft.Json;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;

    /// <summary>
    /// Defines the parameters for HttpVersion match conditions
    /// </summary>
    public partial class HttpVersionMatchConditionParameters
    {
        /// <summary>
        /// Initializes a new instance of the
        /// HttpVersionMatchConditionParameters class.
        /// </summary>
        public HttpVersionMatchConditionParameters()
        {
            CustomInit();
        }

        /// <summary>
        /// Initializes a new instance of the
        /// HttpVersionMatchConditionParameters class.
        /// </summary>
        /// <param name="matchValues">The match value for the condition of the
        /// delivery rule</param>
        /// <param name="negateCondition">Describes if this is negate condition
        /// or not</param>
        public HttpVersionMatchConditionParameters(IList<string> matchValues, bool? negateCondition = default(bool?))
        {
            NegateCondition = negateCondition;
            MatchValues = matchValues;
            CustomInit();
        }
        /// <summary>
        /// Static constructor for HttpVersionMatchConditionParameters class.
        /// </summary>
        static HttpVersionMatchConditionParameters()
        {
            Odatatype = "#Microsoft.Azure.Cdn.Models.DeliveryRuleHttpVersionConditionParameters";
            OperatorProperty = "Equal";
        }

        /// <summary>
        /// An initialization method that performs custom operations like setting defaults
        /// </summary>
        partial void CustomInit();

        /// <summary>
        /// Gets or sets describes if this is negate condition or not
        /// </summary>
        [JsonProperty(PropertyName = "negateCondition")]
        public bool? NegateCondition { get; set; }

        /// <summary>
        /// Gets or sets the match value for the condition of the delivery rule
        /// </summary>
        [JsonProperty(PropertyName = "matchValues")]
        public IList<string> MatchValues { get; set; }

        /// <summary>
        /// </summary>
        [JsonProperty(PropertyName = "@odata.type")]
        public static string Odatatype { get; private set; }

        /// <summary>
        /// Describes operator to be matched
        /// </summary>
        [JsonProperty(PropertyName = "operator")]
        public static string OperatorProperty { get; private set; }

        /// <summary>
        /// Validate the object.
        /// </summary>
        /// <exception cref="ValidationException">
        /// Thrown if validation fails
        /// </exception>
        public virtual void Validate()
        {
            if (MatchValues == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "MatchValues");
            }
        }
    }
}


text:
#include "session_fixture.h"

#include <libssh2.h>

#include <stdio.h>

/* configured in Dockerfile */
static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "key_dsa";
static const char *KEY_FILE_PUBLIC = "key_dsa.pub";

int test(LIBSSH2_SESSION *session)
{
    int rc;

    const char *userauth_list =
        libssh2_userauth_list(session, USERNAME, strlen(USERNAME));
    if(userauth_list == NULL) {
        print_last_session_error("libssh2_userauth_list");
        return 1;
    }

    if(strstr(userauth_list, "publickey") == NULL) {
        fprintf(stderr, "'publickey' was expected in userauth list: %s\n",
                userauth_list);
        return 1;
    }

    rc = libssh2_userauth_publickey_fromfile_ex(
        session, USERNAME, strlen(USERNAME), KEY_FILE_PUBLIC, KEY_FILE_PRIVATE,
        NULL);
    if(rc != 0) {
        print_last_session_error("libssh2_userauth_publickey_fromfile_ex");
        return 1;
    }

    return 0;
}


text:
ACTIONS_RUNNER_INPUT_NAME=$HOSTNAME
# get regsistration token for this runnner
ACTIONS_RUNNER_INPUT_TOKEN="$(curl -sS --request POST --url "https://api.github.com/orgs/${ORG_NAME}/actions/runners/registration-token" --header "authorization: Bearer ${GITHUB_TOKEN}"  --header 'content-type: application/json' | jq -r .token)"
# Link maven settings
mkdir -p ~/.m2
ln -s /etc/maven-settings/settings.xml ~/.m2/settings.xml
# Initialize gnupg
gpg --batch --allow-secret-key-import --import /etc/gnupg/private.key
gpg --batch --import-ownertrust /etc/gnupg/ownertrust.txt
# configure runner
export RUNNER_ALLOW_RUNASROOT=1
export LANG=C.UTF-8
/runner/config.sh --ephemeral --unattended --replace --work "/tmp" --url "https://github.com/${ORG_NAME}" --token "$ACTIONS_RUNNER_INPUT_TOKEN" --labels "$RUNNER_LABEL"
# start runner
# https://github.com/actions/runner/issues/246#issuecomment-615293718
/runner/bin/runsvc.sh


text:
namespace blink {

namespace {

class TestCancellableTaskFactory final : public CancellableTaskFactory {
public:
    explicit TestCancellableTaskFactory(PassOwnPtr<Closure> closure)
        : CancellableTaskFactory(closure)
    {
    }
};

} // namespace

using CancellableTaskFactoryTest = testing::Test;

TEST_F(CancellableTaskFactoryTest, IsPending_TaskNotCreated)
{
    TestCancellableTaskFactory factory(nullptr);

    EXPECT_FALSE(factory.isPending());
}

TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreated)
{
    TestCancellableTaskFactory factory(nullptr);
    OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate());

    EXPECT_TRUE(factory.isPending());
}

void EmptyFn()
{
}

TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreatedAndRun)
{
    TestCancellableTaskFactory factory(WTF::bind(&EmptyFn));
    {
        OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate());
        task->run();
    }

    EXPECT_FALSE(factory.isPending());
}

TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreatedAndDestroyed)
{
    TestCancellableTaskFactory factory(nullptr);
    delete factory.cancelAndCreate();

    EXPECT_FALSE(factory.isPending());
}

TEST_F(CancellableTaskFactoryTest, IsPending_TaskCreatedAndCancelled)
{
    TestCancellableTaskFactory factory(nullptr);
    OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate());
    factory.cancel();

    EXPECT_FALSE(factory.isPending());
}

class TestClass {
public:
    OwnPtr<CancellableTaskFactory> m_factory;

    TestClass()
        : m_factory(CancellableTaskFactory::create(this, &TestClass::TestFn))
    {
    }

    void TestFn()
    {
        EXPECT_FALSE(m_factory->isPending());
    }
};

TEST_F(CancellableTaskFactoryTest, IsPending_InCallback)
{
    TestClass testClass;
    OwnPtr<WebTaskRunner::Task> task = adoptPtr(testClass.m_factory->cancelAndCreate());
    task->run();
}

void AddOne(int* ptr)
{
    *ptr += 1;
}

TEST_F(CancellableTaskFactoryTest, Run_ClosureIsExecuted)
{
    int executionCount = 0;
    TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount));
    OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate());
    task->run();

    EXPECT_EQ(1, executionCount);
}

TEST_F(CancellableTaskFactoryTest, Run_ClosureIsExecutedOnlyOnce)
{
    int executionCount = 0;
    TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount));
    OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate());
    task->run();
    task->run();
    task->run();
    task->run();

    EXPECT_EQ(1, executionCount);
}

TEST_F(CancellableTaskFactoryTest, Run_FactoryDestructionPreventsExecution)
{
    int executionCount = 0;
    OwnPtr<WebTaskRunner::Task> task;
    {
        TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount));
        task = adoptPtr(factory.cancelAndCreate());
    }
    task->run();

    EXPECT_EQ(0, executionCount);
}

TEST_F(CancellableTaskFactoryTest, Run_TasksInSequence)
{
    int executionCount = 0;
    TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount));

    OwnPtr<WebTaskRunner::Task> taskA = adoptPtr(factory.cancelAndCreate());
    taskA->run();
    EXPECT_EQ(1, executionCount);

    OwnPtr<WebTaskRunner::Task> taskB = adoptPtr(factory.cancelAndCreate());
    taskB->run();
    EXPECT_EQ(2, executionCount);

    OwnPtr<WebTaskRunner::Task> taskC = adoptPtr(factory.cancelAndCreate());
    taskC->run();
    EXPECT_EQ(3, executionCount);
}

TEST_F(CancellableTaskFactoryTest, Cancel)
{
    int executionCount = 0;
    TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount));
    OwnPtr<WebTaskRunner::Task> task = adoptPtr(factory.cancelAndCreate());
    factory.cancel();
    task->run();

    EXPECT_EQ(0, executionCount);
}

TEST_F(CancellableTaskFactoryTest, CreatingANewTaskCancelsPreviousOnes)
{
    int executionCount = 0;
    TestCancellableTaskFactory factory(WTF::bind(&AddOne, &executionCount));

    OwnPtr<WebTaskRunner::Task> taskA = adoptPtr(factory.cancelAndCreate());
    OwnPtr<WebTaskRunner::Task> taskB = adoptPtr(factory.cancelAndCreate());

    taskA->run();
    EXPECT_EQ(0, executionCount);

    taskB->run();
    EXPECT_EQ(1, executionCount);
}

} // namespace blink


text:
function setupTests(tester, plugin) {
  tester.addAsyncTest('TestCreate', function(status) {
    var messageListener = status.wrap(function(message) {
      status.log('Received message: ' + message.data);
      plugin.removeEventListener('message', messageListener, false);
      status.assertEqual(message.data, 'TestCreate:PASSED');
      status.pass();
    });
    plugin.addEventListener("message", messageListener, false);
    plugin.postMessage("TestCreate");
  });
  tester.addAsyncTest('TestIsFileSystem', function(status) {
    var messageListener = status.wrap(function(message) {
      status.log('Received message: ' + message.data);
      plugin.removeEventListener('message', messageListener, false);
      status.assertEqual(message.data, 'TestIsFileSystem:PASSED');
      status.pass();
    });
    plugin.addEventListener("message", messageListener, false);
    plugin.postMessage("TestIsFileSystem");
  });
  tester.addAsyncTest('TestGetType', function(status) {
    var messageListener = status.wrap(function(message) {
      status.log('Received message: ' + message.data);
      plugin.removeEventListener('message', messageListener, false);
      status.assertEqual(message.data, 'TestGetType:PASSED');
      status.pass();
    });
    plugin.addEventListener("message", messageListener, false);
    plugin.postMessage("TestGetType");
  });
  tester.addAsyncTest('TestOpen', function(status) {
    var gotPassed = false;
    var messageListener = status.wrap(function(message) {
      status.log('Received message: ' + message.data);
      plugin.removeEventListener('message', messageListener, false);
      if (!gotPassed) {
        status.assertEqual(message.data, 'TestOpen:PASSED');
        gotPassed = true;
        plugin.addEventListener("message", messageListener, false);
      } else {
        status.assertEqual(message.data, 'OpenCallback');
        status.pass();
      }
    });
    plugin.addEventListener("message", messageListener, false);
    plugin.postMessage("TestOpen");
  });
}


text:
/*.container_userData{
  margin: 15% 0%;
}*/
.container_userData strong{
  display: block;
  text-align: center;
  margin-bottom: 5%;
}
.container_userData .containder_userImg{
  width: 50%;
  display: inline-block;
}
.container_userData .containder_userImg img{
  border-radius: 30%;
}
.perfil .panel-dark > .panel-heading{
  background-color: black;
  border-color: black;
  color: white;
}
.perfil{
  margin-top: 5%;
}

.sub-menu-perfil li{

  display: inline-block;
}
hr.hrPerfil{

  width: 100px;

  border-top: solid #a8a2ae 2px;
}

div.title-car{

  color:#fff !important;
  background-color: #414042 !important;

}


text:
package com.example.msf.msf.API.Models;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;

/**
 * Created by Thandile on 2016/07/27.
 */
public class Users implements Serializable {

    @SerializedName("id")
    private int id;
    @SerializedName("username")
    private String username;
    @SerializedName("message")
    private String message;
    @SerializedName("response_code")
    private int responseCode;

    public Users(int id, String username, String message, int responseCode){
        this.id = id;
        this.username = username;
        this.message = message;
        this.responseCode = responseCode;
    }

    public Users(int id, String username){
        this.id = id;
        this.username = username;
    }

    public Users(){

    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getResponseCode() {
        return responseCode;
    }

    public void setResponseCode(int responseCode) {
        this.responseCode = responseCode;
    }

}


text:
package net.hebrewcalendar.impl;

import net.hebrewcalendar.HCalendarType;
import net.hebrewcalendar.HDate;

import org.junit.Test;
import static org.junit.Assert.*;

public class JulianCalendarTest
{
    private static final AbstractCalendar cal = JulianCalendar.INSTANCE;

    @Test
    public void addDays()
    {
        HDate d0 = cal.fromYMD(2000,1,1);
        assertEquals(new HDateImpl(cal, 2000, 12, 31), d0.addDays(365));
        assertEquals(new HDateImpl(cal, 2001, 1, 1), d0.addDays(366));
    }

    @Test
    public void subtractDays()
    {
        HDateImpl d0 = new HDateImpl(cal, 2000,1,2);
        HDateImpl d1 = new HDateImpl(cal, 2001,1,1);
        assertEquals(d0, d1.subtractDays(365));
    }

    @Test
    public void getAbsDay()
    {
        HDateImpl d0 = new HDateImpl(cal, 1,1,1);
        assertEquals(cal.getStart()+1, d0.absDay());

        HDateImpl d20170101 = new HDateImpl(cal, 2017,1,1);
        assertEquals(cal.getStart()+2016*365+504+1, d20170101.absDay());

        HDateImpl d20170701 = new HDateImpl(cal, 2017,7,1);
        assertEquals(cal.getStart()+2016*365+504+31+28+31+30+31+30+1, d20170701.absDay());

        HDateImpl greg = new HDateImpl(GregorianCalendar.INSTANCE, 2017,1,1);
        assertEquals(13, d20170101.absDay()-greg.absDay());
    }

    @Test
    public void gregorianVsJulian()
    {
        HDateImpl j0 = new HDateImpl(JulianCalendar.INSTANCE, 1,1,3);
        HDateImpl g0 = new HDateImpl(GregorianCalendar.INSTANCE, 1,1,1);
        assertEquals(j0.absDay(), g0.absDay());

        HDateImpl j1 = new HDateImpl(JulianCalendar.INSTANCE, 2,1,3);
        HDateImpl g1 = new HDateImpl(GregorianCalendar.INSTANCE, 2,1,1);
        assertEquals(j1.absDay(), g1.absDay());

        HDateImpl j101 = new HDateImpl(JulianCalendar.INSTANCE, 101,1,2);
        HDateImpl g101 = new HDateImpl(GregorianCalendar.INSTANCE, 101,1,1);
        assertEquals(j101.absDay(), g101.absDay());

        HDateImpl j101a = new HDateImpl(JulianCalendar.INSTANCE, 100,2,29);
        HDateImpl g101a = new HDateImpl(GregorianCalendar.INSTANCE, 100,2,27);
        assertEquals(j101a.absDay(), g101a.absDay());

        HDateImpl j101b = new HDateImpl(JulianCalendar.INSTANCE, 100,3,1);
        HDateImpl g101b = new HDateImpl(GregorianCalendar.INSTANCE, 100,2,28);
        assertEquals(j101b.absDay(), g101b.absDay());

        HDateImpl j101c = new HDateImpl(JulianCalendar.INSTANCE, 100,3,2);
        HDateImpl g101c = new HDateImpl(GregorianCalendar.INSTANCE, 100,3,1);
        assertEquals(j101c.absDay(), g101c.absDay());

        HDateImpl j1900a = new HDateImpl(JulianCalendar.INSTANCE, 1900,2,17);
        HDateImpl g1900a = new HDateImpl(GregorianCalendar.INSTANCE, 1900,3,1);
        assertEquals(j1900a.absDay(), g1900a.absDay());

        HDateImpl j1900b = new HDateImpl(JulianCalendar.INSTANCE, 1900,2,29);
        HDateImpl g1900b = new HDateImpl(GregorianCalendar.INSTANCE, 1900,3,13);
        assertEquals(j1900b.absDay(), g1900b.absDay());

        HDateImpl j1900c = new HDateImpl(JulianCalendar.INSTANCE, 1900,3,1);
        HDateImpl g1900c = new HDateImpl(GregorianCalendar.INSTANCE, 1900,3,14);
        assertEquals(j1900c.absDay(), g1900c.absDay());

        HDateImpl j20170709 = new HDateImpl(JulianCalendar.INSTANCE, 2017,7, 9);
        HDateImpl g20170722 = new HDateImpl(GregorianCalendar.INSTANCE, 2017,7,22);
        assertEquals(j20170709.absDay(), g20170722.absDay());

    }
    @Test
    public void getCalendarType()
    {
        HDateImpl d0 = new HDateImpl(cal, 2017,7,31);

        assertEquals(HCalendarType.JULIAN, d0.getCalendarType());
    }

    @Test
    public void isValid()
    {
        assertTrue(new HDateImpl(cal,1997,12, 31).isValid());
        try {
            new HDateImpl(cal,1997,12, 32);
            fail("Illegal date created, no exception thrown");
        } catch(IllegalStateException ise) {}

        try {
            new HDateImpl(cal,1997,0, 3);
            fail("Illegal date created, no exception thrown");
        } catch(IllegalStateException ise) {}

        assertTrue(new HDateImpl(cal,1996,2, 29).isValid());
        assertTrue(new HDateImpl(cal,2000,2, 29).isValid());
        assertTrue(new HDateImpl(cal,1900,2, 29).isValid());

        try {
            new HDateImpl(cal,2000,2, 30);
            fail("Illegal date 2000-02-30 created, no exception thrown");
        } catch(IllegalStateException ise) {}
    }

    @Test
    public void getDayOfWeek()
    {
        HDateImpl d0 = new HDateImpl(cal, 1,1,3);
        assertEquals(2, d0.getDayOfWeek());

        HDateImpl d1 = new HDateImpl(cal, 2,1,3);
        assertEquals(3, d1.getDayOfWeek());

        HDateImpl d2 = new HDateImpl(cal, 2017,7,9);
        assertEquals(7, d2.getDayOfWeek());

    }

    @Test
    public void testIsLeap()
    {
        assertTrue(cal.isLeap(100));
        assertFalse(cal.isLeap(1011));
        assertTrue(cal.isLeap(2000));
        assertTrue(cal.isLeap(2004));
        assertTrue(cal.isLeap(1900));
        assertFalse(cal.isLeap(1));
    }

    @Test
    public void testMonthLength()
    {
        assertEquals(31, cal.monthLength(2010, 7));
        assertEquals(31, cal.monthLength(2009, 12));
        assertEquals(31, cal.monthLength(2010, 1));
        assertEquals(31, cal.monthLength(2010, 8));
        assertEquals(30, cal.monthLength(2010, 9));
        assertEquals(30, cal.monthLength(2010, 11));
        assertEquals(28, cal.monthLength(2010, 2));
        assertEquals(28, cal.monthLength(2011, 2));
        assertEquals(29, cal.monthLength(1900, 2));
        assertEquals(29, cal.monthLength(2000, 2));
        assertEquals(29, cal.monthLength(2004, 2));
    }

    @Test
    public void stringRepresentation()
    {
        assertEquals("0001-01-01J", cal.fromYMD(1,1,1).toString());
        assertEquals("2017-07-09J", cal.fromYMD(2017,7,9).toString());
        assertEquals("1812-11-12J", cal.fromYMD(1812,11,12).toString());
    }

}


text:
using System;

namespace Z80lib.Disassembler
{
    internal partial class Z80Disassembler
    {
        protected override void ex_de_hl()
        {
            vRecord.Set(MnemonicZ80.ex, Operand.de, OperandType.RegisterPair, Operand.hl, OperandType.RegisterPair);
            vRecord.Set8080(Mnemonic8080.xchg);
        }

        protected override void ex_xspx_hl()
        {
            vRecord.Set(MnemonicZ80.ex, Operand.sp, OperandType.RegisterPairPointer, Operand.hl, OperandType.RegisterPair);
            vRecord.Set8080(Mnemonic8080.xthl);
        }

        protected override void ex_xspx_ix()
        {
            vRecord.Set(MnemonicZ80.ex, Operand.sp, OperandType.RegisterPairPointer, Operand.ix, OperandType.RegisterPair);
        }

        protected override void ex_xspx_iy()
        {
            vRecord.Set(MnemonicZ80.ex, Operand.sp, OperandType.RegisterPairPointer, Operand.iy, OperandType.RegisterPair);
        }

        protected override void ex_af_af()
        {
            vRecord.Set(MnemonicZ80.ex, Operand.af, OperandType.RegisterPair, Operand.af, OperandType.AltRegisterPair);
        }

        protected override void exx()
        {
            vRecord.Set(MnemonicZ80.exx);
        }

        protected override void lddr()
        {
            vRecord.Set(MnemonicZ80.lddr);
        }

        protected override void ldir()
        {
            vRecord.Set(MnemonicZ80.ldir);
        }

        protected override void ldd()
        {
            vRecord.Set(MnemonicZ80.ldd);
        }

        protected override void ldi()
        {
            vRecord.Set(MnemonicZ80.ldi);
        }

        protected override void cpd()
        {
            vRecord.Set(MnemonicZ80.cpd);
        }

        protected override void cpdr()
        {
            vRecord.Set(MnemonicZ80.cpdr);
        }

        protected override void cpi()
        {
            vRecord.Set(MnemonicZ80.cpi);
        }

        protected override void cpir()
        {
            vRecord.Set(MnemonicZ80.cpir);
        }

    }

}


text:
package isse.mbr.integration;

import java.io.File;
import java.io.IOException;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import isse.mbr.parsing.MiniBrassCompiler;
import isse.mbr.parsing.MiniBrassParseException;
import isse.mbr.tools.MiniZincLauncher;

/**
 * This test case uses probabilistic cost function networks
 * and pure MiniZinc optimization
 * @author Alexander Schiendorfer
 *
 */
public class ProbabilisticCostFunctionNetwork {

	String minibrassModel = "test-models/testProbCfn.mbr";
	String minibrassCompiled = "test-models/testProbCfn_o.mzn";
	String minizincModel = "test-models/testProbCfn.mzn";
	private MiniBrassCompiler compiler;
	private MiniZincLauncher launcher;

	@Before
	public void setUp() throws Exception {
		compiler = new MiniBrassCompiler(true);
		compiler.setMinizincOnly(true);
		launcher = new MiniZincLauncher();
		launcher.setMinizincGlobals("jacop");
		launcher.setFlatzincExecutable("fzn-jacop");
	}

	@Test

	/**
	 * For, we only test correct MiniBrass compilation as the solvers do not work well with floats
	 * @throws IOException
	 * @throws MiniBrassParseException
	 */
	public void test() throws IOException, MiniBrassParseException {
		// 1. compile minibrass file
		File output = new File(minibrassCompiled);

		compiler.compile(new File(minibrassModel), output);
		Assert.assertTrue(output.exists());

		// 2. execute minisearch
		// Does not work due to float stuff

//		BasicTestListener listener = new BasicTestListener();
//		launcher.addMiniZincResultListener(listener);
//		//launcher.runMiniSearchModel(new File(minizincModel), null, 60);
//		launcher.runMiniZincModel(new File(minizincModel), null, 60);
//
//		// 3. check solution
//		Assert.assertTrue(listener.isSolved());
//		Assert.assertTrue(listener.isOptimal());
//
//		Assert.assertEquals("1", listener.getLastSolution().get("x"));
//		Assert.assertEquals("2", listener.getLastSolution().get("y"));
//		Assert.assertEquals("1", listener.getLastSolution().get("z"));
//
//		// for the objective, we need to find out the variable name
//		// instance was "cr1"
//		String obj = "topLevelObjective";
//		Assert.assertEquals("1", listener.getObjectives().get(obj));
	}

}


text:
require 'spec_helper'

describe "With the list of available filters" do

  attr_reader :blog, :whiteboard
  before(:each) do
    @blog = build_stubbed(:blog)
    @filters = TextFilter.available_filters
    @whiteboard = Hash.new
  end

  describe "#available_filters" do
    subject { @filters }
    it { should include(Typo::Textfilter::Markdown) }
    it { should include(Typo::Textfilter::Smartypants) }
    it { should include(Typo::Textfilter::Htmlfilter) }
    it { should include(Typo::Textfilter::Textile) }
    it { should include(Typo::Textfilter::Flickr) }
    it { should include(Typo::Textfilter::Code) }
    it { should include(Typo::Textfilter::Lightbox) }
    it { should_not include(TextFilterPlugin::Markup) }
    it { should_not include(TextFilterPlugin::Macro) }
  end

  describe "#macro_filters" do
    subject { TextFilter.macro_filters }
    it { should_not include(Typo::Textfilter::Markdown) }
    it { should_not include(Typo::Textfilter::Smartypants) }
    it { should_not include(Typo::Textfilter::Htmlfilter) }
    it { should_not include(Typo::Textfilter::Textile) }
    it { should include(Typo::Textfilter::Flickr) }
    it { should include(Typo::Textfilter::Code) }
    it { should include(Typo::Textfilter::Lightbox) }
    it { should_not include(TextFilterPlugin::Markup) }
    it { should_not include(TextFilterPlugin::Macro) }
  end

  describe "#filter_text" do

    def filter_text(text, filters, filterparams={})
      TextFilter.filter_text(blog, text, self, filters, filterparams)
    end

    it "unknown" do
      text = filter_text('*foo*',[:unknowndoesnotexist])
      text.should == '*foo*'
    end

    it "smartypants" do
      build_stubbed(:smartypants)
      text = filter_text('"foo"',[:smartypants])
      text.should == '"foo"'
    end

    it "markdown" do
      build_stubbed(:markdown)
      text = filter_text('*foo*', [:markdown])
      assert_equal '
foo
', text

      text = filter_text("foo\n\nbar",[:markdown])
      assert_equal "
foo
\n\n
bar
", text
    end

    it "filterchain" do
      build_stubbed(:markdown)
      build_stubbed(:smartypants)
      assert_equal '
“foo”
',
      filter_text('*"foo"*',[:markdown,:smartypants])

      assert_equal '
“foo”
',
      filter_text('*"foo"*',[:doesntexist1,:markdown,"doesn't exist 2",:smartypants,:nopenotmeeither])
    end

    describe "specific typo tags" do

      describe "flickr" do

        it "should show with default settings" do
          assert_equal "

This is Matz, Ruby's creator

",
            filter_text('<typo:flickr img="31366117" size="Square" style="float:left"/>',
                        [:macropre,:macropost],
                        {'flickr-user' => 'scott@sigkill.org'})
        end

        it "should use default image size" do
          assert_equal "

This is Matz, Ruby's creator

",
            filter_text('<typo:flickr img="31366117"/>',
                        [:macropre,:macropost],
                        {'flickr-user' => 'scott@sigkill.org'})
        end

        it "should use caption" do
          assert_equal "

",
            filter_text('<typo:flickr img="31366117" caption=""/>',
                        [:macropre,:macropost],
                        {'flickr-user' => 'scott@sigkill.org'})
        end

        it "broken_flickr_link" do
          assert_equal %{
\`notaflickrid\' could not be displayed because:
Photo not found
},
            filter_text('<typo:flickr img="notaflickrid" />',
                        [:macropre, :macropost],
                        { 'flickr-user' => 'scott@sigkill.org' })
        end
      end

    end #flickr

    describe 'code textfilter' do
      describe 'single line' do
        it 'should made nothin if no args' do
          filter_text('<typo:code>foo-code</typo:code>', [:macropre,:macropost]).should == %{

<notextile>foo-code</notextile>

}
        end

        it 'should parse ruby lang' do
          filter_text('<typo:code lang="ruby">foo-code</typo:code>', [:macropre,:macropost]).should == %{

<notextile>foo-code</notextile>

}
        end

        it 'should parse ruby and xml in same sentence but not in same place' do
          filter_text('<typo:code lang="ruby">foo-code</typo:code> blah blah <typo:code lang="xml">zzz</typo:code>',[:macropre,:macropost]).should == %{

<notextile>foo-code</notextile>

 blah blah

<notextile>zzz</notextile>

}
        end

      end
      describe 'multiline' do
        it 'should render ruby' do
          filter_text(%{
<typo:code lang="ruby">
class Foo
  def bar
    @a = "zzz"
  end
end
</typo:code>
          },[:macropre,:macropost]).should == %{

<notextile>class Foo
  def bar
    @a = "zzz"
  end
end</notextile>

          }
        end
      end #multiline
    end #code textfilter

    it "test_code_plus_markup_chain" do
      build_stubbed :textile
      build_stubbed :markdown

      text = <<-EOF
*header text here*

<typo:code lang="ruby">
class test
  def method
    "foo"
  end
end
</typo:code>

_footer text here_

      EOF

      expects_markdown = <<-EOF

header text here

class test
  def method
    "foo"
  end
end

footer text here

      EOF

      expects_textile = <<-EOF

header text here
\n

class test\n  def method\n    "foo"\n  end\nend

\n
footer text here

      EOF

      assert_equal expects_markdown.strip, TextFilter.filter_text_by_name(blog, text, 'markdown')
      assert_equal expects_textile.strip, TextFilter.filter_text_by_name(blog, text, 'textile')
    end

    context "lightbox" do
      it "should work" do
        assert_equal "
This is Matz, Ruby's creator
",
          filter_text('<typo:lightbox img="31366117" thumbsize="Thumbnail" displaysize="Large" style="float:left"/>',
                      [:macropre,:macropost],
                      {})
      end

      it "shoudl use default thumb image size" do
        assert_equal "
This is Matz, Ruby's creator
",
          filter_text('<typo:lightbox img="31366117" displaysize="Large"/>',
                      [:macropre,:macropost],
                      {})
      end

      it "should use default display image size" do
        assert_equal "
This is Matz, Ruby's creator
",
          filter_text('<typo:lightbox img="31366117"/>',
                      [:macropre,:macropost],
                      {})
      end

      it "should work with caption" do
        assert_equal "",
          filter_text('<typo:lightbox img="31366117" caption=""/>',
                      [:macropre,:macropost],
                      {})
      end
    end

    describe "combining a post-macro" do
      describe "with markdown" do
        it "correctly interprets the macro" do
          result = filter_text('<typo:flickr img="31366117" size="Square" style="float:left"/>',
                               [:macropre, :markdown, :macropost])
          result.should =~ %r{

This is Matz, Ruby's creator

}
        end
      end

      describe "with markdown" do
        it "correctly interprets the macro" do
          result = filter_text('<typo:flickr img="31366117" size="Square" style="float:left"/>',
                               [:macropre, :textile, :macropost])
          result.should == "

This is Matz, Ruby's creator

"
        end
      end
    end

  end # #filter_text

  it "#filter text by name" do
    t = build_stubbed('markdown smartypants')
    result = TextFilter.filter_text_by_name(blog, '*"foo"*', 'markdown smartypants')
    result.should == '
“foo”
'
  end

end


text:
var crypto = require('crypto')
var resolve = require('path').resolve

var lockfile = require('lockfile')
var log = require('npmlog')

var npm = require('../npm.js')
var correctMkdir = require('../utils/correct-mkdir.js')

var installLocks = {}

function lockFileName (base, name) {
  var c = name.replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '')
  var p = resolve(base, name)
  var h = crypto.createHash('sha1').update(p).digest('hex')
  var l = resolve(npm.cache, '_locks')

  return resolve(l, c.substr(0, 24) + '-' + h.substr(0, 16) + '.lock')
}

function lock (base, name, cb) {
  var lockDir = resolve(npm.cache, '_locks')
  correctMkdir(lockDir, function (er) {
    if (er) return cb(er)

    var opts = {
      stale: npm.config.get('cache-lock-stale'),
      retries: npm.config.get('cache-lock-retries'),
      wait: npm.config.get('cache-lock-wait')
    }
    var lf = lockFileName(base, name)
    lockfile.lock(lf, opts, function (er) {
      if (er) log.warn('locking', lf, 'failed', er)

      if (!er) {
        log.verbose('lock', 'using', lf, 'for', resolve(base, name))
        installLocks[lf] = true
      }

      cb(er)
    })
  })
}

function unlock (base, name, cb) {
  var lf = lockFileName(base, name)
  var locked = installLocks[lf]
  if (locked === false) {
    return process.nextTick(cb)
  } else if (locked === true) {
    lockfile.unlock(lf, function (er) {
      if (er) {
        log.warn('unlocking', lf, 'failed', er)
      } else {
        installLocks[lf] = false
        log.verbose('unlock', 'done using', lf, 'for', resolve(base, name))
      }

      cb(er)
    })
  } else {
    var notLocked = new Error(
      'Attempt to unlock ' + resolve(base, name) + ", which hasn't been locked"
    )
    notLocked.code = 'ENOTLOCKED'
    throw notLocked
  }
}

module.exports = {
  lock: lock,
  unlock: unlock
}


text:
__author__ = 'Brian Bradley'
__version__ = '2.0.1'

from pisoc import *
from time import sleep

class CapSense(object):
    """
    :Class:

        Provides functionality for use of CapSense buttons on the PiSoC

    :Example:

        Define a CapSense object in the following way::

            >>> button = CapSense(0)

    |

    """
    def __init__(self, pin, threshold = 6):
        """
        :Method:

            __init__

        :Description:

            Initializes a Capsense object for use as a touch sensor

        :param pin: The capsense pin number. pin n directly corresponds to the pin which is assigned to Capsense_BTN_N in the pisoc firmware

            * V2.0 of the firmware uses 8 CapSense buttons, so valid arguments are *0* - *7*
            * pins *0-6* exist on Port 4 pins 0-6, respectively. pin 7 exists on P0[4]

        :type pin: int

        :param threshold: Optional parameter. The number of counts, between 0 and 255, that any touch reading must exceed above the calculated baseline for a touch to be processed.

            * By default this value is 6. This tends to be sufficient for most use cases.
            * If the sensor used is hard to characterize, a higher threshold may be needed for fewer errors.
            * A lower threshold will give some proximity detection

        :type threshold: int

        :returns:

            None

        .. note::

            **threshold** is only needed for :meth:`is_touched` (the suggested reading method).
            :meth:`Read` is only valid when SmartSense is enabled in firmware, which by default it is not.

        """
        if PiSoC.CAPSENSE_SENSOR_NUM is 0:
            raise ValueError('Error: No CapSense pins found. Verify your schematic on the PiSoC is correct, or try resetting the PiSoC and trying again.')
        elif pin not in range(PiSoC.CAPSENSE_SENSOR_NUM):
            raise ValueError('Invalid CapSense sensor number chosen: Valid range is between 0 and %d'%(PiSoC.CAPSENSE_SENSOR_NUM - 1))
        else:
            self.pin = pin
            self.address = PiSoC.CAPSENSE_REGISTER
        self.threshold = threshold

        self.__running = False

    def Start(self):
        """
        :Method:

            Start

        :Description: Initializes registers and enables active mode power template bits of the subcomponents used within CapSense. Also establishes a CapSense baseline, which is used as a comparison value in :meth:`~is_touched`

        :returns:

            None

        .. note::

            If the sensor is touched when this method is called, the sensor will be calibrated to a touched value. This may or may not be desireable based on application.

        """
        cmd = 0x00
        self.baseline = PiSoC.commChannel.receive_data(self.address,cmd, self.pin, self.threshold, Hformat = [])
        logging.debug("CapSense sensor %d calibrated with baseline %d"%(self.pin, self.baseline))

        self.__running = True

    def is_running(self):
        """
        :Method:

            is_running

        :Description:

            Checks to see if the CapSense component and all subcomponents are currently operational

        :returns:

            A boolean variable which evaluates to *True* if CapSense is active, or *False* if it is not
        """
        return self.__running

    def Stop(self):
        """
        :Method:

            Stop

        :Description:

            Disables component interrupts, and calls CapSense_ClearSensors() to reset all sensors to an inactive state

        :returns:

            None

        .. warning::

            This will affect functionality of *all* CapSense sensors, use it only if this is intended.
        """
        cmd = 0x01
        PiSoC.commChannel.receive_data(self.address,cmd)
        self.__running = False

    def Sleep(self):
        """
        :Method:

            Sleep

        :Description:

            Prepares the component for the device entering a low-power mode. Disables Active mode power template bits of the sub components used within CapSense, saves nonretention registers, and resets all sensors to
            an inactive state.

        :returns:

            None

        .. warning::

            This will affect functionality of *all* CapSense sensors, use it only if this is intended.
        """
        cmd = 0x02
        PiSoC.commChannel.receive_data(self.address,cmd)

    def Wakeup(self):
        """
        :Method:

            Wakeup

        :Description:

            Restores CapSense configuration and nonretention register values after the device wake from a low power mode sleep mode

        :returns:

            None

        .. warning::

            This will affect functionality of *all* CapSense sensors, use it only if this is intended.
        """
        cmd = 0x03
        PiSoC.commChannel.receive_data(self.address,cmd)

    def Read(self):
        """
        :Method:

            Read

        :Description:

            Determines the state of the capsense button, as determined by PSoC SmartSensing. This will need to be calibrated in PSoC Creator for optimal results.
            Use :meth:`is_touched` for more general application

        :returns:

            A boolean (True or False) value when the output is determined to be touched or not touched, respectively.
        """
        cmd = 0x18
        val = self.pin
        return bool(PiSoC.commChannel.receive_data(self.address,cmd, val, Hformat = [], delay = 0.03))

    def ReadRaw(self):
        """
        :Method:

            ReadRaw

        :Description:

            Gives an 8-bit raw value from the capsense raw data array, which represents capacitance detection and is thus correlated with touch data.
            Use this to calibrate touch buttons by deciding an approriate *threshold* as described in :meth:`~__init__`

        :returns:

            The raw value on the capsense button, which can be used to characterize the nature of a touch event
        """
        cmd = 0x0F
        val = self.pin
        return PiSoC.commChannel.receive_data(self.address, cmd, val, Hformat = [])

    def is_touched(self, bitmap = None):
        """
        :Method:

            is_touched

        :Description:

            Uses the calibrated baseline and provided threshold value to determine if the requested CapSense button is being touched. This is the suggested method for touch detection.

        :param bitmap:

            An optional input, which when provided will be used to decide if the sensor has been touched instead of asking the PiSoC.
            It is a hexadecimal value which represents the state of all capsense sensors, as returned by :meth:`get_register`.
            Providing a bitmap to this function simply abstracts the bit manipulation required to decode that result.

        :type bitmap: int

        :returns:

            A boolean (True or False) value when the output is determined to be touched or not touched, respectively
        """

        if bitmap is None:
            cmd = 0xFD
            result = PiSoC.commChannel.receive_data(self.address, cmd, self.pin, Hformat = [])
        else:
            result = (bitmap>>self.pin)&0x01

        return result

    def get_register(self):#move this to a PiSoC method? todo
        """
        :Method:

            get_register

        :Description:

            Calculates a touched event for all enabled CapSense sensors, and returns the result as a single 8-bit hexadecimal value containing the state of each sensor.

        :returns:

            8-bit hexadceimal value where the binary representation contains the state information for each pin.
            The n-th bit of this value will be *1* if pin n is touched, or *0* if pin n is not touched. Bit-0 is the LSB of the returned result.
        """
        cmd = 0xFF
        return PiSoC.commChannel.receive_data(self.address, cmd, self.pin, Hformat = [])

class AnalogPin(object):
    """
    :Class:

        Provides functionality for use of the general purpose analog input pins exposed on the PiSoC

    :Example:

        Define an AnalogPin object in the following way::

            >>> My_analog_pin = AnalogPin(pin)

    |

    """
    def __init__(self, pin):
        """
        :Method:

            __init__

        :Description:

            Constructs and initializes an AnalogPin object for general purpose analog input

        :param pin: The analog pin number - This directly corresponds to the pins connected to your sequenced SAR ADC, where 0 is the top pin

            * V2.0 of the PiSoC firmware has *10* analog pins available, and so valid arguments are *0*-*9*.
            * The default version assigns Port 3 pins *0*-*7* as AnalogPins *0*-*7*, respectively. pin *8* and *9* are on P0[5] and P0[6], respectively.

        :type pin: int

        :returns:

            None
        """

        if int(pin) not in range(PiSoC.ANALOG_IN_NUM):
            raise ValueError('Invalid Pin for Analog input specified. Only %d analog inputs available.' %PiSoC.ANALOG_IN_NUM)
        else:
            self.pin = pin

        self.address = PiSoC.ANALOG_IN_REGISTER
        self.__resolution = 12 #this needs to be updated so that it is read in during init...
        self.__max_counts = pow(2,self.__resolution)
        self.__offset = 0

    def Read(self):
        """
        :Method:

            Read

        :Description:

            Reads the calculated digital value after analog to digital conversion

        :returns: Digital value after an A/D conversion

            * The size of this value and the voltage which is represented by it will depend on the resolution set (or not set) by :meth:`~SetResolution`
            * Default resolution is 12 (:meth:`~SetResolution` never called), so :math:`Voltage = 5.0*\\frac{counts}{2^{12} - 1}`

        :rtype: int

        """
        cmd = 0x00
        counts = int(PiSoC.commChannel.receive_data(self.address, cmd, self.pin))
        return counts
    def ReadVolts(self, precision = 2, counts = None):
        """
        :Method:

            ReadVolts

        :Description:

            Reads the specified analog pin and converts that digital reading to a voltage in Volts, or converts a given count value to Volts if one is provided

        :param precision:

            Optional parameter. The number of decimal points to be included in the returned result. Defaults to 2.

        :type precision: int

        :param counts:

            Optional parameter. If given, the provided count value will be converted to a voltage
            according to :math:`Voltage = 5.0*\\frac{counts - offset}{2^{n} - 1}`, where n is the ADC resolution in bits
            and *offset* is optionally set with :meth:`SetOffset` (defaults to *0* otherwise)

        :type counts: int

        :returns:

            A floating point number representative of an analog voltage taken with respect to PiSoC ground.
        """
        cmd = 0x01
        if counts is None:
            return round((float(((PiSoC.commChannel.receive_data(self.address,cmd, self.pin))/1000000.0))), precision)
        else:
            return round(float(float(counts - self.__offset)/self.__max_counts)*5.0, precision)

    def SetOffset(self,counts):
        """
        :Method:

            SetOffset

        :Description:

            Sets an offset on the ADC which is used for the voltage conversion. It will subtract the given offset before making the conversion

        :param counts:

            Digital value which will be subtracted from any digital result before its conversion to a voltage takes place

        :type counts: int

        :returns:

            None
        """
        cmd = 0x02
        self.__offset = counts
        PiSoC.commChannel.send_data(self.address, cmd, counts)

    def SetResolution(self, resolution):
        """
        :Method:

            SetResolution

        :Description:

            This function sets the resolution of ALL AnalogPin objects. The resolution is defaulted to 12, so this method is only needed if this needs to be changed

        :param resolution:

            An integer value, in bits, that represents the new resolution of the SAR ADC. Valid arguments are *8*, *10*, and *12*

        :type resolution: int

        :returns:

            None
        """
        if resolution not in [8, 10, 12]:
            raise ValueError('Invalid resolution specified: valid entries are 8, 10, or 12')
        self.__resolution = resolution
        self.__max_counts = pow(2,self.__resolution)

        cmd = 0x03
        PiSoC.commChannel.send_data(self.address, cmd, resolution)

class ADC(object):
    """
    :Class:

        The ADC class provides functionality for using the Delta Sigma ADC and two
        Succesive Approximation ADC's on the PiSoC.

    :Example:

        Define ADC objects in the following way::

                >>> My_DELSIG    = ADC('DELSIG')
                >>> My_SAR       = ADC('SAR0')
                >>> My_other_SAR = ADC('SAR1')

    |

    """

    def __init__(self, c_type):
        """
        :Method:

            __init__

        :Description:

            Constructs and initializes an ADC object for use of a SAR or DELSIG ADC

        :param c_type: Specifies the type of ADC to be used. Valid arguments are:

            * 'DELSIG'- This is for the Delta sigma ADC, which has resolution up to 20 bits, but a slower conversion rate
            * 'SAR0' or 'SAR1' - These are for the as many as two Successive Approximation ADCs, which has resolution of 8, 10, or 12 bits, but with a very fast conversion rate

        :type c_type: str

        :returns:

            None
        """

        self.type = c_type

        if self.type == 'DELSIG':
            if not PiSoC.DELSIG:
                raise ValueError('Delta-Sigma ADC not found on PSoC Creator program, verify that it is in your schematic and named correctly')
            self.address = PiSoC.DELSIG_ADC_CONTROL
        elif self.type == 'SAR0':
            if not PiSoC.SAR0:
                raise ValueError('SAR0 ADC not found on PSoC Creator program, verify that it is in your schematic and named correctly')
            self.address = PiSoC.SAR_ADC0_CONTROL
        elif self.type == 'SAR1':
            if not PiSoC.SAR1:
                raise ValueError('SAR1 ADC not found on PSoC Creator program, verify that it is in your schematic and named correctly')
            self.address = PiSoC.SAR_ADC1_CONTROL
        else:
            raise ValueError('Invalid ADC type: Choose "DELSIG" "SAR0" or "SAR1"')
        self.polarity = 1

        if self.address in PiSoC.REGISTERS_IN_USE:
            logging.warning('Attempting to initialize object at register %d which is already in use.' %self.address)
        PiSoC.REGISTERS_IN_USE.append(self.address)

        self.__running = False

    def Start(self):
        """
        :Method:

            Start

        :Description:

            Sets the initVar variable on the PiSoC, calls the ADC_Init() function, and then calls the ADC_Enable() function.
            This function configures and powers up the ADC, but does not start conversions

        :returns:

            None

        """
        cmd = 0x00
        data = (self.address, cmd)
        PiSoC.commChannel.send_data(*data)
        self.__running =True

    def Stop(self):
        """
        :Method:

            Stop

        :Description:

            Disables and powers down the ADC

        :returns:

            None
        """
        cmd = 0x01
        data = (self.address, cmd)
        PiSoC.commChannel.send_data(*data)
        self.__runnning = False

    def is_running(self):
        """
        :Method:

            is_running

        :Description:

            Checks to see if the ADC component and all subcomponents are currently operational

        :returns:

            A boolean variable which evaluates to *True* if the ADC is active, or *False* if it is not
        """
        return self.__running

    def SetBufferGain(self, gain):
        """
        :Method:

            SetBufferGain

        :Description:

            Sets the input buffer gain

        :param gain:

            The number by which the ADC output will be multiplied after conversion .
            Valid arguments are *1, 2, 4,* or *8*

        :type gain: int

        :returns:

            None

        .. note::

            Increasing the gain will lower the buffer bandwidth. This method is only available for the Delta-Sigma ADC; use with a SAR ADC will raise a *ValueError*
        """

        if self.type != 'DELSIG':
            raise ValueError('Setting Buffer Gain only supported by DELSIG ADC')

        cmd = 0x02

        if gain not in [1,2,4,8]:
            raise ValueError('Invalid Gain Value for DELSIG ADC: Accepts 1, 2, 4, or 8')

        data = (self.address, cmd, gain)
        PiSoC.commChannel.send_data(*data)

    def SetResolution(self, resolution):
        """
        :Method:

            SetResolution

        :Description:

            This function sets the resolution of the SAR ADCs only. This method is unavailable for the DELSIG ADC.
            The resolution is defaulted to 12, so this method is only needed if this needs to be changed

        :param resolution:

            An integer value, in bits, that represents the new resolution of the SAR ADC. Valid arguments are *8, 10, or 12* only

        :type resolution:

            int

        :returns:

            None

        .. note::

            The ADC resolution cannot be changed during a conversion cycle. The recommended bestpractice is to stop conversions with :meth:`~Stop` before changing the resolution, and then restarting with :meth:`~Start`
            If you call :meth:`~SetResolution` during a conversion, the resolution will not change until the current conversion is complete, and data will not be available in the new resolution for another 6+resolution clock cycles

        """

        if self.type == 'DELSIG':
            raise ValueError('Invalid operation for the DELSIG ADC; SetResolution is only used by the SAR ADC')

        if resolution not in [8, 10, 12]:
            raise ValueError('Invalid resolution specified: valid entries are 8, 10, or 12')

        cmd = 0x03
        PiSoC.commChannel.send_data(self.address, cmd, resolution)

    def StartConvert(self):
        """
        :Method:

            StartConvert

        :Description:

            Forces the ADC to initialize a conversion. This is handled internally for the Delsig ADC, using the :meth:`~Read` function, but it is kept seperate for the SAR.
            However, It can also be used for the Delsig

        :returns:

            None
        """
        if self.type == "SAR0" or self.type == "SAR1":
            cmd = 0x04
        elif self.type == 'DELSIG':
            cmd = 0x03

        PiSoC.commChannel.send_data(self.address, cmd)

    def StopConvert(self):
        """
        :Method:

            StopConvert

        :Description:

            Forces the ADC to end conversion. This is handled internally for the Delsig ADC, using the :meth:`~Read` function, but it is kept seperate for the SAR.
            However, It can also be used for the Delsig

        :returns:

            None
        """
        if self.type == "SAR0" or self.type == "SAR1":
            cmd = 0x05
        elif self.type == 'DELSIG':
            cmd = 0x04

        PiSoC.commChannel.send_data(self.address,cmd)

    def GetResult(self):
        """
        :Method:

            GetResult

        :Description:

            Gets the result of a conversion which has been completed. :meth:`~StartConvert` must be called prior to this function, and :meth:`~StopConvert` must be called after

        :returns:

            Digital value which represents the result of the most recent AD conversion
        """

        cmd = 0x0A
        counts = int(PiSoC.commChannel.receive_data(self.address, cmd))

        if counts<0:
            self.polarity = -1
        else:
            self.polarity = 1

        return counts

    def Read(self):
        """
        :Method:

            Read

        :Description:

            Simplifies the reading process by starting conversion, waiting for conversion to complete, stopping conversion, and returing the result, when called.

        :returns:

            Digital value which represents the result of the most recent AD conversion
        """
        if self.type != 'DELSIG':
            self.StartConvert()
            while not self.IsEndConversion():
                pass
            counts = self.GetResult()
            self.StopConvert()
        else:
            cmd = 0x0D
            counts = int(PiSoC.commChannel.receive_data(self.address, cmd))

        if counts<0:
            self.polarity = -1
        else:
            self.polarity = 1

        return counts

    def IsEndConversion(self):
        """
        :Method:

            IsEndConversion

        :Description:

            Checks to see if the ADC is done converting

        :returns:

            Boolean value (True/False) that will evaluate True if the most recent conversion is complete, otherwise False.
        """
        if self.type == 'DELSIG':
            cmd = 0x07
        elif self.type == "SAR0" or self.type == "SAR1":
            cmd = 0x08

        return bool(int(PiSoC.commChannel.receive_data(self.address,cmd)))

    def SetOffset(self, offset):
        """
        :Method:

            SetOffset

        :Description:

            Sets an offset on the ADC which is used for the voltage conversion. It will subtract the given offset before making the conversion

        :param offset:

            Digital value which will be subtracted from any digital result before its conversion to a voltage takes place

        :type offset: int

        :returns:

            None
        """
        if self.type == 'DELSIG':
            cmd = 0x0E
        elif self.type == "SAR0" or self.type == "SAR1":
            cmd = 0x0B

        PiSoC.commChannel.send_data(self.address,cmd, offset)

    def SetGain(self, gain):
        """
        :Method:

            SetGain

        :Description:

            Sets the ADC gain in counts per volt, which will be applied before voltage conversion

        :param gain:

            Output gain in counts per volt to be applied before conversion.

        :type gain: int

        :returns:

            None

        .. warning::

            *gain* is set by default by the reference and input range settings. It should only be used to further calibrate the ADC with a known input or if an external reference is used
        """

        if self.type == 'DELSIG':
            cmd = 0x0F
        elif self.type == "SAR0" or self.type == "SAR1":
            gain*=10 #SAR takes gain in counts per 10 volts
            cmd = 0x0C

        PiSoC.commChannel.send_data(self.address,cmd, gain)

    def CountsTo_Volts(self, counts):
        """
        :Method:

            CountsTo_Volts

        :Description:

            Converts the ADC output to a Voltage, taking into account any set gains or offsets

        :param counts:

            Digital value to be converted to it's analog equivalent (voltage in Volts)

        :type counts: int

        :returns:

            Floating point value representative of converted voltage
        """
        if self.type == 'DELSIG':
            cmd = 0x10
        elif self.type == "SAR0" or self.type == "SAR1":
            cmd = 0x0D

        counts*=self.polarity
        return self.polarity*(float(((PiSoC.commChannel.receive_data(self.address,cmd, counts))/1000000.0)))

    def Sleep(self):
        """
        :Method:

            Sleep

        :Description:

            Checks to see if the component is enabled, then it stops the ADC and saves the current configuration for later use

        :returns:

            None
        """
        if self.type == 'DELSIG':
            cmd = 0x14
        elif self.type == "SAR0" or self.type == "SAR1":
            cmd = 0x10

        PiSoC.commChannel.send_data(self.address,cmd)

    def Wakeup(self):
        """
        :Method:

            Wakeup

        :Description:

            Restores and enables the most recently saved configuration of the ADC

        :returns:

            None
        """
        if self.type == 'DELSIG':
            cmd = 0x15
        elif self.type == "SAR0" or self.type == "SAR1":
            cmd = 0x11

        PiSoC.commChannel.send_data(self.address,cmd)

class IDAC(object):
    """
    :Class:

        The IDAC class provides functionality for using the IDAC's available on the PiSoC.

    :Example:

        Define IDAC objects in the following way::

            >>> My_IDAC       = IDAC(0)
            >>> My_other_IDAC = IDAC(1)

    |

    """
    def __init__(self, channel):
        """
        :Method:

            __init__

        :Description:

            Constructs and initializes an IDAC object

        :param channel: Determines which IDAC is to be utilized. V2.0 only exposes channel 0 by default - output on P0[7]

        :type channel: int

        :returns:

            None
        """
        self.channel = channel

        if self.channel == 0:
            if not PiSoC.IDAC0:
                raise ValueError('IDAC0 not found on PSoC Creator program, verify that it is in your schematic and named correctly')
            self.address = PiSoC.IDAC0_CONTROL
            self.full_range = PiSoC.IDAC0_RANGE
       	elif self.channel == 1:
            if not PiSoC.IDAC1:
                raise ValueError('IDAC1 not found on PSoC Creator program, verify that it is in your schematic and named correctly')
            self.address = PiSoC.IDAC1_CONTROL
            self.full_range = PiSoC.IDAC1_RANGE
        else:
            raise ValueError('Invalid channel: Only two IDACs available; choose 0 or 1.')

        if self.address in PiSoC.REGISTERS_IN_USE:
            logging.warning('Attempting to initialize object at register %d which is already in use.' %self.address)
        PiSoC.REGISTERS_IN_USE.append(self.address)
        self.__running = False

    def Start(self):
        """
        :Method:

            Start

        :Description:

            Sets the initVar variable on the PiSoC, calls the IDAC8_Init() function and then calls the IDAC8_Enable() function. Enables and powers up the IDAC

        :returns:

            None
        """
        cmd = 0x00
        PiSoC.commChannel.send_data(self.address, cmd)
        self.__running = True

    def Stop(self):
        """
        :Method:

            Stop

        :Description:

            Powers down IDAC to lowest power state and disables output

        :returns:

            None
        """
        cmd = 0x01
        PiSoC.commChannel.send_data(self.address, cmd)
        self.__running = False

    def is_running(self):
        """
        :Method:

            is_running

        :Description:

            Checks to see if the DAC component and all subcomponents are currently operational

        :returns:

            A boolean variable which evaluates to *True* if the DAC is active, or *False* if it is not
        """
        return self.__running

    def SetSpeed(self,speed):
        """
        :Method:

            SetSpeed

        :Description:

            Sets the DAC speed, and consequently the power level

        :param speed: *HIGH* or *LOW* for high speed or low speed, respectively

        :type speed: str

        :returns:

            None
        """
        cmd = 0x02
        if speed =='LOW':
            val = 0
        elif speed =='HIGH':
            val = 1
        else:
            raise ValueError('Invalid Speed: Input "HIGH" or "LOW"')

        PiSoC.commChannel.send_data(self.address, cmd, val)

    def SetPolarity(self,polarity):
        """
        :Method:

            SetPolarity

        :Description:

            Sets the DAC output polarity

        :param polarity: String argument which should be *SOURCE* or *SINK*
        :type polarity: str

        :returns:

            None
        """

        cmd = 0x03
        if polarity =='SOURCE':
            val = 0
        elif polarity =='SINK':
            val = 1
        else:
            raise ValueError('Invalid Polarity: Input "SOURCE" or "SINK"')

        PiSoC.commChannel.send_data(self.address, cmd, val)

    def SetRange(self, mode):
        """
        :Method:

            SetRange

        :Description:

            Sets the full scale range for the IDAC

        :param mode: Choices are *0*, *1*, and *2*

            :0: Sets full scale range to **31.875 uA**
            :1: Sets full scale range to **255 uA**
            :2: Sets full scale range to **2.04 mA**

        :type mode: int

        :returns:

            None
        """
        cmd = 0x04
        if mode not in range(3):
            raise ValueError('Invalid Mode Specified:\n"0" for 32uA range\n"1" for 255uA range\n"2" for 2mA range ')
        if mode == 0:
            self.full_range = .031875
        elif mode == 1:
            self.full_range = .255
        elif mode == 2:
            self.full_range = 2.04

        PiSoC.commChannel.send_data(self.address, cmd, mode)

    def SetValue(self, value):
        """
        :Method:

            SetValue

        :Description:

            Sets a digital value to be converted into an analog current and output by the IDAC

        :param value: Value between *0* and *255*

            * A value of 0 will correspond to an output of the lowest possible current output
            * A value of 255 will output the full scale value, as selected with :meth:`~SetRange`
            * All values between *0* and *255* are linearized according to the full scale range

        :type value: int

        :returns:

            None
        """
        cmd = 0x05
        if value not in range(256):
            raise ValueError('Invalid IDAC Value: Input integer values between 0(min) and 255(max)')

        PiSoC.commChannel.send_data(self.address, cmd, value)

    def SetCurrent(self, m_amps):
        """
        :Method:

            SetCurrent

        :Description:

            Sets a current in milliamps to be output on the specified IDAC

        :param m_amps: A number between 0 and the full scale range (in milliamps), as selected by :meth:`~SetRange`. This will be converted to an analog current and output from the IDAC.

        :type m_amps: float

        :returns:

            None
        """

        if m_amps <= self.full_range and m_amps>=0:
            digital_val = int((float(m_amps)/self.full_range) * 255 + 0.5)
        else:
            digital_val = int(255*(m_amps>self.full_range))

        self.SetValue(digital_val)

    def Sleep(self):
        """
        :Method:

            Sleep

        :Description:

            Checks to see if the component is enabled, then it stops the DAC and saves the current configuration for later use

        :returns:

            None
        """
        cmd = 0x06
        PiSoC.commChannel.send_data(self.address, cmd)

    def Wakeup(self):
        """
        :Method:

            Wakeup

        :Description:

            Restores and enables the most recently saved configuration of the DAC

        :returns:

            None
        """
        cmd = 0x07
        PiSoC.commChannel.send_data(self.address, cmd)

class VDAC(object):
    """
    :Class:

        The VDAC class provides functionality for using the VDAC's available on the PiSoC.

    :Example:

        Define VDAC objects in the following way::

            >>> My_VDAC       = VDAC(0)
            >>> My_other_VDAC = VDAC(1)
    """
    def __init__(self, channel):
        """
        :Method:

            __init__

        :Description:

            Constructs and initializes a VDAC object

        :param channel:

            Determines which VDAC is to be utilized. *0* for the first VDAC, output is on P0[1]. Second VDAC not available by default.

        :returns:

            None
        """

        self.channel = channel

        if self.channel == 0:
            if not PiSoC.VDAC0:
                raise ValueError('VDAC0 not found on PSoC Creator program, verify that it is in your schematic and named correctly')
            self.address = PiSoC.VDAC0_CONTROL
            self.full_range = PiSoC.VDAC0_RANGE
        elif self.channel == 1:
            if not PiSoC.VDAC1:
                raise ValueError('VDAC1 not found on PSoC Creator program, verify that it is in your schematic and named correctly')
            self.address = PiSoC.VDAC1_CONTROL
            self.full_range = PiSoC.VDAC1_RANGE
        else:
            raise ValueError('Invalid channel: Only two VDACs available; choose 0 or 1')

        if self.address in PiSoC.REGISTERS_IN_USE:
            logging.warning('Attempting to initialize object at register %d which is already in use.' %self.address)
        PiSoC.REGISTERS_IN_USE.append(self.address)
        self.__running = False

    def Start(self):
        """
        :Method:

            Start

        :Description:

            Enables and powers up the VDAC

        :returns:

            None
        """
        cmd = 0x00
        PiSoC.commChannel.send_data(self.address, cmd)
        self.__running = True

    def Stop(self):
        """
        :Method:

            Stop

        :Description:

            Powers down VDAC to lowest power state and disables output

        :returns:

            None
        """
        cmd = 0x01
        PiSoC.commChannel.send_data(self.address, cmd)
        self.__running = False

    def is_running(self):
        """
        :Method:

            is_running

        :Description:

            Checks to see if the DAC component and all subcomponents are currently operational

        :returns:

            A boolean variable which evaluates to *True* if the DAC is active, or *False* if it is not
        """
        return self.__running

    def SetSpeed(self,speed):
        """
        :Method:

            SetSpeed

        :Description:

            Sets the DAC speed, and consequently the power level

        :param speed: *HIGH* or *LOW* for high speed or low speed, respectively
        :type speed: str

        :returns:

            None
        """
        cmd = 0x02
        if speed =='LOW':
            val = 0
        elif speed =='HIGH':
            val = 1
        else:
            raise ValueError('Invalid Speed: Input "HIGH" or "LOW"')

        PiSoC.commChannel.send_data(self.address, cmd, val)

    def SetRange(self,mode):
        """
        :Method:

            SetRange

        :Description:

            Sets the full scale range for the VDAC

        :param mode: Choices are *0* or *1*

            :0: Sets full scale range to **4.080 V**
            :1: Sets full scale range to **1.020 V**

        :type mode: int

        :returns:

            None
        """
        cmd = 0x03
        if mode =='LOW': #Range of 1.020 V
            val = 0
            self.full_range = 1.02
        elif mode =='HIGH': #Range of 4V
            val = 1
            self.full_range = 4.08
        else:
            raise ValueError('Invalid Range: Input "HIGH" for 4.080V range or "LOW" for 1.020V range')

        PiSoC.commChannel.send_data(self.address, cmd, val)

    def SetVoltage(self, volts):
        """
        :Method:

            SetVoltage

        :Description:

            Sets a voltage in Volts to be output on the specified VDAC

        :param volts:

            A number between 0 and the full scale range, as selected by  :meth:`~SetRange`. This will be converted to an analog voltage and output.

        :type volts: float

        :returns:

            None
        """

        if volts <= self.full_range and volts>=0:
            digital_val = int((float(volts)/self.full_range) * 255 + 0.5)
        else:
            digital_val = int(255*(volts>self.full_range))
        self.SetValue(digital_val)

    def SetValue(self, value):
        """
        :Method:

            SetValue

        :Description:

            Sets a digital value to be converted into an analog voltage and output by the VDAC

        :param value: Value between *0* and *255*

            * A value of 0 will correspond to an output of the lowest possible voltage output
            * A value of 255 will output the full scale value, as selected with :meth:`~SetRange`
            * All values between *0* and *255* are linearized according to the full scale range

        :type value: int

        :returns:

            None
        """
        cmd = 0x04
        if value not in range(256):
            raise ValueError('Invalid VDAC Value: Input values between 0(min) and 255(max)')

        PiSoC.commChannel.send_data(self.address, cmd, value)

    def Sleep(self):
        """
        :Method:

            Sleep

        :Description:

            Checks to see if the component is enabled, then it stops the VDAC and saves the current configuration for later use

        :returns:

            None
        """
        cmd = 0x05
        PiSoC.commChannel.send_data(self.address, cmd)

    def Wakeup(self):
        """
        :Method:

            Wakeup

        :Description:

            Restores and enables the most recently saved configuration of the VDAC

        :returns:

            None
        """

        cmd = 0x06
        PiSoC.commChannel.send_data(self.address, cmd)

class WaveDAC(object):
    """
    :Class:

        The WaveDAC class provides functionality for using the WaveDAC available on the PiSoC.

    :Example:

        Define WaveDAC objects in the following way::

            >>> My_Wave = WaveDAC()
    """

    def __init__(self):
        """
        :Method:

            __init__

        :Description:

            Constructs and initializes an WaveDAC object

        :returns:

            None
        """

        if not PiSoC.WAVEDAC:
                raise ValueError('Wave DAC not found on PSoC Creator program, verify that it is in your schematic and named correctly')
        self.master_clk = 3000000 #might want to automate....
        self.frequency = 250000
        self.divider_value = 12
        self.amplitude = 255
        self.dcBias = 0
        self.waveType = 'SINE'
        self.address = PiSoC.WAVEDAC_CONTROL

        if self.address in PiSoC.REGISTERS_IN_USE:
            logging.warning('Attempting to initialize object at register %d which is already in use.' %self.address)
        PiSoC.REGISTERS_IN_USE.append(self.address)
        self.__running = False

    def Start(self):
        """
        :Method:

            Start

        :Description:

            Performs all of the required initialization for the component and enables power to the block

        :returns:

            None
        """
        cmd = 0x00
        PiSoC.commChannel.send_data(self.address, cmd)
        self.__running = True

    def Stop(self):
        """
        :Method:

            Stop

        :Description:

            Powers down the WaveDAC to its lowest power state and disables output

        :returns:

            None
        """
        cmd = 0x01
        PiSoC.commChannel.send_data(self.address, cmd)
        self.__running = False

    def is_running(self):
        """
        :Method:

            is_running

        :Description:

            Checks to see if the DAC component and all subcomponents are currently operational

        :returns:

            A boolean variable which evaluates to *True* if the DAC is active, or *False* if it is not
        """
        return self.__running

    def SetSpeed(self, speed):
        """
        :Method:

            SetSpeed

        :Description:

            Dets the DAC speed to one of the defined settings

        :param speed: *HIGH* or *LOW* for high speed or low speed, respectively

        :type speed: str

        :returns:

            None
        """
        cmd = 0x07

        if speed == 'HIGH':
            val = 1
        elif speed == 'LOW':
            val = 0
        else:
            raise ValueError('Invalid Speed: Choose "HIGH" or "LOW"')

        PiSoC.commChannel.send_data(self.address, cmd, val)

    def GenerateWave(self, waveType, amplitude = 4.0, dc_bias = 0.0):
        """
        :Method:

            Provides functionality for generating a specific waveform

        :Description: Provides functionality for generating a specific waveform

        :param waveType: The output behavior of the WaveDAC, Valid choices are: *SINE, SQUARE, TRIANGLE,* or *SAWTOOTH*

        :type waveType: str

        :param amplitude: Determines how the output waveform is scaled. Output will be such that this value is the maximum, with everything else being linearly related.

        :type amplitude: float

        :param dc_bias: A voltage that will be added to each value (DC portion). If this causes values to exceed 255, they will clip at 4V.

        :type dc_bias: float

        :returns:

            None
        """

        cmd = 0x04
        self.waveType = waveType

        if waveType == 'SINE':
            val = 0x01
        elif waveType =='SQUARE':
            val = 0x03
        elif waveType == 'TRIANGLE':
            val = 0x05
        elif waveType == 'SAWTOOTH':
            val = 0x07
        else:
            raise ValueError('Invalid waveType: Choose "SINE" "SQUARE" "TRIANGLE" or "SAWTOOTH" ')

        self.amplitude = int(255/4.0*float(amplitude))
        self.dcBias = int(255/4.0*float(dc_bias))

        PiSoC.commChannel.send_data(self.address, cmd, val, self.amplitude, self.dcBias, Hformat = [])
        #PiSoC.commChannel.send_data((val, self.amplitude, self.dcBias))

    def SetValue(self, val):
        """
        :Method:

            SetValue

        :Description:

            Sets a digital value to be converted into a voltage and output by the WaveDAC.

        :param val: Value between *0* and *255*

        :type val: int

        :returns:

            None
        """
        cmd = 0x09
        if val not in range(256):
            raise ValueError('Invalid WaveDAC Value: Input integer between 0(min) and 255(max)')
        else:
            PiSoC.commChannel.send_data(self.address,cmd,val)

    def Sleep(self):
        """
        :Method:

            Sleep

        :Description:

            Checks to see if the component is enabled, then it stops the DAC and saves the current configuration for later use

        :returns:

            None
        """
        cmd = 0x0B
        PiSoC.commChannel.send_data(self.address, cmd)

    def Wakeup(self):
        """
        :Method:

            Wakeup

        :Description:

            Restores and enables the most recently saved configuration of the DAC

        :returns:

            None
        """
        cmd = 0x0C
        PiSoC.commChannel.send_data(self.address, cmd)

    def SetFrequency(self, frequency):
        """
        :Method:

            SetFrequency

        :Description:

            Sets an approximate frequency by using an appropriate clock divider so that the resulting wave is as close to the desired frequency as possible

        :param frequency: A frequency in Hz that will be representative of the output wave rate (Valid range is between 0.46 and 2500)

        :type frequency: float

        :returns:

            None
        """
        cmd = 0xFF

        if frequency > 2500:
            logging.warning("Wave Frequency cannot be greater than 2.5kHz \nWave frequency will be set to 2.5kHz to prevent runtime errors.")
            frequency = 2500
        elif frequency<0.46:
            logging.warning('Wave Frequency must not be less than 0.46 Hz because no valid clock divider will sufficiently achieve such a frequency. Frequency will be set to 0.46 Hz to prevent runtime errors ')
            frequency = 0.46

        divider = int((self.master_clk/(frequency*100.0)) + 0.5)
        self.divider_value = (PiSoC.commChannel.receive_data(self.address, cmd, divider)) + 1

    def GetFrequency(self):
        """
        :Method:

            GetFrequency

        :Description:

            Calculates the actual wave frequency based on the most recently confirmed clock divider value

        :returns:

            (float) The *actual* frequency of the wave, *not* a requested frequency
        """
        return int(((self.master_clk/self.divider_value)/100.0))

    def StartClock(self):
        """
        :Method:

            StartClock

        :Description:

            Restarts the WaveDAC clock after it has been stopped

        :returns:

            None
        """
        cmd = 0xFD
        PiSoC.commChannel.send_data(self.address,cmd)

    def StopClock(self):
        """
        :Method:

            StopClock

        :Description:

            Stops the WaveDAC clock so that a value can be set without interference by the clock

        :returns:

            None
        """
        cmd = 0xFE
        PiSoC.commChannel.send_data(self.address,cmd)