Mercurial > eagle-eye
diff pyikriam/sync_utils.py @ 188:bf4ddf5bffb9
Extracts information about resources required to upgrade a building.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 02 Nov 2008 22:31:06 +0800 |
parents | 6adad3bcca78 |
children | 015ac84d038c |
line wrap: on
line diff
--- a/pyikriam/sync_utils.py Sun Nov 02 16:33:01 2008 +0800 +++ b/pyikriam/sync_utils.py Sun Nov 02 22:31:06 2008 +0800 @@ -2,6 +2,8 @@ # \brief Sync information of objects with DOM trees of respective pages. # +import re as _re + def sync_tagclass(obj, patterns, page_dom): xpath_building = '/html/body/descendant::*[@class=\'%s\']/text()' for name, clzname in patterns.items(): @@ -42,3 +44,29 @@ pass pass +_reo_tv = _re.compile(u'(([0-9]+)\u6642)? ?(([0-9]+)\u5206)? ?(([0-9]+)\u79d2)?') +## \brief Translate timeval in Chinese text format to integer seconds. +# +def ikariam_zh_timeval(tv_str): + tmo = _reo_tv.match(tv_str) + if not tmo: + raise SyntaxError, \ + '%s is an invalid time interval string' % (repr(tv_str)) + tv = 0 + + value = tmo.group(2) # hour + if value: + tv = tv + int(value) * 360 + pass + + value = tmo.group(4) # minute + if value: + tv = tv + int(value) * 60 + pass + + value = tmo.group(6) # second + if value: + tv = tv + int(value) + pass + + return tv