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

Unified 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.
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 | « no previous file | abp/filters/blocks.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: README.rst
===================================================================
--- a/README.rst
+++ b/README.rst
@@ -176,30 +176,45 @@
The ``abp.filters`` module also exports a lower-level function for parsing
individual lines of a filter list: ``parse_line``. It returns a parsed line
object just like the items in the iterator returned by ``parse_filterlist``.
For further information on the library API use ``help()`` on ``abp.filters`` and
its contents in an interactive Python session, read the docstrings, or look at
the tests for some usage examples.
+Blocks of filters
+~~~~~~~~~~~~~~~~~
+
+Further processing of blocks of filters separated by comments can be performed
+using ``to_blocks`` function from ``abp.filters.blocks``:
+
+.. code-block:: python
+
+ from abp.filters import parse_filterlist
+ from abp.filters.blocks import to_blocks
+
+ with open(fl_path) as f:
+ for block in to_blocks(parse_filterlist(f)):
+ print(json.dumps(block.to_dict(), indent=2))
+
+Use ``help()`` on ``abp.filters.blocks`` for more information.
Testing
-------
Unit tests for ``python-abp`` are located in the ``/tests`` directory. `Pytest <http://pytest.org/>`_
is used for quickly running the tests during development. `Tox <https://tox.readthedocs.org/>`_ is used for
testing in different environments (Python 2.7, Python 3.5+ and PyPy) and code
quality reporting.
Use tox for a comprehensive report of unit tests and test coverage::
$ tox
-
Development
-----------
When adding new functionality, add tests for it (preferably first). If some
code will never be reached on a certain version of Python, it may be exempted
from coverage tests by adding a comment, e.g. ``# pragma: no py2 cover``.
All public functions, classes and methods should have docstrings compliant with
« 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