configparser.py 449 Bytes
Newer Older
1 2 3
from __future__ import absolute_import

import configparser
Dion Haefner's avatar
Dion Haefner committed
4 5 6 7 8 9 10 11

def add_section_header(properties_file, header_name):
    # configparser.ConfigParser requires at least one section header
    yield '[{}]\n'.format(header_name)
    for line in properties_file:
        yield line

def cp(path):
12 13 14
    with open(path) as f:
        config = configparser.RawConfigParser()
        config.read_file(add_section_header(f, "nosection"), path)
Dion Haefner's avatar
Dion Haefner committed
15
    return config