text:
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import styled from 'react-emotion';
import axios from 'axios';

import loading from './helpers/loading';
import errorHandler from './helpers/errorHandler';
import { Island, Title, Button, Input } from './';

const MobilePaymentLayout = styled(Island)`
	width: 440px;
	background: #108051;
`;

const MobilePaymentTitle = styled(Title)`
	color: #fff;
`;

const InputField = styled.div`
	display: flex;
	align-items: center;
	margin-bottom: 26px;
	position: relative;
	padding-left: 150px;
`;

const Label = styled.div`
	font-size: 15px;
	color: #fff;
	position: absolute;
	left: 0;
`;

const Currency = styled.span`
	font-size: 13px;
	color: #fff;
	margin-left: 12px;
`;

const Commission = styled.div`
	color: rgba(255, 255, 255, 0.6);
	font-size: 13px;
	text-align: right;
	margin: 35px 0 20px;
`;

const Underline = styled.div`
	height: 1px;
	margin-bottom: 20px;
	background-color: rgba(0, 0, 0, 0.16);
`;

const PaymentButton = styled(Button)`
  float: right;
`;

const InputPhoneNumber = styled(Input)`
	width: 225px;
`;

const InputSum = styled(Input)`
	width: 160px;
`;

const InputCommision = styled(Input)`
	cursor: no-drop;
	width: 160px;
	border: dotted 1.5px rgba(0, 0, 0, 0.2);
	background-color: initial;
`;

/**
 * Компонент MobilePaymentContract
 */
class MobilePaymentContract extends Component {
  /**
	 * Конструктор
	 * @param {Object} props свойства компонента MobilePaymentContract
	 */
  constructor(props) {
    super(props);

    this.state = {
      phoneNumber: '',
      sum: 500,
      commission: 3,
      submitDisabled: true,
    };
  }

  /**
	 * Отправка формы
	 * @param {Event} event событие отправки формы
	 */
  onSubmitForm(event) {
    if (event) {
      event.preventDefault();
    }

    const { sum, phoneNumber, commission } = this.state;
    const isNumber = !isNaN(parseFloat(sum)) && isFinite(sum);

    if (!isNumber || Number(sum) === 0) {
      return errorHandler('Введите корректную сумму пополнения');
    }

    const { activeCard } = this.props;

    if (activeCard.balance < Number(sum)) {
      return errorHandler('У вас недостаточно средств');
    }

    let phoneNum = phoneNumber.match(/\d/g);

    if (!phoneNum) {
      return errorHandler('Введен некорректный номер телефона');
    }

    phoneNum = phoneNum.join('');

    if (phoneNum.length === 10) {
      phoneNum = `7${phoneNum}`;
    }

    const hide = loading('Подождите...');

    return axios
      .post(`/cards/${activeCard.id}/pay`, {
        phoneNumber: phoneNum,
        sum,
      })
      .then((res) => {
        hide();

        const { id, sum: summa, data: phone = {} } = res.data;
        const transaction = Object.assign({}, phone, {
          id,
          sum: summa,
          commission,
        });

        this.props.onPaymentSuccess(transaction);
      })
      .catch(errorHandler(hide));
  }

  /**
	 * Обработка изменения значения в input
	 * @param {Event} event - событие изменения значения input
	 */
  onChangeInputValue(event) {
    if (!event) {
      return;
    }

    const { name, value } = event.target;

    this.setState({
      [name]: value,
      submitDisabled: !(this.isValid(value) && this.isValidPhone()),
    });
  }

  /**
   * Обработка изменения значения в input phoneNumber
   * @param {Event} event - событие изменения
   */
  onChangePhoneNumber(event) {
    if (!event) {
      return;
    }

    const { name, value } = event.target;

    this.setState({
      [name]: value,
      submitDisabled: !(this.isValid() && this.isValidPhone(value)),
    });
  }

  /**
   * Получить цену с учетом комиссии
   * @returns {Number}
   */
  getSumWithCommission() {
    const { sum, commission } = this.state;

    const isNumber = !isNaN(parseFloat(sum)) && isFinite(sum);
    if (!isNumber || sum <= 0) {
      return 0;
    }

    return Number(sum) + Number(commission);
  }

  isValid(value) {
    const sum = value || this.state.sum;
    const { activeCard } = this.props;
    const isNumber = !isNaN(parseFloat(sum)) && isFinite(sum);

    if (!isNumber || Number(sum) <= 0) {
      return false;
    }

    if (activeCard.balance < Number(sum)) {
      return false;
    }

    return true;
  }

  isValidPhone(value) {
    const phoneNumber = value || String(this.state.phoneNumber);
    let numbers = phoneNumber.match(/\d/g);

    if (!numbers) {
      return false;
    }

    numbers = numbers.map((v) => parseInt(v, 10));

    if (numbers.length === 10) {
      return numbers[0] === 9;
    }

    return numbers.length === 11 && numbers[0] === 7 && numbers[1] === 9;
  }

  /**
	 * Рендер компонента
	 *
	 * @override
	 * @returns {JSX}
	 */
  render() {
    const { commission, submitDisabled } = this.state;

    return (
      <MobilePaymentLayout>
        <form onSubmit={(event) => this.onSubmitForm(event)}>
          <MobilePaymentTitle>Пополнить телефон</MobilePaymentTitle>
          <InputField>
            Телефон
            <InputPhoneNumber
              name='phoneNumber'
              required='required'
              value={this.state.phoneNumber}
              placeholder='Введите номер телефона'
              onChange={(event) => this.onChangePhoneNumber(event)} />
          </InputField>
          <InputField>
            Сумма
            <InputSum
              name='sum'
              type='number'
              min='1'
              required='required'
              step='any'
              value={this.state.sum}
              onChange={(event) => this.onChangeInputValue(event)} />
            <Currency>₽</Currency>
          </InputField>
          <InputField>
            Спишется
            <InputCommision value={this.getSumWithCommission()} readOnly />
            <Currency>₽</Currency>
          </InputField>
          <Commission>Размер коммиссии составляет {commission} ₽</Commission>
          <Underline />
          <PaymentButton bgColor='#fff' textColor='#108051' disabled={submitDisabled}>Пополнить</PaymentButton>
        </form>
      </MobilePaymentLayout>
    );
  }
}

MobilePaymentContract.propTypes = {
  activeCard: PropTypes.shape({
    id: PropTypes.number,
    balance: PropTypes.number.isRequired,
  }).isRequired,
  onPaymentSuccess: PropTypes.func.isRequired,
};

export default MobilePaymentContract;


text:
package org.dozer.functional_tests.runner;

import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import net.sf.cglib.proxy.Dispatcher;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import org.dozer.functional_tests.DataObjectInstantiator;
import org.dozer.util.MappingUtils;

/**
 * Quick and dirty class used to create test data objects that are wrapped with a proxy.  Right now use CGLIB to proxy
 * the data objects since this is probably the most typical usage of proxied data objects(Hibernate lazy loading).
 *
 * @author Matt Tierney
 */
public final class ProxyDataObjectInstantiator implements DataObjectInstantiator {

    public static final ProxyDataObjectInstantiator INSTANCE = new ProxyDataObjectInstantiator();

    private ProxyDataObjectInstantiator() {

    }

    @Override
    public String getName() {
        return "cglib";
    }

    public <T> T newInstance(Class<T> classToInstantiate) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(classToInstantiate);
        enhancer.setCallback(NoOpInterceptor.INSTANCE);

        return (T)enhancer.create();
    }

    public <T> T newInstance(Class<T> classToInstantiate, Object[] args) {
        List<Class<?>> argTypes = new ArrayList<Class<?>>();
        for (Object arg : args) {
            argTypes.add(MappingUtils.getRealClass(arg.getClass()));
        }

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(classToInstantiate);
        enhancer.setCallback(NoOpInterceptor.INSTANCE);

        return (T)enhancer.create(argTypes.toArray(new Class[0]), args);
    }

    public Object newInstance(Class<?>[] interfacesToProxy, final Object target) {
        Enhancer enhancer = new Enhancer();
        enhancer.setInterfaces(interfacesToProxy);
        enhancer.setCallback(new Dispatcher() {
            public Object loadObject() throws Exception {
                return target;
            }
        });

        return enhancer.create();
    }

    private static class NoOpInterceptor implements MethodInterceptor, Serializable {
        private static final NoOpInterceptor INSTANCE = new NoOpInterceptor();

        public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
            return methodProxy.invokeSuper(object, args);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
cask :v1 => 'flowdock' do
  version :latest
  sha256 :no_check

  url 'https://flowdock-resources.s3.amazonaws.com/mac/Flowdock.zip'
  appcast 'https://s3.amazonaws.com/flowdock-resources/mac/appcast.xml'
  homepage 'https://www.flowdock.com/'
  license :unknown    # todo: change license and remove this comment; ':unknown' is a machine-generated placeholder

  app 'Flowdock.app'
end


text:
package bouncermain

import (
	"sync"
	"sync/atomic"
	"time"
)

type TokenBucket struct {
	Name     string
	Size     uint64
	Interval time.Duration
	Stats    *Metrics
	acquireC chan bool
	timer    *time.Timer
}

var buckets = map[string]*TokenBucket{}
var bucketsMutex = &sync.Mutex{}

func newTokenBucket(name string, size uint64, interval time.Duration) (bucket *TokenBucket) {
	bucket = &TokenBucket{
		Name:     name,
		Size:     size,
		Interval: interval,
		Stats:    &Metrics{CreatedAt: time.Now().Format(time.RFC3339)},
		acquireC: make(chan bool),
		timer:    time.NewTimer(interval),
	}

	buckets[name] = bucket

	go bucket.refill()
	//go bucket.Stats.Run()

	return bucket
}

func getTokenBucket(name string, size uint64, interval time.Duration) (bucket *TokenBucket, err error) {
	bucketsMutex.Lock()
	defer bucketsMutex.Unlock()

	bucket, ok := buckets[name]
	if !ok {
		bucket = newTokenBucket(name, size, interval)
		logger.Infof("tokenbucket created: name=%v, size=%v", name, size)
	}

	bucket.Size = size
	bucket.Interval = interval

	return
}

func (bucket *TokenBucket) refill() {
	var n uint64
	for {
		// bucket size being changed midloop is not a problem, since
		// we want size changes to take effect immediately
		for n = 0; n < bucket.Size; n++ {
			// make token available
			bucket.acquireC <- true
		}

		// wait
		<-bucket.timer.C

		// and reset the timer
		bucket.timer.Reset(bucket.Interval)
	}
}

func (bucket *TokenBucket) Acquire(maxwait time.Duration, arrival time.Time) (err error) {

	_, err = RecvTimeout(bucket.acquireC, maxwait)
	if err != nil {
		atomic.AddUint64(&bucket.Stats.TimedOut, 1)
		return err
	}

	wait := uint64(time.Now().Sub(arrival) / time.Millisecond)

	logger.Debugf("wait time %v", wait)

	atomic.AddUint64(&bucket.Stats.Acquired, 1)
	atomic.AddUint64(&bucket.Stats.WaitTime, wait)
	return nil
}

func (bucket *TokenBucket) GetStats() *Metrics {
	return bucket.Stats
}

func getTokenBucketStats(name string) (stats *Metrics, err error) {
	bucketsMutex.Lock()
	defer bucketsMutex.Unlock()

	bucket, ok := buckets[name]
	if !ok {
		return nil, ErrNotFound
	}

	return bucket.Stats, nil
}


text:
#pragma once
#include <aws/ds/DirectoryService_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/ds/model/TrustType.h>
#include <aws/ds/model/TrustDirection.h>
#include <aws/ds/model/TrustState.h>
#include <aws/core/utils/DateTime.h>
#include <utility>

namespace Aws
{
namespace Utils
{
namespace Json
{
  class JsonValue;
} // namespace Json
} // namespace Utils
namespace DirectoryService
{
namespace Model
{

  /**
   *
Describes a trust relationship between an Microsoft AD in the AWS cloud and
   * an external domain.

See Also:
   AWS API
   * Reference

   */
  class AWS_DIRECTORYSERVICE_API Trust
  {
  public:
    Trust();
    Trust(const Aws::Utils::Json::JsonValue& jsonValue);
    Trust& operator=(const Aws::Utils::Json::JsonValue& jsonValue);
    Aws::Utils::Json::JsonValue Jsonize() const;

    /**
     *
The Directory ID of the AWS directory involved in the trust relationship.

     */
    inline const Aws::String& GetDirectoryId() const{ return m_directoryId; }

    /**
     *
The Directory ID of the AWS directory involved in the trust relationship.

     */
    inline void SetDirectoryId(const Aws::String& value) { m_directoryIdHasBeenSet = true; m_directoryId = value; }

    /**
     *
The Directory ID of the AWS directory involved in the trust relationship.

     */
    inline void SetDirectoryId(Aws::String&& value) { m_directoryIdHasBeenSet = true; m_directoryId = std::move(value); }

    /**
     *
The Directory ID of the AWS directory involved in the trust relationship.

     */
    inline void SetDirectoryId(const char* value) { m_directoryIdHasBeenSet = true; m_directoryId.assign(value); }

    /**
     *
The Directory ID of the AWS directory involved in the trust relationship.

     */
    inline Trust& WithDirectoryId(const Aws::String& value) { SetDirectoryId(value); return *this;}

    /**
     *
The Directory ID of the AWS directory involved in the trust relationship.

     */
    inline Trust& WithDirectoryId(Aws::String&& value) { SetDirectoryId(std::move(value)); return *this;}

    /**
     *
The Directory ID of the AWS directory involved in the trust relationship.

     */
    inline Trust& WithDirectoryId(const char* value) { SetDirectoryId(value); return *this;}

    /**
     *
The unique ID of the trust relationship.

     */
    inline const Aws::String& GetTrustId() const{ return m_trustId; }

    /**
     *
The unique ID of the trust relationship.

     */
    inline void SetTrustId(const Aws::String& value) { m_trustIdHasBeenSet = true; m_trustId = value; }

    /**
     *
The unique ID of the trust relationship.

     */
    inline void SetTrustId(Aws::String&& value) { m_trustIdHasBeenSet = true; m_trustId = std::move(value); }

    /**
     *
The unique ID of the trust relationship.

     */
    inline void SetTrustId(const char* value) { m_trustIdHasBeenSet = true; m_trustId.assign(value); }

    /**
     *
The unique ID of the trust relationship.

     */
    inline Trust& WithTrustId(const Aws::String& value) { SetTrustId(value); return *this;}

    /**
     *
The unique ID of the trust relationship.

     */
    inline Trust& WithTrustId(Aws::String&& value) { SetTrustId(std::move(value)); return *this;}

    /**
     *
The unique ID of the trust relationship.

     */
    inline Trust& WithTrustId(const char* value) { SetTrustId(value); return *this;}

    /**
     *
The Fully Qualified Domain Name (FQDN) of the external domain involved in the
     * trust relationship.

     */
    inline const Aws::String& GetRemoteDomainName() const{ return m_remoteDomainName; }

    /**
     *
The Fully Qualified Domain Name (FQDN) of the external domain involved in the
     * trust relationship.

     */
    inline void SetRemoteDomainName(const Aws::String& value) { m_remoteDomainNameHasBeenSet = true; m_remoteDomainName = value; }

    /**
     *
The Fully Qualified Domain Name (FQDN) of the external domain involved in the
     * trust relationship.

     */
    inline void SetRemoteDomainName(Aws::String&& value) { m_remoteDomainNameHasBeenSet = true; m_remoteDomainName = std::move(value); }

    /**
     *
The Fully Qualified Domain Name (FQDN) of the external domain involved in the
     * trust relationship.

     */
    inline void SetRemoteDomainName(const char* value) { m_remoteDomainNameHasBeenSet = true; m_remoteDomainName.assign(value); }

    /**
     *
The Fully Qualified Domain Name (FQDN) of the external domain involved in the
     * trust relationship.

     */
    inline Trust& WithRemoteDomainName(const Aws::String& value) { SetRemoteDomainName(value); return *this;}

    /**
     *
The Fully Qualified Domain Name (FQDN) of the external domain involved in the
     * trust relationship.

     */
    inline Trust& WithRemoteDomainName(Aws::String&& value) { SetRemoteDomainName(std::move(value)); return *this;}

    /**
     *
The Fully Qualified Domain Name (FQDN) of the external domain involved in the
     * trust relationship.

     */
    inline Trust& WithRemoteDomainName(const char* value) { SetRemoteDomainName(value); return *this;}

    /**
     *
The trust relationship type.

     */
    inline const TrustType& GetTrustType() const{ return m_trustType; }

    /**
     *
The trust relationship type.

     */
    inline void SetTrustType(const TrustType& value) { m_trustTypeHasBeenSet = true; m_trustType = value; }

    /**
     *
The trust relationship type.

     */
    inline void SetTrustType(TrustType&& value) { m_trustTypeHasBeenSet = true; m_trustType = std::move(value); }

    /**
     *
The trust relationship type.

     */
    inline Trust& WithTrustType(const TrustType& value) { SetTrustType(value); return *this;}

    /**
     *
The trust relationship type.

     */
    inline Trust& WithTrustType(TrustType&& value) { SetTrustType(std::move(value)); return *this;}

    /**
     *
The trust relationship direction.

     */
    inline const TrustDirection& GetTrustDirection() const{ return m_trustDirection; }

    /**
     *
The trust relationship direction.

     */
    inline void SetTrustDirection(const TrustDirection& value) { m_trustDirectionHasBeenSet = true; m_trustDirection = value; }

    /**
     *
The trust relationship direction.

     */
    inline void SetTrustDirection(TrustDirection&& value) { m_trustDirectionHasBeenSet = true; m_trustDirection = std::move(value); }

    /**
     *
The trust relationship direction.

     */
    inline Trust& WithTrustDirection(const TrustDirection& value) { SetTrustDirection(value); return *this;}

    /**
     *
The trust relationship direction.

     */
    inline Trust& WithTrustDirection(TrustDirection&& value) { SetTrustDirection(std::move(value)); return *this;}

    /**
     *
The trust relationship state.

     */
    inline const TrustState& GetTrustState() const{ return m_trustState; }

    /**
     *
The trust relationship state.

     */
    inline void SetTrustState(const TrustState& value) { m_trustStateHasBeenSet = true; m_trustState = value; }

    /**
     *
The trust relationship state.

     */
    inline void SetTrustState(TrustState&& value) { m_trustStateHasBeenSet = true; m_trustState = std::move(value); }

    /**
     *
The trust relationship state.

     */
    inline Trust& WithTrustState(const TrustState& value) { SetTrustState(value); return *this;}

    /**
     *
The trust relationship state.

     */
    inline Trust& WithTrustState(TrustState&& value) { SetTrustState(std::move(value)); return *this;}

    /**
     *
The date and time that the trust relationship was created.

     */
    inline const Aws::Utils::DateTime& GetCreatedDateTime() const{ return m_createdDateTime; }

    /**
     *
The date and time that the trust relationship was created.

     */
    inline void SetCreatedDateTime(const Aws::Utils::DateTime& value) { m_createdDateTimeHasBeenSet = true; m_createdDateTime = value; }

    /**
     *
The date and time that the trust relationship was created.

     */
    inline void SetCreatedDateTime(Aws::Utils::DateTime&& value) { m_createdDateTimeHasBeenSet = true; m_createdDateTime = std::move(value); }

    /**
     *
The date and time that the trust relationship was created.

     */
    inline Trust& WithCreatedDateTime(const Aws::Utils::DateTime& value) { SetCreatedDateTime(value); return *this;}

    /**
     *
The date and time that the trust relationship was created.

     */
    inline Trust& WithCreatedDateTime(Aws::Utils::DateTime&& value) { SetCreatedDateTime(std::move(value)); return *this;}

    /**
     *
The date and time that the trust relationship was last updated.

     */
    inline const Aws::Utils::DateTime& GetLastUpdatedDateTime() const{ return m_lastUpdatedDateTime; }

    /**
     *
The date and time that the trust relationship was last updated.

     */
    inline void SetLastUpdatedDateTime(const Aws::Utils::DateTime& value) { m_lastUpdatedDateTimeHasBeenSet = true; m_lastUpdatedDateTime = value; }

    /**
     *
The date and time that the trust relationship was last updated.

     */
    inline void SetLastUpdatedDateTime(Aws::Utils::DateTime&& value) { m_lastUpdatedDateTimeHasBeenSet = true; m_lastUpdatedDateTime = std::move(value); }

    /**
     *
The date and time that the trust relationship was last updated.

     */
    inline Trust& WithLastUpdatedDateTime(const Aws::Utils::DateTime& value) { SetLastUpdatedDateTime(value); return *this;}

    /**
     *
The date and time that the trust relationship was last updated.

     */
    inline Trust& WithLastUpdatedDateTime(Aws::Utils::DateTime&& value) { SetLastUpdatedDateTime(std::move(value)); return *this;}

    /**
     *
The date and time that the TrustState was last updated.

     */
    inline const Aws::Utils::DateTime& GetStateLastUpdatedDateTime() const{ return m_stateLastUpdatedDateTime; }

    /**
     *
The date and time that the TrustState was last updated.

     */
    inline void SetStateLastUpdatedDateTime(const Aws::Utils::DateTime& value) { m_stateLastUpdatedDateTimeHasBeenSet = true; m_stateLastUpdatedDateTime = value; }

    /**
     *
The date and time that the TrustState was last updated.

     */
    inline void SetStateLastUpdatedDateTime(Aws::Utils::DateTime&& value) { m_stateLastUpdatedDateTimeHasBeenSet = true; m_stateLastUpdatedDateTime = std::move(value); }

    /**
     *
The date and time that the TrustState was last updated.

     */
    inline Trust& WithStateLastUpdatedDateTime(const Aws::Utils::DateTime& value) { SetStateLastUpdatedDateTime(value); return *this;}

    /**
     *
The date and time that the TrustState was last updated.

     */
    inline Trust& WithStateLastUpdatedDateTime(Aws::Utils::DateTime&& value) { SetStateLastUpdatedDateTime(std::move(value)); return *this;}

    /**
     *
The reason for the TrustState.

     */
    inline const Aws::String& GetTrustStateReason() const{ return m_trustStateReason; }

    /**
     *
The reason for the TrustState.

     */
    inline void SetTrustStateReason(const Aws::String& value) { m_trustStateReasonHasBeenSet = true; m_trustStateReason = value; }

    /**
     *
The reason for the TrustState.

     */
    inline void SetTrustStateReason(Aws::String&& value) { m_trustStateReasonHasBeenSet = true; m_trustStateReason = std::move(value); }

    /**
     *
The reason for the TrustState.

     */
    inline void SetTrustStateReason(const char* value) { m_trustStateReasonHasBeenSet = true; m_trustStateReason.assign(value); }

    /**
     *
The reason for the TrustState.

     */
    inline Trust& WithTrustStateReason(const Aws::String& value) { SetTrustStateReason(value); return *this;}

    /**
     *
The reason for the TrustState.

     */
    inline Trust& WithTrustStateReason(Aws::String&& value) { SetTrustStateReason(std::move(value)); return *this;}

    /**
     *
The reason for the TrustState.

     */
    inline Trust& WithTrustStateReason(const char* value) { SetTrustStateReason(value); return *this;}

  private:
    Aws::String m_directoryId;
    bool m_directoryIdHasBeenSet;
    Aws::String m_trustId;
    bool m_trustIdHasBeenSet;
    Aws::String m_remoteDomainName;
    bool m_remoteDomainNameHasBeenSet;
    TrustType m_trustType;
    bool m_trustTypeHasBeenSet;
    TrustDirection m_trustDirection;
    bool m_trustDirectionHasBeenSet;
    TrustState m_trustState;
    bool m_trustStateHasBeenSet;
    Aws::Utils::DateTime m_createdDateTime;
    bool m_createdDateTimeHasBeenSet;
    Aws::Utils::DateTime m_lastUpdatedDateTime;
    bool m_lastUpdatedDateTimeHasBeenSet;
    Aws::Utils::DateTime m_stateLastUpdatedDateTime;
    bool m_stateLastUpdatedDateTimeHasBeenSet;
    Aws::String m_trustStateReason;
    bool m_trustStateReasonHasBeenSet;
  };

} // namespace Model
} // namespace DirectoryService
} // namespace Aws


text:
<?php

$header = <<<'EOF'
This file is part of PHP Nominatim.
(c) Maxime Hélias <maximehelias16@gmail.com>
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
EOF;

$finder = (new PhpCsFixer\Finder())
    ->in(__DIR__ . '/examples')
    ->in(__DIR__ . '/src')
    ->in(__DIR__ . '/tests')
;

return (new PhpCsFixer\Config())
    ->setRiskyAllowed(true)
    ->setRules([
        '@PhpCsFixer' => true,
        '@PhpCsFixer:risky' => true,
        '@PHP74Migration:risky' => true,
        '@PHPUnit84Migration:risky' => true,
        'date_time_immutable' => true,
        'general_phpdoc_annotation_remove' => [
            'annotations' => [
                'expectedException',
                'expectedExceptionMessage',
                'expectedExceptionMessageRegExp'
            ]
        ],
        'global_namespace_import' => true,
        'header_comment' => [
            'comment_type' => 'PHPDoc',
            'header' => $header,
            'location' => 'after_declare_strict'
        ],
        'linebreak_after_opening_tag' => true,
        'list_syntax' => ['syntax' => 'short'],
        'mb_str_functions' => true,
        'nullable_type_declaration_for_default_null_value' => true,
        'ordered_interfaces' => true,
        'php_unit_strict' => false,
        'phpdoc_line_span' => true,
        'self_static_accessor' => true,
        'simplified_null_return' => true,
    ])
    ->setFinder($finder)
    ->setCacheFile(__DIR__.'/.php_cs.cache');


text:
using Demic.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demic.Managers
{
    interface ILocationManager
    {
        IEnumerable<Location> GetLocations();

        Location StartingLocation { get; }
    }
}


text:
# Copyright 2006 James Tauber and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# iteration from Bob Ippolito's Iteration in JavaScript

# must declare import _before_ importing sys

# FIXME: dynamic=1, async=False, init=True are useless here (?)
def import_module(path, parent_module, module_name, dynamic=1, async=False, init=True):
    JS("""
    module = $pyjs.modules_hash[module_name];
    if (typeof module == 'function' && module.__was_initialized__ == true) {
        return null;
    }
    if (module_name == 'sys' || module_name == 'pyjslib') {
        module();
        return null;
    }
    """)
    module = None
    names = module_name.split(".")
    importName = ''
    # Import all modules in the chain (import a.b.c)
    for name in names:
        importName += name
        JS("""module = $pyjs.modules_hash[importName];""")
        if isUndefined(module):
            raise ImportError("No module named " + importName)
        if JS("module.__was_initialized__ != true"):
            # Module wasn't initialized
            module()
        importName += '.'
    return None

# FIXME: dynamic=1, async=False are useless here (?). Only dynamic modules
# are loaded with load_module and it's always "async"
@noSourceTracking
def load_module(path, parent_module, module_name, dynamic=1, async=False):
    """
    """

    JS("""
        var cache_file;
        var module = $pyjs.modules_hash[module_name];
        if (typeof module == 'function') {
            return true;
        }

        if (!dynamic) {
            // There's no way we can load a none dynamic module
            return false;
        }

        if (path == null)
        {
            path = './';
        }

        var override_name = sys.platform + "." + module_name;
        if (((sys.overrides != null) &&
             (sys.overrides.has_key(override_name))))
        {
            cache_file =  sys.overrides.__getitem__(override_name) ;
        }
        else
        {
            cache_file =  module_name ;
        }

        cache_file = (path + cache_file + '.cache.js' ) ;

        //alert("cache " + cache_file + " " + module_name + " " + parent_module);

        onload_fn = '';

        // this one tacks the script onto the end of the DOM
        pyjs_load_script(cache_file, onload_fn, async);

        try {
            loaded = (typeof $pyjs.modules_hash[module_name] == 'function')
        } catch ( e ) {
        }
        if (loaded) {
            return true;
        }
        return false;
    """)

@noSourceTracking
def load_module_wait(proceed_fn, parent_mod, module_list, dynamic):
    module_list = module_list.getArray()
    JS("""

    var wait_count = 0;
    //var data = '';
    //var element = $doc.createElement("div");
    //element.innerHTML = '';
    //$doc.body.appendChild(element);
    //function write_dom(txt) {
    //    element.innerHTML += txt;
    //}

    var timeoutperiod = 1;
    if (dynamic)
        var timeoutperiod = 1;

    var wait = function() {
        wait_count++;
        //write_dom(".");
        var loaded = true;
        for (var i in module_list) {
            if (typeof $pyjs.modules_hash[module_list[i]] != 'function') {
                loaded = false;
                break;
            }
        }
        if (!loaded) {
            setTimeout(wait, timeoutperiod);
        } else {
            if (proceed_fn.importDone)
                proceed_fn.importDone(proceed_fn);
            else
                proceed_fn();
            //$doc.body.removeChild(element);
        }
    }
    //write_dom("Loading modules ");
    wait();
""")

class Modload:

    # All to-be-imported module names are in app_modlist
    # Since we're only _loading_ the modules here, we can do that in almost
    # any order. There's one limitation: a child/sub module cannot be loaded
    # unless its parent is loaded. It has to be chained in the module list.
    # (1) $pyjs.modules.pyjamas
    # (2) $pyjs.modules.pyjamas.ui
    # (3) $pyjs.modules.pyjamas.ui.Widget
    # Therefore, all modules are collected and sorted on the depth (i.e. the
    # number of dots in it)
    # As long as we don't move on to the next depth unless all modules of the
    # previous depth are loaded, we won't trun into unchainable modules
    # The execution of the module code is done when the import statement is
    # reached, or after loading the modules for the main module.
    @noSourceTracking
    def __init__(self, path, app_modlist, app_imported_fn, dynamic,
                 parent_mod):
        self.app_modlist = app_modlist
        self.app_imported_fn = app_imported_fn
        self.path = path
        self.dynamic = dynamic
        self.parent_mod = parent_mod
        self.modules = {}
        for modlist in self.app_modlist:
            for mod in modlist:
                depth = len(mod.split('.'))
                if not self.modules.has_key(depth):
                    self.modules[depth] = []
                self.modules[depth].append(mod)
        self.depths = self.modules.keys()
        self.depths.sort()
        self.depths.reverse()

    @noSourceTracking
    def next(self):
        if not self.dynamic:
            # All modules are static. Just start the main module.
            self.app_imported_fn()
            return
        depth = self.depths.pop()
        # Initiate the loading of the modules.
        for app in self.modules[depth]:
            load_module(self.path, self.parent_mod, app, self.dynamic, True);

        if len(self.depths) == 0:
            # This is the last depth. Start the main module after loading these
            # modules.
            load_module_wait(self.app_imported_fn, self.parent_mod, self.modules[depth], self.dynamic)
        else:
            # After loading the modules, to the next depth.
            load_module_wait(getattr(self, "next"), self.parent_mod, self.modules[depth], self.dynamic)

def get_module(module_name):
    ev = "__mod = %s;" % module_name
    JS("pyjs_eval(ev);")
    return __mod

def preload_app_modules(path, app_modnames, app_imported_fn, dynamic,
                        parent_mod=None):

    loader = Modload(path, app_modnames, app_imported_fn, dynamic, parent_mod)
    loader.next()

class BaseException:

    message = ''

    def __init__(self, *args):
        self.args = args
        if len(args) == 1:
            self.message = args[0]

    def __getitem__(self, index):
        return self.args.__getitem__(index)

    def __str__(self):
        if len(self.args) is 0:
            return ''
        elif len(self.args) is 1:
            return str(self.message)
        return repr(self.args)

    def __repr__(self):
        return self.__name__ + repr(self.args)

    def toString(self):
        return str(self)

class Exception(BaseException):
    pass

class StandardError(Exception):
    pass

class TypeError(StandardError):
    pass

class AttributeError(StandardError):

    def toString(self):
        return "AttributeError: %s of %s" % (self.args[1], self.args[0])

class NameError(StandardError):
    pass

class ValueError(StandardError):
    pass

class ImportError(StandardError):
    pass

class LookupError(StandardError):

    def toString(self):
        return self.__name__ + ": " + self.args[0]

class KeyError(LookupError):

    def __str__(self):
        if len(self.args) is 0:
            return ''
        elif len(self.args) is 1:
            return repr(self.message)
        return repr(self.args)

class IndexError(LookupError):
    pass

# There seems to be an bug in Chrome with accessing the message
# property, on which an error is thrown
# Hence the declaration of 'var message' and the wrapping in try..catch
def init():
    JS("""
pyjslib._errorMapping = function(err) {
    if (err instanceof(ReferenceError) || err instanceof(TypeError)) {
        var message = ''
        try {
            message = err.message;
        } catch ( e) {
        }
        return pyjslib.AttributeError(message);
    }
    return err
}

pyjslib.TryElse = function () { };
pyjslib.TryElse.prototype = new Error();
pyjslib.TryElse.__name__ = 'TryElse';
pyjslib.TryElse.message = 'TryElse';

pyjslib.StopIteration = function () { };
pyjslib.StopIteration.prototype = new Error();
pyjslib.StopIteration.__name__ = 'StopIteration';
pyjslib.StopIteration.message = 'StopIteration';

pyjslib.String_find = function(sub, start, end) {
    var pos=this.indexOf(sub, start);
    if (pyjslib.isUndefined(end)) return pos;

    if (pos + sub.length>end) return -1;
    return pos;
}

pyjslib.String_join = function(data) {
    var text="";

    if (pyjslib.isArray(data)) {
        return data.join(this);
    }
    else if (pyjslib.isIteratable(data)) {
        var iter=data.__iter__();
        try {
            text+=iter.next();
            while (true) {
                var item=iter.next();
                text+=this + item;
            }
        }
        catch (e) {
            if (e.__name__ != 'StopIteration') throw e;
        }
    }

    return text;
}

pyjslib.String_isdigit = function() {
    return (this.match(/^\d+$/g) != null);
}

pyjslib.String_replace = function(old, replace, count) {
    var do_max=false;
    var start=0;
    var new_str="";
    var pos=0;

    if (!pyjslib.isString(old)) return this.__replace(old, replace);
    if (!pyjslib.isUndefined(count)) do_max=true;

    while (start<this.length) {
        if (do_max && !count--) break;

        pos=this.indexOf(old, start);
        if (pos<0) break;

        new_str+=this.substring(start, pos) + replace;
        start=pos+old.length;
    }
    if (start<this.length) new_str+=this.substring(start);

    return new_str;
}

pyjslib.String_split = function(sep, maxsplit) {
    var items=new pyjslib.List();
    var do_max=false;
    var subject=this;
    var start=0;
    var pos=0;

    if (pyjslib.isUndefined(sep) || pyjslib.isNull(sep)) {
        sep=" ";
        subject=subject.strip();
        subject=subject.replace(/\s+/g, sep);
    }
    else if (!pyjslib.isUndefined(maxsplit)) do_max=true;

    if (subject.length == 0) {
        return items;
    }

    while (start<subject.length) {
        if (do_max && !maxsplit--) break;

        pos=subject.indexOf(sep, start);
        if (pos<0) break;

        items.append(subject.substring(start, pos));
        start=pos+sep.length;
    }
    if (start<=subject.length) items.append(subject.substring(start));

    return items;
}

pyjslib.String___iter__ = function() {
    var i = 0;
    var s = this;
    return {
        'next': function() {
            if (i >= s.length) {
                throw pyjslib.StopIteration;
            }
            return s.substring(i++, i, 1);
        },
        '__iter__': function() {
            return this;
        }
    };
}

pyjslib.String_strip = function(chars) {
    return this.lstrip(chars).rstrip(chars);
}

pyjslib.String_lstrip = function(chars) {
    if (pyjslib.isUndefined(chars)) return this.replace(/^\s+/, "");

    return this.replace(new RegExp("^[" + chars + "]+"), "");
}

pyjslib.String_rstrip = function(chars) {
    if (pyjslib.isUndefined(chars)) return this.replace(/\s+$/, "");

    return this.replace(new RegExp("[" + chars + "]+$"), "");
}

pyjslib.String_startswith = function(prefix, start, end) {
    // FIXME: accept tuples as suffix (since 2.5)
    if (pyjslib.isUndefined(start)) start = 0;
    if (pyjslib.isUndefined(end)) end = this.length;

    if ((end - start) < prefix.length) return false
    if (this.substr(start, prefix.length) == prefix) return true;
    return false;
}

pyjslib.String_endswith = function(suffix, start, end) {
    // FIXME: accept tuples as suffix (since 2.5)
    if (pyjslib.isUndefined(start)) start = 0;
    if (pyjslib.isUndefined(end)) end = this.length;

    if ((end - start) < suffix.length) return false
    if (this.substr(end - suffix.length, suffix.length) == suffix) return true;
    return false;
}

pyjslib.String_ljust = function(width, fillchar) {
    if (typeof(width) != 'number' ||
        parseInt(width) != width) {
        throw (pyjslib.TypeError("an integer is required"));
    }
    if (pyjslib.isUndefined(fillchar)) fillchar = ' ';
    if (typeof(fillchar) != 'string' ||
        fillchar.length != 1) {
        throw (pyjslib.TypeError("ljust() argument 2 must be char, not " + typeof(fillchar)));
    }
    if (this.length >= width) return this;
    return this + new Array(width+1 - this.length).join(fillchar);
}

pyjslib.String_rjust = function(width, fillchar) {
    if (typeof(width) != 'number' ||
        parseInt(width) != width) {
        throw (pyjslib.TypeError("an integer is required"));
    }
    if (pyjslib.isUndefined(fillchar)) fillchar = ' ';
    if (typeof(fillchar) != 'string' ||
        fillchar.length != 1) {
        throw (pyjslib.TypeError("rjust() argument 2 must be char, not " + typeof(fillchar)));
    }
    if (this.length >= width) return this;
    return new Array(width + 1 - this.length).join(fillchar) + this;
}

pyjslib.String_center = function(width, fillchar) {
    if (typeof(width) != 'number' ||
        parseInt(width) != width) {
        throw (pyjslib.TypeError("an integer is required"));
    }
    if (pyjslib.isUndefined(fillchar)) fillchar = ' ';
    if (typeof(fillchar) != 'string' ||
        fillchar.length != 1) {
        throw (pyjslib.TypeError("center() argument 2 must be char, not " + typeof(fillchar)));
    }
    if (this.length >= width) return this;
    padlen = width - this.length
    right = Math.ceil(padlen / 2);
    left = padlen - right;
    return new Array(left+1).join(fillchar) + this + new Array(right+1).join(fillchar);
}

pyjslib.abs = Math.abs;

""")

class Class:
    def __init__(self, name):
        self.name = name

    def __str___(self):
        return self.name

@noSourceTracking
def eq(a,b):
    # All 'python' classes and types are implemented as objects/functions.
    # So, for speed, do a typeof X / X.__cmp__  on a/b.
    # Checking for the existance of .__cmp__ is expensive...
    JS("""
    if (a === null) {
        if (b === null) return true;
        return false;
    }
    if (b === null) {
        return false;
    }
    if ((typeof a == 'object' || typeof a == 'function') && typeof a.__cmp__ == 'function') {
        return a.__cmp__(b) == 0;
    } else if ((typeof b == 'object' || typeof b == 'function') && typeof b.__cmp__ == 'function') {
        return b.__cmp__(a) == 0;
    }
    return a == b;
    """)

@noSourceTracking
def cmp(a,b):
    JS("""
    if (a === null) {
        if (b === null) return 0;
        return -1;
    }
    if (b === null) {
        return 1;
    }
    if ((typeof a == 'object' || typeof a == 'function') && typeof a.__cmp__ == 'function') {
        return a.__cmp__(b);
    } else if ((typeof b == 'object' || typeof b == 'function') && typeof b.__cmp__ == 'function') {
        return -b.__cmp__(a);
    }
    if (a > b) return 1;
    if (b > a) return -1;
    return 0;
    """)

@noSourceTracking
def bool(v):
    # this needs to stay in native code without any dependencies here,
    # because this is used by if and while, we need to prevent
    # recursion
    JS("""
    if (!v) return false;
    switch(typeof v){
    case 'boolean':
        return v;
    case 'object':
        if (v.__nonzero__){
            return v.__nonzero__();
        }else if (v.__len__){
            return v.__len__()>0;
        }
        return true;
    }
    return Boolean(v);
    """)

class List:
    @noSourceTracking
    def __init__(self, data=None):
        JS("""
        this.l = [];
        this.extend(data);
        """)

    @noSourceTracking
    def append(self, item):
        JS("""    this.l[this.l.length] = item;""")

    @noSourceTracking
    def extend(self, data):
        JS("""
        if (pyjslib.isArray(data)) {
            n = this.l.length;
            for (var i=0; i < data.length; i++) {
                this.l[n+i]=data[i];
                }
            }
        else if (pyjslib.isIteratable(data)) {
            var iter=data.__iter__();
            var i=this.l.length;
            try {
                while (true) {
                    var item=iter.next();
                    this.l[i++]=item;
                    }
                }
            catch (e) {
                if (e.__name__ != 'StopIteration') throw e;
                }
            }
        """)

    @noSourceTracking
    def remove(self, value):
        JS("""
        var index=this.index(value);
        if (index<0) return false;
        this.l.splice(index, 1);
        return true;
        """)

    @noSourceTracking
    def index(self, value, start=0):
        JS("""
        var length=this.l.length;
        for (var i=start; i<length; i++) {
            if (this.l[i]==value) {
                return i;
                }
            }
        return -1;
        """)

    @noSourceTracking
    def insert(self, index, value):
        JS("""    var a = this.l; this.l=a.slice(0, index).concat(value, a.slice(index));""")

    @noSourceTracking
    def pop(self, index = -1):
        JS("""
        if (index<0) index = this.l.length + index;
        var a = this.l[index];
        this.l.splice(index, 1);
        return a;
        """)

    @noSourceTracking
    def __cmp__(self, l):
        if not isinstance(l, List):
            return -1
        ll = len(self) - len(l)
        if ll != 0:
            return ll
        for x in range(len(l)):
            ll = cmp(self.__getitem__(x), l[x])
            if ll != 0:
                return ll
        return 0

    @noSourceTracking
    def slice(self, lower, upper):
        JS("""
        if (upper==null) return pyjslib.List(this.l.slice(lower));
        return pyjslib.List(this.l.slice(lower, upper));
        """)

    @noSourceTracking
    def __getitem__(self, index):
        JS("""
        if (index<0) index = this.l.length + index;
        return this.l[index];
        """)

    @noSourceTracking
    def __setitem__(self, index, value):
        JS("""    this.l[index]=value;""")

    @noSourceTracking
    def __delitem__(self, index):
        JS("""    this.l.splice(index, 1);""")

    @noSourceTracking
    def __len__(self):
        JS("""    return this.l.length;""")

    @noSourceTracking
    def __contains__(self, value):
        return self.index(value) >= 0

    @noSourceTracking
    def __iter__(self):
        JS("""
        var i = 0;
        var l = this.l;
        return {
            'next': function() {
                if (i >= l.length) {
                    throw pyjslib.StopIteration;
                }
                return l[i++];
            },
            '__iter__': function() {
                return this;
            }
        };
        """)

    @noSourceTracking
    def reverse(self):
        JS("""    this.l.reverse();""")

    def sort(self, compareFunc=None, keyFunc=None, reverse=False):
        if not compareFunc:
            compareFunc = cmp
        if keyFunc and reverse:
            def thisSort1(a,b):
                return -compareFunc(keyFunc(a), keyFunc(b))
            self.l.sort(thisSort1)
        elif keyFunc:
            def thisSort2(a,b):
                return compareFunc(keyFunc(a), keyFunc(b))
            self.l.sort(thisSort2)
        elif reverse:
            def thisSort3(a,b):
                return -compareFunc(a, b)
            self.l.sort(thisSort3)
        else:
            self.l.sort(compareFunc)

    @noSourceTracking
    def getArray(self):
        """
        Access the javascript Array that is used internally by this list
        """
        return self.l

    @noSourceTracking
    def __str__(self):
        return self.__repr__()

    @noSourceTracking
    def toString(self):
        return self.__repr__()

    def __repr__(self):
        #r = []
        #for item in self:
        #    r.append(repr(item))
        #return '[' + ', '.join(r) + ']'
        JS("""
        var s = "[";
        for (var i=0; i < self.l.length; i++) {
            s += pyjslib.repr(self.l[i]);
            if (i < self.l.length - 1)
                s += ", ";
        };
        s += "]"
        return s;
        """)

class Tuple:
    @noSourceTracking
    def __init__(self, data=None):
        JS("""
        this.l = [];
        this.extend(data);
        """)

    @noSourceTracking
    def append(self, item):
        JS("""    this.l[this.l.length] = item;""")

    @noSourceTracking
    def extend(self, data):
        JS("""
        if (pyjslib.isArray(data)) {
            n = this.l.length;
            for (var i=0; i < data.length; i++) {
                this.l[n+i]=data[i];
                }
            }
        else if (pyjslib.isIteratable(data)) {
            var iter=data.__iter__();
            var i=this.l.length;
            try {
                while (true) {
                    var item=iter.next();
                    this.l[i++]=item;
                    }
                }
            catch (e) {
                if (e.__name__ != 'StopIteration') throw e;
                }
            }
        """)

    @noSourceTracking
    def remove(self, value):
        JS("""
        var index=this.index(value);
        if (index<0) return false;
        this.l.splice(index, 1);
        return true;
        """)

    @noSourceTracking
    def index(self, value, start=0):
        JS("""
        var length=this.l.length;
        for (var i=start; i<length; i++) {
            if (this.l[i]==value) {
                return i;
                }
            }
        return -1;
        """)

    @noSourceTracking
    def insert(self, index, value):
        JS("""    var a = this.l; this.l=a.slice(0, index).concat(value, a.slice(index));""")

    @noSourceTracking
    def pop(self, index = -1):
        JS("""
        if (index<0) index = this.l.length + index;
        var a = this.l[index];
        this.l.splice(index, 1);
        return a;
        """)

    @noSourceTracking
    def __cmp__(self, l):
        if not isinstance(l, Tuple):
            return 1
        ll = len(self) - len(l)
        if ll != 0:
            return ll
        for x in range(len(l)):
            ll = cmp(self.__getitem__(x), l[x])
            if ll != 0:
                return ll
        return 0

    @noSourceTracking
    def slice(self, lower, upper):
        JS("""
        if (upper==null) return pyjslib.Tuple(this.l.slice(lower));
        return pyjslib.Tuple(this.l.slice(lower, upper));
        """)

    @noSourceTracking
    def __getitem__(self, index):
        JS("""
        if (index<0) index = this.l.length + index;
        return this.l[index];
        """)

    @noSourceTracking
    def __setitem__(self, index, value):
        JS("""    this.l[index]=value;""")

    @noSourceTracking
    def __delitem__(self, index):
        JS("""    this.l.splice(index, 1);""")

    @noSourceTracking
    def __len__(self):
        JS("""    return this.l.length;""")

    @noSourceTracking
    def __contains__(self, value):
        return self.index(value) >= 0

    @noSourceTracking
    def __iter__(self):
        JS("""
        var i = 0;
        var l = this.l;
        return {
            'next': function() {
                if (i >= l.length) {
                    throw pyjslib.StopIteration;
                }
                return l[i++];
            },
            '__iter__': function() {
                return this;
            }
        };
        """)

    @noSourceTracking
    def reverse(self):
        JS("""    this.l.reverse();""")

    def sort(self, compareFunc=None, keyFunc=None, reverse=False):
        if not compareFunc:
            compareFunc = cmp
        if keyFunc and reverse:
            def thisSort1(a,b):
                return -compareFunc(keyFunc(a), keyFunc(b))
            self.l.sort(thisSort1)
        elif keyFunc:
            def thisSort2(a,b):
                return compareFunc(keyFunc(a), keyFunc(b))
            self.l.sort(thisSort2)
        elif reverse:
            def thisSort3(a,b):
                return -compareFunc(a, b)
            self.l.sort(thisSort3)
        else:
            self.l.sort(compareFunc)

    @noSourceTracking
    def getArray(self):
        """
        Access the javascript Array that is used internally by this list
        """
        return self.l

    @noSourceTracking
    def __str__(self):
        return self.__repr__()

    @noSourceTracking
    def toString(self):
        return self.__repr__()

    def __repr__(self):
        #r = []
        #for item in self:
        #    r.append(repr(item))
        #if len(r) == 1:
        #    return '(' + ', '.join(r) + ',)'
        #return '(' + ', '.join(r) + ')'
        JS("""
        var s = "(";
        for (var i=0; i < self.l.length; i++) {
            s += pyjslib.repr(self.l[i]);
            if (i < self.l.length - 1)
                s += ", ";
        };
        if (self.l.length == 1)
            s += ",";
        s += ")"
        return s;
        """)

class Dict:
    @noSourceTracking
    def __init__(self, data=None):
        JS("""
        this.d = {};

        if (pyjslib.isArray(data)) {
            for (var i in data) {
                var item=data[i];
                this.__setitem__(item[0], item[1]);
                //var sKey=pyjslib.hash(item[0]);
                //this.d[sKey]=item[1];
                }
            }
        else if (pyjslib.isIteratable(data)) {
            var iter=data.__iter__();
            try {
                while (true) {
                    var item=iter.next();
                    this.__setitem__(item.__getitem__(0), item.__getitem__(1));
                    }
                }
            catch (e) {
                if (e.__name__ != 'StopIteration') throw e;
                }
            }
        else if (pyjslib.isObject(data)) {
            for (var key in data) {
                this.__setitem__(key, data[key]);
                }
            }
        """)

    @noSourceTracking
    def __setitem__(self, key, value):
        JS("""
        var sKey = pyjslib.hash(key);
        this.d[sKey]=[key, value];
        """)

    @noSourceTracking
    def __getitem__(self, key):
        JS("""
        var sKey = pyjslib.hash(key);
        var value=this.d[sKey];
        if (pyjslib.isUndefined(value)){
            throw pyjslib.KeyError(key);
        }
        return value[1];
        """)

    @noSourceTracking
    def __nonzero__(self):
        JS("""
        for (var i in this.d){
            return true;
        }
        return false;
        """)

    @noSourceTracking
    def __len__(self):
        JS("""
        var size=0;
        for (var i in this.d) size++;
        return size;
        """)

    @noSourceTracking
    def has_key(self, key):
        return self.__contains__(key)

    @noSourceTracking
    def __delitem__(self, key):
        JS("""
        var sKey = pyjslib.hash(key);
        delete this.d[sKey];
        """)

    @noSourceTracking
    def __contains__(self, key):
        JS("""
        var sKey = pyjslib.hash(key);
        return (pyjslib.isUndefined(this.d[sKey])) ? false : true;
        """)

    @noSourceTracking
    def keys(self):
        JS("""
        var keys=new pyjslib.List();
        for (var key in this.d) {
            keys.append(this.d[key][0]);
        }
        return keys;
        """)

    @noSourceTracking
    def values(self):
        JS("""
        var values=new pyjslib.List();
        for (var key in this.d) values.append(this.d[key][1]);
        return values;
        """)

    @noSourceTracking
    def items(self):
        JS("""
        var items = new pyjslib.List();
        for (var key in this.d) {
          var kv = this.d[key];
          items.append(new pyjslib.List(kv))
          }
          return items;
        """)

    @noSourceTracking
    def __iter__(self):
        return self.keys().__iter__()

    @noSourceTracking
    def iterkeys(self):
        return self.__iter__()

    @noSourceTracking
    def itervalues(self):
        return self.values().__iter__();

    @noSourceTracking
    def iteritems(self):
        return self.items().__iter__();

    @noSourceTracking
    def setdefault(self, key, default_value):
        if not self.has_key(key):
            self[key] = default_value
        return self[key]

    @noSourceTracking
    def get(self, key, default_value=None):
        if not self.has_key(key):
            return default_value
        return self[key]

    @noSourceTracking
    def update(self, d):
        for k,v in d.iteritems():
            self[k] = v

    @noSourceTracking
    def getObject(self):
        """
        Return the javascript Object which this class uses to store
        dictionary keys and values
        """
        return self.d

    @noSourceTracking
    def copy(self):
        return Dict(self.items())

    @noSourceTracking
    def __str__(self):
        return self.__repr__()

    @noSourceTracking
    def toString(self):
        return self.__repr__()

    def __repr__(self):
        #r = []
        #for item in self:
        #    r.append(repr(item) + ': ' + repr(self[item]))
        #return '{' + ', '.join(r) + '}'
        JS("""
        var keys = new Array();
        for (var key in self.d)
            keys.push(key);

        var s = "{";
        for (var i=0; i<keys.length; i++) {
            var v = self.d[keys[i]]
            s += pyjslib.repr(v[0]) + ": " + pyjslib.repr(v[1]);
            if (i < keys.length-1)
                s += ", "
        };
        s += "}";
        return s;
        """)

# IE6 doesn't like pyjslib.super
@noSourceTracking
def _super(type_, object_or_type = None):
    # This is a partially implementation: only super(type, object)
    if not _issubtype(object_or_type, type_):
        raise TypeError("super(type, obj): obj must be an instance or subtype of type")
    JS("""
    var fn = pyjs_type('super', type_.__mro__.slice(1), {})
    fn.__new__ = fn.__mro__[1].__new__;
    fn.__init__ = fn.__mro__[1].__init__;
    if (object_or_type.__is_instance__ === false) {
        return fn;
    }
    var obj = new Object();
    function wrapper(obj, name) {
        var fnwrap = function() {
            var args = [];
            for (var i = 0; i < arguments.length; i++) {
              args.push(arguments[i]);
            }
            return obj[name].apply(object_or_type,args);
        }
        fnwrap.__name__ = name;
        fnwrap.parse_kwargs = obj.parse_kwargs;
        return fnwrap;
    }
    for (var m in fn) {
        if (typeof fn[m] == 'function') {
            obj[m] = wrapper(fn, m);
        }
    }
    return obj;
    """)

# taken from mochikit: range( [start,] stop[, step] )
@noSourceTracking
def range(start, stop = None, step = 1):
    if stop is None:
        stop = start
        start = 0
    JS("""
/*
    var start = 0;
    var stop = 0;
    var step = 1;

    if (arguments.length == 2) {
        start = arguments[0];
        stop = arguments[1];
        }
    else if (arguments.length == 3) {
        start = arguments[0];
        stop = arguments[1];
        step = arguments[2];
        }
    else if (arguments.length>0) stop = arguments[0];
*/
    return {
        'next': function() {
            if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) throw pyjslib.StopIteration;
            var rval = start;
            start += step;
            return rval;
            },
        '__iter__': function() {
            return this;
            }
        }
    """)

@noSourceTracking
def slice(object, lower, upper):
    JS("""
    if (pyjslib.isString(object)) {
        if (lower < 0) {
           lower = object.length + lower;
        }
        if (upper < 0) {
           upper = object.length + upper;
        }
        if (pyjslib.isNull(upper)) upper=object.length;
        return object.substring(lower, upper);
    }
    if (pyjslib.isObject(object) && object.slice)
        return object.slice(lower, upper);

    return null;
    """)

@noSourceTracking
def str(text):
    JS("""
    if (pyjslib.hasattr(text,"__str__")) {
        return text.__str__();
    }
    return String(text);
    """)

@noSourceTracking
def ord(x):
    if(isString(x) and len(x) is 1):
        JS("""
            return x.charCodeAt(0);
        """)
    else:
        JS("""
            throw pyjslib.TypeError();
        """)
    return None

@noSourceTracking
def chr(x):
    JS("""
        return String.fromCharCode(x)
    """)

@noSourceTracking
def is_basetype(x):
    JS("""
       var t = typeof(x);
       return t == 'boolean' ||
       t == 'function' ||
       t == 'number' ||
       t == 'string' ||
       t == 'undefined'
       ;
    """)

@noSourceTracking
def get_pyjs_classtype(x):
    JS("""
        if (pyjslib.hasattr(x, "__is_instance__")) {
            var src = x.__name__;
            return src;
        }
        return null;
    """)

@noSourceTracking
def repr(x):
    """ Return the string representation of 'x'.
    """
    if hasattr(x, '__repr__'):
        return x.__repr__()
    JS("""
       if (x === null)
           return "null";

       if (x === undefined)
           return "undefined";

       var t = typeof(x);

        //alert("repr typeof " + t + " : " + x);

       if (t == "boolean")
           return x.toString();

       if (t == "function")
           return "<function " + x.toString() + ">";

       if (t == "number")
           return x.toString();

       if (t == "string") {
           if (x.indexOf("'") == -1)
               return "'" + x + "'";
           if (x.indexOf('"') == -1)
               return '"' + x + '"';
           var s = x.replace(new RegExp('"', "g"), '\\\\"');
           return '"' + s + '"';
       };

       if (t == "undefined")
           return "undefined";

       // If we get here, x is an object.  See if it's a Pyjamas class.

       if (!pyjslib.hasattr(x, "__init__"))
           return "<" + x.toString() + ">";

       // Handle the common Pyjamas data types.

       var constructor = "UNKNOWN";

       constructor = pyjslib.get_pyjs_classtype(x);

        //alert("repr constructor: " + constructor);

       // If we get here, the class isn't one we know -> return the class name.
       // Note that we replace underscores with dots so that the name will
       // (hopefully!) look like the original Python name.

       //var s = constructor.replace(new RegExp('_', "g"), '.');
       return "<" + constructor + " object>";
    """)

@noSourceTracking
def float(text):
    JS("""
    return parseFloat(text);
    """)

@noSourceTracking
def int(text, radix=0):
    JS("""
    var i = parseInt(text, radix);
    if (!isNaN(i)) {
        return i;
    }
    """)
    if radix == 0:
        radix = 10
    raise ValueError("invalid literal for int() with base %d: '%s'" % (radix, text))

@noSourceTracking
def len(object):
    JS("""
    if (object==null) return 0;
    if (pyjslib.isObject(object) && object.__len__) return object.__len__();
    return object.length;
    """)

@noSourceTracking
def isinstance(object_, classinfo):
    if pyjslib.isUndefined(object_):
        return False
    JS("""if (classinfo.__name__ == 'int') {
            return pyjslib.isNumber(object_); /* XXX TODO: check rounded? */
            }
        """)
    JS("""if (classinfo.__name__ == 'str') {
            return pyjslib.isString(object_);
            }
        """)
    if not pyjslib.isObject(object_):
        return False
    if _isinstance(classinfo, Tuple):
        for ci in classinfo:
            if isinstance(object_, ci):
                return True
        return False
    else:
        return _isinstance(object_, classinfo)

@noSourceTracking
def _isinstance(object_, classinfo):
    JS("""
    if (object_.__is_instance__ !== true) {
        return false;
    }
    for (var c in object_.__mro__) {
        if (object_.__mro__[c].__md5__ == classinfo.prototype.__md5__) return true;
    }
    return false;
    """)

@noSourceTracking
def _issubtype(object_, classinfo):
    JS("""
    if (object_.__is_instance__ == null || classinfo.__is_instance__ == null) {
        return false;
    }
    for (var c in object_.__mro__) {
        if (object_.__mro__[c] == classinfo.prototype) return true;
    }
    return false;
    """)

@noSourceTracking
def getattr(obj, name, default_value=None):
    JS("""
    if ((!pyjslib.isObject(obj))||(pyjslib.isUndefined(obj[name]))){
        if (arguments.length != 3){
            throw pyjslib.AttributeError(obj, name);
        }else{
        return default_value;
        }
    }
    if (!pyjslib.isFunction(obj[name])) return obj[name];
    var method = obj[name];
    var fnwrap = function() {
        var args = [];
        for (var i = 0; i < arguments.length; i++) {
          args.push(arguments[i]);
        }
        return method.apply(obj,args);
    }
    fnwrap.__name__ = name;
    fnwrap.parse_kwargs = obj.parse_kwargs;
    return fnwrap;
    """)

@noSourceTracking
def delattr(obj, name):
    JS("""
    if (!pyjslib.isObject(obj)) {
       throw pyjslib.AttributeError("'"+typeof(obj)+"' object has no attribute '"+name+"%s'")
    }
    if ((pyjslib.isUndefined(obj[name])) ||(typeof(obj[name]) == "function") ){
        throw pyjslib.AttributeError(obj.__name__+" instance has no attribute '"+ name+"'");
    }
    delete obj[name];
    """)

@noSourceTracking
def setattr(obj, name, value):
    JS("""
    if (!pyjslib.isObject(obj)) return null;

    obj[name] = value;

    """)

@noSourceTracking
def hasattr(obj, name):
    JS("""
    if (!pyjslib.isObject(obj)) return false;
    if (pyjslib.isUndefined(obj[name])) return false;

    return true;
    """)

@noSourceTracking
def dir(obj):
    JS("""
    var properties=new pyjslib.List();
    for (property in obj) properties.append(property);
    return properties;
    """)

@noSourceTracking
def filter(obj, method, sequence=None):
    # object context is LOST when a method is passed, hence object must be passed separately
    # to emulate python behaviour, should generate this code inline rather than as a function call
    items = []
    if sequence is None:
        sequence = method
        method = obj

        for item in sequence:
            if method(item):
                items.append(item)
    else:
        for item in sequence:
            if method.call(obj, item):
                items.append(item)

    return items

@noSourceTracking
def map(obj, method, sequence=None):
    items = []

    if sequence is None:
        sequence = method
        method = obj

        for item in sequence:
            items.append(method(item))
    else:
        for item in sequence:
            items.append(method.call(obj, item))

    return items

def enumerate(sequence):
    enumeration = []
    nextIndex = 0
    for item in sequence:
        enumeration.append([nextIndex, item])
        nextIndex = nextIndex + 1
    return enumeration

def min(*sequence):
    if len(sequence) == 1:
        sequence = sequence[0]
    minValue = None
    for item in sequence:
        if minValue is None:
            minValue = item
        elif cmp(item, minValue) == -1:
            minValue = item
    return minValue

def max(*sequence):
    if len(sequence) == 1:
        sequence = sequence[0]
    maxValue = None
    for item in sequence:
        if maxValue is None:
            maxValue = item
        elif cmp(item, maxValue) == 1:
            maxValue = item
    return maxValue

@noSourceTracking
def hash(obj):
    JS("""
    if (obj == null) return null;

    if (obj.$H) return obj.$H;
    if (obj.__hash__) return obj.__hash__();
    if (obj.constructor == String || obj.constructor == Number || obj.constructor == Date) return obj;

    obj.$H = ++pyjslib.next_hash_id;
    return obj.$H;
    """)

# type functions from Douglas Crockford's Remedial Javascript: http://www.crockford.com/javascript/remedial.html
@noSourceTracking
def isObject(a):
    JS("""
    return (a != null && (typeof a == 'object')) || pyjslib.isFunction(a);
    """)

@noSourceTracking
def isFunction(a):
    JS("""
    return typeof a == 'function';
    """)

@noSourceTracking
def isString(a):
    JS("""
    return typeof a == 'string';
    """)

@noSourceTracking
def isNull(a):
    JS("""
    return typeof a == 'object' && !a;
    """)

@noSourceTracking
def isArray(a):
    JS("""
    return pyjslib.isObject(a) && a.constructor == Array;
    """)

@noSourceTracking
def isUndefined(a):
    JS("""
    return typeof a == 'undefined';
    """)

@noSourceTracking
def isIteratable(a):
    JS("""
    return pyjslib.isString(a) || (pyjslib.isObject(a) && a.__iter__);
    """)

@noSourceTracking
def isNumber(a):
    JS("""
    return typeof a == 'number' && isFinite(a);
    """)

@noSourceTracking
def toJSObjects(x):
    """
       Convert the pyjs pythonic List and Dict objects into javascript Object and Array
       objects, recursively.
    """
    if isArray(x):
        JS("""
        var result = [];
        for(var k=0; k < x.length; k++) {
           var v = x[k];
           var tv = pyjslib.toJSObjects(v);
           result.push(tv);
        }
        return result;
        """)
    if isObject(x):
        if isinstance(x, Dict):
            JS("""
            var o = x.getObject();
            var result = {};
            for (var i in o) {
               result[o[i][0].toString()] = o[i][1];
            }
            return pyjslib.toJSObjects(result)
            """)
        elif isinstance(x, List):
            return toJSObjects(x.l)
        elif hasattr(x, '__class__'):
            # we do not have a special implementation for custom
            # classes, just pass it on
            return x
    if isObject(x):
        JS("""
        var result = {};
        for(var k in x) {
            var v = x[k];
            var tv = pyjslib.toJSObjects(v)
            result[k] = tv;
            }
            return result;
         """)
    return x

@noSourceTracking
def sprintf(strng, args):
    # See http://docs.python.org/library/stdtypes.html
    constructor = get_pyjs_classtype(args)
    JS("""
    var re_dict = /([^%]*)%[(]([^)]+)[)]([#0\x20\0x2B-]*)(\d+)?(\.\d+)?[hlL]?(.)((.|\\n)*)/;
    var re_list = /([^%]*)%([#0\x20\x2B-]*)(\*|(\d+))?(\.\d+)?[hlL]?(.)((.|\\n)*)/;
    var re_exp = /(.*)([+-])(.*)/;
""")
    strlen = len(strng)
    argidx = 0
    nargs = 0
    result = []
    remainder = strng

    def next_arg():
        if argidx == nargs:
            raise TypeError("not enough arguments for format string")
        arg = args[argidx]
        argidx += 1
        return arg

    def formatarg(flags, minlen, precision, conversion, param):
            subst = ''
            numeric = True
            if not minlen:
                minlen=0
            else:
                minlen = int(minlen)
            if not precision:
                precision = None
            else:
                precision = int(precision)
            left_padding = 1
            if flags.find('-') >= 0:
                left_padding = 0
            if conversion == '%':
                numeric = False
                subst = '%'
            elif conversion == 'c':
                numeric = False
                subst = chr(int(param))
            elif conversion == 'd' or conversion == 'i' or conversion == 'u':
                subst = str(int(param))
            elif conversion == 'e':
                if precision is None:
                    precision = 6
                JS("""
                subst = re_exp.exec(String(param.toExponential(precision)));
                if (subst[3].length == 1) {
        	    subst = subst[1] + subst[2] + '0' + subst[3];
		} else {
        	    subst = subst[1] + subst[2] + subst[3];
		}""")
            elif conversion == 'E':
                if precision is None:
                    precision = 6
                JS("""
                subst = re_exp.exec(String(param.toExponential(precision)).toUpperCase());
                if (subst[3].length == 1) {
        	    subst = subst[1] + subst[2] + '0' + subst[3];
		} else {
        	    subst = subst[1] + subst[2] + subst[3];
		}""")
            elif conversion == 'f':
                if precision is None:
                    precision = 6
                JS("""
                subst = String(parseFloat(param).toFixed(precision));""")
            elif conversion == 'F':
                if precision is None:
                    precision = 6
                JS("""
                subst = String(parseFloat(param).toFixed(precision)).toUpperCase();""")
            elif conversion == 'g':
                if flags.find('#') >= 0:
                    if precision is None:
                        precision = 6
                if param >= 1E6 or param < 1E-5:
                    JS("""
                    subst = String(precision == null ? param.toExponential() : param.toExponential().toPrecision(precision));""")
                else:
                    JS("""
                    subst = String(precision == null ? parseFloat(param) : parseFloat(param).toPrecision(precision));""")
            elif conversion == 'G':
                if flags.find('#') >= 0:
                    if precision is None:
                        precision = 6
                if param >= 1E6 or param < 1E-5:
                    JS("""
                    subst = String(precision == null ? param.toExponential() : param.toExponential().toPrecision(precision)).toUpperCase();""")
                else:
                    JS("""
                    subst = String(precision == null ? parseFloat(param) : parseFloat(param).toPrecision(precision)).toUpperCase().toUpperCase();""")
            elif conversion == 'r':
                numeric = False
                subst = repr(param)
            elif conversion == 's':
                numeric = False
                subst = str(param)
            elif conversion == 'o':
                param = int(param)
                JS("""
                subst = param.toString(8);""")
                if flags.find('#') >= 0 and subst != '0':
                    subst = '0' + subst
            elif conversion == 'x':
                param = int(param)
                JS("""
                subst = param.toString(16);""")
                if flags.find('#') >= 0:
                    if left_padding:
                        subst = subst.rjust(minlen - 2, '0')
                    subst = '0x' + subst
            elif conversion == 'X':
                param = int(param)
                JS("""
                subst = param.toString(16).toUpperCase();""")
                if flags.find('#') >= 0:
                    if left_padding:
                        subst = subst.rjust(minlen - 2, '0')
                    subst = '0X' + subst
            else:
                raise ValueError("unsupported format character '" + conversion + "' ("+hex(ord(conversion))+") at index " + (strlen - len(remainder) - 1))
            if minlen and len(subst) < minlen:
                padchar = ' '
                if numeric and left_padding and flags.find('0') >= 0:
                    padchar = '0'
                if left_padding:
                    subst = subst.rjust(minlen, padchar)
                else:
                    subst = subst.ljust(minlen, padchar)
            return subst

    def sprintf_list(strng, args):
        while remainder:
            JS("""
            var a = re_list.exec(remainder);""")
            if a is None:
                result.append(remainder)
                break;
            JS("""
            var left = a[1], flags = a[2];
            var minlen = a[3], precision = a[5], conversion = a[6];
            remainder = a[7];
            if (typeof minlen == 'undefined') minlen = null;
            if (typeof precision == 'undefined') precision = null;
            if (typeof conversion == 'undefined') conversion = null;
""")
            result.append(left)
            if minlen == '*':
                minlen = next_arg()
                JS("var minlen_type = typeof(minlen);")
                if minlen_type != 'number' or \
                   int(minlen) != minlen:
                    raise TypeError('* wants int')
            if conversion != '%':
                param = next_arg()
            result.append(formatarg(flags, minlen, precision, conversion, param))

    def sprintf_dict(strng, args):
        arg = args
        argidx += 1
        while remainder:
            JS("""
            var a = re_dict.exec(remainder);""")
            if a is None:
                result.append(remainder)
                break;
            JS("""
            var left = a[1], key = a[2], flags = a[3];
            var minlen = a[4], precision = a[5], conversion = a[6];
            remainder = a[7];
            if (typeof minlen == 'undefined') minlen = null;
            if (typeof precision == 'undefined') precision = null;
            if (typeof conversion == 'undefined') conversion = null;
""")
            result.append(left)
            if not arg.has_key(key):
                raise KeyError(key)
            else:
                param = arg[key]
            result.append(formatarg(flags, minlen, precision, conversion, param))

    JS("""
    var a = re_dict.exec(strng);
""")
    if a is None:
        if constructor != "Tuple":
            args = (args,)
        nargs = len(args)
        sprintf_list(strng, args)
        if argidx != nargs:
            raise TypeError('not all arguments converted during string formatting')
    else:
        if constructor != "Dict":
            raise TypeError("format requires a mapping")
        sprintf_dict(strng, args)
    return ''.join(result)

@noSourceTracking
def printFunc(objs, newline):
    JS("""
    if ($wnd.console==undefined)  return;
    var s = "";
    for(var i=0; i < objs.length; i++) {
        if(s != "") s += " ";
        s += objs[i];
    }
    console.debug(s)
    """)

@noSourceTracking
def type(clsname, bases=None, methods=None):
    """ creates a class, derived from bases, with methods and variables
    """

    JS(" var mths = {}; ")
    if methods:
        for k in methods.keys():
            mth = methods[k]
            JS(" mths[k] = mth; ")

    JS(" var bss = null; ")
    if bases:
        JS("bss = bases.l;")
    JS(" return pyjs_type(clsname, bss, mths); ")

def pow(x, y, z = None):
    JS("p = Math.pow(x, y);")
    if z is None:
        return float(p)
    return float(p % z)

def hex(x):
    if int(x) != x:
        raise TypeError("hex() argument can't be converted to hex")
    JS("r = '0x'+x.toString(16);")
    return str(r)

def oct(x):
    if int(x) != x:
        raise TypeError("oct() argument can't be converted to oct")
    JS("r = '0'+x.toString(8);")
    return str(r)

def round(x, n = 0):
    n = pow(10, n)
    JS("r = Math.round(n*x)/n;")
    return float(r)

def divmod(x, y):
    if int(x) == x and int(y) == y:
        return (int(x / y), int(x % y))
    JS("f = Math.floor(x / y);")
    f = float(f)
    return (f, x - f * y)

def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

def any(iterable):
    for element in iterable:
        if element:
            return True
    return False


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Agaricus epichysium Pers., 1794

### Remarks
null


text:
declare function mergeObjects<T extends object, U extends object>(object1: T, object2: U): T & U;

export = mergeObjects;


text:
ACCEPTED

#### According to
International Plant Names Index

#### Published in
null

#### Original name
Sulcorebutia tiraquensis var. renatae Hentzschel & S.Beck

### Remarks
null


text:
package com.signalcollect

trait SumOfOutWeights[Id, State] extends AbstractVertex[Id, State] {

  /**
   * @return The sum of the weights of all outgoing edges.
   */
  var sumOfOutWeights: Double = 0

  abstract override def addEdge(e: Edge[_], graphEditor: GraphEditor[Any, Any]): Boolean = {
    val added = super.addEdge(e, graphEditor)
    if (added) {
      sumOfOutWeights += e.weight
    }
    added
  }

  abstract override def removeEdge(targetId: Any, graphEditor: GraphEditor[Any, Any]): Boolean = {
    val outgoingEdge = outgoingEdges.get(targetId)
    val weightToSubtract = outgoingEdge match {
      case None => 0
      case Some(edge) => edge.weight
    }
    val removed = super.removeEdge(targetId, graphEditor)
    if (removed) {
      sumOfOutWeights -= weightToSubtract
    }
    removed
  }

}


text:
package com.cloud.network;

import com.cloud.acl.ControlledEntity;
import com.cloud.api.Identity;
import com.cloud.api.InternalIdentity;

/**
 * Nic represents one nic on the VM.
 */
public interface MonitoringService extends ControlledEntity, Identity, InternalIdentity {
    @Override
    long getId();

    String getService();

    String getServiceName();

    String getServicePidFile();

    String getServicePath();

    /**
     * @return id in the CloudStack database
     */
    enum Service {
        Dhcp, LoadBalancing, Ssh, Webserver,
    }
}


text:
Imports System.Runtime.Serialization
Imports System.ComponentModel

<Serializable()> _
Public Class Section
    Inherits GenericObject
    Implements ISerializable, ISelfValidate

#Region "Shared properties"

    Public Shared MaxDataBaseID As Integer = 0

#End Region

#Region "Generic section properties"

    Private _shortName As String = ""

    'Short name Property.
    <CategoryAttribute("(Main)"), _
    DefaultValueAttribute(""), _
    DisplayName("Short name"), _
    DescriptionAttribute("Indicates the short name of the section.")> _
    Public Property ShortName() As String
        Get
            Return _shortName
        End Get
        Set(ByVal value As String)
            _shortName = BO.GenericObject.CheckIdentifier(value)
        End Set
    End Property

    <[ReadOnly](True), _
    CategoryAttribute("System Information")> _
    Public ReadOnly Property QuestionnaireSetID() As Integer
        Get
            If Me.Parent IsNot Nothing AndAlso Me.Parent.Parent IsNot Nothing Then
                Return Me.Parent.Parent.DataBaseID
            Else
                Return "N/A"
            End If
        End Get
    End Property

    <[ReadOnly](True), _
    CategoryAttribute("System Information")> _
    Public ReadOnly Property QuestionnaireID() As Integer
        Get
            If Me.Parent IsNot Nothing Then
                Return Me.Parent.DataBaseID
            Else
                Return "N/A"
            End If
        End Get
    End Property

    <[ReadOnly](True), _
        CategoryAttribute("System Information")> _
        Public ReadOnly Property SectionID() As Integer
        Get
            Return Me.DataBaseID
        End Get
    End Property

#End Region

#Region "PDA settings properties"

    Private _modifiable As Boolean = False
    Private _preCondition As String = ""
    Private _onNewRecord As String = Nothing

    ' Modifiable property.
    <CategoryAttribute("PDA settings"), _
    DefaultValueAttribute(True), _
    DisplayName("Modifiable"), _
    DescriptionAttribute("Indicates if the section can be edited or modified.")> _
    Public Property Modifiable() As Boolean
        Get
            Return _modifiable
        End Get
        Set(ByVal value As Boolean)
            _modifiable = value
        End Set
    End Property

    ' Precondition property.
    <CategoryAttribute("PDA settings"), _
    DisplayName("Precondition"), _
    DescriptionAttribute("Sets the condition to set the questionnaire avialible or not."), _
    EditorAttribute(GetType(CodeEditor), GetType(System.Drawing.Design.UITypeEditor))> _
    Public Property PreCondition() As String
        Get
            Return _preCondition
        End Get
        Set(ByVal value As String)
            If value IsNot Nothing Then
                _preCondition = value.Trim
            Else
                _preCondition = Nothing
            End If
        End Set
    End Property

    ' OnNewRecordProcedureID property.
    <CategoryAttribute("PDA settings"), _
    DisplayName("OnNewRecordProcedureID"), _
    DescriptionAttribute("ID of the procedure to execute when a new record is created.")> _
    Public Property OnNewRecord() As String
        Get
            Return _onNewRecord
        End Get
        Set(ByVal value As String)
            _onNewRecord = value
        End Set
    End Property

#End Region

#Region "Child properties"

    Private _variables As New List(Of Variable)
    Private _sectionItems As New List(Of SectionItem)

    ' Variables Property.
    <BrowsableAttribute(False)> _
    Public Overrides Property Variables() As List(Of Variable)
        Get
            Return _variables
        End Get
        Set(ByVal value As List(Of Variable))
            _variables = value
        End Set
    End Property

    ' Phases Property.
    <BrowsableAttribute(False)> _
    Public Overrides ReadOnly Property SectionItems() As List(Of SectionItem)
        Get
            Return _sectionItems
        End Get
    End Property

    ' Phases Property.
    <BrowsableAttribute(False)> _
    Public ReadOnly Property Phase(ByVal index As Integer) As SectionItem
        Get
            Return _sectionItems(index)
        End Get
    End Property

#End Region

#Region "Generic Object properties"

    ' HasSectionItems property
    <BrowsableAttribute(False)> _
    Public Overrides ReadOnly Property HasSectionItems() As Boolean
        Get
            Return True
        End Get
    End Property

    ' HasVariables property
    <BrowsableAttribute(False)> _
    Public Overrides ReadOnly Property HasVariables() As Boolean
        Get
            Return True
        End Get
    End Property

#End Region

#Region "Methods"

    ' Constructor.
    Public Sub New(Optional ByVal id As Integer = 0)

        ' Si no trae id valido asignarle uno y actualizar el maximo.
        Me.DataBaseID = IIf(id > 0, id, MaxDataBaseID + 1)
        MaxDataBaseID = IIf(DataBaseID > MaxDataBaseID, DataBaseID, MaxDataBaseID)

        ' Set name.
        Me.Name = "Section " & Me.DataBaseID

    End Sub

    ' ToString.
    Public Overrides Function ToString() As String
        Return Me.Name
    End Function

    ' Finds the diferences between two sections.
    Public Overrides Function Difference(ByVal genericObject As GenericObject) As GenericObject

        ' Check types.
        If Not genericObject.GetType.Equals(GetType(Section)) Then Return Nothing

        ' Create the object.
        Dim result As New Section(0)
        Dim section As Section = genericObject
        Dim changed As Boolean = False

        ' Generic object properties.
        result.SetGuidWithoutHash(Nothing)

        If Me.Name <> section.Name Then
            result.Name = Me.Name
            changed = True
        Else
            result.Name = Nothing
        End If

        If Me.Comment <> section.Comment Then
            result.Comment = Me.Comment
            changed = True
        Else
            result.Comment = Nothing
        End If

        result.DataBaseID = Nothing

        ' Section properties.
        If Me.ShortName <> section.ShortName Then
            result.ShortName = Me.ShortName
            changed = True
        Else
            result.ShortName = Nothing
        End If

        If Me.Modifiable <> section.Modifiable Then
            result.Modifiable = Me.Modifiable
            changed = True
        Else
            result.Modifiable = Nothing
        End If

        If Me.PreCondition <> section.PreCondition Then
            result.PreCondition = Me.PreCondition
            changed = True
        Else
            result.PreCondition = Nothing
        End If

        If Not Me.OnNewRecord.Equals(section.OnNewRecord) Then
            result.OnNewRecord = Me.OnNewRecord
            changed = True
        Else
            result.OnNewRecord = Nothing
        End If

        result.Variables = Nothing
        result._sectionItems = Nothing

        ' Return the value.
        If changed Then Return result Else Return Nothing
    End Function

    ' Validates the questionnaireset.
    Public Function IsValid() As Boolean Implements ISelfValidate.IsValid

        Dim message As String = ""

        If String.IsNullOrEmpty(Me.Name) Then message &= Environment.NewLine & "A valid name required."
        If String.IsNullOrEmpty(Me.ShortName) Then message &= Environment.NewLine & "A valid short name required."

        If Not String.IsNullOrEmpty(message) Then
            MessageBox.Show("Error list:" & message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return False
        Else
            Return True
        End If

    End Function

    Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)

        ' Generic object properties.
        Me._guid = info.GetValue("GO001", GetType(Guid))
        Me._name = info.GetValue("GO002", GetType(Dictionary(Of Integer, String)))
        Me._comment = info.GetValue("GO003", GetType(String))
        Me._dataBaseID = info.GetValue("GO004", GetType(Integer))
        Me._dataTableName = info.GetValue("GO005", GetType(String))
        Me._logTableName = info.GetValue("GO006", GetType(String))

        ' Section properties.
        Me._shortName = info.GetValue("S001", GetType(String))
        Me._modifiable = info.GetValue("S002", GetType(Boolean))
        Me._preCondition = info.GetValue("S003", GetType(String))
        Me._onNewRecord = info.GetValue("S004", GetType(String))
        Me._variables = info.GetValue("S005", GetType(List(Of Variable)))
        Me._sectionItems = info.GetValue("S006", GetType(List(Of SectionItem)))

    End Sub

    Public Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) Implements ISerializable.GetObjectData

        ' Generic object properties.
        info.AddValue("GO001", Me._guid)
        info.AddValue("GO002", Me._name)
        info.AddValue("GO003", Me._comment)
        info.AddValue("GO004", Me._dataBaseID)
        info.AddValue("GO005", Me._dataTableName)
        info.AddValue("GO006", Me._logTableName)

        ' Section properties.
        info.AddValue("S001", Me._shortName)
        info.AddValue("S002", Me._modifiable)
        info.AddValue("S003", Me._preCondition)
        info.AddValue("S004", Me._onNewRecord)

        ' If not recursive then serialize empty lists.
        If ContextClass.RecursiveSerialization Then

            info.AddValue("S005", Me._variables)
            info.AddValue("S006", Me._sectionItems)

        Else

            info.AddValue("S005", New List(Of Variable))
            info.AddValue("S006", New List(Of SectionItem))

        End If

    End Sub

#End Region

End Class


text:
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Cloud\AAS\Entity;

use SCToolbox\AAS\Entity\UserInterface;
use \Doctrine\ORM\Mapping as ORM;

/**
 * Description of User
 * @ORM\Entity
 * @ORM\Table(name="users")
 * @author stephan
 */
class DigestUser implements UserInterface {

    protected static $REALM = "cloudDav";
    /**
     * @ORM\Id @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $uid;
    /**
     * @ORM\Column(type="string", length=50, unique=true)
     */
    protected $username;
    /**
     * @ORM\Column(type="string", length=50)
     */
    protected $name;
    /**
     * @ORM\Column(type="string", length=70)
     */
    protected $password;
    /**
     * @ORM\Column(type="string", length=70)
     */
    protected $email;
    /**
     * @ORM\Column(type="boolean")
     */
    protected $activ;
    /**
     * @ORM\Column(type="datetime")
     */
    protected $register;
    /**
     * @ORM\Column(type="string", length=70)
     */
    protected $digest;

    function __construct($username = null, $password = null, $email = null, $activ = null, $register = null) {
        $this->username = $username;
        $this->password = $password;
        $this->email = $email;
        $this->activ = $activ;
        $this->register = $register;
    }

    public function getUsername() {
        return $this->username;
    }

    public function setUsername($username) {
        $this->username = $username;
    }

    public function getPassword() {
        return $this->password;
    }

    public function setPassword($password) {
        $hash = new \PasswordHash(8, false);
        $this->password = $hash->HashPassword($password);
        $this->setDigest($password);
    }

    public function checkPassword($password) {
        $hash = new \PasswordHash(8, false);
        return $hash->CheckPassword($password, $this->password);
    }

    public function getEmail() {
        return $this->email;
    }

    public function setEmail($email) {
        $this->email = $email;
    }

    public function getActiv() {
        return $this->activ;
    }

    public function setActiv($activ) {
        $this->activ = $activ;
    }

    public function getRegister() {
        return $this->register;
    }

    public function setRegister($register) {
        $this->register = $register;
    }

    public function getUid() {
        return $this->uid;
    }

    public function getName() {
        return $this->name;
    }

    public function setName($name) {
        $this->name = $name;
    }

    public function getDigest() {
        return $this->digest;
    }

    public function setDigest($digest) {
        $this->digest = md5($this->getUsername() . ':' . self::$REALM . ':' . $digest);
    }

    public static function getRealm(){
        return self::$REALM;
    }

}

?>


text:
/*!
 * Start Bootstrap - Modern Business HTML Template (http://startbootstrap.com)
 * Code licensed under the Apache License v2.0.
 * For details, see http://www.apache.org/licenses/LICENSE-2.0.
 */

/* Global Styles */

html,
body {
    height: 100%;
}

body {
    padding-top: 50px; /* Required padding for .navbar-fixed-top. Remove if using .navbar-static-top. Change if height of navigation changes. */
    color:#000;
    background-color:#f3f3f3;

}

.img-portfolio {
    margin-bottom: 30px;
}

.img-hover:hover {
    opacity: 0.8;
    cursor: pointer;
}

/* Home Page Carousel */

header.carousel {
    height: 100%;
}

header.carousel .item,
header.carousel .item.active,
header.carousel .carousel-inner {
    height: 100%;
}

header.carousel .fill {
    width: 100%;
    height: 100%;
    background-position: center;
    background-size: cover;
}

/* 404 Page Styles */

.error-404 {
    font-size: 100px;
}

/* Pricing Page Styles */

.price {
    display: block;
    font-size: 50px;
    line-height: 50px;
}

.price sup {
    top: -20px;
    left: 2px;
    font-size: 20px;
}

.period {
    display: block;
    font-style: italic;
}

/* Footer Styles */

footer {
    background: none repeat scroll 0 0 #333;
    color: #fff;
    margin: 0;
    padding: 30px 0;
    }

/* Responsive Styles */

@media(max-width:991px) {
    .customer-img,
    .img-related {
        margin-bottom: 30px;
    }
}

@media(max-width:767px) {
    .img-portfolio {
        margin-bottom: 15px;
    }

    header.carousel .carousel {
        height: 70%;
    }
}
.home-jobs {
background-color: #fff;
}
.job-box{
 margin:10px 0;
}
.btn-more{
text-align: center;
text-decoration: none;
}

.btn-more:hover{
text-align: center;
text-decoration: none;
cursor: pointer;
}

.footer-services-space{
border-radius: 4px;
min-height: 20px;
padding: 19px 0;
text-align: center;
}

.footer-services{
background-image: url("../img/bottom_icons.png");
background-repeat: no-repeat;
display: inline-block;
height: 54px;
width: 54px;
}
a.mediumlightgray{
    color:#000;
    text-decoration: none;
}

a.mediumlightgray:hover{
    color:#087ccd;
    text-decoration: none;
    cursor: pointer;
}

a div.takeTest {
     background-position: 0px -1150px;
     text-decoration: none;
}

a:hover div.takeTest {
     background-position: -71px -1150px;
     text-decoration: none;
         cursor: pointer;
}

a div.getHired {
     background-position: 0 -1287px;
     text-decoration: none;
}

a:hover div.getHired {
     background-position: -71px -1287px;
     text-decoration: none;
         cursor: pointer;
}

a div.forEmployers {
     background-position: 0px -1356px;
     text-decoration: none;
}

a:hover div.forEmployers {
     background-position: -71px -1356px;
     text-decoration: none;
         cursor: pointer;
}

a div.resumeWriting {
     background-position: 0px -1424px;
     text-decoration: none;
}

a:hover div.resumeWriting {
    background-position: -71px -1424px;
    text-decoration: none;
}
.o4u-footer{

}
.o4u-footer > div h5 {
    color: #fff !important;
    font-size: 24px !important;
    font-weight: 500;
    margin-bottom: 10px;
}

.o4u-footer ul{
    padding: 0;

}
.o4u-footer a{
    color:#fff;
    font-size: 16px;

}
.o4u-footer a:hover{
    text-decoration: none;
    cursor: pointer;
}
.lowerFoot{
    text-align: center;
    margin-top: 96px;
}
.filter_list_box{
    overflow: hidden;
    padding: 3px 0;
    width: 165px;
    display: flex;
}
h3.filter_text {
    font-size: 12px;
    overflow: hidden;
    position: relative;
    top: 1px;
    width: 145px;
    margin:0;
    padding: 0 0 0 5px;
    vertical-align: middle;

}
label.apart{
margin:0;
padding: 0;
}
input.filter_checkbox{
    margin:0;
}
input.filter_checkbox:focus{
    outline:none;
}
.media-heading a{
    text-decoration: none;

}
a.media-heading{
    text-decoration: none;
}
a.media-heading:hover{
    text-decoration: none;
}
.jobListing-box {
    margin: 0 auto 10px 0;
    border: 1px solid #ddd;
}


text:
import os

from setuptools import setup

def get_version():
    """Get the version info from the mpld3 package without importing it"""
    import ast

    with open(os.path.join("geneimpacts", "__init__.py"), "r") as init_file:
        module = ast.parse(init_file.read())

    version = (ast.literal_eval(node.value) for node in ast.walk(module)
               if isinstance(node, ast.Assign)
               and node.targets[0].id == "__version__")
    try:
        return next(version)
    except StopIteration:
        raise ValueError("version could not be located")

setup(version=get_version(),
      name='geneimpacts',
      description="normalize effects from variant annotation tools (snpEff, VEP)",
      packages=['geneimpacts', 'geneimpacts.tests'],
      long_description=open('README.md').read(),
      long_description_content_type="text/markdown",
      author="Brent Pedersen",
      author_email="bpederse@gmail.com",
      zip_safe=False,
      test_suite='pytest',
      include_package_data=True,
      tests_require=['pytest'],
      classifiers=[
    'Development Status :: 4 - Beta',
    'Intended Audience :: Science/Research',
    'License :: OSI Approved :: MIT License',
    'Topic :: Scientific/Engineering :: Bio-Informatics'
  ])