def parse_properties(filebuf):
    """
    Parses the given file using the Java properties file format.
    Lines beginning with # are ignored.
    :param file: an open iterator into the file
    :return: the properties in the file as a dictionary
    """
    return java_util.parse_properties(filebuf.splitlines())
Пример #2
0
def test_parse_properties():
    properties = """
    prop1=val1
    prop2 = val2
    #prop3 = ignored due to comments
      prop4 = val4
    """

    props = java_util.parse_properties(properties.splitlines())

    assert props["prop1"] == "val1"
    assert props["prop2"] == "val2"
    assert "prop3" not in props
    assert props["prop4"] == "val4"
Пример #3
0
def test_parse_properties():
    properties = """
    prop1=val1
    prop2 = val2
    #prop3 = ignored due to comments
      prop4 = val4
    """

    props = java_util.parse_properties(properties.splitlines())

    assert props['prop1'] == 'val1'
    assert props['prop2'] == 'val2'
    assert 'prop3' not in props
    assert props['prop4'] == 'val4'