comparison pyikriam/buildings.py @ 246:60c4b4b78a01

code clean
author "Hisn Yi, Chen <ossug.hychen@gmail.com>"
date Mon, 01 Dec 2008 00:25:07 +0800
parents 550e20dd7573
children
comparison
equal deleted inserted replaced
244:fd6c3660cd38 246:60c4b4b78a01
1 from lazy.www import c 1 from lazy.www import c, Resource
2 from lxml import etree 2 from lxml import etree
3 from StringIO import StringIO 3 from StringIO import StringIO
4 from sync_utils import sync_tagclass, sync_tagvalue 4 from sync_utils import sync_tagclass, sync_tagvalue
5 from sync_utils import sync_tagcount, sync_tagclass_start_appear 5 from sync_utils import sync_tagcount, sync_tagclass_start_appear
6 from sync_utils import ikariam_zh_timeval 6 from sync_utils import ikariam_zh_timeval
190 def __init__(self, city_id, idx, baseurl): 190 def __init__(self, city_id, idx, baseurl):
191 super(shipyard, self).__init__('shipyard', city_id, idx, baseurl) 191 super(shipyard, self).__init__('shipyard', city_id, idx, baseurl)
192 pass 192 pass
193 pass 193 pass
194 194
195 class safehouse(building):
196 def __init__(self, city_id, idx, baseurl):
197 super(shipyard, self).__init__('safehouse', city_id, idx, baseurl)
198 self.data_patterns = {
199 'vacancy_spys_total':"/::input[@id='spyCount']/@value",
200 'trained_spys_total':"/descendant::div[@id='mainview']/div[4]/div[1]/p/span/span[2]/text()"}
201 pass
202
203 def __sync__(self, page_dom):
204 workflow = create_workflow('find', page_dom)
205 attrs = workflow.findall(self.data_patterns).get_content()
206 for attr_name, attr_value in attrs:
207 setattr(self, attr_name, attr_value)
208 pass
209 pass
210
211 def _mk_spy(self):
212 import spys
213
195 class empty_pos(position): 214 class empty_pos(position):
196 res_patterns = { 215 res_patterns = {
197 'wood': 'wood', 216 'wood': 'wood',
198 'marble': 'marble', 217 'marble': 'marble',
199 'crystal': 'glass' 218 'crystal': 'glass'