Differential D3659 Diff 8958 plugins/extensions/pykrita/plugin/plugins/scripter/document_scripter/document.py
Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/plugins/scripter/document_scripter/document.py
Show All 14 Lines | 10 | def open(self, filePath=''): | |||
---|---|---|---|---|---|
15 | if _file.open(QIODevice.ReadOnly | QIODevice.Text): | 15 | if _file.open(QIODevice.ReadOnly | QIODevice.Text): | ||
16 | out = QTextStream(_file) | 16 | out = QTextStream(_file) | ||
17 | while not out.atEnd(): | 17 | while not out.atEnd(): | ||
18 | line = out.readLine() | 18 | line = out.readLine() | ||
19 | self._document.append(line) | 19 | self._document.append(line) | ||
20 | 20 | | |||
21 | _file.close() | 21 | _file.close() | ||
22 | 22 | | |||
23 | def save(self): | ||||
24 | with open(self._filePath, 'w') as pythonFile: | ||||
25 | for line in self._document: | ||||
26 | print(line, file=pythonFile) | ||||
27 | | ||||
28 | def compare(self, new_doc): | ||||
29 | if len(self._document) != len(new_doc): | ||||
30 | return False | ||||
31 | | ||||
32 | for line in range(len(new_doc)): | ||||
33 | if new_doc[line] != self._document[line]: | ||||
34 | return False | ||||
35 | | ||||
36 | return True | ||||
37 | | ||||
38 | @property | ||||
23 | def data(self): | 39 | def data(self): | ||
24 | return self._document | 40 | return self._document | ||
41 | | ||||
42 | @data.setter | ||||
43 | def data(self, data): | ||||
44 | self._document = data | ||||
45 | | ||||
46 | @property | ||||
47 | def filePath(self): | ||||
48 | return self._filePath |