mf2util
Advanced tools
| Metadata-Version: 1.1 | ||
| Name: mf2util | ||
| Version: 0.4.2 | ||
| Version: 0.4.3 | ||
| Summary: Python Microformats2 utilities, a companion to mf2py | ||
@@ -5,0 +5,0 @@ Home-page: http://indiewebcamp.com/mf2util |
+13
-9
@@ -88,19 +88,20 @@ """Utilities for interpreting mf2 data. | ||
| """ | ||
| return next(_find_all_entries(parsed, types), None) | ||
| return next(_find_all_entries(parsed, types, False), None) | ||
| def find_all_entries(parsed, types): | ||
| def find_all_entries(parsed, types, include_properties=False): | ||
| """Find all h-* objects of a given type in BFS-order. Traverses the | ||
| top-level items and their children and descendents. Does not | ||
| include property values (e.g. finding all h-cards would not find | ||
| values of "p-author h-card") | ||
| top-level items and their children and descendents. Includes property | ||
| values (e.g. finding all h-cards would not find values of | ||
| "p-author h-card") only if `include_properties` is True. | ||
| :param dict parsed: a mf2py parsed dict | ||
| :param list types: target types, e.g. ['h-entry', 'h-event'] | ||
| :param boolean include_properties: include properties in search of entries | ||
| :return: all entries with any of the the target types | ||
| """ | ||
| return list(_find_all_entries(parsed, types)) | ||
| return list(_find_all_entries(parsed, types, include_properties)) | ||
| def _find_all_entries(parsed, types): | ||
| def _find_all_entries(parsed, types, include_properties): | ||
| queue = deque(item for item in parsed['items']) | ||
@@ -112,2 +113,5 @@ while queue: | ||
| queue.extend(item.get('children', [])) | ||
| if include_properties: | ||
| queue.extend(prop for props in item.get('properties', {}).values() | ||
| for prop in props if isinstance(prop, dict)) | ||
@@ -235,3 +239,3 @@ | ||
| def find_parent_hfeed_author(hentry): | ||
| for hfeed in _find_all_entries(parsed, ['h-feed']): | ||
| for hfeed in _find_all_entries(parsed, ['h-feed'], False): | ||
| # find the h-entry's parent h-feed | ||
@@ -325,3 +329,3 @@ if hentry in hfeed.get('children', []): | ||
| """ | ||
| hcards = find_all_entries(parsed, ['h-card']) | ||
| hcards = find_all_entries(parsed, ['h-card'], include_properties=True) | ||
| # uid and url both match source_url | ||
@@ -328,0 +332,0 @@ for hcard in hcards: |
+1
-1
| Metadata-Version: 1.1 | ||
| Name: mf2util | ||
| Version: 0.4.2 | ||
| Version: 0.4.3 | ||
| Summary: Python Microformats2 utilities, a companion to mf2py | ||
@@ -5,0 +5,0 @@ Home-page: http://indiewebcamp.com/mf2util |
+2
-2
@@ -1,2 +0,2 @@ | ||
| [pytest] | ||
| [tool:pytest] | ||
| norecursedirs = venv* | ||
@@ -6,4 +6,4 @@ | ||
| tag_build = | ||
| tag_date = 0 | ||
| tag_svn_revision = 0 | ||
| tag_date = 0 | ||
+1
-1
@@ -27,3 +27,3 @@ #!/usr/bin/env python | ||
| setup(name='mf2util', | ||
| version='0.4.2', | ||
| version='0.4.3', | ||
| description='Python Microformats2 utilities, a companion to mf2py', | ||
@@ -30,0 +30,0 @@ long_description=""" |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
36227
1.11%744
0.54%