some code beautifications

This commit is contained in:
tao.takashi
2008-09-03 23:00:27 +00:00
committed by Salad Dais
parent 6a6dd5fdb1
commit 23446625ca
2 changed files with 13 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ from template import MsgData, MsgBlockData, MsgVariableData
#NOTE: right now there is no checking with the template
class Message(MsgData):
def __init__(self, name, *args):
super(Message, self).__init__(name)
self.parse_blocks(args)
@@ -16,6 +17,7 @@ class Message(MsgData):
self.add_block(block)
class Block(MsgBlockData):
def __init__(self, name, **kwds):
super(Block, self).__init__(name)
self.__parse_vars(kwds)

View File

@@ -33,13 +33,12 @@ import grokcore.component as grok
from interfaces import IMessageData
#this probably needs to implement an interface so it can be serialized
class MsgData(object):
implements(IMessageData)
""" Used as a Message that is being created that will be
serialized and sent. """
implements(IMessageData)
def __init__(self, name):
self.name = name
self.size = 0
@@ -57,10 +56,10 @@ class MsgData(object):
def add_data(self, block_name, var_name, data, data_size):
get_block(block_name).add_data(var_name, data, data_size)
#this probably needs to implement an interface so it can be serialized
class MsgBlockData(object):
""" Used as a Message block that is being created that will be
serialized and sent. """
def __init__(self, name):
self.name = name
self.size = 0
@@ -87,12 +86,17 @@ class MsgVariableData(object):
self.data = data
class MessageTemplateVariable(object):
"""TODO: Add docstring"""
def __init__(self, name, tp, size):
self.name = name
self.type = tp
self.size = size
class MessageTemplateBlock(object):
"""TODO: Add docstring"""
def __init__(self, name):
self.variables = []
self.variable_map = {}
@@ -111,9 +115,11 @@ class MessageTemplateBlock(object):
return self.variable_map[name]
class MessageTemplate(object):
def __init__(self, name):
self.blocks = []
self.block_map = {}
#this is the function or object that will handle this type of message
self.received_count = 0