https://github.com/frozen/scalafn
https://github.com/frozen/scalafn
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/frozen/scalafn
- Owner: Frozen
- Created: 2014-07-31T09:15:55.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-17T10:37:19.000Z (over 11 years ago)
- Last Synced: 2025-01-30T09:41:37.584Z (over 1 year ago)
- Language: Python
- Size: 285 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
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 = """blablabla@yandex.ru 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 noreply@example.com"""
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 noreply@example.com'
)