annotate pyikriam/example.py @ 228:d54e2041e4aa

fix the problem of gmail client for unread subject rules.
author kevin@59-125-147-75.HINET-IP.hinet.net
date Wed, 05 Nov 2008 00:21:57 +0800
parents bf4ddf5bffb9
children
rev   line source
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
1 import sys
177
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
2 import buildings
166
f7fd2738b9b4 Move Ikariam out of __init__.py to ikariam.py.
Thinker K.F. Li <thinker@branda.to>
parents: 162
diff changeset
3 from ikariam import Ikariam
62
a4c364888197 add ikriam game binding lib python version
hychen@mluna
parents:
diff changeset
4
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
5 if len(sys.argv) != 2:
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
6 print >> sys.stderr, 'Usage: %s <city id>' % (sys.argv[0])
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
7 sys.exit(1)
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
8 pass
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
9
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
10 city_id = int(sys.argv[1]) # 117261
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
11
64
19d2a7b175b3 Load configure data from .eagleeye.pm
kevin@localhost.localdomain
parents: 62
diff changeset
12 i = Ikariam()
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
13 city = i.city(city_id)
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
14
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
15 print "pull datas of the city %s" % (city_id)
62
a4c364888197 add ikriam game binding lib python version
hychen@mluna
parents:
diff changeset
16 city.sync()
162
e49137521123 pyikriam retrive information about land positions.
Thinker K.F. Li <thinker@branda.to>
parents: 161
diff changeset
17
160
7551342718b6 Refactory pyikriam with patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 64
diff changeset
18 print 'gold is ' + city.gold
161
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
19 print 'inhabitants is ' + city.inhabitants
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
20 print 'wood is ' + city.wood
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
21 print 'wine is ' + city.wine
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
22 print 'marble is ' + city.marble
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
23 print 'crystal is ' + city.crystal
1507c2d16b35 Extract wood, marble, crystal, sulfure, and inhabitants information.
Thinker K.F. Li <thinker@branda.to>
parents: 160
diff changeset
24 print 'sulfur is ' + city.sulfur
160
7551342718b6 Refactory pyikriam with patterns.
Thinker K.F. Li <thinker@branda.to>
parents: 64
diff changeset
25
177
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
26 for idx, pos in enumerate(city.positions):
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
27 if not isinstance(pos, buildings.position):
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
28 continue
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
29 pos.sync()
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
30 building_attrs = filter(lambda attr: not attr[0].startswith('_'),
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
31 pos.__dict__.items())
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
32 building_attrs.sort(key=lambda x: x[0])
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
33 print
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
34 print 'positions[%d]' % (idx)
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
35 for building_attr, value in building_attrs:
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
36 print '\t%s: %s' % (building_attr, repr(value))
6adad3bcca78 Refactory to functions for sychronizing object attributes with pages.
Thinker K.F. Li <thinker@branda.to>
parents: 176
diff changeset
37 pass