Mercurial > eagle-eye
view pyikriam/lconf.py @ 232:978a949602e5
Auto-update Scientists numbers for Academy.
Refined the rules for safehouse, the safe house must be same or higher level then Town Hall.
Make people very happy, when the townHall is less then 16.
Build museum first then tavern
THG: changed warfare.pl
author | "Rex Tsai <chihchun@kalug.linux.org.tw>" |
---|---|
date | Thu, 06 Nov 2008 20:31:05 +0800 |
parents | d4b7d8f51e9f |
children |
line wrap: on
line source
import os, string import re _user_home = os.environ['HOME'] dfl_profile = os.path.join(_user_home, '.eagleeye.pm') _reo_assign = re.compile('^\\$::([_a-zA-Z][_a-zA-Z0-9]+) *= *([\'"][^"]*[\'"]).*$') def _real_load_conf(conf_o): confs = [_reo_assign.match(line) for line in conf_o if line.startswith('$::')] cd = dict([(mo.group(1), eval(mo.group(2))) for mo in confs if mo]) return cd class LoadConfigfile(object): def __init__(self, profile=dfl_profile): prof_o = open(profile, 'r') self.cd = _real_load_conf(prof_o) pass pass if __name__ == '__main__': from StringIO import StringIO conf = ''' $::user = "alsfjsf"; #lsfjslf $::server = "fkljalfasf"; # sfjslf $::pass = "lsfjslfsf"; ''' conf_o = StringIO(conf) cd = _real_load_conf(conf_o) print cd pass