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


Python QTextStream.atEnd方法代码示例

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


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

示例1: _grep_file

# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import atEnd [as 别名]
    def _grep_file(self, file_path, file_name):
        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.emit(SIGNAL("found_pattern(PyQt_PyObject)"),
            (relative_file_name, lines))
开发者ID:AlexaProjects,项目名称:Alexa2,代码行数:34,代码来源:find_in_files.py

示例2: go_to_definition

# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.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:AnyBucket,项目名称:ninja-ide,代码行数:34,代码来源:locator.py

示例3: loadQTextStream

# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import atEnd [as 别名]
 def loadQTextStream(self):
     error = None
     fh = None
     try:
         fh = QFile(self.__fname)
         if not fh.open(QIODevice.ReadOnly):
             raise IOError(str(fh.errorString()))
         stream = QTextStream(fh)
         stream.setCodec(CODEC)
         self.clear(False)
         lino = 0
         while not stream.atEnd():
             title = year = minutes = acquired = notes = None
             line = stream.readLine()
             lino += 1
             if not line.startsWith("{{MOVIE}}"):
                 raise ValueError("no movie record found")
             else:
                 title = line.mid(len("{{MOVIE}}")).trimmed()
             if stream.atEnd():
                 raise ValueError("premature end of file")
             line = stream.readLine()
             lino += 1
             parts = line.split(" ")
             if parts.count() != 3:
                 raise ValueError("invalid numeric data")
             year = intFromQStr(parts[0])
             minutes = intFromQStr(parts[1])
             ymd = parts[2].split("-")
             if ymd.count() != 3:
                 raise ValueError("invalid acquired date")
             acquired = QDate(intFromQStr(ymd[0]),
                     intFromQStr(ymd[1]), intFromQStr(ymd[2]))
             if stream.atEnd():
                 raise ValueError("premature end of file")
             line = stream.readLine()
             lino += 1
             if line != "{NOTES}":
                 raise ValueError("notes expected")
             notes = QString()
             while not stream.atEnd():
                 line = stream.readLine()
                 lino += 1
                 if line == "{{ENDMOVIE}}":
                     if (title is None or year is None or
                         minutes is None or acquired is None or
                         notes is None):
                         raise ValueError("incomplete record")
                     self.add(Movie(title, year, minutes,
                                    acquired, notes.trimmed()))
                     break
                 else:
                     notes += line + "\n"
             else:
                 raise ValueError("missing endmovie marker")
     except (IOError, OSError, ValueError) as e:
         error = "Failed to load: {0} on line {1}".format(e, lino)
     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,代码行数:68,代码来源:moviedata.py

示例4: load_gcode_file

# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import atEnd [as 别名]
    def load_gcode_file(self):
        file = QFile(self.filename)
        file.open(QIODevice.ReadOnly | QIODevice.Text)
        in_stream = QTextStream(file)
        file_size = file.size()
        counter = 0
        line = 0
        line_number = 0
        while not in_stream.atEnd() and self.is_running is True:

            if self.update_progressbar:
                if counter==10000:
                    #in_stream.pos() je hodne pomala funkce takze na ni pozor!!!
                    progress = (in_stream.pos()*1./file_size*1.) * 100.
                    self.set_update_progress.emit(int(progress))
                    counter=0
                else:
                    counter+=1

            line = in_stream.readLine()
            bits = line.split(';', 1)
            bits_len = len(bits)

            if bits[0] == '':
                line_number+=1
                if bits_len > 1:
                    if bits[0] == '' and bits[1] == "END gcode for filament":
                        break
                continue

            if 'G1 ' in bits[0]:
                self.parse_g1_line_new(bits, line_number)
            elif 'G4' in bits[0]:
                self.parse_g4_line(bits, line_number)
            elif 'T0' in bits[0] or 'T1' in bits[0] or 'T2' in bits[0] or 'T3' in bits[0]:
                self.parse_t_line(bits, line_number)
            elif 'G90' in bits[0]:
                self.absolute_coordinates = True
            elif 'G91' in bits[0]:
                self.absolute_coordinates = False
            elif 'G92' in bits[0]:
                self.parse_g92_line(bits, line_number)
            else:
                if DEBUG:
                    print("Nezpracovano: " + str(bits))
                line_number += 1
                continue
            line_number += 1

        if self.is_running is False and self.update_progressbar is True:
            self.set_update_progress.emit(0)

        self.printing_time = self.calculate_time_of_print()
        self.filament_length = 0.0  # self.calculate_length_of_filament()

        ###
        self.non_extruding_layers = []
        for i in self.data:
            layer_flag = 'M'
            for l in self.data[i]:
                _start, _end, flag, _speed, _extrusion, _extruder, _line = l
                if flag in ['E', 'E-sk', 'E-su', 'E-i', 'E-p']:
                    layer_flag = 'E'
                    break
            if layer_flag == 'M':
                self.non_extruding_layers.append(i)

        for i in self.non_extruding_layers:
            self.data.pop(i, None)

        self.data_keys = set()
        self.data_keys = set(self.data)
        self.data_keys = sorted(self.data_keys, key=float)


        self.set_data_keys.emit(self.data_keys)
        self.set_data.emit(self.data)
        self.set_all_data.emit(self.all_data)
        self.set_printing_time.emit(self.printing_time)

        self.finished.emit()
开发者ID:DakotaMcCutch,项目名称:PrusaControl,代码行数:83,代码来源:gcode.py


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