Atlas 0.7.0
Networking protocol for the Worldforge system.
decoder.py
1#base decoder class
2
3#Copyright 2002 by AIR-IX SUUNNITTELU/Ahiplan Oy
4
5#This library is free software; you can redistribute it and/or
6#modify it under the terms of the GNU Lesser General Public
7#License as published by the Free Software Foundation; either
8#version 2.1 of the License, or (at your option) any later version.
9
10#This library is distributed in the hope that it will be useful,
11#but WITHOUT ANY WARRANTY; without even the implied warranty of
12#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13#Lesser General Public License for more details.
14
15#You should have received a copy of the GNU Lesser General Public
16#License along with this library; if not, write to the Free Software
17#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20import atlas
21
23 def setup(self, stream_flag=None):
24 self.data = ""
25 self.msgList = []
26 self.set_stream_mode(stream_flag)
27
28 def set_stream_mode(self, mode=1):
29 self.stream_flag = mode
30
31 def parse_init(self): pass
32
33 def parse_stream(self, msg):
34 self.parse_init()
35 self.msg=msg
36 self.feed(msg) #inherited from XMLParser
37 if self.stream_flag:
38 res=atlas.Messages(*tuple(self.msgList))
39 self.msgList=[]
40 return res
41 else:
42 if self.msgList:
43 res = self.msgList.pop(0)
44 else:
45 res = None
46 return res
47 __call__=parse_stream #this makes possible to call instance like
48 #it was function
def set_stream_mode(self, mode=1)
Definition: decoder.py:28