Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parse(self, data):
- if len(data) == 0:
- return ERR.NODAT
- if data[0] == ':':
- data = data[1:].split(' ')
- if len(data) != 0:
- prefix = data.pop(0)
- rs = prefix.find("!")
- hs = prefix.find("@")
- if hs == -1:
- hs = len(prefix)
- if rs == -1:
- rs = hs
- prefix = (prefix[:rs], prefix[rs + 1:hs], prefix[hs + 1:])
- else:
- prefix = ('', '', '')
- data = ' '.join(data)
- else:
- prefix = ('', '', '')
- pe = data.find(' :')
- trail = data[pe + 2:]
- params = data[:pe].split(' ')
- if len(params) != 0:
- com = params.pop(0)
- else:
- print "PROBLEM PARSING FOLLOWING LINE"
- print "<<" + data
- com = ""
- print str(prefix) + com + "::" + "|".join(params) + "[" + str(len(params)) + "]::" + trail
- return (prefix, (com, params, trail))
Add Comment
Please, Sign In to add comment