Пример #1
0
    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:

            counter += 1
            if self.set_update_progress and 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

            line = in_stream.readLine()
            bits = line.split(';', 1)
            if bits[0] == '':
                line_number += 1
                continue
            if 'G1 ' in bits[0]:
                self.parse_g1_line(bits, line_number)
            else:
                line_number += 1
                continue
            line_number += 1

        if self.is_running is False:
            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, _extr, _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()
Пример #2
0
    def save(self):
        """Hum ... just save ..."""
        if self.filename.startswith("Unnamed"):
            filename = self.parent().parent().parent().saveAsFile()
            if not (filename == ''):
                return
            self.filename = filename
        self.setWindowTitle(QFileInfo(self.filename).fileName())
        exception = None
        filehandle = None
        try:
            #Before FileSave plugin hook
            for plugin in filter_plugins_by_capability('beforeFileSave',
                                                       self.enabled_plugins):
                plugin.do_beforeFileSave(self)

            filehandle = QFile(self.filename)
            if not filehandle.open(QIODevice.WriteOnly):
                raise IOError, unicode(filehandle.errorString())
            stream = QTextStream(filehandle)
            stream.setCodec("UTF-8")
            stream << self.toPlainText()
            self.document().setModified(False)
            RecentFiles().append(self.filename)
        except (IOError, OSError), ioError:
            exception = ioError
Пример #3
0
def load_stylesheet():
    """
    Loads the stylesheet. Takes care of importing the rc module.
    :return the stylesheet string
    """
    import DarkStyle.pyqt_style_rc
    # Load the stylesheet content from resources
    from PyQt4.QtCore import QFile, QTextStream
    f = QFile(":DarkStyle/style.qss")
    if not f.exists():
        _logger().error("Unable to load stylesheet, file not found in "
                        "resources")
        return ""
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()
        if platform.system().lower() == 'darwin':  # see issue #12 on github
            mac_fix = '''
            QDockWidget::title
            {
                background-color: #31363b;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix
        return stylesheet
Пример #4
0
 def save(self):
     if self.filename.startsWith("Unnamed"):
         filename = QFileDialog.getSaveFileName(self,
                 "Text Editor -- Save File As", self.filename,
                 "Text files (*.txt *.*)")
         if filename.isEmpty():
             return
         self.filename = filename
     self.setWindowTitle(QFileInfo(self.filename).fileName())
     exception = None
     fh = None
     try:
         fh = QFile(self.filename)
         if not fh.open(QIODevice.WriteOnly):
             raise IOError(str(fh.errorString()))
         stream = QTextStream(fh)
         stream.setCodec("UTF-8")
         stream << self.toPlainText()
         self.document().setModified(False)
     except EnvironmentError as e:
         exception = e
     finally:
         if fh is not None:
             fh.close()
         if exception is not None:
             raise exception
Пример #5
0
def load_stylesheet_pyqt5():
    """
    Loads the stylesheet for use in a pyqt5 application.
    :return the stylesheet string
    """
    # Validate that rc files is updated
    compile_qrc.compile_all()

    # Smart import of the rc file
    import qdarkgraystyle.pyqt5_style_rc

    # Load the stylesheet content from resources
    from PyQt5.QtCore import QFile, QTextStream

    f = QFile(':qdarkgraystyle/style.qss')
    if not f.exists():
        _logger().error('Unable to load stylesheet, file not found in '
                        'resources')
        return ''
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()
        if platform.system().lower() == 'darwin':  # see issue #12 on github
            mac_fix = '''
            QDockWidget::title
            {
                background-color: #31363b;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix
        return stylesheet
Пример #6
0
    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.emit(SIGNAL("found_pattern(PyQt_PyObject)"),
                  (relative_file_name, lines))
Пример #7
0
 def saveCompleteHtml(self, htmlFile):
     html = QFile(htmlFile)
     html.open(QIODevice.WriteOnly)
     savestream = QTextStream(html)
     css = QFile(self.settings.cssfile)
     css.open(QIODevice.ReadOnly)
     # Use a html lib may be a better idea?
     savestream << "<html><head><meta charset='utf-8'></head>"
     # Css is inlined.
     savestream << "<style>"
     savestream << QTextStream(css).readAll()
     savestream << "</style>"
     # Note content
     savestream << self.toHtml()
     savestream << "</html>"
     html.close()
Пример #8
0
    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
        self._search = None
        self._isVariable = None
Пример #9
0
def style_rc():
    # Smart import of the rc file
    import qdarkstyle.pyqt5_style_rc

    # Load the stylesheet content from resources
    from PyQt5.QtCore import QFile, QTextStream

    f = QFile(":qdarkstyle/style.qss")
    if not f.exists():
        _logger().error("Unable to load stylesheet, file not found in "
                        "resources")
        return ""
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()
        if platform.system().lower() == 'darwin':  # see issue #12 on github
            mac_fix = '''
            QDockWidget::title
            {
                background-color: #31363b;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix
        return stylesheet
Пример #10
0
def write_file(filename, content):
    _file = QFile(filename)
    if not _file.open(QIODevice.WriteOnly | QIODevice.Truncate):
        raise EdisIOError
    outfile = QTextStream(_file)
    outfile << content
    return filename
Пример #11
0
    def save(self, content, path=None):
        """
        Write a temprorary file with .tnj extension and copy it over the
        original one.
        .nsf = Ninja Swap File
        #FIXME: Where to locate addExtension, does not fit here
        """
        new_path = False
        if path:
            self.attach_to_path(path)
            new_path = True

        save_path = self._file_path

        if not save_path:
            raise NinjaNoFileNameException("I am asked to write a "
                                           "file but no one told me where")
        swap_save_path = "%s.nsp" % save_path

        # If we have a file system watcher, remove the file path
        # from its watch list until we are done making changes.
        if self.__watcher:
            self.__watcher.removePath(save_path)

        flags = QIODevice.WriteOnly | QIODevice.Truncate
        f = QFile(swap_save_path)
        if settings.use_platform_specific_eol():
            flags |= QIODevice.Text

        if not f.open(flags):
            raise NinjaIOException(f.errorString())

        stream = QTextStream(f)
        encoding = get_file_encoding(content)
        if encoding:
            stream.setCodec(encoding)

        encoded_stream = stream.codec().fromUnicode(content)
        f.write(encoded_stream)
        f.flush()
        f.close()
        #SIGNAL: Will save (temp, definitive) to warn folder to do something
        self.emit(SIGNAL("willSave(QString, QString)"),
                  swap_save_path, save_path)
        self.__mtime = os.path.getmtime(swap_save_path)
        shutil.move(swap_save_path, save_path)
        self.reset_state()

        # If we have a file system watcher, add the saved path back
        # to its watch list, otherwise create a watcher and start
        # watching
        if self.__watcher:
            if new_path:
                self.__watcher.removePath(self.__watcher.files()[0])
                self.__watcher.addPath(self._file_path)
            else:
                self.__watcher.addPath(save_path)
        else:
            self.start_watching()
        return self
Пример #12
0
def load_stylesheet_pyqt5():
    """
    Loads the stylesheet for use in a pyqt5 application.

    :param pyside: True to load the pyside rc file, False to load the PyQt rc file

    :return the stylesheet string
    """
    # Smart import of the rc file
    import vnTrader.qdarkstyle.pyqt5_style_rc

    # Load the stylesheet content from resources
    from PyQt5.QtCore import QFile, QTextStream

    f = QFile(":qdarkstyle/style.qss")
    if not f.exists():
        _logger().error("Unable to load stylesheet, file not found in "
                        "resources")
        return ""
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()
        if platform.system().lower() == 'darwin':  # see issue #12 on github
            mac_fix = '''
            QDockWidget::title
            {
                background-color: #31363b;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix
        return stylesheet
Пример #13
0
    def __init__(self, appID, argv):
        #--------------------------------------------------------------------------------------------------------------
        # INICIAR LA CLASE
        #--------------------------------------------------------------------------------------------------------------
        super(QSingleton, self).__init__(argv)

        #--------------------------------------------------------------------------------------------------------------
        # CONFIGURACIONES INICIALES
        #--------------------------------------------------------------------------------------------------------------

        self.appID = appID
        self._outSocket = QLocalSocket()
        self._outSocket.connectToServer(self.appID)
        self._isRunning = self._outSocket.waitForConnected()

        # Si hay instancias previas corriendo
        if self._isRunning:
            self._outStream = QTextStream(self._outSocket)
            self._outStream.setCodec('UTF-8')

        # Si es la primera instancia
        else:
            self._outSocket = None
            self._outStream = None
            self._inSocket = None
            self._inStream = None
            self._server = QLocalServer()
            self._server.listen(self.appID)
            self._server.newConnection.connect(self._onNewConnection)
Пример #14
0
 def exportXml(self, fname):
     error = None
     fh = None
     try:
         fh = QFile(fname)
         if not fh.open(QIODevice.WriteOnly):
             raise IOError(str(fh.errorString()))
         stream = QTextStream(fh)
         stream.setCodec(CODEC)
         stream << ("<?xml version='1.0' encoding='{0}'?>\n"
                    "<!DOCTYPE MOVIES>\n"
                    "<MOVIES VERSION='1.0'>\n".format(CODEC))
         for key, movie in self.__movies:
             stream << ("<MOVIE YEAR='{0}' MINUTES='{1}' "
                        "ACQUIRED='{2}'>\n".format(movie.year,
                        movie.minutes,
                        movie.acquired.toString(Qt.ISODate))) \
                    << "<TITLE>" << Qt.escape(movie.title) \
                    << "</TITLE>\n<NOTES>"
             if not movie.notes.isEmpty():
                 stream << "\n" << Qt.escape(encodedNewlines(movie.notes))
             stream << "\n</NOTES>\n</MOVIE>\n"
         stream << "</MOVIES>\n"
     except EnvironmentError as e:
         error = "Failed to export: {0}".format(e)
     finally:
         if fh is not None:
             fh.close()
         if error is not None:
             return False, error
         self.__dirty = False
         return True, "Exported {0} movie records to {1}".format(
             len(self.__movies),
             QFileInfo(fname).fileName())
Пример #15
0
 def saveQTextStream(self):
     error = None
     fh = None
     try:
         fh = QFile(self.__fname)
         if not fh.open(QIODevice.WriteOnly):
             raise IOError(str(fh.errorString()))
         stream = QTextStream(fh)
         stream.setCodec(CODEC)
         for key, movie in self.__movies:
             stream << "{{MOVIE}} " << movie.title << "\n" \
                    << movie.year << " " << movie.minutes << " " \
                    << movie.acquired.toString(Qt.ISODate) \
                    << "\n{NOTES}"
             if not movie.notes.isEmpty():
                 stream << "\n" << movie.notes
             stream << "\n{{ENDMOVIE}}\n"
     except EnvironmentError as e:
         error = "Failed to save: {0}".format(e)
     finally:
         if fh is not None:
             fh.close()
         if error is not None:
             return False, error
         self.__dirty = False
         return True, "Saved {0} movie records to {1}".format(
             len(self.__movies),
             QFileInfo(self.__fname).fileName())
Пример #16
0
 def _replace_results(self):
     result = QMessageBox.question(
         self,
         self.tr("Replace Files Contents"),
         self.tr("Are you sure you want to replace the content in "
                 "this files?\n(The change is not reversible)"),
         buttons=QMessageBox.Yes | QMessageBox.No)
     if result == QMessageBox.Yes:
         for index in range(self._result_widget.topLevelItemCount()):
             parent = self._result_widget.topLevelItem(index)
             root_dir_name = parent.dir_name_root
             file_name = parent.text(0)
             file_path = file_manager.create_path(root_dir_name, file_name)
             file_object = QFile(file_path)
             if not file_object.open(QFile.ReadOnly):
                 return
             stream = QTextStream(file_object)
             content = stream.readAll()
             file_object.close()
             pattern = self._find_widget.pattern_line_edit.text()
             case_sensitive = self._find_widget.case_checkbox.isChecked()
             type_ = QRegExp.RegExp if \
                 self._find_widget.type_checkbox.isChecked() else \
                 QRegExp.FixedString
             target = QRegExp(pattern, case_sensitive, type_)
             content.replace(target, self._find_widget.replace_line.text())
             file_manager.store_file_content(file_path, content, False)
Пример #17
0
 def writeGcpFile(gc, path):
     outFile = QFile(path)
     if (not outFile.open(QIODevice.WriteOnly | QIODevice.Text)):
         return 'Unable to open GCP file for writing'
     outStream = QTextStream(outFile)
     outStream << gc.asCsv()
     outFile.close()
Пример #18
0
 def readyRead(self):  #  可以读数据了
     local = self.sender()  #  取得是哪个localsocket可以读数据了
     if (local == None):
         return
     _in = QTextStream(local)
     readMsg = _in.readAll()
     print "recv Msg:", readMsg
     self.emit(SIGNAL("newMessage(QString)"), QString(readMsg))
Пример #19
0
 def _onNewConnection(self):
     if self._inSocket:
         self._inSocket.readyRead.disconnect(self._onReadyRead)
     self._inSocket = self._server.nextPendingConnection()
     if not self._inSocket:
         return
     self._inStream = QTextStream(self._inSocket)
     self._inStream.setCodec('UTF-8')
     self._inSocket.readyRead.connect(self._onReadyRead)
Пример #20
0
def read_network_path():
    """get the netowrk config file location"""
    network_config = QFile(os.path.join(USER_PLUGIN_DIR, 'network_path.txt'))

    if network_config.open(QIODevice.ReadOnly):
        stream = QTextStream(network_config)
        f_path = stream.readLine()
        if f_path:
            return f_path
Пример #21
0
def table_view_dependencies(table_name, column_name=None):
    """
    Find database views that are dependent on the given table and
    optionally the column.
    :param table_name: Table name
    :type table_name: str
    :param column_name: Name of the column whose dependent views are to be
    extracted.
    :type column_name: str
    :return: A list of views which are dependent on the given table name and
    column respectively.
    :rtype: list(str)
    """
    views = []

    # Load the SQL file depending on whether its table or table/column
    if column_name is None:
        script_path = PLUGIN_DIR + '/scripts/table_related_views.sql'
    else:
        script_path = PLUGIN_DIR + '/scripts/table_column_related_views.sql'

    script_file = QFile(script_path)

    if not script_file.exists():
        raise IOError('SQL file for retrieving view dependencies could '
                      'not be found.')

    else:
        if not script_file.open(QIODevice.ReadOnly):
            raise IOError('Failed to read the SQL file for retrieving view '
                          'dependencies.')

        reader = QTextStream(script_file)
        sql = reader.readAll()
        if sql:
            t = text(sql)
            if column_name is None:
                result = _execute(
                    t,
                    table_name=table_name
                )

            else:
                result = _execute(
                    t,
                    table_name=table_name,
                    column_name=column_name
                )

            # Get view names
            for r in result:
                view_name = r['view_name']
                views.append(view_name)

    return views
Пример #22
0
    def convert(self, notefile, htmlfile, page):

        self.count += 1
        note = QFile(notefile)
        note.open(QIODevice.ReadOnly)
        html = QFile(htmlfile)
        html.open(QIODevice.WriteOnly)
        savestream = QTextStream(html)
        savestream << '<html><head>' \
                      '<meta charset="utf-8">' \
                      '<link rel="stylesheet" href="/css/notebook.css" type="text/css" />' \
                      '</head>'
        savestream << "<header>" + self.breadcrumb(page) + "</header>"
        # Note content
        if 'mdx_asciimathml' in self.exts:
            savestream << JSCRIPT_TPL.format(self.qsettings.value('mathJax'))
        savestream << self.md.reset().convert(QTextStream(note).readAll())
        savestream << "</html>"
        note.close()
        html.close()
Пример #23
0
    def method_30(self):
        filePath = define.appPath + "/Resource/settingData/phxtemplates.xml"
        fileInfo = QFileInfo(filePath)
        if fileInfo.exists():
            QFile.remove(filePath)

        doc = QDomDocument()
        rootElem = doc.createElement("Templates")
        xmlDeclaration = doc.createProcessingInstruction(
            "xml", "version=\"1.0\" encoding=\"utf-8\"")
        doc.appendChild(xmlDeclaration)

        for i in range(self.parametersPanel.gridModel.rowCount()):
            elem = doc.createElement(
                "Templates" + self.parametersPanel.gridModel.item(i, 0).text())
            valueElem = doc.createElement("title")
            valueElem.appendChild(
                doc.createTextNode(
                    self.parametersPanel.gridModel.item(i, 0).text()))
            elem.appendChild(valueElem)

            valueElem = doc.createElement("space")
            valueElem.appendChild(
                doc.createTextNode(
                    self.parametersPanel.gridModel.item(i, 1).text()))
            elem.appendChild(valueElem)

            valueElem = doc.createElement("value")
            valueElem.appendChild(
                doc.createTextNode(
                    self.parametersPanel.gridModel.item(i, 2).text()))
            elem.appendChild(valueElem)

            rootElem.appendChild(elem)

        doc.appendChild(rootElem)
        qFile = QFile(filePath)
        if qFile.open(QFile.WriteOnly):
            textStream = QTextStream(qFile)
            doc.save(textStream, 4)
            qFile.close()

            # ###CRC file is created.
            contents = None
            with open(filePath, 'rb', 0) as tempFile:
                contents = tempFile.read()
                tempFile.flush()
                tempFile.close()
            bytes = FasDataBlockFile.CRC_Calculation(contents)
            string_0 = QString(filePath)
            path = string_0.left(string_0.length() - 3) + "crc"
            fileStream = open(path, 'wb')
            fileStream.write(bytes)
            fileStream.close()
Пример #24
0
    def __init__(self):
        super(MainWindow, self).__init__(None)
        uic.loadUi("./mainwindow.ui", self)

        doc = QDomDocument()
        # 添加处理指令即XML说明
        instruction = QDomProcessingInstruction()
        instruction = doc.createProcessingInstruction(
            "xml", "version=\"1.0\" encoding=\"UTF-8\"")
        doc.appendChild(instruction)

        # 添加根元素
        root = doc.createElement(QString("书库"))
        doc.appendChild(root)  # 添加根元素

        # 添加第一个图书元素及其子元素
        book = doc.createElement(QString("图书"))
        id = doc.createAttribute(QString("编号"))
        title = doc.createElement(QString("书名"))
        author = doc.createElement(QString("作者"))
        text = QDomText()

        id.setValue(QString("1"))
        book.setAttributeNode(id)
        text = doc.createTextNode(QString("Qt"))
        title.appendChild(text)
        text = doc.createTextNode(QString("shiming"))
        author.appendChild(text)
        book.appendChild(title)  # 图书元素 添加 书名元素
        book.appendChild(author)  # 图书元素 添加 作者元素
        root.appendChild(book)  # 根元素 添加 图书元素

        # 添加第二个图书元素及其子元素
        book = doc.createElement(QString("图书"))
        id = doc.createAttribute(QString("编号"))
        title = doc.createElement(QString("书名"))
        author = doc.createElement(QString("作者"))

        id.setValue(QString("2"))
        book.setAttributeNode(id)
        text = doc.createTextNode(QString("Linux"))
        title.appendChild(text)
        text = doc.createTextNode(QString("yafei"))
        author.appendChild(text)
        book.appendChild(title)
        book.appendChild(author)
        root.appendChild(book)

        file = QFile("my.xml")
        if (not file.open(QIODevice.WriteOnly | QIODevice.Truncate)):
            raise Exception("open my.xml Err")
        out = QTextStream(file)
        doc.save(out, 4)  # 将文档保存到文件,4为子元素缩进字符数
        file.close()
    def btnEvaluate_Click(self):   #### ---------------  Export  -------------------###
        if ProcedureExportDlg.dataBase == None:
            return
        filePathDir = QFileDialog.getSaveFileName(self, "Save Data",QCoreApplication.applicationDirPath (),"XML Files (*.xml)")
        if filePathDir == "":
            return

        effectiveDate = ProcedureExportDlg.dataBase.EffectiveDate;
        resultDlg, effectiveDate = DlgAixmEffectiveDate.smethod_0(effectiveDate)
        if (not resultDlg):
            return;
        xmlDocument = QDomDocument()
        xmlDeclaration = xmlDocument.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"" )
        xmlDocument.appendChild(xmlDeclaration)
        xmlElement = xmlDocument.createElement("AIXM-update")
        # xmlAttribute = xmlDocument.createAttribute("xsi")
        # xmlAttribute.setValue("http://www.w3.org/2001/XMLSchema-instance")
        xmlElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
        xmlElement.setAttribute("xsi:noNamespaceSchemaLocation", "AIXM+Update.xsd");
    #     xmlAttribute.Value = "AIXM+Update.xsd";
        xmlElement.setAttribute("version", "4.5");
        xmlElement.setAttribute("origin", "ASAP s.r.o.");
        strS = QDateTime.currentDateTime().toString("yyyy-MM-dd");
        now = QDateTime.currentDateTime();
        xmlElement.setAttribute("created", String.Concat([strS, "T", now.toString("hh:mm:ss")]));
        xmlElement.setAttribute("effective", String.Concat([effectiveDate.toString("yyyy-MM-dd"), "T00:00:00"]));
        # xmlElement.Attributes.Append(xmlAttribute);
        xmlDocument.appendChild(xmlElement)
        xmlElement1 = xmlDocument.createElement("Group");
        xmlElement1.setAttribute("Name", "Group 1 of 1");
        ProcedureExportDlg.dataBase.ProcedureData.method_61(xmlElement1, self.newProcedurePointsInUse);
        ProcedureExportDlg.dataBase.ProcedureData.method_62(xmlElement1, ProcedureExportDlg.dataBase.SIDs.Select({"deleted":"True", "new":"False"}), DataBaseProcedureExportDlgType.Deleted);
        ProcedureExportDlg.dataBase.ProcedureData.method_62(xmlElement1, ProcedureExportDlg.dataBase.SIDs.Select({"deleted":"False", "changed":"True", "new":"False"}), DataBaseProcedureExportDlgType.Updated);
        ProcedureExportDlg.dataBase.ProcedureData.method_62(xmlElement1, ProcedureExportDlg.dataBase.SIDs.Select({"deleted":"False", "new":"True"}), DataBaseProcedureExportDlgType.Created);
        ProcedureExportDlg.dataBase.ProcedureData.method_63(xmlElement1, ProcedureExportDlg.dataBase.STARs.Select({"deleted":"True", "new":"False"}), DataBaseProcedureExportDlgType.Deleted);
        ProcedureExportDlg.dataBase.ProcedureData.method_63(xmlElement1, ProcedureExportDlg.dataBase.STARs.Select({"deleted":"False", "changed":"True", "new":"False"}), DataBaseProcedureExportDlgType.Updated);
        ProcedureExportDlg.dataBase.ProcedureData.method_63(xmlElement1, ProcedureExportDlg.dataBase.STARs.Select({"deleted":"False", "new":"True"}), DataBaseProcedureExportDlgType.Created);
        ProcedureExportDlg.dataBase.ProcedureData.method_64(xmlElement1, ProcedureExportDlg.dataBase.IAPs.Select({"deleted":"True", "new":"False"}), DataBaseProcedureExportDlgType.Deleted);
        ProcedureExportDlg.dataBase.ProcedureData.method_64(xmlElement1, ProcedureExportDlg.dataBase.IAPs.Select({"deleted":"False", "changed":"True", "new":"False"}), DataBaseProcedureExportDlgType.Updated);
        ProcedureExportDlg.dataBase.ProcedureData.method_64(xmlElement1, ProcedureExportDlg.dataBase.IAPs.Select({"deleted":"False", "new":"True"}), DataBaseProcedureExportDlgType.Created);
        ProcedureExportDlg.dataBase.ProcedureData.method_65(xmlElement1, ProcedureExportDlg.dataBase.Holdings.Select({"deleted":"True", "new":"False"}), DataBaseProcedureExportDlgType.Deleted);
        ProcedureExportDlg.dataBase.ProcedureData.method_65(xmlElement1, ProcedureExportDlg.dataBase.Holdings.Select({"deleted":"False", "changed":"True", "new":"False"}), DataBaseProcedureExportDlgType.Updated);
        ProcedureExportDlg.dataBase.ProcedureData.method_65(xmlElement1, ProcedureExportDlg.dataBase.Holdings.Select({"deleted":"False", "new":"True"}), DataBaseProcedureExportDlgType.Created);
        xmlElement.appendChild(xmlElement1);
    #     xmlDocument.Save(self.sfd.FileName);
    #     base.method_20(string.Format(Messages.X_SUCCESSFULLY_CREATED, self.pnlFile.Value));
        qFile = QFile(filePathDir)
        if qFile.open(QFile.WriteOnly):
            textStream = QTextStream(qFile)
            xmlDocument.save(textStream, 4)
            qFile.close()
        else:
            raise UserWarning, "can not open file:" + filePathDir
Пример #26
0
def load_stylesheet_pyqt5(**kwargs):
    """
    Loads the stylesheet for use in a pyqt5 application.

    :param pyside: True to load the pyside rc file, False to load the PyQt rc file

    :return the stylesheet string
    """
    # Smart import of the rc file

    if kwargs["style"] == "style_Dark":
        import eslearn.stylesheets.PyQt5_stylesheets.pyqt5_style_Dark_rc
    if kwargs["style"] == "style_DarkOrange":
        import eslearn.stylesheets.PyQt5_stylesheets.pyqt5_style_DarkOrange_rc
    if kwargs["style"] == "style_Classic":
        import eslearn.stylesheets.PyQt5_stylesheets.pyqt5_style_Classic_rc

    if kwargs["style"] == "style_navy":
        import eslearn.stylesheets.PyQt5_stylesheets.pyqt5_style_navy_rc

    if kwargs["style"] == "style_gray":
        import eslearn.stylesheets.PyQt5_stylesheets.pyqt5_style_gray_rc

    if kwargs["style"] == "style_blue":
        import eslearn.stylesheets.PyQt5_stylesheets.pyqt5_style_blue_rc

    if kwargs["style"] == "style_black":
        import eslearn.stylesheets.PyQt5_stylesheets.pyqt5_style_black_rc
    # Load the stylesheet content from resources
    from PyQt5.QtCore import QFile, QTextStream

    f = QFile(":PyQt5_stylesheets/%s.qss" % kwargs["style"])
    if not f.exists():
        f = QFile(":PyQt5_stylesheets/%s.css" % kwargs["style"])
    if not f.exists():
        _logger().error("Unable to load stylesheet, file not found in "
                        "resources")
        return ""
    else:
        f.open(QFile.ReadOnly | QFile.Text)
        ts = QTextStream(f)
        stylesheet = ts.readAll()
        if platform.system().lower() == 'darwin':  # see issue #12 on github
            mac_fix = '''
            QDockWidget::title
            {
                background-color: #31363b;
                text-align: center;
                height: 12px;
            }
            '''
            stylesheet += mac_fix
        return stylesheet
Пример #27
0
 def load(self):
     exception = None
     fh = None
     try:
         fh = QFile(self.filename)
         if not fh.open(QIODevice.ReadOnly):
             raise IOError, unicode(fh.errorString())
         stream = QTextStream(fh)
         stream.setCodec("UTF-8")
         self.setPlainText(stream.readAll())
         self.document().setModified(False)
     except (IOError, OSError), e:
         exception = e
Пример #28
0
    def write(self, msg=""):
        """ Write a  simple message to log

            :param msg: message to write
        """
        for i in range(self.repeat_count):
            f = QFile(self.logfile)
            if not f.open(QIODevice.Append | QIODevice.Text):
                continue
            stream = QTextStream(f)
            stream << (msg + '\n')
            break
        f.close()
Пример #29
0
 def save(self):
     fileName = QFileDialog.getSaveFileName(self, caption='Save As...')
     try:
         file = QFile(fileName + '.txt')
         file.open( QIODevice.WriteOnly | QIODevice.Text )
         out = QTextStream(file)
         out << self.plainTextEdit.toPlainText()
         out.flush()
         file.close()
         self.close()
         return True
     except IOError:
         return False
Пример #30
0
 def saveNoteAs(self):
     self.saveCurrentNote()
     fileName = QFileDialog.getSaveFileName(
         self, self.tr('Save as'), '',
         '(*.md *.mkd *.markdown);;' + self.tr('All files(*)'))
     if fileName == '':
         return
     if not QFileInfo(fileName).suffix():
         fileName += '.md'
     fh = QFile(fileName)
     fh.open(QIODevice.WriteOnly)
     savestream = QTextStream(fh)
     savestream << self.notesEdit.toPlainText()
     fh.close()