text:
package kong

import (
	_ "fmt"
	"net/http"

	"github.com/dghubble/sling"
	"github.com/orangesys/orangeapi/pkg/config"
)

type Plugins struct {
	Plugin []Plugin `json:"data,omitempty"`
	Total  int      `json:"total,omitempty"`
}

type Plugin struct {
	APIID     string      `json:"api_id,omitempty"`
	Config    interface{} `json:"config,omitempty"`
	CreatedAt int         `json:"created_at,omitempty"`
	Enabled   bool        `json:"enabled,omitempty"`
	ID        string      `json:"id,omitempty"`
	Name      string      `json:"name,omitempty"`
}

type EnabledPlugin struct {
	//	EnabledPlugins map[string]bool `json:"enabled_plugins"`
	EnabledPlugins []string `json:"enabled_plugins"`
}

type PluginSchema struct {
	Fields     map[string]*PluginSchemaField `json:"fields"`
	NoConsumer bool                          `json:"no_consumer,omitempty"`
}

type PluginSchemaField struct {
	Type     string       `json:"type"`
	Required bool         `json:"required,omitempty"`
	Func     string       `json:"func,omitempty"`
	Default  interface{}  `json:"default,omitempty"`
	Schema   PluginSchema `json:"schema,omitempty"`
	Name     string       `json:"name"`
}

// Services

// PluginService provides methods for creating and reading issues.
type PluginService struct {
	sling  *sling.Sling
	config *config.KongConfiguration
}

type GeneratePluginParams struct {
	Name       string      `form:"name" json:"name" binding:"required"`
	ConsumerID string      `form:"consumer_id" json:"consumer_id,omitempty" binding:"omitempty"`
	Config     interface{} `form:"config" json:"config" binding:"omitempty"`
}

// NewPluginService returns a new PluginService.
func NewPluginService(httpClient *http.Client, config *config.KongConfiguration) *PluginService {
	return &PluginService{
		sling:  sling.New().Client(httpClient).Base(config.KongAdminURL + "apis/"),
		config: config,
	}
}

func (s *PluginService) GetEnabledPlugins() (*EnabledPlugin, *http.Response, error) {
	plugins := new(EnabledPlugin)
	resp, err := s.sling.New().Get(s.config.KongAdminURL + "plugins/enabled").ReceiveSuccess(plugins)
	return plugins, resp, err
}

func (schema *PluginSchema) setPluginSchemaName(prefix string) {
	for key, field := range schema.Fields {
		field.Name = prefix + key
		if field.Type == "table" {
			field.Schema.setPluginSchemaName(field.Name + ".")
		}
	}
}

func (s *PluginService) GetPluginSchema(name string) (*PluginSchema, *http.Response, error) {
	schema := new(PluginSchema)
	resp, err := s.sling.New().Get(s.config.KongAdminURL + "plugins/schema/" + name).ReceiveSuccess(schema)
	schema.setPluginSchemaName("")
	return schema, resp, err
}

func (s *PluginService) Create(params *Plugin, apiName string) (*Plugin, *http.Response, error) {
	plugin := new(Plugin)
	resp, err := s.sling.New().Post(s.config.KongAdminURL + "apis/" + apiName + "/plugins").BodyJSON(params).ReceiveSuccess(plugin)
	return plugin, resp, err
}

func (s *PluginService) Get(pluginID string, apiName string) (*Plugin, *http.Response, error) {
	plugin := new(Plugin)
	resp, err := s.sling.New().Path(apiName + "/plugins/" + pluginID).ReceiveSuccess(plugin)
	return plugin, resp, err
}

func (s *PluginService) List(apiName string) (*Plugins, *http.Response, error) {
	plugins := new(Plugins)
	resp, err := s.sling.New().Path(apiName + "/plugins/").ReceiveSuccess(plugins)
	return plugins, resp, err
}

func (s *PluginService) Update(params *Plugin, apiName string) (*Plugin, *http.Response, error) {
	api := new(Plugin)
	resp, err := s.sling.New().Patch(s.config.KongAdminURL + "apis/" + apiName + "/plugins/" + params.ID).BodyJSON(params).ReceiveSuccess(api)
	return api, resp, err
}

func (s *PluginService) Delete(pluginID string, apiName string) (string, *http.Response, error) {
	var message string
	resp, err := s.sling.New().Delete(s.config.KongAdminURL + "apis/" + apiName + "/plugins/" + pluginID).ReceiveSuccess(message)
	return message, resp, err
}


text:
#ifndef __INCLUDE_NUTTX_MEMLCD_H
#define __INCLUDE_NUTTX_MEMLCD_H

/*******************************************************************************
 * Included Files
 ******************************************************************************/

#include <stdbool.h>

#ifdef __cplusplus
#  define EXTERN extern "C"
extern "C"
{
#else
#  define EXTERN extern
#endif

/*******************************************************************************
 * Pre-processor Definitions
 ******************************************************************************/

/*******************************************************************************
 * Public Types
 ******************************************************************************/

/* A reference to a structure of this type must be passed to the initialization
 * method. It provides some board-specific hooks used by driver to manage the
 * timer and gpio (IRQ and DISP).
 *
 * Memory for this structure is provided by the caller.  It is not copied
 * by the driver and is presumed to persist while the driver is active.
 */

struct memlcd_priv_s
{
  /* IRQ/GPIO access callbacks.  These operations all hidden behind
   * callbacks to isolate the Memory LCD driver from differences in GPIO
   * interrupt handling by varying boards and MCUs.
   *
   * irqattach   - Attach the driver interrupt handler to the GPIO interrupt
   *               If isr is NULL, detach and disable it.
   * dispcontrol - Enable or disable the DISP pin and EXTCOMIN interrupt.
   * setpolarity - Board specified method to set EXTCOMIN.
   *               Needed only when CONFIG_MEMLCD_EXTCOMIN_MODE_HW is not set.
   * setvcomfreq - Set timer frequency for EXTCOMIN.
   */

  int (*attachirq) (xcpt_t isr);
  void (*dispcontrol) (bool on);
#ifndef CONFIG_MEMLCD_EXTCOMIN_MODE_HW
  void (*setpolarity) (bool pol);
#endif
  void (*setvcomfreq) (unsigned int freq);
};

/*******************************************************************************
 * Public Data
 ******************************************************************************/

/*******************************************************************************
 * Public Function Prototypes
 ******************************************************************************/

/*******************************************************************************
 * Name:  memlcd_initialize
 *
 * Description:
 *
 * Input Parameters:
 *
 *   spi - A reference to the SPI driver instance.
 *   devno - A value in the range of 0 throuh CONFIG_MEMLCD_NINTERFACES-1.
 *   This allows support for multiple devices.
 *   memlcd_priv_s - Board specific structure
 *
 * Returned Value:
 *
 *   On success, this function returns a reference to the LCD object for the
 *   specified LCD.  NULL is returned on any failure.
 *
 ******************************************************************************/

struct lcd_dev_s;               /* see nuttx/lcd.h */
struct spi_dev_s;               /* see nuttx/spi/spi.h */
FAR struct lcd_dev_s *memlcd_initialize(FAR struct spi_dev_s *spi,
                                        FAR struct memlcd_priv_s *priv,
                                        unsigned int devno);

#undef EXTERN
#ifdef __cplusplus
}
#endif

#endif /* __INCLUDE_NUTTX_MEMLCD_H */

redpajama_set_name: RedPajamaGithub


text:
package org.kuali.rice.edl.impl.service;

import java.io.InputStream;
import java.util.List;

import javax.xml.transform.Templates;
import javax.xml.transform.TransformerConfigurationException;

import org.kuali.rice.core.framework.impex.xml.XmlExporter;
import org.kuali.rice.core.framework.impex.xml.XmlLoader;
import org.kuali.rice.edl.impl.EDLController;
import org.kuali.rice.edl.impl.bo.EDocLiteAssociation;
import org.kuali.rice.edl.impl.bo.EDocLiteDefinition;
import org.w3c.dom.Document;

public interface EDocLiteService extends XmlLoader, XmlExporter {

	void saveEDocLiteDefinition(InputStream xml);
    void saveEDocLiteAssociation(InputStream xml);

    EDocLiteDefinition getEDocLiteDefinition(String defName);
    EDocLiteAssociation getEDocLiteAssociation(String docType);
    EDocLiteAssociation getEDocLiteAssociation(Long associationId);

    List<EDocLiteDefinition> getEDocLiteDefinitions();
    List<EDocLiteAssociation> getEDocLiteAssociations();

    Templates getStyleAsTranslet(String styleName) throws TransformerConfigurationException;
    List<EDocLiteAssociation> search(EDocLiteAssociation edocLite);

    EDLController getEDLControllerUsingEdlName(String edlName);
	EDLController getEDLControllerUsingDocumentId(String documentId);
	void initEDLGlobalConfig();
    void saveEDocLiteDefinition(EDocLiteDefinition data) ;
    void saveEDocLiteAssociation(EDocLiteAssociation assoc);
    Document getDefinitionXml(EDocLiteAssociation edlAssociation);
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>Uses of Class com.hp.hpl.jena.sparql.util.graph.GNode (Apache Jena ARQ)</title>
<meta name="date" content="2014-10-02">
<link rel="stylesheet" type="text/css" href="../../../../../../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Class
com.hp.hpl.jena.sparql.util.graph.GNode

Packages that use GNode

Package
Description

com.hp.hpl.jena.sparql.util.graph

Uses of GNode in com.hp.hpl.jena.sparql.util.graph

Methods in com.hp.hpl.jena.sparql.util.graph with parameters of type GNode

Modifier and Type
Method and Description

static List<Triple>
GraphList.allTriples(GNode gnode)

static void
GraphList.allTriples(GNode gnode,
          Collection<Triple> acc)

static boolean
GraphList.contains(GNode gnode,
        Node item)

static Node
GraphList.get(GNode gnode,
   int idx)

static int
GraphList.index(GNode gnode,
     Node value)

static List<Integer>
GraphList.indexes(GNode gnode,
       Node value)

static boolean
GraphList.isListNode(GNode gnode)

static int
GraphList.length(GNode gnode)

static List<Node>
GraphList.listFromMember(GNode gnode)

Starting at a list element, find the heads of lists it is in

static void
GraphList.listFromMember(GNode gnode,
              Collection<Node> acc)

static List<Node>
GraphList.members(GNode gnode)

static void
GraphList.members(GNode gnode,
       Collection<Node> acc)

static int
GraphList.occurs(GNode gnode,
      Node item)

static void
GraphList.triples(GNode gnode,
       Collection<Triple> acc)

Constructors in com.hp.hpl.jena.sparql.util.graph with parameters of type GNode

Constructor and Description

GNode(GNode other,
     Node node)

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Licenced under the Apache License, Version 2.0


text:
using System.Runtime.CompilerServices;
using PdfSharp.Drawing;
using SharpLayout;

namespace Examples
{
    public static class BandHelper
    {
        public static double Px(double value) => XUnit.FromInch(value / 300d);

        public static Section Band(this Section section, double x, double y, int columnCount, int rowCount, Indexer indexer,
            [CallerLineNumber] int line = 0, [CallerFilePath] string filePath = "")
        {
            for (var i = 0; i < rowCount; i++)
                section.Band(x, y + 98 * i, columnCount, indexer, line, filePath);
            return section;
        }

        public static Section Band(this Section section, double x, double y, int columnCount, Indexer indexer,
            [CallerLineNumber] int line = 0, [CallerFilePath] string filePath = "")
        {
            var table = section.AddTable().Font(Styles.Courier15)
                .ContentAlign(HorizontalAlign.Center).ContentVerticalAlign(VerticalAlign.Center)
                .Location(Px(x), Px(y));
            for (var i = 0; i < columnCount; i++)
                table.AddColumn(Px(2333 / 40d));
            var r1 = table.AddRow().Height(Px(72));
            for (var i = 0; i < columnCount; i++)
            {
                r1[i].Add(new Paragraph()
                    .Add(indexer.Current, line, filePath));
                indexer.Next();
            }
            return section;
        }
    }
}


text: Password incorrect or Session-ID in use. Verify username/password and login again.


text:
typedef enum {
    AddressNameCell,
    AddressCellPhoneCell,
    AddressPostcodeCell,
    AddressRegionCell,
    AddressStreetCell
} AddressCell;


text:
"""Test suite of the StringElement class."""

import pytest

from ..spec.string import StringElement
from ..lexicon.feature.category import CANNED_TEXT, NOUN
from ..lexicon.feature.gender import FEMININE
from ..lexicon.lang import FRENCH
from ..lexicon.feature import ELIDED

def test_string_element_no_base_word():
    se = StringElement(u"à la pêche au requin")
    assert se.category == CANNED_TEXT
    assert se.realisation == u"à la pêche au requin"
    assert se.features == {ELIDED: False}
    assert se.children == []

def test_string_element_with_base_word(lexicon_fr):
    w = lexicon_fr.first(u"pêche")
    se = StringElement(word=w)
    assert se.category == NOUN
    assert se.realisation == u"pêche"
    assert se.elided is False
    assert se.gender == FEMININE
    assert se.children == []

@pytest.mark.parametrize('left,right,expected_left,expected_right', [
    ('de', 'le', 'du', None),
    ('de', 'lequel', 'duquel', None),
    ('le', 'arbre', "l'", 'arbre'),
    ('que', "qu'", "que", None),
])
def test_realise_word_morphophonology(
        lexicon_fr, left, right, expected_left, expected_right):
    left = lexicon_fr.first(left)
    str_left = StringElement(word=left, language=FRENCH)
    right = lexicon_fr.first(right)
    str_right = StringElement(word=right, language=FRENCH)
    str_left.realise_morphophonology(next_word=str_right)
    assert str_left.realisation == expected_left
    assert str_right.realisation == expected_right

def test_realise_morphophonology_phrase(lexicon_fr):
    words = [u"Je", u"vais", u"à", u"la", u"pêche", u"à", u"le", u"poisson"]
    words = (lexicon_fr.first(w) for w in words)
    words = [StringElement(word=w, language=FRENCH) for w in words]
    for i, word in enumerate(words[:-1]):
        word.realise_morphophonology(next_word=words[i + 1])
    reas = [w.realisation for w in words if w.realisation]
    sentence = " ".join(reas)
    assert sentence == u"Je vais à la pêche au poisson"


text:
<?php

namespace Mcwork\View\Helper\Mcwork;

use Zend\View\Helper\AbstractHelper;
use ContentinumComponents\Html\HtmlAttribute;
use ContentinumComponents\Tools\ArrayMergeRecursiveDistinct;

/**
 * Toolbar
 * Created a link list with buttons or with a tag
 *
 * @author Michael Jochum, michael.jochum@jochum-mediaservices.de
 */
class Toolbar extends AbstractHelper
{

    protected $attribute = array();

    protected $standards = array();

    protected $tag = 'a';

    /**
     * Created a list depending on the given array
     *
     * @param array $links condition for the list
     * @return string list in html
     */
    public function __invoke(array $links, $std = false, array $list = null, $translate = true)
    {
        $this->emptyProps();
        $this->setStandards($list);
        $html = '
attribute);
        $html .= '>';
        foreach ($links as $key => $link) {
            $standard = array();
            if (is_array($link) && true === $std && ($standard = $this->getStandards($key))) {
                $link = ArrayMergeRecursiveDistinct::merge($standard, $link);
            } else {
                $link = $this->getStandards($key);
            }
            $html .= '
<' . $this->tag;
            if ('a' == $this->tag && false !== $link['href']) {
                $html .= ' href="' . $link['href'] . '"';
            }
            if (isset($link['attribs']) && is_array($link['attribs'])) {
                foreach ($link['attribs'] as $attr => $val) {
                    if (false !== $val) {
                        if ('title' === $attr) {
                            $val = $this->view->translate($val);
                        }
                        $html .= HtmlAttribute::attributeString($attr, $val, true);
                    }
                }
            }
            $html .= '>';
            $html .= (true === $translate) ? $this->view->translate($link['label']) : $link['label'];
            $html .= '</' . $this->tag . '>';
            $html .= '
';
        }
        $html .= '
';
        return $html;
    }

    /**
     * Set standards
     *
     * @param array $standards
     */
    protected function setStandards($standards)
    {
        if (isset($standards['attribute'])) {
            $this->attribute = $standards['attribute'];
        }

        if (isset($standards['standards'])) {
            $this->standards = $standards['standards'];
        }

        if (isset($standards['tag'])) {
            $this->tag = $standards['tag'];
        }
    }

    /**
     * Get standard toolbar content
     *
     * @param string $key
     * @return multitype:multitype:string multitype:string
     */
    protected function getStandards($key)
    {
        if (isset($this->standards[$key])) {
            return $this->standards[$key];
        }
        return false;
    }

    /**
     * Clear properties and set standards
     */
    protected function emptyProps()
    {
        $this->attribute = array();
        $this->standards = array();
        $this->tag = 'a';
    }
}


text:
/*globals angular:false*/
(function (angular) {
  'use strict';

  var app;
  app = angular.module('dacos');
  app.factory('Catalog', function (coursesUri, $resource) {
    return $resource(coursesUri + '/catalogs/:catalogCode', {'catalogCode' : '@year'}, {
      'update' : {'method' : 'PUT'},
      'save'   : {'method' : 'POST', 'url' : coursesUri + '/catalogs'}
    });
  });
})(angular);


text:
package com.azure.resourcemanager.devtestlabs.implementation;

import com.azure.resourcemanager.devtestlabs.fluent.models.ArmTemplateInner;
import com.azure.resourcemanager.devtestlabs.models.ArmTemplate;
import com.azure.resourcemanager.devtestlabs.models.ParametersValueFileInfo;
import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public final class ArmTemplateImpl implements ArmTemplate {
    private ArmTemplateInner innerObject;

    private final com.azure.resourcemanager.devtestlabs.DevTestLabsManager serviceManager;

    ArmTemplateImpl(
        ArmTemplateInner innerObject, com.azure.resourcemanager.devtestlabs.DevTestLabsManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
    }

    public String id() {
        return this.innerModel().id();
    }

    public String name() {
        return this.innerModel().name();
    }

    public String type() {
        return this.innerModel().type();
    }

    public String location() {
        return this.innerModel().location();
    }

    public Map<String, String> tags() {
        Map<String, String> inner = this.innerModel().tags();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

    public String displayName() {
        return this.innerModel().displayName();
    }

    public String description() {
        return this.innerModel().description();
    }

    public String publisher() {
        return this.innerModel().publisher();
    }

    public String icon() {
        return this.innerModel().icon();
    }

    public Object contents() {
        return this.innerModel().contents();
    }

    public OffsetDateTime createdDate() {
        return this.innerModel().createdDate();
    }

    public List<ParametersValueFileInfo> parametersValueFilesInfo() {
        List<ParametersValueFileInfo> inner = this.innerModel().parametersValueFilesInfo();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    public Boolean enabled() {
        return this.innerModel().enabled();
    }

    public ArmTemplateInner innerModel() {
        return this.innerObject;
    }

    private com.azure.resourcemanager.devtestlabs.DevTestLabsManager manager() {
        return this.serviceManager;
    }
}


text:
export function pad(value, length) {
  while (value.length < length)
  value = '0' + value;
  return value;
};

export function clone(date) {
  return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
};

export function toString(date) {
  return date.getFullYear() + '-' + pad((date.getMonth() + 1).toString(), 2) + '-' + pad(date.getDate().toString(), 2);
};

export function toDayOfMonthString(date) {
  return pad(date.getDate().toString());
};

export function toMonthAndYearString(date) {
  var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  return months[date.getMonth()] + ' ' + date.getFullYear();
};

export function moveToDayOfWeek(date, dayOfWeek) {
  while (date.getDay() !== dayOfWeek)
  date.setDate(date.getDate() - 1);
  return date;
};

export function isSameDay(first, second) {
  return first.getFullYear() === second.getFullYear() && first.getMonth() === second.getMonth() && first.getDate() === second.getDate();
};

export function isBefore(first, second) {
  return first.getTime() < second.getTime();
};

export function isAfter(first, second) {
  return first.getTime() > second.getTime();
};


text:
begin
  require 'rubygems'
rescue LoadError
end

$LOAD_PATH.unshift File.expand_path('../lib/', File.dirname(__FILE__))
require "ashton"

def media_path(file); File.expand_path "media/#{file}", File.dirname(__FILE__) end

class TestWindow < Gosu::Window
  def initialize
    super 640, 480, false
    self.caption = "Post-processing with 'pixelate' - 1..9 affect pixel size"

    @pixelate = Ashton::Shader.new fragment: :pixelate, uniforms: {
        pixel_size: @pixel_size = 4,
    }

    @font = Gosu::Font.new self, Gosu::default_font_name, 40
    @star = Gosu::Image.new(self, media_path("LargeStar.png"), true)
  end

  def update
    $gosu_blocks.clear if defined? $gosu_blocks # Workaround for Gosu bug (0.7.45)
  end

  def button_down(id)
    if (Gosu::Kb1..Gosu::Kb9).include? id
      @pixel_size = (id - Gosu::Kb1 + 1) ** 2
      @pixelate.pixel_size = @pixel_size
    elsif id == Gosu::KbEscape
      close
    end
  end

  def draw
    post_process @pixelate do
      @font.draw_rel "Hello world!", 350, 50, 0, 0.5, 0.5
      @font.draw_rel "Goodbye world!", 400, 350, 0, 0.5, 0.5
      @star.draw 0, 0, 0
      @star.draw 200, 100, 0
    end

    # Drawing after the effect isn't processed, which is useful for GUI elements.
    @font.draw "Pixel ratio: 1:#{@pixel_size}", 0, 0, 0
  end
end

TestWindow.new.show


text:
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;

exports.__esModule = true;
exports.default = void 0;

var _VirtualizedList = _interopRequireDefault(require("../../vendor/react-native/VirtualizedList"));

var _default = _VirtualizedList.default;
exports.default = _default;
module.exports = exports.default;


text:
module CoordsafeApi
  class Response
    attr_accessor :success, :body

    def initialize(request)
      @status, @body = request.response, request.response.body
    end

    def success
      if @status.class == Net::HTTPOK
        true
      else
        false
      end
    end

    def body
      JSON.parse @body
    end
  end
end


text:
package io.quarkus.vertx.http.runtime.attribute;

import io.quarkus.vertx.core.runtime.VertxMDC;
import io.vertx.ext.web.RoutingContext;

/**
 * Provide entries from the MDC section of the RoutingContext.
 * This is especially helpful to put OTel data 'traceId' and 'spanId'
 * into the access log.
 */
public class VertxMDCDataAttribute implements ExchangeAttribute {

    private final String dataKey;

    public VertxMDCDataAttribute(String dataKey) {
        this.dataKey = dataKey;
    }

    @Override
    public String readAttribute(RoutingContext exchange) {
        VertxMDC mdc = VertxMDC.INSTANCE;
        return mdc.get(dataKey);
    }

    @Override
    public void writeAttribute(RoutingContext exchange, String newValue) throws ReadOnlyAttributeException {
        throw new ReadOnlyAttributeException();
    }

    public static final class Builder implements ExchangeAttributeBuilder {

        @Override
        public String name() {
            return "OTel data";
        }

        @Override
        public ExchangeAttribute build(final String token) {
            if (token.startsWith("%{X,") && token.endsWith("}")) {
                final String dataItemName = token.substring(4, token.length() - 1);
                return new VertxMDCDataAttribute(dataItemName);
            }
            return null;
        }

        @Override
        public int priority() {
            return 0;
        }
    }

}


text:
A crude  winforms app to aid creation of openlayers 3 maps

The  designer takes GIS data (ie. .shp/.tab/.kml etc) and produces simple interactive maps without the need for any code. It handles both the javascript and a crude customizable layout to position dynamic map legends, images, text etc...

There are some examples of what the application in its current state can do here:
http://johnwilcock.github.io/OL3Designer/

The application is currently unfinished but core features do work dispite being very buggy in places.
It was designed to take the bulk of the work out of creating an OL3 map.  while it will create a working map, it will need some tidying up to make it look 100% presentable.  The maps it exports are completely 'client side' and have no need for any server infrastructure, only an internet connection is required if you choose to use an OSM background.


text:
from __future__ import unicode_literals

from django.db import migrations

class Migration(migrations.Migration):

    dependencies = [
        ('filer_gui', '0002_filerguifolder'),
    ]

    operations = [
        migrations.DeleteModel(
            name='FilerGuiFolder',
        ),
    ]


text:
package de.escidocng.model;

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

/**
 * Object holds a List of AuditRecord-Objects.
 */
public class AuditRecords {

    private List<AuditRecord> auditRecords = new ArrayList<AuditRecord>();

    /**
     * Default Constructor.
     */
    public AuditRecords() {
    }

    /**
     * Constructor with List of AuditRecord-Objects.
     *
     * @param auditRecords
     */
    public AuditRecords(List<AuditRecord> auditRecords) {
        if (auditRecords != null) {
            this.auditRecords = auditRecords;
        }
    }

    /**
     * @return the auditRecords
     */
    public List<AuditRecord> getAuditRecords() {
        return auditRecords;
    }

    /**
     * @param auditRecords the auditRecords to set
     */
    public void setAuditRecords(List<AuditRecord> auditRecords) {
        if (auditRecords == null) {
            this.auditRecords = new ArrayList<AuditRecord>();
        }
        else {
            this.auditRecords = auditRecords;
        }
    }

}


text:
package org.apache.ode.axis2.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;

import javax.wsdl.xml.WSDLLocator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.InputSource;

public class Axis2WSDLLocator implements WSDLLocator {
    private static final Log LOG = LogFactory.getLog(Axis2WSDLLocator.class);
    private URI _baseUri;
    private String _latest;

    public Axis2WSDLLocator(URI baseUri) throws URISyntaxException {
        _baseUri = baseUri;
    }

    public InputSource getBaseInputSource() {
        try {
            InputSource is = new InputSource();
            is.setByteStream(openResource(_baseUri));
            is.setSystemId(_baseUri.toString());
            return is;
        } catch (IOException e) {
            LOG.error("Unable to create InputSource for " + _baseUri, e);
            return null;
        }
    }

    public InputSource getImportInputSource(String parent, String imprt) {
        URI uri;
        try {
            uri = parent == null ? _baseUri.resolve(imprt) : new URI(parent).resolve(imprt);
        } catch (URISyntaxException e1) {
            LOG.error("URI syntax error: parent="+parent+" error="+e1);
            return null;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("Get import:  import=" + imprt + " parent=" + parent);
        }

        InputSource is = new InputSource();
        try {
            is.setByteStream(openResource(uri));
        } catch (Exception e) {
            LOG.error("Unable to open import resource: " + uri, e);
            return null;
        }
        is.setSystemId(uri.toString());
        _latest = uri.toString();
        return is;
    }

    public String getBaseURI() {
        return _baseUri.toString();
    }

    public String getLatestImportURI() {
        return _latest;
    }

    public void close() {
    }

    public InputStream openResource(URI uri) throws IOException {
        if (uri.isAbsolute() && uri.getScheme().equals("file")) {
            try {
                return uri.toURL().openStream();
            } catch (Exception except) {
                LOG.error("openResource: unable to open file URL " + uri + "; " + except.toString());
                return null;
            }
        }

        // Note that if we get an absolute URI, the relativize operation will simply
        // return the absolute URI.
        URI relative = _baseUri.relativize(uri);
        if (relative.isAbsolute() && !relative.getScheme().equals("urn")) {
            LOG.error("openResource: invalid scheme (should be urn:)  " + uri);
            return null;
        }

        File f = new File(_baseUri.getPath(), relative.getPath());
        if (!f.exists()) {
            LOG.error("openResource: file not found " + f);
            return null;
        }
        return new FileInputStream(f);
    }
}


text:
package org.apache.poi.xwpf.usermodel;

/**
 * Experimental interface to offer rudimentary read-only processing of
 * of the contentblock of an SDT/ContentControl.
 *

 *

 *

 * WARNING - APIs expected to change rapidly
 */
public interface ISDTContent {

    public String getText();

    public String toString();

}


text:
/****************************************************************************
** Meta object code from reading C++ file 'qgraphicseffect.h'
**
** Created: Mon 26. Nov 09:31:59 2012
**      by: The Qt Meta Object Compiler version 63 (Qt 4.8.4)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#include "../../../effects/qgraphicseffect.h"
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'qgraphicseffect.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.4. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif

QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_QGraphicsEffect[] = {

 // content:
       6,       // revision
       0,       // classname
       0,    0, // classinfo
       3,   14, // methods
       1,   29, // properties
       1,   33, // enums/sets
       0,    0, // constructors
       0,       // flags
       1,       // signalCount

 // signals: signature, parameters, type, tag, flags
      25,   17,   16,   16, 0x05,

 // slots: signature, parameters, type, tag, flags
      53,   46,   16,   16, 0x0a,
      70,   16,   16,   16, 0x0a,

 // properties: name, type, flags
      17,   79, 0x01495103,

 // properties: notify_signal_id
       0,

 // enums: name, flags, count, data
      84, 0x1,    4,   37,

 // enum data: key, value
      96, uint(QGraphicsEffect::SourceAttached),
     111, uint(QGraphicsEffect::SourceDetached),
     126, uint(QGraphicsEffect::SourceBoundingRectChanged),
     152, uint(QGraphicsEffect::SourceInvalidated),

       0        // eod
};

static const char qt_meta_stringdata_QGraphicsEffect[] = {
    "QGraphicsEffect\0\0enabled\0enabledChanged(bool)\0"
    "enable\0setEnabled(bool)\0update()\0bool\0"
    "ChangeFlags\0SourceAttached\0SourceDetached\0"
    "SourceBoundingRectChanged\0SourceInvalidated\0"
};

void QGraphicsEffect::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    if (_c == QMetaObject::InvokeMetaMethod) {
        Q_ASSERT(staticMetaObject.cast(_o));
        QGraphicsEffect *_t = static_cast<QGraphicsEffect *>(_o);
        switch (_id) {
        case 0: _t->enabledChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: _t->setEnabled((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 2: _t->update(); break;
        default: ;
        }
    }
}

const QMetaObjectExtraData QGraphicsEffect::staticMetaObjectExtraData = {
    0,  qt_static_metacall
};

const QMetaObject QGraphicsEffect::staticMetaObject = {
    { &QObject::staticMetaObject, qt_meta_stringdata_QGraphicsEffect,
      qt_meta_data_QGraphicsEffect, &staticMetaObjectExtraData }
};

#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &QGraphicsEffect::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION

const QMetaObject *QGraphicsEffect::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}

void *QGraphicsEffect::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_QGraphicsEffect))
        return static_cast<void*>(const_cast< QGraphicsEffect*>(this));
    return QObject::qt_metacast(_clname);
}

int QGraphicsEffect::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 3)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 3;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isEnabled(); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setEnabled(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 1;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 1;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 1;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}

// SIGNAL 0
void QGraphicsEffect::enabledChanged(bool _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 0, _a);
}
static const uint qt_meta_data_QGraphicsColorizeEffect[] = {

 // content:
       6,       // revision
       0,       // classname
       0,    0, // classinfo
       4,   14, // methods
       2,   34, // properties
       0,    0, // enums/sets
       0,    0, // constructors
       0,       // flags
       2,       // signalCount

 // signals: signature, parameters, type, tag, flags
      31,   25,   24,   24, 0x05,
      61,   52,   24,   24, 0x05,

 // slots: signature, parameters, type, tag, flags
      86,   84,   24,   24, 0x0a,
     103,   52,   24,   24, 0x0a,

 // properties: name, type, flags
      25,  122, 0x43495103,
      52,  129, ((uint)QMetaType::QReal << 24) | 0x00495103,

 // properties: notify_signal_id
       0,
       1,

       0        // eod
};

static const char qt_meta_stringdata_QGraphicsColorizeEffect[] = {
    "QGraphicsColorizeEffect\0\0color\0"
    "colorChanged(QColor)\0strength\0"
    "strengthChanged(qreal)\0c\0setColor(QColor)\0"
    "setStrength(qreal)\0QColor\0qreal\0"
};

void QGraphicsColorizeEffect::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    if (_c == QMetaObject::InvokeMetaMethod) {
        Q_ASSERT(staticMetaObject.cast(_o));
        QGraphicsColorizeEffect *_t = static_cast<QGraphicsColorizeEffect *>(_o);
        switch (_id) {
        case 0: _t->colorChanged((*reinterpret_cast< const QColor(*)>(_a[1]))); break;
        case 1: _t->strengthChanged((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 2: _t->setColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break;
        case 3: _t->setStrength((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        default: ;
        }
    }
}

const QMetaObjectExtraData QGraphicsColorizeEffect::staticMetaObjectExtraData = {
    0,  qt_static_metacall
};

const QMetaObject QGraphicsColorizeEffect::staticMetaObject = {
    { &QGraphicsEffect::staticMetaObject, qt_meta_stringdata_QGraphicsColorizeEffect,
      qt_meta_data_QGraphicsColorizeEffect, &staticMetaObjectExtraData }
};

#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &QGraphicsColorizeEffect::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION

const QMetaObject *QGraphicsColorizeEffect::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}

void *QGraphicsColorizeEffect::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_QGraphicsColorizeEffect))
        return static_cast<void*>(const_cast< QGraphicsColorizeEffect*>(this));
    return QGraphicsEffect::qt_metacast(_clname);
}

int QGraphicsColorizeEffect::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsEffect::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 4)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 4;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QColor*>(_v) = color(); break;
        case 1: *reinterpret_cast< qreal*>(_v) = strength(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setColor(*reinterpret_cast< QColor*>(_v)); break;
        case 1: setStrength(*reinterpret_cast< qreal*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}

// SIGNAL 0
void QGraphicsColorizeEffect::colorChanged(const QColor & _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 0, _a);
}

// SIGNAL 1
void QGraphicsColorizeEffect::strengthChanged(qreal _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
static const uint qt_meta_data_QGraphicsBlurEffect[] = {

 // content:
       6,       // revision
       0,       // classname
       0,    0, // classinfo
       4,   14, // methods
       2,   34, // properties
       2,   42, // enums/sets
       0,    0, // constructors
       0,       // flags
       2,       // signalCount

 // signals: signature, parameters, type, tag, flags
      32,   21,   20,   20, 0x05,
      63,   57,   20,   20, 0x05,

 // slots: signature, parameters, type, tag, flags
      91,   21,   20,   20, 0x0a,
     112,   57,   20,   20, 0x0a,

 // properties: name, type, flags
      21,  136, ((uint)QMetaType::QReal << 24) | 0x00495103,
     152,  142, 0x0049510b,

 // properties: notify_signal_id
       0,
       1,

 // enums: name, flags, count, data
     162, 0x1,    3,   50,
     142, 0x1,    3,   56,

 // enum data: key, value
     171, uint(QGraphicsBlurEffect::PerformanceHint),
     187, uint(QGraphicsBlurEffect::QualityHint),
     199, uint(QGraphicsBlurEffect::AnimationHint),
     171, uint(QGraphicsBlurEffect::PerformanceHint),
     187, uint(QGraphicsBlurEffect::QualityHint),
     199, uint(QGraphicsBlurEffect::AnimationHint),

       0        // eod
};

static const char qt_meta_stringdata_QGraphicsBlurEffect[] = {
    "QGraphicsBlurEffect\0\0blurRadius\0"
    "blurRadiusChanged(qreal)\0hints\0"
    "blurHintsChanged(BlurHints)\0"
    "setBlurRadius(qreal)\0setBlurHints(BlurHints)\0"
    "qreal\0BlurHints\0blurHints\0BlurHint\0"
    "PerformanceHint\0QualityHint\0AnimationHint\0"
};

void QGraphicsBlurEffect::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    if (_c == QMetaObject::InvokeMetaMethod) {
        Q_ASSERT(staticMetaObject.cast(_o));
        QGraphicsBlurEffect *_t = static_cast<QGraphicsBlurEffect *>(_o);
        switch (_id) {
        case 0: _t->blurRadiusChanged((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 1: _t->blurHintsChanged((*reinterpret_cast< BlurHints(*)>(_a[1]))); break;
        case 2: _t->setBlurRadius((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 3: _t->setBlurHints((*reinterpret_cast< BlurHints(*)>(_a[1]))); break;
        default: ;
        }
    }
}

const QMetaObjectExtraData QGraphicsBlurEffect::staticMetaObjectExtraData = {
    0,  qt_static_metacall
};

const QMetaObject QGraphicsBlurEffect::staticMetaObject = {
    { &QGraphicsEffect::staticMetaObject, qt_meta_stringdata_QGraphicsBlurEffect,
      qt_meta_data_QGraphicsBlurEffect, &staticMetaObjectExtraData }
};

#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &QGraphicsBlurEffect::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION

const QMetaObject *QGraphicsBlurEffect::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}

void *QGraphicsBlurEffect::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_QGraphicsBlurEffect))
        return static_cast<void*>(const_cast< QGraphicsBlurEffect*>(this));
    return QGraphicsEffect::qt_metacast(_clname);
}

int QGraphicsBlurEffect::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsEffect::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 4)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 4;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< qreal*>(_v) = blurRadius(); break;
        case 1: *reinterpret_cast<int*>(_v) = QFlag(blurHints()); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setBlurRadius(*reinterpret_cast< qreal*>(_v)); break;
        case 1: setBlurHints(QFlag(*reinterpret_cast<int*>(_v))); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}

// SIGNAL 0
void QGraphicsBlurEffect::blurRadiusChanged(qreal _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 0, _a);
}

// SIGNAL 1
void QGraphicsBlurEffect::blurHintsChanged(BlurHints _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
static const uint qt_meta_data_QGraphicsDropShadowEffect[] = {

 // content:
       6,       // revision
       0,       // classname
       0,    0, // classinfo
      10,   14, // methods
       5,   64, // properties
       0,    0, // enums/sets
       0,    0, // constructors
       0,       // flags
       3,       // signalCount

 // signals: signature, parameters, type, tag, flags
      34,   27,   26,   26, 0x05,
      68,   57,   26,   26, 0x05,
      99,   93,   26,   26, 0x05,

 // slots: signature, parameters, type, tag, flags
     124,  120,   26,   26, 0x0a,
     149,  143,   26,   26, 0x0a,
     174,  172,   26,   26, 0x0a,
     194,  191,   26,   26, 0x0a,
     215,  212,   26,   26, 0x0a,
     233,   57,   26,   26, 0x0a,
     254,   93,   26,   26, 0x0a,

 // properties: name, type, flags
      27,  271, 0x1a495103,
     285,  279, ((uint)QMetaType::QReal << 24) | 0x00495103,
     293,  279, ((uint)QMetaType::QReal << 24) | 0x00495103,
      57,  279, ((uint)QMetaType::QReal << 24) | 0x00495103,
      93,  301, 0x43495103,

 // properties: notify_signal_id
       0,
       0,
       0,
       1,
       2,

       0        // eod
};

static const char qt_meta_stringdata_QGraphicsDropShadowEffect[] = {
    "QGraphicsDropShadowEffect\0\0offset\0"
    "offsetChanged(QPointF)\0blurRadius\0"
    "blurRadiusChanged(qreal)\0color\0"
    "colorChanged(QColor)\0ofs\0setOffset(QPointF)\0"
    "dx,dy\0setOffset(qreal,qreal)\0d\0"
    "setOffset(qreal)\0dx\0setXOffset(qreal)\0"
    "dy\0setYOffset(qreal)\0setBlurRadius(qreal)\0"
    "setColor(QColor)\0QPointF\0qreal\0xOffset\0"
    "yOffset\0QColor\0"
};

void QGraphicsDropShadowEffect::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    if (_c == QMetaObject::InvokeMetaMethod) {
        Q_ASSERT(staticMetaObject.cast(_o));
        QGraphicsDropShadowEffect *_t = static_cast<QGraphicsDropShadowEffect *>(_o);
        switch (_id) {
        case 0: _t->offsetChanged((*reinterpret_cast< const QPointF(*)>(_a[1]))); break;
        case 1: _t->blurRadiusChanged((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 2: _t->colorChanged((*reinterpret_cast< const QColor(*)>(_a[1]))); break;
        case 3: _t->setOffset((*reinterpret_cast< const QPointF(*)>(_a[1]))); break;
        case 4: _t->setOffset((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2]))); break;
        case 5: _t->setOffset((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 6: _t->setXOffset((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 7: _t->setYOffset((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 8: _t->setBlurRadius((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 9: _t->setColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break;
        default: ;
        }
    }
}

const QMetaObjectExtraData QGraphicsDropShadowEffect::staticMetaObjectExtraData = {
    0,  qt_static_metacall
};

const QMetaObject QGraphicsDropShadowEffect::staticMetaObject = {
    { &QGraphicsEffect::staticMetaObject, qt_meta_stringdata_QGraphicsDropShadowEffect,
      qt_meta_data_QGraphicsDropShadowEffect, &staticMetaObjectExtraData }
};

#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &QGraphicsDropShadowEffect::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION

const QMetaObject *QGraphicsDropShadowEffect::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}

void *QGraphicsDropShadowEffect::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_QGraphicsDropShadowEffect))
        return static_cast<void*>(const_cast< QGraphicsDropShadowEffect*>(this));
    return QGraphicsEffect::qt_metacast(_clname);
}

int QGraphicsDropShadowEffect::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsEffect::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 10)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 10;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QPointF*>(_v) = offset(); break;
        case 1: *reinterpret_cast< qreal*>(_v) = xOffset(); break;
        case 2: *reinterpret_cast< qreal*>(_v) = yOffset(); break;
        case 3: *reinterpret_cast< qreal*>(_v) = blurRadius(); break;
        case 4: *reinterpret_cast< QColor*>(_v) = color(); break;
        }
        _id -= 5;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setOffset(*reinterpret_cast< QPointF*>(_v)); break;
        case 1: setXOffset(*reinterpret_cast< qreal*>(_v)); break;
        case 2: setYOffset(*reinterpret_cast< qreal*>(_v)); break;
        case 3: setBlurRadius(*reinterpret_cast< qreal*>(_v)); break;
        case 4: setColor(*reinterpret_cast< QColor*>(_v)); break;
        }
        _id -= 5;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 5;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 5;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}

// SIGNAL 0
void QGraphicsDropShadowEffect::offsetChanged(const QPointF & _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 0, _a);
}

// SIGNAL 1
void QGraphicsDropShadowEffect::blurRadiusChanged(qreal _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 1, _a);
}

// SIGNAL 2
void QGraphicsDropShadowEffect::colorChanged(const QColor & _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 2, _a);
}
static const uint qt_meta_data_QGraphicsOpacityEffect[] = {

 // content:
       6,       // revision
       0,       // classname
       0,    0, // classinfo
       4,   14, // methods
       2,   34, // properties
       0,    0, // enums/sets
       0,    0, // constructors
       0,       // flags
       2,       // signalCount

 // signals: signature, parameters, type, tag, flags
      32,   24,   23,   23, 0x05,
      59,   54,   23,   23, 0x05,

 // slots: signature, parameters, type, tag, flags
      86,   24,   23,   23, 0x0a,
     104,   54,   23,   23, 0x0a,

 // properties: name, type, flags
      24,  127, ((uint)QMetaType::QReal << 24) | 0x00495103,
     140,  133, 0x42495103,

 // properties: notify_signal_id
       0,
       1,

       0        // eod
};

static const char qt_meta_stringdata_QGraphicsOpacityEffect[] = {
    "QGraphicsOpacityEffect\0\0opacity\0"
    "opacityChanged(qreal)\0mask\0"
    "opacityMaskChanged(QBrush)\0setOpacity(qreal)\0"
    "setOpacityMask(QBrush)\0qreal\0QBrush\0"
    "opacityMask\0"
};

void QGraphicsOpacityEffect::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    if (_c == QMetaObject::InvokeMetaMethod) {
        Q_ASSERT(staticMetaObject.cast(_o));
        QGraphicsOpacityEffect *_t = static_cast<QGraphicsOpacityEffect *>(_o);
        switch (_id) {
        case 0: _t->opacityChanged((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 1: _t->opacityMaskChanged((*reinterpret_cast< const QBrush(*)>(_a[1]))); break;
        case 2: _t->setOpacity((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 3: _t->setOpacityMask((*reinterpret_cast< const QBrush(*)>(_a[1]))); break;
        default: ;
        }
    }
}

const QMetaObjectExtraData QGraphicsOpacityEffect::staticMetaObjectExtraData = {
    0,  qt_static_metacall
};

const QMetaObject QGraphicsOpacityEffect::staticMetaObject = {
    { &QGraphicsEffect::staticMetaObject, qt_meta_stringdata_QGraphicsOpacityEffect,
      qt_meta_data_QGraphicsOpacityEffect, &staticMetaObjectExtraData }
};

#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &QGraphicsOpacityEffect::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION

const QMetaObject *QGraphicsOpacityEffect::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}

void *QGraphicsOpacityEffect::qt_metacast(const char *_clname)
{
    if (!_clname) return 0;
    if (!strcmp(_clname, qt_meta_stringdata_QGraphicsOpacityEffect))
        return static_cast<void*>(const_cast< QGraphicsOpacityEffect*>(this));
    return QGraphicsEffect::qt_metacast(_clname);
}

int QGraphicsOpacityEffect::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsEffect::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 4)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 4;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< qreal*>(_v) = opacity(); break;
        case 1: *reinterpret_cast< QBrush*>(_v) = opacityMask(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setOpacity(*reinterpret_cast< qreal*>(_v)); break;
        case 1: setOpacityMask(*reinterpret_cast< QBrush*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}

// SIGNAL 0
void QGraphicsOpacityEffect::opacityChanged(qreal _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 0, _a);
}

// SIGNAL 1
void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush & _t1)
{
    void *_a[] = { 0, const_cast<void*>(reinterpret_cast<const void*>(&_t1)) };
    QMetaObject::activate(this, &staticMetaObject, 1, _a);
}
QT_END_MOC_NAMESPACE


text:
@implementation CBCellOptions

- (id) initWithTitle:(NSString*)title andValuePath:(NSString*)valuePath andPickerOptions:(NSArray*)options {
	if (self = [super initWithTitle:title andValuePath:valuePath]) {

		self.style = title ? UITableViewCellStyleValue1 : UITableViewCellStyleDefault;
		self.multiline = NO;

		NSMutableDictionary *d = [[NSMutableDictionary alloc] init];
		for (CBPickerOption *o in options) {
			[d setObject:o forKey:(id)o.value];
		}
		_options = d;
	}
	return self;
}

+ (CBCellOptions*) cellWithTitle:(NSString*)title valuePath:(NSString*)valuePath pickerOptions:(NSArray*)options {
	CBCellOptions *cell = [[[self class] alloc] initWithTitle:title
                                                 andValuePath:valuePath
                                             andPickerOptions:options];
	return cell;
}

+ (CBCellOptions*) cellWithTitle:(NSString*)title valuePath:(NSString*)valuePath pickerOptions:(NSArray*)options editor:(CBEditor*)editor {
	CBCellOptions *cell = [[[self class] alloc] initWithTitle:title
                                                 andValuePath:valuePath
                                             andPickerOptions:options];
	cell.editor = editor;
	return cell;
}

- (CBCellOptions*) applyDefaultValue:(NSObject*) defaultValue;
{
    _defaultValue = defaultValue;

    return self;
}

- (void) dealloc
{
	_options = nil;
    _defaultValue = nil;

}

#pragma mark CBCell protocol

- (void) setValue:(id)value
		   ofCell:(UITableViewCell*)cell
	  inTableView:(UITableView*)tableView {
	value = [_options objectForKey:value];
    if (!value && _defaultValue) {
        value = [_options objectForKey:_defaultValue];
    }

    if (![value isKindOfClass:[CBPickerOption class]]) {
        [super setValue:value ofCell:cell inTableView:tableView];
    } else {
        CBPickerOption *option = value;
        [super setValue:option.label ofCell:cell inTableView:tableView];

        if (option.icon) {
            cell.imageView.image = option.icon;
        } else {
            cell.imageView.image = nil;
        }
    }

}

@end


text:
import transaction
import pytest

from kinto.core.errors import ERRORS
from kinto.core.storage.exceptions import RecordNotFoundError
from kinto.core.testing import FormattedErrorMixin, sqlalchemy, unittest
from kinto.plugins.quotas.listener import (
    QUOTA_RESOURCE_NAME, QUOTA_BUCKET_ID, QUOTA_COLLECTION_ID)
from kinto.plugins.quotas.utils import record_size

from .. import support

class QuotaWebTest(support.BaseWebTest, unittest.TestCase):

    bucket_uri = '/buckets/test'
    collection_uri = '/buckets/test/collections/col'
    record_uri = '/buckets/test/collections/col/records/rec'
    group_uri = '/buckets/test/groups/grp'

    @classmethod
    def setUpClass(cls):
        if not sqlalchemy:
            raise unittest.SkipTest("postgresql is not installed.")

    def create_bucket(self):
        resp = self.app.put(self.bucket_uri, headers=self.headers)
        self.bucket = resp.json['data']

    def create_collection(self):
        resp = self.app.put(self.collection_uri, headers=self.headers)
        self.collection = resp.json['data']

    def create_group(self):
        body = {'data': {'members': ['elle']}}
        resp = self.app.put_json(self.group_uri, body, headers=self.headers)
        self.group = resp.json['data']

    def create_record(self):
        body = {'data': {'foo': 42}}
        resp = self.app.put_json(self.record_uri, body, headers=self.headers)
        self.record = resp.json['data']

    def get_app_settings(self, extras=None):
        settings = super(QuotaWebTest, self).get_app_settings(extras)

        # Setup the postgresql backend for transaction support.
        settings['storage_backend'] = 'kinto.core.storage.postgresql'
        db = "postgres://postgres:postgres@localhost/testdb"
        settings['storage_url'] = db
        settings['permission_backend'] = 'kinto.core.permission.postgresql'
        settings['permission_url'] = db
        settings['cache_backend'] = 'kinto.core.cache.memory'

        settings['includes'] = 'kinto.plugins.quotas'
        return settings

    def assertStatsEqual(self, data, stats):
        for key in stats:
            assert data[key] == stats[key]

class HelloViewTest(QuotaWebTest):

    def test_quota_capability_if_enabled(self):
        resp = self.app.get('/')
        capabilities = resp.json['capabilities']
        self.assertIn('quotas', capabilities)

class QuotaListenerTest(QuotaWebTest):

    #
    # Bucket
    #
    def test_quota_tracks_bucket_creation(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(self.record)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

    def test_tracks_bucket_attributes_update(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        body = {'data': {'foo': 'baz'}}
        resp = self.app.patch_json(self.bucket_uri, body,
                                   headers=self.headers)
        storage_size = record_size(resp.json['data'])
        storage_size += record_size(self.collection)
        storage_size += record_size(self.record)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

    def test_bucket_delete_destroys_its_quota_entries(self):
        self.create_bucket()
        self.app.delete(self.bucket_uri, headers=self.headers)
        stored_in_backend, _ = self.storage.get_all(
            parent_id='/buckets/test',
            collection_id=QUOTA_RESOURCE_NAME)
        assert len(stored_in_backend) == 0

    def test_bucket_delete_doesnt_raise_if_quota_entries_do_not_exist(self):
        self.create_bucket()
        self.storage.delete(parent_id='/buckets/test',
                            collection_id=QUOTA_RESOURCE_NAME,
                            object_id=QUOTA_BUCKET_ID)
        transaction.commit()
        self.app.delete(self.bucket_uri, headers=self.headers)

    #
    # Collection
    #
    def test_stats_are_not_accessible_if_collection_does_not_exist(self):
        self.create_bucket()
        self.app.get(self.collection_uri, headers=self.headers, status=404)

    def test_quota_tracks_collection_creation(self):
        self.create_bucket()
        self.create_collection()

        # Bucket stats
        storage_size = record_size(self.bucket) + record_size(self.collection)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 0,
            "storage_size": storage_size
        })

        # Collection stats
        storage_size = record_size(self.collection)
        data = self.storage.get(QUOTA_RESOURCE_NAME, self.collection_uri,
                                QUOTA_COLLECTION_ID)
        self.assertStatsEqual(data, {
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_tracks_collection_attributes_update(self):
        self.create_bucket()
        self.create_collection()
        body = {'data': {'foo': 'baz'}}
        resp = self.app.patch_json(self.collection_uri, body,
                                   headers=self.headers)
        # Bucket stats
        storage_size = record_size(self.bucket)
        storage_size += record_size(resp.json['data'])

        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 0,
            "storage_size": storage_size
        })

        # Collection stats
        storage_size -= record_size(self.bucket)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.collection_uri,
                                object_id=QUOTA_COLLECTION_ID)
        self.assertStatsEqual(data, {
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_tracks_collection_delete(self):
        self.create_bucket()
        self.create_collection()
        body = {'data': {'foo': 'baz'}}
        self.app.patch_json(self.collection_uri, body,
                            headers=self.headers)
        self.app.delete(self.collection_uri, headers=self.headers)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 0,
            "record_count": 0,
            "storage_size": record_size(self.bucket)
        })

    def test_collection_delete_destroys_its_quota_entries(self):
        self.create_bucket()
        self.create_collection()
        self.app.delete(self.collection_uri, headers=self.headers)
        stored_in_backend, _ = self.storage.get_all(
            parent_id=self.collection_uri,
            collection_id=QUOTA_RESOURCE_NAME)
        assert len(stored_in_backend) == 0

    def test_collection_delete_doesnt_raise_if_quota_entries_dont_exist(self):
        self.create_bucket()
        self.create_collection()
        self.storage.delete(parent_id=self.collection_uri,
                            collection_id=QUOTA_RESOURCE_NAME,
                            object_id=QUOTA_COLLECTION_ID)
        transaction.commit()
        self.app.delete(self.collection_uri, headers=self.headers)

    def test_tracks_collection_delete_with_multiple_records(self):
        self.create_bucket()
        self.create_collection()
        body = {'data': {'foo': 42}}
        self.app.post_json('%s/records' % self.collection_uri,
                           body, headers=self.headers)
        self.app.post_json('%s/records' % self.collection_uri,
                           body, headers=self.headers)
        self.app.post_json('%s/records' % self.collection_uri,
                           body, headers=self.headers)
        self.app.post_json('%s/records' % self.collection_uri,
                           body, headers=self.headers)
        self.app.delete(self.collection_uri, headers=self.headers)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 0,
            "record_count": 0,
            "storage_size": record_size(self.bucket)
        })

    #
    # Group
    #

    def test_quota_tracks_group_creation(self):
        self.create_bucket()
        self.create_group()
        storage_size = record_size(self.bucket) + record_size(self.group)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 0,
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_tracks_group_attributes_update(self):
        self.create_bucket()
        self.create_group()
        body = {'data': {'foo': 'baz', 'members': ['lui']}}
        resp = self.app.patch_json(self.group_uri, body,
                                   headers=self.headers)
        storage_size = record_size(self.bucket)
        storage_size += record_size(resp.json['data'])
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 0,
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_tracks_group_delete(self):
        self.create_bucket()
        self.create_group()
        self.app.delete(self.group_uri, headers=self.headers)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 0,
            "record_count": 0,
            "storage_size": record_size(self.bucket)
        })

    #
    # Record
    #

    def test_quota_tracks_record_creation(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(self.record)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

    def test_tracks_record_attributes_update(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        resp = self.app.patch_json(self.record_uri, {'data': {'foo': 'baz'}},
                                   headers=self.headers)
        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(resp.json['data'])
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

    def test_tracks_record_delete(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        self.app.delete(self.record_uri, headers=self.headers)
        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_tracks_records_delete_with_multiple_records(self):
        self.create_bucket()
        self.create_collection()
        body = {'data': {'foo': 42}}
        self.app.post_json('%s/records' % self.collection_uri,
                           body, headers=self.headers)
        self.app.post_json('%s/records' % self.collection_uri,
                           body, headers=self.headers)
        self.app.post_json('%s/records' % self.collection_uri,
                           body, headers=self.headers)
        self.app.post_json('%s/records' % self.collection_uri,
                           body, headers=self.headers)
        self.app.delete('%s/records' % self.collection_uri,
                        headers=self.headers)
        storage_size = record_size(self.bucket) + record_size(self.collection)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_bulk_create(self):
        body = {
            'defaults': {
                'method': 'POST',
                'path': '%s/records' % self.collection_uri,
            },
            'requests': [{
                'path': self.bucket_uri,
                'method': 'PUT'
            }, {
                'path': self.collection_uri,
                'method': 'PUT'
            }, {
                'body': {'data': {'id': 'a', 'attr': 1}},
            }, {
                'body': {'data': {'id': 'b', 'attr': 2}},
            }, {
                'body': {'data': {'id': 'c', 'attr': 3}}
            }]
        }
        self.app.post_json('/batch', body, headers=self.headers)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 3,
            "storage_size": 232
        })

    def test_bulk_update(self):
        body = {
            'defaults': {
                'method': 'POST',
                'path': '%s/collections' % self.bucket_uri,
            },
            'requests': [{
                'path': self.bucket_uri,
                'method': 'PUT'
            }, {
                'body': {'data': {'id': 'a', 'attr': 10}},
            }, {
                'body': {'data': {'id': 'b', 'attr': 200}},
            }, {
                'body': {'data': {'id': 'c', 'attr': 3000}}
            }]
        }
        self.app.post_json('/batch', body, headers=self.headers)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 3,
            "record_count": 0,
            "storage_size": 196
        })
        body = {
            'defaults': {
                'method': 'PUT',
            },
            'requests': [{
                'path': '%s/collections/a' % self.bucket_uri,
                'body': {'data': {'attr': 100}},
            }, {
                'path': '%s/collections/b' % self.bucket_uri,
                'body': {'data': {'attr': 2000}},
            }, {
                'path': '%s/collections/c' % self.bucket_uri,
                'body': {'data': {'attr': 30000}}
            }]
        }
        self.app.post_json('/batch', body, headers=self.headers)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 3,
            "record_count": 0,
            "storage_size": 199
        })

    def test_bulk_delete(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()

        body = {
            'defaults': {
                'method': 'POST',
                'path': '%s/collections' % self.bucket_uri,
            },
            'requests': [{
                'body': {'data': {'id': 'a', 'attr': 1}},
            }, {
                'body': {'data': {'id': 'b', 'attr': 2}},
            }, {
                'body': {'data': {'id': 'c', 'attr': 3}}
            }]
        }
        self.app.post_json('/batch', body, headers=self.headers)

        body = {
            'defaults': {
                'method': 'DELETE',
            },
            'requests': [{
                'path': '%s/collections/a' % self.bucket_uri
            }, {
                'path': '%s/collections/b' % self.bucket_uri
            }, {
                'path': '%s/collections/c' % self.bucket_uri
            }, {
                'path': self.collection_uri
            }]
        }
        self.app.post_json('/batch', body, headers=self.headers)

        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 0,
            "record_count": 0,
            "storage_size": record_size(self.bucket)
        })

        with pytest.raises(RecordNotFoundError):
            self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                             parent_id='%s/collections/a' % self.bucket_uri,
                             object_id=QUOTA_COLLECTION_ID)

        with pytest.raises(RecordNotFoundError):
            self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                             parent_id='%s/collections/b' % self.bucket_uri,
                             object_id=QUOTA_COLLECTION_ID)

        with pytest.raises(RecordNotFoundError):
            self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                             parent_id='%s/collections/c' % self.bucket_uri,
                             object_id=QUOTA_COLLECTION_ID)

        with pytest.raises(RecordNotFoundError):
            self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                             parent_id=self.collection_uri,
                             object_id=QUOTA_COLLECTION_ID)

class QuotaBucketRecordMixin(object):
    def test_507_is_raised_if_quota_exceeded_on_record_creation(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        body = {'data': {'foo': 42}}
        resp = self.app.post_json('%s/records' % self.collection_uri,
                                  body, headers=self.headers, status=507)

        # Check that the storage was not updated.
        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(self.record)

        self.assertFormattedError(
            resp, 507, ERRORS.FORBIDDEN, "Insufficient Storage",
            self.error_message)

        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

        # Check that the record wasn't created
        resp = self.app.get('%s/records' % self.collection_uri,
                            headers=self.headers)
        assert len(resp.json['data']) == 1

class QuotaBucketUpdateMixin(object):
    def test_507_is_raised_if_quota_exceeded_on_record_update(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        body = {'data': {'foo': 42, 'bar': 'This is a very long string.'}}
        resp = self.app.patch_json(self.record_uri,
                                   body, headers=self.headers, status=507)

        # Check that the storage was not updated.
        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(self.record)

        self.assertFormattedError(
            resp, 507, ERRORS.FORBIDDEN, "Insufficient Storage",
            self.error_message)

        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

    def test_507_is_raised_if_quota_exceeded_on_collection_update(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        body = {'data': {'foo': 42, 'bar': 'This is a very long string.'}}
        resp = self.app.patch_json(self.collection_uri,
                                   body, headers=self.headers, status=507)

        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(self.record)

        self.assertFormattedError(
            resp, 507, ERRORS.FORBIDDEN, "Insufficient Storage",
            self.error_message)

        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

    def test_507_is_raised_if_quota_exceeded_on_group_update(self):
        self.create_bucket()
        self.create_collection()
        body = {'data': {'members': []}}
        resp = self.app.put_json(self.group_uri, body,
                                 headers=self.headers)
        group = resp.json['data']
        body = {'data': {'members': ['elle', 'lui', 'je', 'tu', 'il', 'nous',
                                     'vous', 'ils', 'elles']}}
        resp = self.app.put_json(self.group_uri, body,
                                 headers=self.headers, status=507)

        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(group)

        self.assertFormattedError(
            resp, 507, ERRORS.FORBIDDEN, "Insufficient Storage",
            self.error_message)

        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_507_is_not_raised_if_quota_exceeded_on_record_delete(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        self.app.delete(self.record_uri, headers=self.headers)

        # Check that the storage was not updated.
        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_507_is_not_raised_if_quota_exceeded_on_collection_delete(self):
        self.create_bucket()
        self.create_collection()
        # fake the quota to the Max
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        data['storage_size'] = 140
        self.storage.update(collection_id=QUOTA_RESOURCE_NAME,
                            parent_id=self.bucket_uri,
                            object_id=QUOTA_BUCKET_ID,
                            record=data)
        transaction.commit()
        self.app.delete(self.collection_uri,
                        headers=self.headers)

        storage_size = 140
        storage_size -= record_size(self.collection)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 0,
            "record_count": 0,
            "storage_size": storage_size
        })

    def test_507_is_raised_if_quota_exceeded_on_group_delete(self):
        self.create_bucket()
        body = {"data": {"members": []}}
        resp = self.app.put_json(self.group_uri, body, headers=self.headers)
        group = resp.json['data']
        # fake the quota to the Max
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        data['storage_size'] = 140
        self.storage.update(collection_id=QUOTA_RESOURCE_NAME,
                            parent_id=self.bucket_uri,
                            object_id=QUOTA_BUCKET_ID,
                            record=data)
        transaction.commit()

        self.app.delete(self.group_uri, headers=self.headers)

        storage_size = 140
        storage_size -= record_size(group)
        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 0,
            "record_count": 0,
            "storage_size": storage_size
        })

class QuotaBucketMixin(object):
    def test_507_is_raised_if_quota_exceeded_on_collection_creation(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        body = {'data': {'foo': 42}}
        resp = self.app.post_json('%s/collections' % self.bucket_uri,
                                  body, headers=self.headers, status=507)

        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(self.record)

        self.assertFormattedError(
            resp, 507, ERRORS.FORBIDDEN, "Insufficient Storage",
            self.error_message)

        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

        # Check that the collection wasn't created
        resp = self.app.get('%s/collections' % self.bucket_uri,
                            headers=self.headers)
        assert len(resp.json['data']) == 1

    def test_507_is_raised_if_quota_exceeded_on_group_creation(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        body = {'data': {'members': ['elle']}}
        resp = self.app.put_json(self.group_uri, body,
                                 headers=self.headers, status=507)

        storage_size = record_size(self.bucket)
        storage_size += record_size(self.collection)
        storage_size += record_size(self.record)

        self.assertFormattedError(
            resp, 507, ERRORS.FORBIDDEN, "Insufficient Storage",
            self.error_message)

        data = self.storage.get(collection_id=QUOTA_RESOURCE_NAME,
                                parent_id=self.bucket_uri,
                                object_id=QUOTA_BUCKET_ID)
        self.assertStatsEqual(data, {
            "collection_count": 1,
            "record_count": 1,
            "storage_size": storage_size
        })

        # Check that the group wasn't created
        resp = self.app.get('%s/groups' % self.bucket_uri,
                            headers=self.headers)
        assert len(resp.json['data']) == 0

class QuotaMaxBytesExceededSettingsListenerTest(
        FormattedErrorMixin, QuotaBucketRecordMixin, QuotaBucketUpdateMixin,
        QuotaBucketMixin, QuotaWebTest):

    error_message = "Bucket maximum total size exceeded "

    def get_app_settings(self, extras=None):
        settings = super(QuotaMaxBytesExceededSettingsListenerTest,
                         self).get_app_settings(extras)
        settings['quotas.bucket_max_bytes'] = '150'
        return settings

class QuotaMaxBytesExceededBucketSettingsListenerTest(
        FormattedErrorMixin, QuotaBucketRecordMixin, QuotaBucketUpdateMixin,
        QuotaBucketMixin, QuotaWebTest):

    error_message = "Bucket maximum total size exceeded "

    def get_app_settings(self, extras=None):
        settings = super(QuotaMaxBytesExceededBucketSettingsListenerTest,
                         self).get_app_settings(extras)
        settings['quotas.bucket_test_max_bytes'] = '150'
        return settings

class QuotaMaxItemsExceededSettingsListenerTest(
        FormattedErrorMixin, QuotaBucketRecordMixin, QuotaWebTest):

    error_message = "Bucket maximum number of objects exceeded "

    def get_app_settings(self, extras=None):
        settings = super(QuotaMaxItemsExceededSettingsListenerTest,
                         self).get_app_settings(extras)
        settings['quotas.bucket_max_items'] = '1'
        return settings

class QuotaMaxItemsExceededBucketSettingsListenerTest(
        FormattedErrorMixin, QuotaBucketRecordMixin, QuotaWebTest):

    error_message = "Bucket maximum number of objects exceeded "

    def get_app_settings(self, extras=None):
        settings = super(QuotaMaxItemsExceededBucketSettingsListenerTest,
                         self).get_app_settings(extras)
        settings['quotas.bucket_test_max_items'] = '1'
        return settings

class QuotaMaxBytesPerItemExceededListenerTest(
        FormattedErrorMixin, QuotaBucketRecordMixin, QuotaBucketUpdateMixin,
        QuotaBucketMixin, QuotaWebTest):

    error_message = "Maximum bytes per object exceeded "

    def get_app_settings(self, extras=None):
        settings = super(QuotaMaxBytesPerItemExceededListenerTest,
                         self).get_app_settings(extras)
        settings['quotas.bucket_max_bytes_per_item'] = '55'
        return settings

class QuotaMaxBytesPerItemExceededBucketListenerTest(
        FormattedErrorMixin, QuotaBucketRecordMixin, QuotaBucketUpdateMixin,
        QuotaBucketMixin, QuotaWebTest):

    error_message = "Maximum bytes per object exceeded "

    def get_app_settings(self, extras=None):
        settings = super(QuotaMaxBytesPerItemExceededBucketListenerTest,
                         self).get_app_settings(extras)
        settings['quotas.bucket_test_max_bytes_per_item'] = '55'
        return settings

class QuotaCollectionMixin(object):
    def test_507_is_raised_if_quota_exceeded_on_record_creation(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        body = {'data': {'foo': 42}}
        resp = self.app.post_json('%s/records' % self.collection_uri,
                                  body, headers=self.headers, status=507)

        # Check that the storage was not updated.
        storage_size = record_size(self.collection)
        storage_size += record_size(self.record)

        self.assertFormattedError(
            resp, 507, ERRORS.FORBIDDEN, "Insufficient Storage",
            self.error_message)

        data = self.storage.get(QUOTA_RESOURCE_NAME, self.collection_uri,
                                QUOTA_COLLECTION_ID)
        self.assertStatsEqual(data, {
            "record_count": 1,
            "storage_size": storage_size
        })

class QuotaCollectionUpdateMixin(object):
    def test_507_is_raised_if_quota_exceeded_on_record_update(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        body = {'data': {'foo': 42, 'bar': 'This is a very long string.'}}
        resp = self.app.patch_json(self.record_uri,
                                   body, headers=self.headers, status=507)

        # Check that the storage was not updated.
        storage_size = record_size(self.collection)
        storage_size += record_size(self.record)

        self.assertFormattedError(
            resp, 507, ERRORS.FORBIDDEN, "Insufficient Storage",
            self.error_message)

        data = self.storage.get(QUOTA_RESOURCE_NAME, self.collection_uri,
                                QUOTA_COLLECTION_ID)
        self.assertStatsEqual(data, {
            "record_count": 1,
            "storage_size": storage_size
        })

    def test_507_is_not_raised_if_quota_exceeded_on_record_delete(self):
        self.create_bucket()
        self.create_collection()
        self.create_record()
        self.app.delete(self.record_uri, headers=self.headers)

        # Check that the storage was not updated.
        storage_size = record_size(self.collection)
        data = self.storage.get(QUOTA_RESOURCE_NAME, self.collection_uri,
                                QUOTA_COLLECTION_ID)
        self.assertStatsEqual(data, {
            "record_count": 0,
            "storage_size": storage_size
        })

class QuotaMaxBytesExceededCollectionSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaCollectionUpdateMixin,
        QuotaWebTest):

    error_message = "Collection maximum size exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxBytesExceededCollectionSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_max_bytes'] = '100'
        return settings

class QuotaMaxBytesExceededCollectionBucketSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaCollectionUpdateMixin,
        QuotaWebTest):

    error_message = "Collection maximum size exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxBytesExceededCollectionBucketSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_test_max_bytes'] = '100'
        return settings

class QuotaMaxBytesExceededBucketCollectionSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaCollectionUpdateMixin,
        QuotaWebTest):

    error_message = "Collection maximum size exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxBytesExceededBucketCollectionSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_test_col_max_bytes'] = '100'
        return settings

class QuotaMaxItemsExceededCollectionSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaWebTest):

    error_message = "Collection maximum number of objects exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxItemsExceededCollectionSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_max_items'] = '1'
        return settings

class QuotaMaxItemsExceededCollectionBucketSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaWebTest):

    error_message = "Collection maximum number of objects exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxItemsExceededCollectionBucketSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_test_max_items'] = '1'
        return settings

class QuotaMaxItemsExceededBucketCollectionSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaWebTest):

    error_message = "Collection maximum number of objects exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxItemsExceededBucketCollectionSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_test_col_max_items'] = '1'
        return settings

class QuotaMaxBytesPerItemExceededCollectionSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaWebTest):

    error_message = "Maximum bytes per object exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxBytesPerItemExceededCollectionSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_max_bytes_per_item'] = '80'
        return settings

class QuotaMaxBytesPerItemExceededCollectionBucketSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaCollectionUpdateMixin,
        QuotaWebTest):

    error_message = "Maximum bytes per object exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxBytesPerItemExceededCollectionBucketSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_test_max_bytes_per_item'] = '80'
        return settings

class QuotaMaxBytesPerItemExceededBucketCollectionSettingsListenerTest(
        FormattedErrorMixin, QuotaCollectionMixin, QuotaCollectionUpdateMixin,
        QuotaWebTest):

    error_message = "Maximum bytes per object exceeded "

    def get_app_settings(self, extras=None):
        settings = super(
            QuotaMaxBytesPerItemExceededBucketCollectionSettingsListenerTest,
            self).get_app_settings(extras)
        settings['quotas.collection_test_col_max_bytes_per_item'] = '80'
        return settings