text:
// Copyright (c) 2014, Alexandre Mutel
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted
// provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions
//    and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
//    and the following disclaimer in the documentation and/or other materials provided with the
//    distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
//  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace SharpCLABot.ViewModels
{
    /// <summary>
    /// Connection status.
    /// </summary>
    public class DbConnectionStatus
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DbConnectionStatus"/> class.
        /// </summary>
        public DbConnectionStatus()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DbConnectionStatus"/> class.
        /// </summary>
        /// <param name="isValid">if set to <c>true</c> [is valid].</param>
        public DbConnectionStatus(bool isValid)
        {
            IsValid = isValid;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DbConnectionStatus"/> class.
        /// </summary>
        /// <param name="isValid">if set to <c>true</c> [is valid].</param>
        /// <param name="message">The message.</param>
        public DbConnectionStatus(bool isValid, string message)
        {
            IsValid = isValid;
            Message = message;
        }

        /// <summary>
        /// Gets or sets a value indicating whether the connection is valid.
        /// </summary>
        /// <value><c>true</c> if the connection is valid; otherwise, <c>false</c>.</value>
        public bool IsValid { get; set; }

        /// <summary>
        /// Gets or sets the message indicating wether the connection is valid.
        /// </summary>
        /// <value>The message.</value>
        public string Message { get; set; }
    }
}


text:
<?xml version="1.0" encoding="utf-8" ?>

<collections>
  <collection>
    <name>Dimensional anchor</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Create undead</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Acid splash</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Resistance</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Detect poison</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Detect magic</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Read magic</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Daze</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Dancing lights</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Flare</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Light</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Ray of frost</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Ghost sound</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Disrupt undead</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Touch of fatigue</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Mage hand</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Mending</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Message</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Open/Close</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Arcane mark</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Prestidigitation</name>
    <entry>0</entry>
  </collection>
  <collection>
    <name>Alarm</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Endure elements</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Hold portal</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Protection from chaos/law/good/evil</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Shield</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Disguise self</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Grease</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Mage armor</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Mount</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Obscuring mist</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Summon monster I</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Unseen servant</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Comprehend languages</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Detect secret doors</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Detect undead</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Identify</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>True strike</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Charm person</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Hypnotism</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Sleep</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Burning hands</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Floating disk</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Magic missile</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Shocking grasp</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Color spray</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Magic aura</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Silent image</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Ventriloquism</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Cause fear</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Chill touch</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Ray of enfeeblement</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Animate rope</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Enlarge person</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Erase</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Expeditious retreat</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Feather fall</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Jump</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Magic weapon</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Reduce person</name>
    <entry>1</entry>
  </collection>
  <collection>
    <name>Arcane lock</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Obscure object</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Protection from arrows</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Resist energy</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Acid arrow</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Fog cloud</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Glitterdust</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Summon monster II</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Summon swarm</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Web</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Detect thoughts</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Locate object</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>See invisibility</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Daze monster</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Hideous laughter</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Touch of idiocy</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Continual flame</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Darkness</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Flaming sphere</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Gust of wind</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Scorching ray</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Shatter</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Blur</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Hypnotic pattern</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Invisibility</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Magic mouth</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Minor image</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Mirror image</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Misdirection</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Phantom trap</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Blindness/deafness</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Command undead</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>False life</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Ghoul touch</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Scare</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Spectral hand</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Alter self</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Bear's endurance</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Bull's strength</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Cat's grace</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Darkvision</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Eagle's splendor</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Fox's cunning</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Knock</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Levitate</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Owl's wisdom</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Pyrotechnics</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Rope trick</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Spider climb</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Whispering wind</name>
    <entry>2</entry>
  </collection>
  <collection>
    <name>Dispel magic</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Explosive runes</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Magic circle against chaos/law/good/evil</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Nondetection</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Protection from energy</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Phantom steed</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Sepia snake sigil</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Sleet storm</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Stinking cloud</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Summon monster III</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Arcane sight</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Clairaudience/Clairvoyance</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Tongues</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Deep slumber</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Heroism</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Hold person</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Rage</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Suggestion</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Daylight</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Fireball</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Lightning bolt</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Tiny hut</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Wind wall</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Displacement</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Illusory script</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Invisibility sphere</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Major image</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Gentle repose</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Halt undead</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Ray of exhaustion</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Vampiric touch</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Blink</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Flame arrow</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Fly</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Gaseous form</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Haste</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Keen edge</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Greater magic weapon</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Secret page</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Shrink item</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Slow</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Water breathing</name>
    <entry>3</entry>
  </collection>
  <collection>
    <name>Fire trap</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Lesser globe of invulnerability</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Remove curse</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Stoneskin</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Shadow conjuration</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Black tentacles</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Dimension door</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Minor creation</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Secure shelter</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Solid fog</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Summon monster IV</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Arcane eye</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Detect scrying</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Locate creature</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Scrying</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Charm monster</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Confusion</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Crushing despair</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Lesser geas</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Fire shield</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Ice storm</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Resilient sphere</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Shout</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Wall of fire</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Wall of ice</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Hallucinatory terrain</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Illusory wall</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Greater invisibility</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Phantasmal killer</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Rainbow pattern</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Animate dead</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Bestow curse</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Contagion</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Enervation</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Fear</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Mass enlarge person</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Mnemonic enhancer</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Polymorph</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Mass reduce person</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Stone shape</name>
    <entry>4</entry>
  </collection>
  <collection>
    <name>Break enchantment</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Dismissal</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Mage's private sanctum</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Cloudkill</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Mage's faithful hound</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Major creation</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Lesser planar binding</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Secret chest</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Summon monster V</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Teleport</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Wall of stone</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Contact other plane</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Prying eyes</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Telepathic bond</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Dominate person</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Feeblemind</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Hold monster</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Mind fog</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Symbol of sleep</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Cone of cold</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Interposing hand</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Sending</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Wall of force</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Dream</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>False vision</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Mirage arcana</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Nightmare</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Persistent image</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Seeming</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Shadow evocation</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Blight</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Magic jar</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Symbol of pain</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Waves of fatigue</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Animal growth</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Fabricate</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Overland flight</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Passwall</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Telekinesis</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Transmute mud to rock</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Transmute rock to mud</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Permanency</name>
    <entry>5</entry>
  </collection>
  <collection>
    <name>Antimagic field</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Greater dispel magic</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Globe of invulnerability</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Guards and wards</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Repulsion</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Acid fog</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Planar binding</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Summon monster VI</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Wall of iron</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Analyze dweomer</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Legend lore</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>True seeing</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Geas/Quest</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Greater heroism</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mass suggestion</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Symbol of persuasion</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Chain lightning</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Contingency</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Forceful hand</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Freezing sphere</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mislead</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mage's lucubration</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Permanent image</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Programmed image</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Shadow walk</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Veil</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Circle of death</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Eyebite</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Symbol of fear</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Undeath to death</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mass bear's endurance</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mass bull's strength</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mass cat's grace</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Control water</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Disintegrate</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mass eagle's splendor</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Flesh to stone</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mass fox's cunning</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Move earth</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Mass owl's wisdom</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Stone to flesh</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Transformation</name>
    <entry>6</entry>
  </collection>
  <collection>
    <name>Banishment</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Sequester</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Spell turning</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Instant summons</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Mage's magnificent mansion</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Phase door</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Plane shift</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Summon monster VII</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Greater teleport</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Teleport object</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Greater arcane sight</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Greater scrying</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Vision</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Mass hold person</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Insanity</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Power word blind</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Symbol of stunning</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Delayed blast fireball</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Forcecage</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Grasping hand</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Mage's sword</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Prismatic spray</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Mass invisibility</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Project image</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Greater shadow conjuration</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Simulacrum</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Control undead</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Finger of death</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Symbol of weakness</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Waves of exhaustion</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Control weather</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Ethereal jaunt</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Reverse gravity</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Statue</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Limited wish</name>
    <entry>7</entry>
  </collection>
  <collection>
    <name>Dimensional lock</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Mind blank</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Prismatic wall</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Protection from spells</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Incendiary cloud</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Maze</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Greater planar binding</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Summon monster VIII</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Trap the soul</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Discern location</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Moment of prescience</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Greater prying eyes</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Antipathy</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Binding</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Mass charm monster</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Demand</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Irresistible dance</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Power word stun</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Symbol of insanity</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Sympathy</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Clenched fist</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Polar ray</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Greater shout</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Sunburst</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Telekinetic sphere</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Scintillating pattern</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Screen</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Greater shadow evocation</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Clone</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Create greater undead</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Horrid wilting</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Symbol of death</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Iron body</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Polymorph any object</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Temporal stasis</name>
    <entry>8</entry>
  </collection>
  <collection>
    <name>Freedom</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Imprisonment</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Mage's disjunction</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Prismatic sphere</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Gate</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Refuge</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Summon monster IX</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Teleportation circle</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Foresight</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Dominate monster</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Mass hold monster</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Power word kill</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Crushing hand</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Meteor swarm</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Shades</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Weird</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Astral projection</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Energy drain</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Soul bind</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Wail of the banshee</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Etherealness</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Shapechange</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Time stop</name>
    <entry>9</entry>
  </collection>
  <collection>
    <name>Wish</name>
    <entry>9</entry>
  </collection>
</collections>

redpajama_set_name: RedPajamaGithub


text:
"""Some common utilities for tools to use."""

import codecs
import contextlib
import glob
import logging
import os
import os.path as path
import re
import shutil
import subprocess
import sys
import time
import zipfile

from nototools import notoconfig

@contextlib.contextmanager
def temp_chdir(path):
    """Usage: with temp_chdir(path):
    do_something
    """
    saved_dir = os.getcwd()
    try:
        os.chdir(path)
        yield
    finally:
        os.chdir(saved_dir)

noto_re = re.compile(
    r"\[(tools|fonts|fonts_alpha|emoji|cjk|source|adobe|mti|afdko)\](.*)"
)

def resolve_path(somepath):
    """Resolve a path that might start with noto path shorthand. If
    the path is empty, is '-', or the shorthand is not defined,
    returns None. Example: '[fonts]/hinted'."""

    if not somepath or somepath == "-":
        return None
    m = noto_re.match(somepath)
    if m:
        base, rest = m.groups()
        if base == "adobe":
            key = "adobe_data"
        elif base == "mti":
            key = "monotype_data"
        elif base == "afdko":
            key = "afdko"
        else:
            key = "noto_" + base
        base = notoconfig.get(key)
        while rest.startswith(path.sep):
            rest = rest[len(path.sep) :]
        somepath = path.join(base, rest)
    return path.realpath(path.abspath(path.expanduser(somepath)))

def commonpathprefix(paths):
    """Return the common path prefix and a tuple of the relative subpaths for the
    provided paths.  Uses resolve_path to convert to absolute paths and returns
    the common absolute path.  Some subpaths might be the empty string and joining
    these will produce paths ending in '/', use normpath if you don't want this.

    Python 2.7 only has path.commonprefix, which returns a common string prefix,
    not a common path prefix.
    """
    norm_paths = [resolve_path(p) + path.sep for p in paths]
    prefix = path.dirname(path.commonprefix(norm_paths))
    prefix_len = len(prefix)
    if prefix_len > 1:
        prefix_len += 1  # not '/' so does not end in '/', strip from subpaths
    subpaths = tuple(p[prefix_len:-1] for p in norm_paths)
    return prefix, subpaths

def _name_to_key(keyname):
    if keyname == "adobe_data":
        return "adobe"
    if keyname == "monotype_data":
        return ("mti",)
    if keyname.startswith("noto_"):
        return keyname[5:]
    return keyname

def short_path(somepath, basedir=os.getcwd()):
    """Return a short version of somepath, either relative to one of the noto path
    shorthands or to the provided base directory (defaults to current).  For
    logging/debugging output of file paths."""
    shortest = somepath
    if basedir and somepath.startswith(basedir):
        shortest = "." + somepath[len(basedir) :]
    for k, v in notoconfig.values.items():
        if somepath.startswith(v):
            test = ("[%s]" % _name_to_key(k)) + somepath[len(v) :]
            if len(test) < len(shortest):
                shortest = test
    return shortest

def check_dir_exists(dirpath):
    if not os.path.isdir(dirpath):
        raise ValueError("%s does not exist or is not a directory" % dirpath)

def check_file_exists(filepath):
    if not os.path.isfile(filepath):
        raise ValueError("%s does not exist or is not a file" % filepath)

def ensure_dir_exists(path, clean=False):
    path = os.path.realpath(path)
    if not os.path.isdir(path):
        if os.path.exists(path):
            raise ValueError("%s exists and is not a directory" % path)
        print("making '%s'" % path)
        os.makedirs(path)
    elif clean:
        shutil.rmtree(path)
        os.makedirs(path)
    return path

def generate_zip_with_7za(root_dir, file_paths, archive_path):
    """file_paths is a list of files relative to root_dir, these will be the names
    in the archive at archive_path."""

    arg_list = ["7za", "a", archive_path, "-tzip", "-mx=7", "-bd", "--"]
    arg_list.extend(file_paths)
    with temp_chdir(root_dir):
        # capture but discard output
        subprocess.check_output(arg_list)

def generate_zip_with_7za_from_filepairs(pairs, archive_path):
    """Pairs are source/destination path pairs. The source will be put into the
    zip with name destination."""

    staging_dir = "/tmp/stage_7za"
    if os.path.exists(staging_dir):
        shutil.rmtree(staging_dir)
    os.makedirs(staging_dir)

    pair_map = {}
    for source, dest in pairs:
        if not source.endswith(dest):
            staging_source = os.path.join(staging_dir, dest)
            shutil.copyfile(source, staging_source)
            source_root = staging_dir
        else:
            source_root = source[: -len(dest)]
        if source_root not in pair_map:
            pair_map[source_root] = set()
        pair_map[source_root].add(dest)
    for source_root, dest_set in pair_map.items():
        generate_zip_with_7za(source_root, sorted(dest_set), archive_path)

def dos2unix(root_dir, glob_list):
    """Convert dos line endings to unix ones in place."""
    with temp_chdir(root_dir):
        for g in glob_list:
            file_list = glob.glob(g)
            if file_list:
                subprocess.check_call(["dos2unix", "-k", "-q", "-o"] + file_list)

def zip_extract_with_timestamp(zippath, dstdir):
    zip = zipfile.ZipFile(zippath)
    with temp_chdir(dstdir):
        for info in zip.infolist():
            zip.extract(info.filename)
            # of course, time zones mess this up, so don't expect precision
            date_time = time.mktime(info.date_time + (0, 0, -1))
            os.utime(info.filename, (date_time, date_time))

def git_checkout(repo, branch_or_tag, verbose=False):
    """checkout the branch or tag"""
    with temp_chdir(repo):
        result = subprocess.check_output(
            ["git", "checkout", branch_or_tag], stderr=subprocess.STDOUT
        )
        if verbose:
            print("%s:\n%s\n-----" % (repo, result))

def git_mv(repo, old, new):
    """Rename old to new in repo"""
    with temp_chdir(repo):
        return subprocess.check_output(["git", "mv", old, new])

def git_file_lastlog(repo, filepath):
    """Return a string containing the short hash, date, author email, and title
    of most recent commit of filepath, separated by tab."""
    with temp_chdir(repo):
        return subprocess.check_output(
            [
                "git",
                "log",
                "-n",
                "1",
                "--format=%h\t%ad\t%ae\t%s",
                "--date=short",
                "--",
                filepath,
            ]
        )

def git_tags(repo):
    """Return a list of info about annotated tags.  The list consists of tuples
    of the commit hash (as a string), the  tag name, and the time, sorted in
    in reverse chronological order (most recent first).  The hash is for the
    referenced commit and not the tag itself, but the date is the tag date."""
    with temp_chdir(repo):
        text = subprocess.check_output(
            [
                "git",
                "tag",
                "-l",
                "--format=%(*objectname)|%(refname:strip=2)|"
                "%(taggerdate:format:%Y-%m-%d %T %Z)",
                "--sort=-taggerdate",
            ]
        ).decode("utf-8")
        print(text)
        return [
            tuple(line.split("|"))
            for line in text.splitlines()
            if not line.strip().startswith("|")
        ]

def git_tag_info(repo, tag_name):
    """Return the annotation for this tag in the repo.  It is limited to no more
    than 50 lines."""
    # Unfortunately, I can't get the other formatted tag info and also limit
    # to the tag annotation without more serious munging of tag or show output.
    with temp_chdir(repo):
        text = subprocess.check_output(["git", "tag", "-l", "-n50", tag_name])
        lines = text[len(tag_name) :].strip().splitlines()
        return "\n".join(l.strip() for l in lines)

def get_tool_generated(repo, subdir, commit_title_prefix="Updated by tool"):
    """
    Return a list of the names of tool-generated files in the provided directory.
    The idea is that when we check in files that are generated by a tool, the
    commit will start with the given prefix.  If a files' most recent log entry
    matches this, it means that we've not applied patches or fixes to the file
    since it was generated, so we can overwrite it with new tool-generated data.

    The motivation for this is mantaining the sample texts.  The original source
    for most of these is UDHR data, but subsequently we have fixed things in
    some of the samples.  We generally do not want to blindly overwrite these
    fixes, but do want to be able to regenerate the samples if we get new source
    data.
    """
    files_not_under_version_control = []
    protected_files = []
    tool_generated_files = []
    for f in sorted(os.listdir(path.join(repo, subdir))):
        relpath = path.join(subdir, f)
        lastlog_str = git_file_lastlog(repo, relpath)
        if not lastlog_str:
            files_not_under_version_control.append(f)
            continue
        commit, date, author, title = lastlog_str.split("\t")
        if title.startswith(commit_title_prefix):
            tool_generated_files.append(f)
        else:
            protected_files.append(f)

    if files_not_under_version_control:
        sys.stderr.write(
            "%d files were not under version control:\n  %s\n"
            % (
                len(files_not_under_version_control),
                ", ".join(files_not_under_version_control),
            )
        )

    if protected_files:
        sys.stderr.write(
            "%d files protected:\n  %s\n"
            % (len(protected_files), ", ".join(protected_files))
        )

    return tool_generated_files

def git_get_branch(repo):
    try:
        with temp_chdir(repo):
            with open(os.devnull) as trash:
                return subprocess.check_output(
                    ["git", "symbolic-ref", "--short", "HEAD"], stderr=trash
                ).strip()
    except:
        return "<not on any branch>"

def git_is_clean(repo, print_errors=False):
    """Ensure there are no unstaged or uncommitted changes in the repo."""

    def capture_and_show_errors(cmd):
        def dumplines(msg, text, limit):
            if text:
                lines = text.splitlines()
                print(
                    "%s (%d lines):\n  %s"
                    % (msg, len(lines), "\n  ".join(lines[:limit]))
                )
                if len(lines) > limit:
                    print("  ...")

        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        out, err = p.communicate()
        dumplines("out", out, 20)
        dumplines("err", err, 20)

    result = True
    with temp_chdir(repo):
        subprocess.check_call(
            ["git", "update-index", "-q", "--ignore-submodules", "--refresh"]
        )
        if subprocess.call(
            ["git", "diff-files", "--quiet", "--ignore-submodules", "--"]
        ):
            if print_errors:
                print("There are unstaged changes:")
                capture_and_show_errors(
                    [
                        "git",
                        "diff-files",
                        "--name-status",
                        "-r",
                        "--ignore-submodules",
                        "--",
                    ]
                )
            result = False
        if subprocess.call(
            [
                "git",
                "diff-index",
                "--cached",
                "--quiet",
                "HEAD",
                "--ignore-submodules",
                "--",
            ]
        ):
            if print_errors:
                print("There are uncommitted changes:")
                capture_and_show_errors(
                    [
                        "git",
                        "diff-index",
                        "--cached",
                        "--name-status",
                        "-r",
                        "HEAD",
                        "--ignore-submodules",
                        "--",
                    ]
                )
            result = False
    return result

def git_head_commit(repo):
    """Return the commit hash at head, the date and time of the commit as
    YYYY-mm-dd HH:MM:SS, and the subject line, as a tuple of three strings."""
    with temp_chdir(repo):
        text = subprocess.check_output(
            [
                "git",
                "show",
                "-s",
                "--date=format:%Y-%m-%d %H:%M:%S",
                "--no-expand-tabs",
                "--pretty=format:%H\t%cd\t%s",
                "HEAD",
            ]
        )
        return tuple(text.strip().split(b"\t", 2))

def git_check_remote_commit(repo, commit, remote="upstream", branch="master"):
    """Return true if the commit exists in the remote repo at the given branch
    (or any branch if branch is None). This has the side effect of calling
    'git fetch {remote}'."""
    with temp_chdir(repo):
        subprocess.check_call(["git", "fetch", remote])
        # the following will throw an exception if commit is unrecognized
        text = subprocess.check_output(["git", "branch", "-r", "--contains", commit])

        lines = [line.strip() for line in text.splitlines()]
        if branch:
            if branch == "HEAD":
                # assume a link, it will be reported as one
                expected = remote + "/HEAD ->"
                return any(line.startswith(expected) for line in lines)
            expected = remote + "/" + branch
            return expected in lines
        else:
            expected = remote + "/"
            return any(line.startswith(remote) for line in lines)

def git_add_all(repo_subdir):
    """Add all changed, deleted, and new files in subdir to the staging area."""
    # git can now add everything, even removed files
    with temp_chdir(repo_subdir):
        subprocess.check_call(["git", "add", "--", "."])

def svn_get_version(repo):
    with temp_chdir(repo):
        version_string = subprocess.check_output(["svnversion", "-c"]).strip()
        colon_index = version_string.find(":".encode("utf-8"))
        if colon_index >= 0:
            version_string = version_string[colon_index + 1 :]
    return version_string

def svn_update(repo):
    with temp_chdir(repo):
        subprocess.check_call(["svn", "up"], stderr=subprocess.STDOUT)

def parse_int_ranges(
    range_string,
    is_hex=True,
    sep=None,
    allow_duplicates=False,
    return_set=True,
    allow_compressed=False,
):
    """Returns a set/list of ints from a string of numbers or ranges separated by
    sep.  A range is two values separated by hyphen with no intervening separator;
    ranges are inclusive.  If allow_compressed is true, '/' is also allowed
    as a separator, and ranges following it or hyphen are interpreted as suffixes
    that replace the same number of characters at the end of the previous value.
    '-' generates the range of intervening characters as before, while '/' does
    not.  Returns a set or a list depending on return_set.

    For example, with compressed ranges the following:
      1ee42/7/9/b/d-f 1ee51-2/4/7/9/b/d/f

    expands to:
      1ee42 1ee47 1ee49 1ee4b 1ee4d-1ee4f 1ee51-1ee52 1ee54 1ee57 1ee59 1ee5b
      1ee5d 1ee5f
    """

    base = 16 if is_hex else 10
    vals = []

    def _add_segment(prev_str, suffix, is_range):
        slen = len(suffix)
        if prev_str is None:
            next_str = suffix
            next_val = int(next_str, base)
        else:
            if slen > len(prev_str):
                raise ValueError(
                    "suffix '%s' is longer than previous '%s'" % (suffix, prev_str)
                )
            next_str = prev_str[:-slen] + suffix

            next_val = int(next_str, base)
            if next_val <= vals[-1]:
                raise ValueError(
                    "next value '%s' is not greater than previous '%s'"
                    % (next_str, prev_str)
                )

        if is_range:
            start_val = vals[-1] + 1
            vals.extend(range(start_val, next_val))
        vals.append(next_val)

        return next_str

    def _add_range(r):
        stops = "-/"
        if len(r) == 0:
            raise ValueError("empty range")
        if r[0] in stops:
            raise ValueError('range "%s" has leading separator' % r)
        if r[-1] in stops:
            raise ValueError('range "%s" has trailing separator' % r)
        r = r + "/"

        prev_str = None
        is_range = False
        start = 0
        len_limit = -1
        for i in range(len(r)):
            cp = r[i]
            if cp not in stops:
                continue

            if i == start:
                raise ValueError('range "%s" has two separators together' % r)

            if is_range and cp == "-":
                raise ValueError("range \"%s\" has two '-' in sequence" % r)

            if not allow_compressed:
                if start == 0:
                    len_limit = i
                elif i - start > len_limit:
                    raise ValueError(
                        "segment '%s' longer than previous segment" % r[start:i]
                    )
                else:
                    len_limit = i - start

            prev_str = _add_segment(prev_str, r[start:i], is_range)
            is_range = cp == "-"
            start = i + 1

    # main
    # handle comments and multiline input
    if "\n" in range_string or "#" in range_string:
        # strip comments and turn into single line
        def strip_comment(line):
            x = line.find("#")
            if x >= 0:
                line = line[:x]
            return line.strip()

        join_char = " " if sep is None else sep
        range_string = join_char.join(
            filter(None, (strip_comment(line) for line in range_string.splitlines()))
        )

    if not allow_compressed and "/" != sep and range_string.find("/") != -1:
        raise ValueError("'/' only allowed in compressed range format")

    # collect ordered list of values
    for r in range_string.split(sep):
        _add_range(r)

    # check for duplicates and/or convert to set
    if return_set or not allow_duplicates:
        range_set = set(vals)
        if not allow_duplicates and len(range_set) != len(vals):
            fail = set()
            seen = set()
            for v in vals:
                if v in seen:
                    fail.add(v)
                else:
                    seen.add(v)
            raise ValueError(
                'range "%s" has %d duplicates: %s'
                % (range_string, len(fail), write_int_ranges(fail))
            )

    return range_set if return_set else vals

def write_int_ranges(int_values, in_hex=True, sep=" "):
    """From a set or list of ints, generate a string representation that can be
    parsed by parse_int_ranges to return the original values (not
    order_preserving)."""

    if not int_values:
        return ""

    num_list = []

    int_values = iter(sorted(int_values))
    start = prev = next(int_values)
    single_fmt = "%04x" if in_hex else "%d"
    pair_fmt = single_fmt + "-" + single_fmt

    def emit():
        if prev == start:
            num_list.append(single_fmt % prev)
        else:
            num_list.append(pair_fmt % (start, prev))

    for v in int_values:
        if v == prev + 1:
            prev += 1
            continue
        else:
            emit()
        start = prev = v
    emit()
    return sep.join(num_list)

def setup_logging(loglevel, quiet_ttx=True):
    """Set up logging to stream to stdout.

    The loglevel is a logging level name or a level value (int or string).

    ttx/fontTools uses 'info' to report when it is reading/writing tables,
    but when we want 'info' in our own tools we usually don't want this detail.
    When quiet_ttx is true, set up logging to treat 'info' logs from
    fontTools misc.xmlReader and ttLib as though they were at level 19."""

    try:
        loglevel = int(loglevel)
    except:
        loglevel = getattr(logging, loglevel.upper(), loglevel)
    if not isinstance(loglevel, int):
        print(
            "Could not set log level, should be one of debug, info, warning, "
            "error, critical, or a numeric value"
        )
        return
    logging.basicConfig(level=loglevel)

    if quiet_ttx and loglevel == logging.INFO:
        for logger_name in ["fontTools.misc.xmlReader", "fontTools.ttLib"]:
            logger = logging.getLogger(logger_name)
            logger.setLevel(loglevel + 1)

def write_lines(lines, outfile):
    """Write lines as utf-8 to outfile, separated by and ending with newline"""
    ensure_dir_exists(path.dirname(outfile))
    with codecs.open(outfile, "w", "utf-8") as f:
        f.write("\n".join(lines + [""]))

def read_lines(infile, ignore_comments=True, strip=True, skip_empty=True):
    """Read lines from infile and return as a list, optionally stripping comments,
    whitespace, and/or skipping blank lines."""
    lines = []
    with codecs.open(infile, "r", "utf-8") as f:
        for line in f:
            if ignore_comments:
                ix = line.find("#")
                if ix >= 0:
                    line = line[:ix]
            if strip:
                line = line.strip()
            if not line and skip_empty:
                continue
            lines.append(line)
    return lines

def _read_filename_list(filenames):
    with open(filenames, "r") as f:
        return [resolve_path(n.strip()) for n in f if n]

# see noto_fonts.NOTO_FONT_PATHS
NOTO_FONT_PATHS = ["[fonts]/hinted", "[fonts]/unhinted", "[emoji]/fonts", "[cjk]"]

def collect_paths(dirs, files):
    """Return a collection of all files in any of the listed dirs, and
    the listed files.  Can use noto short paths.  A file name starting
    with '@' is interpreted as the name of a file containing a list
    of filenames one per line.  The short name '[noto]' refers to
    the noto (phase 2) font paths."""

    paths = []
    if dirs:
        for i in range(len(dirs)):
            # special case '[noto]' to include all noto font dirs
            if dirs[i] == "[noto]":
                dirs[i] = None
                dirs.extend(NOTO_FONT_PATHS)
                dirs = filter(None, args.dirs)
                break
        for d in dirs:
            d = resolve_path(d)
            paths.extend(n for n in glob.glob(path.join(d, "*")))
    if files:
        for fname in files:
            if fname[0] == "@":
                paths.extend(_read_filename_list(fname[1:]))
            else:
                paths.append(resolve_path(fname))
    return paths


text:
(function() {

	Smart.ui.createDetailProductWindow = function() {
		var detailproductWindow = Titanium.UI.createWindow(style.Window);
		var lblTitle = Titanium.UI.createLabel(Smart.combine(style.titleBar, {
			text : 'Productinfo'
		}));
		detailproductWindow.setTitleControl(lblTitle);

		//
		//Back button
		//
		var backButton = Titanium.UI.createButton(style.backButton);
		backButton.addEventListener('click', function() {
			Smart.navGroup.close(detailproductWindow, {
				animated : false
			});
		});
		detailproductWindow.leftNavButton = backButton;

		detailproductWindow.addEventListener('open', function() {
			getDetail();
		});
		//
		// Product in detail
		//

		function getDetail() {
			var getReq = Titanium.Network.createHTTPClient();
			if(Ti.App.localonline==="local"){
				getReq.open("POST", "http://localhost/smartsell/get_itemdetail.php");
			}else{
				getReq.open("POST", "http://sofiehendrickx.eu/smartsell/get_itemdetail.php");
			}
			var params = {
				id : Titanium.App.prodId
			};

			getReq.timeout = 5000;
			getReq.onload = function() {
				try {
					var detail = JSON.parse(this.responseText);
					if(detail.getItem === false) {
						var lblNoDetail = Titanium.UI.createLabel(Smart.combine(style.textError, {
							text : 'Kan product niet ophalen.',
							top : 30
						}));
						detailproductWindow.add(lblNoDetail);

					} else {

						name = detail.name;
						title = detail.title;
						var pFoto = detail.foto;
						Ti.App.pId = detail.id;
						var pBeschrijving = detail.beschrijving;
						var pPrijs = detail.prijs;

						var bgView = Titanium.UI.createView(style.bgProduct);

						var cropView = Titanium.UI.createView({
							width : 100,
							height : 100,
							borderColor : '#B6AFA9',
							backgroundColor : '#fff',
							borderWidth : 1
						});

						var baseImg = Titanium.UI.createImageView({
							image : pFoto
						});
						cropView.add(baseImg);

						var croppedImage = cropView.toImage();

						var imageView = Titanium.UI.createImageView({
							image : croppedImage,
							width : 100,
							height : 100,
							left : 20,
							top : 45
						});

						var title = Titanium.UI.createLabel(Smart.combine(style.textProductTitle, {
							text : name + ' ' + title
						}));
						var beschrijving = Titanium.UI.createLabel(Smart.combine(style.textProductDescription, {
							text : pBeschrijving
						}));

						var prijs = Titanium.UI.createLabel(Smart.combine(style.textProductPrice, {
							text : '€ ' + pPrijs
						}));
						bgView.add(title);
						bgView.add(imageView);
						bgView.add(beschrijving);
						bgView.add(prijs);

						detailproductWindow.add(bgView);

					}

				} catch(e) {
					alert(e);
				}
			}
			getReq.onerror = function(e) {
				Ti.API.info("TEXT onerror:   " + this.responseText);
				alert('Er is iets mis met de databank.');
			}

			getReq.send(params);
		};
		var voegToeButton = Titanium.UI.createButton(Smart.combine(style.voegToeButton,{
			top:220,
			right:15
		}));
		detailproductWindow.add(voegToeButton);
		voegToeButton.addEventListener('click', function() {
			Smart.navGroup.open(Smart.ui.createAddProductWindow(), {
				animated : false
			});
		});

		var voegLaterToeButton = Titanium.UI.createButton(Smart.combine(style.voegToeButton,{
			top:275,
			right:15
		}));
		detailproductWindow.add(voegLaterToeButton);
		voegLaterToeButton.addEventListener('click', function() {
			Titanium.App.selectedIndex = Titanium.App.linkId;
			Ti.API.info('Link id: '+Titanium.App.selectedIndex);
			Titanium.App.selectedNaam=Titanium.App.linkNaam;
			Smart.navGroup.open(Smart.ui.createDetailWindow(), {
				animated : false
			});
		});

		return detailproductWindow;
	};
})();


text:
/*
 * Description:
 *     What is this file about?
 *
 * Revision history:
 *     xxxx-xx-xx, author, first version
 *     xxxx-xx-xx, author, fix bug about xxx
 */

# pragma once

# include <dsn/service_api_cpp.h>
# include <dsn/tool-api/task.h>
# include <dsn/tool-api/task_worker.h>
# include <gtest/gtest.h>
# include <iostream>

using namespace ::dsn;

#ifndef TEST_PORT_BEGIN
#define TEST_PORT_BEGIN 20201
#define TEST_PORT_END 20203
#endif

DEFINE_THREAD_POOL_CODE(THREAD_POOL_TEST_SERVER)

DEFINE_TASK_CODE_RPC(RPC_TEST_HASH, TASK_PRIORITY_COMMON, THREAD_POOL_TEST_SERVER)
DEFINE_TASK_CODE_RPC(RPC_TEST_HASH1, TASK_PRIORITY_COMMON, THREAD_POOL_TEST_SERVER)
DEFINE_TASK_CODE_RPC(RPC_TEST_HASH2, TASK_PRIORITY_COMMON, THREAD_POOL_TEST_SERVER)
DEFINE_TASK_CODE_RPC(RPC_TEST_HASH3, TASK_PRIORITY_COMMON, THREAD_POOL_TEST_SERVER)
DEFINE_TASK_CODE_RPC(RPC_TEST_HASH4, TASK_PRIORITY_COMMON, THREAD_POOL_TEST_SERVER)
DEFINE_TASK_CODE_RPC(RPC_TEST_STRING_COMMAND, TASK_PRIORITY_COMMON, THREAD_POOL_TEST_SERVER)

DEFINE_TASK_CODE_AIO(LPC_AIO_TEST, TASK_PRIORITY_COMMON, THREAD_POOL_DEFAULT)
DEFINE_TASK_CODE(LPC_TEST_HASH, TASK_PRIORITY_COMMON, THREAD_POOL_DEFAULT)
DEFINE_TASK_CODE_AIO(LPC_AIO_TEST_READ, TASK_PRIORITY_COMMON, THREAD_POOL_DEFAULT)
DEFINE_TASK_CODE_AIO(LPC_AIO_TEST_WRITE, TASK_PRIORITY_COMMON, THREAD_POOL_DEFAULT)
DEFINE_TASK_CODE_AIO(LPC_AIO_TEST_NFS, TASK_PRIORITY_COMMON, THREAD_POOL_DEFAULT)

extern void run_all_unit_tests_when_necessary();

class test_client :
    public ::dsn::serverlet<test_client>,
    public ::dsn::service_app
{
public:
    test_client(dsn_gpid gpid)
        : ::dsn::serverlet<test_client>("test-server", 7), ::dsn::service_app(gpid)
    {
    }

    void on_rpc_test(const std::string& test_id, ::dsn::rpc_replier<std::string>& replier)
    {
        std::string r = dsn::task::get_current_node_name();
        replier(std::move(r));
    }

    void on_rpc_string_test(dsn_message_t message) {
        std::string command;
        ::dsn::unmarshall(message, command);

        if (command == "expect_talk_to_others") {
            dsn::rpc_address next_addr = dsn::service_app::primary_address();
            if (next_addr.port() != TEST_PORT_END) {
                next_addr.assign_ipv4(next_addr.ip(), next_addr.port()+1);
                ddebug("test_client_server, talk_to_others: %s", next_addr.to_std_string().c_str());
                dsn_rpc_forward(message, next_addr.c_addr());
            }
            else {
                ddebug("test_client_server, talk_to_me: %s", next_addr.to_std_string().c_str());
                reply(message, next_addr.to_std_string());
            }
        }
        else if (command == "expect_no_reply") {
            if (dsn::service_app::primary_address().port() == TEST_PORT_END) {
                ddebug("test_client_server, talk_with_reply: %s", dsn::service_app::primary_address().to_std_string().c_str());
                reply(message, dsn::service_app::primary_address().to_std_string());
            }
        }
        else if (command.substr(0, 5) == "echo ") {
            reply(message, command.substr(5));
        }
        else {
            derror("unknown command");
        }
    }

    ::dsn::error_code start(int argc, char** argv)
    {
        // server
        if (argc == 1)
        {
            register_async_rpc_handler(RPC_TEST_HASH, "rpc.test.hash", &test_client::on_rpc_test);
            //used for corrupted message test
            register_async_rpc_handler(RPC_TEST_HASH1, "rpc.test.hash1", &test_client::on_rpc_test);
            register_async_rpc_handler(RPC_TEST_HASH2, "rpc.test.hash2", &test_client::on_rpc_test);
            register_async_rpc_handler(RPC_TEST_HASH3, "rpc.test.hash3", &test_client::on_rpc_test);
            register_async_rpc_handler(RPC_TEST_HASH4, "rpc.test.hash4", &test_client::on_rpc_test);

            register_rpc_handler(RPC_TEST_STRING_COMMAND, "rpc.test.string.command", &test_client::on_rpc_string_test);
        }

        // client
        else
        {
            run_all_unit_tests_when_necessary();
        }

        return ::dsn::ERR_OK;
    }

    ::dsn::error_code stop(bool cleanup = false)
    {
        return ERR_OK;
    }
};


text:
#include "projects/skybox/skybox_event_handler.hh"

#include <iostream>
#include <mutex>

#include <GL/glew.h>
#include <GLFW/glfw3.h>

#include "utils/graphic_contexts/graphic_context.hh"
#include "core/particle_module.hh"
#include "utils/timer.hh"
#include "utils/camera.hh"
#include <glm/gtc/matrix_transform.inl>

#include "projects/skybox/skybox_scene.hh"

namespace gem { namespace particle {
namespace skybox_project {
namespace event_handler {
namespace {

std::once_flag init_flag;
std::once_flag terminate_flag;

// TODO: If it's worth it, move these settings someplace else
// Window dimension
int _WindowWidth  = 640;
int _WindowHeight = 480;

// Camera settings
glm::vec3 camera_direction;
float camera_speed;
float mouse_sensitivity;
double yaw;
double pitch;
double last_x;
double last_y;

enum MouseState {
  POI_MOVING,
  CAMERA_MOVING,
  FREE_CURSOR
};
MouseState                      mouse_state;
bool firstMouse = true;

// Handles
std::shared_ptr<GraphicContext>         context_handle;

void MouseButtonCallBack(GLFWwindow* a_pWindow, int a_nButtonID, int a_nAction, int a_nMods) {
  switch (a_nButtonID) {
  case GLFW_MOUSE_BUTTON_LEFT:
    if (a_nAction == GLFW_PRESS) {
    }
    else {
      mouse_state = FREE_CURSOR;
      firstMouse = true;
    }
    break;
  case GLFW_MOUSE_BUTTON_MIDDLE:
    break;
  case GLFW_MOUSE_BUTTON_RIGHT:
    if (a_nAction == GLFW_PRESS) {
      mouse_state = CAMERA_MOVING;
    }
    else {
      mouse_state = FREE_CURSOR;
      firstMouse = true;
    }
    break;
  default:
    break;
  }
}

void MouseCursorPositionCallback(GLFWwindow* a_pWindow, double a_dXPos, double a_dYPos) {
  if (mouse_state == CAMERA_MOVING) {
    /*
    * Reference: https://learnopengl.com/index.php#!Getting-started/Camera
    */
    if (firstMouse)
    {
      last_x = a_dXPos;
      last_y = a_dYPos;
      firstMouse = false;
      return;
    }

    double xoffset = a_dXPos - last_x;
    double yoffset = last_y - a_dYPos; // Reversed since y-coordinates go from bottom to left
    last_x = a_dXPos;
    last_y = a_dYPos;

    double sensitivity = 0.10;	// Change this value to your liking
    xoffset *= sensitivity;
    yoffset *= sensitivity;

    yaw += xoffset;
    pitch += yoffset;

    // Make sure that when pitch is out of bounds, screen doesn't get flipped
    // TODO: Create constants for these magical numbers/values
    if (pitch > 89.0f)
      pitch = 89.0f;
    if (pitch < -89.0f)
      pitch = -89.0f;

    glm::vec3 front = {
      cos(glm::radians(yaw)) * cos(glm::radians(pitch)),
      sin(glm::radians(pitch)),
      sin(glm::radians(yaw)) * cos(glm::radians(pitch))
    };

    camera_direction = glm::normalize(front);
    auto  position = camera::GetEyePosition(),
      up = camera::GetUpVector();
    camera::LookAt(position, position + camera_direction, up);
  }
  else {
    // DO NOTHING
  }
}

void KeyCallback(GLFWwindow* a_pWindow,  int a_nKeyID, int a_nScanCode, int a_nAction, int n_aMods) {
  if (a_nAction == GLFW_PRESS || a_nAction == GLFW_REPEAT) {
  auto position       = camera::GetEyePosition();
  auto targetPosition = camera::GetTargetPosition();
  auto up = camera::GetUpVector();
  auto camera_right = glm::normalize(glm::cross(camera_direction, up)) * camera_speed;
  auto camera_forward = camera_direction * camera_speed;
    switch(a_nKeyID) {
      // Move forward
      case GLFW_KEY_W:
        position += camera_forward;
        targetPosition += camera_forward;
        camera::LookAt(position, targetPosition, camera::GetUpVector());
        break;
      // Move backward
      case GLFW_KEY_S:
        position -= camera_forward;
        targetPosition -= camera_forward;
        camera::LookAt(position, targetPosition, camera::GetUpVector());
        break;
      // Move right
      case GLFW_KEY_D:
        position += camera_right;
        targetPosition += camera_right;
        camera::LookAt(position,targetPosition,camera::GetUpVector());
        break;
      // Move left
      case GLFW_KEY_A:
        position -= camera_right;
        targetPosition -= camera_right;
        camera::LookAt(position, targetPosition, camera::GetUpVector());
        break;
        // Toggle debug option
      case GLFW_KEY_B:
        scene::SetDebugOption(!scene::IsDebug());
        break;
      case GLFW_KEY_SPACE:
        camera::LookAt(position, { 0.0f,0.0f,0.0f }, camera::GetUpVector());
        break;
      default:
        break;
    }
  }
}

void FramebufferSizeCallback(GLFWwindow* a_pWindow, int a_nWidth, int a_nHeight) {
  _WindowWidth = a_nWidth;
  _WindowHeight = a_nHeight;
  glViewport(0, 0, a_nWidth, a_nHeight);
  camera::SetPerspectiveProjection(
    glm::radians(45.0f),
    a_nWidth, a_nHeight,
    0.1f, 100.0f);
}
}

void Init(const std::shared_ptr<GraphicContext>& a_pCtxt) {
  std::call_once(init_flag, [&]() {
    // Get a reference on the dynamics of this project
    //_AttractorHandle = a_pAttractorHandle;
    //_ColorUpdaterHandle = a_pColorUpdater;

    // TODO: If it's worth it, move these hardcoded values someplace else
    yaw = -90.0f;
    pitch = 0.0f;
    last_x = 0.0f;
    last_y = 0.0f;

    camera_speed = 0.05f;
    camera_direction = camera::GetTargetPosition() - camera::GetEyePosition();
    mouse_sensitivity = 0.005f;

    context_handle = a_pCtxt;
    mouse_state = FREE_CURSOR;
    GLFWwindow* window = static_cast<GLFWwindow*>(context_handle->GetWindowHandle());

    // Set callbacks
    glfwSetMouseButtonCallback(window, MouseButtonCallBack);
    glfwSetCursorPosCallback(window, MouseCursorPositionCallback);
    glfwSetKeyCallback(window, KeyCallback);
    glfwSetFramebufferSizeCallback(window, FramebufferSizeCallback);
  });
}

void Terminate() {
  std::call_once(terminate_flag, [&]() {
  });
}

void Update() {
}
} /* namespace event_handler*/
} /* namespace skybox_project */
} /* namespace particle */
} /* namespace gem */


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="JavaScriptLibraryMappings">
    <file url="file://$PROJECT_DIR$/builder" libraries="{Node.js Globals, Node.js v0.10.31 Core Modules}" />
    <file url="file://$PROJECT_DIR$/builder/build.js" libraries="{Node.js Globals, Node.js v0.10.31 Core Modules}" />
    <file url="file://$PROJECT_DIR$/demos" libraries="{HTML5 / EcmaScript 5}" />
    <file url="PROJECT" libraries="{Node.js v0.10.31 Core Modules}" />
  </component>
</project>


text:
echo ""
echo "### -------------------------------"
echo "###    INSTALLING BASIC SYSTEM  ###"
echo "###         CHAPTER 6.all       ###"
echo "### Installing Basic System Software"
echo "### Must be run as \"chroot\" user"
echo "### -------------------------------"

echo ""
echo "... Loading commun functions and variables"
if [ ! -f ./script-all_commun-functions.sh ]
then
  echo "!! Fatal Error 1: './script-all_commun-functions.sh' not found."
  exit 1
fi
source ./script-all_commun-functions.sh

if [ ! -f ./script-all_commun-variables.sh ]
then
  echo "!! Fatal Error 1: './script-all_commun-variables.sh' not found."
  exit 1
fi
source ./script-all_commun-variables.sh

echo ""
echo "... Validating the environment"
check_chroot

echo ""
echo "READ CAREFULLY"
echo "Running this script will be long, ~6h"
echo "The compilation time is ~5h in the best cases."
echo "But note that you will be required during some of the steps."
echo "When steps are required from you, the terminal will produce a sound. But check often, in case you didn't hear it."
echo ""
echo -e "\a"
read -p "Enter to confirm" -n 1 -r
echo ""

./6.7-chroot_api-headers.sh
./6.8-chroot_man-pages.sh
./6.9-chroot_glibc.sh
./6.10-chroot_toolchain.sh
./6.11-chroot_zlib.sh
./6.12-chroot_file.sh
./6.13-chroot_binutils.sh
./6.14-chroot_gmp.sh
./6.15-chroot_mpfr.sh
./6.16-chroot_mpc.sh
./6.17-chroot_gcc.sh
./6.18-chroot_bzip2.sh
./6.19-chroot_pkg-config.sh
./6.20-chroot_ncurses.sh
./6.21-chroot_attr.sh
./6.22-chroot_acl.sh
./6.23-chroot_libcap.sh
./6.24-chroot_sed.sh
./6.25-chroot_shadow.sh
./6.26-chroot_psmisc.sh
./6.27-chroot_procps-ng.sh
./6.28-chroot_e2fsprogs.sh
./6.29-chroot_coreutils.sh
./6.30-chroot_iana-etc.sh
./6.31-chroot_m4.sh
./6.32-chroot_flex.sh
./6.33-chroot_bison.sh
./6.34-chroot_grep.sh
./6.35-chroot_readline.sh
./6.36-chroot_bash.sh


text:
using System.Runtime.InteropServices;
using System;
using System.Reflection;
using System.Text;

class Test
{
    static void ReportFailure(string describe, bool expect, bool actual)
    {
        throw new Exception(" === Fail: " + describe + "\n\tExpected:" + expect + "\n\tActual:" + actual);
    }

    public static int Main(string[] args)
    {
        const bool boolManaged = true;
        const bool boolNative = false;

        //Test Method1
        bool boolValue1 = boolManaged;
        bool boolValueRet1 = NativeMethods.Marshal_In(boolValue1);
        if (!boolValueRet1)
        {
            ReportFailure("Method Marshal_In[Managed Side],The return value is wrong", true, boolValueRet1);
        }

        //TestMethod2
        bool boolValue2 = boolManaged;
        bool boolValueRet2 = NativeMethods.Marshal_InOut(boolValue2);
        if (!boolValueRet2)
        {
            ReportFailure("Method Marshal_InOut[Managed Side],The return value is wrong", true, boolValueRet2);
        }
        if (boolValue2 != boolManaged)
        {
            ReportFailure("Method Marshal_InOut[Managed Side],The parameter value is changed", boolManaged, boolValue2);
        }

        //TestMethod3
        bool boolValue3 = boolManaged;
        bool boolValueRet3 = NativeMethods.Marshal_Out(boolValue3);
        if (!boolValueRet3)
        {
            ReportFailure("Method Marshal_Out[Managed Side],The return value is wrong", true, boolValueRet3);
        }
        if (boolValue3 != boolManaged)
        {
            ReportFailure("Method Marshal_Out[Managed Side],The parameter value is changed", boolManaged, boolValue3);
        }

        //TestMethod4
        bool boolValue4 = boolManaged;
        bool boolValueRet4 = NativeMethods.MarshalPointer_In(ref boolValue4);
        if (!boolValueRet4)
        {
            ReportFailure("Method MarshalPointer_In[Managed Side],The return value is wrong", true, boolValueRet4);
        }
        if (boolValue4 != boolManaged)
        {
            ReportFailure("Method MarshalPointer_In[Managed Side],The parameter value is changed", boolManaged, boolValue4);
        }

        //TestMethod5
        bool boolValue5 = boolManaged;
        bool boolValueRet5 = NativeMethods.MarshalPointer_InOut(ref boolValue5);
        if (!boolValueRet5)
        {
            ReportFailure("Method MarshalPointer_InOut[Managed Side],The return value is wrong", true, boolValueRet5);
        }
        if (boolValue5 != boolNative)
        {
            ReportFailure("Method MarshalPointer_InOut[Managed Side],The passed value is wrong", boolNative, boolValue5);
        }

        //TestMethod6
        bool boolValue6 = boolManaged;
        bool boolValueRet6 = NativeMethods.MarshalPointer_Out(out boolValue6);
        if (!boolValueRet6)
        {
            ReportFailure("Method Marshal_Out[Managed Side],The return value is wrong", true, boolValueRet6);
        }
        if (boolValue6 != boolNative)
        {
            ReportFailure("Method Marshal_Out[Managed Side],The passed value is wrong", boolNative, boolValue6);
        }

        //Test Method7
        bool boolValue7 = boolManaged;
        bool boolValueRet7 = NativeMethods.Marshal_As_In(boolValue7);
        if (!boolValueRet7)
        {
            ReportFailure("Method Marshal_As_In[Managed Side],The return value is wrong", true, boolValueRet1);
        }

        //TestMethod8
        bool boolValue8 = boolManaged;
        bool boolValueRet8 = NativeMethods.Marshal_As_InOut(boolValue8);
        if (!boolValueRet8)
        {
            ReportFailure("Method Marshal_As_InOut[Managed Side],The return value is wrong", true, boolValueRet2);
        }
        if (boolValue8 != boolManaged)
        {
            ReportFailure("Method Marshal_As_InOut[Managed Side],The parameter value is changed", boolManaged, boolValue8);
        }

        //TestMethod9
        bool boolValue9 = boolManaged;
        bool boolValueRet9 = NativeMethods.Marshal_As_Out(boolValue9);
        if (!boolValueRet9)
        {
            ReportFailure("Method Marshal_As_Out[Managed Side],The return value is wrong", true, boolValueRet3);
        }
        if (boolValue9 != boolManaged)
        {
            ReportFailure("Method Marshal_As_Out[Managed Side],The parameter value is changed", boolManaged, boolValue3);
        }
        return 100;
    }
}


text:
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using ServiceStack.Text;

namespace Vulcan.AspNetMvc
{
    public class ServiceStackTextFormatter : MediaTypeFormatter
    {
        //Uses ISO8601 date by default
        private JsonDateHandler _dateHandler = JsonDateHandler.ISO8601;

        public ServiceStackTextFormatter(JsonDateHandler dateHandler)
            : this()
        {
            _dateHandler = dateHandler;
        }

        public ServiceStackTextFormatter()
        {
            SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json"));

            SupportedEncodings.Add(new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true));
            SupportedEncodings.Add(new UnicodeEncoding(bigEndian: false, byteOrderMark: true, throwOnInvalidBytes: true));
            //TODO: Add XHR Header mapping. Will add this after a discussion with aspnetwebstack team: See: http://aspnetwebstack.codeplex.com/discussions/350758
        }

        public override Task<object> ReadFromStreamAsync(Type type, System.IO.Stream stream, HttpContent content, IFormatterLogger formatterLogger)
        {
            return Task.Factory.StartNew(() =>
            {
                JsConfig.DateHandler = _dateHandler;
                var result = JsonSerializer.DeserializeFromStream(type, stream);
                JsConfig.Reset();
                return result;
            });
        }

        public override Task WriteToStreamAsync(Type type, object value, System.IO.Stream stream, HttpContent content, TransportContext transportContext)
        {
            return Task.Factory.StartNew(() =>
            {
                JsConfig.DateHandler = _dateHandler;
                JsonSerializer.SerializeToStream(value, type, stream);
                JsConfig.Reset();
            });
        }

        public override bool CanReadType(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            return true;
        }

        public override bool CanWriteType(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            return true;
        }
    }
}


text:
#if !defined(MatNest_impl_h)
#define MatNest_impl_h

#include <petsc/private/matimpl.h>

struct MatNestISPair {
  IS *row,*col;
};

typedef struct {
  PetscInt             nr,nc;      /* nr x nc blocks */
  Mat                  **m;
  struct MatNestISPair isglobal;
  struct MatNestISPair islocal;
  Vec                  *left,*right;
  PetscInt             *row_len,*col_len;
  PetscBool            splitassembly;
} Mat_Nest;

#endif


text:
local IronBox = require "IronBox"

local box = IronBox.create(function()
    while true do
        -- never exits
    end
    print("I don't finish :(")
end)

-- run the box
box() -- box:resume() works too
-- ding! The box has surpassed the executing limit.  Pausing the coroutine

-- continue the box
box()
-- stops again

print("And it stops!")


text:
package org.apache.commons.functor.aggregator.functions;

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

import org.apache.commons.functor.Function;

/**
 * Aggregator function to be used with subclasses of
 * {@link org.apache.commons.functor.aggregator.AbstractListBackedAggregator}
 * which retrieves the percentile value for a
 * given percentile. The percentile rank/index for a value P can be obtained
 * using formula: n = round((P / 100) * N + 0.5) where N is the
 * number of items in a list.
 */
public class IntegerPercentileAggregatorFunction implements Function<List<Integer>, Integer> {
    /** A percentile goes from 0 to 100% and that's it. */
    private static final double MAX_PERCENTAGE = 100.0;
    /**
     * Percentile value to calculate. 0 < percentile <= 100
     */
    private double              percentile;

    /**
     * Flag to indicate whether we are going to operate on a copy of the list
     * given or not. In order to compute the percentile, we need to sort the
     * list first (and then choose the item based on the formula given above).
     * This function offers 2 ways of doing the sorting:
     *

     *
by sorting (modifying) the original list (useCopy=false)
     *

     *
by operating on a copy of the original list and leaving the original
     * untouched (useCopy=true)

     *

     * NOTE: While using a copy ensures the original list is untouched, it does
     * mean we are creating a temporary list for the purpose of this computation
     * so it will have an impact on memory!
     */
    private boolean             useCopy;

    /**
     * Similar to {@link #IntegerPercentileAggregatorFunction(double, boolean)
     * IntPercentilAggregatorFunction(percentile,true)}.
     *
     * @param percentile
     *            Percentile this function will return the value for
     */
    public IntegerPercentileAggregatorFunction(double percentile) {
        this(percentile, true);
    }

    /**
     * Initializes the function with the given percentile and decides whether
     * the function will modify the original list or not.
     *
     * @param percentile
     *            Percentile this function will return the value for
     * @param useCopy
     *            If set to true, the original list will not be modified and
     *            will contain the data in sorted order, if false, this instance
     *            will operate on a copy of the list
     */
    public IntegerPercentileAggregatorFunction(double percentile, boolean useCopy) {
        if (percentile < 0.0 || percentile > MAX_PERCENTAGE) {
            throw new IllegalArgumentException("Invalid value for percentile: " + percentile);
        }
        this.percentile = percentile;
        this.useCopy = useCopy;
    }

    /**
     * Used internally to compute the rank of the item in the list for the
     * requested percentile. This is invoked internally from
     * {@link #evaluate(List)}.
     *
     * @param data
     *            List containing data. This cannot be null (throws
     *            NullPointerException) or empty (throws
     *            ArrayIndexOutOfBoundsException).
     * @return Index of the item for the requested percentile
     * @see #getPercentile()
     */
    final int computeRank(List<Integer> data) {
        int maxRank = data.size() - 1;
        int rank = (int) Math.floor((percentile * maxRank) / MAX_PERCENTAGE);
        return rank;
    }

    /**
     * Traverses the list and computes the percentile. In doing so, it sorts the
     * list first -- and might or might not use the original list or a copy
     * depending on {@link #isUseCopy()}.
     *
     * @param data
     *            List to compute the percentile for
     * @return percentile of the given list or null if list is null
     *         or empty (zero size).
     */
    public Integer evaluate(List<Integer> data) {
        if (data == null || data.size() == 0) {
            return null;
        }
        List<Integer> copy = data;
        if (useCopy) {
            copy = new ArrayList<Integer>(data);
        }
        Collections.sort(copy);
        int rank = computeRank(data);
        return copy.get(rank);
    }

    /**
     * Getter for {@link #percentile}.
     *
     * @return Retrieves the percentile this instance will return
     */
    public double getPercentile() {
        return percentile;
    }

    /**
     * Does this instance modify the passed in list or not?
     *
     * @return If true, this instance will sort the list passed in and then use
     *         it to compute the percentile; if false, it will operate on a copy
     *         of the list
     * @see IntegerPercentileAggregatorFunction#IntegerPercentileAggregatorFunction(double,
     *      boolean)
     */
    public boolean isUseCopy() {
        return useCopy;
    }

    @Override
    public String toString() {
        return IntegerPercentileAggregatorFunction.class.getName();
    }
}


text:
- Python 2.x or 3.x
- pygame library installed, if you don't have it already

### To run the game:

It's as easy as `python main.py` ;) :100: :beer:

And if you wanna contribute, I surely will appreciate the effort!

It's as easy as sending a pull request! :)
- - -

## (OLD VERSION)

### Commands
- Escape/F4 to exit
- Left mouse button to shoot
- Mouse cursor movement to change ship angle
- W, A, S, D to change ship's direction
- ``NEW``! Added **XBOX Controller** native support!

### To run...

Open a terminal in the project's directory and execute the following command:

``python main.py **optional arguments**``

#### Parameters:
- debug --> Show some debug info onscreen
- debug nolagom --> Show debug info without lagometer
- extreme --> When a bug becomes a cool feature... :D

-Hope you enjoy this **little and especially messy** project!

- - -


text:
/* Generated by camel build tools - do NOT edit this file! */
package org.apache.camel.component.jcache;

import java.util.Map;

import org.apache.camel.CamelContext;
import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.spi.ConfigurerStrategy;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.util.CaseInsensitiveMap;
import org.apache.camel.support.component.PropertyConfigurerSupport;

/**
 * Generated by camel build tools - do NOT edit this file!
 */
@SuppressWarnings("unchecked")
public class JCacheEndpointConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {

    @Override
    public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
        JCacheEndpoint target = (JCacheEndpoint) obj;
        switch (ignoreCase ? name.toLowerCase() : name) {
        case "action": target.getConfiguration().setAction(property(camelContext, java.lang.String.class, value)); return true;
        case "bridgeerrorhandler":
        case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true;
        case "cacheconfiguration":
        case "cacheConfiguration": target.getConfiguration().setCacheConfiguration(property(camelContext, javax.cache.configuration.Configuration.class, value)); return true;
        case "cacheconfigurationproperties":
        case "cacheConfigurationProperties": target.getConfiguration().setCacheConfigurationProperties(property(camelContext, java.util.Properties.class, value)); return true;
        case "cacheloaderfactory":
        case "cacheLoaderFactory": target.getConfiguration().setCacheLoaderFactory(property(camelContext, javax.cache.configuration.Factory.class, value)); return true;
        case "cachewriterfactory":
        case "cacheWriterFactory": target.getConfiguration().setCacheWriterFactory(property(camelContext, javax.cache.configuration.Factory.class, value)); return true;
        case "cachingprovider":
        case "cachingProvider": target.getConfiguration().setCachingProvider(property(camelContext, java.lang.String.class, value)); return true;
        case "configurationuri":
        case "configurationUri": target.getConfiguration().setConfigurationUri(property(camelContext, java.lang.String.class, value)); return true;
        case "createcacheifnotexists":
        case "createCacheIfNotExists": target.getConfiguration().setCreateCacheIfNotExists(property(camelContext, boolean.class, value)); return true;
        case "eventfilters":
        case "eventFilters": target.getConfiguration().setEventFilters(property(camelContext, java.util.List.class, value)); return true;
        case "exceptionhandler":
        case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true;
        case "exchangepattern":
        case "exchangePattern": target.setExchangePattern(property(camelContext, org.apache.camel.ExchangePattern.class, value)); return true;
        case "expirypolicyfactory":
        case "expiryPolicyFactory": target.getConfiguration().setExpiryPolicyFactory(property(camelContext, javax.cache.configuration.Factory.class, value)); return true;
        case "filteredevents":
        case "filteredEvents": target.getConfiguration().setFilteredEvents(property(camelContext, java.lang.String.class, value)); return true;
        case "lazystartproducer":
        case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
        case "lookupproviders":
        case "lookupProviders": target.getConfiguration().setLookupProviders(property(camelContext, boolean.class, value)); return true;
        case "managementenabled":
        case "managementEnabled": target.getConfiguration().setManagementEnabled(property(camelContext, boolean.class, value)); return true;
        case "oldvaluerequired":
        case "oldValueRequired": target.getConfiguration().setOldValueRequired(property(camelContext, boolean.class, value)); return true;
        case "readthrough":
        case "readThrough": target.getConfiguration().setReadThrough(property(camelContext, boolean.class, value)); return true;
        case "statisticsenabled":
        case "statisticsEnabled": target.getConfiguration().setStatisticsEnabled(property(camelContext, boolean.class, value)); return true;
        case "storebyvalue":
        case "storeByValue": target.getConfiguration().setStoreByValue(property(camelContext, boolean.class, value)); return true;
        case "synchronous": target.getConfiguration().setSynchronous(property(camelContext, boolean.class, value)); return true;
        case "writethrough":
        case "writeThrough": target.getConfiguration().setWriteThrough(property(camelContext, boolean.class, value)); return true;
        default: return false;
        }
    }

    @Override
    public Class<?> getOptionType(String name, boolean ignoreCase) {
        switch (ignoreCase ? name.toLowerCase() : name) {
        case "action": return java.lang.String.class;
        case "bridgeerrorhandler":
        case "bridgeErrorHandler": return boolean.class;
        case "cacheconfiguration":
        case "cacheConfiguration": return javax.cache.configuration.Configuration.class;
        case "cacheconfigurationproperties":
        case "cacheConfigurationProperties": return java.util.Properties.class;
        case "cacheloaderfactory":
        case "cacheLoaderFactory": return javax.cache.configuration.Factory.class;
        case "cachewriterfactory":
        case "cacheWriterFactory": return javax.cache.configuration.Factory.class;
        case "cachingprovider":
        case "cachingProvider": return java.lang.String.class;
        case "configurationuri":
        case "configurationUri": return java.lang.String.class;
        case "createcacheifnotexists":
        case "createCacheIfNotExists": return boolean.class;
        case "eventfilters":
        case "eventFilters": return java.util.List.class;
        case "exceptionhandler":
        case "exceptionHandler": return org.apache.camel.spi.ExceptionHandler.class;
        case "exchangepattern":
        case "exchangePattern": return org.apache.camel.ExchangePattern.class;
        case "expirypolicyfactory":
        case "expiryPolicyFactory": return javax.cache.configuration.Factory.class;
        case "filteredevents":
        case "filteredEvents": return java.lang.String.class;
        case "lazystartproducer":
        case "lazyStartProducer": return boolean.class;
        case "lookupproviders":
        case "lookupProviders": return boolean.class;
        case "managementenabled":
        case "managementEnabled": return boolean.class;
        case "oldvaluerequired":
        case "oldValueRequired": return boolean.class;
        case "readthrough":
        case "readThrough": return boolean.class;
        case "statisticsenabled":
        case "statisticsEnabled": return boolean.class;
        case "storebyvalue":
        case "storeByValue": return boolean.class;
        case "synchronous": return boolean.class;
        case "writethrough":
        case "writeThrough": return boolean.class;
        default: return null;
        }
    }

    @Override
    public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
        JCacheEndpoint target = (JCacheEndpoint) obj;
        switch (ignoreCase ? name.toLowerCase() : name) {
        case "action": return target.getConfiguration().getAction();
        case "bridgeerrorhandler":
        case "bridgeErrorHandler": return target.isBridgeErrorHandler();
        case "cacheconfiguration":
        case "cacheConfiguration": return target.getConfiguration().getCacheConfiguration();
        case "cacheconfigurationproperties":
        case "cacheConfigurationProperties": return target.getConfiguration().getCacheConfigurationProperties();
        case "cacheloaderfactory":
        case "cacheLoaderFactory": return target.getConfiguration().getCacheLoaderFactory();
        case "cachewriterfactory":
        case "cacheWriterFactory": return target.getConfiguration().getCacheWriterFactory();
        case "cachingprovider":
        case "cachingProvider": return target.getConfiguration().getCachingProvider();
        case "configurationuri":
        case "configurationUri": return target.getConfiguration().getConfigurationUri();
        case "createcacheifnotexists":
        case "createCacheIfNotExists": return target.getConfiguration().isCreateCacheIfNotExists();
        case "eventfilters":
        case "eventFilters": return target.getConfiguration().getEventFilters();
        case "exceptionhandler":
        case "exceptionHandler": return target.getExceptionHandler();
        case "exchangepattern":
        case "exchangePattern": return target.getExchangePattern();
        case "expirypolicyfactory":
        case "expiryPolicyFactory": return target.getConfiguration().getExpiryPolicyFactory();
        case "filteredevents":
        case "filteredEvents": return target.getConfiguration().getFilteredEvents();
        case "lazystartproducer":
        case "lazyStartProducer": return target.isLazyStartProducer();
        case "lookupproviders":
        case "lookupProviders": return target.getConfiguration().isLookupProviders();
        case "managementenabled":
        case "managementEnabled": return target.getConfiguration().isManagementEnabled();
        case "oldvaluerequired":
        case "oldValueRequired": return target.getConfiguration().isOldValueRequired();
        case "readthrough":
        case "readThrough": return target.getConfiguration().isReadThrough();
        case "statisticsenabled":
        case "statisticsEnabled": return target.getConfiguration().isStatisticsEnabled();
        case "storebyvalue":
        case "storeByValue": return target.getConfiguration().isStoreByValue();
        case "synchronous": return target.getConfiguration().isSynchronous();
        case "writethrough":
        case "writeThrough": return target.getConfiguration().isWriteThrough();
        default: return null;
        }
    }
}