You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

mf2util

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mf2util - pypi Package Compare versions

Comparing version
0.4.3
to
0.5.0
+1
-1
mf2util.egg-info/PKG-INFO
Metadata-Version: 1.1
Name: mf2util
Version: 0.4.3
Version: 0.5.0
Summary: Python Microformats2 utilities, a companion to mf2py

@@ -5,0 +5,0 @@ Home-page: http://indiewebcamp.com/mf2util

@@ -80,3 +80,19 @@ """Utilities for interpreting mf2 data.

# From https://indieweb.org/location#How_to_determine_the_location_of_a_microformat
LOCATION_PROPERTIES = frozenset((
'street-address',
'extended-address',
'post-office-box',
'locality',
'region',
'postal-code',
'country-name',
'label',
'latitude',
'longitude',
'altitude',
'name',
))
def find_first_entry(parsed, types):

@@ -520,4 +536,6 @@ """Find the first interesting h-* object in BFS-order

result = {}
props = hentry['properties']
for prop in ('url', 'uid', 'photo', 'featured' 'logo'):
value = get_plain_text(hentry['properties'].get(prop))
value = get_plain_text(props.get(prop))
if value:

@@ -527,3 +545,3 @@ result[prop] = value

for prop in ('start', 'end', 'published', 'updated', 'deleted'):
date_str = get_plain_text(hentry['properties'].get(prop))
date_str = get_plain_text(props.get(prop))
if date_str:

@@ -545,8 +563,8 @@ if want_json:

content_prop = hentry['properties'].get('content')
content_prop = props.get('content')
content_value = None
if content_prop:
if isinstance(content_prop[0], dict):
content_html = content_prop[0]['html'].strip()
content_value = content_prop[0]['value'].strip()
content_html = content_prop[0].get('html', '').strip()
content_value = content_prop[0].get('value', '').strip()
else:

@@ -558,3 +576,3 @@ content_value = content_html = content_prop[0]

summary_prop = hentry['properties'].get('summary')
summary_prop = props.get('summary')
if summary_prop:

@@ -566,14 +584,36 @@ if isinstance(summary_prop[0], dict):

# TODO handle h-adr and h-geo variants
locations = hentry['properties'].get('location')
if locations:
result['location'] = {}
if isinstance(locations[0], dict):
for loc_prop in ('url', 'name', 'latitude', 'longitude'):
loc_values = locations[0]['properties'].get(loc_prop)
if loc_values:
result['location'][loc_prop] = loc_values[0]
# Collect location objects, then follow this algorithm to consolidate their
# properties:
# https://indieweb.org/location#How_to_determine_the_location_of_a_microformat
location_stack = [props]
for prop in 'location', 'adr':
vals = props.get(prop)
if vals:
if isinstance(vals[0], string_type):
location_stack.append({'name': vals})
else:
location_stack.append(vals[0].get('properties', {}))
geo = props.get('geo')
if geo:
if isinstance(geo[0], dict):
location_stack.append(geo[0].get('properties', {}))
else:
result['location'] = {'name': locations[0]}
if geo[0].startswith('geo:'):
# a geo: URL. try to parse it. https://tools.ietf.org/html/rfc5870
parts = geo[0][len('geo:'):].split(';')[0].split(',')
if len(parts) >= 2:
location_stack.append({
'latitude': [parts[0]],
'longitude': [parts[1]],
'altitude': [parts[2]] if len(parts) >= 3 else [],
})
for prop in LOCATION_PROPERTIES:
for obj in location_stack:
if obj and obj.get(prop) and not (obj == props and prop == 'name'):
result.setdefault('location', {})[prop] = obj[prop][0]
if use_rel_syndication:

@@ -580,0 +620,0 @@ result['syndication'] = list(set(

Metadata-Version: 1.1
Name: mf2util
Version: 0.4.3
Version: 0.5.0
Summary: Python Microformats2 utilities, a companion to mf2py

@@ -5,0 +5,0 @@ Home-page: http://indiewebcamp.com/mf2util

@@ -27,3 +27,3 @@ #!/usr/bin/env python

setup(name='mf2util',
version='0.4.3',
version='0.5.0',
description='Python Microformats2 utilities, a companion to mf2py',

@@ -30,0 +30,0 @@ long_description="""