text:
using Xunit;
using Pixills.Net.Http;
using System;

namespace Pixills.Consul.Client.UnitTests
{
    public class HttpConnection
    {
        private IHttpClient _client;

        public HttpConnection()
        {
            _client = new HttpClient();
            Environment.SetEnvironmentVariable("CONSUL_AGENT_PORT", "1337");
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithInvalidUrl_ShouldThrowException()
        {
            Assert.Throws<UriFormatException>(() =>
            {
                Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", "invalid url");
                new Consul.Client.HttpConnection(_client, true, 5);
            });
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithNullClient_ShouldThrowException()
        {
            Assert.Throws<ArgumentException>(() =>
            {
                Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", null);
                new Consul.Client.HttpConnection(null, true, 5);
            });
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithValidArgs_ShouldNotThrowException()
        {
            Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", "localhost");
            var con = new Consul.Client.HttpConnection(_client, true, 5);
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithLeastParameters_ShouldNotThrowException()
        {
            Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", "localhost");
            var con = new Consul.Client.HttpConnection(_client);
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithHostWithHttpPrefix_ShouldRemoveHttpPrefix()
        {
            Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", "http://localhost");
            var con = new Consul.Client.HttpConnection(_client);
            Assert.Equal(new Uri("http://localhost:1337/v1"), con.BaseAddress);
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithTlsFalse_ShouldAddHttpPrefix()
        {
            Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", "localhost");
            var con = new Consul.Client.HttpConnection(_client);
            Assert.Equal(new Uri("http://localhost:1337/v1"), con.BaseAddress);
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithTlsTrue_ShouldAddHttpsPrefix()
        {
            Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", "localhost");
            var con = new Consul.Client.HttpConnection(_client, true);
            Assert.Equal(new Uri("https://localhost:1337/v1"), con.BaseAddress);
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithTimeout0_ShouldNotAddTimeout()
        {
            Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", "localhost");
            var con = new Consul.Client.HttpConnection(_client, true, 0);
            Assert.Equal(0, (int)con.Timeout);
        }

        [Fact]
        public void HttpConnection_Constructor_CallWithTimeoutGreater0_ShouldAddTimeout()
        {
            Environment.SetEnvironmentVariable("CONSUL_AGENT_HOSTNAME", "localhost");
            var con = new Consul.Client.HttpConnection(_client, true, 5);
            Assert.Equal(5, (int)con.Timeout);
        }
    }
}


text:
INFORMATIONEN FÜR RECHTEINHABER

Wenn du der Urheber von material link (oder die links), die auf dieser Website verfügbar ist, und möchte nicht zur Verbreitung dieser Informationen von den Benutzern ohne Ihre Zustimmung werden wir glücklich sein zu helfen, Sie durch Entfernung der entsprechenden links.

Dies erfordert, dass Sie uns einen Brief (in elektronischer form)
welche zeigte Sie uns die folgenden Informationen:

1. Dokumentieren Sie Ihre Rechte, um urheberrechtlich geschütztes material:

 - gescannte Dokument mit dem Siegel oder

 - E-Mail von einer offiziellen e-mail-Domäne des Firmeninhabers, oder

 - andere Kontaktinformationen eindeutig identifiziert Sie als Eigentümer des Materials.

2. Der text, den Sie platzieren möchten, begleitet durch eine abnehmbare Informationen.

In ihm können Sie angeben, wo und unter welchen Bedingungen können Sie Informationen, Verweise auf die entfernt wurden, sowie Ihre Kontaktdaten, so dass Benutzer können erhalten von Ihnen alle erforderlichen Informationen in Bezug auf dieses material.

3. Direkte links zu Seiten enthalten Verweise auf Daten, die entfernt werden müssen.

Die Links Ansicht http://<?= $_SERVER['SERVER_NAME']?>/tXXXXX oder etwas ähnliches.

Nach 48 Stunden, entfernen wir Ihnen interessante links aus dem Ort.

Unsere E-Mail: <a href="mailto:<?= $bb_cfg['abuse_email']; ?>" class="gen"><?= $bb_cfg['abuse_email']; ?>

WARNUNG!

a) Wir behalten uns das Recht zur Veröffentlichung auf der Website alle Informationen, die Sie uns per E-mail <a href="mailto:<?= $bb_cfg['abuse_email']; ?>" class="gen"><?= $bb_cfg['abuse_email']; ?>

b) Wir haben keine Kontrolle über die Handlungen der Benutzer, die re-post-links zu Informationen, die das Objekt Ihrer Urheber. Alle Informationen, das forum, erfolgt automatisch, ohne Kontrolle von irgendeiner Seite auch immer, das entspricht der allgemein anerkannten internationalen Praxis der Platzierung von Informationen im Internet. Jedoch in jedem Fall betrachten wir alle Ihre Fragen in Bezug auf den Verweis auf die information, dass Ihre Rechte verletzt.

c) Nach dem Gesetz über Urheberrecht und Verwandte Schutzrechte, einen Verweis auf die Daten (Informationen, Nachrichten), von selbst, ist nicht Gegenstand des Urheberrechts (obwohl es kann eine Verletzung der "Vereinbarung über die Nutzung der website"). Somit ist es nicht notwendig zu senden, Briefe mit Drohungen oder Forderungen, als nicht einen wirklichen Grund.

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

    <title>Butter Test Suite [Observer]</title>
	  <link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">

    \

Butter API Test Suite [EventManagerWrapper]


text:
package io.bit3.jsass.adapter;

import io.bit3.jsass.type.SassBoolean;
import io.bit3.jsass.type.SassColor;
import io.bit3.jsass.type.SassNumber;
import io.bit3.jsass.type.SassString;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class NativeSassToJavaTest {
  private NativeTestAdapter adapter;

  @BeforeEach
  public void setUp() {
    adapter = new NativeTestAdapter();
  }

  @Test
  public void testSassPositiveNumberToJava() {
    Object object = adapter.testSassPositiveNumberToJava();
    assertTrue(object instanceof SassNumber);

    SassNumber sassNumber = (SassNumber) object;
    assertEquals(678.0, sassNumber.doubleValue());
    assertEquals("", sassNumber.getUnit());
  }

  @Test
  public void testSassNegativeNumberToJava() {
    Object object = adapter.testSassNegativeNumberToJava();
    assertTrue(object instanceof SassNumber);

    SassNumber sassNumber = (SassNumber) object;
    assertEquals(-429.0, sassNumber.doubleValue());
    assertEquals("", sassNumber.getUnit());
  }

  @Test
  public void testSassZeroNumberToJava() {
    Object object = adapter.testSassZeroNumberToJava();
    assertTrue(object instanceof SassNumber);

    SassNumber sassNumber = (SassNumber) object;
    assertEquals(.0, sassNumber.doubleValue());
    assertEquals("", sassNumber.getUnit());
  }

  @Test
  public void testSassPositiveNumberWithUnitToJava() {
    Object object = adapter.testSassPositiveNumberWithUnitToJava();
    assertTrue(object instanceof SassNumber);

    SassNumber sassNumber = (SassNumber) object;
    assertEquals(397.0, sassNumber.doubleValue());
    assertEquals("px", sassNumber.getUnit());
  }

  @Test
  public void testSassNegativeNumberWithUnitToJava() {
    Object object = adapter.testSassNegativeNumberWithUnitToJava();
    assertTrue(object instanceof SassNumber);

    SassNumber sassNumber = (SassNumber) object;
    assertEquals(-241.0, sassNumber.doubleValue());
    assertEquals("em", sassNumber.getUnit());
  }

  @Test
  public void testSassZeroNumberWithUnitToJava() {
    Object object = adapter.testSassZeroNumberWithUnitToJava();
    assertTrue(object instanceof SassNumber);

    SassNumber sassNumber = (SassNumber) object;
    assertEquals(.0, sassNumber.doubleValue());
    assertEquals("%", sassNumber.getUnit());
  }

  @Test
  public void testSassStringToJava() {
    Object object = adapter.testSassStringToJava();
    assertTrue(object instanceof SassString);

    SassString sassString = (SassString) object;
    assertEquals("Nullam vel sem", sassString.getValue());
    assertFalse(sassString.isQuoted());
  }

  @Test
  public void testSassQuotedStringToJava() {
    Object object = adapter.testSassQuotedStringToJava();
    assertTrue(object instanceof SassString);

    SassString sassString = (SassString) object;
    assertEquals("In ac felis", sassString.getValue());
    assertTrue(sassString.isQuoted());
  }

  @Test
  public void testSassTrueToJava() {
    Object object = adapter.testSassTrueToJava();
    assertTrue(object instanceof SassBoolean);

    SassBoolean sassBoolean = (SassBoolean) object;
    assertTrue(sassBoolean.getValue());
  }

  @Test
  public void testSassFalseToJava() {
    Object object = adapter.testSassFalseToJava();
    assertTrue(object instanceof SassBoolean);

    SassBoolean sassBoolean = (SassBoolean) object;
    assertFalse(sassBoolean.getValue());
  }

  @Test
  public void testSassRgbColorToJava() {
    Object object = adapter.testSassRgbColorToJava();
    assertTrue(object instanceof SassColor);

    SassColor sassColor = (SassColor) object;
    assertEquals(.74, sassColor.getRed());
    assertEquals(.32, sassColor.getGreen());
    assertEquals(.56, sassColor.getBlue());
    assertEquals(1.0, sassColor.getAlpha());
  }

  @Test
  public void testSassRgbaColorToJava() {
    Object object = adapter.testSassRgbaColorToJava();
    assertTrue(object instanceof SassColor);

    SassColor sassColor = (SassColor) object;
    assertEquals(.97, sassColor.getRed());
    assertEquals(.24, sassColor.getGreen());
    assertEquals(.48, sassColor.getBlue());
    assertEquals(.5, sassColor.getAlpha());
  }
}


text:
package com.sqisland.tutorial.recipes.data.local;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Luiz on 04/10/17.
 */

public class InMemoryFavorites implements Favorites {

    private Map<String, Boolean> mMap = new HashMap<>();

    @Override
    public boolean get(String id) {
        return mMap.get(id) != null;
    }

    @Override
    public boolean toggle(String id) {
        boolean value = !get(id);
        put(id, value);
        return value;
    }

    public void put(String id, boolean value){
        mMap.put(id, value);
    }

    public void clear() {
        mMap.clear();
    }
}


text:
FOUNDATION_EXPORT double Pods_WS_Connector_ExampleVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_WS_Connector_ExampleVersionString[];


text:
package x509

import "os"

func initSystemRoots() {
	// no system roots
}

func execSecurityRoots() (*CertPool, error) {
	return nil, os.ErrNotExist
}


text:
package com.intellij.codeInsight;

import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
import com.intellij.openapi.application.WriteAction;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiAnnotation;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;

public class MakeAnnotationExternal extends BaseIntentionAction {

  @Nls
  @NotNull
  @Override
  public String getFamilyName() {
    return "Annotate Externally";
  }

  @Override
  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
    PsiAnnotation annotation = PsiTreeUtil.getParentOfType(file.findElementAt(editor.getCaretModel().getOffset()), PsiAnnotation.class);

    if (annotation != null && annotation.getQualifiedName() != null &&
        annotation.getManager().isInProject(annotation)) {
      PsiModifierListOwner modifierListOwner = PsiTreeUtil.getParentOfType(annotation, PsiModifierListOwner.class);
      if (modifierListOwner != null && ExternalAnnotationsManagerImpl.areExternalAnnotationsApplicable(modifierListOwner)) {
        VirtualFile virtualFile = PsiUtilCore.getVirtualFile(modifierListOwner);
        if (JavaCodeStyleSettings.getInstance(file).USE_EXTERNAL_ANNOTATIONS ||
            virtualFile != null && ExternalAnnotationsManager.getInstance(project).hasAnnotationRootsForFile(virtualFile)) {
          setText("Annotate externally");
          return true;
        }
      }
    }
    return false;
  }

  @Override
  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    final PsiElement leaf = file.findElementAt(editor.getCaretModel().getOffset());
    PsiAnnotation annotation = PsiTreeUtil.getParentOfType(leaf, PsiAnnotation.class);
    assert annotation != null;

    final PsiModifierListOwner owner = PsiTreeUtil.getParentOfType(annotation, PsiModifierListOwner.class);
    assert owner != null;

    ExternalAnnotationsManager externalAnnotationsManager = ExternalAnnotationsManager.getInstance(project);

    if (!FileModificationService.getInstance().preparePsiElementsForWrite(MakeExternalAnnotationExplicit.getFilesToWrite(file, owner, externalAnnotationsManager))) return;

    String qualifiedName = annotation.getQualifiedName();
    assert qualifiedName != null;
    try {
      externalAnnotationsManager.annotateExternally(owner, qualifiedName, file, annotation.getParameterList().getAttributes());
    }
    catch (ExternalAnnotationsManager.CanceledConfigurationException e) {
      return;
    }

    WriteAction.run(annotation::delete);
  }

  @Override
  public boolean startInWriteAction() {
    return false;
  }
}


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

<TITLE>
Uses of Class edu.american.student.stonewall.display.Display
</TITLE>

<META NAME="date" CONTENT="2013-03-25">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style">

      Overview
      Package
      Class
    Use
      Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Uses of Class
edu.american.student.stonewall.display.Display

Packages that use Display

edu.american.student.stonewall

edu.american.student.stonewall.display.basic.component

edu.american.student.stonewall.display.basic.framework

edu.american.student.stonewall.display.custom

edu.american.student.stonewall.layout

Uses of Display in edu.american.student.stonewall

Methods in edu.american.student.stonewall that return types with arguments of type Display

 java.util.List<Display>
MyLayout.getDisplays()

 java.util.List<Display>
ExampleLayout.getDisplays()

Constructors in edu.american.student.stonewall with parameters of type Display

ExampleLayout(Display toGenerate,
              GistDisplay gist)

Uses of Display in edu.american.student.stonewall.display.basic.component

Subclasses of Display in edu.american.student.stonewall.display.basic.component

 class
BasicAddress

          The high level representation of the low level HTML element: address

 class
BasicAnchor

          The high level representation of the low level HTML element: anchor (Hypertext link)

 class
BasicArea

          The high level representation of the low level HTML element: Area

 class
BasicAudio

          The high level representation of the low level HTML element: audio

 class
BasicBlockQuote

          The high level representation of the low level HTML element: blockquote

 class
BasicBody

          The high level representation of the low level HTML element: body

 class
BasicButton

          The high level representation of the low level HTML element: button

 class
BasicCanvas

          The high level representation of the low level HTML element: canvas

 class
BasicCodeBlock

          The high level representation of the low level HTML element: code

 class
BasicDivision

          The high level representation of the low level HTML object: div

 class
BasicEmbed

          The high level representation of the low level HTML element : embed

 class
BasicGauge

          The high level representation of the low level HTML element: meter

 class
BasicHeading

          The high level representation of the low level HTML element: h#

 class
BasicImage

          The high level representation of the low level HTML element: img

 class
BasicImageNavigation

          The high level representation of several low level HTML elements that compose a navigation

 class
BasicInput

 class
BasicMap

          The high level representation of the low level HTML element: map

 class
BasicNavigation

          The high level representation of the low level HTML element: nav

 class
BasicParagraph

          The high level representation of the low level HTML element: p

Constructors in edu.american.student.stonewall.display.basic.component with parameters of type Display

BasicDivision(Display... displays)

Uses of Display in edu.american.student.stonewall.display.basic.framework

Subclasses of Display in edu.american.student.stonewall.display.basic.framework

 class
BasicDisplay

          The abstract parent of all displays in the 'basic' package.

 They are simply minimal abstractions on top of their low level HTML element counterparts.

Uses of Display in edu.american.student.stonewall.display.custom

Subclasses of Display in edu.american.student.stonewall.display.custom

 class
GistDisplay

Uses of Display in edu.american.student.stonewall.layout

Methods in edu.american.student.stonewall.layout that return types with arguments of type Display

abstract  java.util.List<Display>
Layout.getDisplays()

      Overview
      Package
      Class
    Use
      Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes


text:
#import "BasicMethod.h"
#import "Constants.h"
#import "DelegateMessenger.h"

@interface BasicMethod()
{
    NSMutableCharacterSet* _charSetForEncodeURLComponentString;
}

- (NSString *)encodeURLComponentString:(NSString *)urlStr encoding:(NSStringEncoding)encoding;

@end

@implementation BasicMethod

@synthesize requestTimeoutInterval;
@synthesize encoding;

-(id)init {
	self = [super init];

	if (self != nil) {
		//Initialize the dictionary used for storing parameters
		params = [[NSMutableDictionary alloc] init];
        self.encoding = NSUTF8StringEncoding;

        _charSetForEncodeURLComponentString = [[NSMutableCharacterSet alloc] init];
        [_charSetForEncodeURLComponentString formUnionWithCharacterSet:[NSCharacterSet alphanumericCharacterSet]];
        [_charSetForEncodeURLComponentString addCharactersInString:@"-._~"];
	}

	return self;
}

-(void)addParameter:(NSString*)paramData withName:(NSString*)paramName {
	//Add the parameter to the parameters dictionary
	[params setValue:paramData forKey:paramName];
}

-(void)addParametersFromDictionary:(NSDictionary*)dict {
	for (id key in dict) {
		[params setValue:[dict objectForKey:key] forKey:key];
	}
}

-(void)prepareMethod:(NSURL*)methodURL methodType:(NSString*)methodType dataInBody:(bool)dataInBody contentType:(NSString*)contentType withRequest:(NSMutableURLRequest*)request {
	//Set the destination URL
	[request setURL:methodURL];
	//Set the method type
	[request setHTTPMethod:methodType];
	//Set the content-type
	[request addValue:contentType forHTTPHeaderField:@"Content-Type"];

	//Create a data object to hold the body while we're creating it
	NSMutableData * body = [[NSMutableData alloc] init];

	//Loop over all the items in the parameters dictionary and add them to the body
	int cCount = 0;
	for (NSString* cKey in params) {
		cCount++;
		//If we've already added at least one data item, we need to add the & character between each new data item
		if (cCount > 1) {
			[body appendData:[@"&" dataUsingEncoding:encoding]];
		}

		//Add the parameter(No need encode in "POST" method)
        /*
        if(dataInBody)
        {
            [body appendData:[[NSString stringWithFormat:@"%@=%@", cKey, [params valueForKey:cKey]] dataUsingEncoding:encoding]];
        }
        else
            */
        {
            [body appendData:[[NSString stringWithFormat:@"%@=%@", cKey, [self encodeURLComponentString:[params valueForKey:cKey] encoding:encoding]] dataUsingEncoding:encoding]];
        }
	}

	//Add the body data in either the actual HTTP body or as part of the URL query
	if (dataInBody) { //For post methods, we add the parameters to the body
		[request setHTTPBody:body];
	} //For get methods, we have to add parameters to the url
	else {
		//Get a mutable string so that we can add the parameters to the end as query arguments
		NSMutableString * newURLString = [[NSMutableString alloc] initWithString:[methodURL absoluteString]];
		//Convert the body data into a string
		NSString * bodyString = [[NSString alloc] initWithData:body encoding:encoding];
		//Append the body data as a URL query
		[newURLString appendFormat:@"?%@", bodyString];
		//Create a new URL, escaping characters as necessary
        //Already encoded in adding parameters ---------
		//NSURL * newURL = [NSURL URLWithString:[newURLString stringByAddingPercentEscapesUsingEncoding:encoding]];
		NSURL * newURL = [NSURL URLWithString:newURLString];

#ifdef CLANG_OBJC_ARC_DISABLED
		[bodyString release];
		[newURLString release];
#else
        bodyString = nil;
        newURLString = nil;
#endif
		//Set the url request's url to be this new URL with the query appended
		[request setURL:newURL];
	}

#ifdef CLANG_OBJC_ARC_DISABLED
	[body release];
#else
    body = nil;
#endif
}

-(HttpResponse*)executeMethodSynchronously:(NSURL*)methodURL methodType:(NSString*)methodType dataInBody:(bool)dataInBody contentType:(NSString*)contentType {

	//Create a new URL request object
	NSMutableURLRequest * request = [[NSMutableURLRequest alloc] init];

    if(requestTimeoutInterval > 0)
    {
        [request setTimeoutInterval:requestTimeoutInterval];
    }

	[self prepareMethod:methodURL methodType:methodType dataInBody:dataInBody contentType:contentType withRequest:request];

	//Execute the HTTP method, saving the return data
	NSHTTPURLResponse * response;
    NSError* error;
	NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

	HttpResponse * responseObject = [[HttpResponse alloc] initWithHttpURLResponse:response withData:returnData];

#ifdef CLANG_OBJC_ARC_DISABLED
	return [responseObject autorelease];
#else
    return responseObject;
#endif

}

-(void)executeMethodAsynchronously:(NSURL*)methodURL methodType:(NSString*)methodType dataInBody:(bool)dataInBody contentType:(NSString*)contentType withDelegate:(id<HttpClientDelegate,NSObject>)delegate {
	NSMutableURLRequest * request = [[NSMutableURLRequest alloc] init];

    if(requestTimeoutInterval > 0)
    {
        [request setTimeoutInterval:requestTimeoutInterval];
    }

	[self prepareMethod:methodURL methodType:methodType dataInBody:dataInBody contentType:contentType withRequest:request];

	//Execute the HTTP method
	DelegateMessenger * messenger = [DelegateMessenger delegateMessengerWithDelegate:delegate];

	[NSURLConnection connectionWithRequest:request delegate:messenger];
}

/*
+ (NSString *)encodeURLString:(NSString *)urlStr encoding:(CFStringEncoding)encoding
{
    // Encode all the reserved characters, per RFC 3986
    // (<http://www.ietf.org/rfc/rfc3986.txt>)
    CFStringRef escaped = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                                  (CFStringRef)urlStr,
                                                                  NULL,
                                                                  (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                                  encoding);
    NSString* encodedStr = (__bridge_transfer NSString*) escaped;
#ifdef CLANG_OBJC_ARC_DISABLED
	return [encodedStr autorelease];
#else
    return encodedStr;
#endif
}
*/
- (NSString *)encodeURLComponentString:(NSString *)urlStr encoding:(NSStringEncoding)encoding
{
    // Encode all the reserved characters, per RFC 3986
    // (<http://www.ietf.org/rfc/rfc3986.txt>)
    //NSString* encodedStr =  [[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"] ;
    NSString* encodedStr = [urlStr stringByAddingPercentEncodingWithAllowedCharacters:_charSetForEncodeURLComponentString];
#ifdef CLANG_OBJC_ARC_DISABLED
	return [encodedStr autorelease];
#else
    return encodedStr;
#endif
}

@end


text:
import random
import time

from oslo_config import cfg

from rally.benchmark.scenarios import base
from rally.benchmark import utils as bench_utils
from rally import exceptions

MANILA_BENCHMARK_OPTS = [
    cfg.FloatOpt(
        "manila_share_create_prepoll_delay",
        default=2.0,
        help="Delay between creating Manila share and polling for its "
             "status."),
    cfg.FloatOpt(
        "manila_share_create_timeout",
        default=300.0,
        help="Timeout for Manila share creation."),
    cfg.FloatOpt(
        "manila_share_create_poll_interval",
        default=3.0,
        help="Interval between checks when waiting for Manila share "
             "creation."),
    cfg.FloatOpt(
        "manila_share_delete_timeout",
        default=180.0,
        help="Timeout for Manila share deletion."),
    cfg.FloatOpt(
        "manila_share_delete_poll_interval",
        default=2.0,
        help="Interval between checks when waiting for Manila share "
             "deletion."),
]

CONF = cfg.CONF
benchmark_group = cfg.OptGroup(name="benchmark", title="benchmark options")
CONF.register_opts(MANILA_BENCHMARK_OPTS, group=benchmark_group)

class ManilaScenario(base.Scenario):
    """Base class for Manila scenarios with basic atomic actions."""

    @base.atomic_action_timer("manila.create_share")
    def _create_share(self, share_proto, size=1, **kwargs):
        """Create a share.

        :param share_proto: share protocol for new share,
            available values are NFS, CIFS, GlusterFS and HDFS.
        :param size: size of a share in GB
        :param snapshot_id: ID of the snapshot
        :param name: name of new share
        :param description: description of a share
        :param metadata: optional metadata to set on share creation
        :param share_network: either instance of ShareNetwork or str with ID
        :param share_type: either instance of ShareType or str with ID
        :param is_public: defines whether to set share as public or not.
        :returns: instance of :class:`Share`
        """
        if (self.context and
                self.context.get("tenant", {}).get("share_networks", []) and
                not kwargs.get("share_network")):
            kwargs["share_network"] = next(self.context.get("tenant", {}).get(
                "sn_iterator"))

        if not kwargs.get("name"):
            kwargs["name"] = self._generate_random_name()

        share = self.clients("manila").shares.create(
            share_proto, size, **kwargs)
        time.sleep(CONF.benchmark.manila_share_create_prepoll_delay)
        share = bench_utils.wait_for(
            share,
            is_ready=bench_utils.resource_is("available"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.manila_share_create_timeout,
            check_interval=CONF.benchmark.manila_share_create_poll_interval,
        )
        return share

    @base.atomic_action_timer("manila.delete_share")
    def _delete_share(self, share):
        """Delete the given share.

        :param share: :class:`Share`
        """
        share.delete()
        error_statuses = ("error_deleting", )
        bench_utils.wait_for_delete(
            share,
            update_resource=bench_utils.get_from_manager(error_statuses),
            timeout=CONF.benchmark.manila_share_delete_timeout,
            check_interval=CONF.benchmark.manila_share_delete_poll_interval)

    @base.atomic_action_timer("manila.list_shares")
    def _list_shares(self, detailed=True, search_opts=None):
        """Returns user shares list.

        :param detailed: defines either to return detailed list of
            objects or not.
        :param search_opts: container of search opts such as
            "name", "host", "share_type", etc.
        """
        return self.clients("manila").shares.list(
            detailed=detailed, search_opts=search_opts)

    @base.atomic_action_timer("manila.set_metadata")
    def _set_metadata(self, share, sets=1, set_size=1,
                      key_min_length=1, key_max_length=255,
                      value_min_length=1, value_max_length=1023):
        """Sets share metadata.

        :param share: the share to set metadata on
        :param sets: how many operations to perform
        :param set_size: number of metadata keys to set in each operation
        :param key_min_length: minimal size of metadata key to set
        :param key_max_length: maximum size of metadata key to set
        :param value_min_length: minimal size of metadata value to set
        :param value_max_length: maximum size of metadata value to set
        :returns: A list of keys that were set
        """
        if not (key_min_length <= key_max_length and
                value_min_length <= value_max_length):
            raise exceptions.InvalidArgumentsException(
                "Min length for keys and values of metadata can not be bigger "
                "than maximum length.")
        elif key_min_length not in range(1, 256):
            raise exceptions.InvalidArgumentsException(
                "key_min_length '%s' is not in range(1, 256)" % key_min_length)
        elif key_max_length not in range(1, 256):
            raise exceptions.InvalidArgumentsException(
                "key_max_length '%s' is not in range(1, 256)" % key_max_length)
        elif value_min_length not in range(1, 1024):
            raise exceptions.InvalidArgumentsException(
                "value_min_length '%s' is not in range(1, 1024)" %
                value_min_length)
        elif value_max_length not in range(1, 1024):
            raise exceptions.InvalidArgumentsException(
                "value_max_length '%s' is not in range(1, 1024)" %
                value_max_length)

        keys = []
        for i in range(sets):
            metadata = {}
            for j in range(set_size):
                if key_min_length == key_max_length:
                    key_length = key_min_length
                else:
                    key_length = random.choice(
                        range(key_min_length, key_max_length))
                if value_min_length == value_max_length:
                    value_length = value_min_length
                else:
                    value_length = random.choice(
                        range(value_min_length, value_max_length))
                key = self._generate_random_name(prefix="", length=key_length)
                keys.append(key)
                metadata[key] = self._generate_random_name(
                    prefix="", length=value_length)
            self.clients("manila").shares.set_metadata(share, metadata)

        return keys

    @base.atomic_action_timer("manila.delete_metadata")
    def _delete_metadata(self, share, keys, deletes=10, delete_size=3):
        """Deletes share metadata.

        :param share: The share to delete metadata from
        :param deletes: how many operations to perform
        :param delete_size: number of metadata keys to delete in each operation
        :param keys: a list of keys to choose deletion candidates from
        """
        if not keys:
            raise exceptions.InvalidArgumentsException(
                "Param 'keys' should be list with values. keys = '%s'" % keys)
        elif len(keys) < deletes * delete_size:
            raise exceptions.InvalidArgumentsException(
                "Not enough metadata keys to delete: "
                "%(num_keys)s keys, but asked to delete %(num_deletes)s" %
                {"num_keys": len(keys), "num_deletes": deletes * delete_size})
        for i in range(deletes):
            to_del = keys[i * delete_size:(i + 1) * delete_size]
            self.clients("manila").shares.delete_metadata(share, to_del)

    @base.atomic_action_timer("manila.create_share_network")
    def _create_share_network(self, neutron_net_id=None,
                              neutron_subnet_id=None,
                              nova_net_id=None, name=None, description=None):
        """Create share network.

        :param neutron_net_id: ID of Neutron network
        :param neutron_subnet_id: ID of Neutron subnet
        :param nova_net_id: ID of Nova network
        :param name: share network name
        :param description: share network description
        :returns: instance of :class:`ShareNetwork`
        """
        share_network = self.clients("manila").share_networks.create(
            neutron_net_id=neutron_net_id,
            neutron_subnet_id=neutron_subnet_id,
            nova_net_id=nova_net_id,
            name=name,
            description=description)
        return share_network

    @base.atomic_action_timer("manila.delete_share_network")
    def _delete_share_network(self, share_network):
        """Delete share network.

        :param share_network: instance of :class:`ShareNetwork`.
        """
        share_network.delete()
        bench_utils.wait_for_delete(
            share_network,
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.manila_share_delete_timeout,
            check_interval=CONF.benchmark.manila_share_delete_poll_interval)

    @base.atomic_action_timer("manila.list_share_networks")
    def _list_share_networks(self, detailed=True, search_opts=None):
        """List share networks.

        :param detailed: defines either to return detailed list of
            objects or not.
        :param search_opts: container of search opts such as
            "project_id" and "name".
        :returns: list of instances of :class:`ShareNetwork`
        """
        share_networks = self.clients("manila").share_networks.list(
            detailed=detailed, search_opts=search_opts)
        return share_networks

    @base.atomic_action_timer("manila.list_share_servers")
    def _list_share_servers(self, search_opts=None):
        """List share servers. Admin only.

        :param search_opts: set of key-value pairs to filter share servers by.
            Example: {"share_network": "share_network_name_or_id"}
        :returns: list of instances of :class:`ShareServer`
        """
        share_servers = self.clients("manila").share_servers.list(
            search_opts=search_opts)
        return share_servers

    @base.atomic_action_timer("manila.create_security_service")
    def _create_security_service(self, type, dns_ip=None, server=None,
                                 domain=None, user=None, password=None,
                                 name=None, description=None):
        """Create security service.

        'Security service' is data container in Manila that stores info
        about auth services 'Active Directory', 'Kerberos' and catalog
        service 'LDAP' that should be used for shares.

        :param type: security service type, permitted values are
            'ldap', 'kerberos' or 'active_directory'.
        :param dns_ip: dns ip address used inside tenant's network
        :param server: security service server ip address or hostname
        :param domain: security service domain
        :param user: security identifier used by tenant
        :param password: password used by user
        :param name: security service name
        :param description: security service description
        :returns: instance of :class:`SecurityService`
        """
        security_service = self.clients("manila").security_services.create(
            type=type,
            dns_ip=dns_ip,
            server=server,
            domain=domain,
            user=user,
            password=password,
            name=name,
            description=description)
        return security_service

    @base.atomic_action_timer("manila.delete_security_service")
    def _delete_security_service(self, security_service):
        """Delete security service.

        :param security_service: instance of :class:`SecurityService`.
        """
        security_service.delete()
        bench_utils.wait_for_delete(
            security_service,
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.manila_share_delete_timeout,
            check_interval=CONF.benchmark.manila_share_delete_poll_interval)

    @base.atomic_action_timer("manila.add_security_service_to_share_network")
    def _add_security_service_to_share_network(self, share_network,
                                               security_service):
        """Associate given security service with a share network.

        :param share_network: ID or instance of :class:`ShareNetwork`.
        :param security_service: ID or instance of :class:`SecurityService`.
        :returns: instance of :class:`ShareNetwork`.
        """
        share_network = self.clients(
            "manila").share_networks.add_security_service(
                share_network, security_service)
        return share_network


text:
Разбирает адресную строку, отмечает выбранные и присваивает value для элементов формы на основе полученных GET параметров.

###Элементы для парсинга
`Плагин работает со следующими элементами:`
 - input[type="text"]
 - input[type="color"]
 - input[type="date"]
 - input[type="hidden"]
 - input[type="datetime"]
 - input[type="datetime-local"]
 - input[type="email"]
 - input[type="number"]
 - input[type="range"]
 - input[type="search"]
 - input[type="tel"]
 - input[type="time"]
 - input[type="url"]
 - input[type="month"]
 - input[type="week"]
 - input[type="radio"]
 - input[type="checkbox"]
 - select
 - textarea

###Параметры

      Имя
      Значение по умолчанию
	  Описание

      ignoreClass
      'no_parsing_get'
	  При добавлении к элементу стандартного или переопределенного пользовательского класса, элемент не будет обработан

      show
      true
	  В разработке

###Демонстрация
m-ulyanov.github.io/parsing-get/demo.html


text:
<?php
$TRANSLATIONS = array(
"Version not found" => "Версията не е открита.",
"Upgrade is not possible. Your web server does not have permission to remove the following directory:" => "Обновяването не е възможно. Уеб сървърът няма права да премахне следната папка:",
"Update permissions on this directory and its content or remove it manually first." => "Първо обнови правата на тази папка и съдържанието й или я изтрий.",
"Update failed." => "Неуспешно обновяване.",
"The update was unsuccessful. Please check logs at admin page and report this issue to the ownCloud community." => "Обновяването е неуспешно. Моля, провери записите в доклада в страницата за управление и докладвайте проблема в ownCloud общността.",
"Server error. Please check web server log file for details" => "Сървърна грешка. Моля, провери лог файловете за повече информация",
"Retry" => "Опитай Отново",
"Here is your backup:" => "Тук е Вашия архив:",
"Proceed" => "Продължи",
"All done. Click to the link below to start database upgrade." => "Готово. Натисни връзката по-долу за обновяване на базата от данни.",
"Please ask your server administrator to enable PHP zip extension." => "Моля, поискай твоят администратор да разреши PHP zip разширения.",
"Not possible to update %s to %s. Downgrading or skipping major releases is not supported." => "Не е възможна да се обнови %s до %s. Обновяване до по-стара версия или прескачането на главна версия не се поддържа.",
"Make sure that your web server has read access to the following files and directories:" => "Увери се, че твоят уеб сървър има достъп за четене до следните файлове и директории:",
"Make sure that your web server has write access to the following files and directories:" => "Увери се, че твоят уеб сървър има права за запис до следните файлове и директории:",
"Updater" => "Обновяване",
"Open Update Center" => "Отвори Център за Обновления.",
"Updates" => "Обновления",
"A new version is available: %s" => "Има Нова Версия: %s",
"Up to date. Checked on %s" => "Най-нова версия. Проверен на %s",
"1. Check & Backup" => "1. Превери & Направи резервен архив",
"2. Download & Extract" => "2. Изтегли & Извлечи от файла",
"3. Replace" => "3. Замени",
"Update" => "Обновяване",
"Backups" => "Резервни Архиви",
"Backup directory" => "Папка за Архиви",
"No backups found" => "Не са открити архиви",
"Backup" => "Архивиране",
"Done on" => "Извършено върху",
"Download" => "Изтегли",
"Delete" => "Изтрий"
);
$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";


text:
Main Page

	<button id='updateButton'>Update Status</button>


text:
import { UIBaseInput } from "./ui-input";
export declare class UITextarea extends UIBaseInput {
    element: Element;
    constructor(element: Element);
    bind(bindingContext: Object, overrideContext: Object): void;
    attached(): void;
    detached(): void;
    value: string;
    dir: string;
    rows: number;
    errors: any;
    maxlength: number;
    disabled: boolean;
    readonly: boolean;
    placeholder: string;
    autoComplete: string;
    info: string;
    beforeReplace: any;
    private clear;
    private counter;
    private ignore;
    private tether;
    private obMouseup;
    private dropdown;
    private acList;
    private acShow;
    valueChanged(newValue: any): void;
    autoCompleteChanged(newValue: any): void;
    hilightItem(evt: any): void;
    checkList(evt: any): boolean;
    checkInput(evt: any): boolean;
    replace(selected: any): void;
    closeAutoComplete(): void;
    properties: string[];
    isBrowser: boolean;
    isFirefox: boolean;
    getCaretCoordinates(): {
        top: string;
        left: string;
    };
}


text:
require 'haml'
require 'haml/html'

module Rack
  class Markup

    def initialize(app, options={})
      @app = app
    end

    def call(env)
      if env["REQUEST_PATH"] == "/api/markup/to_html"
        # [404,{'Content-Type' => 'text/plain'},'not found']
        call_method('_to_html', env)
      elsif env["REQUEST_PATH"] == "/api/markup/from_html"
        call_method('_from_html', env)
      elsif env["REQUEST_PATH"] == "/api/markup/get"
        render_file(env)
      else
        @app.call(env)
      end
    end

    protected

    def render_file(env)
      file = ::Rack::Request.new(env).params['file']
      text = ::File.open(::File.join(Dir.pwd, 'source/textareas', file)).read
      [200,{'Content-Type' => 'text/plain'}, text]
    rescue => e
      p e, e.message
      [500,{'Content-Type' => 'text/plain'},'no valid markup type']
    end

    def call_method(method_part, env)
      params = ::Rack::Request.new(env).params
      return_string = self.send(params['type'] + method_part, params['content'])
      [200,{'Content-Type' => 'text/plain'}, return_string]
    rescue => e
      p e, e.message, params['content']
      [500,{'Content-Type' => 'text/plain'},'no valid markup type']
    end

    def haml_to_html(string)
      Haml::Engine.new(string, :ugly => true).render
    end

    def haml_from_html(string)
      Haml::HTML.new(string).render
    end

  end
end


text:
package com.object;

/**
 * Created by SamMFFL on 2016/4/18.
 */
public class Telephone {
    private float screen;
    private float cpu;
    private float mem;

    public Telephone() {
        System.out.println("无参构造函数方法执行了!");
    }

    public Telephone(float newScreen, float newCpu, float newMem) {
        this.screen = newScreen;
        this.cpu = newCpu;
        this.mem = newMem;
        System.out.println("有参构造函数方法执行了!");
    }

    public float getScreen() {
        return screen;
    }

    public void setScreen(float screen) {
        this.screen = screen;
    }

    public float getCpu() {
        return cpu;
    }

    public void setCpu(float cpu) {
        this.cpu = cpu;
    }

    public float getMem() {
        return mem;
    }

    public void setMem(float mem) {
        this.mem = mem;
    }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LaunchAtlanta.FaceSwap.Web.Models
{
    public static class Constants
    {
        public const string LocalTempDirectory = @"c:\tmp\";
        public const string Key = "lkjasd234xcv2k3n8lsqvnoiqac==";
    }
}


text:
using NUnit.Framework;
using Markdig.Helpers;

namespace Markdig.Tests
{
    /// <summary>
    /// Test for <see cref="LineReader"/>.
    /// </summary>
    [TestFixture]
    public class TestLineReader
    {
        [Test]
        public void TestEmpty()
        {
            var lineReader = new LineReader("");
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestLinesOnlyLf()
        {
            var lineReader = new LineReader("\n\n\n");
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.AreEqual(1, lineReader.SourcePosition);
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.AreEqual(2, lineReader.SourcePosition);
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestLinesOnlyCr()
        {
            var lineReader = new LineReader("\r\r\r");
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.AreEqual(1, lineReader.SourcePosition);
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.AreEqual(2, lineReader.SourcePosition);
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestLinesOnlyCrLf()
        {
            var lineReader = new LineReader("\r\n\r\n\r\n");
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.AreEqual(2, lineReader.SourcePosition);
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.AreEqual(4, lineReader.SourcePosition);
            Assert.AreEqual(string.Empty, lineReader.ReadLine().ToString());
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestNoEndOfLine()
        {
            var lineReader = new LineReader("123");
            Assert.AreEqual("123", lineReader.ReadLine().ToString());
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestLf()
        {
            var lineReader = new LineReader("123\n");
            Assert.AreEqual("123", lineReader.ReadLine().ToString());
            Assert.AreEqual(4, lineReader.SourcePosition);
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestLf2()
        {
            // When limited == true, we limit the internal buffer exactly after the first new line char '\n'
            var lineReader = new LineReader("123\n456");
            Assert.AreEqual("123", lineReader.ReadLine().ToString());
            Assert.AreEqual(4, lineReader.SourcePosition);
            Assert.AreEqual("456", lineReader.ReadLine().ToString());
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestCr()
        {
            var lineReader = new LineReader("123\r");
            Assert.AreEqual("123", lineReader.ReadLine().ToString());
            Assert.AreEqual(4, lineReader.SourcePosition);
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestCr2()
        {
            var lineReader = new LineReader("123\r456");
            Assert.AreEqual("123", lineReader.ReadLine().ToString());
            Assert.AreEqual(4, lineReader.SourcePosition);
            Assert.AreEqual("456", lineReader.ReadLine().ToString());
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestCrLf()
        {
            // When limited == true, we limit the internal buffer exactly after the first new line char '\r'
            // and we check that we don't get a new line for `\n`
            var lineReader = new LineReader("123\r\n");
            Assert.AreEqual("123", lineReader.ReadLine().ToString());
            Assert.AreEqual(5, lineReader.SourcePosition);
            Assert.Null(lineReader.ReadLine().Text);
        }

        [Test]
        public void TestCrLf2()
        {
            var lineReader = new LineReader("123\r\n456");
            Assert.AreEqual("123", lineReader.ReadLine().ToString());
            Assert.AreEqual(5, lineReader.SourcePosition);
            Assert.AreEqual("456", lineReader.ReadLine().ToString());
            Assert.Null(lineReader.ReadLine().Text);
        }
    }
}


text:
(function() {
    /**
     * Arc constructor
     * @constructor
     * @augments Kinetic.Shape
     * @param {Object} config
     * @param {Number} config.angle in degrees
     * @param {Number} config.innerRadius
     * @param {Number} config.outerRadius
     * @param {Boolean} [config.clockwise]
     * @@shapeParams
     * @@nodeParams
     * @example
     * // draw a Arc that's pointing downwards

     * var arc = new Kinetic.Arc({

     *   innerRadius: 40,

     *   outerRadius: 80,

     *   fill: 'red',

     *   stroke: 'black'

     *   strokeWidth: 5,

     *   angle: 60,

     *   rotationDeg: -120

     * });
     */
    Kinetic.Arc = function(config) {
        this.___init(config);
    };

    Kinetic.Arc.prototype = {
        ___init: function(config) {
            // call super constructor
            Kinetic.Shape.call(this, config);
            this.className = 'Arc';
            this.sceneFunc(this._sceneFunc);
        },
        _sceneFunc: function(context) {
            var angle = this.angle() * Math.PI / 180,
                clockwise = this.clockwise();

            context.beginPath();
            context.arc(0, 0, this.getOuterRadius(), 0, angle, clockwise);
            context.arc(0, 0, this.getInnerRadius(), angle, 0, !clockwise);
            context.closePath();
            context.fillStrokeShape(this);
        }
    };
    Kinetic.Util.extend(Kinetic.Arc, Kinetic.Shape);

    // add getters setters
    Kinetic.Factory.addGetterSetter(Kinetic.Arc, 'innerRadius', 0);

    /**
     * get/set innerRadius
     * @name innerRadius
     * @method
     * @memberof Kinetic.Arc.prototype
     * @param {Number} innerRadius
     * @returns {Number}
     * @example
     * // get inner radius
     * var innerRadius = arc.innerRadius();
     *
     * // set inner radius
     * arc.innerRadius(20);
     */

    Kinetic.Factory.addGetterSetter(Kinetic.Arc, 'outerRadius', 0);

    /**
     * get/set outerRadius
     * @name outerRadius
     * @method
     * @memberof Kinetic.Arc.prototype
     * @param {Number} outerRadius
     * @returns {Number}
     * @example
     * // get outer radius

     * var outerRadius = arc.outerRadius();

     *
     * // set outer radius

     * arc.outerRadius(20);
     */

    Kinetic.Factory.addGetterSetter(Kinetic.Arc, 'angle', 0);

    /**
     * get/set angle in degrees
     * @name angle
     * @method
     * @memberof Kinetic.Arc.prototype
     * @param {Number} angle
     * @returns {Number}
     * @example
     * // get angle

     * var angle = arc.angle();

     *
     * // set angle

     * arc.angle(20);
     */

    Kinetic.Factory.addGetterSetter(Kinetic.Arc, 'clockwise', false);

    /**
     * get/set clockwise flag
     * @name clockwise
     * @method
     * @memberof Kinetic.Arc.prototype
     * @param {Number} clockwise
     * @returns {Number}
     * @example
     * // get clockwise flag

     * var clockwise = arc.clockwise();

     *
     * // draw arc counter-clockwise

     * arc.clockwise(false);

     *
     * // draw arc clockwise

     * arc.clockwise(true);
     */

     Kinetic.Collection.mapMethods(Kinetic.Arc);
})();


text:
var es = require('elasticsearch');
var _  = require('lodash');

/**
 * # Search
 */

/**
 * Search the model based off of a elasticsearch Query string
 * @param  {String}   query   based of elasitcsarch query string
 * @param  {Object}   options Options for the es call
 * @param  {Function} callback  Optional callback
 * @return {Promise}       Returns a promise unless there is a callback
 */
exports.searchQuery = function (query, opt, cb) {
  var params = _.merge({
    index: this.index,
    type: this.type,
    q: query
  }, opt);

  return this
    .connection
    .search(params, cb);
}

/**
 * Search the model based of a elasticsearch body object
 * @param  {Object}   body object with more search options
 * @param  {Object}   options Options for the es call
 * @param  {Function} callback  Optional callback
 * @return {Promise}       Returns a promise unless there is a callback
 */
exports.searchBody = function (body, opt, cb) {
  var params = _.merge({
    index: this.index,
    type: this.type,
    body: body
  }, opt);

  return this
    .connection
    .search(params, cb);
}

/**
 * Get document by document Id
 * @param  {String|Number|ElasitcsearchId}   id  document id
 * @param  {Object}   options Options for the es call
 * @param  {Function} callback  Optional callback
 * @return {Promise}       Returns a promise unless there is a callback
 */
exports.get = function (id, opt, cb) {
  if (!opt) opt = {};

  return this
    .connection
    .get(_.merge(
      {
        index: this.index,
        type: this.type,
        id: id
      }, opt),
      cb
    );
}


text:
development_standards
=====================

A collection of organizational best practices. This will likely be an empty repository with a wiki, but I can imagine adding dotfiles and IDE settings at some point.


text:
"""
    Format RAIS data for DB entry
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Columns:
    0 Municipality_ID
    1 EconmicAtivity_ID_ISIC
    2 EconomicActivity_ID_CNAE
    3 BrazilianOcupation_ID
    4 AverageMonthlyWage
    5 WageReceived
    6 Employee_ID
    7 Establishment_ID
    8 Year

    Example Usage
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    python scripts/rais/format_raw_data.py data/rais/Rais_2002.csv.bz2 -y 2002 -o data/rais/2002
    or
    python scripts/rais/format_raw_data.py data/rais/Rais_2003.csv.bz2 -y 2003 -o data/rais/2003 -g -o data/rais/2002
    or
    python scripts/rais/format_raw_data.py data/rais/Rais_2007.csv.bz2 -y 2007 -o data/rais/2007 -g -o data/rais/2006 -g5 -o data/rais/2002
    or (for debugging)
    %run -b scripts/rais/_required.py:87 -d scripts/rais/format_raw_data.py data/rais/Rais_2002.csv.bz2 -y 2002 -o data/rais/2002

"""

''' Import statements '''
import os, sys, time, bz2, click, fnmatch
import pandas as pd
import pandas.io.sql as sql
import numpy as np

from _to_df import to_df
from _aggregate import aggregate, aggregate_demographics
from _required import required
from _importance import importance
from _calc_diversity import calc_diversity
from _rdo import rdo
from _growth import calc_growth
from _column_lengths import add_column_length
# from _mne import mne

def findFiles (path, filter):
    for root, dirs, files in os.walk(path):
        for file in fnmatch.filter(files, filter):
            yield os.path.join(root, file)

@click.command()
@click.argument('file_path', type=click.Path(), required=False)
@click.option('-y', '--year', prompt='Year', help='year of the data to convert', required=True)
@click.option('output_path', '--output', '-o', help='Path to save files to.', type=click.Path(), required=True, prompt="Output path")
@click.option('prev_path', '--prev', '-g', help='Path to files from the previous year for calculating growth.', type=click.Path(exists=True), required=False)
@click.option('prev5_path', '--prev5', '-g5', help='Path to files from 5 years ago for calculating growth.', type=click.Path(exists=True), required=False)
@click.option('requireds_only', '--ro', '-ro', help='Only perform required operation.', is_flag=True, default=False, required=False)
def main(file_path, year, output_path, prev_path, prev5_path, requireds_only):

    print; print "~~~**** YEAR: {0} ****~~~".format(year); print;
    start = time.time()
    step = 0
    # regions state, meso, micro, planning region, munic
    depths = {
        "bra": [1, 3, 5, 7, 8, 9],
        "cnae": [1, 3, 6],
        "cbo": [1, 4],
        "demo": [1, 4]
    }

    if file_path:
        if not os.path.exists(output_path): os.makedirs(output_path)
        d = pd.HDFStore(os.path.join(output_path, 'rais_df_raw.h5'))
        if "rais_df" in d:
            rais_df = d['rais_df']
        else:
            step+=1; print; print '''STEP {0}: \nImport file to pandas dataframe'''.format(step)
            rais_df = to_df(file_path, False)
            try:
                d['rais_df'] = rais_df
                # d.close()
            except OverflowError:
                print "WARNING: Unable to save dataframe, Overflow Error."
                d.close()
                os.remove(os.path.join(output_path, 'rais_df_raw.h5'))
        # rais_df = to_df(file_path, False)

        if "yb" in d and not requireds_only:
            tables = {"yb":d["yb"], "yo":d["yo"], "yi":d["yi"], "ybi":d["ybi"], "ybo":d["ybo"], "yio":d["yio"], "ybio":d["ybio"]}
        else:
            step+=1; print; print '''STEP {0}: \nAggregate'''.format(step)
            tables = aggregate(rais_df, depths)

            step+=1; print; print 'STEP {0}: \nImportance'.format(step)
            tables["yio"] = importance(tables["ybio"], tables["ybi"], tables["yio"], tables["yo"], year, depths)

            try:
                d["yb"] = tables["yb"]; d["yo"] =  tables["yo"]; d["yi"] =  tables["yi"]; d["ybi"] = tables["ybi"]; d["ybo"] = tables["ybo"]; d["yio"] = tables["yio"]; d["ybio"] = tables["ybio"]
                d.close()
            except OverflowError:
                print "WARNING: Unable to save dataframe, Overflow Error."
                d.close()
                os.remove(os.path.join(output_path, 'rais_df_raw.h5'))

        step+=1; print; print 'STEP {0}: \nRequired'.format(step)
        [tables["ybi"], tables["ybio"]] = required(tables["ybio"], tables["ybi"], tables["yi"], year, depths, output_path)

        # print tables["ybi"].head()
        # sys.exit()

        step+=1; print; print 'STEP {0}: \nDiversity'.format(step)
        tables["yb"] = calc_diversity(tables["ybi"], tables["yb"], "bra_id", "cnae_id", year, depths)
        tables["yb"] = calc_diversity(tables["ybo"], tables["yb"], "bra_id", "cbo_id", year, depths)
        tables["yi"] = calc_diversity(tables["ybi"], tables["yi"], "cnae_id", "bra_id", year, depths)
        tables["yi"] = calc_diversity(tables["yio"], tables["yi"], "cnae_id", "cbo_id", year, depths)
        tables["yo"] = calc_diversity(tables["ybo"], tables["yo"], "cbo_id", "bra_id", year, depths)
        tables["yo"] = calc_diversity(tables["yio"], tables["yo"], "cbo_id", "cnae_id", year, depths)

        step+=1; print; print 'STEP {0}: \nCalculate RCA, diversity and opportunity gain aka RDO'.format(step)
        tables["ybi"] = rdo(tables["ybi"], tables["yi"], year, depths)

        for table_name, table_data in tables.items():
            table_data = add_column_length(table_name, table_data)

        print; print '''FINAL STEP: \nSave files to output path'''
        for t_name, t in tables.items():
            new_file_path = os.path.abspath(os.path.join(output_path, "{0}.tsv.bz2".format(t_name)))
            t.to_csv(bz2.BZ2File(new_file_path, 'wb'), sep="\t", index=True, float_format="%.3f")

    if prev_path:
        print; print '''Calculating growth:'''
        for current_year_file_path in findFiles(output_path, '*.tsv.bz2'):
            if "growth" in current_year_file_path: continue
            current_year_file_name = os.path.basename(current_year_file_path)
            prev_year_file_path = os.path.join(prev_path, current_year_file_name)
            prev5_year_file_path = None
            if prev5_path:
                prev5_year_file_path = os.path.join(prev5_path, current_year_file_name)
            if not os.path.exists(prev_year_file_path):
                print "Unable to find", current_year_file_name, "for previous year."
                continue
            tbl_name, tbl_w_growth = calc_growth(year, current_year_file_path, prev_year_file_path, prev5_year_file_path)
            print tbl_name
            new_file_path = os.path.abspath(os.path.join(output_path, "{0}_growth.tsv.bz2".format(tbl_name)))
            tbl_w_growth.to_csv(bz2.BZ2File(new_file_path, 'wb'), sep="\t", index=True, float_format="%.3f")
            # os.remove(current_year_file_path)

    print("--- %s minutes ---" % str((time.time() - start)/60))

if __name__ == "__main__":
    main()