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

Delta Between Two Patch Sets: abp/filters/rpy.py

Issue 29988581: Issue 7230 - python-abp line2dict vectorization (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Left Patch Set: Switch from dict to list Created Jan. 25, 2019, 12:27 a.m.
Right Patch Set: Separate tests Created Jan. 29, 2019, 1:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « .hgignore ('k') | tests/test_rpy.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 def lines2dicts(string_list, mode='body'): 98 def lines2dicts(string_list, mode='body'):
99 """Convert a list of filterlist strings to a dictionary. 99 """Convert a list of filterlist strings to a dictionary.
100 100
101 All strings in the output dictionary will be UTF8 byte strings. This is 101 All strings in the output dictionary will be UTF8 byte strings. This is
102 necessary to prevent unicode encoding errors in rPython conversion layer. 102 necessary to prevent unicode encoding errors in rPython conversion layer.
103 103
104 Parameters 104 Parameters
105 ---------- 105 ----------
106 string_list: iterable of str 106 string_list: iterable of str
107 Each string in the list can be an empty line, include instruction, or 107 Each string in the list can be an empty line, include instruction, or
108 filter. Headers and metadata will not parse properly unless the mode 108 filter. If the mode is 'start', headers and metadata can also be
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.
109 is 'start'. 109 parsed.
110 mode: str 110 mode: str
111 Parsing mode (see `abp.filters.parser.parse_line`). 111 Parsing mode (see `abp.filters.parser.parse_line`).
112 112
113 Returns 113 Returns
114 ------- 114 -------
115 dict 115 list of dict
Vasily Kuznetsov 2019/01/25 15:00:58 Nit: it should be list of dict.
rhowell 2019/01/26 01:08:22 Done.
116 With the parsing results and all strings converted to utf8 byte 116 With the parsing results and all strings converted to utf8 byte
117 strings. 117 strings.
118 118
119 """ 119 """
120 result = [] 120 result = []
121 for string in string_list: 121 for string in string_list:
122 result.append(line2dict(string, mode)) 122 result.append(line2dict(string, mode))
123 return result 123 return result
LEFTRIGHT

Powered by Google App Engine
This is Rietveld