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

Side by Side Diff: README.rst

Issue 30053555: Issue 7471 - Add an API for working with blocks of filters (Closed) Base URL: https://hg.adblockplus.org/python-abp
Patch Set: Adjust the API in response to review comments Created May 9, 2019, 4:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | abp/filters/blocks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 python-abp 1 python-abp
2 ========== 2 ==========
3 3
4 This repository contains a library for working with Adblock Plus filter lists, 4 This repository contains a library for working with Adblock Plus filter lists,
5 a script for rendering diffs between filter lists, and the script that is used 5 a script for rendering diffs between filter lists, and the script that is used
6 for building Adblock Plus filter lists from the form in which they are authored 6 for building Adblock Plus filter lists from the form in which they are authored
7 into the format suitable for consumption by the adblocking software (aka 7 into the format suitable for consumption by the adblocking software (aka
8 rendering). 8 rendering).
9 9
10 .. contents:: 10 .. contents::
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 175
176 The ``abp.filters`` module also exports a lower-level function for parsing 176 The ``abp.filters`` module also exports a lower-level function for parsing
177 individual lines of a filter list: ``parse_line``. It returns a parsed line 177 individual lines of a filter list: ``parse_line``. It returns a parsed line
178 object just like the items in the iterator returned by ``parse_filterlist``. 178 object just like the items in the iterator returned by ``parse_filterlist``.
179 179
180 For further information on the library API use ``help()`` on ``abp.filters`` and 180 For further information on the library API use ``help()`` on ``abp.filters`` and
181 its contents in an interactive Python session, read the docstrings, or look at 181 its contents in an interactive Python session, read the docstrings, or look at
182 the tests for some usage examples. 182 the tests for some usage examples.
183 183
184 Blocks of filters
185 ~~~~~~~~~~~~~~~~~
186
187 Further processing of blocks of filters separated by comments can be performed
188 using ``to_blocks`` function from ``abp.filters.blocks``:
189
190 .. code-block:: python
191
192 from abp.filters import parse_filterlist
193 from abp.filters.blocks import to_blocks
194
195 with open(fl_path) as f:
196 for block in to_blocks(parse_filterlist(f)):
197 print(json.dumps(block.to_dict(), indent=2))
198
199 Use ``help()`` on ``abp.filters.blocks`` for more information.
184 200
185 Testing 201 Testing
186 ------- 202 -------
187 203
188 Unit tests for ``python-abp`` are located in the ``/tests`` directory. `Pytest < http://pytest.org/>`_ 204 Unit tests for ``python-abp`` are located in the ``/tests`` directory. `Pytest < http://pytest.org/>`_
189 is used for quickly running the tests during development. `Tox <https://tox.read thedocs.org/>`_ is used for 205 is used for quickly running the tests during development. `Tox <https://tox.read thedocs.org/>`_ is used for
190 testing in different environments (Python 2.7, Python 3.5+ and PyPy) and code 206 testing in different environments (Python 2.7, Python 3.5+ and PyPy) and code
191 quality reporting. 207 quality reporting.
192 208
193 Use tox for a comprehensive report of unit tests and test coverage:: 209 Use tox for a comprehensive report of unit tests and test coverage::
194 210
195 $ tox 211 $ tox
196 212
197
198 Development 213 Development
199 ----------- 214 -----------
200 215
201 When adding new functionality, add tests for it (preferably first). If some 216 When adding new functionality, add tests for it (preferably first). If some
202 code will never be reached on a certain version of Python, it may be exempted 217 code will never be reached on a certain version of Python, it may be exempted
203 from coverage tests by adding a comment, e.g. ``# pragma: no py2 cover``. 218 from coverage tests by adding a comment, e.g. ``# pragma: no py2 cover``.
204 219
205 All public functions, classes and methods should have docstrings compliant with 220 All public functions, classes and methods should have docstrings compliant with
206 `NumPy/SciPy documentation guide <https://github.com/numpy/numpy/blob/master/doc /HOWTO_DOCUMENT.rst.txt>`_. 221 `NumPy/SciPy documentation guide <https://github.com/numpy/numpy/blob/master/doc /HOWTO_DOCUMENT.rst.txt>`_.
207 One exception is the constructors of classes that the user is not expected to 222 One exception is the constructors of classes that the user is not expected to
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 > abp <- import("abp.filters.rpy") 268 > abp <- import("abp.filters.rpy")
254 269
255 Now you can use the functions with ``abp$functionname``, e.g. 270 Now you can use the functions with ``abp$functionname``, e.g.
256 ``abp$line2dict("@@||g.doubleclick.net/pagead/$subdocument,domain=hon30.org")`` 271 ``abp$line2dict("@@||g.doubleclick.net/pagead/$subdocument,domain=hon30.org")``
257 272
258 For more information about the reticulate package, see their guide_. 273 For more information about the reticulate package, see their guide_.
259 274
260 .. _User Guide: https://virtualenv.pypa.io/en/latest/userguide/#usage 275 .. _User Guide: https://virtualenv.pypa.io/en/latest/userguide/#usage
261 .. _docs: https://docs.python.org/3/library/venv.html 276 .. _docs: https://docs.python.org/3/library/venv.html
262 .. _guide: https://rstudio.github.io/reticulate/ 277 .. _guide: https://rstudio.github.io/reticulate/
OLDNEW
« no previous file with comments | « no previous file | abp/filters/blocks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld