Example #1
0
def lineBooks(value):
    """ Splits a path line into one or more book references.

    @param line string containing one or references
    @return yields list of tokens for given line
    """
    for bookpart in rxsplit(Rx.bookSeparator, value):
        refs = rxsplit(Rx.simpleBcv, bookpart)
        yield [b.strip() for b in refs[1:] if b.strip()]
Example #2
0
def tickFieldTitle(name):
    """ Make title from name, aka UnCapCase.

    """
    words = rxsplit('([A-Z0-9][a-z]+)', name)
    ## my rx fu isn't great enough.  special case for when the split
    ## does not work, e.g., bidEFP.
    if len(words) == 1:
        words = rxsplit('([a-z]+)', name)
    ## title case each word in the word list if the word isn't already
    ## all upper case.
    words = [(w if w.upper() == w else w.title()) for w in words if w]
    return str.join(' ', words)
Example #3
0
def tickFieldTitle(name):
    """ Make title from name, aka UnCapCase.

    """
    words = rxsplit('([A-Z0-9][a-z]+)', name)
    ## my rx fu isn't great enough.  special case for when the split
    ## does not work, e.g., bidEFP.
    if len(words) == 1:
        words = rxsplit('([a-z]+)', name)
    ## title case each word in the word list if the word isn't already
    ## all upper case.
    words = [(w if w.upper()==w else w.title()) for w in words if w]
    return str.join(' ', words)
Example #4
0
def pathLines(value):
    """ Splits path string into lines, discarding comments.

    @param value unparsed path
    @return yields non-empty string value for each valid line
    """
    value = rxsub(',?\s+and\s+', ', ', value)
    for line in value.split('\n'):
        if rxmatch(Rx.fullBcv, line):
            yield rxsplit(Rx.comment, line.strip())[0]
Example #5
0
def bookRefs(value):
    """ Generates book, chapter and verse reference.


    @param value
    @return yields verse range quad-tuple for each reference
    """
    ref = value[1] if value[1:] else ''
    bookpart = (value[0], )
    for chap in rxsplit(Rx.chapterSeparator, ref):
        match = rxmatch(Rx.verseReference, chap)
        if match:
            vals = tuple((int(v) if v else None) for v in match.groups())
        else:
            vals = ()
        yield bookpart + vals