spring-projects/spring-xd — pull request #1232 by dturanski (2014-10-14 15:04:59+00:00)
Title: XD-2237 add python module for implementing processor

Added spring-xd/spring-xd-python for python code. This is not a sub-module of XD, known to the gradle build but the python module springxd.stream is used in echo.py invoked within ShellProcessorTests.

`springxd.stream` is a python module that wraps a python function in an I/O loop for use as a Spring XD processor. The function should take a single string argument and return a string. See echo.py for an example. It is also possible to use lambda functions, e.g

```
from springxd.stream import Processor
processor = Processor()
processor.start(lambda x: "foo" + x)
```

Caveats:

* Requires Python 2.x (tested with 2.7.x). This is not expected to work with Python 3 since it relies on `raw_input()` which is discontinued in Python 3 according to documentation. There may be additional unidentified issues.

* This implementation supports only LF, and CRLF encoding (LF is the default). I investigated supporting additional encoders that the shell module supports. This requires low level, byte-oriented I/O, which is non-standard and not portable in Python, so LF or CRLF seems like a reasonable restriction for this module.

* ShellProcessorTests now includes a test using non-ascii characters, which works out of the box, but I'm not sure why, since Python documents state that ascii encoding is the default. Understanding supported charsets will take further investigation, but it appears that UTF-8 is not an issue.