text:
namespace Pcc
{
    using System;
    using System.Net;
    using System.Web;
    using System.IO;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.RegularExpressions;
    using System.Web.Script.Serialization;
    using System.Data.Entity;
    using System.Text;

    /// <summary>
    /// Summary description for HTTPDatabaseHandler
    /// </summary>
    public class HTTPDatabaseHandler : PccHandler
    {
        JavaScriptSerializer serializer = new JavaScriptSerializer();
        public override void ProcessRequest(HttpContext context, Match match)
        {
            // Environmental Setup
            //PccConfig.LoadConfig("viewer-webtier/pcc.config");

            // find the request method
            string method = context.Request.RequestType.ToLower();
            string methodHeader = context.Request.Headers["X-HTTP-Method-Override"];

            if (!String.IsNullOrEmpty(methodHeader))
            {
                method = methodHeader.ToLower();
            }

            if (!(method == "get" || method == "post"))
            {
                // Request is not a get or a post
                sendResponse(context, (int)HttpStatusCode.MethodNotAllowed);
                return;
            }

            string viewingSessionId = GetStringFromUrl(context, match, "DocumentID");
            string userName = string.Empty;

            // We can check for status of our user's identification in multiple places
            if (context.Request.Headers["username"] != null)
            {
                userName = context.Request.Headers["username"];
            }
            else if (context.Request.QueryString["username"] != null)
            {
                userName = context.Request.QueryString["username"];
            }
            else if (context.Request.Params["username"] != null)
            {
                userName = context.Request.Params["username"];
            }
            else
            {
                sendResponse(context, (int)HttpStatusCode.BadRequest, "No username defined. 1");
                return;
            }

            // Final check to make sure we have a useable user name.
            if (userName == string.Empty)
            {
                sendResponse(context, (int)HttpStatusCode.BadRequest, "No username defined. 2");
                return;
            }

            // Perform an HTTP GET request to retrieve properties about the viewing session from PCCIS.
            // The properties will include an identifier of the source document that will be used below
            // to construct the name of file where markups are stored.
            string uriString = PccConfig.WebServiceAddress + "/ViewingSession/" + viewingSessionId;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uriString);
            request.Method = "GET";
            string responseBody = null;
            request.Headers.Add("acs-api-key", PccConfig.ApiKey);
            try
            {
                // Send request to PCCIS and get response
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                using (StreamReader sr = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
                {
                    responseBody = sr.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                sendResponse(context, (int)HttpStatusCode.BadGateway, "Bad or expired Viewing Session");
                return;
            }

            ViewingSessionProperties viewingSessionProperties = serializer.Deserialize<ViewingSessionProperties>(responseBody);
            string documentMarkupId = string.Empty;
            viewingSessionProperties.origin.TryGetValue("documentMarkupId", out documentMarkupId);

            if (!String.IsNullOrEmpty(documentMarkupId))
            {
                if (method == "post")
                {
                    // Post is used to update an existin annotation or insert a new one.
                    upsertAnnotation(context, documentMarkupId, userName);
                }
                else if (method == "get")
                {
                    // Get is used to retrieve an annotation
                    selectAnnotaion(context, documentMarkupId, userName);
                }
            }
            else
            {
                // Return an error if the documentMarkupId is not present
                // This means that there was a problem with the response from PCCIS
                sendResponse(context, (int)HttpStatusCode.BadGateway, "Bad Gateway");
                return;
            }
        }

        /// <summary>
        /// Selects an annotation from the current database context.
        /// </summary>
        /// <param name="context">Http context</param>
        /// <param name="userName">User's name as a query param</param>
        private void selectAnnotaion(HttpContext context, string externalId, string userName)
        {
            using (var dbContext = new AnnotationModel.AnnotationContext())
            {
                // Entity Framework does not currently support unique constraints
                // Check if this document already exists
                // LINQ will return 0 or the primary key for the current document
                Pcc.DocumentModel.Document document = null;
                try
                {
                    document = dbContext.Documents
                               .Where(d => d.ExternalId == externalId)
                               .FirstOrDefault();
                }
                catch (Exception)
                {

                    sendResponse(context, (int)HttpStatusCode.BadGateway, "Failed to connect to database. Please check your conneciton string.");
                }

                if (document != null)
                {
                    // Document exists
                    var annotation = dbContext.Annotations
                        .Where(a => a.UserName == userName &&
                        a.Document.DocumentID == document.DocumentID)
                        .FirstOrDefault();

                    if (annotation != null)
                    {
                        //Annotation exists, return the data
                        MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(annotation.AnnotationText ?? ""));
                        //StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);
                        //writer.Write(annotation.AnnotationText);
                        //writer.Flush();
                        stream.Position = 0;
                        context.Response.StatusCode = (int)HttpStatusCode.OK;
                        context.Response.ContentType = "application/json";
                        stream.CopyTo(context.Response.OutputStream);
                    }
                    else
                    {
                        // Annotation does not exist
                        sendResponse(context, (int)HttpStatusCode.NotFound);
                    }
                }
                else
                {
                    // Document does not exist
                    sendResponse(context, (int)HttpStatusCode.NotFound);
                }
            }
        }

        /// <summary>
        /// Updates or inserts an annotation into the current database context.
        /// </summary>
        /// <param name="context">Http context</param>
        /// <param name="externalId">Unique document identifier generated from document's absolute path</param>
        /// <param name="userName">User's name as a query param</param>
        private void upsertAnnotation(HttpContext context, string externalId, string userName)
        {
            var rawData = String.Empty;
            // Make sure we're at the beginning
            context.Request.InputStream.Position = 0;
            using (StreamReader inputStream = new StreamReader(context.Request.InputStream))
            {
                rawData = inputStream.ReadToEnd();
            }

            var jsonData = serializer.Deserialize<List<Dictionary<String, Object>>>(rawData);

            var creationDateTime = jsonData[0]["creationDateTime"];

            var type = creationDateTime.GetType();

            using (var dbContext = new AnnotationModel.AnnotationContext())
            {
                // Entity Framework does not currently support unique constraints
                // Check if this document already exists
                // LINQ will return 0 or the primary key for the current document
                Pcc.DocumentModel.Document document = null;

                try
                {
                    document = dbContext.Documents
                                .Where(d => d.ExternalId == externalId)
                                .FirstOrDefault();
                }
                catch (Exception e)
                {

                    sendResponse(context, (int)HttpStatusCode.BadGateway, "Failed to connect to database. Please check your conneciton string.");
                }

                if (document != null)
                {
                    // Document already exists
                    // In this use case, we are only supporting one set of annotations per user.
                    // Does the current user already own a set of annotations for this document?

                    var annotation = dbContext.Annotations
                        .Where(a => a.UserName == userName &&
                        a.DocumentID == document.DocumentID)
                        .FirstOrDefault();

                    if (annotation != null)
                    {
                        // User already owns a set of annotations, update those annotations
                        annotation.AnnotationText = rawData;

                        // Mark as modified and save
                        dbContext.Entry(annotation).State = EntityState.Modified;
                        dbContext.SaveChanges();

                        sendResponse(context, (int)HttpStatusCode.OK, "Annotation Updated");

                    }
                    else
                    {
                        // This is a new set of annotations for this user
                        AnnotationModel.Annotation newAnno = new AnnotationModel.Annotation()
                        {
                            UserName = userName,
                            AnnotationText = rawData,
                            DocumentID = document.DocumentID
                        };

                        // Insert into the local context and save to the store
                        dbContext.Annotations.Add(newAnno);
                        dbContext.SaveChanges();

                        sendResponse(context, (int)HttpStatusCode.OK, "Annotation Created");

                    }

                }
                else
                {
                    // If this document's external ID does not exist in the current context or in the store
                    // Insert the document for this request
                    DocumentModel.Document newDoc = new DocumentModel.Document() { ExternalId = externalId };

                    // Insert into the local context and save to the store
                    dbContext.Documents.Add(newDoc);
                    dbContext.SaveChanges();

                    // Now get the primary key for that document so we can use it
                    document = dbContext.Documents
                    .Where(d => d.ExternalId == externalId)
                    .FirstOrDefault();

                    // In this use case, we are only supporting one set of annotations per user.
                    // Does the current user already own a set of annotations for this document?
                    var annotation = dbContext.Annotations
                        .Where(a => a.UserName == userName &&
                        a.DocumentID == document.DocumentID)
                        .FirstOrDefault();

                    if (annotation != null)
                    {
                        // User already owns a set of annotations, update those annotations locallly
                        // Note that this condition should never happen (ie - no document means no annotation)
                        annotation.AnnotationText = rawData;
                        annotation.AnnotationText = jsonData[0]["modificationDateTime"].ToString();

                        // Mark as modified and save
                        dbContext.Entry(annotation).State = EntityState.Modified;
                        dbContext.SaveChanges();

                        sendResponse(context, (int)HttpStatusCode.OK, "Annotation Updated");
                    }
                    else
                    {
                        // This is a new set of annotations for this user
                        AnnotationModel.Annotation newAnno = new AnnotationModel.Annotation()
                        {
                            UserName = userName,
                            AnnotationText = rawData,
                            DocumentID = document.DocumentID,
                            Document = document
                        };

                        // Insert into the local context and save to the store
                        dbContext.Annotations.Add(newAnno);
                        dbContext.SaveChanges();

                        sendResponse(context, (int)HttpStatusCode.OK, "Annotation Created");
                    }
                }
            }
        }

        private void sendResponse(HttpContext context, int status, Object body = null)
        {
            if (body != null)
            {
                var jsonBody = toJSON(body);

                context.Response.ContentType = "application/json";
                context.Response.Write(jsonBody);
            }

            context.Response.StatusCode = status;
        }

        private string toJSON(Object obj)
        {
            return serializer.Serialize(obj);
        }
    }
}


text:
<?php

namespace Test\CalcBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
 * Class Operator
 * @package Test\CalcBundle\DependencyInjection
 *
 * Do calculator operations
 */
class Operator
{
    /**
     * @var
     * First argument
     */
    private $argument1;
    /**
     * @var
     * Second argument
     */
    private $argument2;

    /**
     * Validate if argument is numeric
     * @param $argument
     * @return bool
     * @throws \Exception
     */
    private function validateArgument($argument)
    {
        if (!is_numeric($argument))
            throw new \Exception('Argument have to be numeric');
        return true;
    }

    /**
     * First argument setter
     * @param $argument
     */
    public function setArgument1($argument)
    {
        if ($this->validateArgument($argument))
            $this->argument1 = $argument;
    }

    /**
     * Second argument setter
     * @param $argument
     */
    public function setArgument2($argument)
    {
        if ($this->validateArgument($argument))
            $this->argument2 = $argument;
    }

    /**
     * Performs adding
     * @return float
     */
    public function add()
    {
        return $this->argument1 + $this->argument2;
    }

    /**
     * Performs substracting
     * @return float
     */
    public function substract()
    {
        return $this->argument1 - $this->argument2;
    }

    /**
     * Performs multiplying
     * @return float
     */
    public function multiply()
    {
        return $this->argument1 * $this->argument2;
    }

    /**
     * Performs dividing
     * @return float
     * @throws \Exception
     */
    public function divide()
    {
        if ($this->argument2 == 0)
            throw new \Exception('Can not divide by 0');

        return $this->argument1 / $this->argument2;
    }
}

redpajama_set_name: RedPajamaGithub


text:
        <link rel="Stylesheet" media="screen" href="data/styles.css" />

jquery.youtubeLinksToEmbed.js

Copyright (c) 2007-2008 Maxime Haineault (haineault.com)

MIT License ~ http://www.opensource.org/licenses/mit-license.php

Dependencies

jquery.flash.js

Usage

$(document).ready(function(){
    $('body').youtubeLinksToEmbed();
});

Demo

Let's roll


text:
namespace Incoding.MvcContrib
{
    #region << Using >>

    using Incoding.Data;
    using Incoding.Quality;

    #endregion

    public abstract class EntityVm
    {
        #region Constructors

        protected EntityVm(IEntity entity)
        {
            Id = entity.Id.ToString();
            AssemblyQualifiedName = entity.GetType().AssemblyQualifiedName;
        }

        #endregion

        #region Properties

        [IgnoreCompare("Base class")]
        public string Id { get; private set; }

        [IgnoreCompare("Base class")]
        public string AssemblyQualifiedName { get; private set; }

        #endregion
    }
}


text:
/*
    module: sparse.c

    make_sparse is a last-step cleanup to reduce the total number
    of literals in the cover.

    This is done by reducing the "sparse" variables (using a modified
    version of irredundant rather than reduce), followed by expanding
    the "dense" variables (using modified version of expand).
*/

#include "espresso.h"

pcover make_sparse(F, D, R)
pcover F, D, R;
{
    cost_t cost, best_cost;

    cover_cost(F, &best_cost);

    do {
	EXECUTE(F = mv_reduce(F, D), MV_REDUCE_TIME, F, cost);
	if (cost.total == best_cost.total)
	    break;
	copy_cost(&cost, &best_cost);

	EXECUTE(F = expand(F, R, TRUE), RAISE_IN_TIME, F, cost);
	if (cost.total == best_cost.total)
	    break;
	copy_cost(&cost, &best_cost);
    } while (force_irredundant);

    return F;
}

/*
    mv_reduce -- perform an "optimal" reduction of the variables which
    we desire to be sparse

    This could be done using "reduce" and then saving just the desired
    part of the reduction.  Instead, this version uses IRRED to find
    which cubes of an output are redundant.  Note that this gets around
    the cube-ordering problem.

    In normal use, it is expected that the cover is irredundant and
    hence no cubes will be reduced to the empty cube (however, this is
    checked for and such cubes will be deleted)
*/

pcover
mv_reduce(F, D)
pcover F, D;
{
    register int i, var;
    register pcube p, p1, last;
    int index;
    pcover F1, D1;
    pcube *F_cube_table;

    /* loop for each multiple-valued variable */
    for(var = 0; var < cube.num_vars; var++) {

	if (cube.sparse[var]) {

	    /* loop for each part of the variable */
	    for(i = cube.first_part[var]; i <= cube.last_part[var]; i++) {

		/* remember mapping of F1 cubes back to F cubes */
		F_cube_table = ALLOC(pcube, F->count);

		/* 'cofactor' against part #i of variable #var */
		F1 = new_cover(F->count);
		foreach_set(F, last, p) {
		    if (is_in_set(p, i)) {
			F_cube_table[F1->count] = p;
			p1 = GETSET(F1, F1->count++);
			(void) set_diff(p1, p, cube.var_mask[var]);
			set_insert(p1, i);
		    }
		}

		/* 'cofactor' against part #i of variable #var */
		/* not really necessary -- just more efficient ? */
		D1 = new_cover(D->count);
		foreach_set(D, last, p) {
		    if (is_in_set(p, i)) {
			p1 = GETSET(D1, D1->count++);
			(void) set_diff(p1, p, cube.var_mask[var]);
			set_insert(p1, i);
		    }
		}

		mark_irredundant(F1, D1);

		/* now remove part i from cubes which are redundant */
		index = 0;
		foreach_set(F1, last, p1) {
		    if (! TESTP(p1, ACTIVE)) {
			p = F_cube_table[index];

			/*   don't reduce a variable which is full
			 *   (unless it is the output variable)
			 */
			if (var == cube.num_vars-1 ||
			     ! setp_implies(cube.var_mask[var], p)) {
			    set_remove(p, i);
			}
			RESET(p, PRIME);
		    }
		    index++;
		}

		free_cover(F1);
		free_cover(D1);
		FREE(F_cube_table);
	    }
	}
    }

    /* Check if any cubes disappeared */
    (void) sf_active(F);
    for(var = 0; var < cube.num_vars; var++) {
	if (cube.sparse[var]) {
	    foreach_active_set(F, last, p) {
		if (setp_disjoint(p, cube.var_mask[var])) {
		    RESET(p, ACTIVE);
		    F->active_count--;
		}
	    }
	}
    }

    if (F->count != F->active_count) {
	F = sf_inactive(F);
    }
    return F;
}


text:
cask 'qgis' do
  version '2.18.9-1'
  sha256 'bc8bd9a63244b89145b0e346c6a242f7055b4b61a14229c9cf54c34e0b8ecb98'

  url "http://www.kyngchaos.com/files/software/qgis/QGIS-#{version}.dmg"
  name 'QGIS'
  homepage 'http://www.kyngchaos.com/software/qgis'

  depends_on cask: 'gdal-framework'
  depends_on formula: 'homebrew/science/matplotlib'

  pkg '4 Install QGIS.pkg'

  uninstall pkgutil: 'org.qgis.qgis-*'

  caveats <<-EOS.undent
    #{token} requires matplotlib in a specific location. Please run the following to finish install:

      sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /Library/Python/2.7/site-packages/matplotlib-override
  EOS
end


text:
package org.openehealth.ipf.commons.ihe.xds.core.transform.ebxml.ebxml30;

import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLFactory;
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.EbXMLFactory30;
import org.openehealth.ipf.commons.ihe.xds.core.transform.ebxml.FolderTransformer;
import org.openehealth.ipf.commons.ihe.xds.core.transform.ebxml.FolderTransformerTestBase;

/**
 * Tests for {@link FolderTransformer}.
 * @author Jens Riemschneider
 */
public class FolderTransformerTest extends FolderTransformerTestBase {
    @Override
    public EbXMLFactory createFactory() {
        return new EbXMLFactory30();
    }
}


text:
require 'ebay/types/item'

module Ebay # :nodoc:
  module Requests # :nodoc:
    # == Attributes
    #  object_node :item, 'Item', :class => Item, :optional => true
    #  value_array_node :deleted_fields, 'DeletedField', :default_value => []
    class VerifyRelistItem < Abstract
      include XML::Mapping
      include Initializer
      root_element_name 'VerifyRelistItemRequest'
      object_node :item, 'Item', :class => Item, :optional => true
      value_array_node :deleted_fields, 'DeletedField', :default_value => []
    end
  end
end


text:
import json

class CommandHandler:
  def __init__(self, request):
      assert isinstance(request, dict)
      self._request=request

  def execute_command(self):
      _command=self._request.get('command', None)

      if _command is None:
         return "invalid request"

      if _command == 'list_files':
         return self.list_files()
      elif _command == 'read_file':
         return self.read_file()
      elif _command == 'write_file':
         return self.write_file()
      elif _command == 'rm_file':
         return self.rm_file()

      return "invalid command"

  def list_files(self):
      _dir=self._request.get('directory', '/')

      #retrieve a list of files this person has access to.
      return json.dumps(self._list_files(_dir))

  def read_file(self):
      _filename=self._request['filename']
      return self._read_file(_filename)

  def write_file(self):
      _fileobj=self._request['fileobj']  #already a json string!
      if self._write_file(_fileobj):
         return json.dumps({'status': 'Okay', 'message': 'File saved successfully!'})

      #something went wrong...
      return json.dumps({'status': 'Error', 'message': 'File not saved..'})

  def rm_file(self):
      _filename=self._request['filename']
      return self._rm_file(_filename)

  def _list_files(self, directory):
      pass

  def _read_file(self, filename):
      pass

  def _write_file(self, filename, contents):
      pass

  def _rm_file(self, filename):
      pass


text:
package org.glamey.training.codes.strings;

/**
 * 字符串中,找到连续的最长的数字字符串
 * <p>
 * https://www.nowcoder.com/practice/bd891093881d4ddf9e56e7cc8416562d?tpId=179&&tqId=34157&rp=1&ru=/activity/oj&qru
 * =/ta/exam-other/question-ranking
 */
public class LongestContinueNumbers {

    public static void main(String[] args) {
        System.out.println(getLongestContinueNumbers("abcd12345ed125ss123456789"));
        System.out.println(getLongestContinueNumbers("abc"));
        System.out.println(getLongestContinueNumbers("123a"));
        System.out.println(getLongestContinueNumbers("a23"));

        System.out.println(analyzerCharNum("dabcab"));
    }

    public static String analyzerCharNum(String source) {
        if (source == null || "".equals(source)) {
            return "";
        }

        int[] nums = new int[26];
        for (int i = 0; i < source.length(); i++) {
            nums[source.charAt(i) - 'a']++;
        }

        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] > 0) {
                char c = (char) (nums[i] + 'a');
                System.out.println(c);
                buffer.append(c).append(nums[i]);
            }
        }
        return buffer.toString();
    }

    public static String getLongestContinueNumbers(String source) {
        if (source == null || "".equals(source)) {
            return "";
        }
        int maxLen = 0, end = 0, count = 0;
        for (int i = 0; i < source.length(); i++) {
            if (source.charAt(i) < '0' || source.charAt(i) > '9') {
                count = 0;
                continue;
            }
            count++;
            if (maxLen < count) {
                maxLen = count;
                end = i;
            }
        }
        return maxLen > 0 ? source.substring(end - maxLen + 1, end + 1) : "";
    }
}


text:
package org.apache.hadoop.hive.ql.optimizer;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;

import org.apache.hadoop.hive.common.JavaUtils;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.api.Order;
import org.apache.hadoop.hive.ql.ErrorMsg;
import org.apache.hadoop.hive.ql.exec.DummyStoreOperator;
import org.apache.hadoop.hive.ql.exec.JoinOperator;
import org.apache.hadoop.hive.ql.exec.MapJoinOperator;
import org.apache.hadoop.hive.ql.exec.Operator;
import org.apache.hadoop.hive.ql.exec.ReduceSinkOperator;
import org.apache.hadoop.hive.ql.exec.SMBMapJoinOperator;
import org.apache.hadoop.hive.ql.exec.TableScanOperator;
import org.apache.hadoop.hive.ql.lib.Node;
import org.apache.hadoop.hive.ql.lib.NodeProcessor;
import org.apache.hadoop.hive.ql.lib.NodeProcessorCtx;
import org.apache.hadoop.hive.ql.metadata.Partition;
import org.apache.hadoop.hive.ql.metadata.Table;
import org.apache.hadoop.hive.ql.parse.ParseContext;
import org.apache.hadoop.hive.ql.parse.PrunedPartitionList;
import org.apache.hadoop.hive.ql.parse.QB;
import org.apache.hadoop.hive.ql.parse.SemanticException;
import org.apache.hadoop.hive.ql.parse.TableAccessAnalyzer;
import org.apache.hadoop.hive.ql.plan.ExprNodeDesc;
import org.apache.hadoop.hive.ql.plan.JoinCondDesc;
import org.apache.hadoop.hive.ql.plan.JoinDesc;
import org.apache.hadoop.hive.ql.plan.OperatorDesc;
import org.apache.hadoop.hive.ql.plan.ReduceSinkDesc;
import org.apache.hadoop.hive.ql.plan.SMBJoinDesc;
import org.apache.hadoop.util.ReflectionUtils;

//try to replace a bucket map join with a sorted merge map join
abstract public class AbstractSMBJoinProc extends AbstractBucketJoinProc implements NodeProcessor {

  public AbstractSMBJoinProc(ParseContext pctx) {
    super(pctx);
  }

  public AbstractSMBJoinProc() {
    super();
  }

  @Override
  abstract public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx,
         Object... nodeOutputs) throws SemanticException;

  /*
   * Return true or false based on whether a bucketed mapjoin can be converted successfully to
   * a sort-merge map join operator. The following checks are performed:
   * a. The mapjoin under consideration is a bucketed mapjoin.
   * b. All the tables are sorted in same order, such that join columns is equal to or a prefix
   *    of the sort columns.
   */
  protected boolean canConvertBucketMapJoinToSMBJoin(MapJoinOperator mapJoinOp,
    Stack<Node> stack,
    SortBucketJoinProcCtx smbJoinContext,
    Object... nodeOutputs) throws SemanticException {

    // Check whether the mapjoin is a bucketed mapjoin.
    // The above can be ascertained by checking the big table bucket -> small table buckets
    // mapping in the mapjoin descriptor.
    // First check if this map-join operator is already a BucketMapJoin or not. If not give up
    // we are only trying to convert a BucketMapJoin to sort-BucketMapJoin.
    if (mapJoinOp.getConf().getAliasBucketFileNameMapping() == null
      || mapJoinOp.getConf().getAliasBucketFileNameMapping().size() == 0) {
      return false;
    }

    if (!this.pGraphContext.getMapJoinOps().contains(mapJoinOp)) {
      return false;
    }

    String[] srcs = mapJoinOp.getConf().getBaseSrc();
    for (int srcPos = 0; srcPos < srcs.length; srcPos++) {
      srcs[srcPos] = QB.getAppendedAliasFromId(mapJoinOp.getConf().getId(), srcs[srcPos]);
    }

    boolean tableEligibleForBucketedSortMergeJoin = true;

    // All the tables/partitions columns should be sorted in the same order
    // For example, if tables A and B are being joined on columns c1, c2 and c3
    // which are the sorted and bucketed columns. The join would work, as long
    // c1, c2 and c3 are sorted in the same order.
    List<Order> sortColumnsFirstTable = new ArrayList<Order>();

    for (int pos = 0; pos < srcs.length; pos++) {
      tableEligibleForBucketedSortMergeJoin = tableEligibleForBucketedSortMergeJoin
        && isEligibleForBucketSortMergeJoin(smbJoinContext,
             mapJoinOp.getConf().getKeys().get((byte) pos),
             mapJoinOp.getConf().getAliasToOpInfo(),
             srcs,
             pos,
             sortColumnsFirstTable);
    }
    if (!tableEligibleForBucketedSortMergeJoin) {
      // this is a mapjoin but not suited for a sort merge bucket map join. check outer joins
      if (MapJoinProcessor.checkMapJoin(mapJoinOp.getConf().getPosBigTable(),
            mapJoinOp.getConf().getConds()) < 0) {
        throw new SemanticException(
            ErrorMsg.INVALID_BIGTABLE_MAPJOIN.format(mapJoinOp.getConf().getBigTableAlias()));
      }
      return false;
    }

    smbJoinContext.setSrcs(srcs);
    return true;
  }

  // Convert the bucket map-join operator to a sort-merge map join operator
  protected SMBMapJoinOperator convertBucketMapJoinToSMBJoin(MapJoinOperator mapJoinOp,
    SortBucketJoinProcCtx smbJoinContext) {

    String[] srcs = smbJoinContext.getSrcs();
    SMBMapJoinOperator smbJop = new SMBMapJoinOperator(mapJoinOp);
    SMBJoinDesc smbJoinDesc = new SMBJoinDesc(mapJoinOp.getConf());
    smbJop.setConf(smbJoinDesc);
    HashMap<Byte, String> tagToAlias = new HashMap<Byte, String>();
    for (int i = 0; i < srcs.length; i++) {
      tagToAlias.put((byte) i, srcs[i]);
    }
    smbJoinDesc.setTagToAlias(tagToAlias);

    int indexInListMapJoinNoReducer =
      this.pGraphContext.getListMapJoinOpsNoReducer().indexOf(mapJoinOp);
    if (indexInListMapJoinNoReducer >= 0 ) {
      this.pGraphContext.getListMapJoinOpsNoReducer().remove(indexInListMapJoinNoReducer);
      this.pGraphContext.getListMapJoinOpsNoReducer().add(indexInListMapJoinNoReducer, smbJop);
    }

    Map<String, DummyStoreOperator> aliasToSink =
        new HashMap<String, DummyStoreOperator>();
    // For all parents (other than the big table), insert a dummy store operator
    /* Consider a query like:
     *
     * select * from
     *   (subq1 --> has a filter)
     *   join
     *   (subq2 --> has a filter)
     * on some key
     *
     * Let us assume that subq1 is the small table (either specified by the user or inferred
     * automatically). The following operator tree will be created:
     *
     * TableScan (subq1) --> Select --> Filter --> DummyStore
     *                                                         \
     *                                                          \     SMBJoin
     *                                                          /
     *                                                         /
     * TableScan (subq2) --> Select --> Filter
     */

    List<Operator<? extends OperatorDesc>> parentOperators = mapJoinOp.getParentOperators();
    for (int i = 0; i < parentOperators.size(); i++) {
      Operator<? extends OperatorDesc> par = parentOperators.get(i);
      int index = par.getChildOperators().indexOf(mapJoinOp);
      par.getChildOperators().remove(index);
      if (i == smbJoinDesc.getPosBigTable()) {
        par.getChildOperators().add(index, smbJop);
      }
      else {
        DummyStoreOperator dummyStoreOp = new DummyStoreOperator(par.getCompilationOpContext());
        par.getChildOperators().add(index, dummyStoreOp);

        List<Operator<? extends OperatorDesc>> childrenOps =
            new ArrayList<Operator<? extends OperatorDesc>>();
        childrenOps.add(smbJop);
        dummyStoreOp.setChildOperators(childrenOps);

        List<Operator<? extends OperatorDesc>> parentOps =
            new ArrayList<Operator<? extends OperatorDesc>>();
        parentOps.add(par);
        dummyStoreOp.setParentOperators(parentOps);

        aliasToSink.put(srcs[i], dummyStoreOp);
        smbJop.getParentOperators().remove(i);
        smbJop.getParentOperators().add(i, dummyStoreOp);
      }
    }
    smbJoinDesc.setAliasToSink(aliasToSink);

    List<Operator<? extends OperatorDesc>> childOps = mapJoinOp.getChildOperators();
    for (int i = 0; i < childOps.size(); i++) {
      Operator<? extends OperatorDesc> child = childOps.get(i);
      int index = child.getParentOperators().indexOf(mapJoinOp);
      child.getParentOperators().remove(index);
      child.getParentOperators().add(index, smbJop);
    }

    // Data structures coming from QBJoinTree
    smbJop.getConf().setQBJoinTreeProps(mapJoinOp.getConf());
    //
    pGraphContext.getSmbMapJoinOps().add(smbJop);
    pGraphContext.getMapJoinOps().remove(mapJoinOp);

    return smbJop;
  }

  /**
   * Whether this table is eligible for a sort-merge join.
   *
   * @param pctx                  parse context
   * @param op                    map join operator being considered
   * @param joinTree              join tree being considered
   * @param alias                 table alias in the join tree being checked
   * @param pos                   position of the table
   * @param sortColumnsFirstTable The names and order of the sorted columns for the first table.
   *                              It is not initialized when pos = 0.
   * @return
   * @throws SemanticException
   */
  private boolean isEligibleForBucketSortMergeJoin(
    SortBucketJoinProcCtx smbJoinContext,
    List<ExprNodeDesc> keys,
    Map<String, Operator<? extends OperatorDesc>> aliasToOpInfo,
    String[] aliases,
    int pos,
    List<Order> sortColumnsFirstTable) throws SemanticException {
    String alias = aliases[pos];

    /*
     * Consider a query like:
     *
     * select -- mapjoin(subq1) --  * from
     * (select a.key, a.value from tbl1 a) subq1
     *   join
     * (select a.key, a.value from tbl2 a) subq2
     * on subq1.key = subq2.key;
     *
     * aliasToOpInfo contains the SelectOperator for subq1 and subq2.
     * We need to traverse the tree (using TableAccessAnalyzer) to get to the base
     * table. If the object being map-joined is a base table, then aliasToOpInfo
     * contains the TableScanOperator, and TableAccessAnalyzer is a no-op.
     */
    Operator<? extends OperatorDesc> topOp = aliasToOpInfo.get(alias);
    if (topOp == null) {
      return false;
    }

    // get all join columns from join keys
    List<String> joinCols = toColumns(keys);
    if (joinCols == null || joinCols.isEmpty()) {
      return false;
    }

    TableScanOperator tso = TableAccessAnalyzer.genRootTableScan(topOp, joinCols);
    if (tso == null) {
      return false;
    }

    // For nested sub-queries, the alias mapping is not maintained in QB currently.
    /*
     * Consider a query like:
     *
     * select count(*) from
     *   (
     *     select key, count(*) from
     *       (
     *         select --mapjoin(a)-- a.key as key, a.value as val1, b.value as val2
     *         from tbl1 a join tbl2 b on a.key = b.key
     *       ) subq1
     *     group by key
     *   ) subq2;
     *
     * The table alias should be subq2:subq1:a which needs to be fetched from topOps.
     */
    if (pGraphContext.getTopOps().containsValue(tso)) {
      for (Map.Entry<String, TableScanOperator> topOpEntry :
        this.pGraphContext.getTopOps().entrySet()) {
        if (topOpEntry.getValue() == tso) {
          alias = topOpEntry.getKey();
          aliases[pos] = alias;
          break;
        }
      }
    }
    else {
      // Ideally, this should never happen, and this should be an assert.
      return false;
    }

    Table tbl = tso.getConf().getTableMetadata();
    if (tbl.isPartitioned()) {
      PrunedPartitionList prunedParts = pGraphContext.getPrunedPartitions(alias, tso);
      List<Partition> partitions = prunedParts.getNotDeniedPartns();
      // Populate the names and order of columns for the first partition of the
      // first table
      if ((pos == 0) && (partitions != null) && (!partitions.isEmpty())) {
        Partition firstPartition = partitions.get(0);
        sortColumnsFirstTable.addAll(firstPartition.getSortCols());
      }

      for (Partition partition : prunedParts.getNotDeniedPartns()) {
        if (!checkSortColsAndJoinCols(partition.getSortCols(),
          joinCols,
          sortColumnsFirstTable)) {
          return false;
        }
      }
      return true;
    }

    // Populate the names and order of columns for the first table
    if (pos == 0) {
      sortColumnsFirstTable.addAll(tbl.getSortCols());
    }

    return checkSortColsAndJoinCols(tbl.getSortCols(),
      joinCols,
      sortColumnsFirstTable);
  }

  private boolean checkSortColsAndJoinCols(List<Order> sortCols,
      List<String> joinCols,
      List<Order> sortColumnsFirstPartition) {

    if (sortCols == null || sortCols.size() < joinCols.size()) {
      return false;
    }

    // A join is eligible for a sort-merge join, only if it is eligible for
    // a bucketized map join. So, we dont need to check for bucketized map
    // join here. We are guaranteed that the join keys contain all the
    // bucketized keys (note that the order need not be the same).
    List<String> sortColNames = new ArrayList<String>();

    // The join columns should contain all the sort columns
    // The sort columns of all the tables should be in the same order
    // compare the column names and the order with the first table/partition.
    for (int pos = 0; pos < sortCols.size(); pos++) {
      Order o = sortCols.get(pos);

      if (pos < sortColumnsFirstPartition.size()) {
        if (o.getOrder() != sortColumnsFirstPartition.get(pos).getOrder()) {
          return false;
        }
      }
      sortColNames.add(o.getCol());
    }

    // The column names and order (ascending/descending) matched
    // The first 'n' sorted columns should be the same as the joinCols, where
    // 'n' is the size of join columns.
    // For eg: if the table is sorted by (a,b,c), it is OK to convert if the join is
    // on (a), (a,b), or any combination of (a,b,c):
    //   (a,b,c), (a,c,b), (c,a,b), (c,b,a), (b,c,a), (b,a,c)
    // but it is not OK to convert if the join is on (a,c)
    return sortColNames.subList(0, joinCols.size()).containsAll(joinCols);
  }

  // Can the join operator be converted to a sort-merge join operator ?
  // It is already verified that the join can be converted to a bucket map join
  protected boolean checkConvertJoinToSMBJoin(
      JoinOperator joinOperator,
      SortBucketJoinProcCtx smbJoinContext) throws SemanticException {

    if (!this.pGraphContext.getJoinOps().contains(joinOperator)) {
      return false;
    }

    String[] srcs = joinOperator.getConf().getBaseSrc();

    // All the tables/partitions columns should be sorted in the same order
    // For example, if tables A and B are being joined on columns c1, c2 and c3
    // which are the sorted and bucketed columns. The join would work, as long
    // c1, c2 and c3 are sorted in the same order.
    List<Order> sortColumnsFirstTable = new ArrayList<Order>();

    for (int pos = 0; pos < srcs.length; pos++) {
      if (!isEligibleForBucketSortMergeJoin(smbJoinContext,
          smbJoinContext.getKeyExprMap().get((byte) pos),
          joinOperator.getConf().getAliasToOpInfo(),
          srcs,
          pos,
          sortColumnsFirstTable)) {
        return false;
      }
    }

    smbJoinContext.setSrcs(srcs);
    return true;
  }

  // Can the join operator be converted to a sort-merge join operator ?
  protected boolean canConvertJoinToSMBJoin(
    JoinOperator joinOperator,
    SortBucketJoinProcCtx smbJoinContext) throws SemanticException {
    boolean canConvert =
      canConvertJoinToBucketMapJoin(
        joinOperator,
        smbJoinContext
      );

    if (!canConvert) {
      return false;
    }

    return checkConvertJoinToSMBJoin(joinOperator, smbJoinContext);
  }

  // Can the join operator be converted to a bucket map-merge join operator ?
  @SuppressWarnings("unchecked")
  protected boolean canConvertJoinToBucketMapJoin(
    JoinOperator joinOp,
    SortBucketJoinProcCtx context) throws SemanticException {

    // This has already been inspected and rejected
    if (context.getRejectedJoinOps().contains(joinOp)) {
      return false;
    }

    if (!this.pGraphContext.getJoinOps().contains(joinOp)) {
      return false;
    }

    Class<? extends BigTableSelectorForAutoSMJ> bigTableMatcherClass = null;
    try {
      String selector = HiveConf.getVar(pGraphContext.getConf(),
          HiveConf.ConfVars.HIVE_AUTO_SORTMERGE_JOIN_BIGTABLE_SELECTOR);
      bigTableMatcherClass =
        JavaUtils.loadClass(selector);
    } catch (ClassNotFoundException e) {
      throw new SemanticException(e.getMessage());
    }

    BigTableSelectorForAutoSMJ bigTableMatcher =
      ReflectionUtils.newInstance(bigTableMatcherClass, null);
    JoinDesc joinDesc = joinOp.getConf();
    JoinCondDesc[] joinCondns = joinDesc.getConds();
    Set<Integer> joinCandidates = MapJoinProcessor.getBigTableCandidates(joinCondns);
    if (joinCandidates.isEmpty()) {
      // This is a full outer join. This can never be a map-join
      // of any type. So return false.
      return false;
    }
    int bigTablePosition =
      bigTableMatcher.getBigTablePosition(pGraphContext, joinOp, joinCandidates);
    if (bigTablePosition < 0) {
      // contains aliases from sub-query
      return false;
    }
    context.setBigTablePosition(bigTablePosition);
    String joinAlias =
      bigTablePosition == 0 ?
        joinOp.getConf().getLeftAlias() :
        joinOp.getConf().getRightAliases()[bigTablePosition - 1];
    joinAlias = QB.getAppendedAliasFromId(joinOp.getConf().getId(), joinAlias);

    Map<Byte, List<ExprNodeDesc>> keyExprMap  = new HashMap<Byte, List<ExprNodeDesc>>();
    List<Operator<? extends OperatorDesc>> parentOps = joinOp.getParentOperators();
    // get the join keys from parent ReduceSink operators
    for (Operator<? extends OperatorDesc> parentOp : parentOps) {
      ReduceSinkDesc rsconf = ((ReduceSinkOperator)parentOp).getConf();
      Byte tag = (byte) rsconf.getTag();
      List<ExprNodeDesc> keys = rsconf.getKeyCols();
      keyExprMap.put(tag, keys);
    }

    context.setKeyExprMap(keyExprMap);
    // Make a deep copy of the aliases so that they are not changed in the context
    String[] joinSrcs = joinOp.getConf().getBaseSrc();
    String[] srcs = new String[joinSrcs.length];
    for (int srcPos = 0; srcPos < joinSrcs.length; srcPos++) {
      joinSrcs[srcPos] = QB.getAppendedAliasFromId(joinOp.getConf().getId(), joinSrcs[srcPos]);
      srcs[srcPos] = new String(joinSrcs[srcPos]);
    }

    // Given a candidate map-join, can this join be converted.
    // The candidate map-join was derived from the pluggable sort merge join big
    // table matcher.
    return checkConvertBucketMapJoin(
      context,
      joinOp.getConf().getAliasToOpInfo(),
      keyExprMap,
      joinAlias,
      Arrays.asList(srcs));
  }

  // Convert the join operator to a bucket map-join join operator
  protected MapJoinOperator convertJoinToBucketMapJoin(
    JoinOperator joinOp,
    SortBucketJoinProcCtx joinContext) throws SemanticException {
    MapJoinOperator mapJoinOp = new MapJoinProcessor().convertMapJoin(
      pGraphContext.getConf(),
      joinOp,
      joinOp.getConf().isLeftInputJoin(),
      joinOp.getConf().getBaseSrc(),
      joinOp.getConf().getMapAliases(),
      joinContext.getBigTablePosition(),
      false,
      false);
    // Remove the join operator from the query join context
    // Data structures coming from QBJoinTree
    mapJoinOp.getConf().setQBJoinTreeProps(joinOp.getConf());
    //
    pGraphContext.getMapJoinOps().add(mapJoinOp);
    pGraphContext.getJoinOps().remove(joinOp);
    convertMapJoinToBucketMapJoin(mapJoinOp, joinContext);
    return mapJoinOp;
  }

  // Convert the join operator to a sort-merge join operator
  protected void convertJoinToSMBJoin(
    JoinOperator joinOp,
    SortBucketJoinProcCtx smbJoinContext) throws SemanticException {
    MapJoinOperator mapJoinOp = convertJoinToBucketMapJoin(joinOp, smbJoinContext);
    SMBMapJoinOperator smbMapJoinOp =
        convertBucketMapJoinToSMBJoin(mapJoinOp, smbJoinContext);
    smbMapJoinOp.setConvertedAutomaticallySMBJoin(true);
  }
}


text:
using FluentValidation;
using ReMi.Common.Cqrs.FluentValidation;
using ReMi.Queries.BusinessRules;

namespace ReMi.QueryValidators.BusinessRules
{
    public class GetBusinessRuleValidator : RequestValidatorBase<GetBusinessRuleRequest>
    {
        public GetBusinessRuleValidator()
        {
            RuleFor(x => x)
                .Must(x => !string.IsNullOrEmpty(x.Name) || x.ExternalId.HasValue)
                .WithName("Name or ExternalId")
                .WithMessage("Rule Name or ExternalId has to be provided");
        }
    }
}


text:
"""
Created on Sat Mar 26 11:48:26 2016

@author: Felipe Galvão
"""

from lxml import html
import requests
import re
import pandas as pd
import pickle
import time
import os.path

# Remove attributes from links in a list and return "clean" list
def remove_attributes_from_link(comic_link_list):
    clean_comic_link_list = []
    for comic_link in comic_link_list:
        # Substituir tudo após a "?" por nada
        new_comic_link = re.sub("(\?.+)","",comic_link)
        clean_comic_link_list.append(new_comic_link)
    return(clean_comic_link_list)

# Return list with links of publishers
def get_publishers_links():
    publisher_links = []

    # Iterate through each page of the link Browse > by Publisher
    for i in range(1,5):
        # Definition of the link to be scraped
        link = 'https://www.comixology.com/browse-publisher?publisherList_pg='
        page = requests.get(link+str(i))
        tree = html.fromstring(page.content)

        # Xpath expression for extraction of Publishers' links
        quantity_pub_xpath = '//div[@class="list publisherList"]/ul'
        quantity_pub_xpath += '/li[@class="content-item"]/figure/div/a/@href'

        # Extraction of links through Xpath function
        extracted_publishers_links = tree.xpath(quantity_pub_xpath)
        clean_publisher_links = remove_attributes_from_link(
            extracted_publishers_links)
        # Insert links into the already created list
        publisher_links.extend(clean_publisher_links)

    return(publisher_links)

# Receive list of links for each Publisher and return list of links for the
# Comics Series
def get_series_links_from_publisher(publisher_links):
    series_links = []

    for link in publisher_links:
        page = requests.get(link)
        tree = html.fromstring(page.content)

        # Xpath string for extraction of total quantity of Series
        xpath_series = '//div[@class="list seriesList"]/div[@class="pager"]'
        xpath_series += '/div[@class="pager-text"]/text()'

        total_series = tree.xpath(xpath_series)

        # If the extraction returned the total quantity
        if total_series:
            # The only item in the list is a string with the quantity, which
            # we will split to create a list with each word of it
            total_series = total_series[0].split()
            # Quantity of series will be the last item of that series
            total_series = int(total_series[len(total_series)-1])
            # Divide the quantity of Series by 36, in order to discover the
            # number of pages of Series in this Publisher
            if total_series % 36 == 0:
                number_of_pages = (total_series // 36)
            else:
                number_of_pages = (total_series // 36) + 1
        # If the extraction returns an empty list, there is only one page of Series
        else:
            number_of_pages = 1
        for page_number in range(1,number_of_pages+1):
            page = requests.get(link+'?seriesList_pg='+str(page_number))
            tree = html.fromstring(page.content)

            # Xpath for extraction of the Series links in this page
            xpath_series_links = '//div[@class="list seriesList"]/ul/'
            xpath_series_links += 'li[@class="content-item"]/figure/'
            xpath_series_links += 'div[@class="content-cover"]/a/@href'
            extracted_series_links = tree.xpath(xpath_series_links)
            clean_series_links = remove_attributes_from_link(extracted_series_links)
            series_links.extend(clean_series_links)
    return(series_links)

def extract_comics_links(link, div_xpath, page_link_str, tree):
    type_comics_links = []
    # Check if the div for this type of comic exists
    type_div = tree.xpath(div_xpath)

    if type_div:
        # Get the total quantity of comics for this type of comic
        total_quantity_xpath = div_xpath + '/div[@class="pager"]/'
        total_quantity_xpath += 'div[@class="pager-text"]/text()'
        total_type = tree.xpath(total_quantity_xpath)
        if total_type:
            total_type = total_type[0].split()
            total_type = int(total_type[len(total_type)-1])
            if total_type % 18 == 0:
                number_of_pages = (total_type // 18)
            else:
                number_of_pages = (total_type // 18) + 1
        else:
            number_of_pages = 1
        for page_number in range(1,number_of_pages+1):
            page = requests.get(link+page_link_str+str(page_number))
            tree = html.fromstring(page.content)
            # Path for the links to this type of comic
            type_links_xpath = div_xpath + '/ul/li/figure/div/a/@href'
            type_links = tree.xpath(type_links_xpath)
            clean_type_links = remove_attributes_from_link(type_links)
            type_comics_links.extend(clean_type_links)
    return(type_comics_links)

def comics_links_dump(comics_links, counter, comics_links_counter):
    pickle.dump(comics_links, open("comics_links_files/comics_links" +
                "_" + str((counter + comics_links_counter) // 100 + 1)
                + ".p","wb"))
    pickle.dump(counter + comics_links_counter,
                open("comics_links_files/comics_links_counter.p","wb"))
    comics_links = []
    return(comics_links)

def get_issues_links_from_series(series_links, comics_links_counter):
    comics_links = []

    for counter, link in enumerate(series_links):
        page = requests.get(link)
        tree = html.fromstring(page.content)

# -------------------------------------------------------------- #
        # Scraping code for the collected editions
# -------------------------------------------------------------- #

        collected_div_xpath = '//div[@class="list CollectedEditions"]'
        collected_link_str = '?CollectedEditions_pg='

        collected_links = extract_comics_links(link, collected_div_xpath,
                                               collected_link_str, tree)

# -------------------------------------------------------------- #
        # Scraping code for the Issues
# -------------------------------------------------------------- #
        issues_div_xpath = '//div[@class="list Issues"]'
        issues_link_str = '?Issues_pg='

        issues_links = extract_comics_links(link, issues_div_xpath,
                                            issues_link_str, tree)

# -------------------------------------------------------------- #
        # Scraping code for the Omnibuses
# -------------------------------------------------------------- #
        omnibuses_div_xpath = '//div[@class="list Omnibuses"]'
        omnibuses_link_str = '?Omnibuses_pg='

        omnibuses_links = extract_comics_links(link, omnibuses_div_xpath,
                                               omnibuses_link_str, tree)

# -------------------------------------------------------------- #
        # Scraping code for the One-Shots
# -------------------------------------------------------------- #
        oneshots_div_xpath = '//div[@class="list OneShots"]'
        oneshots_link_str = '?Oneshots_pg='

        oneshots_links = extract_comics_links(link, oneshots_div_xpath,
                                              oneshots_link_str, tree)

# -------------------------------------------------------------- #
        # Scraping code for the Bandees Dessinees
# -------------------------------------------------------------- #
        bandes_div_xpath = '//div[@class="list BandesDessines"]'
        bandes_link_str = '?BandeesDessinees_pg='

        bandes_links = extract_comics_links(link, bandes_div_xpath,
                                              bandes_link_str, tree)

# -------------------------------------------------------------- #
        # Scraping code for the Graphic Novels
# -------------------------------------------------------------- #
        graphicnovels_div_xpath = '//div[@class="list GraphicNovels"]'
        graphicnovels_link_str = '?GraphicNovels_pg='

        graphicnovels_links = extract_comics_links(link, graphicnovels_div_xpath,
                                              graphicnovels_link_str, tree)

# -------------------------------------------------------------- #
        # Scraping code for the Extras
# -------------------------------------------------------------- #
        extras_div_xpath = '//div[@class="list Extras"]'
        extras_link_str = '?Extras_pg='

        extras_links = extract_comics_links(link, extras_div_xpath,
                                              extras_link_str, tree)

# -------------------------------------------------------------- #
        # Scraping code for Artbooks
# -------------------------------------------------------------- #
        artbooks_div_xpath = '//div[@class="list Artbooks"]'
        artbooks_link_str = '?Artbooks_pg='

        artbooks_links = extract_comics_links(link, artbooks_div_xpath,
                                              artbooks_link_str, tree)

        # Add links to all kinds of comics in the list previously created
        comics_links.extend(collected_links + issues_links + omnibuses_links +
                            oneshots_links + bandes_links + graphicnovels_links +
                            extras_links + artbooks_links)

        # Export links each time 100 links are visited, avoiding loss of information
		# due to possible errors
        if (counter % 100 == 0 and counter != 0) or (
            counter == len(series_links) - 1):
            comics_links = comics_links_dump(comics_links, counter,
                                             comics_links_counter)
    return(comics_links)

def get_comic_info_from_page(link):
    comic_info = {}

    page = requests.get(link)
    tree = html.fromstring(page.content)

    # Define the base path that contains the content of the page
    base_path = '//div[@class="comic_view detail-container"]'

     # Extract the title of the page, to check if this address returns a 404 error
    page_title = tree.xpath('//title/text()')[0]
    if page_title != 'Site Error - Comics by comiXology':
        # Extract the name of the comic
        name = tree.xpath('//h2[@itemprop="name"]/text()')
        comic_info['Name'] = name[0]

        # Extract list of tasks from credits and names that execute each task
        credits_tasks_str = base_path + '/div[@id="column3"]/'
        credits_tasks_str += 'div[@class="credits"]/div/dl/dt/text()'
        credits_tasks = tree.xpath(credits_tasks_str)

        credits_names_str = base_path + '/div[@id="column3"]/'
        credits_names_str += 'div[@class="credits"]/div/dl/dd/a/text()'
        credits_names = tree.xpath(credits_names_str)

        # ---------------------------------------------------------------------
        # Fix names, remove scape sequences and create new list of names
        # ---------------------------------------------------------------------
        credits_names_lists = []

        first_item = 0
        for counter, name in enumerate(credits_names):
            if name == 'HIDE...':
                credits_names_lists.append(credits_names[first_item:counter])
                first_item = counter+1

        new_names = []
        new_names_credits = []

        for names_list in credits_names_lists:
            for name in names_list:
                new_name = re.sub("^\\n\\t\\t\\t\\t\\t\\t\\t","", name)
                new_name = re.sub("\\t\\t\\t\\t\\t\\t$", "", new_name)
                if new_name != "More...":
                    new_names.append(new_name)
            new_names_credits.append(new_names)
            new_names = []
        # ---------------------------------------------------------------------
        # End of name fixing
        # ---------------------------------------------------------------------

        # Insert each credits information in the comic_info dictionary
        for counter, item in enumerate(credits_tasks):
            comic_info[item] = new_names_credits[counter]

        # Extract Publisher of comic
        publisher = tree.xpath('//*[@id="column3"]/div/div[1]/a[2]/span/text()')
        publisher = re.sub("^\\n\\t\\t\\t","",publisher[0])
        publisher = re.sub("\\t\\t$","",publisher)
        comic_info['Publisher'] = publisher

        # Extract list of informations of the comic, such as page count,
		# age classification, etc
        comics_infos_names_xpath = base_path + '/div[@id="column3"]/'
        comics_infos_names_xpath += 'div[@class="credits"]/'
        comics_infos_names_xpath += 'h4[@class="subtitle"]/text()'
        comics_infos_names = tree.xpath(comics_infos_names_xpath)

        comics_infos_values_xpath = base_path + '/div[@id="column3"]/'
        comics_infos_values_xpath += 'div[@class="credits"]/'
        comics_infos_values_xpath += 'div[@class="aboutText"]/text()'
        comics_infos_values = tree.xpath(comics_infos_values_xpath)

        # Add the information of the comic into the dictionary
        for counter, item in enumerate(comics_infos_names):
            if item == 'Page Count':
                comic_info[item] = int(comics_infos_values[counter].split()[0])
            else:
                comic_info[item] = comics_infos_values[counter]

        # Extract prices from the comic
        full_price_xpath = '//h6[@class="item-full-price"]/text()'
        # Extract full price
        full_price = tree.xpath(full_price_xpath)
        discounted_price_xpath = '//div[@class="pricing-info"]/'
        discounted_price_xpath += 'h5[@class="item-price"]/text()'
        # Extract discounted price, if it exists
        discounted_price = tree.xpath(discounted_price_xpath)
        if discounted_price:
            # If discounted price is equal to the string FREE, this is a free comic
            if discounted_price[0] == 'FREE':
                final_price = 0.0
            # If it is not, extract the final price
            else:
                final_price = float(discounted_price[0][1:])
            # If there is a full price, the comic has a discounted price too
            if full_price:
                original_price = float(full_price[0][1:])
                discounted = True
            # If there is not, the prices are equal and there is no discount
            else:
                original_price = final_price
                discounted = False
        # Comics exclusive to bundles
        else:
            final_price = None
            original_price = None
            discounted = False
        comic_info['Original_price'] = original_price
        comic_info['Final_price'] = final_price
        comic_info['Discounted'] = discounted

        # Extract comic rating from the hidden element
        ratings_value_xpath = '//*[@id="column2"]/div[2]/div[2]/div[2]/text()'
        ratings_value = tree.xpath(ratings_value_xpath)
        if ratings_value:
            ratings_value = ratings_value[0]
            ratings_value = re.sub("^\\n\\t\\t\\t\\t\\t\\t\\t","",ratings_value)
            ratings_value = int(re.sub("\\t\\t\\t\\t\\t\\t$","",ratings_value))
            comic_info['Rating'] = ratings_value
        else:
            comic_info['Rating'] = None

        # Extract comic's rating quantity
        ratings_quantity_xpath = '//*[@id="column2"]/div[2]/div[2]/div[1]/text()'
        ratings_quantity = tree.xpath(ratings_quantity_xpath)
        if ratings_quantity:
            ratings_quantity = ratings_quantity[0].split()[2]
            ratings_quantity = ratings_quantity[1:][:-2]
            comic_info['Ratings_Quantity'] = int(ratings_quantity)
        else:
            comic_info['Ratings_Quantity'] = 0

    return(comic_info)

def get_all_comics_info(comics_links, start_counter):
    all_comics_info = []
    for counter, link in enumerate(comics_links):
        comic_info = get_comic_info_from_page(link)
        if comic_info:
            all_comics_info.append(comic_info)
        if (counter % 100 == 0 and counter != 0) or (counter +
            start_counter == len(comics_links)-1):
            print(comic_info)
            pickle.dump(all_comics_info, open("Comics_info/comics_infos_" + "_" +
                        str((counter + start_counter) // 100) + ".p","wb"))
            pickle.dump(counter + start_counter,
                        open("Comics_info/counter_comics_info.p","wb"))
            all_comics_info = []

def join_comics_links():
    comics_links = []
    # For each file one the "comics_links_folder" folder
    for file in os.listdir("comics_links_folder"):
        temp_comics_links = pickle.load(open("comics_links_folder/" + file,"rb"))
        comics_links.append(temp_comics_links)
    return(comics_links)

def join_comics_info():
    comics_info = []
    # For each file in the "comics_info_files" folder
    for file in os.listdir("comics_info_files"):
        if file != "counter_comics_info.p" and file != "Comics_info_backup.7z":
            print(file)
            comic_info = pickle.load(open("comics_info_files/" + file,"rb"))
            for comic in comic_info:
                comics_info.append(comic)
    pickle.dump(comics_info, open("all_comics_info.p", "wb"))

# Check if the file publisher_links.p exists; if it does not, do the scraping
if os.path.isfile('publisher_links.p') == True:
    print("Arquivo de Links de Publishers já existe... carregando arquivo")
    publisher_links = pickle.load(open("publisher_links.p","rb"))
# If it does not, do the scraping
else:
    print("Arquivo de Links de Publishers não existe.")
    print("Iniciando o Scraping do site para links de Publishers.")
    print("Links serão exportados para o arquivo publisher_links.p")
    publisher_links = get_publishers_links()
    pickle.dump(publisher_links, open("publisher_links.p","wb"))

# Check if the series_links.p file exists
if os.path.isfile('series_links.p') == True:
    print("Arquivo de Links de Series já existe... carregando arquivo")
    series_links = pickle.load(open("series_links.p","rb"))
# If it does not, do the scraping
else:
    print("Arquivo de Links de Series não existe.")
    print("Iniciando o Scraping do site para links de Series.")
    print("Links serão exportados para o arquivo series_links.p")
    series_links = get_series_links_from_publisher(publisher_links)
    pickle.dump(series_links, open("series_links.p","wb"))

# Check if the file publisher_links.p exists; if it does not, do the scraping
if os.path.isfile('publisher_links.p') == True:
    print("Publisher links file already exists... loading file")
    publisher_links = pickle.load(open("publisher_links.p","rb"))
else:
    print("Publisher links file does not exists.")
    print("Scraping website for the publisher links")
    print("Links will be exported to publisher_links.p")
    publisher_links = get_publishers_links()
    pickle.dump(publisher_links, open("publisher_links.p","wb"))

# Check if the series_links.p file exists; if it does not, do the scraping
if os.path.isfile('series_links.p') == True:
    print("Series links file already exists... loading file")
    series_links = pickle.load(open("series_links.p","rb"))
else:
    print("Series links file does not exists.")
    print("Scraping website for the series links")
    print("Links will be exported to series_links.p")
    series_links = get_series_links_from_publisher(publisher_links)
    pickle.dump(series_links, open("series_links.p","wb"))

# Check if the comics_links_files folder exists
if os.path.isdir('comics_links_files'):
    print("Folder comics_links_files already exists. Checking for files")
    # Check if the counter for the scraping code exists
    if os.path.isfile('comics_links_files/comics_links_counter.p'):
        # Load the counter and check if the scraping process is complete
        comics_links_counter = pickle.load(open("comics_links_files/comics_links_counter.p","rb"))
        print("Current count: " + str(comics_links_counter+1) + " of " +
              str(len(series_links)))
        # If the scraping is complete, load the files
        if comics_links_counter + 1 == len(series_links):
            print("Scraping already completed. Loading files")
            comics_links = join_comics_links()
        # If the scraping is not complete, continue it
        else:
            print("Scraping initiated but not completed. Continuing...")
            get_issues_links_from_series(series_links[comics_links_counter+1:],
                                         comics_links_counter)
            comics_links = join_comics_links()
    # If the file does not exists, start the scraping
    else:
        print("Comics links extracting not started.")
        print("Starting comics links scraping")
        comics_links_counter = 0
        get_issues_links_from_series(series_links, comics_links_counter)
        comics_links = join_comics_links()
# If the folder does not exist, create the folder and start the scraping
else:
    print("Folder does not exists.")
    print("Creating folder comics_links_files")
    os.makedirs("comics_links_files")
    print("Starting comics links scraping")
    comics_links_counter = 0
    get_issues_links_from_series(series_links, comics_links_counter)
    comics_links = join_comics_links()

# Check if the comics_info_files folder exists
if os.path.isdir('comics_info_files'):
    print("Folder comics_info_files already exists. Checking for files")
    # Check if the counter file exists
    if os.path.isfile('comics_info_files/comics_info_counter.p'):
        # If it exists, load the counter
        comics_info_counter = pickle.load(open("comics_info_counter.p"))
        print("Current count: " + str(comics_info_counter+1) + " of " +
              str(len(comics_links)))
        # If the counter is equal to the quantity of items in the comics_links list
        if comics_info_counter + 1 == len(comics_links):
            print("Scraping already completed. Loading files")
        # If the counter is not equal to the quantity of items, continue
		# the scraping
        else:
            print("Scraping initiated but not completed. Continuing...")
            get_all_comics_info(comics_links[comics_info_counter+1:],
                                comics_info_counter)
    # If the counter does not exists, start the scraping
    else:
        print("Comics info extracting not started.")
        print("Starting comics info scraping")
        comics_info_counter = 0
        get_all_comics_info(comics_links, comics_info_counter)
# If the folder does not exists, create it and start the scraping
else:
    print("Folder does not exists.")
    print("Creating folder comics_info_files")
    os.makedirs("comics_info_files")
    print("Starting comics info scraping")
    comics_info_counter = 0
    get_all_comics_info(comics_links, comics_info_counter)

# Load information from comics and create a DataFrame with it
join_comics_info()
# Load information of all comics
comics_info = pickle.load(open("comics_info_files/all_comics_info.p","rb"))
# Create DataFrame with list of dictionaries
comics_df = pd.DataFrame(comics_info)
# We can create a CSV with it
comics_df.to_csv("comixology_comics_dataset.csv")


text:
function(ament_pep257)
  cmake_parse_arguments(ARG "" "TESTNAME" "" ${ARGN})
  if(NOT ARG_TESTNAME)
    set(ARG_TESTNAME "pep257")
  endif()

  find_program(ament_pep257_BIN NAMES "ament_pep257")
  if(NOT ament_pep257_BIN)
    message(FATAL_ERROR "ament_pep257() could not find program 'ament_pep257'")
  endif()

  set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${ARG_TESTNAME}.xunit.xml")
  set(cmd "${ament_pep257_BIN}" "--xunit-file" "${result_file}")
  list(APPEND cmd ${ARG_UNPARSED_ARGUMENTS})

  file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/ament_pep257")
  ament_add_test(
    "${ARG_TESTNAME}"
    COMMAND ${cmd}
    OUTPUT_FILE "${CMAKE_BINARY_DIR}/ament_pep257/${ARG_TESTNAME}.txt"
    RESULT_FILE "${result_file}"
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  )
  set_tests_properties(
    "${ARG_TESTNAME}"
    PROPERTIES
    LABELS "pep257;linter"
  )
endfunction()


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:orientation="horizontal">

    <ImageButton
        android:id="@+id/ibSort"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/image_button_background"
        android:contentDescription="@string/sort_dict_button"
        android:gravity="center_vertical"
        android:src="@drawable/ic_hamburger_alpha"/>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="vertical"
        android:paddingStart="5dp"
        tools:ignore="RtlSymmetry">

        <TextView
            android:id="@+id/tvName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:gravity="center_vertical"
            android:textSize="16sp"
            android:textStyle="bold"
            tools:text="name"/>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/tvCount"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:paddingStart="10dp"
                tools:text="Count"/>

            <TextView
                android:id="@+id/tvEnabled"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:paddingEnd="10dp"
                tools:text="Enabled"/>
        </RelativeLayout>
    </LinearLayout>
</LinearLayout>


text:
class RegionsController < ApplicationController
  # GET /regions
  # GET /regions.json
  def index
    @regions = Region.all
  end

  # GET /regions/1
  # GET /regions/1.json
  def show
  end

  # GET /regions/new
  def new
  end

  # GET /regions/1/edit
  def edit
  end

  # POST /regions
  # POST /regions.json
  def create
    @region = Region.new(region_params)

    respond_to do |format|
      if @region.save
        format.html { redirect_to admin_region_path(@region), notice: 'region was successfully created.' }
        format.json { render :show, status: :created, location: @region }
      else
        format.html { render :new }
        format.json { render json: @region.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /regions/1
  # PATCH/PUT /regions/1.json
  def update
    respond_to do |format|
      if @region.update(region_params)
        format.html { redirect_to admin_region_path(@region), notice: 'region was successfully updated.' }
        format.json { render :show, status: :ok, location: @region }
      else
        format.html { render :edit }
        format.json { render json: @region.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /regions/1
  # DELETE /regions/1.json
  def destroy
    @regions.destroy
    respond_to do |format|
      format.html { redirect_to admin_regions_url, notice: 'region was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
  # Never trust parameters from the scary internet, only allow the white list through.
  def region_params
    params.require(:region).permit(:name)
  end
end


text:
if [ -z "${NODE_ENV}" ]; then
  export NODE_ENV=development
fi

if [ -z "${PORT}" ]; then
  export PORT=3000
fi


text:
"""Tests for `tf.data.experimental.make_batched_features_dataset()`."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np

from tensorflow.python.data.experimental.kernel_tests import reader_dataset_ops_test_base
from tensorflow.python.data.experimental.ops import readers
from tensorflow.python.data.ops import dataset_ops
from tensorflow.python.data.ops import readers as core_readers
from tensorflow.python.data.util import nest
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import errors
from tensorflow.python.framework import ops
from tensorflow.python.framework import test_util
from tensorflow.python.ops import io_ops
from tensorflow.python.ops import parsing_ops
from tensorflow.python.platform import test

class MakeBatchedFeaturesDatasetTest(
    reader_dataset_ops_test_base.MakeBatchedFeaturesDatasetTestBase):

  def testRead(self):
    for batch_size in [1, 2]:
      for num_epochs in [1, 10]:
        with ops.Graph().as_default() as g:
          with self.session(graph=g) as sess:
            # Basic test: read from file 0.
            self.outputs = dataset_ops.make_one_shot_iterator(
                self.make_batch_feature(
                    filenames=self.test_filenames[0],
                    label_key="label",
                    num_epochs=num_epochs,
                    batch_size=batch_size)).get_next()
            self.verify_records(
                sess,
                batch_size,
                0,
                num_epochs=num_epochs,
                label_key_provided=True)
            with self.assertRaises(errors.OutOfRangeError):
              self._next_actual_batch(sess, label_key_provided=True)

        with ops.Graph().as_default() as g:
          with self.session(graph=g) as sess:
            # Basic test: read from file 1.
            self.outputs = dataset_ops.make_one_shot_iterator(
                self.make_batch_feature(
                    filenames=self.test_filenames[1],
                    label_key="label",
                    num_epochs=num_epochs,
                    batch_size=batch_size)).get_next()
            self.verify_records(
                sess,
                batch_size,
                1,
                num_epochs=num_epochs,
                label_key_provided=True)
            with self.assertRaises(errors.OutOfRangeError):
              self._next_actual_batch(sess, label_key_provided=True)

        with ops.Graph().as_default() as g:
          with self.session(graph=g) as sess:
            # Basic test: read from both files.
            self.outputs = dataset_ops.make_one_shot_iterator(
                self.make_batch_feature(
                    filenames=self.test_filenames,
                    label_key="label",
                    num_epochs=num_epochs,
                    batch_size=batch_size)).get_next()
            self.verify_records(
                sess,
                batch_size,
                num_epochs=num_epochs,
                label_key_provided=True)
            with self.assertRaises(errors.OutOfRangeError):
              self._next_actual_batch(sess, label_key_provided=True)

        with ops.Graph().as_default() as g:
          with self.session(graph=g) as sess:
            # Basic test: read from both files.
            self.outputs = dataset_ops.make_one_shot_iterator(
                self.make_batch_feature(
                    filenames=self.test_filenames,
                    num_epochs=num_epochs,
                    batch_size=batch_size)).get_next()
            self.verify_records(sess, batch_size, num_epochs=num_epochs)
            with self.assertRaises(errors.OutOfRangeError):
              self._next_actual_batch(sess)

  @test_util.run_deprecated_v1
  def testReadWithEquivalentDataset(self):
    features = {
        "file": parsing_ops.FixedLenFeature([], dtypes.int64),
        "record": parsing_ops.FixedLenFeature([], dtypes.int64),
    }
    dataset = (
        core_readers.TFRecordDataset(self.test_filenames)
        .map(lambda x: parsing_ops.parse_single_example(x, features))
        .repeat(10).batch(2))
    iterator = dataset_ops.make_initializable_iterator(dataset)
    init_op = iterator.initializer
    next_element = iterator.get_next()

    with self.cached_session() as sess:
      self.evaluate(init_op)
      for file_batch, _, _, _, record_batch, _ in self._next_expected_batch(
          range(self._num_files), 2, 10):
        actual_batch = self.evaluate(next_element)
        self.assertAllEqual(file_batch, actual_batch["file"])
        self.assertAllEqual(record_batch, actual_batch["record"])
      with self.assertRaises(errors.OutOfRangeError):
        self.evaluate(next_element)

  def testReadWithFusedShuffleRepeatDataset(self):
    num_epochs = 5
    total_records = num_epochs * self._num_records
    for batch_size in [1, 2]:
      # Test that shuffling with same seed produces the same result.
      with ops.Graph().as_default() as g:
        with self.session(graph=g) as sess:
          outputs1 = dataset_ops.make_one_shot_iterator(self.make_batch_feature(
              filenames=self.test_filenames[0],
              num_epochs=num_epochs,
              batch_size=batch_size,
              shuffle=True,
              shuffle_seed=5)).get_next()
          outputs2 = dataset_ops.make_one_shot_iterator(self.make_batch_feature(
              filenames=self.test_filenames[0],
              num_epochs=num_epochs,
              batch_size=batch_size,
              shuffle=True,
              shuffle_seed=5)).get_next()
          for _ in range(total_records // batch_size):
            batch1 = self._run_actual_batch(outputs1, sess)
            batch2 = self._run_actual_batch(outputs2, sess)
            for i in range(len(batch1)):
              self.assertAllEqual(batch1[i], batch2[i])

      # Test that shuffling with different seeds produces a different order.
      with ops.Graph().as_default() as g:
        with self.session(graph=g) as sess:
          outputs1 = dataset_ops.make_one_shot_iterator(self.make_batch_feature(
              filenames=self.test_filenames[0],
              num_epochs=num_epochs,
              batch_size=batch_size,
              shuffle=True,
              shuffle_seed=5)).get_next()
          outputs2 = dataset_ops.make_one_shot_iterator(self.make_batch_feature(
              filenames=self.test_filenames[0],
              num_epochs=num_epochs,
              batch_size=batch_size,
              shuffle=True,
              shuffle_seed=15)).get_next()
          all_equal = True
          for _ in range(total_records // batch_size):
            batch1 = self._run_actual_batch(outputs1, sess)
            batch2 = self._run_actual_batch(outputs2, sess)
            for i in range(len(batch1)):
              all_equal = all_equal and np.array_equal(batch1[i], batch2[i])
          self.assertFalse(all_equal)

  def testParallelReadersAndParsers(self):
    num_epochs = 5
    for batch_size in [1, 2]:
      for reader_num_threads in [2, 4]:
        for parser_num_threads in [2, 4]:
          with ops.Graph().as_default() as g:
            with self.session(graph=g) as sess:
              self.outputs = dataset_ops.make_one_shot_iterator(
                  self.make_batch_feature(
                      filenames=self.test_filenames,
                      label_key="label",
                      num_epochs=num_epochs,
                      batch_size=batch_size,
                      reader_num_threads=reader_num_threads,
                      parser_num_threads=parser_num_threads)).get_next()
              self.verify_records(
                  sess,
                  batch_size,
                  num_epochs=num_epochs,
                  label_key_provided=True,
                  interleave_cycle_length=reader_num_threads)
              with self.assertRaises(errors.OutOfRangeError):
                self._next_actual_batch(sess, label_key_provided=True)

          with ops.Graph().as_default() as g:
            with self.session(graph=g) as sess:
              self.outputs = dataset_ops.make_one_shot_iterator(
                  self.make_batch_feature(
                      filenames=self.test_filenames,
                      num_epochs=num_epochs,
                      batch_size=batch_size,
                      reader_num_threads=reader_num_threads,
                      parser_num_threads=parser_num_threads)).get_next()
              self.verify_records(
                  sess,
                  batch_size,
                  num_epochs=num_epochs,
                  interleave_cycle_length=reader_num_threads)
              with self.assertRaises(errors.OutOfRangeError):
                self._next_actual_batch(sess)

  def testDropFinalBatch(self):
    for batch_size in [1, 2]:
      for num_epochs in [1, 10]:
        with ops.Graph().as_default():
          # Basic test: read from file 0.
          outputs = dataset_ops.make_one_shot_iterator(self.make_batch_feature(
              filenames=self.test_filenames[0],
              label_key="label",
              num_epochs=num_epochs,
              batch_size=batch_size,
              drop_final_batch=True)).get_next()
          for tensor in nest.flatten(outputs):
            if isinstance(tensor, ops.Tensor):  # Guard against SparseTensor.
              self.assertEqual(tensor.shape[0], batch_size)

  def testIndefiniteRepeatShapeInference(self):
    dataset = self.make_batch_feature(
        filenames=self.test_filenames[0],
        label_key="label",
        num_epochs=None,
        batch_size=32)
    for shape, clazz in zip(nest.flatten(dataset.output_shapes),
                            nest.flatten(dataset.output_classes)):
      if issubclass(clazz, ops.Tensor):
        self.assertEqual(32, shape[0])

  def testOldStyleReader(self):
    with self.assertRaisesRegexp(
        TypeError, r"The `reader` argument must return a `Dataset` object. "
        r"`tf.ReaderBase` subclasses are not supported."):
      _ = readers.make_batched_features_dataset(
          file_pattern=self.test_filenames[0], batch_size=32,
          features={
              "file": parsing_ops.FixedLenFeature([], dtypes.int64),
              "record": parsing_ops.FixedLenFeature([], dtypes.int64),
              "keywords": parsing_ops.VarLenFeature(dtypes.string),
              "label": parsing_ops.FixedLenFeature([], dtypes.string),
          },
          reader=io_ops.TFRecordReader)

if __name__ == "__main__":
  test.main()


text:
class BatchKit

    # Captures details of a definable batch process, e.g. a Task or Job.
    #
    # @abstract
    class Definable

        class << self

            # Register additional properties to be recorded on this definable.
            #
            # @param props [Array<Symbol>] The names of properties to be added
            #   to the definition. Used by sub-classes to add to the available
            #   properties. This provides a mechanism by which associated
            #   Run objects can obtain a list of process properties that they
            #   can delegate.
            def add_properties(*props)
                attr_accessor(*props)
                properties.concat(props)
            end

            # @return [Array<Symbol>] the names of properties available on this
            #   definition.
            def properties
                @properties ||= []
            end

            # When this class is inherited, we need to copy the common property
            # names into the sub-class, since each sub-class needs the common
            # property names defined on this base class, as well as any sub-
            # class specific properties.
            def inherited(subclass)
                subclass.instance_variable_set(:@properties, @properties.clone)
            end

        end

        # @!attribute :name [String] A user-friendly name for this process.
        # @!attribute :description [String] A short description of what this
        #   process does.
        # @!attribute :instance [String] An optional expression used to assign
        #   an instance identifier to a process.
        #   An instance identifier allows a process that has different execution
        #   profiles (typically depending on the arguments it is run with)
        #   to identify which of those profiles it is executing. This expression
        #   will be evaluated at the time this process is invoked, and the
        #   result will become the instance identifier for the Runnable.
        # @!attribute :runs [Array<Runnable>] Array of runs of this process.
        # @!attribute :lock_name [String] The name of any lock that this
        #   process requires before it can proceed. If nil, no lock is
        #   required and the process can commence without any co-ordination
        #   with other processes.
        # @!attribute :lock_timeout [Fixnum] Number of seconds after which a
        #   lock obtained by this process will expire. This is to ensure that
        #   locks don't remain indefinitely if a process fails to release the
        #   lock properly. As such, it should be longer than any reasonable
        #   run of this process is likely to take, but no longer.
        # @!attribute :lock_wait_timeout [Fixnum] Number of seconds before
        #   this process will give up waiting for a lock to become available.
        add_properties(:name, :description, :instance, :runs,
            :lock_name, :lock_timeout, :lock_wait_timeout
        )

        # Create a new instance of this definition.
        def initialize
            @runs = []
        end

        # Returns an event name for publication, based on the sub-class of Runnable
        # that is triggering the event.
        def event_name(event)
            "#{self.class.name.split('::')[1].downcase}.#{event}"
        end

        # Sets properties from an options hash.
        #
        # @param opts [Hash] A hash containing properties to be set on this
        #   definable.
        def set_from_options(opts)
            unknown = opts.keys - self.class.properties
            if unknown.size > 0
                raise ArgumentError, "The following option(s) are invalid for #{
                    self.class.name}: #{unknown.join(', ')}. Valid options are: #{
                    self.class.properties.join(', ')}"
            end
            self.class.properties.each do |prop|
                if opts.has_key?(prop)
                    self.send("#{prop}=", opts[prop])
                end
            end
        end

        # Adds an aspect (as in aspect-oriented programming, or AOP) around the
        # existing instance method +mthd_name+ on +tgt_class+. The aspect does
        # the following:
        # - Calls the #pre_execute method with the object instance on which the
        #   aspect method is being invoked. If the #pre_execute method returns
        #   false, the method call is skipped; otherwise, proceeds to the next
        #   step.
        # - Calls the #around_execute method, which must yield back at the point
        #   at which the wrapped method body should be invoked.
        # - Calls the #post_execute method with a boolean OK indicator, and the
        #   result of the method (if OK) or the exception it threw (if not OK).
        #
        # @param tgt_class [Class] The class on which the method to be wrapped
        #   is defined.
        # @param mthd_name [Symbol] The name of the instance method to be
        #   wrapped.
        def add_aspect(tgt_class, mthd_name)
            defn = self
            mthd = tgt_class.instance_method(mthd_name)
            tgt_class.class_eval do
                define_method mthd_name do |*args, &block|
                    run = defn.create_run(self, *args)
                    if run.pre_execute(self, *args)
                        ok = false
                        result = nil
                        begin
                            run.around_execute(self, *args) do
                                result = mthd.bind(self).call(*args, &block)
                            end
                            ok = true
                            run.success(self, result)
                            result
                        rescue Exception => ex
                            run.failure(self, ex) unless ok
                            raise
                        rescue Interrupt
                            run.abort(self) unless ok
                            raise
                        ensure
                            run.post_execute(self, ok)
                        end
                    end
                end
            end
            Events.publish(tgt_class, event_name('defined'), mthd_name)
        end

        # Creates an associated Runnable object for this definition. This method
        # must be overridden in sub-classes.
        #
        # @param process_obj [Object] The process object instance on which the
        #   process method will be invoked.
        # @param args [Array<Object>] The arguments to be passed to the process
        #   method.
        def create_run(process_obj, *args)
            raise "Not implemented in #{self.class.name}"
        end

        # Add a handler for interrupt (i.e. Ctrl-C etc) signals; this simply
        # raises an Interrupt exception on the main thread
        trap 'INT' do
            Thread.main.raise Interrupt
        end

    end

end


text:
package com.fissionworks.restalm.constants.field;

/**
 * System fields that comprise Release objects in ALM; The ENUM is equal to the
 * default label for fields that are displayed in the UI.
 *
 * @since 1.0.0
 */
public enum ReleaseField implements FieldName {

	/**
	 * The description field for relating defects to their detected in release;
	 * field name is {@code description} with alias
	 * {@code defect-to-detected-release-mirror}.
	 *
	 * @since 1.0.0
	 */
	DEFECT_DETECTED_RELEASE_DESCRIPTION("description", "defect-to-detected-release-mirror"),

	/**
	 * The end date field for relating defects to their detected in release;
	 * field name is {@code end-date} with alias
	 * {@code defect-to-detected-release-mirror}.
	 *
	 * @since 1.0.0
	 */
	DEFECT_DETECTED_RELEASE_END_DATE("end-date", "defect-to-detected-release-mirror"),

	/**
	 * The ID field for relating defects to their detected in release; field
	 * name is {@code id} with alias {@code defect-to-detected-release-mirror}.
	 *
	 * @since 1.0.0
	 */
	DEFECT_DETECTED_RELEASE_ID("id", "defect-to-detected-release-mirror"),

	/**
	 * The name field for relating defects to their detected in release; field
	 * name is {@code name} with alias
	 * {@code defect-to-detected-release-mirror}.
	 *
	 * @since 1.0.0
	 */
	DEFECT_DETECTED_RELEASE_NAME("name", "defect-to-detected-release-mirror"),

	/**
	 * The parent id field for relating defects to their detected in release;
	 * field name is {@code parent-id} with alias
	 * {@code defect-to-detected-release-mirror}.
	 *
	 * @since 1.0.0
	 */
	DEFECT_DETECTED_RELEASE_PARENT_ID("parent-id", "defect-to-detected-release-mirror"),

	/**
	 * The start date field for relating defects to their detected in release;
	 * field name is {@code start-date} with alias
	 * {@code defect-to-detected-release-mirror}.
	 *
	 * @since 1.0.0
	 */
	DEFECT_DETECTED_RELEASE_START_DATE("start-date", "defect-to-detected-release-mirror"),

	/**
	 * The description field; field name is {@code description} with alias
	 * {@code release}.
	 *
	 * @since 1.0.0
	 */
	DESCRIPTION("description", "release"),

	/**
	 * The end date field; field name is {@code end-date} with alias
	 * {@code release}.
	 *
	 * @since 1.0.0
	 */
	END_DATE("end-date", "release"),

	/**
	 * The ID field; field name is {@code id} with alias {@code release}.
	 *
	 * @since 1.0.0
	 */
	ID("id", "release"),

	/**
	 * The name field; field name is {@code name} with alias {@code release}.
	 *
	 * @since 1.0.0
	 */
	NAME("name", "release"),

	/**
	 * The parent id field; field name is {@code parent-id} with alias
	 * {@code release}.
	 *
	 * @since 1.0.0
	 */
	PARENT_ID("parent-id", "release"),

	/**
	 * The start date field; field name is {@code start-date} with alias
	 * {@code release}.
	 *
	 * @since 1.0.0
	 */
	START_DATE("start-date", "release");

	private final String alias;

	private final String name;

	private ReleaseField(final String theName, final String theAlias) {
		this.name = theName;
		this.alias = theAlias;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public String getQualifiedName() {
		return String.format("%s.%s", alias, name);
	}

}


text:
import {InjectFlags} from './core';
import {Identifiers} from './identifiers';
import * as o from './output/output_ast';
import {R3DependencyMetadata, R3FactoryDelegateType, R3FactoryMetadata, compileFactoryFunction} from './render3/r3_factory';
import {mapToMapExpression, typeWithParameters} from './render3/util';

export interface InjectableDef {
  expression: o.Expression;
  type: o.Type;
  statements: o.Statement[];
}

export interface R3InjectableMetadata {
  name: string;
  type: o.Expression;
  typeArgumentCount: number;
  ctorDeps: R3DependencyMetadata[]|'invalid'|null;
  providedIn: o.Expression;
  useClass?: o.Expression;
  useFactory?: o.Expression;
  useExisting?: o.Expression;
  useValue?: o.Expression;
  userDeps?: R3DependencyMetadata[];
}

export function compileInjectable(meta: R3InjectableMetadata): InjectableDef {
  let result: {factory: o.Expression, statements: o.Statement[]}|null = null;

  const factoryMeta = {
    name: meta.name,
    type: meta.type,
    deps: meta.ctorDeps,
    injectFn: Identifiers.inject,
  };

  if (meta.useClass !== undefined) {
    // meta.useClass has two modes of operation. Either deps are specified, in which case `new` is
    // used to instantiate the class with dependencies injected, or deps are not specified and
    // the factory of the class is used to instantiate it.
    //
    // A special case exists for useClass: Type where Type is the injectable type itself and no
    // deps are specified, in which case 'useClass' is effectively ignored.

    const useClassOnSelf = meta.useClass.isEquivalent(meta.type);
    let deps: R3DependencyMetadata[]|undefined = undefined;
    if (meta.userDeps !== undefined) {
      deps = meta.userDeps;
    }

    if (deps !== undefined) {
      // factory: () => new meta.useClass(...deps)
      result = compileFactoryFunction({
        ...factoryMeta,
        delegate: meta.useClass,
        delegateDeps: deps,
        delegateType: R3FactoryDelegateType.Class,
      });
    } else if (useClassOnSelf) {
      result = compileFactoryFunction(factoryMeta);
    } else {
      result = compileFactoryFunction({
        ...factoryMeta,
        delegate: meta.useClass,
        delegateType: R3FactoryDelegateType.Factory,
      });
    }
  } else if (meta.useFactory !== undefined) {
    result = compileFactoryFunction({
      ...factoryMeta,
      delegate: meta.useFactory,
      delegateDeps: meta.userDeps || [],
      delegateType: R3FactoryDelegateType.Function,
    });
  } else if (meta.useValue !== undefined) {
    // Note: it's safe to use `meta.useValue` instead of the `USE_VALUE in meta` check used for
    // client code because meta.useValue is an Expression which will be defined even if the actual
    // value is undefined.
    result = compileFactoryFunction({
      ...factoryMeta,
      expression: meta.useValue,
    });
  } else if (meta.useExisting !== undefined) {
    // useExisting is an `inject` call on the existing token.
    result = compileFactoryFunction({
      ...factoryMeta,
      expression: o.importExpr(Identifiers.inject).callFn([meta.useExisting]),
    });
  } else {
    result = compileFactoryFunction(factoryMeta);
  }

  const token = meta.type;
  const providedIn = meta.providedIn;

  const expression = o.importExpr(Identifiers.defineInjectable).callFn([mapToMapExpression(
      {token, factory: result.factory, providedIn})]);
  const type = new o.ExpressionType(o.importExpr(
      Identifiers.InjectableDef, [typeWithParameters(meta.type, meta.typeArgumentCount)]));

  return {
    expression,
    type,
    statements: result.statements,
  };
}


text:
Accessing your identity details

In order to share your identity details they need to be accessed:

We will access:

name

date of birth

nationality

To work out the quickest way to access your details, you will be asked some questions.