Read config data from pygo.cfg

This commit is contained in:
Anna Rose 2012-04-15 01:00:36 -04:00
parent 16061abf0a
commit da583678c1
2 changed files with 16 additions and 1 deletions

4
pygo.cfg Normal file
View File

@ -0,0 +1,4 @@
[general]
net_user=User
net_server=pygoserver.example.com
net_port=6859

13
pygo.py
View File

@ -6,11 +6,15 @@
import sys import sys
sys.path.append('lib/') sys.path.append('lib/')
import ConfigParser
import goban import goban
import pygogui import pygogui
def main(): def main():
# Read config file
settings = read_config_file()
# Data # Data
gb = goban.Goban() gb = goban.Goban()
network_mode = False network_mode = False
@ -20,8 +24,15 @@ def main():
gui.update(gb) gui.update(gb)
while True: while True:
event = gui.do_event(gb, network_mode, our_color) gui.do_event(gb, network_mode, our_color)
gui.update(gb) gui.update(gb)
def read_config_file():
ret = ConfigParser.ConfigParser()
ret.read('pygo.cfg')
return ret
if __name__ == '__main__': main() if __name__ == '__main__': main()