Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/frozen/scalafn


https://github.com/frozen/scalafn

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

****************************************
Scalafn: scala-like lists usage
****************************************

============
Installation
============

pip install git+git://github.com/Frozen/scalafn.git@master

=====
Usage
=====

.. code-block:: python

from scalafn import List

str1 = """[email protected] R=dnslookup """ \
"""T=remote_smtp H=mx.yandex.ru [127.0.0.1] """ \
"""X=TLS1.0:RSA_AES_256_CBC_SHA1:32"""
str2 = """<> R=1XSUTD-0008L9-Vn U=Debian-exim """ \
"""P=local S=5035 T="Mail delivery failed: """ \
"""returning message to sender" for [email protected]"""
import re

rs1 = List(*re.split(" (?=\w=)", str1)).\
filter(lambda x: x.count("=")).\
toMap(lambda x: x.split("=", 1))

assert rs1 == dict(
R='dnslookup',
T='remote_smtp',
H='mx.yandex.ru [127.0.0.1]',
X='TLS1.0:RSA_AES_256_CBC_SHA1:32'
)

rs2 = List(*re.split(" (?=\w=)", str2)).\
filter(lambda x: x.count("=")).\
toMap(lambda x: x.split("=", 1))

assert rs2 == dict(
R='1XSUTD-0008L9-Vn',
U='Debian-exim',
P='local',
S='5035',
T='"Mail delivery failed: returning message to sender" for [email protected]'
)