[parser] find a better solution than pulling the entire wiki contents into memory

Bug #1599974 reported by Joe Talbott
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Confirmed
Undecided
Unassigned

Bug Description

Facundo Batista recommends something along these lines for the part processing

def splitgen(text, sep):
    pos_from = 0
    while True:
        try:
            pos_to = text.index(sep, pos_from)
        except ValueError:
            yield text[pos_from:]
            break

        yield text[pos_from:pos_to]
        pos_from = pos_to + len(sep)

test = [
    'foo',
    'foo\n---\nbar',
    'foo\n---\n',
    'foo\n---\nbar\n---\n',
    'foo\n---\n\n---\nbar\n---\n',
]
for t in test:
    assert t.split("\n---\n") == list(splitgen(t, "\n---\n"))

Tags: wiki
Leo Arias (elopio)
tags: added: wiki
Joe Talbott (joetalbott)
Changed in snapcraft:
status: New → Confirmed
status: Confirmed → Incomplete
status: Incomplete → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.