Otter 核心开发日志

-- Zoom.Quiet [DateTime(2004-08-16T00:15:40Z)] TableOfContents

开发节点

简述各个时期的开发重心

040818 Templet

    设计的标签系统:
        - ###XPath### 值替换标签
        - ###start###XPath### ; ###end###XPath### 块标签,返回进一步处理后的整块文本
        - ###loop###XPath### 行标签,通过传入数值列来在行的单位中进行值替换处理

from ###./@ProtocolName###.message import bytemsg
import struct

class ###./Protocol/@ProtocolName###Message(bytemsg.ByteMessage):
    """###./Protocol/@ProtocolName### 消息基类"""
    def __init__(self):
        # 消息头
        self.head = bytemsg.ByteMessageHead(self)
        # 消息体
        self.body = bytemsg.ByteMessageBody(self)
        # 消息工具
        self.msgutilcls = ###./Protocol/@ProtocolName###MessageUtil
        # 协议名称
        self.protocolname = '###./Protocol/@ProtocolName###'
        # 当前的消息名称
        self.msgname = ''

    ###start###./Message/Commands/Command###
    def pack_###./Protocol/@ProtocolName###_###CommandName###(self, fields):
        """###CommandName###报文打包"""
        return struct.pack('###Field###',
                ###loop###Fields###
                )
    def unpack_###./Protocol/@ProtocolName###_###CommandName###(self, packet):
        """###CommandName###报文解包"""
        ###loop###Field###
            struct.unpack('###Field###',packet)    
    ###end###./Message/Commands/Command###
    
# ###./Protocol/@ProtocolName### Message定义
###./Protocol/@ProtocolName###MessageUtil.commandinfo = {
    ###loop###commandinfo###
    }

# 通过名称查出消息ID的结构定义
###./Protocol/@ProtocolName###MessageUtil.nametoid = {}
for k in ###./Protocol/@ProtocolName###MessageUtil.commandinfo.keys():
    ###./Protocol/@ProtocolName###MessageUtil.nametoid[###./Protocol/@ProtocolName###MessageUtil.commandinfo[k]] = k


types -- Names for all built-in types

This module defines names for all object types that are used by the standard Python interpreter, but not for the types defined by various extension modules. It is safe to use "from types import *" -- the module does not export any names besides the ones listed here. New names exported by future versions of this module will all end in "Type".

   1 Typical use is for functions that do different things depending on their argument types, like the following: 
   2 
   3 
   4 from types import *
   5 def delete(list, item):
   6     if type(item) is IntType:
   7        del list[item]
   8     else:
   9        list.remove(item)
  10 
  11 The module defines the following names: 
  12 
  13 
  14 NoneType 
  15 The type of None. 
  16 
  17 TypeType 
  18 The type of type objects (such as returned by type() ). 
  19 
  20 IntType 
  21 The type of integers (e.g. 1). 
  22 
  23 LongType 
  24 The type of long integers (e.g. 1L). 
  25 
  26 FloatType 
  27 The type of floating point numbers (e.g. 1.0). 
  28 
  29 ComplexType 
  30 The type of complex numbers (e.g. 1.0j). This is not defined if Python was built without complex number support. 
  31 
  32 StringType 
  33 The type of character strings (e.g. 'Spam'). 
  34 
  35 UnicodeType 
  36 The type of Unicode character strings (e.g. u'Spam'). This is not defined if Python was built without Unicode support. 
  37 
  38 TupleType 
  39 The type of tuples (e.g. (1, 2, 3, 'Spam')). 
  40 
  41 ListType 
  42 The type of lists (e.g. [0, 1, 2, 3]). 
  43 
  44 DictType 
  45 The type of dictionaries (e.g. {'Bacon': 1, 'Ham': 0}). 
  46 
  47 DictionaryType 
  48 An alternate name for DictType. 
  49 
  50 FunctionType 
  51 The type of user-defined functions and lambdas. 
  52 
  53 LambdaType 
  54 An alternate name for FunctionType. 
  55 
  56 GeneratorType 
  57 The type of generator-iterator objects, produced by calling a generator function. New in version 2.2. 
  58 
  59 CodeType 
  60 The type for code objects such as returned by compile() . 
  61 
  62 ClassType 
  63 The type of user-defined classes. 
  64 
  65 InstanceType 
  66 The type of instances of user-defined classes. 
  67 
  68 MethodType 
  69 The type of methods of user-defined class instances. 
  70 
  71 UnboundMethodType 
  72 An alternate name for MethodType. 
  73 
  74 BuiltinFunctionType 
  75 The type of built-in functions like len() or sys.exit(). 
  76 
  77 BuiltinMethodType 
  78 An alternate name for BuiltinFunction. 
  79 
  80 ModuleType 
  81 The type of modules. 
  82 
  83 FileType 
  84 The type of open file objects such as sys.stdout. 
  85 
  86 XRangeType 
  87 The type of range objects returned by xrange() . 
  88 
  89 SliceType 
  90 The type of objects returned by slice() . 
  91 
  92 EllipsisType 
  93 The type of Ellipsis. 
  94 
  95 TracebackType 
  96 The type of traceback objects such as found in sys.exc_traceback. 
  97 
  98 FrameType 
  99 The type of frame objects such as found in tb.tb_frame if tb is a traceback object. 
 100 
 101 BufferType 
 102 The type of buffer objects created by the buffer() function. 
 103 
 104 StringTypes 

040817 XML

['###./@Version###', '0.1']

['###./@ProtocolName###', 'uss']

['###./@PersistentConnection###', 'false']

['###./@OtBaseDir###', 'OtterBaseTemplet']

['###./Message/@MessageName###', 'usspmsg']

['###./Message/@OtBaseDir###', 'message']

['###./Message/@OtBaseFile###', 'bytemsg.py']

['###./Message/Commands/Command###', 'generic_noop', '0x00000000L'], ['generic_noop_resp', '0xff000000L'], ['connect', '0x00000001L', [['system_id', '6', 's'], ['auth_source', '16', 's'], ['version', None, 'I'], ['time_stamp', '8', 's'], ['connect_resp', '0xff000001L', 'status', None, 'I'], ['version', None, 'I'], ['terminate', '0x00000002L'], ['terminate_resp', '0xff000002L'], ['mail_counter', '0x00000005L'], ['mail_counter_resp', '0xff000005L']], ('CommandName', 'CommandID'), ('FieldName', 'FieldSize', 'FieldType')]

['###./Protocol/@ProtocolName###', 'ussp']

['###./Protocol/@ListenPort###', '7890']

['###./Protocol/@OtBaseDir###', 'protocols']

['###./Protocol/@OtBaseFile###', 'byteprotocol.py']

['###./Protocol/ClientProtocol/Command###', 'generic_noop_resp', '0xff000000L'], ['connect_resp', '0xff000001L'], ['terminate', '0x00000002L'], ['terminate_resp', '0xff000002L'], ['mail_counter_resp', '0xff000005L', ('CommandName', 'CommandID')]

['###./Protocol/ServerProtocol/Command###', 'generic_noop', '0x00000000L'], ['connect', '0x00000001L'], ['terminate', '0x00000002L'], ['terminate_resp', '0xff000002L'], ['mail_counter', '0x00000005L', ('CommandName', 'CommandID')]

040816 XSD

   1 # -*- coding: utf-8 -*-
   2 # file OtterTools.py
   3 #
   4 """Otter Tools main script
   5 
   6 @version: 0.1a
   7 @author: U{Zoom.Quiet<mailto:[email protected]>}
   8 @see: http://wiki.woodpecker.org.cn/moin.cgi/Otter_2fOtterTool
   9 """
  10 import sys,string
  11 from elementtree import ElementTree
  12 if __name__ == '__main__':      # this way the module can be
  13     """
  14     应用 Elements and Element Trees 来通过XPath 迅速理解XML
  15     """
  16     file = open("uss.xml", "r")
  17     weblog = ElementTree.parse('uss.xml').getroot()
  18     commands = weblog.findall('.//Command')
  19     for node in commands:
  20         print node.attrib["CommandID"] 

040815 开始