Hi all,

I am a Europa Universalis II freak, and in attempting to recreate a lost saved game, I had to delve into the mechanics of the save game file.
Which, luckily, is plain text.

It's formatted like this -

country = {
    tag = ENG
    ai = {
        flags = { }
        combat = { DAU FRA ORL PRO }
        continent = { }
        area = { }
        region = { "British Isles" "NorthSeaSea" "ECAtlanticSea" "NAtlanticSea" "TagoSea" "WCAtlanticSea" }
        war = 60
        ferocity = no
       }
}

Now, it tends to conform to certain rules, which make it a bit easier, there's always a space either side of an equals sign and such forth, which should hopefully make parsing stuff like -

date = { year = 1421 month = july day = 7 }

a bit less complex, considering that it uses space to separate list items.

What I need to do, is to turn this into a data structure, and I think this relates to XML in a way. Basically, I want to parse the above (I assume I'll be counting braces to find where I am) so that a country object called ENG has a dictionary called ai, which points to lists, integers, strings etc. and so forth. 

If anyone has any links to any (simple) examples of XML parsing or similar which could give me pointers as to how to go about this, it'd be much appreciated.

Regards,

Liam Clarke
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to