backup de julho
[h2N7SspZmY.git] / data / cache / 4 / 4aeb360fb7429e69f1096dc0c35dd5c9.i
blobe572b2ebf368cada6aa693495a949af1d7255038
1 a:20:{i:0;a:3:{i:0;s:14:"document_start";i:1;a:0:{}i:2;i:0;}i:1;a:3:{i:0;s:6:"p_open";i:1;a:0:{}i:2;i:0;}i:2;a:3:{i:0;s:7:"p_close";i:1;a:0:{}i:2;i:1;}i:3;a:3:{i:0;s:12:"section_edit";i:1;a:4:{i:0;i:-1;i:1;i:0;i:2;i:1;i:3;s:0:"";}i:2;i:1;}i:4;a:3:{i:0;s:6:"header";i:1;a:3:{i:0;s:9:"Appengine";i:1;i:1;i:2;i:1;}i:2;i:1;}i:5;a:3:{i:0;s:12:"section_open";i:1;a:1:{i:0;i:1;}i:2;i:1;}i:6;a:3:{i:0;s:6:"p_open";i:1;a:0:{}i:2;i:24;}i:7;a:3:{i:0;s:5:"cdata";i:1;a:1:{i:0;s:1:"
2 ";}i:2;i:25;}i:8;a:3:{i:0;s:12:"externallink";i:1;a:2:{i:0;s:33:"http://code.google.com/appengine/";i:1;s:16:"Google Appengine";}i:2;i:26;}i:9;a:3:{i:0;s:7:"p_close";i:1;a:0:{}i:2;i:80;}i:10;a:2:{i:0;s:6:"plugin";i:1;a:4:{i:0;s:7:"uparrow";i:1;a:1:{i:0;s:42:"lib/plugins/uparrow/images/tango-small.png";}i:2;i:1;i:3;s:6:"~~UP~~";}}i:11;a:3:{i:0;s:13:"section_close";i:1;a:0:{}i:2;i:82;}i:12;a:3:{i:0;s:12:"section_edit";i:1;a:4:{i:0;i:1;i:1;i:81;i:2;i:1;i:3;s:9:"Appengine";}i:2;i:82;}i:13;a:3:{i:0;s:6:"header";i:1;a:3:{i:0;s:7:"Example";i:1;i:2;i:2;i:82;}i:2;i:82;}i:14;a:3:{i:0;s:12:"section_open";i:1;a:1:{i:0;i:2;}i:2;i:82;}i:15;a:3:{i:0;s:4:"code";i:1;a:3:{i:0;s:4160:"
3 from google.appengine.ext import webapp
4 from google.appengine.ext.webapp.util import run_wsgi_app
5 from google.appengine.ext import db
6 import urllib
7 from HTMLParser import HTMLParser
8 import re
10 class MyHTMLParser(HTMLParser):
11 def __init__(self):
12 HTMLParser.__init__(self)
13 self.s = ''
15 def handle_starttag(self, tag, attrs):
16 if tag == 'embed':
17 for attr in attrs:
18 if attr[0] == 'flashvars':
19 self.s = attr[1]
21 def feed(self, data):
22 HTMLParser.feed(self, data)
23 return self
25 def get_s(self):
26 return self.s
28 class Level(db.Model):
29 content = db.TextProperty()
31 class Current(db.Model):
32 x = db.IntegerProperty()
33 y = db.IntegerProperty()
34 d = db.IntegerProperty()
35 n = db.IntegerProperty()
36 m = db.IntegerProperty()
37 l = db.IntegerProperty()
39 class Wrong(db.Model):
40 x = db.IntegerProperty()
41 y = db.IntegerProperty()
42 d = db.IntegerProperty()
43 l = db.IntegerProperty()
45 class CrossPage(webapp.RequestHandler):
46 def get(self):
47 url = 'http://www.hacker.org/cross/index.php?name=kauesilv&password=a1b2c3d4'
48 regex = r'boardinit = "([^"]*)"'
49 debug = self.request.get('debug')
50 s = self.request.get('s')
51 path = self.request.get('path')
52 self.response.headers['Content-Type'] = 'text/plain'
53 if s == '1':
54 urllib.urlopen(url + '&sol=' + path).read()
55 s = urllib.urlopen(url).read()
56 #self.response.out.write(s + '\n')
57 board = re.compile(regex).search(s).groups()[0].split(',')
58 self.response.out.write(str(len(board)) + '\n' + str(len(board[0])) + '\n')
59 for line in board:
60 self.response.out.write(str(line) + '\n')
62 class MainPage(webapp.RequestHandler):
63 def get(self):
64 delete = self.request.get('delete')
65 if delete == '1':
66 db.delete(Wrong.all().fetch(100))
67 if Wrong.all().count(1) == 1:
68 return
70 url = 'http://www.hacker.org/coil/index.php?name=kauesilv&password=a1b2c3d4'
71 regex = r'x=(\d*)&y=(\d*)&board=(.*)'
72 regexLevel = r'Level: (\d*)'
73 self.response.headers['Content-Type'] = 'text/plain'
74 debug = self.request.get('debug')
75 s = self.request.get('s')
76 r = self.request.get('r')
77 x = self.request.get('x')
78 y = self.request.get('y')
79 d = self.request.get('d')
80 w = self.request.get('w')
81 path = self.request.get('path')
83 levels = Level.all()
84 currents = Current.all()
86 if s == '1':
87 urllib.urlopen(url + '&x=' + x + '&y=' + y + '&path=' + path).read()
89 if w == '1':
90 wrong = Wrong()
91 wrong.x = int(x)
92 wrong.y = int(y)
93 wrong.d = int(d)
94 wrong.l = currents.fetch(1)[0].l
95 wrong.put()
97 if s == '1' or r == '1':
98 s = urllib.urlopen(url).read()
99 x, y, board = re.compile(regex).search(MyHTMLParser().feed(s).get_s()).groups()
100 lvl, = re.compile(regexLevel).search(s).groups()
101 db.delete(Level.all().fetch(1000000))
102 db.delete(Current.all().fetch(1000000))
104 level = Level()
105 level.content = x + '\n' + y + '\n' + board + '\n'
106 level.put()
108 current = Current()
109 current.x = current.y = current.d = 0
110 current.n = int(x)
111 current.m = int(y)
112 current.l = int(lvl)
113 current.put()
115 cur = currents.fetch(1)[0]
116 while(True):
117 cur.d = cur.d + 1
118 if(cur.d == 4):
119 cur.d = 0
120 cur.y = cur.y + 1
121 if(cur.y == cur.m):
122 cur.y = 0
123 cur.x = cur.x + 1
124 if(cur.x == cur.n):
125 cur.x = 0
126 cur.put()
127 wrong = Wrong().gql("WHERE x = :1 AND y = :2 AND d = :3 AND l = :4", cur.x, cur.y, cur.d, cur.l)
128 if(wrong.count(1) == 0):
129 break
131 self.response.out.write(str(cur.x) + '\n' + str(cur.y) + '\n' + str(cur.d) + '\n' + str(cur.l) + '\n')
132 self.response.out.write(levels.fetch(1)[0].content)
134 if debug == '1':
135 self.response.out.write('\n\n----DEBUG----\n\nwrongs\n')
136 wrongs = Wrong.gql("WHERE l = :1", cur.l)
137 for wrong in wrongs:
138 self.response.out.write(str(wrong.x) + ' ' + str(wrong.y) + ' ' + str(wrong.d) + ' ' + str(wrong.l) + '\n')
140 self.response.out.write('\ncurrents\n')
141 for current in currents:
142 self.response.out.write(str(current.x) + ' ' + str(current.y) + ' ' + str(current.d) + ' ' + str(current.l) + '\n')
144 application = webapp.WSGIApplication([('/', MainPage), ('/cross', CrossPage)], debug=True)
146 def main():
147 run_wsgi_app(application)
149 if __name__ == "__main__":
150 main()
151 ";i:1;s:6:"python";i:2;N;}i:2;i:108;}i:16;a:2:{i:0;s:6:"plugin";i:1;a:4:{i:0;s:7:"uparrow";i:1;a:1:{i:0;s:42:"lib/plugins/uparrow/images/tango-small.png";}i:2;i:1;i:3;s:6:"~~UP~~";}}i:17;a:3:{i:0;s:13:"section_close";i:1;a:0:{}i:2;i:4285;}i:18;a:3:{i:0;s:12:"section_edit";i:1;a:4:{i:0;i:82;i:1;i:0;i:2;i:2;i:3;s:7:"Example";}i:2;i:4285;}i:19;a:3:{i:0;s:12:"document_end";i:1;a:0:{}i:2;i:4285;}}