Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Oct 2020 19:59:37 +0000 (UTC)
From:      Sunpoet Po-Chuan Hsieh <sunpoet@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r552444 - in head/textproc: . py-ttp py-ttp/files
Message-ID:  <202010151959.09FJxb5i099088@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sunpoet
Date: Thu Oct 15 19:59:36 2020
New Revision: 552444
URL: https://svnweb.freebsd.org/changeset/ports/552444

Log:
  Add py-ttp 0.5.0
  
  TTP is a Python library for semi-structured text parsing using templates.
  
  In essence, TTP can help to:
  - Prepare, sort and load text data for parsing
  - Parse text using regexes dynamically derived out of templates
  - Process matches on the fly using broad set of built-in or custom functions
  - Combine match results in a structure with arbitrary hierarchy
  - Transform results in desired format to ease consumption by humans or machines
  - Return results to various destinations for storage or further processing
  
  WWW: https://github.com/dmulyalin/ttp

Added:
  head/textproc/py-ttp/
  head/textproc/py-ttp/Makefile   (contents, props changed)
  head/textproc/py-ttp/distinfo   (contents, props changed)
  head/textproc/py-ttp/files/
  head/textproc/py-ttp/files/patch-ttp-match-ip.py   (contents, props changed)
  head/textproc/py-ttp/files/patch-ttp-returners-terminal_returner.py   (contents, props changed)
  head/textproc/py-ttp/files/patch-ttp-utils-loaders.py   (contents, props changed)
  head/textproc/py-ttp/pkg-descr   (contents, props changed)
Modified:
  head/textproc/Makefile

Modified: head/textproc/Makefile
==============================================================================
--- head/textproc/Makefile	Thu Oct 15 19:52:58 2020	(r552443)
+++ head/textproc/Makefile	Thu Oct 15 19:59:36 2020	(r552444)
@@ -1414,6 +1414,7 @@
     SUBDIR += py-transifex-client
     SUBDIR += py-translationstring
     SUBDIR += py-transpopy
+    SUBDIR += py-ttp
     SUBDIR += py-ucl
     SUBDIR += py-ufal.udpipe
     SUBDIR += py-whoosh

Added: head/textproc/py-ttp/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/py-ttp/Makefile	Thu Oct 15 19:59:36 2020	(r552444)
@@ -0,0 +1,27 @@
+# Created by: Po-Chuan Hsieh <sunpoet@FreeBSD.org>
+# $FreeBSD$
+
+PORTNAME=	ttp
+PORTVERSION=	0.5.0
+CATEGORIES=	textproc python
+MASTER_SITES=	CHEESESHOP
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	sunpoet@FreeBSD.org
+COMMENT=	Template Text Parser
+
+LICENSE=	MIT
+
+USES=		dos2unix python
+USE_PYTHON=	autoplist concurrent distutils
+
+NO_ARCH=	yes
+
+.include <bsd.port.pre.mk>
+
+.if ${PYTHON_REL} > 3000
+post-patch:
+	@${RM} ${WRKSRC}/ttp/utils/load_python_exec_py2.py
+.endif
+
+.include <bsd.port.post.mk>

Added: head/textproc/py-ttp/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/py-ttp/distinfo	Thu Oct 15 19:59:36 2020	(r552444)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1602780720
+SHA256 (ttp-0.5.0.tar.gz) = bc5fc277f052b1c5f18faf10f4a944a55e12b4730556d916ac43578476d2ae11
+SIZE (ttp-0.5.0.tar.gz) = 59510

Added: head/textproc/py-ttp/files/patch-ttp-match-ip.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/py-ttp/files/patch-ttp-match-ip.py	Thu Oct 15 19:59:36 2020	(r552444)
@@ -0,0 +1,56 @@
+--- ttp/match/ip.py.orig	2020-08-16 22:06:01 UTC
++++ ttp/match/ip.py
+@@ -5,9 +5,9 @@ log = logging.getLogger(__name__)
+ 
+ def to_ip(data, *args):
+     # for py2 support need to convert data to unicode:
+-    if _ttp_["python_major_version"] is 2:
++    if _ttp_["python_major_version"] == 2:
+         ipaddr_data = unicode(data)
+-    elif _ttp_["python_major_version"] is 3:
++    elif _ttp_["python_major_version"] == 3:
+         ipaddr_data = data
+     if "ipv4" in args:
+         if "/" in ipaddr_data or " " in ipaddr_data:
+@@ -33,9 +33,9 @@ def is_ip(data, *args):
+ 		
+ def to_net(data, *args):
+     # for py2 support need to convert data to unicode:
+-    if _ttp_["python_major_version"] is 2:
++    if _ttp_["python_major_version"] == 2:
+         ipaddr_data = unicode(data)
+-    elif _ttp_["python_major_version"] is 3:
++    elif _ttp_["python_major_version"] == 3:
+         ipaddr_data = data
+     if "ipv4" in args:
+         return ipaddress.IPv4Network(ipaddr_data), None
+@@ -124,21 +124,21 @@ def cidr_match(data, prefix):
+         check = ip_obj.network.overlaps(ip_net)
+     elif isinstance(ip_obj, ipaddress.IPv4Address) or isinstance(ip_obj, ipaddress.IPv6Address):
+         # if object is ipaddress, need to convert it into ipinterface with /32 mask:
+-        if ip_obj.version is 4:
++        if ip_obj.version == 4:
+             # for py2 support need to convert data to unicode:
+-            if _ttp_["python_major_version"] is 2:
++            if _ttp_["python_major_version"] == 2:
+                 ipaddr_data = unicode("{}/32".format(str(ip_obj)))
+-            elif _ttp_["python_major_version"] is 3:
++            elif _ttp_["python_major_version"] == 3:
+                 ipaddr_data = "{}/32".format(str(ip_obj))
+             ip_obj = ipaddress.IPv4Interface(ipaddr_data)
+-        elif ip_obj.version is 6:
++        elif ip_obj.version == 6:
+             # for py2 support need to convert data to unicode:
+-            if _ttp_["python_major_version"] is 2:
++            if _ttp_["python_major_version"] == 2:
+                 ipaddr_data = unicode("{}/128".format(str(ip_obj)))
+-            elif _ttp_["python_major_version"] is 3:
++            elif _ttp_["python_major_version"] == 3:
+                 ipaddr_data = "{}/128".format(str(ip_obj))
+             ip_obj = ipaddress.IPv6Interface(ipaddr_data)
+         check = ip_obj.network.overlaps(ip_net)
+     else:
+         check = None
+-    return data, check
+\ No newline at end of file
++    return data, check

Added: head/textproc/py-ttp/files/patch-ttp-returners-terminal_returner.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/py-ttp/files/patch-ttp-returners-terminal_returner.py	Thu Oct 15 19:59:36 2020	(r552444)
@@ -0,0 +1,20 @@
+--- ttp/returners/terminal_returner.py.orig	2020-09-03 21:58:49 UTC
++++ ttp/returners/terminal_returner.py
+@@ -31,13 +31,13 @@ def terminal_returner(data, **kwargs):
+         for yeallow_word in yeallow_words:
+             data = data.replace(yeallow_word, fttr.format(Y, yeallow_word, N))
+     # print output
+-    if _ttp_["python_major_version"] is 2:
++    if _ttp_["python_major_version"] == 2:
+         if isinstance(data, str) or isinstance(data, unicode):
+             print(data)
+         else:
+             print(str(data).replace('\\n', '\n'))
+-    elif _ttp_["python_major_version"] is 3:
++    elif _ttp_["python_major_version"] == 3:
+         if isinstance(data, str):
+             print(data)
+         else:
+-            print(str(data).replace('\\n', '\n'))
+\ No newline at end of file
++            print(str(data).replace('\\n', '\n'))

Added: head/textproc/py-ttp/files/patch-ttp-utils-loaders.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/py-ttp/files/patch-ttp-utils-loaders.py	Thu Oct 15 19:59:36 2020	(r552444)
@@ -0,0 +1,49 @@
+--- ttp/utils/loaders.py.orig	2020-09-14 21:20:38 UTC
++++ ttp/utils/loaders.py
+@@ -33,7 +33,7 @@ def load_files(path, extensions=[], filters=[], read=F
+     if os.path.isfile(path[:5000]):
+         if read:
+             try:
+-                if _ttp_["python_major_version"] is 2:
++                if _ttp_["python_major_version"] == 2:
+                     with open(path, 'r') as file_obj:
+                         return [('text_data', file_obj.read(),)]
+                 with open(path, 'r', encoding='utf-8') as file_obj:
+@@ -53,10 +53,10 @@ def load_files(path, extensions=[], filters=[], read=F
+         if read:
+             ret = []
+             for f in files:
+-                if _ttp_["python_major_version"] is 2:  
++                if _ttp_["python_major_version"] == 2:  
+                     with open((path + f), 'r') as file_obj:
+                         ret.append(('text_data', file_obj.read(),))
+-                elif _ttp_["python_major_version"] is 3:
++                elif _ttp_["python_major_version"] == 3:
+                     with open((path + f), 'r', encoding='utf-8') as file_obj:
+                         ret.append(('text_data', file_obj.read(),))
+             return ret
+@@ -111,7 +111,7 @@ def _get_include_data(text_data, include):
+     return text_data
+     
+ def load_ini(text_data, include=None, **kwargs):
+-    if _ttp_["python_major_version"] is 3:
++    if _ttp_["python_major_version"] == 3:
+         import configparser
+         cfgparser = configparser.ConfigParser()
+         # to make cfgparser keep the case, e.g. VlaN222 will not become vlan222:
+@@ -132,7 +132,7 @@ def load_ini(text_data, include=None, **kwargs):
+                 log.error("ttp_utils.load_struct: Python3, Unable to load ini formatted data\n'{}'".format(text_data))
+         # convert configparser object into dictionary
+         result = {k: dict(cfgparser.items(k)) for k in list(cfgparser.keys())}
+-    elif _ttp_["python_major_version"] is 2:
++    elif _ttp_["python_major_version"] == 2:
+         import ConfigParser
+         import StringIO
+         cfgparser = ConfigParser.ConfigParser()
+@@ -217,4 +217,4 @@ def load_csv(text_data, include=None, **kwargs):
+             continue
+         temp = {headers[index]: i for index, i in enumerate(row)}
+         data[temp.pop(key)] = temp
+-    return data
+\ No newline at end of file
++    return data

Added: head/textproc/py-ttp/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/py-ttp/pkg-descr	Thu Oct 15 19:59:36 2020	(r552444)
@@ -0,0 +1,11 @@
+TTP is a Python library for semi-structured text parsing using templates.
+
+In essence, TTP can help to:
+- Prepare, sort and load text data for parsing
+- Parse text using regexes dynamically derived out of templates
+- Process matches on the fly using broad set of built-in or custom functions
+- Combine match results in a structure with arbitrary hierarchy
+- Transform results in desired format to ease consumption by humans or machines
+- Return results to various destinations for storage or further processing
+
+WWW: https://github.com/dmulyalin/ttp



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010151959.09FJxb5i099088>