pyorg / pyorg /

"""Parser related stuff
import re

def maxhead(text):
    """tell which is the topmost level
    levels = []
    for line in text.splitlines():
        match = re.match('^(\*+)\s(.*?)\s*$', line)
        if match:
    return min(levels)

def splitheads(text):
    """Split up the topmost headers returning a list of the headers
    with the associated text.
    indexes = [m.start() for m in 
               re.finditer('^(\*{%i})\s(.*?)\s*$'%maxhead(text), text, flags = re.MULTILINE)]
    ret = []
    for i in range(len(indexes)-1):
        start = indexes[i]
        end = indexes[i+1]
    return ret