text:
#include "../shared/utils.h"

#include <QtConcurrent>
#include <QtPromise>
#include <QtTest>

class tst_qpromise_filter : public QObject
{
    Q_OBJECT

private Q_SLOTS:
    void emptySequence();
    void filterValues();
    void delayedFulfilled();
    void delayedRejected();
    void functorThrows();
    void functorArguments();
    void preserveOrder();
    void sequenceTypes();
};

QTEST_MAIN(tst_qpromise_filter)
#include "tst_filter.moc"

namespace {

template<class Sequence>
struct SequenceTester
{
    static void exec()
    {
        auto p = QtPromise::resolve(Sequence{42, 43, 44, 45, 46, 47, 48, 49, 50, 51})
                     .filter([](int v, ...) {
                         return v > 42 && v < 51;
                     })
                     .filter([](int, int i) {
                         return QtPromise::QPromise<bool>::resolve(i % 2 == 0);
                     })
                     .filter([](int v, ...) {
                         return v != 45;
                     });

        Q_STATIC_ASSERT((std::is_same<decltype(p), QtPromise::QPromise<Sequence>>::value));
        QCOMPARE(waitForValue(p, Sequence{}), (Sequence{43, 47, 49}));
    }
};

} // anonymous namespace

void tst_qpromise_filter::emptySequence()
{
    auto p = QtPromise::QPromise<QVector<int>>::resolve({}).filter([](int v, ...) {
        return v % 2 == 0;
    });

    Q_STATIC_ASSERT((std::is_same<decltype(p), QtPromise::QPromise<QVector<int>>>::value));
    QCOMPARE(waitForValue(p, QVector<int>{}), QVector<int>{});
}

void tst_qpromise_filter::filterValues()
{
    auto p = QtPromise::QPromise<QVector<int>>::resolve({42, 43, 44}).filter([](int v, ...) {
        return v % 2 == 0;
    });

    Q_STATIC_ASSERT((std::is_same<decltype(p), QtPromise::QPromise<QVector<int>>>::value));
    QCOMPARE(waitForValue(p, QVector<int>{}), (QVector<int>{42, 44}));
}

void tst_qpromise_filter::delayedFulfilled()
{
    auto p = QtPromise::QPromise<QVector<int>>::resolve({42, 43, 44}).filter([](int v, ...) {
        return QtPromise::QPromise<bool>{[&](const QtPromise::QPromiseResolve<bool>& resolve) {
            QtPromisePrivate::qtpromise_defer([=]() {
                resolve(v % 2 == 0);
            });
        }};
    });

    Q_STATIC_ASSERT((std::is_same<decltype(p), QtPromise::QPromise<QVector<int>>>::value));
    QCOMPARE(waitForValue(p, QVector<int>{}), (QVector<int>{42, 44}));
}

void tst_qpromise_filter::delayedRejected()
{
    auto p = QtPromise::QPromise<QVector<int>>::resolve({42, 43, 44}).filter([](int v, ...) {
        return QtPromise::QPromise<bool>{[&](const QtPromise::QPromiseResolve<bool>& resolve,
                                             const QtPromise::QPromiseReject<bool>& reject) {
            QtPromisePrivate::qtpromise_defer([=]() {
                if (v == 43) {
                    reject(QString{"foo"});
                }
                resolve(true);
            });
        }};
    });

    Q_STATIC_ASSERT((std::is_same<decltype(p), QtPromise::QPromise<QVector<int>>>::value));
    QCOMPARE(waitForError(p, QString{}), QString{"foo"});
}

void tst_qpromise_filter::functorThrows()
{
    auto p = QtPromise::QPromise<QVector<int>>::resolve({42, 43, 44}).filter([](int v, ...) {
        if (v == 43) {
            throw QString{"foo"};
        }
        return true;
    });

    Q_STATIC_ASSERT((std::is_same<decltype(p), QtPromise::QPromise<QVector<int>>>::value));
    QCOMPARE(waitForError(p, QString{}), QString{"foo"});
}

void tst_qpromise_filter::functorArguments()
{
    QMap<int, int> args;
    auto p = QtPromise::QPromise<QVector<int>>::resolve({42, 43, 44}).filter([&](int v, int i) {
        args[v] = i;
        return i % 2 == 0;
    });

    Q_STATIC_ASSERT((std::is_same<decltype(p), QtPromise::QPromise<QVector<int>>>::value));
    QCOMPARE(waitForValue(p, QVector<int>{}), (QVector<int>{42, 44}));
    QMap<int, int> expected{{42, 0}, {43, 1}, {44, 2}};
    QCOMPARE(args, expected);
}

void tst_qpromise_filter::preserveOrder()
{
    auto p =
        QtPromise::QPromise<QVector<int>>::resolve({250, 50, 100, 400, 300}).filter([](int v, ...) {
            return QtPromise::QPromise<bool>::resolve(v > 200).delay(v);
        });

    Q_STATIC_ASSERT((std::is_same<decltype(p), QtPromise::QPromise<QVector<int>>>::value));
    QCOMPARE(waitForValue(p, QVector<int>{}), (QVector<int>{250, 400, 300}));
}

void tst_qpromise_filter::sequenceTypes()
{
    SequenceTester<QList<int>>::exec();
    SequenceTester<QVector<int>>::exec();
    SequenceTester<std::list<int>>::exec();
    SequenceTester<std::vector<int>>::exec();
}


text:
ResearcherWizardBeaconPage::ResearcherWizardBeaconPage(QWidget *parent)
    : QWizardPage(parent)
    , ui(new Ui::ResearcherWizardBeaconPage)
    , m_researcher_model(nullptr)
    , m_wallet_model(nullptr)
{
    ui->setupUi(this);
}

ResearcherWizardBeaconPage::~ResearcherWizardBeaconPage()
{
    delete ui;
}

void ResearcherWizardBeaconPage::setModel(
    ResearcherModel* researcher_model,
    WalletModel* wallet_model)
{
    this->m_researcher_model = researcher_model;
    this->m_wallet_model = wallet_model;

    if (!m_researcher_model || !m_wallet_model) {
        return;
    }

    connect(m_researcher_model, SIGNAL(researcherChanged()), this, SLOT(refresh()));
    connect(m_researcher_model, SIGNAL(beaconChanged()), this, SLOT(refresh()));
    connect(ui->sendBeaconButton, SIGNAL(clicked()), this, SLOT(advertiseBeacon()));
}

void ResearcherWizardBeaconPage::initializePage()
{
    if (!m_researcher_model) {
        return;
    }

    refresh();
    updateBeaconIcon(m_researcher_model->getBeaconStatusIcon());
    updateBeaconStatus(m_researcher_model->formatBeaconStatus());
}

bool ResearcherWizardBeaconPage::isComplete() const
{
    if (m_researcher_model->needsV2BeaconUpgrade()) {
        return m_researcher_model->hasPendingBeacon();
    }

    return m_researcher_model->hasActiveBeacon()
        || m_researcher_model->hasPendingBeacon();
}

int ResearcherWizardBeaconPage::nextId() const
{
    if (m_researcher_model->needsBeaconAuth()) {
        return ResearcherWizard::PageAuth;
    }

    return ResearcherWizard::PageSummary;
}

bool ResearcherWizardBeaconPage::isEnabled() const
{
    return !isComplete() || m_researcher_model->hasRenewableBeacon();
}

void ResearcherWizardBeaconPage::refresh()
{
    if (!m_researcher_model) {
        return;
    }

    ui->cpidLabel->setText(m_researcher_model->formatCpid());
    ui->sendBeaconButton->setVisible(isEnabled());
    ui->v2BeaconNoticeLabel->setVisible(m_researcher_model->needsV2BeaconUpgrade());
    ui->continuePromptWrapper->setVisible(!isEnabled());

    emit completeChanged();
}

void ResearcherWizardBeaconPage::advertiseBeacon()
{
    if (!m_researcher_model || !m_wallet_model) {
        return;
    }

    const WalletModel::UnlockContext unlock_context(m_wallet_model->requestUnlock());

    if (!unlock_context.isValid()) {
        // Unlock wallet was cancelled
        return;
    }

    BeaconStatus status = m_researcher_model->advertiseBeacon();

    if (status == BeaconStatus::ACTIVE) {
        status = BeaconStatus::PENDING;
    }

    updateBeaconStatus(ResearcherModel::mapBeaconStatus(status));
    updateBeaconIcon(ResearcherModel::mapBeaconStatusIcon(status));
}

void ResearcherWizardBeaconPage::updateBeaconStatus(const QString& status)
{
    ui->beaconStatusLabel->setText(status);
}

void ResearcherWizardBeaconPage::updateBeaconIcon(const QIcon& icon)
{
    const int icon_size = ui->beaconIconLabel->width();

    ui->beaconIconLabel->setPixmap(icon.pixmap(icon_size, icon_size));
}

redpajama_set_name: RedPajamaGithub


text:
<?php
/**
 * Created by PhpStorm.
 * User: Nathan-Y
 * Date: 15-3-5
 * Time: 下午2:01
 */

namespace Nathan\CakeBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * Class Category
 * @ORM\Entity(repositoryClass="Nathan\CakeBundle\Repository\CategoryRepository")
 * @ORM\Table(name="category")
 */
class Category {
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=45)
     */
    protected $name;

    /**
     * @ManyToOne(targetEntity="Author", inversedBy="categories")
     * @JoinColumn(name="author_id", referencedColumnName="id")
     */
    private $author;

    /**
     * @OneToMany(targetEntity="Category", mappedBy="parent")
     */
    private $children;
    /**
     * @ManyToOne(targetEntity="Category", inversedBy="children")
     * @JoinColumn(name="parent_id", referencedColumnName="id")
     */
    private $parent;
    /**
     * @ManyToMany(targetEntity="Book", mappedBy="categories")
     */
    private $books;

    public function __construct(){
        $this->children = new ArrayCollection();
        $this->books = new ArrayCollection();
    }
}


text:
namespace libxmljs {

Nan::Persistent<v8::FunctionTemplate> XmlText::constructor_template;

// doc, name, content
NAN_METHOD(XmlText::New) {
  Nan::HandleScope scope;

  // if we were created for an existing xml node, then we don't need
  // to create a new node on the document
  if (info.Length() == 0) {
      return info.GetReturnValue().Set(info.Holder());
  }

  XmlDocument* document = Nan::ObjectWrap::Unwrap<XmlDocument>(Nan::To<v8::Object>(info[0]).ToLocalChecked());
  assert(document);

  v8::Local<v8::Value> contentOpt;
  if (info[1]->IsString()) {
      contentOpt = info[1];
  }
  Nan::Utf8String contentRaw(contentOpt);
  const char* content = (contentRaw.length()) ? *contentRaw : NULL;

  xmlChar* encodedContent = content ? xmlEncodeSpecialChars(document->xml_obj, (const xmlChar*) content) : NULL;

  xmlNode* textNode = xmlNewDocText(document->xml_obj, encodedContent);
  if (encodedContent) {
      xmlFree(encodedContent);
  }

  XmlText* element = new XmlText(textNode);
  textNode->_private = element;
  element->Wrap(info.Holder());

  // this prevents the document from going away
  Nan::Set(info.Holder(), Nan::New<v8::String>("document").ToLocalChecked(), info[0]);

  return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlText::NextElement) {
  Nan::HandleScope scope;
  XmlText *element = Nan::ObjectWrap::Unwrap<XmlText>(info.Holder());
  assert(element);

  return info.GetReturnValue().Set(element->get_next_element());
}

NAN_METHOD(XmlText::PrevElement) {
  Nan::HandleScope scope;
  XmlText *element = Nan::ObjectWrap::Unwrap<XmlText>(info.Holder());
  assert(element);

  return info.GetReturnValue().Set(element->get_prev_element());
}

NAN_METHOD(XmlText::Text) {
  Nan::HandleScope scope;
  XmlText *element = Nan::ObjectWrap::Unwrap<XmlText>(info.Holder());
  assert(element);

  if (info.Length() == 0) {
    return info.GetReturnValue().Set(element->get_content());
  } else {
    element->set_content(*Nan::Utf8String(info[0]));
  }

  return info.GetReturnValue().Set(info.Holder());
}

NAN_METHOD(XmlText::AddPrevSibling) {
  XmlText* text = Nan::ObjectWrap::Unwrap<XmlText>(info.Holder());
  assert(text);

  XmlNode* new_sibling = Nan::ObjectWrap::Unwrap<XmlNode>(Nan::To<v8::Object>(info[0]).ToLocalChecked());
  assert(new_sibling);

  xmlNode *imported_sibling = text->import_node(new_sibling->xml_obj);
  if (imported_sibling == NULL) {
      return Nan::ThrowError("Could not add sibling. Failed to copy node to new Document.");
  }
  else if ((new_sibling->xml_obj == imported_sibling) && text->prev_sibling_will_merge(imported_sibling)) {
      imported_sibling = xmlCopyNode(imported_sibling, 0);
  }
  text->add_prev_sibling(imported_sibling);

  return info.GetReturnValue().Set(info[0]);
}

NAN_METHOD(XmlText::AddNextSibling) {
  XmlText* text = Nan::ObjectWrap::Unwrap<XmlText>(info.Holder());
  assert(text);

  XmlNode* new_sibling = Nan::ObjectWrap::Unwrap<XmlNode>(Nan::To<v8::Object>(info[0]).ToLocalChecked());
  assert(new_sibling);

  xmlNode *imported_sibling = text->import_node(new_sibling->xml_obj);
  if (imported_sibling == NULL) {
      return Nan::ThrowError("Could not add sibling. Failed to copy node to new Document.");
  }
  else if ((new_sibling->xml_obj == imported_sibling) && text->next_sibling_will_merge(imported_sibling)) {
      imported_sibling = xmlCopyNode(imported_sibling, 0);
  }
  text->add_next_sibling(imported_sibling);

  return info.GetReturnValue().Set(info[0]);
}

NAN_METHOD(XmlText::Replace) {
  XmlText* element = Nan::ObjectWrap::Unwrap<XmlText>(info.Holder());
  assert(element);

  if (info[0]->IsString()) {
    element->replace_text(*Nan::Utf8String(info[0]));
  } else {
    XmlText* new_sibling = Nan::ObjectWrap::Unwrap<XmlText>(Nan::To<v8::Object>(info[0]).ToLocalChecked());
    assert(new_sibling);

    xmlNode *imported_sibling = element->import_node(new_sibling->xml_obj);
    if (imported_sibling == NULL) {
        return Nan::ThrowError("Could not replace. Failed to copy node to new Document.");
    }
    element->replace_element(imported_sibling);
  }

  return info.GetReturnValue().Set(info[0]);
}

void
XmlText::set_content(const char* content) {
  xmlChar *encoded = xmlEncodeSpecialChars(xml_obj->doc, (const xmlChar*)content);
  xmlNodeSetContent(xml_obj, encoded);
  xmlFree(encoded);
}

v8::Local<v8::Value>
XmlText::get_content() {
  Nan::EscapableHandleScope scope;
  xmlChar* content = xmlNodeGetContent(xml_obj);
  if (content) {
    v8::Local<v8::String> ret_content =
      Nan::New<v8::String>((const char *)content).ToLocalChecked();
    xmlFree(content);
    return scope.Escape(ret_content);
  }

  return scope.Escape(Nan::New<v8::String>("").ToLocalChecked());
}

v8::Local<v8::Value>
XmlText::get_next_element() {
  Nan::EscapableHandleScope scope;

  xmlNode* sibling = xml_obj->next;
  if (!sibling)
    return scope.Escape(Nan::Null());

  while (sibling && sibling->type != XML_ELEMENT_NODE)
    sibling = sibling->next;

  if (sibling) {
      return scope.Escape(XmlText::New(sibling));
  }

  return scope.Escape(Nan::Null());
}

v8::Local<v8::Value>
XmlText::get_prev_element() {
  Nan::EscapableHandleScope scope;

  xmlNode* sibling = xml_obj->prev;
  if (!sibling)
    return scope.Escape(Nan::Null());

  while (sibling && sibling->type != XML_ELEMENT_NODE) {
    sibling = sibling->prev;
  }

  if (sibling) {
      return scope.Escape(XmlText::New(sibling));
  }

  return scope.Escape(Nan::Null());
}

v8::Local<v8::Object>
XmlText::New(xmlNode* node)
{
    Nan::EscapableHandleScope scope;
    if (node->_private) {
        return scope.Escape(static_cast<XmlNode*>(node->_private)->handle());
    }

    XmlText* element = new XmlText(node);
    v8::Local<v8::Object> obj = Nan::NewInstance(Nan::GetFunction(Nan::New(constructor_template)).ToLocalChecked()).ToLocalChecked();
    element->Wrap(obj);
    return scope.Escape(obj);
}

XmlText::XmlText(xmlNode* node)
    : XmlNode(node)
{
}

void
XmlText::add_prev_sibling(xmlNode* element) {
  xmlAddPrevSibling(xml_obj, element);
}

void
XmlText::add_next_sibling(xmlNode* element) {
  xmlAddNextSibling(xml_obj, element);
}

void
XmlText::replace_element(xmlNode* element) {
  xmlReplaceNode(xml_obj, element);
}

void
XmlText::replace_text(const char* content) {
  xmlNodePtr txt = xmlNewDocText(xml_obj->doc, (const xmlChar*)content);
  xmlReplaceNode(xml_obj, txt);
}

bool
XmlText::next_sibling_will_merge(xmlNode *child) {
  return (child->type == XML_TEXT_NODE);
}

bool
XmlText::prev_sibling_will_merge(xmlNode *child) {
  return (child->type == XML_TEXT_NODE);
}

void
XmlText::Initialize(v8::Local<v8::Object> target)
{
    Nan::HandleScope scope;
    v8::Local<v8::FunctionTemplate> tmpl =
      Nan::New<v8::FunctionTemplate>(New);

    constructor_template.Reset(tmpl);

    tmpl->Inherit(Nan::New(XmlNode::constructor_template));
    tmpl->InstanceTemplate()->SetInternalFieldCount(1);

    Nan::SetPrototypeMethod(tmpl,
            "nextElement",
            XmlText::NextElement);

    Nan::SetPrototypeMethod(tmpl,
            "prevElement",
            XmlText::PrevElement);

    Nan::SetPrototypeMethod(tmpl,
            "text",
            XmlText::Text);

    Nan::SetPrototypeMethod(tmpl,
            "replace",
            XmlText::Replace);

    Nan::Set(target, Nan::New<v8::String>("Text").ToLocalChecked(),
            Nan::GetFunction(tmpl).ToLocalChecked());

}

}  // namespace libxmljs


text:
/**
 * Namespace: mapfish.Protocol
 * Contains convenience methods for protocol manipulation.
 */
mapfish.Protocol = {

    /**
     * APIFunction: decorateProtocol
     * Decorate a protocol.
     *
     * Example of use:
     * (start code)
     * var protocol = mapfish.Protocol.decorateProtocol({
     *     protocol: protocol,
     *     TriggerEventDecorator: {
     *         eventListeners: {
     *             crudfinished: function() {
     *                 alert("CRUD operation completed");
     *             }
     *         }
     *     },
     *     MergeFilterDecorator: null
     * });
     * (end)
     *
     * Parameters:
     * config - {Object} Config object specifying how protocol must be
     *     decorated, see the above the example.
     *
     * Returns:
     * {<OpenLayers.Protocol>} The resulting protocol.
     * */
    decorateProtocol: function(config) {
        var protocol = config.protocol;
        for (var key in config) {
            if (key != "protocol") {
                if (!mapfish.Protocol[key]) {
                    OpenLayers.Console.error(
                        "mapfish.Protocol." + key + " does not exist");
                } else {
                    protocol = new mapfish.Protocol[key](
                        OpenLayers.Util.extend(
                            {protocol: protocol}, config[key])
                    );
                }
            }
       }
       return protocol;
    }

};


text:
package io.transwarp.dfsclient.superput;

import org.apache.hadoop.conf.Configuration;

public class hdfsProperties {
    static Configuration configuration = new Configuration();
    // 加载配置
    static {
        try {
            configuration.addResource("core-site.xml");
            configuration.addResource("hdfs-site.xml");
            configuration.addResource("yarn-site.xml");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Configuration getConf() {
        return configuration;
    }
}


text:
  Animation engine for creative coding

[![Inspect](https://github.com/FMS-Cat/automaton/workflows/Inspect/badge.svg)](https://github.com/FMS-Cat/automaton/actions)

Originally made for [Shift](https://GitHub.com/fms-cat/shift), my WebGL demo

## Playground! (Tutorial)

![Playground](./packages/automaton-with-gui/readme-images/playground.gif)

Try our playground!
It comes with bunch of examples.

[https://fms-cat.github.io/automaton/automaton-with-gui](https://fms-cat.github.io/automaton/automaton-with-gui)

You might want to also check examples of [the core package](https://github.com/FMS-Cat/automaton/tree/dev/packages/automaton).

## What is this

Automaton is an animation engine for creative coding.
While you're doing creative coding, doing time-based animation by code sometimes causes you so much pain.
This project provides a framework and its GUI to connect your coding pieces with animations.

It's intended to be used in 64k intro, so I'm trying my best to make its footprint as small as possible.
The package [`automaton`](./packages/automaton) have a minimal set of features that is required to play animations and it does not have any dependencies.
The package [`automaton-with-gui`](./packages/automaton-with-gui) intended to be used in development stage is pretty big since it contains third party codes like React.

## Packages

- [`@fms-cat/automaton`](./packages/automaton) [![Latest NPM release](https://img.shields.io/npm/v/@fms-cat/automaton.svg)](https://www.npmjs.com/package/@fms-cat/automaton)
  - Core package of the automaton
- [`@fms-cat/automaton-fxs`](./packages/automaton-fxs) [![Latest NPM release](https://img.shields.io/npm/v/@fms-cat/automaton-fxs.svg)](https://www.npmjs.com/package/@fms-cat/automaton-fxs)
  - A package that contains bunch of automaton fxs
- [`@fms-cat/automaton-fxs-v2compat`](./packages/automaton-fxs-v2compat) [![Latest NPM release](https://img.shields.io/npm/v/@fms-cat/automaton-fxs-v2compat.svg)](https://www.npmjs.com/package/@fms-cat/automaton-fxs-v2compat)
  - A package that contains Automaton v2 compatibility fxs
- [`@fms-cat/automaton-with-gui`](./packages/automaton-with-gui) [![Latest NPM release](https://img.shields.io/npm/v/@fms-cat/automaton-with-gui.svg)](https://www.npmjs.com/package/@fms-cat/automaton-with-gui)
  - A variant of automaton that comes with GUI!

## Friend projects

- [automaton-electron](https://github.com/FMS-Cat/automaton-electron)
  - Electron client of automaton
- [automaton-lua](https://github.com/FMS-Cat/automaton-lua)
  - Lua binding of automaton

## Have a problem?

There are pretty much no users other than me so lacks documents if you want to use.
Please feel free to ask questions on [Twitter](https://twitter.com/FMS_Cat) ❤

## License

[MIT](./LICENSE)


text: export { Notification20 as default } from "../../";


text:
@interface ARouteViewController ()

@property (strong, nonatomic, nonnull) UserViewController *userViewController;

@end

@implementation ARouteViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [[[[ARoute sharedRouter] route:@"home"] embedInNavigationController] execute:^(ARouteResponse * _Nonnull routeResponse) {

    }];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UserViewController *)userViewController
{
    if (!_userViewController) {
        _userViewController = [UserViewController new];
    }

    return _userViewController;
}

@end


text:
module Cucumber
  module Rails
    module CapybaraJavascriptEmulation
      def self.included(base)
        base.class_eval do
          alias_method :click_without_javascript_emulation, :click
          alias_method :click, :click_with_javascript_emulation
        end
      end

      def click_with_javascript_emulation
        if link_with_non_get_http_method?
          Capybara::Driver::RackTest::Form.new(driver, js_form(self[:href], emulated_method)).submit(self)
        else
          click_without_javascript_emulation
        end
      end

      private

      def js_form(action, emulated_method, method = 'POST')
        js_form = node.document.create_element('form')
        js_form['action'] = action
        js_form['method'] = method

        if emulated_method and emulated_method.downcase != method.downcase
          input = node.document.create_element('input')
          input['type'] = 'hidden'
          input['name'] = '_method'
          input['value'] = emulated_method
          js_form.add_child(input)
        end

        js_form
      end

      def link_with_non_get_http_method?
        if ::Rails.version.to_f >= 3.0
          tag_name == 'a' && node['data-method'] && node['data-method'] =~ /(?:delete|put|post)/
        else
          tag_name == 'a' && node['onclick'] && node['onclick'] =~ /var f = document\.createElement\('form'\); f\.style\.display = 'none';/
        end
      end

      def emulated_method
        if ::Rails.version.to_f >= 3.0
          node['data-method']
        else
          node['onclick'][/m\.setAttribute\('value', '([^']*)'\)/, 1]
        end
      end
    end
  end
end

class Capybara::Driver::RackTest::Node
  include Cucumber::Rails::CapybaraJavascriptEmulation
end

Before('~@no-js-emulation') do
  # Enable javascript emulation
  Capybara::Driver::RackTest::Node.class_eval do
    alias_method :click, :click_with_javascript_emulation
  end
end

Before('@no-js-emulation') do
  # Disable javascript emulation
  Capybara::Driver::RackTest::Node.class_eval do
    alias_method :click, :click_without_javascript_emulation
  end
end


text:
from __future__ import annotations

import os

from xia2.Driver.InteractiveDriver import InteractiveDriver
from xia2.Driver.QSubDriver import QSubDriver
from xia2.Driver.ScriptDriver import ScriptDriver
from xia2.Driver.SimpleDriver import SimpleDriver

class _DriverFactory:
    def __init__(self):
        self._driver_type = "simple"

        self._implemented_types = [
            "simple",
            "script",
            "interactive",
            "qsub",
        ]

        # should probably write a message or something explaining
        # that the following Driver implementation is being used

        if "XIA2CORE_DRIVERTYPE" in os.environ:
            self.set_driver_type(os.environ["XIA2CORE_DRIVERTYPE"])

    def set_driver_type(self, driver_type):
        """Set the kind of driver this factory should produce."""
        if driver_type not in self._implemented_types:
            raise RuntimeError("unimplemented driver class: %s" % driver_type)

        self._driver_type = driver_type

    def get_driver_type(self):
        return self._driver_type

    def Driver(self, driver_type=None):
        """Create a new Driver instance, optionally providing the
        type of Driver we want."""

        if not driver_type:
            driver_type = self._driver_type

        driver_class = {
            "simple": SimpleDriver,
            "script": ScriptDriver,
            "interactive": InteractiveDriver,
            "qsub": QSubDriver,
        }.get(driver_type)
        if driver_class:
            return driver_class()

        raise RuntimeError('Driver class "%s" unknown' % driver_type)

DriverFactory = _DriverFactory()