cti
.builder
index
/home/miyabe/workspaces/copper_ext/cti.python/src/code/cti/builder.py
$Id: builder.py 932 2013-05-31 05:28:13Z miyabe $
Modules
tempfile
Classes
Fragment
NullBuilder
StreamBuilder
FileBuilder
class
FileBuilder
(
StreamBuilder
)
ファイルに対して結果を構築するオブジェクトです。
Methods defined here:
__init__
(self, file)
結果構築オブジェクトを作成します。
file: 結果ファイル
finish
(self)
serial_write
(self, data)
Methods inherited from
StreamBuilder
:
add_block
(self)
block_write
(self, id, data)
close_block
(self, id)
dispose
(self)
insert_block_before
(self, anchor_id)
class
Fragment
Methods defined here:
__init__
(self, id)
flush
(self, tempFile, out)
フラグメントの内容を吐き出して、フラグメントを破棄します。
tempFile: 一時ファイル
out: 出力先ストリーム( IO )
write
(self, tempFile, onMemory, segment, bytes)
フラグメントにデータを書き込みます。
tempFile: 一時ファイル
onMemory: メモリ上に置かれたデータの合計サイズ
segment: セグメント番号シーケンス
bytes: データ
戻り値: 書き込んだバイト数
class
NullBuilder
このオブジェクトは結果を構築しません。
Methods defined here:
add_block
(self)
block_write
(self, id, data)
close_block
(self, id)
dispose
(self)
finish
(self)
insert_block_before
(self, anchor_id)
serial_write
(self, data)
class
StreamBuilder
ストリームに対して結果を構築するオブジェクトです。
Methods defined here:
__init__
(self, out, finish_func
=None
)
結果構築オブジェクトを作成します。
out: 出力先ストリーム
finish_func: 結果を実際に出力する前に呼び出されるコールバック関数。引数として結果のバイト数が渡されます
例:
def content_type(opts):
print "Content-Type: "+opts['mime_type']
def content_length(length):
print "Content-Length: "+str(length)
print
results = SingleResult(
StreamBuilder
(sys.stdout, content_length), content_type)
add_block
(self)
block_write
(self, id, data)
close_block
(self, id)
dispose
(self)
finish
(self)
insert_block_before
(self, anchor_id)
serial_write
(self, data)
Data
FRG_MEM_SIZE
= 256
ON_MEMORY
= 1048576
SEGMENT_SIZE
= 8192