text:
package org.apache.carbondata.index.lucene

import org.apache.spark.sql.test.util.QueryTest
import org.scalatest.{BeforeAndAfterAll, Ignore}

/**
 * Ignored test class as CG index is not supported yet
 */
@Ignore
class LuceneCoarseGrainIndexSuite extends QueryTest with BeforeAndAfterAll {

  val file2 = resourcesPath + "/index_input.csv"

  override protected def beforeAll(): Unit = {
    // n should be about 5000000 of reset if size is default 1024
    val n = 15000
    LuceneFineGrainIndexSuite.createFile(file2, n * 4, n)
    sql("DROP TABLE IF EXISTS normal_test")
    sql(
      """
        | CREATE TABLE normal_test(id INT, name STRING, city STRING, age INT)
        | STORED AS carbondata
        | TBLPROPERTIES('SORT_COLUMNS'='city,name', 'SORT_SCOPE'='LOCAL_SORT')
      """.stripMargin)
    sql(s"LOAD DATA LOCAL INPATH '$file2' INTO TABLE normal_test OPTIONS('header'='false')")
  }

  test("test lucene coarse grain index") {
    sql("DROP TABLE IF EXISTS index_test")
    sql(
      """
        | CREATE TABLE index_test(id INT, name STRING, city STRING, age INT)
        | STORED AS carbondata
        | TBLPROPERTIES('SORT_COLUMNS'='city,name', 'SORT_SCOPE'='LOCAL_SORT')
      """.stripMargin)

    sql(
      s"""
         | CREATE INDEX dm
         | ON index_test (name, city)
         | AS 'lucene'
      """.stripMargin)

    sql(s"LOAD DATA LOCAL INPATH '$file2' INTO TABLE index_test OPTIONS('header'='false')")

    checkAnswer(sql("select * from index_test where name='n502670'"),
      sql("select * from normal_test where name='n502670'"))
  }

  override protected def afterAll(): Unit = {
    LuceneFineGrainIndexSuite.deleteFile(file2)
    sql("DROP TABLE IF EXISTS normal_test")
    sql("DROP TABLE IF EXISTS index_test")
  }

}


text:
#ifndef _XY_UTIL_H_
#define _XY_UTIL_H_ 1

#include "core.h"

#define MAX_PROC_NAME_LEN 16

#define foreach_free(array) {                   \
            for (int i = 0; array[i]; i++) {    \
                free(array[i]);                 \
            }                                   \
            free(array);                        \
        }                                       \

void dump_stack(int);
char ** parse_command(const char *);
pid_t exec(const char *);
char * rc_path();
void change_name(Display *, const char *);
bool streq(const char *, const char *);
char * trim(char *str);
void restart(const char *);
void set_process_name(const char *);

#endif

redpajama_set_name: RedPajamaGithub


text:
package com.android.inputmethod.keyboard.internal;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.os.Build;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.util.Xml;

import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.KeyboardTheme;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.Arrays;

import com.udmurtlyk.extrainputmethod.annotations.UsedForTesting;
import com.udmurtlyk.extrainputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.StringUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
import com.android.inputmethod.latin.utils.XmlParseUtils;

/**
 * Keyboard Building helper.
 *
 * This class parses Keyboard XML file and eventually build a Keyboard.
 * The Keyboard XML file looks like:
 *

 *   <!-- xml/keyboard.xml -->
 *   <Keyboard keyboard_attributes*>
 *     <!-- Keyboard Content -->
 *     <Row row_attributes*>
 *       <!-- Row Content -->
 *       <Key key_attributes* />
 *       <Spacer horizontalGap="32.0dp" />
 *       <include keyboardLayout="@xml/other_keys">
 *       ...
 *     </Row>
 *     <include keyboardLayout="@xml/other_rows">
 *     ...
 *   </Keyboard>
 *

 * The XML file which is included in other file must have <merge> as root element,
 * such as:
 *

 *   <!-- xml/other_keys.xml -->
 *   <merge>
 *     <Key key_attributes* />
 *     ...
 *   </merge>
 *

 * and
 *

 *   <!-- xml/other_rows.xml -->
 *   <merge>
 *     <Row row_attributes*>
 *       <Key key_attributes* />
 *     </Row>
 *     ...
 *   </merge>
 *

 * You can also use switch-case-default tags to select Rows and Keys.
 *

 *   <switch>
 *     <case case_attribute*>
 *       <!-- Any valid tags at switch position -->
 *     </case>
 *     ...
 *     <default>
 *       <!-- Any valid tags at switch position -->
 *     </default>
 *   </switch>
 *

 * You can declare Key style and specify styles within Key tags.
 *

 *     <switch>
 *       <case mode="email">
 *         <key-style styleName="f1-key" parentStyle="modifier-key"
 *           keyLabel=".com"
 *         />
 *       </case>
 *       <case mode="url">
 *         <key-style styleName="f1-key" parentStyle="modifier-key"
 *           keyLabel="http://"
 *         />
 *       </case>
 *     </switch>
 *     ...
 *     <Key keyStyle="shift-key" ... />
 *

 */

// TODO: Write unit tests for this class.
public class KeyboardBuilder<KP extends KeyboardParams> {
    private static final String BUILDER_TAG = "Keyboard.Builder";
    private static final boolean DEBUG = false;

    // Keyboard XML Tags
    private static final String TAG_KEYBOARD = "Keyboard";
    private static final String TAG_ROW = "Row";
    private static final String TAG_GRID_ROWS = "GridRows";
    private static final String TAG_KEY = "Key";
    private static final String TAG_SPACER = "Spacer";
    private static final String TAG_INCLUDE = "include";
    private static final String TAG_MERGE = "merge";
    private static final String TAG_SWITCH = "switch";
    private static final String TAG_CASE = "case";
    private static final String TAG_DEFAULT = "default";
    public static final String TAG_KEY_STYLE = "key-style";

    private static final int DEFAULT_KEYBOARD_COLUMNS = 10;
    private static final int DEFAULT_KEYBOARD_ROWS = 4;

    protected final KP mParams;
    protected final Context mContext;
    protected final Resources mResources;

    private int mCurrentY = 0;
    private KeyboardRow mCurrentRow = null;
    private boolean mLeftEdge;
    private boolean mTopEdge;
    private Key mRightEdgeKey = null;

    public KeyboardBuilder(final Context context, final KP params) {
        mContext = context;
        final Resources res = context.getResources();
        mResources = res;

        mParams = params;

        params.GRID_WIDTH = res.getInteger(com.udmurtlyk.extrainputmethod.latin.R.integer.config_keyboard_grid_width);
        params.GRID_HEIGHT = res.getInteger(com.udmurtlyk.extrainputmethod.latin.R.integer.config_keyboard_grid_height);
    }

    public void setAutoGenerate(final KeysCache keysCache) {
        mParams.mKeysCache = keysCache;
    }

    public KeyboardBuilder<KP> load(final int xmlId, final KeyboardId id) {
        mParams.mId = id;
        final XmlResourceParser parser = mResources.getXml(xmlId);
        try {
            parseKeyboard(parser);
        } catch (XmlPullParserException e) {
            Log.w(BUILDER_TAG, "keyboard XML parse error", e);
            throw new IllegalArgumentException(e.getMessage(), e);
        } catch (IOException e) {
            Log.w(BUILDER_TAG, "keyboard XML parse error", e);
            throw new RuntimeException(e.getMessage(), e);
        } finally {
            parser.close();
        }
        return this;
    }

    @UsedForTesting
    public void disableTouchPositionCorrectionDataForTest() {
        mParams.mTouchPositionCorrection.setEnabled(false);
    }

    public void setProximityCharsCorrectionEnabled(final boolean enabled) {
        mParams.mProximityCharsCorrectionEnabled = enabled;
    }

    public Keyboard build() {
        return new Keyboard(mParams);
    }

    private int mIndent;
    private static final String SPACES = "                                             ";

    private static String spaces(final int count) {
        return (count < SPACES.length()) ? SPACES.substring(0, count) : SPACES;
    }

    private void startTag(final String format, final Object ... args) {
        Log.d(BUILDER_TAG, String.format(spaces(++mIndent * 2) + format, args));
    }

    private void endTag(final String format, final Object ... args) {
        Log.d(BUILDER_TAG, String.format(spaces(mIndent-- * 2) + format, args));
    }

    private void startEndTag(final String format, final Object ... args) {
        Log.d(BUILDER_TAG, String.format(spaces(++mIndent * 2) + format, args));
        mIndent--;
    }

    private void parseKeyboard(final XmlPullParser parser)
            throws XmlPullParserException, IOException {
        if (DEBUG) startTag("<%s> %s", TAG_KEYBOARD, mParams.mId);
        while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            final int event = parser.next();
            if (event == XmlPullParser.START_TAG) {
                final String tag = parser.getName();
                if (TAG_KEYBOARD.equals(tag)) {
                    parseKeyboardAttributes(parser);
                    startKeyboard();
                    parseKeyboardContent(parser, false);
                    return;
                }
                throw new XmlParseUtils.IllegalStartTag(parser, tag, TAG_KEYBOARD);
            }
        }
    }

    private void parseKeyboardAttributes(final XmlPullParser parser) {
        final AttributeSet attr = Xml.asAttributeSet(parser);
        final TypedArray keyboardAttr = mContext.obtainStyledAttributes(
                attr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard, com.udmurtlyk.extrainputmethod.latin.R.attr.keyboardStyle, com.udmurtlyk.extrainputmethod.latin.R.style.Keyboard);
        final TypedArray keyAttr = mResources.obtainAttributes(attr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Key);
        try {
            final KeyboardParams params = mParams;
            final int height = params.mId.mHeight;
            final int width = params.mId.mWidth;
            params.mOccupiedHeight = height;
            params.mOccupiedWidth = width;
            params.mTopPadding = (int)keyboardAttr.getFraction(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_keyboardTopPadding, height, height, 0);
            params.mBottomPadding = (int)keyboardAttr.getFraction(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_keyboardBottomPadding, height, height, 0);
            params.mLeftPadding = (int)keyboardAttr.getFraction(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_keyboardLeftPadding, width, width, 0);
            params.mRightPadding = (int)keyboardAttr.getFraction(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_keyboardRightPadding, width, width, 0);

            final int baseWidth =
                    params.mOccupiedWidth - params.mLeftPadding - params.mRightPadding;
            params.mBaseWidth = baseWidth;
            params.mDefaultKeyWidth = (int)keyAttr.getFraction(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Key_keyWidth,
                    baseWidth, baseWidth, baseWidth / DEFAULT_KEYBOARD_COLUMNS);
            params.mHorizontalGap = (int)keyboardAttr.getFraction(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_horizontalGap, baseWidth, baseWidth, 0);
            // TODO: Fix keyboard geometry calculation clearer. Historically vertical gap between
            // rows are determined based on the entire keyboard height including top and bottom
            // paddings.
            params.mVerticalGap = (int)keyboardAttr.getFraction(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_verticalGap, height, height, 0);
            final int baseHeight = params.mOccupiedHeight - params.mTopPadding
                    - params.mBottomPadding + params.mVerticalGap;
            params.mBaseHeight = baseHeight;
            params.mDefaultRowHeight = (int) ResourceUtils.getDimensionOrFraction(keyboardAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_rowHeight, baseHeight, baseHeight / DEFAULT_KEYBOARD_ROWS);

            params.mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);

            params.mMoreKeysTemplate = keyboardAttr.getResourceId(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_moreKeysTemplate, 0);
            params.mMaxMoreKeysKeyboardColumn = keyAttr.getInt(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Key_maxMoreKeysColumn, 5);

            params.mThemeId = keyboardAttr.getInt(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_themeId, 0);
            params.mIconsSet.loadIcons(keyboardAttr);
            params.mTextsSet.setLocale(params.mId.mLocale, mContext);

            final int resourceId = keyboardAttr.getResourceId(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_touchPositionCorrectionData, 0);
            if (resourceId != 0) {
                final String[] data = mResources.getStringArray(resourceId);
                params.mTouchPositionCorrection.load(data);
            }
        } finally {
            keyAttr.recycle();
            keyboardAttr.recycle();
        }
    }

    private void parseKeyboardContent(final XmlPullParser parser, final boolean skip)
            throws XmlPullParserException, IOException {
        while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            final int event = parser.next();
            if (event == XmlPullParser.START_TAG) {
                final String tag = parser.getName();
                if (TAG_ROW.equals(tag)) {
                    final KeyboardRow row = parseRowAttributes(parser);
                    if (DEBUG) startTag("<%s>%s", TAG_ROW, skip ? " skipped" : "");
                    if (!skip) {
                        startRow(row);
                    }
                    parseRowContent(parser, row, skip);
                } else if (TAG_GRID_ROWS.equals(tag)) {
                    if (DEBUG) startTag("<%s>%s", TAG_GRID_ROWS, skip ? " skipped" : "");
                    parseGridRows(parser, skip);
                } else if (TAG_INCLUDE.equals(tag)) {
                    parseIncludeKeyboardContent(parser, skip);
                } else if (TAG_SWITCH.equals(tag)) {
                    parseSwitchKeyboardContent(parser, skip);
                } else if (TAG_KEY_STYLE.equals(tag)) {
                    parseKeyStyle(parser, skip);
                } else {
                    throw new XmlParseUtils.IllegalStartTag(parser, tag, TAG_ROW);
                }
            } else if (event == XmlPullParser.END_TAG) {
                final String tag = parser.getName();
                if (DEBUG) endTag("</%s>", tag);
                if (TAG_KEYBOARD.equals(tag)) {
                    endKeyboard();
                    return;
                }
                if (TAG_CASE.equals(tag) || TAG_DEFAULT.equals(tag) || TAG_MERGE.equals(tag)) {
                    return;
                }
                throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_ROW);
            }
        }
    }

    private KeyboardRow parseRowAttributes(final XmlPullParser parser)
            throws XmlPullParserException {
        final AttributeSet attr = Xml.asAttributeSet(parser);
        final TypedArray keyboardAttr = mResources.obtainAttributes(attr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard);
        try {
            if (keyboardAttr.hasValue(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_horizontalGap)) {
                throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "horizontalGap");
            }
            if (keyboardAttr.hasValue(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_verticalGap)) {
                throw new XmlParseUtils.IllegalAttribute(parser, TAG_ROW, "verticalGap");
            }
            return new KeyboardRow(mResources, mParams, parser, mCurrentY);
        } finally {
            keyboardAttr.recycle();
        }
    }

    private void parseRowContent(final XmlPullParser parser, final KeyboardRow row,
            final boolean skip) throws XmlPullParserException, IOException {
        while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            final int event = parser.next();
            if (event == XmlPullParser.START_TAG) {
                final String tag = parser.getName();
                if (TAG_KEY.equals(tag)) {
                    parseKey(parser, row, skip);
                } else if (TAG_SPACER.equals(tag)) {
                    parseSpacer(parser, row, skip);
                } else if (TAG_INCLUDE.equals(tag)) {
                    parseIncludeRowContent(parser, row, skip);
                } else if (TAG_SWITCH.equals(tag)) {
                    parseSwitchRowContent(parser, row, skip);
                } else if (TAG_KEY_STYLE.equals(tag)) {
                    parseKeyStyle(parser, skip);
                } else {
                    throw new XmlParseUtils.IllegalStartTag(parser, tag, TAG_ROW);
                }
            } else if (event == XmlPullParser.END_TAG) {
                final String tag = parser.getName();
                if (DEBUG) endTag("</%s>", tag);
                if (TAG_ROW.equals(tag)) {
                    if (!skip) {
                        endRow(row);
                    }
                    return;
                }
                if (TAG_CASE.equals(tag) || TAG_DEFAULT.equals(tag) || TAG_MERGE.equals(tag)) {
                    return;
                }
                throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_ROW);
            }
        }
    }

    private void parseGridRows(final XmlPullParser parser, final boolean skip)
            throws XmlPullParserException, IOException {
        if (skip) {
            XmlParseUtils.checkEndTag(TAG_GRID_ROWS, parser);
            if (DEBUG) {
                startEndTag("<%s /> skipped", TAG_GRID_ROWS);
            }
            return;
        }
        final KeyboardRow gridRows = new KeyboardRow(mResources, mParams, parser, mCurrentY);
        final TypedArray gridRowAttr = mResources.obtainAttributes(
                Xml.asAttributeSet(parser), com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_GridRows);
        final int codesArrayId = gridRowAttr.getResourceId(
                com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_GridRows_codesArray, 0);
        final int textsArrayId = gridRowAttr.getResourceId(
                com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_GridRows_textsArray, 0);
        gridRowAttr.recycle();
        if (codesArrayId == 0 && textsArrayId == 0) {
            throw new XmlParseUtils.ParseException(
                    "Missing codesArray or textsArray attributes", parser);
        }
        if (codesArrayId != 0 && textsArrayId != 0) {
            throw new XmlParseUtils.ParseException(
                    "Both codesArray and textsArray attributes specifed", parser);
        }
        final String[] array = mResources.getStringArray(
                codesArrayId != 0 ? codesArrayId : textsArrayId);
        final int counts = array.length;
        final float keyWidth = gridRows.getKeyWidth(null, 0.0f);
        final int numColumns = (int)(mParams.mOccupiedWidth / keyWidth);
        for (int index = 0; index < counts; index += numColumns) {
            final KeyboardRow row = new KeyboardRow(mResources, mParams, parser, mCurrentY);
            startRow(row);
            for (int c = 0; c < numColumns; c++) {
                final int i = index + c;
                if (i >= counts) {
                    break;
                }
                final String label;
                final int code;
                final String outputText;
                final int supportedMinSdkVersion;
                if (codesArrayId != 0) {
                    final String codeArraySpec = array[i];
                    label = CodesArrayParser.parseLabel(codeArraySpec);
                    code = CodesArrayParser.parseCode(codeArraySpec);
                    outputText = CodesArrayParser.parseOutputText(codeArraySpec);
                    supportedMinSdkVersion =
                            CodesArrayParser.getMinSupportSdkVersion(codeArraySpec);
                } else {
                    final String textArraySpec = array[i];
                    // TODO: Utilize KeySpecParser or write more generic TextsArrayParser.
                    label = textArraySpec;
                    code = Constants.CODE_OUTPUT_TEXT;
                    outputText = textArraySpec + (char)Constants.CODE_SPACE;
                    supportedMinSdkVersion = 0;
                }
                if (Build.VERSION.SDK_INT < supportedMinSdkVersion) {
                    continue;
                }
                final int labelFlags = row.getDefaultKeyLabelFlags();
                // TODO: Should be able to assign default keyActionFlags as well.
                final int backgroundType = row.getDefaultBackgroundType();
                final int x = (int)row.getKeyX(null);
                final int y = row.getKeyY();
                final int width = (int)keyWidth;
                final int height = row.getRowHeight();
                final Key key = new Key(label, KeyboardIconsSet.ICON_UNDEFINED, code, outputText,
                        null /* hintLabel */, labelFlags, backgroundType, x, y, width, height,
                        mParams.mHorizontalGap, mParams.mVerticalGap);
                endKey(key);
                row.advanceXPos(keyWidth);
            }
            endRow(row);
        }

        XmlParseUtils.checkEndTag(TAG_GRID_ROWS, parser);
    }

    private void parseKey(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
            throws XmlPullParserException, IOException {
        if (skip) {
            XmlParseUtils.checkEndTag(TAG_KEY, parser);
            if (DEBUG) startEndTag("<%s /> skipped", TAG_KEY);
            return;
        }
        final TypedArray keyAttr = mResources.obtainAttributes(
                Xml.asAttributeSet(parser), com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Key);
        final KeyStyle keyStyle = mParams.mKeyStyles.getKeyStyle(keyAttr, parser);
        final String keySpec = keyStyle.getString(keyAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Key_keySpec);
        if (TextUtils.isEmpty(keySpec)) {
            throw new XmlParseUtils.ParseException("Empty keySpec", parser);
        }
        final Key key = new Key(keySpec, keyAttr, keyStyle, mParams, row);
        keyAttr.recycle();
        if (DEBUG) {
            startEndTag("<%s%s %s moreKeys=%s />", TAG_KEY, (key.isEnabled() ? "" : " disabled"),
                    key, Arrays.toString(key.getMoreKeys()));
        }
        XmlParseUtils.checkEndTag(TAG_KEY, parser);
        endKey(key);
    }

    private void parseSpacer(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
            throws XmlPullParserException, IOException {
        if (skip) {
            XmlParseUtils.checkEndTag(TAG_SPACER, parser);
            if (DEBUG) startEndTag("<%s /> skipped", TAG_SPACER);
            return;
        }
        final TypedArray keyAttr = mResources.obtainAttributes(
                Xml.asAttributeSet(parser), com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Key);
        final KeyStyle keyStyle = mParams.mKeyStyles.getKeyStyle(keyAttr, parser);
        final Key spacer = new Key.Spacer(keyAttr, keyStyle, mParams, row);
        keyAttr.recycle();
        if (DEBUG) startEndTag("<%s />", TAG_SPACER);
        XmlParseUtils.checkEndTag(TAG_SPACER, parser);
        endKey(spacer);
    }

    private void parseIncludeKeyboardContent(final XmlPullParser parser, final boolean skip)
            throws XmlPullParserException, IOException {
        parseIncludeInternal(parser, null, skip);
    }

    private void parseIncludeRowContent(final XmlPullParser parser, final KeyboardRow row,
            final boolean skip) throws XmlPullParserException, IOException {
        parseIncludeInternal(parser, row, skip);
    }

    private void parseIncludeInternal(final XmlPullParser parser, final KeyboardRow row,
            final boolean skip) throws XmlPullParserException, IOException {
        if (skip) {
            XmlParseUtils.checkEndTag(TAG_INCLUDE, parser);
            if (DEBUG) startEndTag("</%s> skipped", TAG_INCLUDE);
            return;
        }
        final AttributeSet attr = Xml.asAttributeSet(parser);
        final TypedArray keyboardAttr = mResources.obtainAttributes(
                attr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Include);
        final TypedArray keyAttr = mResources.obtainAttributes(attr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Key);
        int keyboardLayout = 0;
        try {
            XmlParseUtils.checkAttributeExists(
                    keyboardAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Include_keyboardLayout, "keyboardLayout",
                    TAG_INCLUDE, parser);
            keyboardLayout = keyboardAttr.getResourceId(
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Include_keyboardLayout, 0);
            if (row != null) {
                // Override current x coordinate.
                row.setXPos(row.getKeyX(keyAttr));
                // Push current Row attributes and update with new attributes.
                row.pushRowAttributes(keyAttr);
            }
        } finally {
            keyboardAttr.recycle();
            keyAttr.recycle();
        }

        XmlParseUtils.checkEndTag(TAG_INCLUDE, parser);
        if (DEBUG) {
            startEndTag("<%s keyboardLayout=%s />",TAG_INCLUDE,
                    mResources.getResourceEntryName(keyboardLayout));
        }
        final XmlResourceParser parserForInclude = mResources.getXml(keyboardLayout);
        try {
            parseMerge(parserForInclude, row, skip);
        } finally {
            if (row != null) {
                // Restore Row attributes.
                row.popRowAttributes();
            }
            parserForInclude.close();
        }
    }

    private void parseMerge(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
            throws XmlPullParserException, IOException {
        if (DEBUG) startTag("<%s>", TAG_MERGE);
        while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            final int event = parser.next();
            if (event == XmlPullParser.START_TAG) {
                final String tag = parser.getName();
                if (TAG_MERGE.equals(tag)) {
                    if (row == null) {
                        parseKeyboardContent(parser, skip);
                    } else {
                        parseRowContent(parser, row, skip);
                    }
                    return;
                }
                throw new XmlParseUtils.ParseException(
                        "Included keyboard layout must have <merge> root element", parser);
            }
        }
    }

    private void parseSwitchKeyboardContent(final XmlPullParser parser, final boolean skip)
            throws XmlPullParserException, IOException {
        parseSwitchInternal(parser, null, skip);
    }

    private void parseSwitchRowContent(final XmlPullParser parser, final KeyboardRow row,
            final boolean skip) throws XmlPullParserException, IOException {
        parseSwitchInternal(parser, row, skip);
    }

    private void parseSwitchInternal(final XmlPullParser parser, final KeyboardRow row,
            final boolean skip) throws XmlPullParserException, IOException {
        if (DEBUG) startTag("<%s> %s", TAG_SWITCH, mParams.mId);
        boolean selected = false;
        while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
            final int event = parser.next();
            if (event == XmlPullParser.START_TAG) {
                final String tag = parser.getName();
                if (TAG_CASE.equals(tag)) {
                    selected |= parseCase(parser, row, selected ? true : skip);
                } else if (TAG_DEFAULT.equals(tag)) {
                    selected |= parseDefault(parser, row, selected ? true : skip);
                } else {
                    throw new XmlParseUtils.IllegalStartTag(parser, tag, TAG_SWITCH);
                }
            } else if (event == XmlPullParser.END_TAG) {
                final String tag = parser.getName();
                if (TAG_SWITCH.equals(tag)) {
                    if (DEBUG) endTag("</%s>", TAG_SWITCH);
                    return;
                }
                throw new XmlParseUtils.IllegalEndTag(parser, tag, TAG_SWITCH);
            }
        }
    }

    private boolean parseCase(final XmlPullParser parser, final KeyboardRow row, final boolean skip)
            throws XmlPullParserException, IOException {
        final boolean selected = parseCaseCondition(parser);
        if (row == null) {
            // Processing Rows.
            parseKeyboardContent(parser, selected ? skip : true);
        } else {
            // Processing Keys.
            parseRowContent(parser, row, selected ? skip : true);
        }
        return selected;
    }

    private boolean parseCaseCondition(final XmlPullParser parser) {
        final KeyboardId id = mParams.mId;
        if (id == null) {
            return true;
        }
        final AttributeSet attr = Xml.asAttributeSet(parser);
        final TypedArray caseAttr = mResources.obtainAttributes(attr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case);
        try {
            final boolean keyboardLayoutSetMatched = matchString(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_keyboardLayoutSet,
                    SubtypeLocaleUtils.getKeyboardLayoutSetName(id.mSubtype));
            final boolean keyboardLayoutSetElementMatched = matchTypedValue(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_keyboardLayoutSetElement, id.mElementId,
                    KeyboardId.elementIdToName(id.mElementId));
            final boolean keyboardThemeMacthed = matchTypedValue(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_keyboardTheme, mParams.mThemeId,
                    KeyboardTheme.getKeyboardThemeName(mParams.mThemeId));
            final boolean modeMatched = matchTypedValue(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
            final boolean navigateNextMatched = matchBoolean(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_navigateNext, id.navigateNext());
            final boolean navigatePreviousMatched = matchBoolean(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_navigatePrevious, id.navigatePrevious());
            final boolean passwordInputMatched = matchBoolean(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
            final boolean clobberSettingsKeyMatched = matchBoolean(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
            final boolean hasShortcutKeyMatched = matchBoolean(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
            final boolean languageSwitchKeyEnabledMatched = matchBoolean(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
                    id.mLanguageSwitchKeyEnabled);
            final boolean isMultiLineMatched = matchBoolean(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_isMultiLine, id.isMultiLine());
            final boolean imeActionMatched = matchInteger(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_imeAction, id.imeAction());
            final boolean isIconDefinedMatched = isIconDefined(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_isIconDefined, mParams.mIconsSet);
            final boolean localeCodeMatched = matchString(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_localeCode, id.mLocale.toString());
            final boolean languageCodeMatched = matchString(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage());
            final boolean countryCodeMatched = matchString(caseAttr,
                    com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
            final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched
                    && keyboardThemeMacthed && modeMatched && navigateNextMatched
                    && navigatePreviousMatched && passwordInputMatched && clobberSettingsKeyMatched
                    && hasShortcutKeyMatched  && languageSwitchKeyEnabledMatched
                    && isMultiLineMatched && imeActionMatched && isIconDefinedMatched
                    && localeCodeMatched && languageCodeMatched && countryCodeMatched;

            if (DEBUG) {
                startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
                        textAttr(caseAttr.getString(
                                com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_keyboardLayoutSet), "keyboardLayoutSet"),
                        textAttr(caseAttr.getString(
                                com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_keyboardLayoutSetElement),
                                "keyboardLayoutSetElement"),
                        textAttr(caseAttr.getString(
                                com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_keyboardTheme), "keyboardTheme"),
                        textAttr(caseAttr.getString(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_mode), "mode"),
                        textAttr(caseAttr.getString(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_imeAction),
                                "imeAction"),
                        booleanAttr(caseAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_navigateNext,
                                "navigateNext"),
                        booleanAttr(caseAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_navigatePrevious,
                                "navigatePrevious"),
                        booleanAttr(caseAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_clobberSettingsKey,
                                "clobberSettingsKey"),
                        booleanAttr(caseAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_passwordInput,
                                "passwordInput"),
                        booleanAttr(caseAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_hasShortcutKey,
                                "hasShortcutKey"),
                        booleanAttr(caseAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
                                "languageSwitchKeyEnabled"),
                        booleanAttr(caseAttr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_isMultiLine,
                                "isMultiLine"),
                        textAttr(caseAttr.getString(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_isIconDefined),
                                "isIconDefined"),
                        textAttr(caseAttr.getString(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_localeCode),
                                "localeCode"),
                        textAttr(caseAttr.getString(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_languageCode),
                                "languageCode"),
                        textAttr(caseAttr.getString(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Case_countryCode),
                                "countryCode"),
                        selected ? "" : " skipped");
            }

            return selected;
        } finally {
            caseAttr.recycle();
        }
    }

    private static boolean matchInteger(final TypedArray a, final int index, final int value) {
        // If <case> does not have "index" attribute, that means this <case> is wild-card for
        // the attribute.
        return !a.hasValue(index) || a.getInt(index, 0) == value;
    }

    private static boolean matchBoolean(final TypedArray a, final int index, final boolean value) {
        // If <case> does not have "index" attribute, that means this <case> is wild-card for
        // the attribute.
        return !a.hasValue(index) || a.getBoolean(index, false) == value;
    }

    private static boolean matchString(final TypedArray a, final int index, final String value) {
        // If <case> does not have "index" attribute, that means this <case> is wild-card for
        // the attribute.
        return !a.hasValue(index)
                || StringUtils.containsInArray(value, a.getString(index).split("\\|"));
    }

    private static boolean matchTypedValue(final TypedArray a, final int index, final int intValue,
            final String strValue) {
        // If <case> does not have "index" attribute, that means this <case> is wild-card for
        // the attribute.
        final TypedValue v = a.peekValue(index);
        if (v == null) {
            return true;
        }
        if (ResourceUtils.isIntegerValue(v)) {
            return intValue == a.getInt(index, 0);
        }
        if (ResourceUtils.isStringValue(v)) {
            return StringUtils.containsInArray(strValue, a.getString(index).split("\\|"));
        }
        return false;
    }

    private static boolean isIconDefined(final TypedArray a, final int index,
            final KeyboardIconsSet iconsSet) {
        if (!a.hasValue(index)) {
            return true;
        }
        final String iconName = a.getString(index);
        final int iconId = KeyboardIconsSet.getIconId(iconName);
        return iconsSet.getIconDrawable(iconId) != null;
    }

    private boolean parseDefault(final XmlPullParser parser, final KeyboardRow row,
            final boolean skip) throws XmlPullParserException, IOException {
        if (DEBUG) startTag("<%s>", TAG_DEFAULT);
        if (row == null) {
            parseKeyboardContent(parser, skip);
        } else {
            parseRowContent(parser, row, skip);
        }
        return true;
    }

    private void parseKeyStyle(final XmlPullParser parser, final boolean skip)
            throws XmlPullParserException, IOException {
        final AttributeSet attr = Xml.asAttributeSet(parser);
        final TypedArray keyStyleAttr = mResources.obtainAttributes(
                attr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_KeyStyle);
        final TypedArray keyAttrs = mResources.obtainAttributes(attr, com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_Key);
        try {
            if (!keyStyleAttr.hasValue(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_KeyStyle_styleName)) {
                throw new XmlParseUtils.ParseException("<" + TAG_KEY_STYLE
                        + "/> needs styleName attribute", parser);
            }
            if (DEBUG) {
                startEndTag("<%s styleName=%s />%s", TAG_KEY_STYLE,
                        keyStyleAttr.getString(com.udmurtlyk.extrainputmethod.latin.R.styleable.Keyboard_KeyStyle_styleName),
                        skip ? " skipped" : "");
            }
            if (!skip) {
                mParams.mKeyStyles.parseKeyStyleAttributes(keyStyleAttr, keyAttrs, parser);
            }
        } finally {
            keyStyleAttr.recycle();
            keyAttrs.recycle();
        }
        XmlParseUtils.checkEndTag(TAG_KEY_STYLE, parser);
    }

    private void startKeyboard() {
        mCurrentY += mParams.mTopPadding;
        mTopEdge = true;
    }

    private void startRow(final KeyboardRow row) {
        addEdgeSpace(mParams.mLeftPadding, row);
        mCurrentRow = row;
        mLeftEdge = true;
        mRightEdgeKey = null;
    }

    private void endRow(final KeyboardRow row) {
        if (mCurrentRow == null) {
            throw new RuntimeException("orphan end row tag");
        }
        if (mRightEdgeKey != null) {
            mRightEdgeKey.markAsRightEdge(mParams);
            mRightEdgeKey = null;
        }
        addEdgeSpace(mParams.mRightPadding, row);
        mCurrentY += row.getRowHeight();
        mCurrentRow = null;
        mTopEdge = false;
    }

    private void endKey(final Key key) {
        mParams.onAddKey(key);
        if (mLeftEdge) {
            key.markAsLeftEdge(mParams);
            mLeftEdge = false;
        }
        if (mTopEdge) {
            key.markAsTopEdge(mParams);
        }
        mRightEdgeKey = key;
    }

    private void endKeyboard() {
        // {@link #parseGridRows(XmlPullParser,boolean)} may populate keyboard rows higher than
        // previously expected.
        final int actualHeight = mCurrentY - mParams.mVerticalGap + mParams.mBottomPadding;
        mParams.mOccupiedHeight = Math.max(mParams.mOccupiedHeight, actualHeight);
    }

    private void addEdgeSpace(final float width, final KeyboardRow row) {
        row.advanceXPos(width);
        mLeftEdge = false;
        mRightEdgeKey = null;
    }

    private static String textAttr(final String value, final String name) {
        return value != null ? String.format(" %s=%s", name, value) : "";
    }

    private static String booleanAttr(final TypedArray a, final int index, final String name) {
        return a.hasValue(index)
                ? String.format(" %s=%s", name, a.getBoolean(index, false)) : "";
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background">

    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@android:color/white" />

    <FrameLayout
        android:id="@+id/steps_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/llPeople" />

</RelativeLayout>


text:
rm index.zip
zip index.zip index.js index.html images images/*


text:
import base from "./base";

/**
 * Gruvbox Theme
 */
const gruvbox = {
  ...base,
  header_background: "#1D2021",
  editor_theme: "gruvbox",
};

export default gruvbox;


text:
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>W30219_text</title>
        <link rel="stylesheet" type="text/css" href="style.css" />

                «

    <p class="styleSans10.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">TABLE OF CONTENTS

    <p class="styleSans1.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">II.

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">III.
IV.
.<
VII.

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">VIII.

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">x
XII.


text:
Telescope.registerComponent("App",                  require('./common/App.jsx'));
Telescope.registerComponent("Footer",               require('./common/Footer.jsx'));
Telescope.registerComponent("Header",               require('./common/Header.jsx'));
Telescope.registerComponent("Layout",               require('./common/Layout.jsx'));
Telescope.registerComponent("Logo",                 require('./common/Logo.jsx'));
Telescope.registerComponent("Flash",                require('./common/Flash.jsx'));
Telescope.registerComponent('HeadTags',             require('./common/HeadTags.jsx'));
Telescope.registerComponent("FlashMessages",        require('./common/FlashMessages.jsx'));
Telescope.registerComponent("NewsletterForm",       require('./common/NewsletterForm.jsx'));
Telescope.registerComponent("Icon",                 require('./common/Icon.jsx'));
Telescope.registerComponent("SearchForm",           require('./common/SearchForm.jsx'));
Telescope.registerComponent("AppLoading",           require('./common/AppLoading.jsx'));
Telescope.registerComponent("Error404",             require('./common/Error404.jsx'));
Telescope.registerComponent("Loading",              require('./common/Loading.jsx'));
Telescope.registerComponent("Vote",                 require('./common/Vote.jsx'));
Telescope.registerComponent("SettingsEditForm",     require('./common/SettingsEditForm.jsx'));

// posts

Telescope.registerComponent("PostsNewButton",       require('./posts/PostsNewButton.jsx'));
Telescope.registerComponent("PostsLoadMore",        require('./posts/PostsLoadMore.jsx'));
Telescope.registerComponent("PostsNoMore",          require('./posts/PostsNoMore.jsx'));
Telescope.registerComponent("PostsNoResults",       require('./posts/PostsNoResults.jsx'));
Telescope.registerComponent("PostsItem",            require('./posts/PostsItem.jsx'));
Telescope.registerComponent("PostsLoading",         require('./posts/PostsLoading.jsx'));
Telescope.registerComponent("PostsViews",           require('./posts/PostsViews.jsx'));
Telescope.registerComponent("PostsList",            require('./posts/PostsList.jsx'));
Telescope.registerComponent("PostsListHeader",      require('./posts/PostsListHeader.jsx'));
Telescope.registerComponent("PostsCategories",      require('./posts/PostsCategories.jsx'));
Telescope.registerComponent("PostsCommenters",      require('./posts/PostsCommenters.jsx'));
Telescope.registerComponent("PostsPage",            require('./posts/PostsPage.jsx'));
Telescope.registerComponent("PostsStats",           require('./posts/PostsStats.jsx'));
Telescope.registerComponent("PostsDaily",           require('./posts/PostsDaily.jsx'));
Telescope.registerComponent("PostsDay",             require('./posts/PostsDay.jsx'));
Telescope.registerComponent("PostsThumbnail",       require('./posts/PostsThumbnail.jsx'));
Telescope.registerComponent("PostsEditForm",        require('./posts/PostsEditForm.jsx'));
Telescope.registerComponent("PostsNewForm",         require('./posts/PostsNewForm.jsx'));

// comments

Telescope.registerComponent("CommentsItem",         require('./comments/CommentsItem.jsx'));
Telescope.registerComponent("CommentsList",         require('./comments/CommentsList.jsx'));
Telescope.registerComponent("CommentsNode",         require('./comments/CommentsNode.jsx'));
Telescope.registerComponent("CommentsNew",          require('./comments/CommentsNew.jsx'));
Telescope.registerComponent("CommentsEdit",         require('./comments/CommentsEdit.jsx'));

// categories

Telescope.registerComponent("CategoriesList",       require('./categories/CategoriesList.jsx'));
Telescope.registerComponent("Category",             require('./categories/Category.jsx'));
Telescope.registerComponent("CategoriesEditForm",   require('./categories/CategoriesEditForm.jsx'));
Telescope.registerComponent("CategoriesNewForm",    require('./categories/CategoriesNewForm.jsx'));

// permissions

Telescope.registerComponent("CanCreatePost",        require('./permissions/CanCreatePost.jsx'));
Telescope.registerComponent("CanEditPost",          require('./permissions/CanEditPost.jsx'));
Telescope.registerComponent("CanView",              require('./permissions/CanView.jsx'));
Telescope.registerComponent("CanViewPost",          require('./permissions/CanViewPost.jsx'));
Telescope.registerComponent("CanEditUser",          require('./permissions/CanEditUser.jsx'));

// users

Telescope.registerComponent("UserEdit",             require('./users/UserEdit.jsx'));
Telescope.registerComponent("UserProfile",          require('./users/UserProfile.jsx'));
Telescope.registerComponent("UserAvatar",           require('./users/UserAvatar.jsx'));
Telescope.registerComponent("UserName",             require('./users/UserName.jsx'));
Telescope.registerComponent("UserMenu",             require('./users/UserMenu.jsx'));
Telescope.registerComponent("AccountsMenu",         require('./users/AccountsMenu.jsx'));
Telescope.registerComponent("AccountsForm",         require('./users/AccountsForm.jsx'));


text:
/*
  CommonJS module available in front as well as back end.
*/

(function(exports) {
  'use strict';
  var Foo = function(bar, baz) {
      this.bar = bar;
      this.baz = baz;
      // this.prototype = Foo.prototype;
    };

  Foo.prototype = {
    barBaz: function() {
      return ['bar: ', this.bar, ', baz: ', this.baz].toString();
    }
  };

  exports.Foo = Foo;
})((typeof exports !== 'undefined' && exports || this));


text:
"""
Helper methods to deal with images.

This is essentially a copy from nova.virt.images.py
Some slight modifications, but at some point
we should look at maybe pushign this up to OSLO
"""

import os
import re
import tempfile

from cinder import exception
from cinder import flags
from cinder.openstack.common import cfg
from cinder.openstack.common import log as logging
from cinder import utils

LOG = logging.getLogger(__name__)

image_helper_opt = [cfg.StrOpt('image_conversion_dir',
                    default='/tmp',
                    help='parent dir for tempdir used for image conversion'), ]

FLAGS = flags.FLAGS
FLAGS.register_opts(image_helper_opt)

class QemuImgInfo(object):
    BACKING_FILE_RE = re.compile((r"^(.*?)\s*\(actual\s+path\s*:"
                                  r"\s+(.*?)\)\s*$"), re.I)
    TOP_LEVEL_RE = re.compile(r"^([\w\d\s\_\-]+):(.*)$")
    SIZE_RE = re.compile(r"\(\s*(\d+)\s+bytes\s*\)", re.I)

    def __init__(self, cmd_output):
        details = self._parse(cmd_output)
        self.image = details.get('image')
        self.backing_file = details.get('backing_file')
        self.file_format = details.get('file_format')
        self.virtual_size = details.get('virtual_size')
        self.cluster_size = details.get('cluster_size')
        self.disk_size = details.get('disk_size')
        self.snapshots = details.get('snapshot_list', [])
        self.encryption = details.get('encryption')

    def __str__(self):
        lines = [
            'image: %s' % self.image,
            'file_format: %s' % self.file_format,
            'virtual_size: %s' % self.virtual_size,
            'disk_size: %s' % self.disk_size,
            'cluster_size: %s' % self.cluster_size,
            'backing_file: %s' % self.backing_file,
        ]
        if self.snapshots:
            lines.append("snapshots: %s" % self.snapshots)
        return "\n".join(lines)

    def _canonicalize(self, field):
        # Standardize on underscores/lc/no dash and no spaces
        # since qemu seems to have mixed outputs here... and
        # this format allows for better integration with python
        # - ie for usage in kwargs and such...
        field = field.lower().strip()
        for c in (" ", "-"):
            field = field.replace(c, '_')
        return field

    def _extract_bytes(self, details):
        # Replace it with the byte amount
        real_size = self.SIZE_RE.search(details)
        if real_size:
            details = real_size.group(1)
        try:
            details = utils.to_bytes(details)
        except (TypeError, ValueError):
            pass
        return details

    def _extract_details(self, root_cmd, root_details, lines_after):
        consumed_lines = 0
        real_details = root_details
        if root_cmd == 'backing_file':
            # Replace it with the real backing file
            backing_match = self.BACKING_FILE_RE.match(root_details)
            if backing_match:
                real_details = backing_match.group(2).strip()
        elif root_cmd in ['virtual_size', 'cluster_size', 'disk_size']:
            # Replace it with the byte amount (if we can convert it)
            real_details = self._extract_bytes(root_details)
        elif root_cmd == 'file_format':
            real_details = real_details.strip().lower()
        elif root_cmd == 'snapshot_list':
            # Next line should be a header, starting with 'ID'
            if not lines_after or not lines_after[0].startswith("ID"):
                msg = _("Snapshot list encountered but no header found!")
                raise ValueError(msg)
            consumed_lines += 1
            possible_contents = lines_after[1:]
            real_details = []
            # This is the sprintf pattern we will try to match
            # "%-10s%-20s%7s%20s%15s"
            # ID TAG VM SIZE DATE VM CLOCK (current header)
            for line in possible_contents:
                line_pieces = line.split(None)
                if len(line_pieces) != 6:
                    break
                else:
                    # Check against this pattern occuring in the final position
                    # "%02d:%02d:%02d.%03d"
                    date_pieces = line_pieces[5].split(":")
                    if len(date_pieces) != 3:
                        break
                    real_details.append({
                        'id': line_pieces[0],
                        'tag': line_pieces[1],
                        'vm_size': line_pieces[2],
                        'date': line_pieces[3],
                        'vm_clock': line_pieces[4] + " " + line_pieces[5],
                    })
                    consumed_lines += 1
        return (real_details, consumed_lines)

    def _parse(self, cmd_output):
        # Analysis done of qemu-img.c to figure out what is going on here
        # Find all points start with some chars and then a ':' then a newline
        # and then handle the results of those 'top level' items in a separate
        # function.
        #
        # TODO(harlowja): newer versions might have a json output format
        #                 we should switch to that whenever possible.
        #                 see: http://bit.ly/XLJXDX
        if not cmd_output:
            cmd_output = ''
        contents = {}
        lines = cmd_output.splitlines()
        i = 0
        line_am = len(lines)
        while i < line_am:
            line = lines[i]
            if not line.strip():
                i += 1
                continue
            consumed_lines = 0
            top_level = self.TOP_LEVEL_RE.match(line)
            if top_level:
                root = self._canonicalize(top_level.group(1))
                if not root:
                    i += 1
                    continue
                root_details = top_level.group(2).strip()
                details, consumed_lines = self._extract_details(root,
                                                                root_details,
                                                                lines[i + 1:])
                contents[root] = details
            i += consumed_lines + 1
        return contents

def qemu_img_info(path):
    """Return a object containing the parsed output from qemu-img info."""
    out, err = utils.execute('env', 'LC_ALL=C', 'LANG=C',
                             'qemu-img', 'info', path,
                             run_as_root=True)
    return QemuImgInfo(out)

def convert_image(source, dest, out_format):
    """Convert image to other format"""
    cmd = ('qemu-img', 'convert', '-O', out_format, source, dest)
    utils.execute(*cmd, run_as_root=True)

def fetch(context, image_service, image_id, path, _user_id, _project_id):
    # TODO(vish): Improve context handling and add owner and auth data
    #             when it is added to glance.  Right now there is no
    #             auth checking in glance, so we assume that access was
    #             checked before we got here.
    with utils.remove_path_on_error(path):
        with open(path, "wb") as image_file:
            image_service.download(context, image_id, image_file)

def fetch_to_raw(context, image_service,
                 image_id, dest,
                 user_id=None, project_id=None):
    if (FLAGS.image_conversion_dir and not
            os.path.exists(FLAGS.image_conversion_dir)):
        os.makedirs(FLAGS.image_conversion_dir)

    # NOTE(avishay): I'm not crazy about creating temp files which may be
    # large and cause disk full errors which would confuse users.
    # Unfortunately it seems that you can't pipe to 'qemu-img convert' because
    # it seeks. Maybe we can think of something for a future version.
    fd, tmp = tempfile.mkstemp(dir=FLAGS.image_conversion_dir)
    os.close(fd)
    with utils.remove_path_on_error(tmp):
        fetch(context, image_service, image_id, tmp, user_id, project_id)

        data = qemu_img_info(tmp)
        fmt = data.file_format
        if fmt is None:
            raise exception.ImageUnacceptable(
                reason=_("'qemu-img info' parsing failed."),
                image_id=image_id)

        backing_file = data.backing_file
        if backing_file is not None:
            raise exception.ImageUnacceptable(
                image_id=image_id,
                reason=_("fmt=%(fmt)s backed by:"
                         "%(backing_file)s") % locals())

        # NOTE(jdg): I'm using qemu-img convert to write
        # to the volume regardless if it *needs* conversion or not
        # TODO(avishay): We can speed this up by checking if the image is raw
        # and if so, writing directly to the device. However, we need to keep
        # check via 'qemu-img info' that what we copied was in fact a raw
        # image and not a different format with a backing file, which may be
        # malicious.
        LOG.debug("%s was %s, converting to raw" % (image_id, fmt))
        convert_image(tmp, dest, 'raw')

        data = qemu_img_info(dest)
        if data.file_format != "raw":
            raise exception.ImageUnacceptable(
                image_id=image_id,
                reason=_("Converted to raw, but format is now %s") %
                data.file_format)
        os.unlink(tmp)

def upload_volume(context, image_service, image_meta, volume_path):
    image_id = image_meta['id']
    if (image_meta['disk_format'] == 'raw'):
        LOG.debug("%s was raw, no need to convert to %s" %
                  (image_id, image_meta['disk_format']))
        with utils.temporary_chown(volume_path):
            with utils.file_open(volume_path) as image_file:
                image_service.update(context, image_id, {}, image_file)
        return

    if (FLAGS.image_conversion_dir and not
            os.path.exists(FLAGS.image_conversion_dir)):
        os.makedirs(FLAGS.image_conversion_dir)

    fd, tmp = tempfile.mkstemp(dir=FLAGS.image_conversion_dir)
    os.close(fd)
    with utils.remove_path_on_error(tmp):
        LOG.debug("%s was raw, converting to %s" %
                  (image_id, image_meta['disk_format']))
        convert_image(volume_path, tmp, image_meta['disk_format'])

        data = qemu_img_info(tmp)
        if data.file_format != image_meta['disk_format']:
            raise exception.ImageUnacceptable(
                image_id=image_id,
                reason=_("Converted to %(f1)s, but format is now %(f2)s") %
                {'f1': image_meta['disk_format'], 'f2': data.file_format})

        with utils.file_open(tmp) as image_file:
            image_service.update(context, image_id, {}, image_file)
        os.unlink(tmp)


text:
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/top_arrow"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="@dimen/h02"
    android:background="@drawable/dot_design_popupmenu_arrow"
    android:gravity="center" />


text:
package org.osgi.impl.service.serial;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.serial.SerialDevice;
import org.osgi.service.serial.SerialEvent;
import org.osgi.service.serial.SerialEventListener;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;

public class SerialEventManager {
	private BundleContext	context;
	List<ServiceReference<SerialEventListener>>	list	= new LinkedList<>();

	public SerialEventManager(BundleContext context) {
		this.context = context;
		ServiceTracker<SerialEventListener,ServiceReference<SerialEventListener>> tracker = new ServiceTracker<>(
				context, SerialEventListener.class, new SerialCustomizer());
		tracker.open();
	}

	public void sendEvent(String id) {
		try {
			String serialDeviceFilter = "(service.id=" + id + ")";
			Collection<ServiceReference<SerialDevice>> serialDeviceRefs = context
					.getServiceReferences(SerialDevice.class,
							serialDeviceFilter);
			String comPort = (String) serialDeviceRefs.iterator()
					.next()
					.getProperty(SerialDevice.SERIAL_COMPORT);

			SerialEvent event = new SerialEventImpl(comPort, SerialEvent.DATA_AVAILABLE);
			for (int i = 0; i < list.size(); i++) {
				ServiceReference<SerialEventListener> ref = list.get(i);
				String filter = (String) ref.getProperty(SerialEventListener.SERIAL_COMPORT);
				if (filter == null) {
					SerialEventListener listener = context.getService(ref);
					listener.notifyEvent(event);
				} else if (filter.equals(comPort)) {
					SerialEventListener listener = context.getService(ref);
					listener.notifyEvent(event);
				}
			}

		} catch (InvalidSyntaxException e) {
			e.printStackTrace();
		}
	}

	private class SerialCustomizer implements
			ServiceTrackerCustomizer<SerialEventListener,ServiceReference<SerialEventListener>> {

		SerialCustomizer() {
			super();
		}
		@Override
		public ServiceReference<SerialEventListener> addingService(
				ServiceReference<SerialEventListener> reference) {
			list.add(reference);
			return reference;
		}

		@Override
		public void modifiedService(
				ServiceReference<SerialEventListener> reference,
				ServiceReference<SerialEventListener> service) {
			// empty
		}

		@Override
		public void removedService(
				ServiceReference<SerialEventListener> reference,
				ServiceReference<SerialEventListener> service) {
			list.remove(reference);
		}
	}
}


text:
<link rel="import" href="app://bower_components/iron-selector/iron-selector.html">
<link rel="import" href="app://bower_components/iron-input/iron-input.html">
<link rel="import" href="button/button.html">

<link rel="import" href="app-navbar.html">
<link rel="import" href="app-tabs.html">
<link rel="import" href="app-recent.html">
<link rel="import" href="app-new.html">
<link rel="import" href="app-help.html">

<dom-module id="app-main" >
    <link rel="import" type="css" href="styles/app-main.css">
    <template>

                    Fireball-Dashboard

                        <dashboard-button class="square" on-click="_onMinimize"></dashboard-button>
                        <dashboard-button class="square" disabled></dashboard-button>
                        <dashboard-button class="square" on-click="_onClose"></dashboard-button>

                <app-tabs id="appTabs" class="flex-1" on-select="_onSelect">

Recent Projects

New Project

Open Other ...

Help

                </app-tabs>
                <app-navbar class="flex-1 layout horizontal end-justified"></app-navbar>

                    <app-recent></app-recent>

                    <app-new id="appNew"></app-new>

                    <app-help></app-help>

{{projectPath}}

{{status}}

    </template>

</dom-module>


text:
<?php

if (!defined('PHPUnit_MAIN_METHOD')) {
    define('PHPUnit_MAIN_METHOD', 'Request2_AllTests::main');
}

require_once dirname(__FILE__) . '/CookieJarTest.php';
require_once dirname(__FILE__) . '/MultipartBodyTest.php';
require_once dirname(__FILE__) . '/ResponseTest.php';
require_once dirname(__FILE__) . '/Adapter/AllTests.php';

class Request2_AllTests
{
    public static function main()
    {
        if (!function_exists('phpunit_autoload')) {
            require_once 'PHPUnit/TextUI/TestRunner.php';
        }
        PHPUnit_TextUI_TestRunner::run(self::suite());
    }

    public static function suite()
    {
        $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2');

        $suite->addTestSuite('HTTP_Request2_CookieJarTest');
        $suite->addTestSuite('HTTP_Request2_MultipartBodyTest');
        $suite->addTestSuite('HTTP_Request2_ResponseTest');
        $suite->addTest(Request2_Adapter_AllTests::suite());

        return $suite;
    }
}

if (PHPUnit_MAIN_METHOD == 'Request2_AllTests::main') {
    Request2_AllTests::main();
}
?>


text:
name: app.js
language: javascript
---

```javascript
auth0.createAuth0Client({
  domain: "${account.namespace}",
  clientId: "${account.clientId}",
  authorizationParams: {
    redirect_uri: window.location.origin
  }
}).then(async (auth0Client) => {
  // Assumes a button with id "login" in the DOM
  const loginButton = document.getElementById("login");

  loginButton.addEventListener("click", (e) => {
    e.preventDefault();
    auth0Client.loginWithRedirect();
  });

  if (location.search.includes("state=") &&
      (location.search.includes("code=") ||
      location.search.includes("error="))) {
    await auth0Client.handleRedirectCallback();
    window.history.replaceState({}, document.title, "/");
  }

  // Assumes a button with id "logout" in the DOM
  const logoutButton = document.getElementById("logout");

  logoutButton.addEventListener("click", (e) => {
    e.preventDefault();
    auth0Client.logout();
  });

  const isAuthenticated = await auth0Client.isAuthenticated();
  const userProfile = await auth0Client.getUser();

  // Assumes an element with id "profile" in the DOM
  const profileElement = document.getElementById("profile");

  if (isAuthenticated) {
    profileElement.style.display = "block";
    profileElement.innerHTML = `
            <p><%= "${userProfile.name}" %></p>
            <img src="<%= "${userProfile.picture}" %>" />
          `;
  } else {
    profileElement.style.display = "none";
  }
});
```


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

namespace Mufasa.BackEnd.Designer
{
    /// <remarks>
    /// DNA fragment class.
    /// </remarks>
    public class Fragment
    {
        /// <value>
        /// Path to the file or url containing the fragment.
        /// </value>
        public String Source { get; set; }
        /// <summary>
        /// Name of the fragment.
        /// </summary>
        public String Name { get; set; }
        /// <summary>
        /// Fragment sequence.
        /// </summary>
        public ISequence Sequence { get; set; }
        /// <summary>
        /// Concentration.
        /// </summary>
        public double Concentration { get; set; }
        /// <summary>
        /// Length.
        /// </summary>
        public long Length { get; set; }

        /// <summary>
        /// True if this is a vector sequence.
        /// </summary>
        public bool IsVector { get; set; }

        /// <summary>
        /// Reaction volume.
        /// </summary>
        public double Volume { get; set; }
        /// <summary>
        /// Fragment constructor.
        /// </summary>
        /// <param name="source">Filename or URL.</param>
        /// <param name="name">Fragment name.</param>
        public Fragment(String source, String name, ISequence sequence, bool vector = false)
        {
            this.Source = source;
            this.Name = name;
            this.Sequence = sequence;
            this.Length = sequence.Count;
            this.IsVector = vector;
        }

        /// <summary>
        /// Fragment constructor.
        /// </summary>
        public Fragment()
        {
        }

        /// <summary>
        /// Copying Fragment constructor.
        /// </summary>
        public Fragment(Fragment frag)
        {
            this.Name = frag.Name;
            this.Sequence = new Sequence(frag.Sequence);
            this.Source = frag.Source;
        }

        /// <summary>
        /// Returns full fragment sequence as a string. Based on .NET Bio Programming Guide.
        /// </summary>
        /// <returns>Sequence string.</returns>
        public string GetString()
        {
            char[] symbols = new char[this.Sequence.Count];
            for (long index = 0; index < this.Sequence.Count; index++)
            {
                symbols[index] = (char)this.Sequence[index];
            }
            return new String(symbols);
        }

        /// <summary>
        /// Returns full fragment reverse complement sequence as a string.
        /// </summary>
        /// <returns>Reverse complement sequence string.</returns>
        public string GetReverseComplementString()
        {
            ISequence revComp = this.Sequence.GetReverseComplementedSequence();
            char[] symbols = new char[revComp.Count];
            for (long index = 0; index < revComp.Count; index++)
            {
                symbols[index] = (char)revComp[index];
            }
            return new String(symbols);
        }
    }
}


text:
<!--

FlexGen : Flexible Map Generator Library

Copyright (C) 2009-2014 Jeffrey J. Weston <jjweston@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.
* 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.
* Neither the name of the FlexGen project nor the names of its contributors
  may be used to endorse or promote products derived from this software
  without specific prior written permission.

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.

-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <groupId>org.flexgen</groupId>
    <artifactId>flexgen-root</artifactId>
    <version>1.1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>FlexGen Root</name>

    <distributionManagement>
        <repository>
            <id>flexgen-releases</id>
            <name>FlexGen Releases</name>
            <url>scp://ssh.phx.nearlyfreespeech.net/home/public/releases/</url>
        </repository>
        <snapshotRepository>
            <id>flexgen-snapshots</id>
            <name>FlexGen Snapshots</name>
            <url>scp://ssh.phx.nearlyfreespeech.net/home/public/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-ssh</artifactId>
                <version>2.5</version>
            </extension>
        </extensions>
    </build>

    <modules>
        <module>main</module>
        <module>example</module>
        <module>assembly</module>
    </modules>

    <profiles>
        <profile>
            <id>run.example.river</id>
            <build>
                <defaultGoal>package</defaultGoal>
            </build>
        </profile>

        <profile>
            <id>run.example.dungeon</id>
            <build>
                <defaultGoal>package</defaultGoal>
            </build>
        </profile>

        <profile>
            <id>checkstyle</id>
            <build>
                <defaultGoal>package</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <version>2.11</version>
                        <executions>
                            <execution>
                                <id>checkstyle</id>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                                <phase>validate</phase>
                                <configuration>
                                    <configLocation>checkstyle.xml</configLocation>
                                    <consoleOutput>true</consoleOutput>
                                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>distro</id>
            <build>
                <defaultGoal>package</defaultGoal>
            </build>
        </profile>
    </profiles>

</project>