text:
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.34209
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace TupleGeo.Resources.IconLibraries.FamFamFam.Computing.Database.Tables {
    using System;

    /// <summary>
    ///   A strongly-typed resource class, for looking up localized strings, etc.
    /// </summary>
    // This class was auto-generated by the StronglyTypedResourceBuilder
    // class via a tool like ResGen or Visual Studio.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    public class Resources {

        private static global::System.Resources.ResourceManager resourceMan;

        private static global::System.Globalization.CultureInfo resourceCulture;

        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal Resources() {
        }

        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        public static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TupleGeo.Resources.IconLibraries.FamFamFam.Computing.Database.Tables.Resources", typeof(Resources).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }

        /// <summary>
        ///   Overrides the current thread's CurrentUICulture property for all
        ///   resource lookups using this strongly typed resource class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        public static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap Table {
            get {
                object obj = ResourceManager.GetObject("Table", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableAdd {
            get {
                object obj = ResourceManager.GetObject("TableAdd", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableDelete {
            get {
                object obj = ResourceManager.GetObject("TableDelete", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableEdit {
            get {
                object obj = ResourceManager.GetObject("TableEdit", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableError {
            get {
                object obj = ResourceManager.GetObject("TableError", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableGear {
            get {
                object obj = ResourceManager.GetObject("TableGear", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableGo {
            get {
                object obj = ResourceManager.GetObject("TableGo", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableKey {
            get {
                object obj = ResourceManager.GetObject("TableKey", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableLightning {
            get {
                object obj = ResourceManager.GetObject("TableLightning", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableLink {
            get {
                object obj = ResourceManager.GetObject("TableLink", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableMultiple {
            get {
                object obj = ResourceManager.GetObject("TableMultiple", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableRefresh {
            get {
                object obj = ResourceManager.GetObject("TableRefresh", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableRelationship {
            get {
                object obj = ResourceManager.GetObject("TableRelationship", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableRowDelete {
            get {
                object obj = ResourceManager.GetObject("TableRowDelete", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableRowInsert {
            get {
                object obj = ResourceManager.GetObject("TableRowInsert", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableSave {
            get {
                object obj = ResourceManager.GetObject("TableSave", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }

        /// <summary>
        ///   Looks up a localized resource of type System.Drawing.Bitmap.
        /// </summary>
        public static System.Drawing.Bitmap TableSort {
            get {
                object obj = ResourceManager.GetObject("TableSort", resourceCulture);
                return ((System.Drawing.Bitmap)(obj));
            }
        }
    }
}


text:
using System;
using System.Web;
using Subtext.Framework.Infrastructure.Installation;
using Subtext.Infrastructure;

namespace Subtext.Framework.Web.HttpModules
{
    /// <summary>
    /// Checks to see if the blog needs an upgrade.
    /// </summary>
    public class InstallationCheckModule : IHttpModule
    {
        public InstallationCheckModule() : this(null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="InstallationCheckModule"/> class.
        /// </summary>
        public InstallationCheckModule(IInstallationManager installationManager)
        {
            InstallationManager = installationManager ?? Bootstrapper.ServiceLocator.GetService<IInstallationManager>();
        }

        public IInstallationManager InstallationManager { get; private set; }

        /// <summary>
        /// Initializes a module and prepares it to handle
        /// requests.
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpApplication"/> that provides access to the methods, properties,
        /// and events common to all application objects within an ASP.NET application</param>
        public void Init(HttpApplication context)
        {
            context.BeginRequest += HandleInstallationUpdates;
        }

        /// <summary>
        /// Disposes of the resources (other than memory) used by the
        /// module that implements <see langword="IHttpModule."/>
        /// </summary>
        public void Dispose()
        {
            //Do nothing.
        }

        /// <summary>
        /// Checks the installation status and redirects if necessary.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void HandleInstallationUpdates(object sender, EventArgs e)
        {
            var context = new HttpContextWrapper(((HttpApplication)sender).Context);
            HandleInstallationStatus(context, BlogRequest.Current, HostInfo.Instance);
        }

        public void HandleInstallationStatus(HttpContextBase context, BlogRequest blogRequest, HostInfo hostInfo)
        {
            string redirectUrl = GetInstallationRedirectUrl(blogRequest, hostInfo);
            if(!String.IsNullOrEmpty(redirectUrl))
            {
                context.Response.Redirect(redirectUrl);
            }
        }

        /// <summary>
        /// Checks the installation status and redirects if necessary.
        /// </summary>
        public string GetInstallationRedirectUrl(BlogRequest blogRequest, HostInfo hostInfo)
        {
            const string installUrl = "~/install/default.aspx";

            // Bypass for static files.
            if(blogRequest.RawUrl.IsStaticFileRequest())
            {
                return null;
            }

            if(hostInfo == null && blogRequest.RequestLocation != RequestLocation.Installation)
            {
                return installUrl;
            }

            // Want to redirect to install if installation is required,
            // or if we're missing a HostInfo record.
            if((InstallationManager.InstallationActionRequired(VersionInfo.CurrentAssemblyVersion, null) || hostInfo == null))
            {
                InstallationState state = InstallationManager.GetInstallationStatus(VersionInfo.CurrentAssemblyVersion);
                if(state == InstallationState.NeedsInstallation
                   && !blogRequest.IsHostAdminRequest
                   && blogRequest.RequestLocation != RequestLocation.Installation)
                {
                    return installUrl;
                }

                if(state == InstallationState.NeedsUpgrade)
                {
                    if(blogRequest.RequestLocation != RequestLocation.Upgrade
                       && blogRequest.RequestLocation != RequestLocation.LoginPage
                       && blogRequest.RequestLocation != RequestLocation.SystemMessages
                       && blogRequest.RequestLocation != RequestLocation.HostAdmin)
                    {
                        return "~/SystemMessages/UpgradeInProgress.aspx";
                    }
                }
            }
            return null;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.camel.processor.async;

import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;

public class AsyncProducerTest extends ContextTestSupport {

    private static String beforeThreadName;
    private static String afterThreadName;

    @Test
    public void testAsyncProducer() throws Exception {
        getMockEndpoint("mock:before").expectedBodiesReceived("Hello Camel");
        getMockEndpoint("mock:after").expectedBodiesReceived("Bye Camel");
        getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");

        String reply = template.requestBody("direct:start", "Hello Camel", String.class);
        assertEquals("Bye Camel", reply);

        assertMockEndpointsSatisfied();

        assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                context.addComponent("async", new MyAsyncComponent());
                Producer myAsyncProducer = context.getEndpoint("async:bye:camel").createProducer();

                from("direct:start").to("mock:before").process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        beforeThreadName = Thread.currentThread().getName();
                    }
                }).process(myAsyncProducer).process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        afterThreadName = Thread.currentThread().getName();
                    }
                }).to("mock:after").to("mock:result");
            }
        };
    }
}


text:
int GetSecondQuestionPart() {
  return 6;
}


text:
+++
categories = ["asterisk","docker","rpm","automation"]
date = "2015-11-10T19:41:55-05:00"
description = ""
keywords = ["asterisk","docker","rpms","automation"]
title = "Asterisk Docker Container: Phase 1"

+++
## AstriCon
At AstriCon 2015 this year, there was a lot (and I mean a lot) of discussion
around microservices (Docker), and what effort is required over the next year
by the development community in order to make Asterisk better suited to running
in that environment.

One of the first things is, clearly, to have a container image that Asterisk
runs in. I've done this a few times now, but having something that can be
passed over to the official Asterisk Git repository, and which everyone can
contribute to, utilize and play with would be the goal here. The community is
already pretty fragmented, and there are a bunch of useful, but unofficial
images, and I don't think any of them have become the defacto image.

## The Problem; Reproducibility
Part of the problem is really around packages. Digium does release some
official Asterisk packages, but it's not automated. Another interesting tidbit
that came out of AstriDevCon is that no one really uses packages.

Let me elaborate on what I mean by that. Steve Sokol actually made that
statement, and at first I was shocked. As he talked a bit more, there was a bit
of an a-ha moment, so let me try and distill it. Remember that we're in a room
of developers and highly skillful integrators. When Steve said, "no one uses
packages", he was referring to a poll that was done of developers and
integrators, and asking if they deploy their systems to customers using the
defacto packages that are provided with the various distributions.

The issue isn't that we don't have access to packages, but that the packages we
do have access to don't contain the various bits of custom code that developers
and highly skilled integrators tend to absorb and deploy. So what ultimately
happens is that code gets compiled on the system with the changes, and away
everyone goes.

Of course these same people are more than intelligent enough to handle their
own packaging. The issue tends to be that creating your own packages and
managing them is a bit of a pain in the ass. It's extra overhead that never
seems to ultimately bubble up to a high enough priority to solve (in many
cases). No one likes shaving yaks to get their work done.

So with that sidebar out of the way, let me ask a question: how does building
an "official" Docker image solve any of that? The answer is, it doesn't. We end
up in the exact same situation, with everyone having their own Docker images
and their own Dockerfile that as borrowed from someone else, and we end up with
community fragmentation.

## Approaching A Solution
I think there is a solution here though. Docker makes the building of utility
services significantly easier than someone having to install applications, spin
up the corresponding services, configure them, and ultimately host them on
their infrastructure. And we're not even talking yet about people who run
Ubuntu vs CentOS vs Debian vs Mint vs... Gentoo?

However, the underlying distribution in a Docker-based infrastructure becomes
much less of a concern. We have these nice abstraction points called
"containers" :) With the framework of a single container, the distribution can
be one type, and it can interact with other containers that are other
distribution types through things like volumes, networking, etc. We can also
distribute portions of the infrastructure into nice little container images
with minimal setup time for the infrastructure owner.

With one or more containers, we can easily distribute the functionality that
would normally be maintained by each person locally, and make the maintenance
of that functionality a bit more centralized through the distribution of
containers for each of those purposes. Then the only real documentation should
be how to use the containers to achieve the same goals as would be done in a
virtual machine installation. Ideally with significantly less investment of
time as well.

The goal then here, is to create a foundation that allows the building of
Asterisk and distributing it via a container image relatively simple. We can
then avoid any centralized infrastructure spin up that needs to be owned by a
single organization or individual, allowing collaboration across organizations
and developers, and also allowing everyone to have a slightly tweaked
deployment without the overhead of maintaining the entire stack.

## A Draft Solution
With that in mind, we also want people to have access to an Asterisk container
image that they can use, but with the ability to rebuild it locally if need be,
without having to setup a ton of infrastructure to do it. As a first step, it
would be ideal to just have something that is reproducible.

The simplest solution is really just to build Asterisk from source that is
mounted via volume into the container during build. While this definitely
solves multple problems, it provides its own set of obstacles. Primarily that
it results in a large number of dependencies built into the container which
results in a large container image.

> **NOTE**: There are ways around this, but it kind of breaks the simplicity of
> the `Dockerfile` when you break out information into external scripts.
> Externalizing everything also breaks the readability of the container build
> itself when you do a `docker inspect`.

The best way of building the Asterisk container image is to use packages, since
that doesn't increase the size of the distributed container image. It also
keeps the `Dockerfile` readable and a single layer of information. But now
we're right back to our "building packages is hard" issue. Luckily with Docker
we can make this a significantly more appealing a process.

> **NOTE**: Since I started working on this, Alan Graham posted some links to
> RPM building containers which might also be useful for this. I'm currently
> approaching this slightly differently, but there may be an opportunity to
> circle back around and see how these images could also be used to solve the
> problem:
>
> * https://github.com/alanfranz/docker-rpm-builder
> * https://github.com/alanfranz/fpm-within-docker

In my first approach, I didn't want to rewrite all the SPEC file madness for
Asterisk. That's a big job. I've previously built RPMs for Asterisk (many
times) using the [asterisk.spec
file](http://pkgs.fedoraproject.org/cgit/asterisk.git/) from the Fedora
project. It's a great starting point, and usually with some mild tweaking I can
get what I want out of it. The most typical thing I do is add my own custom
changes to the `.spec` file, change versions, maintainer, etc and then build
the RPMs with [mock](https://fedoraproject.org/wiki/Mock). This is better than
having a dependent VM or something for building the RPMs, but it still requires
knowledge of using `mock` and then of course modifying the `spec` files in the
first place. You also need to have a Fedora or CentOS machine to work on.

We can simplify this with a Docker container image that builds the RPMs for us.
I did that here: [asterisk-docker-builder version
0.1](https://github.com/leifmadsen/asterisk-docker-builder/tree/0.1)

The solution I took was to reuse some of the RPM building tools supplied by the
Fedora project. Using `fedpkg` I could generate the dependencies I required,
load them into a local repo, and use that to step through the dependency stack.
With the `.spec` files already created, there wasn't much extra work to do
since I could install dependencies with `yum-builddep` and then use
`createrepo` to build a local RPM repository that could host the dependencies
not available from upstream CentOS.

You can see that I somewhat break my own rule and use a `buildit.sh` script,
but since this was just for the RPM builder, I let it slide for now. The
resulting RPMs are then used during the build process for the Asterisk
container image. This results in a huge savings of space; with the compiled
version of the Docker image, the size was 1.6GB, but with RPMs, it is closer to
500MB.

## Outstanding Issues
I consider the solution I've been working on far from complete. In this blog
post I also don't get into how I solved all the little things, and how to use
the images (I think I did a decent version of that in the `README.md` file
within the Github repo). Here are a few of the problems yet to be solved:

1. dependency on the upstream `spec` file from Fedora
2. dependency on `fedpkg`
3. inability to build packages easily from local source

Let me break down a bit further why the above are issues.

### Dependency on upstream `spec`
When we rely on the upstream `spec` file, we're not really a lot further ahead.
Sure we have the ability to reproduce builds pretty easily, but to a certain
degree we're stuck with whatever version is being packaged upstream. The file
not being local makes it difficult to manage, so we're kind of back to building
packages ourselves.

### Dependency on `fedpkg`
A dependency on `fedpkg` is actually a nice thing to a certain degree, but
doesn't solve all our "build from local source" problems. With `fedpkg` the
default is to grab the `spec` file and sources from a server hosted via Fedora
itself (thus we're) building the same RPMs that Fedora ships with their
systems), but there is an override configuration file we can use. With the
override configuration file, we could actually point at our own `spec` file
hosted in `git` and also point at our own `sources` location, where our own
tarball of Asterisk resides (with our own changes).

Of course this goes back to having to deploy our own infrastructure to support
building packages. It's not ideal, but it's definitely much less than normal. I
think there are things we can do with companion containers though to make this
much more flexible. There might be other tools that are even better than
`fedpkg` to make the building simpler.

### Inability to build from local source
Right now we technically could build packages using the `fedpkg.conf` overrides
and point it at some other infrastructure (either self-hosted, or supplied via
companion containers). The primary issue is if you wanted to build a
development container for testing some code directly from your local source
directory without all the extra work of building tarballs, uploading them to a
remote server, and updating a `spec` file, you're kind of out of luck.

## Next Steps
I think at this point some additional work could be done here to make this all
a little less difficult. For example the usage of
[FPM](https://github.com/jordansissel/fpm) within a companion container could
make the creation of the packages much simpler. If that approach succeeds then
we skip a lot of the overhead of having to maintain `spec` files, outside
infrastructure to make the files available to `fedpkg` and a few other things
that make building packages annoying. It's not clear yet whether FPM really
works well for complex applications like Asterisk that have multiple outside
dependencies, but it's worth a look.

The other approach I've been thinking about is to have a `spec` file per
Asterisk version supplied directly with Asterisk, which makes the editing of
the file locally probably a lot simpler since it'll be tied to your base
version of Asterisk. From there you simply need to add any extra modules /
files that you're adding to the Asterisk source code. If changes only happen in
existing file, then there should be no need to change the file at all, other
than maybe a build flag change (which you might be able to pass in with an
`ENV` variable).

To solve the issue with building a package from the local source, we could
volume mount the working directory or Asterisk code back into the container
during the `docker run` and `tar` the source up, place the resulting archive
into a particular directory, update the signature file, and create a new RPM.
Building your own local Asterisk container then would be relatively straight
forward.

## Conclusion
I know this has been a lengthy post, but I wanted to get all the background
fleshed out so that anyone wanting to jump into this had the prerequisite
information. I have some approaches I'm going to attempt moving forward with
(likely FPM to start, since I think that creates a simple avenue if it works
out), but anyone who wanted to assist with this is more than welcome to get
with me, and provide some other information.

Maybe there are some simple tweaks I'm not seeing, or some other problem to be
solved that I haven't run into yet. The goal here is to get the requisite
`Dockerfile` or files into the Asterisk repository, add some documentation and
make it simple for people to build their own Asterisk containers with their
source. Of course if all you need is a vanilla Asterisk container right now,
I'm already hosting one from the resulting RPMs built by the Fedora projects
`spec` and `fedpkg` at the [Docker
Hub](https://hub.docker.com/r/leifmadsen/asterisk/) under my repository.


text:
To launch the following integration test, make sure to have rundeck launched and listening on port 4440 (default).

export vars pointing at correct directories, and specify name of xmlstarlet executable:

    TMP_DIR=/tmp \
    RDECK_BASE=/var/lib/rundeck \
    RDECK_ETC=/etc/rundeck \
    RDECK_PROJECTS=/var/rundeck/projects \
    XMLSTARLET=xmlstarlet \
    sh src/test.sh http://localhost:4440 admin admin


text:
package com.facebook.buck.util.cache;

import com.google.common.hash.HashCode;

import java.io.IOException;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;

// TODO(bolinfest): This should be renamed to DummyFileHashCache and moved under the test/
// directory.
public class NullFileHashCache implements FileHashCache {

  @Override
  public boolean willGet(Path path) {
    return false;
  }

  @Override
  public void invalidate(Path path) {
  }

  @Override
  public void invalidateAll() {
  }

  @Override
  public HashCode get(Path path) throws IOException {
    throw new NoSuchFileException(path.toString());
  }

}


text:
import os
import re
import json
import requests
import fnmatch

from urllib import urlencode
from BeautifulSoup import BeautifulSoup

_ROOT = os.path.abspath(os.path.dirname(__file__))

invalid_url = {'error': 'Invalid URL'}
unreachable = {'error': 'Failed to reach the URL'}
empty_meta = {'error': 'Found no meta info for that url'}
headers = {'user-agent': 'embeddit/0.0.1'}

class Embeddit(dict):

    url = None
    fetched = False

    def __init__(self, url=None, *args, **kwargs):
        if url:
            self.url = url
            self.fetch()

    def fetch(self, force=False):
        if self.fetched and not force:
            return self

        response = self.fetch_oembed_meta()

        if 'error' in response:
            # No oembed info found.
            # Fall back to open graph
            response = self.fetch_og_meta()

        self.clear()
        self.update(response)
        self.fetched = True

        return response

    def to_json(self):
        if not self.fetched:
            self.fetch()
        return json.dumps(self)

    def fetch_oembed_meta(self):
        try:
            f = open(get_data('providers.json'), 'r')
            providers = json.loads(f.read())
            oembed_url = None

            for provider in providers:
                for endpoint in provider.get('endpoints', []):
                    for schema in endpoint.get('schemes', []):
                        if not schema.startswith('http://*') or not schema.startswith('https://*'):
                            schema = schema.replace('http://', 'http://*')
                            schema = schema.replace('https://', 'https://*')
                        if fnmatch.fnmatch(self.url, schema):
                            oembed_url = endpoint.get('url')
                            break

                if not oembed_url:
                    provider_urls = [
                        provider.get('provider_url'),
                        provider.get('provider_url').replace('http://', 'https://')
                    ]
                    for provider_url in provider_urls:
                        if fnmatch.fnmatch(self.url,  provider_url + "*"):
                            oembed_url = provider.get('endpoints')[0].get('url')
                            break

            if not oembed_url:
                return invalid_url

            params = urlencode({'url': self.url})

            try:
                results = requests.get(
                    '%s?%s' % (oembed_url.replace('{format}', 'json'), params),
                    headers=headers
                )
                content = json.loads(results.content)
                content[u'source_type'] = 'oembed'
            except ValueError:
                params = urlencode({'url': self.url, 'format': 'json'})
                results = requests.get('%s?%s' % (oembed_url, params), headers=headers)
                content = json.loads(results.content)
                content[u'source_type'] = 'oembed'
            return content
        except IndexError:
            return empty_meta
        except requests.exceptions.InvalidSchema:
            return invalid_url
        except requests.exceptions.HTTPError:
            return unreachable

    def fetch_og_meta(self):
        try:
            results = requests.get(self.url, headers=headers)
            soup = BeautifulSoup(results.content)
            meta = soup.findAll('meta')

            content = {}
            for tag in meta:
                if tag.has_key('property'):
                    if re.search('og:', tag['property']) is not None:
                        key = re.sub('og:', '', tag['property'])
                        content[key] = tag['content']

            if content == {}:
                return empty_meta
            else:
                content[u'source_type'] = 'open_graph'
                return content
        except requests.exceptions.InvalidSchema:
            return invalid_url
        except requests.exceptions.HTTPError:
            return unreachable

def get_data(path):
    return os.path.join(_ROOT, 'data', path)


text:
package com.jetbrains.python.psi;

import com.intellij.psi.StubBasedPsiElement;
import com.jetbrains.python.psi.stubs.PyImportStatementStub;

/**
 * @author yole
 */
public interface PyImportStatement extends PyImportStatementBase, StubBasedPsiElement<PyImportStatementStub>, PyImplicitImportNameDefiner {
}


text:
using System;
using OpenADK.Library;

namespace OpenADK.Library.us.Reporting
{
	///
	/// Defines the set of values that can be specified whenever a ReportDefinitionSourceType
	/// is used as a parameter to a method or constructor.
	///
	/// <remarks>
	/// Alternatively, the static
	///  <see cref="Wrap"/> method can be called to encapsulate any string value in
	///  a ReportDefinitionSourceType object.
	/// <para>Author: Generated by adkgen</para>
	/// <para>Version: 2.6</para>
	/// <para>Since: 1.5r1</para>
	/// </remarks>
	[Serializable]
	public class ReportDefinitionSourceType : SifEnum
	{
	/// URL ("URL")
	public static readonly ReportDefinitionSourceType URL = new ReportDefinitionSourceType("URL");

	/// Embedded ("Embedded")
	public static readonly ReportDefinitionSourceType EMBEDDED = new ReportDefinitionSourceType("Embedded");

	/// Description ("Description")
	public static readonly ReportDefinitionSourceType DESCRIPTION = new ReportDefinitionSourceType("Description");

	/// SIF_Query ("SIF_Query")
	public static readonly ReportDefinitionSourceType SIF_QUERY = new ReportDefinitionSourceType("SIF_Query");

	/// Base64Binary ("Base64Binary")
	public static readonly ReportDefinitionSourceType BASE64BINARY = new ReportDefinitionSourceType("Base64Binary");

	/// SIF_ExtendedQuery ("SIF_ExtendedQuery")
	public static readonly ReportDefinitionSourceType SIF_EXTENDEDQUERY = new ReportDefinitionSourceType("SIF_ExtendedQuery");

	/// ExampleObject ("ExampleObject")
	public static readonly ReportDefinitionSourceType EXAMPLEOBJECT = new ReportDefinitionSourceType("ExampleObject");

	///Wrap an arbitrary string value in a ReportDefinitionSourceType object.
	///<param name="wrappedValue">The element/attribute value.</param>
	///<remarks>This method does not verify
	///that the value is valid according to the SIF Specification</remarks>
	public static ReportDefinitionSourceType Wrap( String wrappedValue ) {
		return new ReportDefinitionSourceType( wrappedValue );
	}

	private ReportDefinitionSourceType( string enumDefValue ) : base( enumDefValue ) {}
	}
}


text:
using namespace eosio::chain;
namespace bfs = boost::filesystem;
namespace bpo = boost::program_options;
using bpo::options_description;
using bpo::variables_map;

struct blocklog {
   blocklog()
   {}

   void read_log();
   void set_program_options(options_description& cli);
   void initialize(const variables_map& options);

   bfs::path                        blocks_dir;
   bfs::path                        output_file;
   uint32_t                         first_block = 0;
   uint32_t                         last_block = std::numeric_limits<uint32_t>::max();
   bool                             no_pretty_print = false;
   bool                             as_json_array = false;
   bool                             make_index = false;
   bool                             trim_log = false;
   bool                             fix_irreversible_blocks = false;
   bool                             smoke_test = false;
   bool                             prune_transactions = false;
   bool                             help               = false;
};

struct report_time {
    report_time(std::string desc)
    : _start(std::chrono::high_resolution_clock::now())
    , _desc(desc) {
    }

    void report() {
        const auto duration = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - _start).count() / 1000;
        ilog("eosio-blocklog - ${desc} took ${t} msec", ("desc", _desc)("t", duration));
    }

    const std::chrono::high_resolution_clock::time_point _start;
    const std::string                                    _desc;
};

void blocklog::read_log() {
   report_time rt("reading log");

   block_log block_logger({ .log_dir = blocks_dir });
   const auto end = block_logger.head();
   EOS_ASSERT( end, block_log_exception, "No blocks found in block log" );
   EOS_ASSERT( end->block_num() > 1, block_log_exception, "Only one block found in block log" );

   //fix message below, first block might not be 1, first_block_num is not set yet
   ilog( "existing block log contains block num ${first} through block num ${n}",
         ("first",block_logger.first_block_num())("n",end->block_num()) );
   if (first_block < block_logger.first_block_num()) {
      first_block = block_logger.first_block_num();
   }

   std::optional<chainbase::database> reversible_blocks;
   try {
      ilog("opening reversible db");
      reversible_blocks.emplace(blocks_dir / config::reversible_blocks_dir_name, chainbase::database::read_only, config::default_reversible_cache_size);
      reversible_blocks->add_index<reversible_block_index>();
      const auto& idx = reversible_blocks->get_index<reversible_block_index,by_num>();
      auto first = idx.lower_bound(end->block_num());
      auto last = idx.rbegin();
      if (first != idx.end() && last != idx.rend())
         ilog( "existing reversible block num ${first} through block num ${last} ", ("first",first->get_block()->block_num())("last",last->get_block()->block_num()) );
      else {
         elog( "no blocks available in reversible block database: only block_log blocks are available" );
         reversible_blocks.reset();
      }
   } catch (const std::system_error&e) {
      if (chainbase::db_error_code::dirty == e.code().value()) {
         elog( "database dirty flag set (likely due to unclean shutdown): only block_log blocks are available" );
      } else {
         throw;
      }
   }

   std::ofstream output_blocks;
   std::ostream* out;
   if (!output_file.empty()) {
      output_blocks.open(output_file.generic_string().c_str());
      if (output_blocks.fail()) {
         std::ostringstream ss;
         ss << "Unable to open file '" << output_file.string() << "'";
         throw std::runtime_error(ss.str());
      }
      out = &output_blocks;
   }
   else
      out = &std::cout;

   if (as_json_array)
      *out << "[";
   uint32_t block_num = (first_block < 1) ? 1 : first_block;
   fc::variant pretty_output;
   const fc::microseconds deadline = fc::seconds(10);
   auto print_block = [&](auto& next) {
      abi_serializer::to_variant(*next,
                                 pretty_output,
                                 []( account_name n ) { return std::optional<abi_serializer>(); },
                                 abi_serializer::create_yield_function( deadline ));
      const auto block_id = next->calculate_id();
      const uint32_t ref_block_prefix = block_id._hash[1];
      const auto enhanced_object = fc::mutable_variant_object
                 ("block_num",next->block_num())
                 ("id", block_id)
                 ("ref_block_prefix", ref_block_prefix)
                 (pretty_output.get_object());
      fc::variant v(std::move(enhanced_object));
      if (no_pretty_print)
         *out << fc::json::to_string(v, fc::time_point::maximum());
      else
         *out << fc::json::to_pretty_string(v) << "\n";
   };
   bool contains_obj = false;
   while( block_num <= last_block ) {
      auto sb = block_logger.read_signed_block_by_num( block_num );
      if( !sb ) break;
      if (as_json_array && contains_obj)
         *out << ",";
      print_block(sb);
      ++block_num;
      contains_obj = true;
   }

   if (reversible_blocks) {
      const reversible_block_object* obj = nullptr;
      while( (block_num <= last_block) && (obj = reversible_blocks->find<reversible_block_object,by_num>(block_num)) ) {
         if (as_json_array && contains_obj)
            *out << ",";
         auto next = obj->get_block();
         print_block(next);
         ++block_num;
         contains_obj = true;
      }
   }

   if (as_json_array)
      *out << "]";
   rt.report();
}

void blocklog::set_program_options(options_description& cli)
{
   cli.add_options()
         ("blocks-dir", bpo::value<bfs::path>()->default_value("blocks"),
          "the location of the blocks directory (absolute path or relative to the current directory)")
         ("state-history-dir", bpo::value<bfs::path>()->default_value("state-history"),
           "the location of the state-history directory (absolute path or relative to the current dir)")
         ("output-file,o", bpo::value<bfs::path>(),
          "the file to write the output to (absolute or relative path).  If not specified then output is to stdout.")
         ("first,f", bpo::value<uint32_t>(&first_block)->default_value(0),
          "the first block number to log or the first to keep if trim-blocklog")
         ("last,l", bpo::value<uint32_t>(&last_block)->default_value(std::numeric_limits<uint32_t>::max()),
          "the last block number to log or the last to keep if trim-blocklog")
         ("no-pretty-print", bpo::bool_switch(&no_pretty_print)->default_value(false),
          "Do not pretty print the output.  Useful if piping to jq to improve performance.")
         ("as-json-array", bpo::bool_switch(&as_json_array)->default_value(false),
          "Print out json blocks wrapped in json array (otherwise the output is free-standing json objects).")
         ("make-index", bpo::bool_switch(&make_index)->default_value(false),
          "Create blocks.index from blocks.log. Must give 'blocks-dir'. Give 'output-file' relative to current directory or absolute path (default is <blocks-dir>/blocks.index).")
         ("trim-blocklog", bpo::bool_switch(&trim_log)->default_value(false),
          "Trim blocks.log and blocks.index. Must give 'blocks-dir' and 'first and/or 'last'.")
         ("fix-irreversible-blocks", bpo::bool_switch(&fix_irreversible_blocks)->default_value(false),
          "When the existing block log is inconsistent with the index, allows fixing the block log and index files automatically - that is, "
          "it will take the highest indexed block if it is valid; otherwise it will repair the block log and reconstruct the index.")
         ("smoke-test", bpo::bool_switch(&smoke_test)->default_value(false),
          "Quick test that blocks.log and blocks.index are well formed and agree with each other.")
         ("block-num", bpo::value<uint32_t>()->default_value(0), "The block number which contains the transactions to be pruned")
         ("transaction,t", bpo::value<std::vector<std::string> >()->multitoken(), "The transaction id to be pruned")
         ("prune-transactions", bpo::bool_switch(&prune_transactions)->default_value(false),
          "Prune the context free data and signatures from specified transactions of specified block-num.")
         ("help,h", bpo::bool_switch(&help)->default_value(false), "Print this help message and exit.")
         ;
}

void blocklog::initialize(const variables_map& options) {
   try {
      auto bld = options.at( "blocks-dir" ).as<bfs::path>();
      if( bld.is_relative())
         blocks_dir = bfs::current_path() / bld;
      else
         blocks_dir = bld;

      if (options.count( "output-file" )) {
         bld = options.at( "output-file" ).as<bfs::path>();
         if( bld.is_relative())
            output_file = bfs::current_path() / bld;
         else
            output_file = bld;
      }
   } FC_LOG_AND_RETHROW()

}

int trim_blocklog_end(bfs::path block_dir, uint32_t n) {       //n is last block to keep (remove later blocks)
   report_time rt("trimming blocklog end");
   int ret = block_log::trim_blocklog_end(block_dir, n);
   rt.report();
   return ret;
}

bool trim_blocklog_front(bfs::path block_dir, uint32_t n) {        //n is first block to keep (remove prior blocks)
   report_time rt("trimming blocklog start");
   const bool status = block_log::trim_blocklog_front(block_dir, block_dir / "old", n);
   rt.report();
   return status;
}

void fix_irreversible_blocks(bfs::path block_dir) {
   std::cout << "\nfix_irreversible_blocks of blocks.log and blocks.index in directory " << block_dir << '\n';
   block_log::config_type config;
   config.log_dir = block_dir;
   config.fix_irreversible_blocks = true;
   block_log block_logger(config);

   std::cout << "\nSmoke test of blocks.log and blocks.index in directory " << block_dir << '\n';
   block_log::smoke_test(block_dir, 0);
}

void smoke_test(bfs::path block_dir) {
   using namespace std;
   cout << "\nSmoke test of blocks.log and blocks.index in directory " << block_dir << '\n';
   block_log::smoke_test(block_dir, 0);
   cout << "\nno problems found\n"; // if get here there were no exceptions
}

template <typename Log>
int prune_transactions(const char* type, bfs::path dir, uint32_t block_num,
                       std::vector<transaction_id_type> unpruned_ids) {
   using namespace std;
   if (Log::exists(dir)) {
      Log log( { .log_dir = dir });
      log.prune_transactions(block_num, unpruned_ids);
      if (unpruned_ids.size()) {
         cerr << "block " << block_num << " in " << type << " does not contain the following transactions: ";
         copy(unpruned_ids.begin(), unpruned_ids.end(), ostream_iterator<string>(cerr, " "));
         cerr << "\n";
      }
   } else {
      cerr << "No " << type << " is found in " << dir.native() << "\n";
   }
   return unpruned_ids.size();
}

int prune_transactions(bfs::path block_dir, bfs::path state_history_dir, uint32_t block_num,
                       const std::vector<transaction_id_type>& ids) {

   if (block_num == 0 || ids.size() == 0) {
      std::cerr << "prune-transaction does nothing unless specify block-num and transaction\n";
      return -1;
   }

   using eosio::state_history_traces_log;
   return prune_transactions<block_log>("block log", block_dir, block_num, ids) +
          prune_transactions<state_history_traces_log>("state history traces log", state_history_dir, block_num, ids);
}

int main(int argc, char** argv) {
   std::ios::sync_with_stdio(false); // for potential performance boost for large block log files
   options_description cli ("eosio-blocklog command line options");
   try {
      blocklog blog;
      blog.set_program_options(cli);
      variables_map vmap;
      bpo::store(bpo::parse_command_line(argc, argv, cli), vmap);
      bpo::notify(vmap);
      if (blog.help) {
         cli.print(std::cerr);
         return 0;
      }
      if (blog.smoke_test) {
         smoke_test(vmap.at("blocks-dir").as<bfs::path>());
         return 0;
      }
      if (blog.fix_irreversible_blocks) {
          fix_irreversible_blocks(vmap.at("blocks-dir").as<bfs::path>());
          return 0;
      }
      if (blog.trim_log) {
         if (blog.first_block == 0 && blog.last_block == std::numeric_limits<uint32_t>::max()) {
            std::cerr << "trim-blocklog does nothing unless specify first and/or last block.";
            return -1;
         }
         if (blog.last_block != std::numeric_limits<uint32_t>::max()) {
            if (trim_blocklog_end(vmap.at("blocks-dir").as<bfs::path>(), blog.last_block) != 0)
               return -1;
         }
         if (blog.first_block != 0) {
            if (!trim_blocklog_front(vmap.at("blocks-dir").as<bfs::path>(), blog.first_block))
               return -1;
         }
         return 0;
      }
      if (blog.make_index) {
         const bfs::path blocks_dir = vmap.at("blocks-dir").as<bfs::path>();
         bfs::path out_file = blocks_dir / "blocks.index";
         const bfs::path block_file = blocks_dir / "blocks.log";

         if (vmap.count("output-file") > 0)
             out_file = vmap.at("output-file").as<bfs::path>();

         report_time rt("making index");
         const auto log_level = fc::logger::get(DEFAULT_LOGGER).get_log_level();
         fc::logger::get(DEFAULT_LOGGER).set_log_level(fc::log_level::debug);
         block_log::construct_index(block_file.generic_string(), out_file.generic_string());
         fc::logger::get(DEFAULT_LOGGER).set_log_level(log_level);
         rt.report();
         return 0;
      }
      if (blog.prune_transactions) {
         const auto  blocks_dir        = vmap["blocks-dir"].as<bfs::path>();
         const auto  state_history_dir = vmap["state-history-dir"].as<bfs::path>();
         const auto  block_num         = vmap["block-num"].as<uint32_t>();
         const auto  ids               = vmap.count("transaction") ? vmap["transaction"].as<std::vector<string>>() : std::vector<string>{};

         report_time                 rt("prune transactions");
         int ret = prune_transactions(blocks_dir, state_history_dir, block_num, {ids.begin(), ids.end()});
         rt.report();
         return ret;
      }
      //else print blocks.log as JSON
      blog.initialize(vmap);
      blog.read_log();
   } catch( const fc::exception& e ) {
      elog( "${e}", ("e", e.to_detail_string()));
      return -1;
   } catch( const boost::exception& e ) {
      elog("${e}", ("e",boost::diagnostic_information(e)));
      return -1;
   } catch( const std::exception& e ) {
      elog("${e}", ("e",e.what()));
      return -1;
   } catch( ... ) {
      elog("unknown exception");
      return -1;
   }

   return 0;
}


text:
package org.apache.nifi.processors.enrich;

import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.util.StandardValidators;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public abstract class AbstractEnrichProcessor extends AbstractProcessor {
    public static final PropertyDescriptor QUERY_INPUT = new PropertyDescriptor.Builder()
            .name("QUERY_INPUT")
            .displayName("Lookup value")
            .required(true)
            .description("The value that should be used to populate the query")
            .expressionLanguageSupported(true)
            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
            .build();

    public static final AllowableValue SPLIT= new AllowableValue("Split", "Split",
            "Use a delimiter character or RegEx  to split the results into attributes");
    public static final AllowableValue REGEX = new AllowableValue("RegEx", "RegEx",
            "Use a regular expression to split the results into attributes ");
    public static final AllowableValue NONE = new AllowableValue("None", "None",
            "Do not split results");

    public static final PropertyDescriptor QUERY_PARSER = new PropertyDescriptor.Builder()
            .name("QUERY_PARSER")
            .displayName("Results Parser")
            .description("The method used to slice the results into attribute groups")
            .allowableValues(SPLIT, REGEX, NONE)
            .required(true)
            .defaultValue(NONE.getValue())
            .build();

    public static final PropertyDescriptor QUERY_PARSER_INPUT = new PropertyDescriptor.Builder()
            .name("QUERY_PARSER_INPUT")
            .displayName("Parser RegEx")
            .description("Choice between a splitter and regex matcher used to parse the results of the query into attribute groups.\n" +
            "NOTE: This is a multiline regular expression, therefore, the DFM should decide how to handle trailing new line " +
            "characters.")
            .expressionLanguageSupported(false)
            .required(false)
            .addValidator(StandardValidators.REGULAR_EXPRESSION_VALIDATOR)
            .build();

    public static final PropertyDescriptor KEY_GROUP = new PropertyDescriptor.Builder()
            .name("KEY_GROUP")
            .displayName("Key lookup group (multiline / batch)")
            .description("When performing a batched lookup, the following RegEx numbered capture group or Column number will be used to match " +
                    "the whois server response with the lookup field")
            .required(false)
            .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR)
            .build();

    public static final Relationship REL_FOUND = new Relationship.Builder()
            .name("found")
            .description("Where to route flow files after successfully enriching attributes with data")
            .build();

    public static final Relationship REL_NOT_FOUND = new Relationship.Builder()
            .name("not found")
            .description("Where to route flow files if data enrichment query rendered no results")
            .build();

    @Override
    public List<ValidationResult> customValidate(ValidationContext validationContext) {
        final List<ValidationResult> results = new ArrayList<>(super.customValidate(validationContext));

        final String chosenQUERY_PARSER = validationContext.getProperty(QUERY_PARSER).getValue();

        if (!chosenQUERY_PARSER.equals(NONE.getValue())  &&  !validationContext.getProperty(QUERY_PARSER_INPUT).isSet() ) {
            results.add(new ValidationResult.Builder().input("QUERY_PARSER_INPUT")
                    .subject(QUERY_PARSER.getDisplayName())
                    .explanation("Split and Regex parsers require a valid Regular Expression")
                    .valid(false)
                    .build());
        }

        if (chosenQUERY_PARSER.equals(NONE.getValue()) && validationContext.getProperty(QUERY_PARSER_INPUT).isSet()) {
            results.add(new ValidationResult.Builder().input("QUERY_PARSER")
                    .subject(QUERY_PARSER_INPUT.getDisplayName())
                    .explanation("NONE parser does not support the use of Regular Expressions. " +
                            "Please select another parser or delete the regular expression entered in this field.")
                    .valid(false)
                    .build());
        }

        return results;
    }

    /**
     * This method returns the parsed record string in the form of
     * a map of two strings, consisting of a iteration aware attribute
     * names and its values
     *
     * @param  recordPosition  the iteration counter for the record
     * @param  rawResult the raw query results to be parsed
     * @param queryParser The parsing mechanism being used to parse the data into groups
     * @param queryRegex The regex to be used to split the query results into groups
     * @return  Map with attribute names and values
     */
    protected Map<String, String> parseResponse(String recordPosition, String rawResult, String queryParser, String queryRegex, String schema) {

        Map<String, String> results = new HashMap<>();
        Pattern p;
        recordPosition = StringUtils.isEmpty(recordPosition) ? "0" : recordPosition;

        // Iterates  over the results using the QUERY_REGEX adding the captured groups
        // as it progresses

        switch (queryParser) {
            case "Split":
                // Time to Split the results...
                String[] splitResult = rawResult.split(queryRegex);
                for (int r = 0; r < splitResult.length; r++) {
                    results.put("enrich." + schema + ".record" + recordPosition + ".group" + String.valueOf(r), splitResult[r]);
                }
                break;

            case "RegEx":
                // RegEx was chosen, iterating...
                p = Pattern.compile(queryRegex);
                Matcher finalResult = p.matcher(rawResult);
                if (finalResult.find()) {
                    // Note that RegEx matches capture group 0 is usually broad but starting with it anyway
                    // for the sake of purity
                    for (int r = 0; r < finalResult.groupCount(); r++) {
                        results.put("enrich." + schema + ".record" + recordPosition + ".group" + String.valueOf(r), finalResult.group(r));
                    }
                }
                break;

            case "None":
                // Fails to NONE
            default:
                // NONE was chosen, just appending the record result as group0 without further splitting
                results.put("enrich." + schema + ".record" + recordPosition + ".group0", rawResult);
                break;
        }
        return results;
    }

    /**
     * This method returns the parsed record string in the form of
     * a map of two strings, consisting of a iteration aware attribute
     * names and its values
     *

     * @param  rawResult the raw query results to be parsed
     * @param queryParser The parsing mechanism being used to parse the data into groups
     * @param queryRegex The regex to be used to split the query results into groups. The regex MUST implement at least on named capture group "KEY" to be used to populate the table rows
     * @param lookupKey The regular expression number or the column of a split to be used for matching
     * @return  Table with attribute names and values where each Table row uses the value of the KEY named capture group specified in @param queryRegex
     */
    protected Table<String, String, String> parseBatchResponse(String rawResult, String queryParser, String queryRegex, int lookupKey, String schema) {
        // Note the hardcoded record0.
        //  Since iteration is done within the parser and Multimap is used, the record number here will always be 0.
        // Consequentially, 0 is hardcoded so that batched and non batched attributes follow the same naming
        // conventions
        final String recordPosition = ".record0";

        final Table<String, String, String> results = HashBasedTable.create();

        switch (queryParser) {
            case "Split":
                Scanner scanner = new Scanner(rawResult);
                while (scanner.hasNextLine()) {
                    String line = scanner.nextLine();
                    // Time to Split the results...
                    String[] splitResult = line.split(queryRegex);

                    for (int r = 0; r < splitResult.length; r++) {
                        results.put(splitResult[ lookupKey - 1 ], "enrich." + schema + recordPosition + ".group" + String.valueOf(r), splitResult[r]);
                    }
                }
                break;
            case "RegEx":
            // prepare the regex
            Pattern p;
            // Regex is multiline. Each line should include a KEY for lookup
            p = Pattern.compile(queryRegex, Pattern.MULTILINE);

            Matcher matcher = p.matcher(rawResult);
            while (matcher.find()) {
                try {
                    // Note that RegEx matches capture group 0 is usually broad but starting with it anyway
                    // for the sake of purity
                    for (int r = 0; r <= matcher.groupCount(); r++) {
                        results.put(matcher.group(lookupKey), "enrich." + schema + recordPosition + ".group" + String.valueOf(r), matcher.group(r));
                    }
                } catch (IndexOutOfBoundsException e) {
                    getLogger().warn("Could not find capture group {} while processing result. You may want to review your " +
                            "Regular Expression to match against the content \"{}\"", new Object[]{lookupKey, rawResult});
                }
            }
            break;
        }

        return results;
    }
}