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


Python QTextStream.atEnd方法代码示例

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


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

示例1: go_to_definition

# 需要导入模块: from PyQt5.QtCore import QTextStream [as 别名]
# 或者: from PyQt5.QtCore.QTextStream import atEnd [as 别名]
    def go_to_definition(self):
        self.dirty = True
        self.results = []
        locations = self.get_locations()
        if self._isVariable:
            preResults = [
                [file_manager.get_basename(x.path), x.path, x.lineno, '']
                for x in locations
                if (x.type == FILTERS['attribs']) and (x.name == self._search)]
        else:
            preResults = [
                [file_manager.get_basename(x.path), x.path, x.lineno, '']
                for x in locations
                if ((x.type == FILTERS['functions']) or
                    (x.type == FILTERS['classes'])) and
                   (x.name.startswith(self._search))]
        for data in preResults:
            file_object = QFile(data[1])
            if not file_object.open(QFile.ReadOnly):
                return

            stream = QTextStream(file_object)
            line_index = 0
            line = stream.readLine()
            while not self._cancel and not stream.atEnd():
                if line_index == data[2]:
                    data[3] = line
                    self.results.append(data)
                    break
                #take the next line!
                line = stream.readLine()
                line_index += 1
开发者ID:Salmista-94,项目名称:Ninja_3.0_PyQt5,代码行数:34,代码来源:locator.py

示例2: findFiles

# 需要导入模块: from PyQt5.QtCore import QTextStream [as 别名]
# 或者: from PyQt5.QtCore.QTextStream import atEnd [as 别名]
    def findFiles(self, files, text):
        progressDialog = QProgressDialog(self)

        progressDialog.setCancelButtonText("&Cancel")
        progressDialog.setRange(0, files.count())
        progressDialog.setWindowTitle("Find Files")

        foundFiles = []

        for i in range(files.count()):
            progressDialog.setValue(i)
            progressDialog.setLabelText("Searching file number %d of %d..." % (i, files.count()))
            QApplication.processEvents()

            if progressDialog.wasCanceled():
                break

            inFile = QFile(self.currentDir.absoluteFilePath(files[i]))

            if inFile.open(QIODevice.ReadOnly):
                stream = QTextStream(inFile)
                while not stream.atEnd():
                    if progressDialog.wasCanceled():
                        break
                    line = stream.readLine()
                    if text in line:
                        foundFiles.append(files[i])
                        break

        progressDialog.close()

        return foundFiles
开发者ID:death-finger,项目名称:Scripts,代码行数:34,代码来源:findfiles.py

示例3: loadDescription

# 需要导入模块: from PyQt5.QtCore import QTextStream [as 别名]
# 或者: from PyQt5.QtCore.QTextStream import atEnd [as 别名]
    def loadDescription(self, startPara, nrPara):
        readme = QFile(self.readmePath)
        if not readme.open(QFile.ReadOnly):
            Colors.debug("- MenuContentItem.loadDescription: Could not load:", self.readmePath)
            return ""

        in_str = QTextStream(readme)
        # Skip a certain number of paragraphs.
        while startPara:
            if not in_str.readLine():
                startPara -= 1

        # Read in the number of wanted paragraphs.
        result = ""
        line = in_str.readLine()
        while True:
            result += line + " "
            line = in_str.readLine()
            if not line:
                nrPara -= 1
                line = "<br><br>" + in_str.readLine()

            if nrPara == 0 or in_str.atEnd():
                break

        return Colors.contentColor + result
开发者ID:Magdno1,项目名称:Arianrhod,代码行数:28,代码来源:menucontent.py

示例4: _grep_file

# 需要导入模块: from PyQt5.QtCore import QTextStream [as 别名]
# 或者: from PyQt5.QtCore.QTextStream import atEnd [as 别名]
    def _grep_file(self, file_path, file_name):
        """Search for each line inside the file."""
        if not self.by_phrase:
            with open(file_path, 'r') as f:
                content = f.read()
            words = [word for word in
                self.search_pattern.pattern().split('|')]
            words.insert(0, True)

            def check_whole_words(result, word):
                return result and content.find(word) != -1
            if not reduce(check_whole_words, words):
                return
        file_object = QFile(file_path)
        if not file_object.open(QFile.ReadOnly):
            return

        stream = QTextStream(file_object)
        lines = []
        line_index = 0
        line = stream.readLine()
        while not self._cancel and not (stream.atEnd() and not line):
            column = self.search_pattern.indexIn(line)
            if column != -1:
                lines.append((line_index, line))
            #take the next line!
            line = stream.readLine()
            line_index += 1
        #emit a signal!
        relative_file_name = file_manager.convert_to_relative(
            self.root_dir, file_path)
        self.found_pattern.emit((relative_file_name, lines))
开发者ID:Salmista-94,项目名称:Ninja_3.0_PyQt5,代码行数:34,代码来源:find_in_files.py

示例5: readExtension

# 需要导入模块: from PyQt5.QtCore import QTextStream [as 别名]
# 或者: from PyQt5.QtCore.QTextStream import atEnd [as 别名]
	def readExtension(self, fileName):
		extFile = QFile(fileName)
		extFile.open(QIODevice.ReadOnly)
		extension = {}
		stream = QTextStream(extFile)
		while not stream.atEnd():
			line = stream.readLine()
			if '=' in line:
				index = line.index('=')
				extension[line[:index].rstrip()] = line[index+1:].lstrip()
		extFile.close()
		return extension
开发者ID:daffodil,项目名称:retext,代码行数:14,代码来源:window.py

示例6: _grep_file

# 需要导入模块: from PyQt5.QtCore import QTextStream [as 别名]
# 或者: from PyQt5.QtCore.QTextStream import atEnd [as 别名]
    def _grep_file(self, file_path, file_name):
        """Search for each line inside the file"""
        file_obj = QFile(file_path)
        if not file_obj.open(QFile.ReadOnly):
            return
        stream = QTextStream(file_obj)
        lines = []
        append = lines.append
        line_index = 0
        line = stream.readLine()
        while not self._cancel and not stream.atEnd():
            column = self.search_pattern.indexIn(line)
            if column != -1:
                append((line_index, line))
            # Take the next line
            line = stream.readLine()
            line_index += 1

        p = os.path.join(self.root_dir, file_path)
        self.resultAvailable.emit((p, lines))
开发者ID:ninja-ide,项目名称:ninja-ide,代码行数:22,代码来源:find_in_files.py

示例7: __loadRules

# 需要导入模块: from PyQt5.QtCore import QTextStream [as 别名]
# 或者: from PyQt5.QtCore.QTextStream import atEnd [as 别名]
 def __loadRules(self):
     """
     Private method to load the rules of the subscription.
     """
     fileName = self.rulesFileName()
     f = QFile(fileName)
     if f.exists():
         if not f.open(QIODevice.ReadOnly):
             E5MessageBox.warning(
                 None,
                 self.tr("Load subscription rules"),
                 self.tr(
                     """Unable to open adblock file '{0}' for reading.""")
                 .format(fileName))
         else:
             textStream = QTextStream(f)
             header = textStream.readLine(1024)
             if not header.startswith("[Adblock"):
                 E5MessageBox.warning(
                     None,
                     self.tr("Load subscription rules"),
                     self.tr("""AdBlock file '{0}' does not start"""
                             """ with [Adblock.""")
                     .format(fileName))
                 f.close()
                 f.remove()
                 self.__lastUpdate = QDateTime()
             else:
                 from .AdBlockRule import AdBlockRule
                 
                 self.__updatePeriod = 0
                 self.__remoteModified = QDateTime()
                 self.__rules = []
                 self.__rules.append(AdBlockRule(header, self))
                 while not textStream.atEnd():
                     line = textStream.readLine()
                     self.__rules.append(AdBlockRule(line, self))
                     expires = self.__expiresRe.search(line)
                     if expires:
                         period, kind = expires.groups()
                         if kind:
                             # hours
                             self.__updatePeriod = int(period)
                         else:
                             # days
                             self.__updatePeriod = int(period) * 24
                     remoteModified = self.__remoteModifiedRe.search(line)
                     if remoteModified:
                         day, month, year, time, hour, minute = \
                             remoteModified.groups()
                         self.__remoteModified.setDate(
                             QDate(int(year),
                                   self.__monthNameToNumber[month],
                                   int(day))
                         )
                         if time:
                             self.__remoteModified.setTime(
                                 QTime(int(hour), int(minute)))
                 self.__populateCache()
                 self.changed.emit()
     elif not fileName.endswith("_custom"):
         self.__lastUpdate = QDateTime()
     
     self.checkForUpdate()
开发者ID:pycom,项目名称:EricShort,代码行数:66,代码来源:AdBlockSubscription.py

示例8: read

# 需要导入模块: from PyQt5.QtCore import QTextStream [as 别名]
# 或者: from PyQt5.QtCore.QTextStream import atEnd [as 别名]
    def read(self, fileName):
        file = QFile(fileName)
        if (not file.open (QIODevice.ReadOnly)):
            self.mError = self.tr("Could not open file for reading.")
            return None
        
        # default to values of the original flare alpha game.
        map = Map(Map.Orientation.Isometric, 256, 256, 64, 32)
        stream = QTextStream(file)
        line = QString()
        sectionName = QString()
        newsection = False
        path = QFileInfo(file).absolutePath()
        base = 10
        gidMapper = GidMapper()
        gid = 1
        tilelayer = None
        objectgroup = None
        mapobject = None
        tilesetsSectionFound = False
        headerSectionFound = False
        tilelayerSectionFound = False # tile layer or objects
        while (not stream.atEnd()):
            line = stream.readLine()
            if line == '':
                continue
            startsWith = line[0]
            if (startsWith == '['):
                sectionName = line[1:line.index(']')]
                newsection = True
                continue
            
            if (sectionName == "header"):
                headerSectionFound = True
                #get map properties
                epos = line.index('=')
                if (epos != -1):
                    key = line[:epos].strip()
                    value = line[epos + 1:].strip()
                    if (key == "width"):
                        map.setWidth(Int(value))
                    elif (key == "height"):
                        map.setHeight(Int(value))
                    elif (key == "tilewidth"):
                        map.setTileWidth(Int(value))
                    elif (key == "tileheight"):
                        map.setTileHeight(Int(value))
                    elif (key == "orientation"):
                        map.setOrientation(orientationFromString(value))
                    else:
                        map.setProperty(key, value)
                
            elif (sectionName == "tilesets"):
                tilesetsSectionFound = True
                epos = line.index('=')
                key = line[:epos].strip()
                value = line[epos + 1:].strip()
                if (key == "tileset"):
                    _list = value.split(',')
                    absoluteSource = _list[0]
                    if (QDir.isRelativePath(absoluteSource)):
                        absoluteSource = path + '/' + absoluteSource
                    tilesetwidth = 0
                    tilesetheight = 0
                    if len(_list) > 2:
                        tilesetwidth = Int(_list[1])
                        tilesetheight = Int(_list[2])
                    
                    tileset = Tileset.create(QFileInfo(absoluteSource).fileName(), tilesetwidth, tilesetheight)
                    ok = tileset.loadFromImage(absoluteSource)
                    if not ok:
                        self.mError = self.tr("Error loading tileset %s, which expands to %s. Path not found!"%(_list[0], absoluteSource))
                        return None
                    else :
                        if len(_list) > 4:
                            tileset.setTileOffset(QPoint(Int(_list[3]),Int(_list[4])))
                        gidMapper.insert(gid, tileset)
                        if len(_list) > 5:
                            gid += Int(_list[5])
                        else :
                            gid += tileset.tileCount()
                        
                        map.addTileset(tileset)

            elif (sectionName == "layer"):
                if (not tilesetsSectionFound):
                    self.mError = self.tr("No tilesets section found before layer section.")
                    return None
                
                tilelayerSectionFound = True
                epos = line.index('=')
                if (epos != -1):
                    key = line[:epos].strip()
                    value = line[epos + 1:].strip()
                    if (key == "type"):
                        tilelayer = TileLayer(value, 0, 0, map.width(),map.height())
                        map.addLayer(tilelayer)
                    elif (key == "format"):
                        if (value == "dec"):
                            base = 10
#.........这里部分代码省略.........
开发者ID:theall,项目名称:Python-Tiled,代码行数:103,代码来源:flareplugin.py


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