本文整理汇总了Python中Block.Block类的典型用法代码示例。如果您正苦于以下问题:Python Block类的具体用法?Python Block怎么用?Python Block使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Block类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _read
def _read(self):
Block.read(self)
if not self.valid:
return False
# FileHeader fields
self.own_key = self._get_long(1)
self.block_count = self._get_long(2)
self.first_data = self._get_long(4)
# read (limited) data blocks table
bc = self.block_count
mbc = self.blkdev.block_longs - 56
if bc > mbc:
bc = mbc
self.data_blocks = []
for i in xrange(bc):
self.data_blocks.append(self._get_long(-51-i))
self.protect = self._get_long(-48)
self.protect_flags = ProtectFlags(self.protect)
self.byte_size = self._get_long(-47)
self.comment = self._get_bstr(-46, 79)
self.mod_ts = self._get_timestamp(-23)
self.name = self._get_bstr(-20, 30)
self.hash_chain = self._get_long(-4)
self.parent = self._get_long(-3)
self.extension = self._get_long(-2)
self.valid = (self.own_key == self.blk_num)
return self.valid
示例2: getCalcuDoku
def getCalcuDoku(self):
img = self.cutOut(self.img)
self.calcuDoku = CalcuDoku(self.size)
self.extractSudoku(img, self.size)
print self.sudoku
print self.right
print self.below
self.sectors = [[None for i in range(self.size)] for j in range(self.size)]
for i in range(0, self.size):
for j in range(0, self.size):
if not self.sectors[i][j]:
if self.sudoku[i][j]:
ops = self.sudoku[i][j]
b = Block(ops)
self.calcuDoku.addBlock(b)
b.addLocation(i+1, j+1)
self.sectors[i][j] = b
self.discover(i, j)
else:
print "huh"
sys.exit(1)
return self.calcuDoku
示例3: checkPart1
def checkPart1(self, test):
if (test[0] == '"' and test[len(test)-1] == '"'):
# this is a string literal
return self.checkStringLiteral(test)
elif (test[0] == '{' and test[len(test)-1] == '}'):
# this is a block
from Block import Block
#print test[0:len(test)]
b = Block(test[0:len(test)],self.getParent())
b.setSyntaxOnly(self.syntax_only)
if (b.checkSyntax()):
if(self.syntax_only == False):
self.property_list = b.property_list
return True
else:
return False
elif (test[0] == '(' and test[len(test)-1] == ')'):
# this is an expression
e = Expression(test[1:len(test)-1],self.getParent())
e.setSyntaxOnly(self.syntax_only)
if (e.checkSyntax()):
if(self.syntax_only == False):
self.property_list = e.property_list
return True
else:
return False
elif not (self.checkAsterisk(test)):
# this is a name with none or multiple *
print ("This is an invalid Expression: " + test)
return False
return True
示例4: dump
def dump(self):
Block.dump(self,"FileList")
print " own_key: %d" % self.own_key
print " blk_cnt: %d" % self.block_count
print " data blks: %s" % self.data_blocks
print " parent: %d" % self.parent
print " extension: %d" % self.extension
示例5: create
def create(self, name, create_ts=None, disk_ts=None, mod_ts=None, extension=0, fstype=0):
Block.create(self)
# init fresh hash table
self.hash_size = self.blkdev.block_longs - 56
self.hash_table = []
for i in xrange(self.hash_size):
self.hash_table.append(0)
# timestamps
self.mod_ts = mod_ts
self.disk_ts = disk_ts
self.create_ts = create_ts
# name
self.name = name
# bitmap: blank
self.bitmap_flag = 0xffffffff
self.bitmap_ptrs = []
for i in xrange(25):
self.bitmap_ptrs.append(0)
self.bitmap_ext_blk = 0
# new stuff for DOS6 and DOS7
self.fstype = fstype
self.blocks_used = 0
self.extension = extension
示例6: write
def write(self):
self._create_data()
# hash table
self._put_long(3, self.hash_size)
for i in xrange(self.hash_size):
self._put_long(6+i, self.hash_table[i])
# bitmap
self._put_long(-50, self.bitmap_flag)
for i in xrange(25):
self._put_long(-49+i, self.bitmap_ptrs[i])
self._put_long(-24, self.bitmap_ext_blk)
# timestamps
self._put_timestamp(-23, self.mod_ts)
self._put_timestamp(-10, self.disk_ts)
self._put_timestamp(-7, self.create_ts)
# name
self._put_bstr(-20, 30, self.name)
self._put_long(-2, self.extension)
# DOS6 and DOS7 stuff
self._put_long(-11, self.blocks_used)
self._put_long(-4, self.fstype)
Block.write(self)
示例7: create
def create(self, hdr_key, seq_num, data, next_data):
Block.create(self)
self.hdr_key = hdr_key
self.seq_num = seq_num
self.data_size = len(data)
self.next_data = next_data
self.contents = data
示例8: __init__
def __init__(self, image, pos = (0,0), blocksize = [50,50], screensize = [800,600]):
Block.__init__(self, image, pos, blocksize)
self.maxSpeed = blocksize[0]/14.0
self.screensize = screensize
self.living = True
self.detectRange = 100
self.seePlayer = False
self.headingx = "right"
self.headingy = "none"
self.directionCount = 0
self.realx = pos[0]
self.realy = pos[1]
self.x = screensize[0]/2
self.y = screensize[1]/2
self.x = pos[0]
self.y = pos[1]
self.g = blocksize[0]/10
self.offsetx = 0
self.offsety = 0
self.jumpSpeed = 0
self.jumpSpeedMax = 50
self.fallSpeedMax = int(blocksize[0]/2) -2
self.onfloor = False
self.floor = screensize[1]
self.touchFloor = False
self.turn = 0
示例9: read
def read(self):
Block.read(self)
if not self.valid:
return False
# name hash
self.hash_size = self._get_long(3)
self.hash_table = []
for i in xrange(self.hash_size):
self.hash_table.append(self._get_long(6+i))
# bitmap
self.bitmap_flag = self._get_long(-50)
self.bitmap_ptrs = []
for i in xrange(25):
bm_blk = self._get_long(-49+i)
self.bitmap_ptrs.append(bm_blk)
self.bitmap_ext_blk = self._get_long(-24)
# timestamps
self.mod_ts = self._get_timestamp(-23)
self.disk_ts = self._get_timestamp(-10)
self.create_ts = self._get_timestamp(-7)
# name
self.name = self._get_bstr(-20, 30)
self.extension = self._get_long(-2)
# check validity
self.valid = True
#self.valid = (self.bitmap_flag == 0xffffffff)
return self.valid
示例10: create
def create(self, parent, name, data_blocks, extension, byte_size=0, protect=0, comment=None, mod_ts=None, hash_chain=0):
Block.create(self)
self.own_key = self.blk_num
n = len(data_blocks)
self.block_count = n
if n == 0:
self.first_data = 0
else:
self.first_data = data_blocks[0]
self.data_blocks = data_blocks
self.protect = protect
self.protect_flags = ProtectFlags(self.protect)
self.byte_size = byte_size
if comment == None:
self.comment = ''
else:
self.comment = comment
self.mod_ts = mod_ts
self.name = name
self.hash_chain = hash_chain
self.parent = parent
self.extension = extension
self.valid = True
return True
示例11: blockCollection2BlockObject
def blockCollection2BlockObject(blockCollection):
b = []
bSize = blockCollection.blockBitSize
for blk in blockCollection.blocks:
bObj = Block(0,0)
bObj.buildBlockFromProtoBuf(blk.index, blk.data, bSize)
b.append(bObj)
return b
示例12: blockCollectionDisk2BlockObject
def blockCollectionDisk2BlockObject(blockCollection):
b = []
bSize = blockCollection.blockBitSize
for i in blockCollection.collection:
bObj = Block(0,bSize, True)
bObj.buildBlockFromProtoBufDisk(i.blk)
b.append(bObj)
return b
示例13: dump
def dump(self):
Block.dump(self,"DirCache")
print " own_key: %d" % (self.own_key)
print " parent: %d" % (self.parent)
print " num_records:%d" % (self.num_records)
print " next_cache: %d" % (self.next_cache)
for r in self.records:
r.dump()
示例14: write
def write(self):
Block._create_data(self)
self._put_long(1, self.hdr_key)
self._put_long(2, self.seq_num)
self._put_long(3, self.data_size)
self._put_long(4, self.next_data)
if self.contents != None:
self.data[24:24+self.data_size] = self.contents
Block.write(self)
示例15: create
def create(self, parent, data_blocks, extension):
Block.create(self)
self.own_key = self.blk_num
self.block_count = len(data_blocks)
self.data_blocks = data_blocks
self.parent = parent
self.extension = extension
self.valid = True
return True