Menu

Tree [48e2a3] default tip /
 History

Read Only access


File Date Author Commit
 _doc 2018-08-04 Anthon van der Neut Anthon van der Neut [1d3638] fixed links/badges
 _test 2018-08-02 Anthon van der Neut Anthon van der Neut [e1589a] updates before oitnb
 .hgtags 2018-08-04 Anthon van der Neut Anthon van der Neut [48e2a3] Added tag 0.1.4 for changeset 1d36381711bb
 LICENSE 2018-06-26 Anthon van der Neut Anthon van der Neut [a56482] first public version
 README.rst 2018-08-04 Anthon van der Neut Anthon van der Neut [4a50a4] fix link
 __init__.py 2018-08-04 Anthon van der Neut Anthon van der Neut [1d3638] fixed links/badges
 __main__.py 2018-08-04 Anthon van der Neut Anthon van der Neut [d6e11d] post oitnb, added badges
 develop.py 2018-08-04 Anthon van der Neut Anthon van der Neut [0bc4a1] fix output decoding
 hgignore.py 2018-08-04 Anthon van der Neut Anthon van der Neut [f6bb1a] various extensions, switched to using detox
 readme.py 2018-08-04 Anthon van der Neut Anthon van der Neut [d6e11d] post oitnb, added badges
 revertablefile.py 2018-08-04 Anthon van der Neut Anthon van der Neut [f6bb1a] various extensions, switched to using detox
 setup.py 2018-08-04 Anthon van der Neut Anthon van der Neut [f6bb1a] various extensions, switched to using detox
 tox.ini 2018-08-04 Anthon van der Neut Anthon van der Neut [f6bb1a] various extensions, switched to using detox
 toxini.py 2018-08-04 Anthon van der Neut Anthon van der Neut [f6bb1a] various extensions, switched to using detox
 ununinit.py 2018-08-04 Anthon van der Neut Anthon van der Neut [f6bb1a] various extensions, switched to using detox

Read Me

# coding: utf-8

from __future__ import print_function, absolute_import, division, unicode_literals


"""
Work with project README information: README.rst, CHANGES

The idea is that this information is only read once, but can be updated
and written multiple times.

Although these files are normally under revision control, they are not that big
and revert information (the original read file content) are kept and can be
written out.

"""

from .revertablefile import RevertableFile, LineNotFound, MultipleLinesFound


class ReadMe(RevertableFile):
    def find_single_line_starting_with(self, val, raise_on_error=True):
        res = []
        for idx, line in enumerate(self.lines):
            if line.startswith(val):
                res.append(idx)
        if len(res) == 1:
            return res[0]
        if not raise_on_error:
            return None
        if len(res) > 0:
            raise MultipleLinesFound(f'\n  too many lines found starting with [{val}]: {res}')
        assert len(res) == 0
        raise LineNotFound(f'no line found starting with [{val}]')
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.