diff pyikriam/__init__.py @ 170:7df753a99926

merged
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sun, 02 Nov 2008 02:23:13 +0800
parents 6ab01f709650
children 60c4b4b78a01
line wrap: on
line diff
--- a/pyikriam/__init__.py	Sun Nov 02 02:21:05 2008 +0800
+++ b/pyikriam/__init__.py	Sun Nov 02 02:23:13 2008 +0800
@@ -1,54 +1,3 @@
-from lazy.www import c
-from lconf import LoadConfigfile
-import cookielib
-import os
-import urllib2
-import urllib
-class Ikariam:
-
-    cities = {}
-
-    def __init__(self):
-        self.COOKIEFILE = '/tmp/ikariam.lwp'
-	self.confdata=LoadConfigfile().cd
-        self.baseurl='http://'+self.confdata['server']
-        self.cj = cookielib.LWPCookieJar()
-        if os.path.isfile(self.COOKIEFILE):
-            self.cj.load(self.COOKIEFILE)
- 
-        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cj))
-        opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-TW; rv:1.8.1.12pre) Gecko/20071220 BonEcho/2.0.0.12pre')]
-        urllib2.install_opener(opener)
-
-        self.login()
+from ikariam import Ikariam
 
-    def login(self):     
-	print "login to %s...." % self.confdata['server']
-        params = {"universe":self.confdata['server'], \
-        "name":self.confdata['user'], \
-        "password":self.confdata['pass']}
-        ret = c(self.baseurl+'/index.php?action=loginAvatar&function=login').get(params).get_content()
-        self.cj.save(self.COOKIEFILE)
-        
-    def logout(self):
-	print "logut from %s...." % self.confdata['server']
-        c(self.baseurl+'/index.php?action=loginAvatar&function=logout')
-        os.remove(self.COOKIEFILE)
-        
-    def city(self, id):
-	return self.cities.get(id, IkariamCity(id=id, core=self) )
-    
-class IkariamCity:
-    
-    def __init__(self, id, core ):
-        self.core = core
-        self.id = id
-        self.params = {'view':'city','id':id}
-        
-    def sync(self):
-	print "pull datas of the city %s" % self.id
-        xpath_globalinfo = "/html/body[@id='city']/div[@id='container']/div[@id='container2']/div[@id='globalResources']/ul"
-
-        xpath_gold = xpath_globalinfo + "/li[2]/a/span[@id='value_gold']/text()"
-        self.gold = c(self.core.baseurl).get(self.params).find(xpath_gold).get_content()[0]
-        
+__all__ = ('Ikariam',)