Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: abp/filters/rpy.py

Issue 29988581: Issue 7230 - python-abp line2dict vectorization (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Patch Set: Switch from dict to list Created Jan. 25, 2019, 12:27 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « .hgignore ('k') | tests/test_rpy.py » ('j') | tests/test_rpy.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: abp/filters/rpy.py
===================================================================
--- a/abp/filters/rpy.py
+++ b/abp/filters/rpy.py
@@ -93,3 +93,31 @@
"""
return strings2utf8(tuple2dict(parse_line(text, mode)))
+
+
+def lines2dicts(string_list, mode='body'):
+ """Convert a list of filterlist strings to a dictionary.
+
+ All strings in the output dictionary will be UTF8 byte strings. This is
+ necessary to prevent unicode encoding errors in rPython conversion layer.
+
+ Parameters
+ ----------
+ string_list: iterable of str
+ Each string in the list can be an empty line, include instruction, or
+ filter. Headers and metadata will not parse properly unless the mode
Vasily Kuznetsov 2019/01/25 15:00:58 The connection between the first and the second se
rhowell 2019/01/26 01:08:22 Done.
+ is 'start'.
+ mode: str
+ Parsing mode (see `abp.filters.parser.parse_line`).
+
+ Returns
+ -------
+ dict
Vasily Kuznetsov 2019/01/25 15:00:58 Nit: it should be list of dict.
rhowell 2019/01/26 01:08:22 Done.
+ With the parsing results and all strings converted to utf8 byte
+ strings.
+
+ """
+ result = []
+ for string in string_list:
+ result.append(line2dict(string, mode))
+ return result
« no previous file with comments | « .hgignore ('k') | tests/test_rpy.py » ('j') | tests/test_rpy.py » ('J')

Powered by Google App Engine
This is Rietveld