author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Thu, 01 Jul 2021 14:33:14 +0200 | |
branch | svghmi |
changeset 3268 | d22782b9591f |
parent 2709 | a1b185e21295 |
child 3750 | f62625418bff |
permissions | -rw-r--r-- |
1511
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
1 |
#!/usr/bin/env python |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
3 |
|
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
6 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
8 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
10 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
15 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
19 |
# GNU General Public License for more details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
20 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
24 |
|
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1448
diff
changeset
|
25 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
26 |
from __future__ import absolute_import |
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
27 |
import os |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
28 |
import re |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
29 |
import traceback |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2418
diff
changeset
|
30 |
from builtins import str as text |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
31 |
from copy import deepcopy |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2418
diff
changeset
|
32 |
|
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
33 |
from lxml import etree |
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
34 |
from xmlclass import GenerateParserFromXSDstring |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
361
diff
changeset
|
35 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
36 |
from PLCControler import UndoBuffer |
1330
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1315
diff
changeset
|
37 |
from ConfigTreeNode import XSDSchemaErrorMessage |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
38 |
|
2527
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
39 |
from plcopen.plcopen import TestTextElement |
2528
6bfc8a9bf0e7
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2527
diff
changeset
|
40 |
from editors.CodeFileEditor import GetSectionsText |
2527
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
41 |
|
1124
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
42 |
CODEFILE_XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?> |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
43 |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
44 |
xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
1124
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
45 |
<xsd:element name="%(codefile_name)s"> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
46 |
<xsd:complexType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
47 |
<xsd:sequence> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
48 |
%(includes_section)s |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
49 |
<xsd:element name="variables"> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
50 |
<xsd:complexType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
51 |
<xsd:sequence> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
52 |
<xsd:element name="variable" minOccurs="0" maxOccurs="unbounded"> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
53 |
<xsd:complexType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
54 |
<xsd:attribute name="name" type="xsd:string" use="required"/> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
55 |
<xsd:attribute name="type" type="xsd:string" use="required"/> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
56 |
<xsd:attribute name="class" use="optional"> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
57 |
<xsd:simpleType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
58 |
<xsd:restriction base="xsd:string"> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
59 |
<xsd:enumeration value="input"/> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
60 |
<xsd:enumeration value="memory"/> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
61 |
<xsd:enumeration value="output"/> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
62 |
</xsd:restriction> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
63 |
</xsd:simpleType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
64 |
</xsd:attribute> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
65 |
<xsd:attribute name="initial" type="xsd:string" use="optional" default=""/> |
1448
20ff66dcc31d
Added more columns in variable list of extensions' code editors - updating python's PLCGlobals from PLC logic can trigger asynchronous 'OnChange' python call
Edouard Tisserant
parents:
1332
diff
changeset
|
66 |
<xsd:attribute name="desc" type="xsd:string" use="optional" default=""/> |
20ff66dcc31d
Added more columns in variable list of extensions' code editors - updating python's PLCGlobals from PLC logic can trigger asynchronous 'OnChange' python call
Edouard Tisserant
parents:
1332
diff
changeset
|
67 |
<xsd:attribute name="onchange" type="xsd:string" use="optional" default=""/> |
20ff66dcc31d
Added more columns in variable list of extensions' code editors - updating python's PLCGlobals from PLC logic can trigger asynchronous 'OnChange' python call
Edouard Tisserant
parents:
1332
diff
changeset
|
68 |
<xsd:attribute name="opts" type="xsd:string" use="optional" default=""/> |
1124
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
69 |
</xsd:complexType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
70 |
</xsd:element> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
71 |
</xsd:sequence> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
72 |
</xsd:complexType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
73 |
</xsd:element> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
74 |
%(sections)s |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
75 |
</xsd:sequence> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
76 |
</xsd:complexType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
77 |
</xsd:element> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
78 |
<xsd:complexType name="CodeText"> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
79 |
<xsd:annotation> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
80 |
<xsd:documentation>Formatted text according to parts of XHTML 1.1</xsd:documentation> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
81 |
</xsd:annotation> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
82 |
<xsd:sequence> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
83 |
<xsd:any namespace="http://www.w3.org/1999/xhtml" processContents="lax"/> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
84 |
</xsd:sequence> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
85 |
</xsd:complexType> |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
86 |
</xsd:schema>""" |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
87 |
|
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
88 |
SECTION_TAG_ELEMENT = "<xsd:element name=\"%s\" type=\"CodeText\"/>" |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
89 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
90 |
|
1831
56b48961cc68
fix (old-style-class) Old-style class defined error for most parts of
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
91 |
class CodeFile(object): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
92 |
|
1124
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
93 |
CODEFILE_NAME = "CodeFile" |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
94 |
SECTIONS_NAMES = [] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
95 |
|
31 | 96 |
def __init__(self): |
1124
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
97 |
sections_str = {"codefile_name": self.CODEFILE_NAME} |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
98 |
if "includes" in self.SECTIONS_NAMES: |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
99 |
sections_str["includes_section"] = SECTION_TAG_ELEMENT % "includes" |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
100 |
else: |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
101 |
sections_str["includes_section"] = "" |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
102 |
sections_str["sections"] = "\n".join( |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
103 |
[SECTION_TAG_ELEMENT % name |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
104 |
for name in self.SECTIONS_NAMES if name != "includes"]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
105 |
|
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
106 |
self.CodeFileParser = GenerateParserFromXSDstring( |
1124
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
107 |
CODEFILE_XSD % sections_str) |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
108 |
self.CodeFileVariables = etree.XPath("variables/variable") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
109 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
110 |
filepath = self.CodeFileName() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
111 |
if os.path.isfile(filepath): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
112 |
xmlfile = open(filepath, 'r') |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
113 |
codefile_xml = xmlfile.read() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
114 |
xmlfile.close() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
115 |
|
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
116 |
codefile_xml = codefile_xml.replace( |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
117 |
'<%s>' % self.CODEFILE_NAME, |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
118 |
'<%s xmlns:xhtml="http://www.w3.org/1999/xhtml">' % self.CODEFILE_NAME) |
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
119 |
for cre, repl in [ |
2439
f0a040f1de1b
Fix pep8 warning: W605 invalid escape sequence ?x?
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
120 |
(re.compile(r"(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["), |
f0a040f1de1b
Fix pep8 warning: W605 invalid escape sequence ?x?
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2434
diff
changeset
|
121 |
(re.compile(r"(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]: |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
122 |
codefile_xml = cre.sub(repl, codefile_xml) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
123 |
|
1330
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1315
diff
changeset
|
124 |
try: |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1315
diff
changeset
|
125 |
self.CodeFile, error = self.CodeFileParser.LoadXMLString(codefile_xml) |
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1315
diff
changeset
|
126 |
if error is not None: |
1581
2295fdc5c271
fix translation strings with multiple parameters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1511
diff
changeset
|
127 |
(fname, lnum, src) = ((self.CODEFILE_NAME,) + error) |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1740
diff
changeset
|
128 |
self.GetCTRoot().logger.write_warning(XSDSchemaErrorMessage.format(a1=fname, a2=lnum, a3=src)) |
1330
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1315
diff
changeset
|
129 |
self.CreateCodeFileBuffer(True) |
2418
5587c490a070
Use python 3 compatible exception syntax everywhere
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1969
diff
changeset
|
130 |
except Exception as exc: |
2434
07f48018b6f5
python3 support: pylint, W1612 # (unicode-builtin) unicode built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2418
diff
changeset
|
131 |
msg = _("Couldn't load confnode parameters {a1} :\n {a2}").format(a1=self.CTNName(), a2=text(exc)) |
1581
2295fdc5c271
fix translation strings with multiple parameters
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1511
diff
changeset
|
132 |
self.GetCTRoot().logger.write_error(msg) |
1330
96b242e4c59d
Added support for loading XML file even if not following XSD schema (but still following XML syntax), warning user of errors in XML file
Laurent Bessard
parents:
1315
diff
changeset
|
133 |
self.GetCTRoot().logger.write_error(traceback.format_exc()) |
1872
866fb3ab8778
fix pylint error "(undefined-variable) Undefined variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1837
diff
changeset
|
134 |
raise Exception |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
135 |
else: |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
136 |
self.CodeFile = self.CodeFileParser.CreateRoot() |
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
137 |
self.CreateCodeFileBuffer(False) |
718 | 138 |
self.OnCTNSave() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
139 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
140 |
def GetBaseTypes(self): |
718 | 141 |
return self.GetCTRoot().GetBaseTypes() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
142 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1740
diff
changeset
|
143 |
def GetDataTypes(self, basetypes=False): |
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
144 |
return self.GetCTRoot().GetDataTypes(basetypes=basetypes) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
145 |
|
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
146 |
def GenerateNewName(self, name, format): |
1146 | 147 |
return self.GetCTRoot().GenerateNewName( |
1969
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
148 |
None, name, format, |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
149 |
exclude=dict([(var.getname().upper(), True) |
0607c382d73f
remove duplicating code for variables name generate
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
150 |
for var in self.CodeFile.variables.getvariable()])) |
1146 | 151 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
152 |
def SetVariables(self, variables): |
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
153 |
self.CodeFile.variables.setvariable([]) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
154 |
for var in variables: |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
155 |
variable = self.CodeFileParser.CreateElement("variable", "variables") |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
156 |
variable.setname(var["Name"]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
157 |
variable.settype(var["Type"]) |
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
158 |
variable.setinitial(var["Initial"]) |
1448
20ff66dcc31d
Added more columns in variable list of extensions' code editors - updating python's PLCGlobals from PLC logic can trigger asynchronous 'OnChange' python call
Edouard Tisserant
parents:
1332
diff
changeset
|
159 |
variable.setdesc(var["Description"]) |
20ff66dcc31d
Added more columns in variable list of extensions' code editors - updating python's PLCGlobals from PLC logic can trigger asynchronous 'OnChange' python call
Edouard Tisserant
parents:
1332
diff
changeset
|
160 |
variable.setonchange(var["OnChange"]) |
20ff66dcc31d
Added more columns in variable list of extensions' code editors - updating python's PLCGlobals from PLC logic can trigger asynchronous 'OnChange' python call
Edouard Tisserant
parents:
1332
diff
changeset
|
161 |
variable.setopts(var["Options"]) |
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
162 |
self.CodeFile.variables.appendvariable(variable) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
163 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
164 |
def GetVariables(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
165 |
datas = [] |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
166 |
for var in self.CodeFileVariables(self.CodeFile): |
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
167 |
datas.append({ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
168 |
"Name": var.getname(), |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
169 |
"Type": var.gettype(), |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
170 |
"Initial": var.getinitial(), |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
171 |
"Description": var.getdesc(), |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
172 |
"OnChange": var.getonchange(), |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
173 |
"Options": var.getopts(), |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
174 |
}) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
175 |
return datas |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
176 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
177 |
def SetTextParts(self, parts): |
1124
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
178 |
for section in self.SECTIONS_NAMES: |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
179 |
section_code = parts.get(section) |
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
180 |
if section_code is not None: |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
181 |
getattr(self.CodeFile, section).setanyText(section_code) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
182 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
183 |
def GetTextParts(self): |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
184 |
return dict([(section, getattr(self.CodeFile, section).getanyText()) |
1124
b1705000eba1
Fixed support for defining python runtime code using sections like in c_ext
Laurent Bessard
parents:
1100
diff
changeset
|
185 |
for section in self.SECTIONS_NAMES]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
186 |
|
718 | 187 |
def CTNTestModified(self): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
188 |
return self.ChangesToSave or not self.CodeFileIsSaved() |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
610
diff
changeset
|
189 |
|
1061 | 190 |
def OnCTNSave(self, from_project_path=None): |
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
191 |
filepath = self.CodeFileName() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
192 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
193 |
xmlfile = open(filepath, "w") |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
194 |
xmlfile.write(etree.tostring( |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
195 |
self.CodeFile, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
196 |
pretty_print=True, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
197 |
xml_declaration=True, |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
198 |
encoding='utf-8')) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
199 |
xmlfile.close() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
200 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
201 |
self.MarkCodeFileAsSaved() |
31 | 202 |
return True |
203 |
||
1095 | 204 |
def CTNGlobalInstances(self): |
1448
20ff66dcc31d
Added more columns in variable list of extensions' code editors - updating python's PLCGlobals from PLC logic can trigger asynchronous 'OnChange' python call
Edouard Tisserant
parents:
1332
diff
changeset
|
205 |
variables = self.CodeFileVariables(self.CodeFile) |
1758
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
206 |
ret = [(variable.getname(), |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
207 |
variable.gettype(), |
845ca626db09
clean-up: fix PEP8 E222 multiple spaces after operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
208 |
variable.getinitial()) |
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
209 |
for variable in variables] |
1448
20ff66dcc31d
Added more columns in variable list of extensions' code editors - updating python's PLCGlobals from PLC logic can trigger asynchronous 'OnChange' python call
Edouard Tisserant
parents:
1332
diff
changeset
|
210 |
return ret |
656
c1792dfc8c7e
Fixing bug integrated plugin editors not closed when removing corresponding plugin
laurent
parents:
651
diff
changeset
|
211 |
|
2523
aa7f138648f3
WIP adding searching capabilities in python files:
Edouard Tisserant
parents:
2439
diff
changeset
|
212 |
def CTNSearch(self, criteria): |
2527
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
213 |
variables = self.GetVariables() |
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
214 |
results = [] |
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
215 |
tagname = self.CTNFullName() |
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
216 |
for index, var in enumerate(variables): |
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
217 |
varname = var["Name"] |
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
218 |
results.extend([((tagname, "var_inout", index, "name"),) + result |
f47e397e9b61
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2525
diff
changeset
|
219 |
for result in TestTextElement(varname, criteria)]) |
2528
6bfc8a9bf0e7
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2527
diff
changeset
|
220 |
results.extend([((tagname, "body"),) + result |
6bfc8a9bf0e7
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2527
diff
changeset
|
221 |
for result in TestTextElement( |
6bfc8a9bf0e7
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2527
diff
changeset
|
222 |
GetSectionsText(self, lambda x:""), criteria)]) |
6bfc8a9bf0e7
WIP adding searching capabilities in python files. was done :
Edouard Tisserant
parents:
2527
diff
changeset
|
223 |
return results |
2523
aa7f138648f3
WIP adding searching capabilities in python files:
Edouard Tisserant
parents:
2439
diff
changeset
|
224 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
225 |
# ------------------------------------------------------------------------------- |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
226 |
# Current Buffering Management Functions |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
227 |
# ------------------------------------------------------------------------------- |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
228 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
229 |
def Copy(self, model): |
1837
c507c363625e
fix pylint warning '(pointless-string-statement) String statement has no effect'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1831
diff
changeset
|
230 |
""" |
c507c363625e
fix pylint warning '(pointless-string-statement) String statement has no effect'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1831
diff
changeset
|
231 |
Return a copy of the codefile model |
c507c363625e
fix pylint warning '(pointless-string-statement) String statement has no effect'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1831
diff
changeset
|
232 |
""" |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
233 |
return deepcopy(model) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
234 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
235 |
def CreateCodeFileBuffer(self, saved): |
658 | 236 |
self.Buffering = False |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
237 |
self.CodeFileBuffer = UndoBuffer(self.CodeFileParser.Dumps(self.CodeFile), saved) |
651
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
630
diff
changeset
|
238 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
239 |
def BufferCodeFile(self): |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
240 |
self.CodeFileBuffer.Buffering(self.CodeFileParser.Dumps(self.CodeFile)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
241 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
242 |
def StartBuffering(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
243 |
self.Buffering = True |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
244 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
245 |
def EndBuffering(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
246 |
if self.Buffering: |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
247 |
self.CodeFileBuffer.Buffering(self.CodeFileParser.Dumps(self.CodeFile)) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
248 |
self.Buffering = False |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
249 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
250 |
def MarkCodeFileAsSaved(self): |
651
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
630
diff
changeset
|
251 |
self.EndBuffering() |
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
252 |
self.CodeFileBuffer.CurrentSaved() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
253 |
|
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
254 |
def CodeFileIsSaved(self): |
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
255 |
return self.CodeFileBuffer.IsCurrentSaved() and not self.Buffering |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
256 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
257 |
def LoadPrevious(self): |
651
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
630
diff
changeset
|
258 |
self.EndBuffering() |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
259 |
self.CodeFile = self.CodeFileParser.Loads(self.CodeFileBuffer.Previous()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
260 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
261 |
def LoadNext(self): |
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1153
diff
changeset
|
262 |
self.CodeFile = self.CodeFileParser.Loads(self.CodeFileBuffer.Next()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1581
diff
changeset
|
263 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
264 |
def GetBufferState(self): |
1096
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
265 |
first = self.CodeFileBuffer.IsFirst() and not self.Buffering |
c9ace6a881c9
Fixed CFileEditor replacing folding panels by variable panel and STC
Laurent Bessard
parents:
1095
diff
changeset
|
266 |
last = self.CodeFileBuffer.IsLast() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
137
diff
changeset
|
267 |
return not first, not last |