text:
SauceWhisk provides an "ActiveRecord" style client for the [Sauce Labs](http://www.saucelabs.com) RESTful API.  If you're not using the [Sauce Gem](https://rubygems.org/gems/sauce) and you want a nice way to interact with our API, give this a try.

[![Gem Version](https://badge.fury.io/rb/sauce_whisk.svg)](http://badge.fury.io/rb/sauce_whisk)
[![Build Status](https://travis-ci.org/saucelabs/sauce_whisk.svg?branch=v0.0.12)](https://travis-ci.org/saucelabs/sauce_whisk)
[![Dependency Status](https://gemnasium.com/saucelabs/sauce_whisk.svg)](https://gemnasium.com/saucelabs/sauce_whisk)

## Installation

Add this line to your application's Gemfile:

    gem 'sauce_whisk', 'Some Version Here'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install sauce_whisk

We recommend setting a hard version for now, as the gem is still kinda beta-y.

## Configuration

You'll need a [Sauce Labs account](http://wwww.saucelabs.com/signup).  They're free to try and, if you're an open source project, [your access is always free](http://saucelabs.com/opensauce).

### Values
| Value | ENV Variable | Meaning |
|-------|--------------|---------|
|:username | SAUCE_USERNAME | Your Sauce Labs Username |
|:access\_key | SAUCE\_ACCESS\_KEY| Your Access Key, found on the lower left of your Account page (Not your password!) |
|:asset\_fetch\_retries | SAUCE\_ASSET\_FETCH\_RETRY | Number of times to retry fetching assets |
|:rest_retries | SAUCE_REST_RETRIES | Number of times to try failing REST calls |

### Locations
There are four ways to configure SauceWhisk.  The gem tries each of the following locations in turn.  Note, Environment Variables are the preferred means of setting configuration.

#### Directly on the SauceWhisk object
`username`, `access_key`, `asset_fetch_retries` and `rest_retries` can be set directly on the SauceWhisk object:
```ruby
SauceWhisk.username = 'some_rad_tester'
SauceWhisk.asset_fetch_retries = 5
```

#### The Sauce gem
If you have the Sauce gem required, the SauceWhisk gem will try to read its configuration from the Sauce gem's configuration.

#### ondemand.yml
If you have an ondemand.yml, the SauceWhisk gem will try to read its configuration from that file.  The locations the gem looks for a ondemand.yml are, in order:

1. `./ondemand.yml` (The current directory)
2. `./config/ondemand.yml` (The config directory under the current directory)
3. `$GEM_LOCATION/../ondemand.yml` (The directory of the file which includes `sauce_whisk`
4. `~/.sauce/ondemand.yml` (The .sauce directory in the user's home directory)

The keys are the same as those in the 'value' table, above.

#### Environment variables
This is the preferred way.  Environment variable are available to all applications that need them, won't get accidentally checked into a repo and don't need to be edited for each team member.

```bash
SAUCE_USERNAME=Your Sauce Username
SAUCE_ACCESS_KEY=Your Access Key, found on the lower left of your Account page
```

### HTTP Proxies
To configure a proxy, set the 'HTTP_PROXY' or 'http_proxy' environment variable.  Proxies need to be a valid URI; HTTP Authentication can be included.

## Usage

### Marking jobs passed or failed
```ruby
    SauceWhisk::Jobs.pass_job job_id
    SauceWhisk::Jobs.fail_job job_id
    SauceWhisk::Jobs.change_status job_id, true_for_passed_false_for_failed
```

### Creating Job Objects

There are three ways to create a Job object.

```ruby
# Create an 'empty' job (i.e. don't retrieve job details from the API)
empty_job = SauceWhisk::Job.new job_id

# Create a job with details fetched from the API
fully_detailed_job = SauceWhisk::Jobs.fetch job_id

# Create a job with details fetched from the API, failing if the job is incomplete
partially_detailed_job = SauceWhisk::Jobs.fetch! job_id
```

Use the first form when you just want a simple way to push details to the API.  Use the second form when you want to fetch details from the API, but aren't overly fussy about having complete job information.  Use the third form to throw a `SauceWhisk::JobNotComplete` exception when fetching an incomplete job.  Jobs that are fetched incomplete will not have screenshots, and may not have videos or logs.

NB: It's not possible to create a new job on Sauce Labs' infrastructure with the API.

### Updating Job Metadata

#### Updating Pass or Fail Status
See [here](#marking-jobs-passed-or-failed)

#### Changing job names
```ruby
job = SauceWhisk::Jobs.fetch job_id
job.name = "Determine if the User can Invite Friends"

job.save
```

#### All possible changes

```ruby
job = SauceWhisk::Jobs.fetch job_id
job.build = "12.3.04-beta"
job.visibility = "public"
job.tags = "new_user"
job.name = "Determine if the User can Invite Friends"
job.custom_data = {:executor => "jparth", :team_city_config => "standard_with_instrumentation"}
job.passed = false

job.save
```

It is not possible to alter any other job properties.

### Other Job Properties

```ruby
job = SauceWhisk::Jobs.fetch job_id
job.id      # Sauce job_id
job.owner   # Account name of job's owner
job.browser # Browser job ran on
job.browser_verion  # Version of Browser
job.os      # OS job ran on
job.log_url # URL for accessing Job Log
job.creation_time   # When the job was first created
job.start_time      # When the job started running
job.end_time        # When the job finished
job.video_url       # URL for accessing screencast video
job.screenshot_urls # Array of URLs for accessing screenshots
job.has_all_asset_names?  # True if all asset names were fetched (eg job was complete)
```

### Deleting Jobs
```ruby
Jobs.delete_job job_id
```

### Assets

There are three types of asset for Sauce Labs jobs: screenshots, video and logs.  Assets are represented as an Asset object, which include the name, asset type and data.

#### Screenshots

```ruby
  job = SauceWhisk::Jobs.fetch job_id
  screenshots = job.screenshots # An array of Screenshot assets
```

#### Video

```ruby
  job = SauceWhisk::Jobs.fetch job_id
  video = job.video # A single Asset, holding the video
```

#### Deleting Assets

```ruby
SauceWhisk::Assets.delete job_id #==> Deletes all assets for job.
```

### Accounts

At the moment, it is only possible to query existing accounts, and create subaccounts.

#### Retrieving a specific account
```ruby
my_account = SauceWhisk::Accounts.fetch "account_name" # Returns a SauceWhisk::Account object, with its concurrency limit
my_account = SauceWhisk::Accounts.fetch("account_name", false) # Returns a SauceWhisk::Account object, does not fetch its concurrency limit
```

`SauceWhisk::Account` objects store data about the relevant account:

```ruby
my_account.username             # Sauce Labs Username
my_account.access_key           # Sauce Labs Access Key (For automated test authentication... Not your password)
my_account.minutes              # Automated minutes available for Windows, Android, Linux
my_account.manual_minutes       # Manual minutes available for Windows, Android, Linux
my_account.mac_minutes          # Automated minutes available for Mac, iOS
my_account.mac_manual_minutes   # Manual minutes available for Mac, iOS
my_account.total_concurrency    # Number of concurrent jobs allowed
my_account.mac_concurrency      # Number of concurrent Mac hosted jobs allowed (includes iPad, iPhone, Mac)
```

NB: Minutes counts can be strings

#### Retrieving the concurrency limits for an account

If you exceed your concurrency limits, your tests will be queued waiting for a free VM.  This may cause erroneous failures in your test cases, and no-one wants that.
```ruby
concurrencies = SauceWhisk::Accounts.concurrency_for "account_name"    # Hash containing both concurrency limits
mac_concurrency = SauceWhisk::Accounts.concurrency_for "account_name", :mac    # Fixnum of just the Mac limit
total_concurrency = SauceWhisk::Accounts.concurrency_for "account_name", :total    # Fixnum of the upper concurrency limit
```

#### Creating subaccounts

```ruby
parent = SauceWhisk::Accounts.fetch "account_name"

subaccount = parent.add_subaccount("User", "Username", "User@email.com", "Password") # New SauceWhisk::SubAccount
```

SubAccounts are a subclass of Account, with an accessor for their parent object.
```ruby
subaccount.parent == parent #=>true
```

### Tunnels

Tunnels give information about currently running [Sauce Connect](https://saucelabs.com/docs/connect) tunnels for a given user.

#### Fetching All Active Tunnels

```ruby
all_tunnels = SauceWhisk::Tunnels.all   # An array of SauceWhisk::Tunnel objects
all_tunnels_as_json = SauceWhisk::Tunnels.all(:fetch_each => false)  # An array of Tunnel IDs
```

#### Details for a specific tunnel
```ruby
tunnel = SauceWhisk::Tunnels.fetch(tunnel_id)   # An instance of Tunnel
tunnel.id        # The Tunnel, um, id.
tunnel.owner     # The Sauce Account responsible for the tunnel -- The Credentials used to open it
tunnel.status    # Whether or not the tunnel is open
tunnel.host      # The Sauce Labs machine hosting the other end of the Tunnel
tunnel.creation_time  # When the tunnel was opened, in Epoch time
```

#### Stopping a Tunnel

```ruby
tunnel = SauceWhisk::Tunnels.fetch tunnel_id
tunnel.stop  # Stops the Tunnel

SauceWhisk::Tunnels.stop tunnel_id   # Stops the tunnel with the given id
```
### Retrying fetching of assets
Occasionally, assets won't be available immediately after the job is finished.  The gem will automatically retry fetching them.

You can configure how many times the gem retries by configuring 'asset\_fetch\_retries` to your desired number of retries.

### Generic Sauce Labs Information

The Sauce class returns non-user-specific info about available platforms, the number of jobs run, and the status of Sauce Labs' infrastructure.

These can be used without authentication.

#### Fetch All Available Platforms

You can obtain an Array of all available webdriver platforms using `SauceWhisk::Sauce.platforms`:

```ruby
platforms = SauceWhisk::Sauce.platforms        # Fetch all platforms or return cached values
platforms = SauceWhisk::Sauce.platforms(true)  # Force a fetch of all platforms

platforms.first # => A Hash of platform details:

 {
    "long_name"=>"Firefox",             # Full name of the platform's browser
    "api_name"=>"firefox",              # desired_capabilities name of the platform
    "long_version"=>"20.0.1.",          # Full version number for the platform's browser
    "preferred_version"=>"",            # Preferred version of the platform's browser (If none is requested)
    "automation_backend"=>"webdriver",  # Whether this is a Webdriver or Selenium-rc driven platform
    "os"=>"Linux",                      # desired_capabilities name of the Platform's Operating System
    "short_version"=>"20"               # desired_capabilities name of the Platform's Browsers's version
 }
```

The most important values for a platform are the **os**, **api_name**, **short_version** fields.  These are the values to use for desired_capabilites *os*, *browser* and *browser_version* respectively.

The gem does not support retrieval of selenium-rc platforms at the current time

#### Count

```ruby
all_tests = SauceWhisk::Sauce.total_job_count  # The total number of jobs ever run with Sauce Labs' help
```

#### Service Status

```ruby
status = SauceWhisk::Sauce.service_status   # Check the status of Sauce Labs' service

status.inspect # =>

{
  :wait_time=>0.39880952380952384,                          # Delay between requesting a job and it starting
  :service_operational=>true,                               # Operational Status -- Boolean
  :status_message=>"Basic service status checks passed."    # More info when erros occuring
}
```

### Logger

You can set a custom logger object, passing anything that responds to puts:

```ruby
SauceWhisk.logger = my_logger
```

SauceWhisk.logger defaults to STDOUT, at the warn level.

### Storage

Create a new [storage object](http://saucelabs.com/docs/rest#storage):

```ruby
storage = SauceWhisk::Storage.new username: 'my_user_name', key: '00', debug: true
```

If the environment variables SAUCE_USERNAME and SAUCE_ACCESS_KEY are set then:

```ruby
storage = SauceWhisk::Storage.new debug: true
```

List all files in storage.

```ruby
storage.files
```

Upload a file.

```ruby
storage.upload '/tmp/sauce/test.zip'
```

## Contributing

1. Fork the [sauce-labs version](https://github.com/saucelabs/sauce_whisk) of this repository
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/saucelabs/sauce_whisk/trend.png)](https://bitdeli.com/free "Bitdeli Badge")


text:
namespace Abp.Application.Services.Dto
{
    /// <summary>
    /// This interface must be implemented by all DTO classes to identify them by convention.
    /// </summary>
    public interface IDto
    {

    }
}

redpajama_set_name: RedPajamaGithub


text:
package org.elasticsearch.plugin.readonlyrest.acl.blocks.rules;

/**
 * @author Christian Henke <maitai@users.noreply.github.com>
 */
public class UserNotConfiguredException extends Exception {

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright 2021 Google LLC

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<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>
    <packaging>war</packaging>

    <groupId>com.google.appengine.demos</groupId>
    <artifactId>proberapp</artifactId>
    <name>AppEngine :: proberapp</name>
  <parent>
    <groupId>com.google.appengine</groupId>
    <artifactId>applications</artifactId>
    <version>2.0.11-SNAPSHOT</version>
  </parent>

    <properties>
        <maven.deploy.skip>true</maven.deploy.skip>
        <!--INSTANCE_CONNECTION_NAME>ludo-in-in:us-central1:mysql-instance</INSTANCE_CONNECTION_NAME-->
        <MYSQL_DB_DATABASE>mysql-database</MYSQL_DB_DATABASE>
        <MYSQL_DATABASE_NAME>mysql-instance</MYSQL_DATABASE_NAME>
        <DB_REGION>us-central1</DB_REGION>
        <DB_USER>prober-user</DB_USER>
        <DB_PASSOWRD>prober_connectivity_test_database</DB_PASSOWRD>

        <appengine.target.version>${project.version}</appengine.target.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <appengine.runtime.location>target/${project.artifactId}-${project.version}</appengine.runtime.location>
    </properties>

    <dependencies>
        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-spanner</artifactId>
            <version>6.17.3</version>
        </dependency>
        <dependency>
            <groupId>com.google.api</groupId>
            <artifactId>gax</artifactId>
            <version>2.16.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.api</groupId>
            <artifactId>gax-httpjson</artifactId>
            <version>0.101.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.api</groupId>
            <artifactId>gax-grpc</artifactId>
            <version>2.16.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.api-client</groupId>
            <artifactId>google-api-client</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-remote-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-bigquery</artifactId>
            <version>2.10.10</version>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-core</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-datastore</artifactId>
            <version>2.4.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-logging</artifactId>
            <version>3.7.5</version>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-storage</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.cloud.sql</groupId>
            <artifactId>mysql-socket-factory</artifactId>
            <version>1.5.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.truth</groupId>
            <artifactId>truth</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.google.truth.extensions</groupId>
            <artifactId>truth-java8-extension</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.28</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.15</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.13</version>
        </dependency>
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client-jackson</artifactId>
            <version>1.29.2</version>
        </dependency>
        <!-- Test Dependencies -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>2.0.2-beta</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>

        <plugins>
            <plugin>
                <groupId>com.coderplus.maven.plugins</groupId>
                <artifactId>copy-rename-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <id>rename-file</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>rename</goal>
                        </goals>
                        <configuration>
                              <fileSets>
                                <fileSet>
                                    <sourceFile>../../runtime/deployment/target/runtime-deployment-${project.version}/runtime-impl.jar</sourceFile>
                                    <destinationFile>${appengine.runtime.location}/runtime-impl.jar</destinationFile>
                                </fileSet>
                                <fileSet>
                                    <sourceFile>../../runtime/deployment/target/runtime-deployment-${project.version}/runtime-shared.jar</sourceFile>
                                    <destinationFile>${appengine.runtime.location}/runtime-shared.jar</destinationFile>
                                </fileSet>
                                <fileSet>
                                    <sourceFile>../../runtime/deployment/target/runtime-deployment-${project.version}/runtime-main.jar</sourceFile>
                                    <destinationFile>${appengine.runtime.location}/runtime-main.jar</destinationFile>
                                </fileSet>
                            </fileSets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.2</version>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <!-- in order to interpolate version from pom into appengine-web.xml -->
                        <resource>
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <projectId>ludo-in-in</projectId>
                    <version>liveruntimejava8maven</version>
                    <promote>false</promote>
                    <automaticRestart>true</automaticRestart>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-enforcer-plugin</artifactId>
              <version>3.1.0</version>
              <executions>
                <execution>
                  <id>enforce-maven</id>
                  <goals>
                    <goal>enforce</goal>
                  </goals>
                  <configuration>
                    <rules>
                      <requireMavenVersion>
                        <version>3.1.0</version>
                      </requireMavenVersion>
                    </rules>
                  </configuration>
                </execution>
              </executions>
            </plugin>
        </plugins>
    </build>

</project>


text:
module Engine
  # Generates a expression tree from a set of tokens based on the Slice
  # Context Free Grammar. (Slice Expression Language)
  class Parser
    attr_accessor :tokens, :tree, :events, :identifiers

    def initialize(project, verbose: false)
      @project = project
      @current_position = nil
      @current_token = nil
      @next_token = nil
      @previous_token = nil
      @tree = nil
      @verbose = verbose
      @events = []
      @identifiers = []
    end

    def advance
      set_position(@current_position + 1)
    end

    def insert(token_type)
      @tokens.insert(@current_position, ::Engine::Token.new(token_type, auto: true))
    end

    def parse(tokens)
      @tokens = tokens
      set_position(0)
      recursive_descent_parser
    end

    def set_position(index)
      @current_position = index
      @previous_token = @current_position.positive? ? tokens[@current_position - 1] : nil
      @current_token = tokens[@current_position]
      @next_token = tokens[@current_position + 1]
    end

    def token_is?(*token_types)
      if @current_token&.token_type.in?(token_types)
        advance
        true
      else
        false
      end
    end

    def consume_token!(token_type, message)
      if @current_token&.token_type == token_type
        advance
      else
        insert(token_type)
        advance
      end
    end

    def identifier_designs
      @identifiers.select { |ie| ie.is_a?(::Engine::Expressions::IdentifierDesign) }
    end

    def identifier_events
      @identifiers.select { |ie| ie.is_a?(::Engine::Expressions::IdentifierEvent) }
    end

    def identifier_variables
      @identifiers.select { |ie| ie.is_a?(::Engine::Expressions::IdentifierVariable) }
    end

    private

    def recursive_descent_parser
      puts "#{"Parser".white} recursive descent parsing started..." if @verbose
      @tree = expression
    end

    def expression
      expr = xorterm

      while token_is?(:or)
        operator = @previous_token
        right = xorterm
        expr = ::Engine::Expressions::Binary.new(expr, operator, right)
      end

      expr
    end

    def xorterm
      expr = term

      while token_is?(:xor)
        operator = @previous_token
        right = term
        expr = ::Engine::Expressions::Binary.new(expr, operator, right)
      end

      expr
    end

    def term
      expr = factor

      while token_is?(:and)
        operator = @previous_token
        right = factor
        expr = ::Engine::Expressions::Binary.new(expr, operator, right)
      end

      expr
    end

    def factor
      equality
    end

    def equality
      expr = comparison

      while token_is?(:bang_equal, :equal)
        operator = @previous_token
        right = comparison
        expr = ::Engine::Expressions::Binary.new(expr, operator, right)
      end

      expr
    end

    def comparison
      expr = between

      while token_is?(:greater, :less, :greater_equal, :less_equal)
        operator = @previous_token
        right = between
        expr = ::Engine::Expressions::Binary.new(expr, operator, right)
      end

      expr
    end

    def between
      expr = addition

      if token_is?(:between)
        operator = @previous_token
        lower = addition
        consume_token!(:and, "Missing `and` after between.")
        higher = addition
        left = ::Engine::Expressions::Binary.new(expr, ::Engine::Token.new(:greater_equal, auto: true), lower)
        right = ::Engine::Expressions::Binary.new(expr, ::Engine::Token.new(:less_equal, auto: true), higher)
        expr = ::Engine::Expressions::Binary.new(left, ::Engine::Token.new(:and), right)
      end

      expr
    end

    def addition
      expr = multiplication

      while token_is?(:minus, :plus)
        operator = @previous_token
        right = multiplication
        expr = ::Engine::Expressions::Binary.new(expr, operator, right)
      end

      expr
    end

    def multiplication
      expr = exponentiation

      while token_is?(:slash, :star)
        operator = @previous_token
        right = exponentiation
        expr = ::Engine::Expressions::Binary.new(expr, operator, right)
      end

      expr
    end

    def exponentiation
      expr = unary

      while token_is?(:power)
        operator = @previous_token
        right = unary
        expr = ::Engine::Expressions::Binary.new(expr, operator, right)
      end

      expr
    end

    def unary
      if token_is?(:bang, :minus, :plus)
        operator = @previous_token
        right = unary
        return ::Engine::Expressions::Unary.new(operator, right)
      end

      identifier_event
    end

    def identifier_event
      expr = primary
      if token_is?(:at)
        operator = @previous_token
        right = primary
        # TODO: Raise "expected an event" if right is not of type ::Engine::Expressions::IdentifierEvent
        # TODO: @identifiers[-2] also needs to be an IdentifierVariable or an IdentifierDesign
        @identifiers[-2].event = right if @identifiers[-2].respond_to?(:event)
      end
      expr
    end

    def primary
      return ::Engine::Expressions::Literal.new(false) if token_is?(:false)
      return ::Engine::Expressions::Literal.new(true) if token_is?(:true)
      return ::Engine::Expressions::Literal.new(nil) if token_is?(:nil)
      return ::Engine::Expressions::Literal.new(:entered, meta: true) if token_is?(:entered)
      return ::Engine::Expressions::Literal.new(:present, meta: true) if token_is?(:present)
      return ::Engine::Expressions::Literal.new(:missing, meta: true) if token_is?(:missing)
      return ::Engine::Expressions::Literal.new(:unentered, meta: true) if token_is?(:unentered)

      if token_is?(:number, :string)
        return ::Engine::Expressions::Literal.new(@previous_token.raw)
      end

      if token_is?(:identifier)
        variable = @project.variables.find_by(name: @previous_token.raw)
        if variable
          @previous_token.identified = true
          identifier = ::Engine::Expressions::IdentifierVariable.new(variable.name)
          @identifiers << identifier
          return identifier
        end
        event = @project.events.find_by(slug: @previous_token.raw)
        if event
          @previous_token.identified = true
          identifier = ::Engine::Expressions::IdentifierEvent.new(event.slug)
          @identifiers << identifier
          return identifier
        end
        design = @project.designs.find_by(slug: @previous_token.raw)
        if design
          @previous_token.identified = true
          identifier = ::Engine::Expressions::IdentifierDesign.new(design.slug)
          @identifiers << identifier
          return identifier
        end
      end

      if token_is?(:left_paren)
        expr = expression
        consume_token!(:right_paren, "Missing closing ')'.")
        return ::Engine::Expressions::Grouping.new(expr)
      end

      return ::Engine::Expressions::Literal.new(nil)
    end
  end
end


text:
namespace Lemonade.Web.Core.Events
{
    public class FeatureErrorHasOccurred : IDomainEvent
    {
        public string Message { get; }

        public FeatureErrorHasOccurred(string message)
        {
            Message = message;
        }
    }
}


text:
layout: "aws"
page_title: "AWS: aws_route53_record"
sidebar_current: "docs-aws-resource-route53-record"
description: |-
  Provides a Route53 record resource.
---

# aws\_route53\_record

Provides a Route53 record resource.

## Example Usage

### Simple routing policy

```
resource "aws_route53_record" "www" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name    = "www.example.com"
  type    = "A"
  ttl     = "300"
  records = ["${aws_eip.lb.public_ip}"]
}
```

### Weighted routing policy
Other routing policies are configured similarly. See [AWS Route53 Developer Guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html) for details.

```
resource "aws_route53_record" "www-dev" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name    = "www"
  type    = "CNAME"
  ttl     = "5"

  weighted_routing_policy {
    weight = 10
  }

  set_identifier = "dev"
  records        = ["dev.example.com"]
}

resource "aws_route53_record" "www-live" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name    = "www"
  type    = "CNAME"
  ttl     = "5"

  weighted_routing_policy {
    weight = 90
  }

  set_identifier = "live"
  records        = ["live.example.com"]
}
```

### Alias record
See [related part of AWS Route53 Developer Guide](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-choosing-alias-non-alias.html)
to understand differences between alias and non-alias records.

TTL for all alias records is [60 seconds](https://aws.amazon.com/route53/faqs/#dns_failover_do_i_need_to_adjust),
you cannot change this, therefore `ttl` has to be omitted in alias records.

```
resource "aws_elb" "main" {
  name               = "foobar-terraform-elb"
  availability_zones = ["us-east-1c"]

  listener {
    instance_port     = 80
    instance_protocol = "http"
    lb_port           = 80
    lb_protocol       = "http"
  }
}

resource "aws_route53_record" "www" {
  zone_id = "${aws_route53_zone.primary.zone_id}"
  name    = "example.com"
  type    = "A"

  alias {
    name                   = "${aws_elb.main.dns_name}"
    zone_id                = "${aws_elb.main.zone_id}"
    evaluate_target_health = true
  }
}
```

## Argument Reference

The following arguments are supported:

* `zone_id` - (Required) The ID of the hosted zone to contain this record.
* `name` - (Required) The name of the record.
* `type` - (Required) The record type.
* `ttl` - (Required for non-alias records) The TTL of the record.
* `records` - (Required for non-alias records) A string list of records.
* `set_identifier` - (Optional) Unique identifier to differentiate records with routing policies from one another. Required if using `failover`, `geolocation`, `latency`, or `weighted` routing policies documented below.
* `health_check_id` - (Optional) The health check the record should be associated with.
* `alias` - (Optional) An alias block. Conflicts with `ttl` & `records`.
  Alias record documented below.
* `failover_routing_policy` - (Optional) A block indicating the routing behavior when associated health check fails. Conflicts with any other routing policy. Documented below.
* `geolocation_routing_policy` - (Optional) A block indicating a routing policy based on the geolocation of the requestor. Conflicts with any other routing policy. Documented below.
* `latency_routing_policy` - (Optional) A block indicating a routing policy based on the latency between the requestor and an AWS region. Conflicts with any other routing policy. Documented below.
* `weighted_routing_policy` - (Optional) A block indicating a weighted routing policy. Conflicts with any other routing policy. Documented below.

Exactly one of `records` or `alias` must be specified: this determines whether it's an alias record.

Alias records support the following:

* `name` - (Required) DNS domain name for a CloudFront distribution, S3 bucket, ELB, or another resource record set in this hosted zone.
* `zone_id` - (Required) Hosted zone ID for a CloudFront distribution, S3 bucket, ELB, or Route 53 hosted zone. See [`resource_elb.zone_id`](/docs/providers/aws/r/elb.html#zone_id) for example.
* `evaluate_target_health` - (Required) Set to `true` if you want Route 53 to determine whether to respond to DNS queries using this resource record set by checking the health of the resource record set. Some resources have special requirements, see [related part of documentation](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values.html#rrsets-values-alias-evaluate-target-health).

Failover routing policies support the following:

* `type` - (Required) `PRIMARY` or `SECONDARY`. A `PRIMARY` record will be served if its healthcheck is passing, otherwise the `SECONDARY` will be served. See http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover-configuring-options.html#dns-failover-failover-rrsets

Geolocation routing policies support the following:

* `continent` - A two-letter continent code. See http://docs.aws.amazon.com/Route53/latest/APIReference/API_GetGeoLocation.html for code details. Either `continent` or `country` must be specified.
* `country` - A two-character country code or `*` to indicate a default resource record set.
* `subdivision` - (Optional) A subdivision code for a country.

Latency routing policies support the following:

* `region` - (Required) An AWS region from which to measure latency. See http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-latency

Weighted routing policies support the following:

* `weight` - (Required) A numeric value indicating the relative weight of the record. See http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-weighted.

## Attributes Reference

* `fqdn` - [FQDN](https://en.wikipedia.org/wiki/Fully_qualified_domain_name) built using the zone domain and `name`

## Import

Route53 Records can be imported using ID of the record, e.g.

```
$ terraform import aws_route53_record.myrecord Z4KAPRWWNC7JR_dev.example.com_NS
```


text:
require 'json'
require 'niconico/deferrable'

class Niconico
  def video(video_id)
    login unless logged_in?
    Video.new(self, video_id)
  end

  class Video
    include Niconico::Deferrable

    deferrable :id, :title,
      :description, :description_raw,
      :url, :video_url, :type,
      :tags, :mylist_comment, :api_data

    def initialize(parent, video_id, defer=nil)
      @parent = parent
      @agent = parent.agent
      @fetched = false
      @thread_id = @id = video_id
      @page = nil
      @url = "#{Niconico::URL[:watch]}#{@id}"

      if defer
        preload_deffered_values(defer)
      else
        get()
      end
    end

    def economy?; @eco; end

    def get(options = {})
      begin
        @page = @agent.get(@url)
      rescue Mechanize::ResponseCodeError => e
        raise NotFound, "#{@id} not found" if e.message == "404 => Net::HTTPNotFound"
        raise e
      end

      if /^so/ =~ @id
        sleep 5
        @thread_id = @agent.get("#{Niconico::URL[:watch]}#{@id}").uri.path.sub(/^\/watch\//,"")
      end
      additional_params = nil
      if /^nm/ === @id && (!options.key?(:as3) || options[:as3])
        additional_params = "&as3=1"
      end
      getflv = Hash[@agent.get_file("#{Niconico::URL[:getflv]}?v=#{@thread_id}#{additional_params}").scan(/([^&]+)=([^&]+)/).map{|(k,v)| [k.to_sym,CGI.unescape(v)] }]

      if api_data_node = @page.at("#watchAPIDataContainer")
        @api_data = JSON.parse(api_data_node.text())
        video_detail = @api_data["videoDetail"]
        @title ||= video_detail["title"] if video_detail["title"]
        @description ||= video_detail["description"] if video_detail["description"]
        @tags  ||= video_detail["tagList"].map{|e| e["tag"]}
      end

      t = @page.at("#videoTitle")
      @title ||= t.inner_text unless t.nil?
      d = @page.at("div#videoComment>div.videoDescription")
      @description ||= d.inner_html unless d.nil?

      @video_url = getflv[:url]
      if @video_url
        @eco = !(/low$/ =~ @video_url).nil?
        @type = case @video_url.match(/^http:\/\/(.+\.)?nicovideo\.jp\/smile\?(.+?)=.*$/).to_a[2]
                when 'm'; :mp4
                when 's'; :swf
                else;     :flv
                end
      end
      @tags ||= @page.search("#video_tags a[rel=tag]").map(&:inner_text)
      @mylist_comment ||= nil

      @fetched = true
      @page
    end

    def available?
      !!video_url
    end

    def get_video
      raise VideoUnavailableError unless available?
      unless block_given?
          @agent.get_file(video_url)
      else
        cookies = video_cookies.map(&:to_s).join(';')
        uri = URI(video_url)
        http = Net::HTTP.new(uri.host, uri.port)
        http.request_get(uri.request_uri, 'Cookie' => cookies) do |res|
          res.read_body do |body|
            yield body
          end
        end
      end
    end

    def get_video_by_other
      raise VideoUnavailableError unless available?
      warn "WARN: Niconico::Video#get_video_by_other is deprecated. use Video#video_cookie_jar or video_cookie_jar_file, and video_cookies with video_url instead. (Called by #{caller[0]})"
      {cookie: @agent.cookie_jar.cookies(URI.parse(@video_url)),
       url: video_url}
    end

    def video_cookies
      return nil unless available?
      @agent.cookie_jar.cookies(URI.parse(video_url))
    end

    def video_cookie_jar
      raise VideoUnavailableError unless available?
      video_cookies.map { |cookie|
        [cookie.domain, "TRUE", cookie.path,
         cookie.secure.inspect.upcase, cookie.expires.to_i,
         cookie.name, cookie.value].join("\t")
      }.join("\n")
    end

    def video_cookie_jar_file
      raise VideoUnavailableError unless available?
      Tempfile.new("niconico_cookie_jar_#{self.id}").tap do |io|
        io.puts(video_cookie_jar)
        io.flush
      end
    end

    def add_to_mylist(mylist_id, description='')
      @parent.nico_api.mylist_add(mylist_id, :video, @id, description)
    end

    def inspect
      "#<Niconico::Video: #{@id}.#{@type} \"#{@title}\"#{@eco ? " low":""}#{(fetched? && !@video_url) ? ' (unavailable)' : ''}#{fetched? ? '' : ' (defered)'}>"
    end

    class NotFound < StandardError; end
    class VideoUnavailableError < StandardError; end
  end
end


text:
// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.ops4j.gaderian.service.impl;

import org.ops4j.gaderian.AssemblyParameters;
import org.ops4j.gaderian.ClassResolver;

/**
 * {@link org.ops4j.gaderian.service.impl.BuilderFacet} whose value is the
 * {@link org.ops4j.gaderian.ClassResolver} of the contributing module.
 *
 * @author Howard Lewis Ship
 */
public class BuilderClassResolverFacet extends BuilderFacet
{

    public Object getFacetValue(AssemblyParameters assemblyParameters, Class targetType)
    {
        return assemblyParameters.getInvokingModule().getClassResolver();
    }

    public boolean isAssignableToType(AssemblyParameters assemblyParameters, Class targetType)
    {
        return targetType == ClassResolver.class;
    }

    protected String getDefaultPropertyName()
    {
        return "classResolver";
    }

    /** @since 1.1 */
    public boolean canAutowireConstructorParameter()
    {
        return true;
    }
}


text:
from ..tree import Node

class BreakStat(Node):
    """docstring for BreakStat."""
    def __init__(self,  token):
        super().__init__(None, token)

    def process_semantic(self, **cond):
        if not cond.get('can_break', False):
            Node.raise_error(f'Cant break outsde for|while|switch. Line: {self.token.line_index} - Col: {self.token.col_index}')

    def generate_code(self, **cond):
        break_to = cond.get('break_to', None)
        array, line = Node.assignated_array()
        Node.array_append(array, f'{line} JMP 0, {break_to}')


text:
<!--
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~
  ~ Copyright 2013 Redwarp
  -->

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.redwarp.tool</groupId>
    <artifactId>resizer</artifactId>

    <version>1.4.2</version>
    <name>9Patch Resizer</name>

    <properties>
        <resizer.versionName>${project.version}</resizer.versionName>
        <resizer.versionCode>4</resizer.versionCode>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>res</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/configuration.properties</include>
                </includes>
            </resource>

            <resource>
                <directory>res</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/configuration.properties</exclude>
                </excludes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>net.redwarp.tool.resizer.Main</mainClass>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.8</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <injar>${project.build.finalName}.jar</injar>
                    <outjar>${project.build.finalName}-proguard.jar</outjar>
                    <proguardInclude>proguard.txt</proguardInclude>
                    <includeDependencyInjar>true</includeDependencyInjar>
                    <libs>
                        <lib>${java.home}/lib/rt.jar</lib>
                    </libs>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>launch4j</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.akathist.maven.plugins.launch4j</groupId>
                        <artifactId>launch4j-maven-plugin</artifactId>
                        <version>1.7.4</version>
                        <executions>
                            <execution>
                                <id>launch4j</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>launch4j</goal>
                                </goals>
                                <configuration>
                                    <headerType>gui</headerType>
                                    <outfile>target/Resizer-${project.version}.exe</outfile>
                                    <jar>target/resizer-${project.version}-proguard.jar</jar>
                                    <classPath>
                                        <mainClass>net.redwarp.tool.resizer.Main</mainClass>
                                        <addDependencies>false</addDependencies>
                                        <preCp>anything</preCp>
                                    </classPath>
                                    <jre>
                                        <minVersion>1.6.0</minVersion>
                                        <maxVersion/>
                                        <jdkPreference>preferJre</jdkPreference>
                                        <runtimeBits>64/32</runtimeBits>
                                    </jre>
                                    <icon>extra/icon_512.ico</icon>
                                    <priority>normal</priority>
                                    <singleInstance>
                                        <mutexName>resizer</mutexName>
                                        <windowTitle/>
                                    </singleInstance>
                                    <versionInfo>
                                        <fileVersion>${project.version}.0</fileVersion>
                                        <txtFileVersion>${project.version}</txtFileVersion>
                                        <fileDescription>9Patch Resizer</fileDescription>
                                        <copyright>Redwarp 2013-2015</copyright>
                                        <productVersion>${project.version}.0</productVersion>
                                        <txtProductVersion>${project.version}</txtProductVersion>
                                        <productName>9Patch Resizer</productName>
                                        <internalName>Resizer</internalName>
                                        <originalFilename>Resizer.exe</originalFilename>
                                    </versionInfo>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>


text:
package persistencia;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import persistencia.Sonido;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@Entity
public class Instrumento implements Serializable{
	 /**
		 *
		 */
		private static final long serialVersionUID = 1L;
		private static final String[] tipos = {"Techno","House","Electro","Disco","DrumNBass", "Real", "Personalizado"};
		private static final String[] posiciones = {"Izquierda","Abajo"};
		@Id
		 @GeneratedValue(strategy = GenerationType.TABLE)
		 private Long idInstrumento;
		 private String nombre;
		 private String tipo;
		 private String posicion;
		 private Sonido sonido1;
		 private Sonido sonido2;
		 private Usuario usuario;

		 public Instrumento(){}

		 public Instrumento(String nombre, String tipo, String posicion, Sonido sonido1, Sonido sonido2, Usuario usuario){
			 this.nombre=nombre;
			 this.tipo=tipo;
			 this.posicion=posicion;
			 this.sonido1=sonido1;
			 this.sonido2=sonido2;
			 this.usuario=usuario;
		 }

		 public Long getIdInstrumento() {
			   return idInstrumento;
		 }

		 public void setIdInstrumento(Long idInstrumento) {
			   this.idInstrumento = idInstrumento;
		 }

		 public String getNombre() {
			   return nombre;
		 }

		 public void setNombre(String nombre) {
			   this.nombre = nombre;
		 }

		 public String getTipo() {
				   return tipo;
		 }

		 public void setTipo(String tipo) {
				   this.tipo = tipo;
		 }

		 public String getPosicion() {
			   return posicion;
		 }

		 public void setPosicion(String posicion) {
			   this.posicion = posicion;
		 }

		 @OneToMany
		 public Sonido getSonido1() {
			   return sonido1;
		 }

		 public void setSonido1(Sonido sonido1) {
			   this.sonido1 = sonido1;
		 }

		 @OneToMany
		 public Sonido getSonido2() {
			   return sonido2;
		 }

		 public void setSonido2(Sonido sonido2) {
			   this.sonido2 = sonido2;
		 }

			 @ManyToOne
			 public Usuario getUsuario() {
				    return usuario;
			 }

			 public void setUsuario(Usuario usuario) {
				    this.usuario=usuario;
			 }

			public void modificar(String nombre, String tipo,
					String posicion, Sonido sonido1,Sonido sonido2) {
				 this.nombre=nombre;
				 this.tipo=tipo;
				 this.posicion=posicion;
				 this.sonido1=sonido1;
				 this.sonido2=sonido2;

			}

			public String toString(){
				return "Nombre: " + nombre + " Tipo: " + tipo + " Posicion: " + posicion + " sonido1: " + sonido1+ " sonido1: " + sonido1 + "    Usuario: " + usuario.toString();
			}

}


text:
<?php

namespace Msi\Bundle\CmfBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
use Msi\Bundle\CmfBundle\Entity\Translatable;
use Knp\Menu\NodeInterface;

/**
 * @ORM\Table(name="cmf_menu")
 * @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
 * @Gedmo\Tree(type="nested")
 * @ORM\HasLifecycleCallbacks
 */
class Menu extends Translatable implements NodeInterface
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @Gedmo\TreeLevel
     * @ORM\Column(type="integer")
     */
    protected $lvl;

    /**
     * @Gedmo\TreeLeft
     * @ORM\Column(type="integer")
     */
    protected $lft;

    /**
     * @Gedmo\TreeRight
     * @ORM\Column(type="integer")
     */
    protected $rgt;

    /**
     * @Gedmo\TreeRoot
     * @ORM\Column(type="integer")
     */
    protected $menu;

    /**
     * @Gedmo\TreeParent
     * @ORM\ManyToOne(targetEntity="Menu", inversedBy="children")
     */
    protected $parent;

    /**
     * @ORM\OneToMany(targetEntity="Menu", mappedBy="parent", cascade={"remove"})
     * @ORM\OrderBy({"lft" = "ASC"})
     */
    protected $children;

    /**
     * @ORM\Column(type="datetime", name="created_at")
     */
    protected $createdAt;

    /**
     * @ORM\Column(type="datetime", name="updated_at")
     */
    protected $updatedAt;

    /**
     * @ORM\OneToMany(targetEntity="MenuTranslation", mappedBy="object", cascade={"persist", "remove"})
     */
    protected $translations;

    /**
     * @ORM\ManyToOne(targetEntity="Msi\Bundle\CmfBundle\Entity\Page")
     */
    protected $page;

    protected $options = array();

    /**
     * @ORM\Column(type="boolean")
     */
    protected $targetBlank;

    /**
     * @ORM\ManyToMany(targetEntity="Msi\Bundle\UserBundle\Entity\Group")
     * @ORM\JoinTable(name="cmf_menus_groups",
     *      joinColumns={@ORM\JoinColumn(name="menu_id", referencedColumnName="id")},
     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
     * )
     */
    protected $groups;

    public function __construct()
    {
        $this->createdAt = new \DateTime();
        $this->updatedAt = new \DateTime();
        $this->translations = new ArrayCollection();
        $this->children = new ArrayCollection();
        $this->targetBlank = false;
        $this->groups = new ArrayCollection();
    }

    public function getGroups()
    {
        return $this->groups;
    }

    public function setGroups($groups)
    {
        $this->groups = $groups;

        return $this;
    }

    public function getTargetBlank()
    {
        return $this->targetBlank;
    }

    public function setTargetBlank($targetBlank)
    {
        $this->targetBlank = $targetBlank;

        return $this;
    }

    /**
     * @ORM\PreUpdate()
     */
    public function preUpdate()
    {
        $this->updatedAt = new \DateTime();
    }

    public function getPage()
    {
        return $this->page;
    }

    public function setPage($page)
    {
        $this->page = $page;

        return $this;
    }

    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;

        return $this;
    }

    public function getOptions()
    {
        $this->options['extras']['groups'] = $this->groups;
        $this->options['extras']['published'] = $this->getTranslation()->getPublished();

        if ($this->page) {
            if (!$this->page->getRoute()) {
                $this->options['route'] = 'msi_page_show';
                if (!$this->page->getHome()) {
                    $this->options['routeParameters'] = array('slug' => $this->page->getTranslation()->getSlug());
                }
            } else {
                $this->options['route'] = $this->page->getRoute();
            }
        } else if (preg_match('#^@#', $this->getTranslation()->getRoute())) {
            $this->options['route'] = substr($this->getTranslation()->getRoute(), 1);
        } else {
            $this->options['uri'] = $this->getTranslation()->getRoute();
        }

        if ($this->targetBlank) {
            $this->options['linkAttributes'] = array('target' => '_blank');
        }

        return $this->options;
    }

    public function setOption($k ,$v)
    {
        $this->options[$k] = $v;
    }

    public function addChild($child)
    {
        $this->children[] = $child;

        return $this;
    }

    public function getChildren()
    {
        return $this->children;
    }

    public function getParent()
    {
        return $this->parent;
    }

    public function setParent($parent)
    {
        $this->parent = $parent;

        return $this;
    }

    public function getName()
    {
        return $this->getTranslation()->getName();
    }

    public function getLvl()
    {
        return $this->lvl;
    }

    public function setLvl($lvl)
    {
        $this->lvl = $lvl;

        return $this;
    }

    public function getLft()
    {
        return $this->lft;
    }

    public function setLft($lft)
    {
        $this->lft = $lft;

        return $this;
    }

    public function getRgt()
    {
        return $this->rgt;
    }

    public function setRgt($rgt)
    {
        $this->rgt = $rgt;

        return $this;
    }

    public function getMenu()
    {
        return $this->menu;
    }

    public function setMenu($menu)
    {
        $this->menu = $menu;

        return $this;
    }

    public function getId()
    {
        return $this->id;
    }

    public function getToTree()
    {
        $prefix = '';
        for ($i=0; $i < $this->lvl; $i++) {
            $prefix .= '- ';
        }

        if ($this->lvl === 0) {
            $name = $prefix.'Root';
        } else {
            $name = $prefix.$this->getTranslation()->getName();
        }

        return $name;
    }

    public function __toString()
    {
        return (string) $this->getTranslation()->getName();
    }
}


text:
from django.conf.urls import url

from . import views

app_name = 'blast_local_new'
urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^results/$', views.results, name='results'),
]