本文整理汇总了Python中buffer.Buffer.addInfos方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.addInfos方法的具体用法?Python Buffer.addInfos怎么用?Python Buffer.addInfos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.addInfos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: I18nFileAccessor
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import addInfos [as 别名]
class I18nFileAccessor(object):
def __init__(self, path):
self.b = Buffer()
with open(path, 'r') as f:
self.b.addInfos(f.read())
self._indexes = dict()
self.b.setCursor(self.b.readInt())
nbValues = self.b.readInt() / 8;
for i in range(0, nbValues):
key = self.b.readInt()
val = self.b.readInt()
self._indexes[key] = val
def getText(self, arg1):
pos = self._indexes[arg1]
self.b.setCursor(pos)
return self.b.readUTF()
def hasText(self, arg1):
return self._indexes[arg1]
示例2: Monsters
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import addInfos [as 别名]
class Monsters(object):
def __init__(self, path):
self.b = Buffer()
with open(path, 'r') as f:
self.b.addInfos(f.read())
c = self.b.readUTF(3)
if(cmp(c, "D2O") != 0):
print("D2O error: {}".format(c))
raise Exception()
self._indexes = dict()
self.b.setCursor(self.b.readUnsignedInt());
nbValues = self.b.readInt() / 8;
for i in range(0, nbValues):
key = self.b.readInt();
val = self.b.readInt();
self._indexes[key] = val;
'''
int nbClasses = MonsterDecode::_stream->readInt();
printf("nbclass = %d\n", nbClasses);
for(int i = 0; i < nbClasses; i++){
int id = MonsterDecode::_stream->readInt();
std::string lastName = MonsterDecode::_stream->readUTF();
std::string firstName = MonsterDecode::_stream->readUTF();
cout << "(" << id << ") " << firstName << "." << lastName << endl;
int nbFields = MonsterDecode::_stream->readInt();
for(int j = 0; j < nbFields; j++){
std::string fieldName = MonsterDecode::_stream->readUTF();
int fieldType = MonsterDecode::_stream->readInt();
cout << "\t" << fieldName << ", type : " << fieldType << endl;
}
}
return 0'''
def getObj(self, arg1):
mstr = Monster()
pos = self._indexes[arg1];
self.b.setCursor(pos);
if(self.b.readInt() != 3):
print("!= 2 ?");
return None;
mstr._id = self.b.readInt()
mstr._nameId = self.b.readInt() # readI18n
mstr._gfxId = self.b.readInt()
mstr._race = self.b.readInt()
mstr._grade = 0 # self.b.readInt()
return mstr;
def hasObj(arg1):
return self._indexes[arg1]