Differences between revisions 4 and 5
Revision 4 as of 2004-08-17 03:48:45
Size: 2757
Editor: Zoom.Quiet
Comment: 输出为一个复合列表
Revision 5 as of 2004-08-18 03:34:31
Size: 5990
Editor: Zoom.Quiet
Comment: 快速实现可嵌套模板标签的解析处理
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
== 040818 Templet ==
 * 快速实现可嵌套模板标签的解析处理
Line 11: Line 13:
{{{
#!python
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".

Typical use is for functions that do different things depending on their argument types, like the following:


from types import *
def delete(list, item):
    if type(item) is IntType:
       del list[item]
    else:
       list.remove(item)

The module defines the following names:


NoneType
The type of None.

TypeType
The type of type objects (such as returned by type() ).

IntType
The type of integers (e.g. 1).

LongType
The type of long integers (e.g. 1L).

FloatType
The type of floating point numbers (e.g. 1.0).

ComplexType
The type of complex numbers (e.g. 1.0j). This is not defined if Python was built without complex number support.

StringType
The type of character strings (e.g. 'Spam').

UnicodeType
The type of Unicode character strings (e.g. u'Spam'). This is not defined if Python was built without Unicode support.

TupleType
The type of tuples (e.g. (1, 2, 3, 'Spam')).

ListType
The type of lists (e.g. [0, 1, 2, 3]).

DictType
The type of dictionaries (e.g. {'Bacon': 1, 'Ham': 0}).

DictionaryType
An alternate name for DictType.

FunctionType
The type of user-defined functions and lambdas.

LambdaType
An alternate name for FunctionType.

GeneratorType
The type of generator-iterator objects, produced by calling a generator function. New in version 2.2.

CodeType
The type for code objects such as returned by compile() .

ClassType
The type of user-defined classes.

InstanceType
The type of instances of user-defined classes.

MethodType
The type of methods of user-defined class instances.

UnboundMethodType
An alternate name for MethodType.

BuiltinFunctionType
The type of built-in functions like len() or sys.exit().

BuiltinMethodType
An alternate name for BuiltinFunction.

ModuleType
The type of modules.

FileType
The type of open file objects such as sys.stdout.

XRangeType
The type of range objects returned by xrange() .

SliceType
The type of objects returned by slice() .

EllipsisType
The type of Ellipsis.

TracebackType
The type of traceback objects such as found in sys.exc_traceback.

FrameType
The type of frame objects such as found in tb.tb_frame if tb is a traceback object.

BufferType
The type of buffer objects created by the buffer() function.

StringTypes
A sequence containing StringType and UnicodeType used to facilitate easier checking for any string object. Using this is more portable than using a sequence of the two string types constructed elsewhere since it only contains UnicodeType if it has been built in the running version of Python. For example: isinstance(s, types.StringTypes). New in version 2.2.

}}}

Otter 核心开发日志

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

开发节点

简述各个时期的开发重心

040818 Templet

  • 快速实现可嵌套模板标签的解析处理

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

040817 XML

  • 商定代码组织;
  • 完成XML 解析模块 OtXML.py
  • * 输出为一个复合列表

['###./@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

  • XML schema 确认,
  • 个人开始寻找,XML 解析,代码模板解析方式
    • 040816 19:50 尝试

   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 开始

  • QQ+Msn 与HD 讨论,明白Otter 的开发目标,方式
  • 最小特性开发,保证每一细小的特性KO先!

  • 每日保持就感!

zqOtterDevLog (last edited 2009-12-25 07:16:43 by localhost)