当前位置: 首页>>代码示例>>Python>>正文


Python QDataStream.readInt16方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QDataStream.readInt16方法的典型用法代码示例。如果您正苦于以下问题:Python QDataStream.readInt16方法的具体用法?Python QDataStream.readInt16怎么用?Python QDataStream.readInt16使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QDataStream的用法示例。


在下文中一共展示了QDataStream.readInt16方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import readInt16 [as 别名]
 def load(self):
     exception = None
     fh = None
     try:
         if self.filename.isEmpty():
             raise IOError, "no filename specified for loading"
         fh = QFile(self.filename)
         if not fh.open(QIODevice.ReadOnly):
             raise IOError, unicode(fh.errorString())
         stream = QDataStream(fh)
         magic = stream.readInt32()
         if magic != MAGIC_NUMBER:
             raise IOError, "unrecognized file type"
         fileVersion = stream.readInt16()
         if fileVersion != FILE_VERSION:
             raise IOError, "unrecognized file type version"
         self.ships = []
         while not stream.atEnd():
             name = QString()
             owner = QString()
             country = QString()
             description = QString()
             stream >> name >> owner >> country >> description
             teu = stream.readInt32()
             self.ships.append(Ship(name, owner, country, teu,
                                    description))
             self.owners.add(unicode(owner))
             self.countries.add(unicode(country))
         self.dirty = False
     except IOError, e:
         exception = e
开发者ID:DaoQiu,项目名称:VimProject,代码行数:33,代码来源:ships_ans.py

示例2: open

# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import readInt16 [as 别名]
 def open(self):
     self.offerSave()
     path = (QFileInfo(self.filename).path()
             if not self.filename.isEmpty() else ".")
     fname = QFileDialog.getOpenFileName(self,
             "Page Designer - Open", path,
             "Page Designer Files (*.pgd)")
     if fname.isEmpty():
         return
     self.filename = fname
     fh = None
     try:
         fh = QFile(self.filename)
         if not fh.open(QIODevice.ReadOnly):
             raise IOError, unicode(fh.errorString())
         items = self.scene.items()
         while items:
             item = items.pop()
             self.scene.removeItem(item)
             del item
         self.addBorders()
         stream = QDataStream(fh)
         stream.setVersion(QDataStream.Qt_4_2)
         magic = stream.readInt32()
         if magic != MagicNumber:
             raise IOError, "not a valid .pgd file"
         fileVersion = stream.readInt16()
         if fileVersion != FileVersion:
             raise IOError, "unrecognised .pgd file version"
         while not fh.atEnd():
             self.readItemFromStream(stream)
     except IOError, e:
         QMessageBox.warning(self, "Page Designer -- Open Error",
                 "Failed to open {0}: {1}".format(self.filename, e))
开发者ID:pyros2097,项目名称:SabelIDE,代码行数:36,代码来源:level.py

示例3: loadQDataStream

# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import readInt16 [as 别名]
 def loadQDataStream(self):
     error = None
     fh = None
     try:
         fh = QFile(self.__fname)
         if not fh.open(QIODevice.ReadOnly):
             raise IOError(str(fh.errorString()))
         stream = QDataStream(fh)
         magic = stream.readInt32()
         if magic != MovieContainer.MAGIC_NUMBER:
             raise IOError("unrecognized file type")
         version = stream.readInt32()
         if version < MovieContainer.OLD_FILE_VERSION:
             raise IOError("old and unreadable file format")
         elif version > MovieContainer.FILE_VERSION:
             raise IOError("new and unreadable file format")
         old = False
         if version == MovieContainer.OLD_FILE_VERSION:
             old = True
         stream.setVersion(QDataStream.Qt_4_2)
         self.clear(False)
         while not stream.atEnd():
             title = QString()
             acquired = QDate()
             location = QString()
             notes = QString()
             stream >> title
             year = stream.readInt16()
             minutes = stream.readInt16()
             if old:
                 stream >> acquired >> notes
             else:
                 stream >> acquired >> location >> notes
             self.add(Movie(title, year, minutes, acquired,
                            location, notes))
     except EnvironmentError as e:
         error = "Failed to load: {0}".format(e)
     finally:
         if fh is not None:
             fh.close()
         if error is not None:
             return False, error
         self.__dirty = False
         return True, "Loaded {0} movie records from {1}".format(
                 len(self.__movies),
                 QFileInfo(self.__fname).fileName())
开发者ID:hooloong,项目名称:gitpython,代码行数:48,代码来源:moviedata_ans.py

示例4: run

# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import readInt16 [as 别名]
 def run(self):
         fh = QFile(self.filename)
         fhlen = self._file_len(self.filename)
         if not fh.open(QIODevice.ReadOnly):
                 raise IOError, unicode(fh.errorString())
         self.data_block = {}
         stream = QDataStream(fh)
         stream.setVersion(QDataStream.Qt_4_2)
         magic = stream.readInt32()
         if magic != gMAGICNUM:
                 raise IOError, "not a valid .jd file"
         fileVersion = stream.readInt16()
         if fileVersion != gFILEVERSION:
                 raise IOError, "unrecognised .jd file version"
         while not fh.atEnd():
                 self._ReadItemFromStream(stream)
         
         self.emit(SIGNAL("PROJECTLOADERDONE(PyQt_PyObject)"), self.data_block)
开发者ID:redesigndavid,项目名称:Jay-Dee,代码行数:20,代码来源:jd_threads.py

示例5: load

# 需要导入模块: from PyQt4.QtCore import QDataStream [as 别名]
# 或者: from PyQt4.QtCore.QDataStream import readInt16 [as 别名]
 def load(self):
     exception = None
     fh = None
     try:
         if self.filename.isEmpty():
             raise IOError("no filename specified for loading")
         fh = QFile(self.filename)
         if not fh.open(QIODevice.ReadOnly):
             raise IOError(str(fh.errorString()))
         stream = QDataStream(fh)
         magic = stream.readInt32()
         if magic != MAGIC_NUMBER:
             raise IOError("unrecognized file type")
         fileVersion = stream.readInt16()
         if fileVersion != FILE_VERSION:
             raise IOError("unrecognized file type version")
         self.ships = {}
         while not stream.atEnd():
             name = QString()
             owner = QString()
             country = QString()
             description = QString()
             stream >> name >> owner >> country >> description
             teu = stream.readInt32()
             ship = Ship(name, owner, country, teu, description)
             self.ships[id(ship)] = ship
             self.owners.add(str(owner))
             self.countries.add(str(country))
         self.dirty = False
     except IOError as e:
         exception = e
     finally:
         if fh is not None:
             fh.close()
         if exception is not None:
             raise exception
开发者ID:hooloong,项目名称:gitpython,代码行数:38,代码来源:ships.py


注:本文中的PyQt4.QtCore.QDataStream.readInt16方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。