testgres.postgres-configuration 0.1.0__py3-none-any.whl

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.
Files changed (40) hide show
  1. testgres/postgres_configuration/__init__.py +22 -0
  2. testgres/postgres_configuration/abstract/v00/configuration.py +435 -0
  3. testgres/postgres_configuration/core/bugcheck_error.py +219 -0
  4. testgres/postgres_configuration/core/controller_utils.py +982 -0
  5. testgres/postgres_configuration/core/data_verificator.py +60 -0
  6. testgres/postgres_configuration/core/handlers.py +483 -0
  7. testgres/postgres_configuration/core/helpers.py +95 -0
  8. testgres/postgres_configuration/core/model.py +296 -0
  9. testgres/postgres_configuration/core/option/handlers/add/option_handler_to_add__std.py +38 -0
  10. testgres/postgres_configuration/core/option/handlers/get_value/option_handler_to_get_value__std__simple.py +36 -0
  11. testgres/postgres_configuration/core/option/handlers/get_value/option_handler_to_get_value__std__union_list.py +36 -0
  12. testgres/postgres_configuration/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__bool.py +31 -0
  13. testgres/postgres_configuration/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__generic.py +41 -0
  14. testgres/postgres_configuration/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__int.py +31 -0
  15. testgres/postgres_configuration/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__str.py +31 -0
  16. testgres/postgres_configuration/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__unique_str_list.py +46 -0
  17. testgres/postgres_configuration/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__bool.py +115 -0
  18. testgres/postgres_configuration/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__generic.py +41 -0
  19. testgres/postgres_configuration/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__int.py +44 -0
  20. testgres/postgres_configuration/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__str.py +37 -0
  21. testgres/postgres_configuration/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__unique_str_list.py +63 -0
  22. testgres/postgres_configuration/core/option/handlers/prepare_set_value_item/option_handler_to_prepare_set_value_item__std__str.py +37 -0
  23. testgres/postgres_configuration/core/option/handlers/set_value/option_handler_to_set_value__std__simple.py +38 -0
  24. testgres/postgres_configuration/core/option/handlers/set_value_item/option_handler_to_set_value_item__std__unique.py +38 -0
  25. testgres/postgres_configuration/core/option/handlers/write/option_handler_to_write__std__bool.py +42 -0
  26. testgres/postgres_configuration/core/option/handlers/write/option_handler_to_write__std__generic.py +51 -0
  27. testgres/postgres_configuration/core/option/handlers/write/option_handler_to_write__std__int.py +27 -0
  28. testgres/postgres_configuration/core/option/handlers/write/option_handler_to_write__std__str.py +36 -0
  29. testgres/postgres_configuration/core/option/handlers/write/option_handler_to_write__std__unique_str_list.py +37 -0
  30. testgres/postgres_configuration/core/raise_error.py +365 -0
  31. testgres/postgres_configuration/core/read_utils.py +308 -0
  32. testgres/postgres_configuration/core/write_utils.py +112 -0
  33. testgres/postgres_configuration/implementation/v00/configuration_base.py +4408 -0
  34. testgres/postgres_configuration/implementation/v00/configuration_std.py +538 -0
  35. testgres/postgres_configuration/os/abstract/configuration_os_ops.py +98 -0
  36. testgres/postgres_configuration/os/local/configuration_os_ops.py +154 -0
  37. testgres_postgres_configuration-0.1.0.dist-info/METADATA +25 -0
  38. testgres_postgres_configuration-0.1.0.dist-info/RECORD +40 -0
  39. testgres_postgres_configuration-0.1.0.dist-info/WHEEL +5 -0
  40. testgres_postgres_configuration-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,538 @@
1
+ # //////////////////////////////////////////////////////////////////////////////
2
+ # Postgres Pro. PostgreSQL Configuration Python Library.
3
+
4
+ from __future__ import annotations
5
+
6
+ from .configuration_base import PostgresConfiguration_Base
7
+ from .configuration_base import PostgresConfigurationReader_Base
8
+ from .configuration_base import PostgresConfigurationWriter_Base
9
+ from .configuration_base import PostgresConfigurationWriterCtx_Base
10
+ from .configuration_base import PgCfgModel__OptionHandlerToPrepareSetValue
11
+ from .configuration_base import PgCfgModel__OptionHandlerToPrepareSetValueItem
12
+ from .configuration_base import PgCfgModel__OptionHandlerToPrepareGetValue
13
+ from .configuration_base import PgCfgModel__OptionHandlerToSetValue
14
+ from .configuration_base import PgCfgModel__OptionHandlerToGetValue
15
+ from .configuration_base import PgCfgModel__OptionHandlerToAddOption
16
+ from .configuration_base import PgCfgModel__OptionHandlerToSetValueItem
17
+ from .configuration_base import PgCfgModel__OptionHandlerToWrite
18
+
19
+ from ...os.abstract.configuration_os_ops import ConfigurationOsOps
20
+ from ...os.local.configuration_os_ops import SingleInstance as LocalCfgOsOps
21
+
22
+ # fmt: off
23
+ from ...core.option.handlers.prepare_set_value.option_handler_to_prepare_set_value__std__generic \
24
+ import OptionHandlerToPrepareSetValue__Std__Generic
25
+
26
+ from ...core.option.handlers.prepare_set_value.option_handler_to_prepare_set_value__std__int \
27
+ import OptionHandlerToPrepareSetValue__Std__Int
28
+
29
+ from ...core.option.handlers.prepare_set_value.option_handler_to_prepare_set_value__std__str \
30
+ import OptionHandlerToPrepareSetValue__Std__Str
31
+
32
+ from ...core.option.handlers.prepare_set_value.option_handler_to_prepare_set_value__std__bool \
33
+ import OptionHandlerToPrepareSetValue__Std__Bool
34
+
35
+ from ...core.option.handlers.prepare_set_value.option_handler_to_prepare_set_value__std__unique_str_list \
36
+ import OptionHandlerToPrepareSetValue__Std__UniqueStrList
37
+
38
+ # -------------
39
+ from ...core.option.handlers.prepare_set_value_item.option_handler_to_prepare_set_value_item__std__str \
40
+ import OptionHandlerToPrepareSetValueItem__Std__Str
41
+
42
+ # -------------
43
+ from ...core.option.handlers.prepare_get_value.option_handler_to_prepare_get_value__std__generic \
44
+ import OptionHandlerToPrepareGetValue__Std__Generic
45
+
46
+ from ...core.option.handlers.prepare_get_value.option_handler_to_prepare_get_value__std__int \
47
+ import OptionHandlerToPrepareGetValue__Std__Int
48
+
49
+ from ...core.option.handlers.prepare_get_value.option_handler_to_prepare_get_value__std__str \
50
+ import OptionHandlerToPrepareGetValue__Std__Str
51
+
52
+ from ...core.option.handlers.prepare_get_value.option_handler_to_prepare_get_value__std__bool \
53
+ import OptionHandlerToPrepareGetValue__Std__Bool
54
+
55
+ # -------------
56
+ from ...core.option.handlers.prepare_get_value.option_handler_to_prepare_get_value__std__unique_str_list \
57
+ import OptionHandlerToPrepareGetValue__Std__UniqueStrList
58
+
59
+ # -------------
60
+ from ...core.option.handlers.set_value.option_handler_to_set_value__std__simple \
61
+ import OptionHandlerToSetValue__Std__Simple
62
+
63
+ # -------------
64
+ from ...core.option.handlers.get_value.option_handler_to_get_value__std__simple \
65
+ import OptionHandlerToGetValue__Std__Simple
66
+
67
+ from ...core.option.handlers.get_value.option_handler_to_get_value__std__union_list \
68
+ import OptionHandlerToGetValue__Std__UnionList
69
+
70
+ # -------------
71
+ from ...core.option.handlers.add.option_handler_to_add__std \
72
+ import OptionHandlerToAddOption__Std
73
+
74
+ # -------------
75
+ from ...core.option.handlers.set_value_item.option_handler_to_set_value_item__std__unique \
76
+ import OptionHandlerToSetValueItem__Std__Unique
77
+
78
+ # -------------
79
+ from ...core.option.handlers.write.option_handler_to_write__std__generic \
80
+ import OptionHandlerToWrite__Std__Generic
81
+
82
+ from ...core.option.handlers.write.option_handler_to_write__std__int \
83
+ import OptionHandlerToWrite__Std__Int
84
+
85
+ from ...core.option.handlers.write.option_handler_to_write__std__str \
86
+ import OptionHandlerToWrite__Std__Str
87
+
88
+ from ...core.option.handlers.write.option_handler_to_write__std__bool \
89
+ import OptionHandlerToWrite__Std__Bool
90
+
91
+ from ...core.option.handlers.write.option_handler_to_write__std__unique_str_list \
92
+ import OptionHandlerToWrite__Std__UniqueStrList
93
+ # fmt: on
94
+
95
+ from ...core.bugcheck_error import BugCheckError
96
+
97
+ # //////////////////////////////////////////////////////////////////////////////
98
+ # class PostgresConfiguration_Std
99
+
100
+
101
+ class PostgresConfiguration_Std(PostgresConfiguration_Base):
102
+ C_POSTGRESQL_CONF = "postgresql.conf"
103
+ C_POSTGRESQL_AUTO_CONF = "postgresql.auto.conf"
104
+
105
+ # --------------------------------------------------------------------
106
+ # fmt: off
107
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Generic = \
108
+ OptionHandlerToPrepareSetValue__Std__Generic()
109
+
110
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Int = \
111
+ OptionHandlerToPrepareSetValue__Std__Int()
112
+
113
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Str = \
114
+ OptionHandlerToPrepareSetValue__Std__Str()
115
+
116
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Bool = \
117
+ OptionHandlerToPrepareSetValue__Std__Bool()
118
+
119
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__UniqueStrList = \
120
+ OptionHandlerToPrepareSetValue__Std__UniqueStrList()
121
+
122
+ # ---------
123
+ sm_SingleInstance__OptionHandlerToPrepareSetValueItem__Std__Str = \
124
+ OptionHandlerToPrepareSetValueItem__Std__Str()
125
+
126
+ # ---------
127
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Generic = \
128
+ OptionHandlerToPrepareGetValue__Std__Generic()
129
+
130
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Int = \
131
+ OptionHandlerToPrepareGetValue__Std__Int()
132
+
133
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Str = \
134
+ OptionHandlerToPrepareGetValue__Std__Str()
135
+
136
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Bool = \
137
+ OptionHandlerToPrepareGetValue__Std__Bool()
138
+
139
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__UniqueStrList = \
140
+ OptionHandlerToPrepareGetValue__Std__UniqueStrList()
141
+
142
+ # ---------
143
+ sm_SingleInstance__OptionHandlerToSetValue__Std__Simple = \
144
+ OptionHandlerToSetValue__Std__Simple()
145
+
146
+ # ---------
147
+ sm_SingleInstance__OptionHandlerToGetValue__Std__Simple = \
148
+ OptionHandlerToGetValue__Std__Simple()
149
+
150
+ sm_SingleInstance__OptionHandlerToGetValue__Std__UnionList = \
151
+ OptionHandlerToGetValue__Std__UnionList()
152
+
153
+ # ---------
154
+ sm_SingleInstance__OptionHandlerToAddOption__Std = \
155
+ OptionHandlerToAddOption__Std()
156
+
157
+ # ---------
158
+ sm_SingleInstance__OptionHandlerToSetValueItem__Std__Unique = \
159
+ OptionHandlerToSetValueItem__Std__Unique()
160
+
161
+ # ---------
162
+ sm_SingleInstance__OptionHandlerToWrite__Std__Generic = \
163
+ OptionHandlerToWrite__Std__Generic()
164
+
165
+ sm_SingleInstance__OptionHandlerToWrite__Std__Int = \
166
+ OptionHandlerToWrite__Std__Int()
167
+
168
+ sm_SingleInstance__OptionHandlerToWrite__Std__Str = \
169
+ OptionHandlerToWrite__Std__Str()
170
+
171
+ sm_SingleInstance__OptionHandlerToWrite__Std__Bool = \
172
+ OptionHandlerToWrite__Std__Bool()
173
+
174
+ sm_SingleInstance__OptionHandlerToWrite__Std__UniqueStrList = \
175
+ OptionHandlerToWrite__Std__UniqueStrList()
176
+ # fmt: on
177
+
178
+ # --------------------------------------------------------------------
179
+ class tagOptionHandlers:
180
+ PrepareSetValue: PgCfgModel__OptionHandlerToPrepareSetValue
181
+ PrepareGetValue: PgCfgModel__OptionHandlerToPrepareGetValue
182
+ PrepareSetValueItem: PgCfgModel__OptionHandlerToPrepareSetValueItem
183
+ SetValue: PgCfgModel__OptionHandlerToSetValue
184
+ GetValue: PgCfgModel__OptionHandlerToGetValue
185
+ AddOption: PgCfgModel__OptionHandlerToAddOption
186
+ SetValueItem: PgCfgModel__OptionHandlerToSetValueItem
187
+ Write: PgCfgModel__OptionHandlerToWrite
188
+
189
+ # ----------------------------------------------------------------
190
+ def __init__(
191
+ self,
192
+ prepareSetValue: PgCfgModel__OptionHandlerToPrepareSetValue,
193
+ prepareGetValue: PgCfgModel__OptionHandlerToPrepareGetValue,
194
+ prepareSetValueItem: PgCfgModel__OptionHandlerToPrepareSetValueItem,
195
+ setValue: PgCfgModel__OptionHandlerToSetValue,
196
+ getValue: PgCfgModel__OptionHandlerToGetValue,
197
+ addIntoFile: PgCfgModel__OptionHandlerToAddOption,
198
+ setValueItem: PgCfgModel__OptionHandlerToSetValueItem,
199
+ write: PgCfgModel__OptionHandlerToGetValue,
200
+ ):
201
+ assert prepareSetValue is None or isinstance(
202
+ prepareSetValue, PgCfgModel__OptionHandlerToPrepareSetValue
203
+ )
204
+ assert prepareGetValue is None or isinstance(
205
+ prepareGetValue, PgCfgModel__OptionHandlerToPrepareGetValue
206
+ )
207
+ assert prepareSetValueItem is None or isinstance(
208
+ prepareSetValueItem, PgCfgModel__OptionHandlerToPrepareSetValueItem
209
+ )
210
+ assert setValue is None or isinstance(
211
+ setValue, PgCfgModel__OptionHandlerToSetValue
212
+ )
213
+ assert getValue is None or isinstance(
214
+ getValue, PgCfgModel__OptionHandlerToGetValue
215
+ )
216
+ assert setValueItem is None or isinstance(
217
+ setValueItem, PgCfgModel__OptionHandlerToSetValueItem
218
+ )
219
+ assert addIntoFile is None or isinstance(
220
+ addIntoFile, PgCfgModel__OptionHandlerToAddOption
221
+ )
222
+ assert write is None or isinstance(write, PgCfgModel__OptionHandlerToWrite)
223
+
224
+ self.PrepareSetValue = prepareSetValue
225
+ self.PrepareGetValue = prepareGetValue
226
+ self.PrepareSetValueItem = prepareSetValueItem
227
+ self.SetValue = setValue
228
+ self.AddOption = addIntoFile
229
+ self.GetValue = getValue
230
+ self.SetValueItem = setValueItem
231
+ self.Write = write
232
+
233
+ # --------------------------------------------------------------------
234
+ # fmt: off
235
+ sm_OptionHandlers__Std__Generic = \
236
+ tagOptionHandlers(
237
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Generic,
238
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Generic,
239
+ None,
240
+ sm_SingleInstance__OptionHandlerToSetValue__Std__Simple,
241
+ sm_SingleInstance__OptionHandlerToGetValue__Std__Simple,
242
+ sm_SingleInstance__OptionHandlerToAddOption__Std,
243
+ None,
244
+ sm_SingleInstance__OptionHandlerToWrite__Std__Generic,
245
+ )
246
+
247
+ sm_OptionHandlers__Std__Int = \
248
+ tagOptionHandlers(
249
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Int,
250
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Int,
251
+ None,
252
+ sm_SingleInstance__OptionHandlerToSetValue__Std__Simple,
253
+ sm_SingleInstance__OptionHandlerToGetValue__Std__Simple,
254
+ sm_SingleInstance__OptionHandlerToAddOption__Std,
255
+ None,
256
+ sm_SingleInstance__OptionHandlerToWrite__Std__Int,
257
+ )
258
+
259
+ sm_OptionHandlers__Std__Str = \
260
+ tagOptionHandlers(
261
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Str,
262
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Str,
263
+ None,
264
+ sm_SingleInstance__OptionHandlerToSetValue__Std__Simple,
265
+ sm_SingleInstance__OptionHandlerToGetValue__Std__Simple,
266
+ sm_SingleInstance__OptionHandlerToAddOption__Std,
267
+ None,
268
+ sm_SingleInstance__OptionHandlerToWrite__Std__Str,
269
+ )
270
+
271
+ sm_OptionHandlers__Std__Bool = \
272
+ tagOptionHandlers(
273
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Bool,
274
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Bool,
275
+ None,
276
+ sm_SingleInstance__OptionHandlerToSetValue__Std__Simple,
277
+ sm_SingleInstance__OptionHandlerToGetValue__Std__Simple,
278
+ sm_SingleInstance__OptionHandlerToAddOption__Std,
279
+ None,
280
+ sm_SingleInstance__OptionHandlerToWrite__Std__Bool,
281
+ )
282
+
283
+ sm_OptionHandlers__Std__UniqueStrList = \
284
+ tagOptionHandlers(
285
+ sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__UniqueStrList,
286
+ sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__UniqueStrList,
287
+ sm_SingleInstance__OptionHandlerToPrepareSetValueItem__Std__Str,
288
+ None,
289
+ sm_SingleInstance__OptionHandlerToGetValue__Std__UnionList,
290
+ sm_SingleInstance__OptionHandlerToAddOption__Std,
291
+ sm_SingleInstance__OptionHandlerToSetValueItem__Std__Unique,
292
+ sm_SingleInstance__OptionHandlerToWrite__Std__UniqueStrList,
293
+ )
294
+ # fmt: on
295
+
296
+ # --------------------------------------------------------------------
297
+ sm_OptionHandlers: dict[str, tagOptionHandlers] = {
298
+ # fmt: off
299
+ # STANDARD -------------------------------------------------------
300
+ "port": sm_OptionHandlers__Std__Int,
301
+ "listen_addresses": sm_OptionHandlers__Std__Str,
302
+ "shared_preload_libraries": sm_OptionHandlers__Std__UniqueStrList,
303
+ "restart_after_crash": sm_OptionHandlers__Std__Bool,
304
+
305
+ # PROXIMA --------------------------------------------------------
306
+ "proxima.port": sm_OptionHandlers__Std__Int,
307
+ # fmt: on
308
+ }
309
+
310
+ # --------------------------------------------------------------------
311
+ def __init__(self, data_dir: str, cfgOsOps: ConfigurationOsOps = None):
312
+ assert type(data_dir) == str
313
+ assert cfgOsOps is None or isinstance(cfgOsOps, ConfigurationOsOps)
314
+
315
+ if cfgOsOps is None:
316
+ cfgOsOps = LocalCfgOsOps
317
+
318
+ assert isinstance(cfgOsOps, ConfigurationOsOps)
319
+
320
+ super().__init__(data_dir, LocalCfgOsOps)
321
+
322
+ # --------------------------------------------------------------------
323
+ @staticmethod
324
+ def Create(data_dir: str) -> PostgresConfiguration_Std:
325
+ assert type(data_dir) == str
326
+ assert isinstance(LocalCfgOsOps, ConfigurationOsOps)
327
+ return __class__(data_dir, LocalCfgOsOps)
328
+
329
+ # --------------------------------------------------------------------
330
+ @staticmethod
331
+ def CreateWithCfgOsOps(
332
+ data_dir: str,
333
+ cfgOsOps: ConfigurationOsOps
334
+ ) -> PostgresConfiguration_Std:
335
+ assert type(data_dir) == str
336
+ assert isinstance(cfgOsOps, ConfigurationOsOps)
337
+ return __class__(data_dir, cfgOsOps)
338
+
339
+ # PostgresConfiguration_Base interface -------------------------------
340
+ def Internal__GetAutoConfFileName(self):
341
+ assert type(__class__.C_POSTGRESQL_AUTO_CONF) == str
342
+ assert __class__.C_POSTGRESQL_AUTO_CONF != ""
343
+ return __class__.C_POSTGRESQL_AUTO_CONF
344
+
345
+ # --------------------------------------------------------------------
346
+ def Internal__GetOptionHandlerToPrepareSetValue(
347
+ self, name: str
348
+ ) -> PgCfgModel__OptionHandlerToPrepareSetValue:
349
+ assert type(name) == str
350
+ assert type(self.sm_OptionHandlers) == dict
351
+
352
+ optionHandlers = self.Helper__GetOptionHandlers(name)
353
+ assert type(optionHandlers) == __class__.tagOptionHandlers
354
+
355
+ if optionHandlers.PrepareSetValue is None:
356
+ BugCheckError.OptionHandlerToPrepareSetValueIsNotDefined(name)
357
+
358
+ assert isinstance(
359
+ optionHandlers.PrepareSetValue, PgCfgModel__OptionHandlerToPrepareSetValue
360
+ )
361
+
362
+ return optionHandlers.PrepareSetValue
363
+
364
+ # --------------------------------------------------------------------
365
+ def Internal__GetOptionHandlerToPrepareGetValue(
366
+ self, name: str
367
+ ) -> PgCfgModel__OptionHandlerToPrepareSetValue:
368
+ assert type(name) == str
369
+ assert type(self.sm_OptionHandlers) == dict
370
+
371
+ optionHandlers = self.Helper__GetOptionHandlers(name)
372
+ assert type(optionHandlers) == __class__.tagOptionHandlers
373
+
374
+ if optionHandlers.PrepareGetValue is None:
375
+ BugCheckError.OptionHandlerToPrepareGetValueIsNotDefined(name)
376
+
377
+ assert isinstance(
378
+ optionHandlers.PrepareGetValue, PgCfgModel__OptionHandlerToPrepareGetValue
379
+ )
380
+
381
+ return optionHandlers.PrepareGetValue
382
+
383
+ # --------------------------------------------------------------------
384
+ def Internal__GetOptionHandlerToPrepareSetValueItem(
385
+ self, name: str
386
+ ) -> PgCfgModel__OptionHandlerToPrepareSetValueItem:
387
+ assert type(name) == str
388
+ assert type(self.sm_OptionHandlers) == dict
389
+
390
+ optionHandlers = self.Helper__GetOptionHandlers(name)
391
+ assert type(optionHandlers) == __class__.tagOptionHandlers
392
+
393
+ if optionHandlers.PrepareSetValueItem is None:
394
+ BugCheckError.OptionHandlerToPrepareSetValueItemIsNotDefined(name)
395
+
396
+ assert isinstance(
397
+ optionHandlers.PrepareSetValueItem,
398
+ PgCfgModel__OptionHandlerToPrepareSetValueItem,
399
+ )
400
+
401
+ return optionHandlers.PrepareSetValueItem
402
+
403
+ # --------------------------------------------------------------------
404
+ def Internal__GetOptionHandlerToSetValue(
405
+ self, name: str
406
+ ) -> PgCfgModel__OptionHandlerToSetValue:
407
+ assert type(name) == str
408
+ assert type(self.sm_OptionHandlers) == dict
409
+
410
+ optionHandlers = self.Helper__GetOptionHandlers(name)
411
+ assert type(optionHandlers) == __class__.tagOptionHandlers
412
+
413
+ if optionHandlers.SetValue is None:
414
+ BugCheckError.OptionHandlerToSetValueIsNotDefined(name)
415
+
416
+ assert isinstance(optionHandlers.SetValue, PgCfgModel__OptionHandlerToSetValue)
417
+
418
+ return optionHandlers.SetValue
419
+
420
+ # --------------------------------------------------------------------
421
+ def Internal__GetOptionHandlerToGetValue(
422
+ self, name: str
423
+ ) -> PgCfgModel__OptionHandlerToGetValue:
424
+ assert type(name) == str
425
+ assert type(self.sm_OptionHandlers) == dict
426
+
427
+ optionHandlers = self.Helper__GetOptionHandlers(name)
428
+ assert type(optionHandlers) == __class__.tagOptionHandlers
429
+
430
+ if optionHandlers.GetValue is None:
431
+ BugCheckError.OptionHandlerToGetValueIsNotDefined(name)
432
+
433
+ assert isinstance(optionHandlers.GetValue, PgCfgModel__OptionHandlerToGetValue)
434
+
435
+ return optionHandlers.GetValue
436
+
437
+ # --------------------------------------------------------------------
438
+ def Internal__GetOptionHandlerToAddOption(
439
+ self, name: str
440
+ ) -> PgCfgModel__OptionHandlerToAddOption:
441
+ assert type(name) == str
442
+ assert type(self.sm_OptionHandlers) == dict
443
+
444
+ optionHandlers = self.Helper__GetOptionHandlers(name)
445
+ assert type(optionHandlers) == __class__.tagOptionHandlers
446
+
447
+ if optionHandlers.AddOption is None:
448
+ BugCheckError.OptionHandlerToAddOptionIsNotDefined(name)
449
+
450
+ assert isinstance(
451
+ optionHandlers.AddOption, PgCfgModel__OptionHandlerToAddOption
452
+ )
453
+
454
+ return optionHandlers.AddOption
455
+
456
+ # --------------------------------------------------------------------
457
+ def Internal__GetOptionHandlerToSetValueItem(
458
+ self, name: str
459
+ ) -> PgCfgModel__OptionHandlerToSetValueItem:
460
+ assert type(name) == str
461
+ assert type(self.sm_OptionHandlers) == dict
462
+
463
+ optionHandlers = self.Helper__GetOptionHandlers(name)
464
+ assert type(optionHandlers) == __class__.tagOptionHandlers
465
+
466
+ if optionHandlers.SetValueItem is None:
467
+ BugCheckError.OptionHandlerToSetValueIsNotDefined(name)
468
+
469
+ assert isinstance(
470
+ optionHandlers.SetValueItem, PgCfgModel__OptionHandlerToSetValueItem
471
+ )
472
+
473
+ return optionHandlers.SetValueItem
474
+
475
+ # --------------------------------------------------------------------
476
+ def Internal__GetOptionHandlerToWrite(
477
+ self, name: str
478
+ ) -> PgCfgModel__OptionHandlerToWrite:
479
+ assert type(name) == str
480
+ assert type(self.sm_OptionHandlers) == dict
481
+
482
+ optionHandlers = self.Helper__GetOptionHandlers(name)
483
+ assert type(optionHandlers) == __class__.tagOptionHandlers
484
+
485
+ if optionHandlers.Write is None:
486
+ BugCheckError.OptionHandlerToWriteIsNotDefined(name)
487
+
488
+ assert isinstance(optionHandlers.Write, PgCfgModel__OptionHandlerToWrite)
489
+
490
+ return optionHandlers.Write
491
+
492
+ # Helper methods -----------------------------------------------------
493
+ def Helper__GetOptionHandlers(self, name: str) -> tagOptionHandlers:
494
+ assert type(name) == str
495
+ assert type(self.sm_OptionHandlers) == dict
496
+
497
+ if not (name in self.sm_OptionHandlers.keys()):
498
+ return __class__.sm_OptionHandlers__Std__Generic
499
+
500
+ optionHandlers = self.sm_OptionHandlers[name]
501
+
502
+ assert optionHandlers is not None
503
+ assert type(optionHandlers) == __class__.tagOptionHandlers
504
+
505
+ return self.sm_OptionHandlers[name]
506
+
507
+
508
+ # //////////////////////////////////////////////////////////////////////////////
509
+ # class PostgresConfigurationReader_Std
510
+
511
+
512
+ class PostgresConfigurationReader_Std:
513
+ def LoadConfiguration(cfg: PostgresConfiguration_Std) -> None:
514
+ assert isinstance(cfg, PostgresConfiguration_Std)
515
+
516
+ # We expect that both files exist
517
+ PostgresConfigurationReader_Base.LoadConfigurationFile(
518
+ cfg, cfg.C_POSTGRESQL_CONF
519
+ )
520
+ PostgresConfigurationReader_Base.LoadConfigurationFile(
521
+ cfg, cfg.C_POSTGRESQL_AUTO_CONF
522
+ )
523
+
524
+
525
+ # //////////////////////////////////////////////////////////////////////////////
526
+ # class PostgresConfigurationWriter_Std
527
+
528
+
529
+ class PostgresConfigurationWriter_Std:
530
+ def WriteConfiguration(cfg: PostgresConfiguration_Std) -> None:
531
+ assert isinstance(cfg, PostgresConfiguration_Std)
532
+
533
+ writeCtx = PostgresConfigurationWriterCtx_Base(cfg)
534
+
535
+ PostgresConfigurationWriter_Base.DoWork(writeCtx)
536
+
537
+
538
+ # //////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,98 @@
1
+ # //////////////////////////////////////////////////////////////////////////////
2
+ # Postgres Pro. PostgreSQL Configuration Python Library.
3
+
4
+ from __future__ import annotations
5
+
6
+ from ...core.raise_error import RaiseError
7
+
8
+ import datetime
9
+ import typing
10
+
11
+
12
+ # //////////////////////////////////////////////////////////////////////////////
13
+ # class ConfigurationFileReader
14
+
15
+
16
+ class ConfigurationFileReader:
17
+ def ReadLine(self) -> typing.Optional[str]:
18
+ RaiseError.MethodIsNotImplemented(__class__, "ReadLine")
19
+
20
+
21
+ # //////////////////////////////////////////////////////////////////////////////
22
+ # class ConfigurationOsFile
23
+
24
+
25
+ class ConfigurationOsFile(ConfigurationFileReader):
26
+ def __init__(self):
27
+ pass
28
+
29
+ @property
30
+ def Name(self) -> str:
31
+ RaiseError.MethodIsNotImplemented(__class__, "get_Name")
32
+
33
+ @property
34
+ def IsClosed(self) -> bool:
35
+ RaiseError.MethodIsNotImplemented(__class__, "get_IsClosed")
36
+
37
+ def Overwrite(self, text: str) -> None:
38
+ assert type(text) == str # noqa: E721
39
+ RaiseError.MethodIsNotImplemented(__class__, "Write")
40
+
41
+ def Close(self):
42
+ RaiseError.MethodIsNotImplemented(__class__, "Close")
43
+
44
+ def GetModificationTS(self) -> datetime.datetime:
45
+ RaiseError.MethodIsNotImplemented(__class__, "GetModificationTS")
46
+
47
+
48
+ # //////////////////////////////////////////////////////////////////////////////
49
+ # class ConfigurationOsOps
50
+
51
+
52
+ class ConfigurationOsOps:
53
+ def Path_IsAbs(self, a: str) -> bool:
54
+ assert type(a) == str # noqa: E721
55
+ RaiseError.MethodIsNotImplemented(__class__, "Path_IsAbs")
56
+
57
+ def Path_Join(self, a: str, *p: tuple) -> str:
58
+ assert type(a) == str # noqa: E721
59
+ assert type(p) == tuple # noqa: E721
60
+ RaiseError.MethodIsNotImplemented(__class__, "Path_Join")
61
+
62
+ def Path_NormPath(self, a: str) -> str:
63
+ assert type(a) == str # noqa: E721
64
+ RaiseError.MethodIsNotImplemented(__class__, "Path_NormPath")
65
+
66
+ def Path_AbsPath(self, a: str) -> str:
67
+ assert type(a) == str # noqa: E721
68
+ RaiseError.MethodIsNotImplemented(__class__, "Path_AbsPath")
69
+
70
+ def Path_NormCase(self, a: str) -> str:
71
+ assert type(a) == str # noqa: E721
72
+ RaiseError.MethodIsNotImplemented(__class__, "Path_NormCase")
73
+
74
+ def Path_DirName(self, a: str) -> str:
75
+ assert type(a) == str # noqa: E721
76
+ RaiseError.MethodIsNotImplemented(__class__, "Path_DirName")
77
+
78
+ def Path_BaseName(self, a: str) -> str:
79
+ assert type(a) == str # noqa: E721
80
+ RaiseError.MethodIsNotImplemented(__class__, "Path_BaseName")
81
+
82
+ def Remove(self, a: str) -> str:
83
+ assert type(a) == str # noqa: E721
84
+ RaiseError.MethodIsNotImplemented(__class__, "Remove")
85
+
86
+ def OpenFileToRead(self, filePath: str) -> ConfigurationOsFile:
87
+ assert type(filePath) == str # noqa: E721
88
+ RaiseError.MethodIsNotImplemented(__class__, "OpenFileToRead")
89
+
90
+ def OpenFileToWrite(self, filePath: str) -> ConfigurationOsFile:
91
+ assert type(filePath) == str # noqa: E721
92
+ RaiseError.MethodIsNotImplemented(__class__, "OpenFileToWrite")
93
+
94
+ def CreateFile(self, filePath: str) -> ConfigurationOsFile:
95
+ assert type(filePath) == str # noqa: E721
96
+ RaiseError.MethodIsNotImplemented(__class__, "CreateFile")
97
+
98
+ # //////////////////////////////////////////////////////////////////////////////