Exemplo n.º 1
0
def read_markdown(path):
    """Read a Markdown file.

    Returns `(front_matter, content)`, where `front_matter` is the unparsed TOML
    text at the beginning of the file, and `content` is the main Markdown
    content. The "+++" delimiters do not appear in either.

    """
    path = Path(path)

    with path.open('rt') as f:
        line = f.readline()
        assert line == '+++\n'

        front_matter = []

        while True:
            line = f.readline()
            if line == '+++\n':
                break

            front_matter.append(line)

        front_matter = ''.join(front_matter)
        content = f.read()

    return front_matter, content
Exemplo n.º 2
0
def lock_domain_range_cli(settings):
    from . import DomainRange

    # Load samples
    df = basic_load(settings.datadir)

    # Load skeleton config
    cfg_path = Path(settings.nndir) / 'nn_config.toml'
    with cfg_path.open('rt') as f:
        info = pytoml.load(f)

    # Turn into processed DomainRange object
    dr = DomainRange.from_info_and_samples(info, df)

    # Update config and rewrite
    dr.into_info(info)

    with cfg_path.open('wt') as f:
        pytoml.dump(f, info)