In Progress

A file parser class written in Python

Design and implement a class in Python 2.x that can parse the following configuration file format:

[section name 1]

key: value

key2 : value

[section name 2]

key3: value that is too long for one line, so we wrap onto a second line

and continue by using any whitespace character in the first column.

Or more specifically:

The file is broken up into named sections. The name of each section is enclosed by square brackets, and the opening bracket must be placed in column 0.

The first non-blank line in a file must be a section heading.

Each line is terminated by a CR/LF pair (on all platforms).

Whitespace between the opening bracket and the first non-whitespace character of the section name is discarded, as is any whitespace between the last character of the section name and the closing bracket. The following section names are all identical:

[Section demonstration]

[ Section demonstration]

[ Section demonstration ]

Each non blank line of the file inside a section consists of a key and a value, separated by a colon. Whitespace surrounding the colon is discarded, so the following lines are identical:

key:value

key :value

key : value

Key names within each section must be unique (but key names may be reused in different sections).

Each section name must be unique within the file.

Each key must begin in column zero.

Long lines may be wrapped by continuing them onto the next line and placing one or more whitespace characters in column zero. When reading the file in, the combination CR/LF followed by whitespace is treated as if it were just the whitespace. Only the value component of a line may be wrapped.

Your class must support at least the following operations:

Create a parser object given a file name.

Get a string value associated with a given section and key names.

Get an integer value associated with a given section and key names.

Get a floating point value associated with a given section and key names.

Set a string value for a given section and key names, writing the new file to disk.

Set an integer value for a given section and key names, writing the new file to disk.

Set a floating point value for a given section and key names, writing the new file to disk.

You may use the following test data for your development:

[header]

project: Programming Test

budget : 4.5

accessed :205

[meta data]

description : This is a tediously long description of the Art & Logic

programming test that you are taking. Tedious isn't the right word, but

it's the first word that comes to mind.

correction text: I meant 'moderately,' not 'tediously,' above.

[ trailer ]

budget:all out of budget.

Skills: Python

See more: parser written python, your writing class, writing to a file in python, writing to a file in c, writing in names, writing character development, trailer text, python writing to file, python writing to a file, python programming class, programming with python, programming logic and design, programming in python, programming class, pair of lines, pair line, in line art, get in written, cr design, continue line in c, colon writing, colon in writing, class programming, class in programming, brackets in writing

About the Employer:
( 1 review ) San Diego, United States

Project ID: #4405502

Awarded to:

pabloz1974

Hello, I can do this job with pleasure

$45 USD in 1 day
(0 Reviews)
0.0

3 freelancers are bidding on average $57 for this job

markokovacevic

Hi, I'm interested. Check your PM. Regards, Marko

$75 USD in 1 day
(1 Review)
0.8
MasterDingo

Hello. It's quite a simple task. I can start right now.

$50 USD in 1 day
(0 Reviews)
0.0