Skip to content
This repository has been archived by the owner on Nov 25, 2019. It is now read-only.

Commit

Permalink
Properly handle (key, fragment) tuple aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
itkach committed Nov 15, 2015
1 parent e5c0981 commit c3e7f66
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion aardtools/mwcouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,22 @@ def __iter__(self):
def articles_from_viewiter(viewiter):
for row in viewiter:
if row and row.doc:
if not 'parse' in row.doc:
log.warn('%r has no "parse" key', row)
yield row.id, None, None, False
continue
try:
result = (row.id, set(row.doc.get('aliases', ())),
aliases = row.doc.get('aliases', ())
str_aliases = set()
for alias in aliases:
if isinstance(alias, basestring):
str_aliases.add(alias)
else:
str_aliases.add(u'#'.join(alias))
result = (row.id, str_aliases,
row.doc['parse']['text']['*'], self.rtl)
except Exception:
log.exception('Failed to load %r', row)
result = row.id, None, None, False
yield result

Expand Down Expand Up @@ -258,6 +270,8 @@ def articles():
for name in aliases:
serialized = tojson(('', [], {u'r': title}))
yield Article(name, serialized, isredirect=True)
except StopIteration:
raise
except:
log.exception('')
raise
Expand Down

0 comments on commit c3e7f66

Please sign in to comment.