testgres.postgres-configuration 0.5.0__tar.gz → 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {testgres_postgres_configuration-0.5.0/testgres.postgres_configuration.egg-info → testgres_postgres_configuration-0.6.0}/PKG-INFO +1 -1
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/pyproject.toml +1 -1
- testgres_postgres_configuration-0.6.0/src/__init__.py +41 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/abstract/v00/configuration.py +54 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/bugcheck_error.py +18 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/model.py +35 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/model_utils.py +142 -3
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/raise_error.py +18 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/implementation/v00/configuration_base.py +337 -2
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/implementation/v00/configuration_base_r.py +104 -5
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/implementation/v00/configuration_base_w.py +27 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/os/abstract/configuration_os_ops.py +4 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/os/local/configuration_os_ops.py +4 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0/testgres.postgres_configuration.egg-info}/PKG-INFO +1 -1
- testgres_postgres_configuration-0.5.0/src/__init__.py +0 -22
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/LICENSE +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/README.md +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/setup.cfg +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/data_verificator.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/handlers.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/helpers.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/model_s_multi_index.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/add/option_handler_to_add__std.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/get_value/option_handler_to_get_value__std__simple.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/get_value/option_handler_to_get_value__std__union_list.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/instances.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__bool.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__generic.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__int.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__str.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__unique_str_list.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__bool.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__generic.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__int.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__str.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__unique_str_list.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/prepare_set_value_item/option_handler_to_prepare_set_value_item__std__str.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/set_value/option_handler_to_set_value__std__simple.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/set_value_item/option_handler_to_set_value_item__std__unique.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__bool.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__generic.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__int.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__str.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/option/handlers/write/option_handler_to_write__std__unique_str_list.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/read_utils.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/write_utils.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/exceptions.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/implementation/v00/configuration_base_ds_standard.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/implementation/v00/configuration_base_ds_strict.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/implementation/v00/configuration_std.py +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/testgres.postgres_configuration.egg-info/SOURCES.txt +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/testgres.postgres_configuration.egg-info/dependency_links.txt +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/testgres.postgres_configuration.egg-info/requires.txt +0 -0
- {testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/testgres.postgres_configuration.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
# Postgres Pro. PostgreSQL Configuration Python Library.
|
|
3
|
+
|
|
4
|
+
# fmt: off
|
|
5
|
+
from .implementation.v00.configuration_std import PostgresConfiguration_Std as PostgresConfiguration
|
|
6
|
+
|
|
7
|
+
from .implementation.v00.configuration_std import PostgresConfigurationReader_Std as PostgresConfigurationReader
|
|
8
|
+
|
|
9
|
+
from .implementation.v00.configuration_std import PostgresConfigurationWriter_Std as PostgresConfigurationWriter
|
|
10
|
+
|
|
11
|
+
from .abstract.v00.configuration import PostgresConfigurationOption
|
|
12
|
+
from .abstract.v00.configuration import PostgresConfigurationInclude
|
|
13
|
+
from .abstract.v00.configuration import PostgresConfigurationIncludeIfExists
|
|
14
|
+
from .abstract.v00.configuration import PostgresConfigurationComment
|
|
15
|
+
from .abstract.v00.configuration import PostgresConfigurationOptions
|
|
16
|
+
from .abstract.v00.configuration import PostgresConfigurationFiles
|
|
17
|
+
from .abstract.v00.configuration import AddIncludeIfExistsRule
|
|
18
|
+
from .abstract.v00.configuration import PostgresConfigurationSetOptionValueResult
|
|
19
|
+
from .abstract.v00.configuration import PostgresConfigurationSetOptionValueEventID
|
|
20
|
+
# fmt: on
|
|
21
|
+
|
|
22
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"PostgresConfiguration",
|
|
27
|
+
"PostgresConfigurationReader",
|
|
28
|
+
"PostgresConfigurationWriter",
|
|
29
|
+
"PostgresConfigurationOption",
|
|
30
|
+
"PostgresConfigurationInclude",
|
|
31
|
+
"PostgresConfigurationIncludeIfExists",
|
|
32
|
+
"PostgresConfigurationComment",
|
|
33
|
+
"PostgresConfigurationOptions",
|
|
34
|
+
"PostgresConfigurationFiles",
|
|
35
|
+
"AddIncludeIfExistsRule",
|
|
36
|
+
"PostgresConfigurationSetOptionValueResult",
|
|
37
|
+
"PostgresConfigurationSetOptionValueEventID",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -8,6 +8,15 @@ from ...core.raise_error import RaiseError
|
|
|
8
8
|
import typing
|
|
9
9
|
import enum
|
|
10
10
|
|
|
11
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
12
|
+
# AddIncludeIfExistsRule
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AddIncludeIfExistsRule(enum.Enum):
|
|
16
|
+
without_file = 0
|
|
17
|
+
with_file = 1
|
|
18
|
+
|
|
19
|
+
|
|
11
20
|
# //////////////////////////////////////////////////////////////////////////////
|
|
12
21
|
# class PostgresConfigurationObject
|
|
13
22
|
|
|
@@ -174,6 +183,27 @@ class PostgresConfigurationInclude(PostgresConfigurationElement):
|
|
|
174
183
|
RaiseError.MethodIsNotImplemented(__class__, "Delete")
|
|
175
184
|
|
|
176
185
|
|
|
186
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
187
|
+
# class PostgresConfigurationIncludeIfExists
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class PostgresConfigurationIncludeIfExists(PostgresConfigurationElement):
|
|
191
|
+
def __init__(self):
|
|
192
|
+
super().__init__()
|
|
193
|
+
|
|
194
|
+
# interface ----------------------------------------------------------
|
|
195
|
+
def get_File(self) -> typing.Optional[PostgresConfigurationFile]:
|
|
196
|
+
RaiseError.MethodIsNotImplemented(__class__, "get_File")
|
|
197
|
+
|
|
198
|
+
# --------------------------------------------------------------------
|
|
199
|
+
def Delete(
|
|
200
|
+
self,
|
|
201
|
+
withLine: bool,
|
|
202
|
+
) -> None:
|
|
203
|
+
assert type(withLine) is bool
|
|
204
|
+
RaiseError.MethodIsNotImplemented(__class__, "Delete")
|
|
205
|
+
|
|
206
|
+
|
|
177
207
|
# //////////////////////////////////////////////////////////////////////////////
|
|
178
208
|
# class PostgresConfigurationFileLine
|
|
179
209
|
|
|
@@ -220,6 +250,19 @@ class PostgresConfigurationFileLine(PostgresConfigurationObject):
|
|
|
220
250
|
assert (offset is None) or (type(offset) is int)
|
|
221
251
|
RaiseError.MethodIsNotImplemented(__class__, "AddInclude")
|
|
222
252
|
|
|
253
|
+
# --------------------------------------------------------------------
|
|
254
|
+
def AddIncludeIfExists(
|
|
255
|
+
self,
|
|
256
|
+
path: str,
|
|
257
|
+
offset: typing.Optional[int],
|
|
258
|
+
rule: AddIncludeIfExistsRule,
|
|
259
|
+
) -> PostgresConfigurationIncludeIfExists:
|
|
260
|
+
assert type(path) is str
|
|
261
|
+
assert path != ""
|
|
262
|
+
assert (offset is None) or (type(offset) is int)
|
|
263
|
+
assert type(rule) is AddIncludeIfExistsRule
|
|
264
|
+
RaiseError.MethodIsNotImplemented(__class__, "AddIncludeIfExists")
|
|
265
|
+
|
|
223
266
|
# --------------------------------------------------------------------
|
|
224
267
|
def Clear(self) -> None:
|
|
225
268
|
RaiseError.MethodIsNotImplemented(__class__, "Clear")
|
|
@@ -313,6 +356,17 @@ class PostgresConfigurationFile(PostgresConfigurationObject):
|
|
|
313
356
|
assert path != ""
|
|
314
357
|
RaiseError.MethodIsNotImplemented(__class__, "AddInclude")
|
|
315
358
|
|
|
359
|
+
# --------------------------------------------------------------------
|
|
360
|
+
def AddIncludeIfExists(
|
|
361
|
+
self,
|
|
362
|
+
path: str,
|
|
363
|
+
rule: AddIncludeIfExistsRule,
|
|
364
|
+
) -> PostgresConfigurationIncludeIfExists:
|
|
365
|
+
assert type(path) is str
|
|
366
|
+
assert path != ""
|
|
367
|
+
assert type(rule) is AddIncludeIfExistsRule
|
|
368
|
+
RaiseError.MethodIsNotImplemented(__class__, "AddIncludeIfExists")
|
|
369
|
+
|
|
316
370
|
# --------------------------------------------------------------------
|
|
317
371
|
#
|
|
318
372
|
# Method for inserting, updating and deleting of an option.
|
|
@@ -153,6 +153,12 @@ class BugCheckError:
|
|
|
153
153
|
errMsg = "Include is not found in file line."
|
|
154
154
|
__class__.Helper__Raise(errMsg)
|
|
155
155
|
|
|
156
|
+
# --------------------------------------------------------------------
|
|
157
|
+
@staticmethod
|
|
158
|
+
def IncludeIfExistsIsNotFoundInFileLine() -> typing.NoReturn:
|
|
159
|
+
errMsg = "IncludeIfExists is not found in file line."
|
|
160
|
+
__class__.Helper__Raise(errMsg)
|
|
161
|
+
|
|
156
162
|
# --------------------------------------------------------------------
|
|
157
163
|
@staticmethod
|
|
158
164
|
def FileLineIsNotFoundInFile() -> typing.NoReturn:
|
|
@@ -296,6 +302,18 @@ class BugCheckError:
|
|
|
296
302
|
|
|
297
303
|
__class__.Helper__Raise(errMsg)
|
|
298
304
|
|
|
305
|
+
# --------------------------------------------------------------------
|
|
306
|
+
@staticmethod
|
|
307
|
+
def UnknownAddIncludeIfExistsRule(
|
|
308
|
+
value: typing.AnyStr,
|
|
309
|
+
) -> typing.NoReturn:
|
|
310
|
+
|
|
311
|
+
errMsg = "Unknown AddIncludeIfExistsRule: {}.".format(
|
|
312
|
+
value,
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
__class__.Helper__Raise(errMsg)
|
|
316
|
+
|
|
299
317
|
# --------------------------------------------------------------------
|
|
300
318
|
@staticmethod
|
|
301
319
|
def UnsupportedPgConfStrategy(
|
{testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/model.py
RENAMED
|
@@ -155,6 +155,41 @@ class IncludeData(FileLineElementData):
|
|
|
155
155
|
return
|
|
156
156
|
|
|
157
157
|
|
|
158
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
159
|
+
# IncludeIfExistsData
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class IncludeIfExistsData(FileLineElementData):
|
|
163
|
+
m_Path: str
|
|
164
|
+
m_File: typing.Optional[FileData]
|
|
165
|
+
|
|
166
|
+
# --------------------------------------------------------------------
|
|
167
|
+
def __init__(
|
|
168
|
+
self,
|
|
169
|
+
parent: FileLineData,
|
|
170
|
+
offset: typing.Optional[int],
|
|
171
|
+
path: str,
|
|
172
|
+
fileData: typing.Optional[FileData],
|
|
173
|
+
):
|
|
174
|
+
assert type(parent) is FileLineData
|
|
175
|
+
assert type(path) is str
|
|
176
|
+
assert fileData is None or type(fileData) is FileData
|
|
177
|
+
assert offset is None or type(offset) is int
|
|
178
|
+
|
|
179
|
+
assert parent.IsAlive()
|
|
180
|
+
|
|
181
|
+
if fileData is not None:
|
|
182
|
+
assert fileData.IsAlive()
|
|
183
|
+
assert fileData.get_Parent() is parent.get_Parent().get_Parent()
|
|
184
|
+
pass
|
|
185
|
+
|
|
186
|
+
super().__init__(parent, offset)
|
|
187
|
+
|
|
188
|
+
self.m_Path = path
|
|
189
|
+
self.m_File = fileData
|
|
190
|
+
return
|
|
191
|
+
|
|
192
|
+
|
|
158
193
|
# //////////////////////////////////////////////////////////////////////////////
|
|
159
194
|
# FileLineData
|
|
160
195
|
|
|
@@ -10,6 +10,7 @@ from .model import FileLineElementData as PgCfgModel__FileLineElementData
|
|
|
10
10
|
from .model import CommentData as PgCfgModel__CommentData
|
|
11
11
|
from .model import OptionData as PgCfgModel__OptionData
|
|
12
12
|
from .model import IncludeData as PgCfgModel__IncludeData
|
|
13
|
+
from .model import IncludeIfExistsData as PgCfgModel__IncludeIfExistsData
|
|
13
14
|
from .model import FileLineData as PgCfgModel__FileLineData
|
|
14
15
|
from .model import FileData as PgCfgModel__FileData
|
|
15
16
|
from .model import MultiIndex as PgCfgModel__MultiIndex
|
|
@@ -110,6 +111,31 @@ class ModelUtils:
|
|
|
110
111
|
__class__.Helper__DeleteFileLine(cfgData, fileLineData)
|
|
111
112
|
return
|
|
112
113
|
|
|
114
|
+
# --------------------------------------------------------------------
|
|
115
|
+
@staticmethod
|
|
116
|
+
def IncludeIfExists__delete(
|
|
117
|
+
cfgData: PgCfgModel__ConfigurationData,
|
|
118
|
+
includeIfExistsData: PgCfgModel__IncludeIfExistsData,
|
|
119
|
+
withLine: bool,
|
|
120
|
+
) -> None:
|
|
121
|
+
assert type(cfgData) is PgCfgModel__ConfigurationData
|
|
122
|
+
assert type(includeIfExistsData) is PgCfgModel__IncludeIfExistsData
|
|
123
|
+
assert type(withLine) is bool
|
|
124
|
+
|
|
125
|
+
fileLineData = includeIfExistsData.m_Parent
|
|
126
|
+
assert fileLineData is not None
|
|
127
|
+
assert type(fileLineData) is PgCfgModel__FileLineData
|
|
128
|
+
|
|
129
|
+
__class__.Helper__DeleteIncludeIfExists(includeIfExistsData)
|
|
130
|
+
|
|
131
|
+
if not withLine:
|
|
132
|
+
return
|
|
133
|
+
|
|
134
|
+
assert not __class__.Helper__FileLineHasWorkData(fileLineData)
|
|
135
|
+
|
|
136
|
+
__class__.Helper__DeleteFileLine(cfgData, fileLineData)
|
|
137
|
+
return
|
|
138
|
+
|
|
113
139
|
# --------------------------------------------------------------------
|
|
114
140
|
@staticmethod
|
|
115
141
|
def Comment__delete(
|
|
@@ -193,6 +219,9 @@ class ModelUtils:
|
|
|
193
219
|
if type(lastItem.m_Element) is PgCfgModel__IncludeData:
|
|
194
220
|
return
|
|
195
221
|
|
|
222
|
+
if type(lastItem.m_Element) is PgCfgModel__IncludeIfExistsData:
|
|
223
|
+
return
|
|
224
|
+
|
|
196
225
|
if type(lastItem.m_Element) is PgCfgModel__CommentData:
|
|
197
226
|
RaiseError.FileLineAlreadyHasComment()
|
|
198
227
|
|
|
@@ -230,7 +259,39 @@ class ModelUtils:
|
|
|
230
259
|
fileLineDataItem,
|
|
231
260
|
)
|
|
232
261
|
|
|
233
|
-
|
|
262
|
+
return includeData
|
|
263
|
+
|
|
264
|
+
# --------------------------------------------------------------------
|
|
265
|
+
@staticmethod
|
|
266
|
+
def FileLine__add_IncludeIfExists(
|
|
267
|
+
fileLineData: PgCfgModel__FileLineData,
|
|
268
|
+
filePath: str,
|
|
269
|
+
fileData: typing.Optional[PgCfgModel__FileData],
|
|
270
|
+
offset: typing.Optional[int],
|
|
271
|
+
) -> PgCfgModel__IncludeIfExistsData:
|
|
272
|
+
assert type(fileLineData) is PgCfgModel__FileLineData
|
|
273
|
+
assert type(filePath) is str
|
|
274
|
+
assert fileData is None or type(fileData) is PgCfgModel__FileData
|
|
275
|
+
assert filePath != ""
|
|
276
|
+
assert offset is None or type(offset) is int
|
|
277
|
+
|
|
278
|
+
assert fileLineData.IsAlive()
|
|
279
|
+
assert fileData is None or fileData.IsAlive()
|
|
280
|
+
|
|
281
|
+
__class__.Helper__CheckThatWeCanAddWorkDataToFileLine(fileLineData)
|
|
282
|
+
|
|
283
|
+
includeData = PgCfgModel__IncludeIfExistsData(
|
|
284
|
+
fileLineData,
|
|
285
|
+
offset,
|
|
286
|
+
filePath,
|
|
287
|
+
fileData,
|
|
288
|
+
)
|
|
289
|
+
fileLineDataItem = PgCfgModel__FileLineData.tagItem(
|
|
290
|
+
includeData,
|
|
291
|
+
)
|
|
292
|
+
fileLineData.m_Items.append(
|
|
293
|
+
fileLineDataItem,
|
|
294
|
+
)
|
|
234
295
|
|
|
235
296
|
return includeData
|
|
236
297
|
|
|
@@ -325,6 +386,9 @@ class ModelUtils:
|
|
|
325
386
|
if type(lastItem.m_Element) is PgCfgModel__IncludeData:
|
|
326
387
|
RaiseError.FileLineAlreadyHasIncludeDirective()
|
|
327
388
|
|
|
389
|
+
if type(lastItem.m_Element) is PgCfgModel__IncludeIfExistsData:
|
|
390
|
+
RaiseError.FileLineAlreadyHasIncludeIfExistsDirective()
|
|
391
|
+
|
|
328
392
|
if type(lastItem.m_Element) is PgCfgModel__CommentData:
|
|
329
393
|
RaiseError.FileLineAlreadyHasComment()
|
|
330
394
|
|
|
@@ -364,7 +428,10 @@ class ModelUtils:
|
|
|
364
428
|
assert fileLineData.m_Items is not None
|
|
365
429
|
assert type(fileLineData.m_Items) is list
|
|
366
430
|
|
|
367
|
-
return __class__.Helper__ClearFileLine(
|
|
431
|
+
return __class__.Helper__ClearFileLine(
|
|
432
|
+
cfgData,
|
|
433
|
+
fileLineData,
|
|
434
|
+
)
|
|
368
435
|
|
|
369
436
|
# --------------------------------------------------------------------
|
|
370
437
|
class tagFindCtx:
|
|
@@ -460,6 +527,27 @@ class ModelUtils:
|
|
|
460
527
|
return firstItem.m_Element # <--------- BINGO
|
|
461
528
|
|
|
462
529
|
if type(firstItem.m_Element) is PgCfgModel__IncludeData:
|
|
530
|
+
assert firstItem.m_Element.m_File is not None
|
|
531
|
+
assert type(firstItem.m_Element.m_File.m_Path) is str
|
|
532
|
+
|
|
533
|
+
if not enterIntoIncludes:
|
|
534
|
+
# Stop searching upwards: any option defined above an include
|
|
535
|
+
# might be overridden by that included file.
|
|
536
|
+
return None # <--------- FAIL
|
|
537
|
+
|
|
538
|
+
assert findCtx is not None
|
|
539
|
+
if not findCtx.reg_file(firstItem.m_Element.m_File.m_Path):
|
|
540
|
+
continue
|
|
541
|
+
|
|
542
|
+
nextFile = firstItem.m_Element.m_File
|
|
543
|
+
break
|
|
544
|
+
|
|
545
|
+
if type(firstItem.m_Element) is PgCfgModel__IncludeIfExistsData:
|
|
546
|
+
if firstItem.m_Element.m_File is None:
|
|
547
|
+
continue
|
|
548
|
+
|
|
549
|
+
assert type(firstItem.m_Element.m_File.m_Path) is str
|
|
550
|
+
|
|
463
551
|
if not enterIntoIncludes:
|
|
464
552
|
# Stop searching upwards: any option defined above an include
|
|
465
553
|
# might be overridden by that included file.
|
|
@@ -969,7 +1057,10 @@ class ModelUtils:
|
|
|
969
1057
|
assert lastItem is not None
|
|
970
1058
|
assert isinstance(lastItem.m_Element, PgCfgModel__FileLineElementData)
|
|
971
1059
|
|
|
972
|
-
__class__.Helper__DeleteElement(
|
|
1060
|
+
__class__.Helper__DeleteElement(
|
|
1061
|
+
cfgData,
|
|
1062
|
+
lastItem.m_Element,
|
|
1063
|
+
)
|
|
973
1064
|
|
|
974
1065
|
assert fileLineData.m_Items is not None
|
|
975
1066
|
assert type(fileLineData.m_Items) is list
|
|
@@ -1030,6 +1121,9 @@ class ModelUtils:
|
|
|
1030
1121
|
if type(objectData) is PgCfgModel__IncludeData:
|
|
1031
1122
|
return __class__.Helper__DeleteInclude(objectData)
|
|
1032
1123
|
|
|
1124
|
+
if type(objectData) is PgCfgModel__IncludeIfExistsData:
|
|
1125
|
+
return __class__.Helper__DeleteIncludeIfExists(objectData)
|
|
1126
|
+
|
|
1033
1127
|
BugCheckError.UnkObjectDataType(type(objectData))
|
|
1034
1128
|
|
|
1035
1129
|
# --------------------------------------------------------------------
|
|
@@ -1178,6 +1272,8 @@ class ModelUtils:
|
|
|
1178
1272
|
|
|
1179
1273
|
assert iFileLineItem >= 0
|
|
1180
1274
|
assert iFileLineItem < len(fileLineData.m_Items)
|
|
1275
|
+
assert fileLineData.m_Items[iFileLineItem] is not None
|
|
1276
|
+
assert fileLineData.m_Items[iFileLineItem].m_Element is includeData
|
|
1181
1277
|
|
|
1182
1278
|
# 2. Perform delete operations
|
|
1183
1279
|
|
|
@@ -1187,6 +1283,49 @@ class ModelUtils:
|
|
|
1187
1283
|
fileLineData.m_Items.pop(iFileLineItem)
|
|
1188
1284
|
return
|
|
1189
1285
|
|
|
1286
|
+
# --------------------------------------------------------------------
|
|
1287
|
+
@staticmethod
|
|
1288
|
+
def Helper__DeleteIncludeIfExists(
|
|
1289
|
+
includeIfExistsData: PgCfgModel__IncludeIfExistsData,
|
|
1290
|
+
) -> None:
|
|
1291
|
+
assert type(includeIfExistsData) is PgCfgModel__IncludeIfExistsData
|
|
1292
|
+
assert includeIfExistsData.IsAlive()
|
|
1293
|
+
|
|
1294
|
+
# 0.
|
|
1295
|
+
fileLineData = None
|
|
1296
|
+
iFileLineItem = None
|
|
1297
|
+
|
|
1298
|
+
# 1.1 Set fileLineData
|
|
1299
|
+
fileLineData = includeIfExistsData.m_Parent
|
|
1300
|
+
assert fileLineData is not None
|
|
1301
|
+
assert type(fileLineData) is PgCfgModel__FileLineData
|
|
1302
|
+
assert fileLineData.IsAlive()
|
|
1303
|
+
|
|
1304
|
+
# 1.2 Set iFileLineItem
|
|
1305
|
+
iFileLineItem = __class__.Helper__FindIndexOfFileLineElement(
|
|
1306
|
+
fileLineData,
|
|
1307
|
+
includeIfExistsData,
|
|
1308
|
+
)
|
|
1309
|
+
|
|
1310
|
+
assert iFileLineItem >= 0
|
|
1311
|
+
assert iFileLineItem <= len(fileLineData.m_Items)
|
|
1312
|
+
|
|
1313
|
+
if iFileLineItem == len(fileLineData.m_Items):
|
|
1314
|
+
BugCheckError.IncludeIfExistsIsNotFoundInFileLine()
|
|
1315
|
+
|
|
1316
|
+
assert iFileLineItem >= 0
|
|
1317
|
+
assert iFileLineItem < len(fileLineData.m_Items)
|
|
1318
|
+
assert fileLineData.m_Items[iFileLineItem] is not None
|
|
1319
|
+
assert fileLineData.m_Items[iFileLineItem].m_Element is includeIfExistsData
|
|
1320
|
+
|
|
1321
|
+
# 2. Perform delete operations
|
|
1322
|
+
|
|
1323
|
+
# delete from fileLine
|
|
1324
|
+
includeIfExistsData.MarkAsDeletedFrom(fileLineData)
|
|
1325
|
+
assert not includeIfExistsData.IsAlive()
|
|
1326
|
+
fileLineData.m_Items.pop(iFileLineItem)
|
|
1327
|
+
return
|
|
1328
|
+
|
|
1190
1329
|
# --------------------------------------------------------------------
|
|
1191
1330
|
@staticmethod
|
|
1192
1331
|
def Helper__DeleteFileLine(
|
|
@@ -128,6 +128,15 @@ class RaiseError:
|
|
|
128
128
|
errMsg,
|
|
129
129
|
)
|
|
130
130
|
|
|
131
|
+
# --------------------------------------------------------------------
|
|
132
|
+
@staticmethod
|
|
133
|
+
def IncludeIfExistsObjectWasDeleted() -> typing.NoReturn:
|
|
134
|
+
errMsg = "IncludeIfExists object was deleted."
|
|
135
|
+
|
|
136
|
+
__class__.Helper__RaiseErr__PostgresConfigException(
|
|
137
|
+
errMsg,
|
|
138
|
+
)
|
|
139
|
+
|
|
131
140
|
# --------------------------------------------------------------------
|
|
132
141
|
@staticmethod
|
|
133
142
|
def FileLineObjectWasDeleted() -> typing.NoReturn:
|
|
@@ -384,6 +393,15 @@ class RaiseError:
|
|
|
384
393
|
errMsg,
|
|
385
394
|
)
|
|
386
395
|
|
|
396
|
+
# --------------------------------------------------------------------
|
|
397
|
+
@staticmethod
|
|
398
|
+
def FileLineAlreadyHasIncludeIfExistsDirective() -> typing.NoReturn:
|
|
399
|
+
errMsg = "File line already has an include_if_exists directive."
|
|
400
|
+
|
|
401
|
+
__class__.Helper__RaiseErr__PostgresConfigException(
|
|
402
|
+
errMsg,
|
|
403
|
+
)
|
|
404
|
+
|
|
387
405
|
# --------------------------------------------------------------------
|
|
388
406
|
@staticmethod
|
|
389
407
|
def CfgReader__UnexpectedSymbol(
|
|
@@ -11,6 +11,7 @@ from ...abstract.v00.configuration import PostgresConfigurationOption
|
|
|
11
11
|
from ...abstract.v00.configuration import PostgresConfigurationOptions
|
|
12
12
|
from ...abstract.v00.configuration import PostgresConfigurationOptionsIterator
|
|
13
13
|
from ...abstract.v00.configuration import PostgresConfigurationInclude
|
|
14
|
+
from ...abstract.v00.configuration import PostgresConfigurationIncludeIfExists
|
|
14
15
|
from ...abstract.v00.configuration import PostgresConfigurationFileLine
|
|
15
16
|
from ...abstract.v00.configuration import PostgresConfigurationFileLines
|
|
16
17
|
from ...abstract.v00.configuration import PostgresConfigurationFileLinesIterator
|
|
@@ -19,12 +20,14 @@ from ...abstract.v00.configuration import PostgresConfigurationFiles
|
|
|
19
20
|
from ...abstract.v00.configuration import PostgresConfigurationFilesIterator
|
|
20
21
|
from ...abstract.v00.configuration import PostgresConfigurationSetOptionValueEventID
|
|
21
22
|
from ...abstract.v00.configuration import PostgresConfigurationSetOptionValueResult
|
|
23
|
+
from ...abstract.v00.configuration import AddIncludeIfExistsRule
|
|
22
24
|
|
|
23
25
|
from ...core.model import ConfigurationData as PgCfgModel__ConfigurationData
|
|
24
26
|
from ...core.model import ObjectData as PgCfgModel__ObjectData
|
|
25
27
|
from ...core.model import CommentData as PgCfgModel__CommentData
|
|
26
28
|
from ...core.model import OptionData as PgCfgModel__OptionData
|
|
27
29
|
from ...core.model import IncludeData as PgCfgModel__IncludeData
|
|
30
|
+
from ...core.model import IncludeIfExistsData as PgCfgModel__IncludeIfExistsData
|
|
28
31
|
from ...core.model import FileLineData as PgCfgModel__FileLineData
|
|
29
32
|
from ...core.model import FileData as PgCfgModel__FileData
|
|
30
33
|
from ...core.model import MultiIndex as PgCfgModel__MultiIndex
|
|
@@ -304,7 +307,9 @@ class PostgresConfigurationInclude_Base(PostgresConfigurationInclude):
|
|
|
304
307
|
return self.m_FileLine
|
|
305
308
|
|
|
306
309
|
# Include interface --------------------------------------------------
|
|
307
|
-
def get_File(
|
|
310
|
+
def get_File(
|
|
311
|
+
self,
|
|
312
|
+
) -> PostgresConfigurationIncludedFile_Base:
|
|
308
313
|
self.Helper__CheckAlive()
|
|
309
314
|
|
|
310
315
|
return PostgresConfigurationIncludedFile_Base(
|
|
@@ -356,6 +361,99 @@ class PostgresConfigurationInclude_Base(PostgresConfigurationInclude):
|
|
|
356
361
|
return
|
|
357
362
|
|
|
358
363
|
|
|
364
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
365
|
+
# class PostgresConfigurationIncludeIfExists_Base
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
class PostgresConfigurationIncludeIfExists_Base(PostgresConfigurationIncludeIfExists):
|
|
369
|
+
m_FileLine: PostgresConfigurationFileLine_Base
|
|
370
|
+
m_IncludeIfExistsData: PgCfgModel__IncludeIfExistsData
|
|
371
|
+
|
|
372
|
+
# --------------------------------------------------------------------
|
|
373
|
+
def __init__(
|
|
374
|
+
self,
|
|
375
|
+
fileLine: PostgresConfigurationFileLine_Base,
|
|
376
|
+
includeIfExistsData: PgCfgModel__IncludeIfExistsData,
|
|
377
|
+
):
|
|
378
|
+
assert type(fileLine) is PostgresConfigurationFileLine_Base
|
|
379
|
+
assert type(includeIfExistsData) is PgCfgModel__IncludeIfExistsData
|
|
380
|
+
|
|
381
|
+
super().__init__()
|
|
382
|
+
|
|
383
|
+
self.m_FileLine = fileLine
|
|
384
|
+
self.m_IncludeIfExistsData = includeIfExistsData
|
|
385
|
+
return
|
|
386
|
+
|
|
387
|
+
# Object interface ---------------------------------------------------
|
|
388
|
+
def get_Configuration(self) -> PostgresConfiguration_Base:
|
|
389
|
+
self.Helper__CheckAlive()
|
|
390
|
+
return self.m_FileLine.get_Configuration()
|
|
391
|
+
|
|
392
|
+
# --------------------------------------------------------------------
|
|
393
|
+
def get_Parent(self) -> PostgresConfigurationFileLine_Base:
|
|
394
|
+
self.Helper__CheckAlive()
|
|
395
|
+
return self.m_FileLine
|
|
396
|
+
|
|
397
|
+
# IncludeIfExists interface ------------------------------------------
|
|
398
|
+
def get_File(
|
|
399
|
+
self,
|
|
400
|
+
) -> typing.Optional[PostgresConfigurationIncludedIfExistsFile_Base]:
|
|
401
|
+
self.Helper__CheckAlive()
|
|
402
|
+
|
|
403
|
+
if self.m_IncludeIfExistsData.m_File is None:
|
|
404
|
+
return None
|
|
405
|
+
|
|
406
|
+
return PostgresConfigurationIncludedIfExistsFile_Base(
|
|
407
|
+
self,
|
|
408
|
+
self.m_IncludeIfExistsData.m_File,
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
# --------------------------------------------------------------------
|
|
412
|
+
def Delete(
|
|
413
|
+
self,
|
|
414
|
+
withLine: bool,
|
|
415
|
+
) -> None:
|
|
416
|
+
assert type(withLine) is bool
|
|
417
|
+
|
|
418
|
+
self.Helper__CheckAlive()
|
|
419
|
+
assert type(self.m_IncludeIfExistsData) is PgCfgModel__IncludeIfExistsData
|
|
420
|
+
assert type(self.m_IncludeIfExistsData.m_Parent) is PgCfgModel__FileLineData
|
|
421
|
+
assert (
|
|
422
|
+
type(self.m_IncludeIfExistsData.m_Parent.m_Parent) is PgCfgModel__FileData
|
|
423
|
+
)
|
|
424
|
+
assert (
|
|
425
|
+
type(self.m_IncludeIfExistsData.m_Parent.m_Parent.m_Parent)
|
|
426
|
+
is PgCfgModel__ConfigurationData
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
cfgData = self.m_IncludeIfExistsData.m_Parent.m_Parent.m_Parent
|
|
430
|
+
assert type(cfgData) is PgCfgModel__ConfigurationData
|
|
431
|
+
|
|
432
|
+
PgCfgModel__ModelUtils.IncludeIfExists__delete(
|
|
433
|
+
cfgData,
|
|
434
|
+
self.m_IncludeIfExistsData,
|
|
435
|
+
withLine,
|
|
436
|
+
)
|
|
437
|
+
return
|
|
438
|
+
|
|
439
|
+
# Private interface --------------------------------------------------
|
|
440
|
+
def Private__CheckAlive(self) -> None:
|
|
441
|
+
self.Helper__CheckAlive()
|
|
442
|
+
return
|
|
443
|
+
|
|
444
|
+
# Helper methods -----------------------------------------------------
|
|
445
|
+
def Helper__CheckAlive(self) -> None:
|
|
446
|
+
assert self.m_IncludeIfExistsData is not None
|
|
447
|
+
assert type(self.m_IncludeIfExistsData) is PgCfgModel__IncludeIfExistsData
|
|
448
|
+
|
|
449
|
+
if not self.m_IncludeIfExistsData.IsAlive():
|
|
450
|
+
RaiseError.IncludeIfExistsObjectWasDeleted()
|
|
451
|
+
|
|
452
|
+
assert type(self.m_FileLine) is PostgresConfigurationFileLine_Base
|
|
453
|
+
assert isinstance(self.m_FileLine, PostgresConfigurationFileLine)
|
|
454
|
+
return
|
|
455
|
+
|
|
456
|
+
|
|
359
457
|
# //////////////////////////////////////////////////////////////////////////////
|
|
360
458
|
# class PostgresConfigurationFileLine_Base
|
|
361
459
|
|
|
@@ -564,6 +662,90 @@ class PostgresConfigurationFileLine_Base(PostgresConfigurationFileLine):
|
|
|
564
662
|
|
|
565
663
|
return include
|
|
566
664
|
|
|
665
|
+
# --------------------------------------------------------------------
|
|
666
|
+
def AddIncludeIfExists(
|
|
667
|
+
self,
|
|
668
|
+
path: str,
|
|
669
|
+
offset: typing.Optional[int],
|
|
670
|
+
rule: AddIncludeIfExistsRule,
|
|
671
|
+
) -> PostgresConfigurationIncludeIfExists_Base:
|
|
672
|
+
assert offset is None or type(offset) is int
|
|
673
|
+
assert offset is None or offset >= 0
|
|
674
|
+
assert type(rule) is AddIncludeIfExistsRule
|
|
675
|
+
|
|
676
|
+
DataVerificator.CheckStringOfFilePath(path)
|
|
677
|
+
|
|
678
|
+
assert type(path) is str
|
|
679
|
+
assert path != ""
|
|
680
|
+
|
|
681
|
+
self.Helper__CheckAlive()
|
|
682
|
+
|
|
683
|
+
assert isinstance(self.m_Parent, PostgresConfigurationFile_Base)
|
|
684
|
+
|
|
685
|
+
cfg = self.m_Parent.m_Cfg
|
|
686
|
+
assert isinstance(cfg, PostgresConfiguration_Base)
|
|
687
|
+
assert type(cfg.m_Data) is PgCfgModel__ConfigurationData
|
|
688
|
+
|
|
689
|
+
# Add/Get file
|
|
690
|
+
# Add include element
|
|
691
|
+
|
|
692
|
+
if rule == AddIncludeIfExistsRule.without_file:
|
|
693
|
+
withFile = False
|
|
694
|
+
elif rule == AddIncludeIfExistsRule.with_file:
|
|
695
|
+
withFile = True
|
|
696
|
+
else:
|
|
697
|
+
BugCheckError.UnknownAddIncludeIfExistsRule(rule)
|
|
698
|
+
|
|
699
|
+
if not withFile:
|
|
700
|
+
fileData = None
|
|
701
|
+
else:
|
|
702
|
+
assert self.m_FileLineData.m_Parent is not None
|
|
703
|
+
|
|
704
|
+
baseFolder = cfg.m_Data.OsOps.Path_DirName(
|
|
705
|
+
self.m_FileLineData.m_Parent.m_Path,
|
|
706
|
+
)
|
|
707
|
+
assert type(baseFolder) is str
|
|
708
|
+
|
|
709
|
+
fileData = PgCfgModel__ModelUtils.Cfg__GetOrCreateFile__USER(
|
|
710
|
+
cfg.m_Data,
|
|
711
|
+
baseFolder,
|
|
712
|
+
path,
|
|
713
|
+
)
|
|
714
|
+
assert type(fileData) is PgCfgModel__FileData
|
|
715
|
+
|
|
716
|
+
try:
|
|
717
|
+
includeData = PgCfgModel__ModelUtils.FileLine__add_IncludeIfExists(
|
|
718
|
+
self.m_FileLineData,
|
|
719
|
+
path,
|
|
720
|
+
fileData,
|
|
721
|
+
offset,
|
|
722
|
+
)
|
|
723
|
+
assert includeData is not None
|
|
724
|
+
assert type(includeData) is PgCfgModel__IncludeIfExistsData
|
|
725
|
+
assert includeData.m_Path == path
|
|
726
|
+
assert includeData.m_File is fileData
|
|
727
|
+
assert includeData.m_Parent == self.m_FileLineData
|
|
728
|
+
|
|
729
|
+
try:
|
|
730
|
+
# -----------
|
|
731
|
+
include = PostgresConfigurationIncludeIfExists_Base(
|
|
732
|
+
self,
|
|
733
|
+
includeData,
|
|
734
|
+
)
|
|
735
|
+
assert include.m_FileLine is self
|
|
736
|
+
assert include.m_IncludeIfExistsData is includeData
|
|
737
|
+
except: # rollback an include
|
|
738
|
+
PgCfgModel__ModelUtils.IncludeIfExists__delete(
|
|
739
|
+
cfg.m_Data,
|
|
740
|
+
includeData,
|
|
741
|
+
False,
|
|
742
|
+
)
|
|
743
|
+
raise
|
|
744
|
+
except: # TODO: rollback a file
|
|
745
|
+
raise
|
|
746
|
+
|
|
747
|
+
return include
|
|
748
|
+
|
|
567
749
|
# --------------------------------------------------------------------
|
|
568
750
|
def Clear(self) -> None:
|
|
569
751
|
self.Helper__CheckAlive()
|
|
@@ -936,7 +1118,9 @@ class PostgresConfigurationFile_Base(PostgresConfigurationFile):
|
|
|
936
1118
|
# Add empty line
|
|
937
1119
|
# Add include element
|
|
938
1120
|
|
|
939
|
-
baseFolder = self.m_Cfg.m_Data.OsOps.Path_DirName(
|
|
1121
|
+
baseFolder = self.m_Cfg.m_Data.OsOps.Path_DirName(
|
|
1122
|
+
self.m_FileData.m_Path,
|
|
1123
|
+
)
|
|
940
1124
|
assert type(baseFolder) is str
|
|
941
1125
|
|
|
942
1126
|
fileData = PgCfgModel__ModelUtils.Cfg__GetOrCreateFile__USER(
|
|
@@ -1001,6 +1185,103 @@ class PostgresConfigurationFile_Base(PostgresConfigurationFile):
|
|
|
1001
1185
|
|
|
1002
1186
|
return include
|
|
1003
1187
|
|
|
1188
|
+
# --------------------------------------------------------------------
|
|
1189
|
+
def AddIncludeIfExists(
|
|
1190
|
+
self,
|
|
1191
|
+
path: str,
|
|
1192
|
+
rule: AddIncludeIfExistsRule,
|
|
1193
|
+
) -> PostgresConfigurationIncludeIfExists_Base:
|
|
1194
|
+
DataVerificator.CheckStringOfFilePath(path)
|
|
1195
|
+
|
|
1196
|
+
assert type(path) is str
|
|
1197
|
+
assert path != ""
|
|
1198
|
+
assert type(rule) is AddIncludeIfExistsRule
|
|
1199
|
+
|
|
1200
|
+
self.Internal__CheckAlive()
|
|
1201
|
+
|
|
1202
|
+
assert self.m_Cfg is not None
|
|
1203
|
+
assert isinstance(self.m_Cfg, PostgresConfiguration_Base)
|
|
1204
|
+
assert type(self.m_Cfg.m_Data) is PgCfgModel__ConfigurationData
|
|
1205
|
+
|
|
1206
|
+
# Add/Get file
|
|
1207
|
+
# Add empty line
|
|
1208
|
+
# Add include element
|
|
1209
|
+
|
|
1210
|
+
if rule == AddIncludeIfExistsRule.without_file:
|
|
1211
|
+
withFile = False
|
|
1212
|
+
elif rule == AddIncludeIfExistsRule.with_file:
|
|
1213
|
+
withFile = True
|
|
1214
|
+
else:
|
|
1215
|
+
BugCheckError.UnknownAddIncludeIfExistsRule(rule)
|
|
1216
|
+
|
|
1217
|
+
if not withFile:
|
|
1218
|
+
fileData = None
|
|
1219
|
+
else:
|
|
1220
|
+
baseFolder = self.m_Cfg.m_Data.OsOps.Path_DirName(
|
|
1221
|
+
self.m_FileData.m_Path,
|
|
1222
|
+
)
|
|
1223
|
+
assert type(baseFolder) is str
|
|
1224
|
+
|
|
1225
|
+
fileData = PgCfgModel__ModelUtils.Cfg__GetOrCreateFile__USER(
|
|
1226
|
+
self.m_Cfg.m_Data,
|
|
1227
|
+
baseFolder,
|
|
1228
|
+
path,
|
|
1229
|
+
)
|
|
1230
|
+
assert type(fileData) is PgCfgModel__FileData
|
|
1231
|
+
|
|
1232
|
+
try:
|
|
1233
|
+
fileLineData = PgCfgModel__ModelUtils.File__add_Line(
|
|
1234
|
+
self.m_FileData,
|
|
1235
|
+
)
|
|
1236
|
+
|
|
1237
|
+
assert self.m_FileData is not None
|
|
1238
|
+
assert type(self.m_FileData) is PgCfgModel__FileData
|
|
1239
|
+
assert self.m_FileData.m_Lines is not None
|
|
1240
|
+
assert type(self.m_FileData.m_Lines) is list
|
|
1241
|
+
assert len(self.m_FileData.m_Lines) > 0
|
|
1242
|
+
assert self.m_FileData.m_Lines[-1] is fileLineData
|
|
1243
|
+
|
|
1244
|
+
try:
|
|
1245
|
+
includeData = PgCfgModel__ModelUtils.FileLine__add_IncludeIfExists(
|
|
1246
|
+
fileLineData,
|
|
1247
|
+
path,
|
|
1248
|
+
fileData,
|
|
1249
|
+
None,
|
|
1250
|
+
)
|
|
1251
|
+
assert includeData is not None
|
|
1252
|
+
assert type(includeData) is PgCfgModel__IncludeIfExistsData
|
|
1253
|
+
assert includeData.m_Path == path
|
|
1254
|
+
assert includeData.m_File is fileData
|
|
1255
|
+
assert includeData.m_Parent == fileLineData
|
|
1256
|
+
|
|
1257
|
+
# -----------
|
|
1258
|
+
fileLine = PostgresConfigurationFileLine_Base(
|
|
1259
|
+
self,
|
|
1260
|
+
fileLineData,
|
|
1261
|
+
)
|
|
1262
|
+
assert fileLine is not None
|
|
1263
|
+
assert type(fileLine) is PostgresConfigurationFileLine_Base
|
|
1264
|
+
assert fileLine.m_FileLineData is fileLineData
|
|
1265
|
+
assert fileLine.m_Parent is self
|
|
1266
|
+
|
|
1267
|
+
# -----------
|
|
1268
|
+
include = PostgresConfigurationIncludeIfExists_Base(
|
|
1269
|
+
fileLine,
|
|
1270
|
+
includeData,
|
|
1271
|
+
)
|
|
1272
|
+
assert include.m_FileLine is fileLine
|
|
1273
|
+
assert include.m_IncludeIfExistsData is includeData
|
|
1274
|
+
except: # rollback a line
|
|
1275
|
+
PgCfgModel__ModelUtils.FileLine__delete(
|
|
1276
|
+
self.m_Cfg.m_Data,
|
|
1277
|
+
fileLineData,
|
|
1278
|
+
)
|
|
1279
|
+
raise
|
|
1280
|
+
except: # TODO: rollback a file
|
|
1281
|
+
raise
|
|
1282
|
+
|
|
1283
|
+
return include
|
|
1284
|
+
|
|
1004
1285
|
# --------------------------------------------------------------------
|
|
1005
1286
|
#
|
|
1006
1287
|
# Method for inserting, updating and deleting of an option.
|
|
@@ -1181,6 +1462,60 @@ class PostgresConfigurationIncludedFile_Base(PostgresConfigurationFile_Base):
|
|
|
1181
1462
|
return
|
|
1182
1463
|
|
|
1183
1464
|
|
|
1465
|
+
# //////////////////////////////////////////////////////////////////////////////
|
|
1466
|
+
# class PostgresConfigurationIncludedIfExistsFile_Base
|
|
1467
|
+
|
|
1468
|
+
|
|
1469
|
+
class PostgresConfigurationIncludedIfExistsFile_Base(PostgresConfigurationFile_Base):
|
|
1470
|
+
m_IncludeIfExists: PostgresConfigurationIncludeIfExists_Base
|
|
1471
|
+
|
|
1472
|
+
# --------------------------------------------------------------------
|
|
1473
|
+
def __init__(
|
|
1474
|
+
self,
|
|
1475
|
+
include: PostgresConfigurationIncludeIfExists_Base,
|
|
1476
|
+
fileData: PgCfgModel__FileData,
|
|
1477
|
+
):
|
|
1478
|
+
assert type(include) is PostgresConfigurationIncludeIfExists_Base
|
|
1479
|
+
assert type(fileData) is PgCfgModel__FileData
|
|
1480
|
+
|
|
1481
|
+
super().__init__(
|
|
1482
|
+
include.get_Configuration(),
|
|
1483
|
+
fileData,
|
|
1484
|
+
)
|
|
1485
|
+
|
|
1486
|
+
self.m_IncludeIfExists = include
|
|
1487
|
+
return
|
|
1488
|
+
|
|
1489
|
+
# Object interface ---------------------------------------------------
|
|
1490
|
+
def get_Parent(self) -> PostgresConfigurationIncludeIfExists_Base:
|
|
1491
|
+
self.Internal__CheckAlive()
|
|
1492
|
+
assert isinstance(
|
|
1493
|
+
self.m_IncludeIfExists,
|
|
1494
|
+
PostgresConfigurationIncludeIfExists_Base,
|
|
1495
|
+
)
|
|
1496
|
+
assert isinstance(
|
|
1497
|
+
self.m_IncludeIfExists,
|
|
1498
|
+
PostgresConfigurationIncludeIfExists,
|
|
1499
|
+
)
|
|
1500
|
+
return self.m_IncludeIfExists
|
|
1501
|
+
|
|
1502
|
+
# Internal interface -------------------------------------------------
|
|
1503
|
+
def Internal__CheckAlive(self) -> None:
|
|
1504
|
+
assert self.m_FileData is not None
|
|
1505
|
+
assert self.m_IncludeIfExists is not None
|
|
1506
|
+
assert type(self.m_FileData) is PgCfgModel__FileData
|
|
1507
|
+
assert type(self.m_IncludeIfExists) is PostgresConfigurationIncludeIfExists_Base
|
|
1508
|
+
|
|
1509
|
+
if not self.m_FileData.IsAlive():
|
|
1510
|
+
RaiseError.FileObjectWasDeleted()
|
|
1511
|
+
|
|
1512
|
+
self.m_IncludeIfExists.Private__CheckAlive()
|
|
1513
|
+
|
|
1514
|
+
assert isinstance(self.m_Cfg, PostgresConfiguration_Base)
|
|
1515
|
+
assert isinstance(self.m_Cfg, PostgresConfiguration)
|
|
1516
|
+
return
|
|
1517
|
+
|
|
1518
|
+
|
|
1184
1519
|
# //////////////////////////////////////////////////////////////////////////////
|
|
1185
1520
|
# class PostgresConfigurationSetOptionValueResult_Base
|
|
1186
1521
|
|
|
@@ -9,10 +9,12 @@ from .configuration_base import PostgresConfigurationFileLine_Base
|
|
|
9
9
|
from .configuration_base import PostgresConfigurationFile_Base
|
|
10
10
|
from .configuration_base import PostgresConfigurationTopLevelFile_Base
|
|
11
11
|
from .configuration_base import PostgresConfigurationFactory_Base
|
|
12
|
+
from .configuration_base import AddIncludeIfExistsRule
|
|
12
13
|
|
|
13
14
|
from ...core.model import CommentData as PgCfgModel__CommentData
|
|
14
15
|
from ...core.model import OptionData as PgCfgModel__OptionData
|
|
15
16
|
from ...core.model import IncludeData as PgCfgModel__IncludeData
|
|
17
|
+
from ...core.model import IncludeIfExistsData as PgCfgModel__IncludeIfExistsData
|
|
16
18
|
from ...core.model import FileLineData as PgCfgModel__FileLineData
|
|
17
19
|
from ...core.model import FileData as PgCfgModel__FileData
|
|
18
20
|
from ...core.model import FileStatus as PgCfgModel__FileStatus
|
|
@@ -148,6 +150,33 @@ class PostgresConfigurationReader_Base:
|
|
|
148
150
|
queuedFileDatas.add(includeData.m_File)
|
|
149
151
|
continue
|
|
150
152
|
|
|
153
|
+
if type(fileLineElementData) is PgCfgModel__IncludeIfExistsData:
|
|
154
|
+
# look at existFileDatas
|
|
155
|
+
includeIfExistsData = fileLineElementData
|
|
156
|
+
|
|
157
|
+
if includeIfExistsData.m_File is None:
|
|
158
|
+
continue
|
|
159
|
+
|
|
160
|
+
assert type(includeIfExistsData.m_File) is PgCfgModel__FileData
|
|
161
|
+
assert type(includeIfExistsData.m_File.m_Path) is str
|
|
162
|
+
|
|
163
|
+
if includeIfExistsData.m_File.m_Path in existFileDatas:
|
|
164
|
+
continue # it is an old file
|
|
165
|
+
|
|
166
|
+
assert (
|
|
167
|
+
includeIfExistsData.m_File.m_Status
|
|
168
|
+
== PgCfgModel__FileStatus.IS_NEW
|
|
169
|
+
)
|
|
170
|
+
assert (
|
|
171
|
+
includeIfExistsData.m_File.m_LastModifiedTimestamp is None
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
if includeIfExistsData.m_File in queuedFileDatas:
|
|
175
|
+
continue # already in queue
|
|
176
|
+
|
|
177
|
+
queuedFileDatas.add(includeIfExistsData.m_File)
|
|
178
|
+
continue
|
|
179
|
+
|
|
151
180
|
BugCheckError.UnkObjectDataType(type(fileLineElementData))
|
|
152
181
|
continue
|
|
153
182
|
continue # while queuedFileDatas
|
|
@@ -272,6 +301,17 @@ class PostgresConfigurationReader_Base:
|
|
|
272
301
|
)
|
|
273
302
|
continue
|
|
274
303
|
|
|
304
|
+
if sequence.lower() == "include_if_exists":
|
|
305
|
+
if ch is not None:
|
|
306
|
+
lineReader.StepBack()
|
|
307
|
+
|
|
308
|
+
__class__.Helper__ProcessLineData__IncludeIfExists(
|
|
309
|
+
fileLine,
|
|
310
|
+
lineReader,
|
|
311
|
+
sequenceOffset,
|
|
312
|
+
)
|
|
313
|
+
continue
|
|
314
|
+
|
|
275
315
|
if ch is not None:
|
|
276
316
|
lineReader.StepBack()
|
|
277
317
|
|
|
@@ -333,6 +373,69 @@ class PostgresConfigurationReader_Base:
|
|
|
333
373
|
assert type(includeOffset) is int
|
|
334
374
|
assert includeOffset >= 0
|
|
335
375
|
|
|
376
|
+
filePath = __class__.Helper__ProcessFilePath(
|
|
377
|
+
fileLine,
|
|
378
|
+
lineReader,
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
fileLine.AddInclude(
|
|
382
|
+
filePath,
|
|
383
|
+
includeOffset,
|
|
384
|
+
)
|
|
385
|
+
return
|
|
386
|
+
|
|
387
|
+
# --------------------------------------------------------------------
|
|
388
|
+
@staticmethod
|
|
389
|
+
def Helper__ProcessLineData__IncludeIfExists(
|
|
390
|
+
fileLine: PostgresConfigurationFileLine_Base,
|
|
391
|
+
lineReader: ReadUtils__LineReader,
|
|
392
|
+
includeOffset: int,
|
|
393
|
+
) -> None:
|
|
394
|
+
assert type(fileLine) is PostgresConfigurationFileLine_Base
|
|
395
|
+
assert type(lineReader) is ReadUtils__LineReader
|
|
396
|
+
assert type(includeOffset) is int
|
|
397
|
+
assert includeOffset >= 0
|
|
398
|
+
assert fileLine.m_Parent is not None
|
|
399
|
+
assert fileLine.m_Parent.m_FileData is not None
|
|
400
|
+
assert fileLine.m_Parent.m_FileData.m_Parent is not None
|
|
401
|
+
|
|
402
|
+
filePath = __class__.Helper__ProcessFilePath(
|
|
403
|
+
fileLine,
|
|
404
|
+
lineReader,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
osOps = fileLine.m_Parent.m_FileData.m_Parent.m_OsOps
|
|
408
|
+
assert osOps is not None
|
|
409
|
+
|
|
410
|
+
normFilePath = Helpers.NormalizeFilePath(
|
|
411
|
+
osOps,
|
|
412
|
+
osOps.Path_DirName(fileLine.m_Parent.m_FileData.m_Path),
|
|
413
|
+
filePath,
|
|
414
|
+
)
|
|
415
|
+
assert type(normFilePath) is str
|
|
416
|
+
assert normFilePath != ""
|
|
417
|
+
|
|
418
|
+
if osOps.Path_IsExists(normFilePath):
|
|
419
|
+
rule = AddIncludeIfExistsRule.with_file
|
|
420
|
+
else:
|
|
421
|
+
rule = AddIncludeIfExistsRule.without_file
|
|
422
|
+
|
|
423
|
+
fileLine.AddIncludeIfExists(
|
|
424
|
+
filePath,
|
|
425
|
+
includeOffset,
|
|
426
|
+
rule=rule,
|
|
427
|
+
)
|
|
428
|
+
return
|
|
429
|
+
|
|
430
|
+
# --------------------------------------------------------------------
|
|
431
|
+
@staticmethod
|
|
432
|
+
def Helper__ProcessFilePath(
|
|
433
|
+
fileLine: PostgresConfigurationFileLine_Base,
|
|
434
|
+
lineReader: ReadUtils__LineReader,
|
|
435
|
+
) -> str:
|
|
436
|
+
assert type(fileLine) is PostgresConfigurationFileLine_Base
|
|
437
|
+
assert type(lineReader) is ReadUtils__LineReader
|
|
438
|
+
|
|
336
439
|
# find first quote
|
|
337
440
|
while True:
|
|
338
441
|
ch = lineReader.ReadSymbol()
|
|
@@ -452,11 +555,7 @@ class PostgresConfigurationReader_Base:
|
|
|
452
555
|
lineReader.GetLineNum(),
|
|
453
556
|
)
|
|
454
557
|
|
|
455
|
-
|
|
456
|
-
filePath,
|
|
457
|
-
includeOffset,
|
|
458
|
-
)
|
|
459
|
-
return
|
|
558
|
+
return filePath
|
|
460
559
|
|
|
461
560
|
# --------------------------------------------------------------------
|
|
462
561
|
@staticmethod
|
|
@@ -11,6 +11,7 @@ from ...core.model import FileLineElementData as PgCfgModel__FileLineElementData
|
|
|
11
11
|
from ...core.model import CommentData as PgCfgModel__CommentData
|
|
12
12
|
from ...core.model import OptionData as PgCfgModel__OptionData
|
|
13
13
|
from ...core.model import IncludeData as PgCfgModel__IncludeData
|
|
14
|
+
from ...core.model import IncludeIfExistsData as PgCfgModel__IncludeIfExistsData
|
|
14
15
|
from ...core.model import FileLineData as PgCfgModel__FileLineData
|
|
15
16
|
from ...core.model import FileData as PgCfgModel__FileData
|
|
16
17
|
from ...core.model import FileStatus as PgCfgModel__FileStatus
|
|
@@ -475,6 +476,12 @@ class PostgresConfigurationWriter_Base:
|
|
|
475
476
|
elementData,
|
|
476
477
|
)
|
|
477
478
|
|
|
479
|
+
if type(elementData) is PgCfgModel__IncludeIfExistsData:
|
|
480
|
+
return __class__.Helper__IncludeIfExistsToString(
|
|
481
|
+
ctx,
|
|
482
|
+
elementData,
|
|
483
|
+
)
|
|
484
|
+
|
|
478
485
|
BugCheckError.UnkObjectDataType(type(elementData))
|
|
479
486
|
|
|
480
487
|
# --------------------------------------------------------------------
|
|
@@ -552,5 +559,25 @@ class PostgresConfigurationWriter_Base:
|
|
|
552
559
|
assert result != ""
|
|
553
560
|
return result
|
|
554
561
|
|
|
562
|
+
# --------------------------------------------------------------------
|
|
563
|
+
@staticmethod
|
|
564
|
+
def Helper__IncludeIfExistsToString(
|
|
565
|
+
ctx: PostgresConfigurationWriterCtx_Base,
|
|
566
|
+
includeIfExistsData: PgCfgModel__IncludeIfExistsData,
|
|
567
|
+
) -> str:
|
|
568
|
+
assert type(ctx) is PostgresConfigurationWriterCtx_Base
|
|
569
|
+
assert ctx.Cfg is not None
|
|
570
|
+
assert isinstance(ctx.Cfg, PostgresConfiguration_Base)
|
|
571
|
+
assert type(includeIfExistsData) is PgCfgModel__IncludeIfExistsData
|
|
572
|
+
assert includeIfExistsData.m_Path is not None
|
|
573
|
+
assert type(includeIfExistsData.m_Path) is str
|
|
574
|
+
assert includeIfExistsData.m_Path != ""
|
|
575
|
+
|
|
576
|
+
result = "include_if_exists " + WriteUtils.Pack_Str(includeIfExistsData.m_Path)
|
|
577
|
+
|
|
578
|
+
assert type(result) is str
|
|
579
|
+
assert result != ""
|
|
580
|
+
return result
|
|
581
|
+
|
|
555
582
|
|
|
556
583
|
# //////////////////////////////////////////////////////////////////////////////
|
|
@@ -55,6 +55,10 @@ class ConfigurationOsFile(ConfigurationFileReader):
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
class ConfigurationOsOps:
|
|
58
|
+
def Path_IsExists(self, a: str) -> bool:
|
|
59
|
+
assert type(a) is str
|
|
60
|
+
RaiseError.MethodIsNotImplemented(__class__, "Path_IsExists")
|
|
61
|
+
|
|
58
62
|
def Path_IsAbs(self, a: str) -> bool:
|
|
59
63
|
assert type(a) is str
|
|
60
64
|
RaiseError.MethodIsNotImplemented(__class__, "Path_IsAbs")
|
|
@@ -97,6 +97,10 @@ class ConfigurationOsFile(abstract.ConfigurationOsFile):
|
|
|
97
97
|
|
|
98
98
|
|
|
99
99
|
class ConfigurationOsOps(abstract.ConfigurationOsOps):
|
|
100
|
+
def Path_IsExists(self, a: str) -> bool:
|
|
101
|
+
assert type(a) is str
|
|
102
|
+
return os.path.exists(a)
|
|
103
|
+
|
|
100
104
|
def Path_IsAbs(self, a: str) -> bool:
|
|
101
105
|
assert type(a) is str
|
|
102
106
|
return os.path.isabs(a)
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
# Postgres Pro. PostgreSQL Configuration Python Library.
|
|
3
|
-
|
|
4
|
-
# fmt: off
|
|
5
|
-
from .implementation.v00.configuration_std import PostgresConfiguration_Std as PostgresConfiguration
|
|
6
|
-
|
|
7
|
-
from .implementation.v00.configuration_std import PostgresConfigurationReader_Std as PostgresConfigurationReader
|
|
8
|
-
|
|
9
|
-
from .implementation.v00.configuration_std import PostgresConfigurationWriter_Std as PostgresConfigurationWriter
|
|
10
|
-
# fmt: on
|
|
11
|
-
|
|
12
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__all__ = [
|
|
16
|
-
"PostgresConfiguration",
|
|
17
|
-
"PostgresConfigurationReader",
|
|
18
|
-
"PostgresConfigurationWriter",
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
# //////////////////////////////////////////////////////////////////////////////
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/handlers.py
RENAMED
|
File without changes
|
{testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/core/helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{testgres_postgres_configuration-0.5.0 → testgres_postgres_configuration-0.6.0}/src/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|