MCPcopy Create free account
hub / github.com/clips/pattern / _sync_author_detail

Method _sync_author_detail

pattern/web/feed/feedparser.py:1322–1357  ·  view source on GitHub ↗
(self, key='author')

Source from the content-addressed store, hash-verified

1320 context['contributors'][-1][key] = value
1321
1322 def _sync_author_detail(self, key='author'):
1323 context = self._getContext()
1324 detail = context.get('%s_detail' % key)
1325 if detail:
1326 name = detail.get('name')
1327 email = detail.get('email')
1328 if name and email:
1329 context[key] = u'%s (%s)' % (name, email)
1330 elif name:
1331 context[key] = name
1332 elif email:
1333 context[key] = email
1334 else:
1335 author, email = context.get(key), None
1336 if not author:
1337 return
1338 emailmatch = re.search(ur'''(([a-zA-Z0-9\_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?))(\?subject=\S+)?''', author)
1339 if emailmatch:
1340 email = emailmatch.group(0)
1341 # probably a better way to do the following, but it passes all the tests
1342 author = author.replace(email, u'')
1343 author = author.replace(u'()', u'')
1344 author = author.replace(u'<>', u'')
1345 author = author.replace(u'&lt;&gt;', u'')
1346 author = author.strip()
1347 if author and (author[0] == u'('):
1348 author = author[1:]
1349 if author and (author[-1] == u')'):
1350 author = author[:-1]
1351 author = author.strip()
1352 if author or email:
1353 context.setdefault('%s_detail' % key, FeedParserDict())
1354 if author:
1355 context['%s_detail' % key]['name'] = author
1356 if email:
1357 context['%s_detail' % key]['email'] = email
1358
1359 def _start_subtitle(self, attrsD):
1360 self.pushContent('subtitle', attrsD, u'text/plain', 1)

Callers 4

_end_authorMethod · 0.95
_end_itunes_ownerMethod · 0.95
_save_authorMethod · 0.95
_end_dc_publisherMethod · 0.95

Calls 7

_getContextMethod · 0.95
FeedParserDictClass · 0.85
stripMethod · 0.80
getMethod · 0.45
searchMethod · 0.45
groupMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected