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,60 @@
1
+ # //////////////////////////////////////////////////////////////////////////////
2
+ # Postgres Pro. PostgreSQL Configuration Python Library.
3
+
4
+ from .raise_error import RaiseError
5
+
6
+ # //////////////////////////////////////////////////////////////////////////////
7
+ # class DataVerificator
8
+
9
+
10
+ class DataVerificator:
11
+ def CheckOptionName(name: str):
12
+ if name is None:
13
+ RaiseError.OptionNameIsNone()
14
+
15
+ if type(name) != str:
16
+ RaiseError.OptionNameHasBadType(type(name))
17
+
18
+ if name == "":
19
+ RaiseError.OptionNameIsEmpty()
20
+
21
+ # TODO: Add an extended verification of an option name
22
+
23
+ # --------------------------------------------------------------------
24
+ sm_InvalidCommentSymbols: str = "\n\r\0"
25
+
26
+ # --------------------------------------------------------------------
27
+ def IsValidCommentText(text: str) -> bool:
28
+ assert text is not None
29
+ assert type(text) == str
30
+
31
+ assert type(__class__.sm_InvalidCommentSymbols) == str
32
+
33
+ for ch in text:
34
+ if ch in __class__.sm_InvalidCommentSymbols:
35
+ return False
36
+
37
+ return True
38
+
39
+ # --------------------------------------------------------------------
40
+ def CheckCommentText(text: str):
41
+ assert text is not None
42
+ assert type(text) == str
43
+
44
+ assert type(__class__.sm_InvalidCommentSymbols) == str
45
+
46
+ if not __class__.IsValidCommentText(text):
47
+ RaiseError.CommentTextContainsInvalidSymbols()
48
+
49
+ # OK
50
+
51
+ # --------------------------------------------------------------------
52
+ def CheckStringOfFilePath(text: str):
53
+ assert text is not None
54
+ assert type(text) == str
55
+
56
+ if text == "":
57
+ RaiseError.FilePathIsEmpty()
58
+
59
+
60
+ # //////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,483 @@
1
+ # //////////////////////////////////////////////////////////////////////////////
2
+ # Postgres Pro. PostgreSQL Configuration Python Library.
3
+
4
+ from __future__ import annotations
5
+
6
+ from .model import FileLineData
7
+ from .model import FileData
8
+ from .model import OptionData
9
+ from .raise_error import RaiseError
10
+
11
+ import typing
12
+
13
+ # //////////////////////////////////////////////////////////////////////////////
14
+ # ConfigurationDataHandler
15
+
16
+
17
+ class ConfigurationDataHandler:
18
+ def __init__(self):
19
+ pass
20
+
21
+ # interface ----------------------------------------------------------
22
+ def DataHandler__SetOptionValue__Simple(
23
+ self,
24
+ targetData: typing.Union[None, FileData, OptionData],
25
+ optionName: str,
26
+ optionValue: any,
27
+ ) -> any:
28
+ assert (
29
+ targetData is None
30
+ or type(targetData) == FileData
31
+ or type(targetData) == FileLineData
32
+ )
33
+ assert type(optionName) == str
34
+ assert optionValue is not None
35
+ RaiseError.MethodIsNotImplemented(
36
+ __class__, "DataHandler__SetOptionValue__Simple"
37
+ )
38
+
39
+ # --------------------------------------------------------------------
40
+ def DataHandler__GetOptionValue__Simple(
41
+ self,
42
+ sourceData: typing.Union[None, FileData, OptionData],
43
+ optionName: str,
44
+ ) -> any:
45
+ assert (
46
+ sourceData is None
47
+ or type(sourceData) == FileData
48
+ or type(sourceData) == OptionData
49
+ )
50
+ assert type(optionName) == str or type(optionName) == OptionData
51
+ RaiseError.MethodIsNotImplemented(
52
+ __class__, "DataHandler__GetOptionValue__Simple"
53
+ )
54
+
55
+ # --------------------------------------------------------------------
56
+ def DataHandler__GetOptionValue__UnionList(
57
+ self,
58
+ sourceData: typing.Union[None, FileLineData, OptionData],
59
+ optionName: str,
60
+ ) -> any:
61
+ assert (
62
+ sourceData is None
63
+ or type(sourceData) == FileData
64
+ or type(sourceData) == OptionData
65
+ )
66
+ assert type(optionName) == str
67
+ RaiseError.MethodIsNotImplemented(
68
+ __class__, "DataHandler__GetOptionValue__UnionList"
69
+ )
70
+
71
+ # --------------------------------------------------------------------
72
+ def DataHandler__ResetOption(
73
+ self,
74
+ targetData: typing.Union[None, FileData, OptionData],
75
+ optionName: str,
76
+ ) -> any:
77
+ assert (
78
+ targetData is None
79
+ or type(targetData) == FileData
80
+ or type(targetData) == OptionData
81
+ )
82
+ assert type(optionName) == str
83
+ RaiseError.MethodIsNotImplemented(__class__, "DataHandler__ResetOption")
84
+
85
+ # --------------------------------------------------------------------
86
+ def DataHandler__AddSimpleOption(
87
+ self,
88
+ target: typing.Union[None, FileData, FileLineData],
89
+ optionOffset: typing.Optional[int],
90
+ optionName: str,
91
+ optionValue: any,
92
+ ) -> any:
93
+ assert (
94
+ target is None or type(target) == FileData or type(target) == FileLineData
95
+ )
96
+ assert optionOffset is None or type(optionOffset) == int
97
+ assert type(optionName) == str
98
+ assert optionValue is not None
99
+ RaiseError.MethodIsNotImplemented(__class__, "DataHandler__AddSimpleOption")
100
+
101
+ # --------------------------------------------------------------------
102
+ def DataHandler__SetUniqueOptionValueItem(
103
+ self,
104
+ targetData: typing.Union[None, FileData, OptionData],
105
+ optionName: str,
106
+ optionValueItem: any,
107
+ ) -> any:
108
+ assert (
109
+ targetData is None
110
+ or type(targetData) == FileData
111
+ or type(optionName) == OptionData
112
+ )
113
+ assert type(optionName) == str
114
+ assert optionValueItem is not None
115
+ RaiseError.MethodIsNotImplemented(
116
+ __class__, "DataHandler__SetUniqueOptionValueItem"
117
+ )
118
+
119
+
120
+ # //////////////////////////////////////////////////////////////////////////////
121
+ # OptionHandler
122
+
123
+
124
+ class OptionHandler:
125
+ def __init__(self):
126
+ pass
127
+
128
+
129
+ # //////////////////////////////////////////////////////////////////////////////
130
+ # OptionHandlerCtxToSetValue
131
+
132
+
133
+ class OptionHandlerCtxToSetValue:
134
+ DataHandler: ConfigurationDataHandler
135
+ TargetData: typing.Union[None, FileData, OptionData]
136
+ OptionName: str
137
+ OptionValue: any
138
+
139
+ # --------------------------------------------------------------------
140
+ def __init__(
141
+ self,
142
+ dataHandler: ConfigurationDataHandler,
143
+ targetData: typing.Union[None, FileData, OptionData],
144
+ optionName: str,
145
+ optionValue: any,
146
+ ):
147
+ assert isinstance(dataHandler, ConfigurationDataHandler)
148
+ assert (
149
+ targetData is None
150
+ or type(targetData) == FileData
151
+ or type(targetData) == OptionData
152
+ )
153
+ assert type(optionName) == str
154
+
155
+ self.DataHandler = dataHandler
156
+ self.TargetData = targetData
157
+ self.OptionName = optionName
158
+ self.OptionValue = optionValue
159
+
160
+
161
+ # //////////////////////////////////////////////////////////////////////////////
162
+ # OptionHandlerToSetValue
163
+
164
+
165
+ class OptionHandlerToSetValue(OptionHandler):
166
+ def __init__(self):
167
+ super().__init__()
168
+
169
+ # interface ----------------------------------------------------------
170
+ def SetOptionValue(self, ctx: OptionHandlerCtxToSetValue) -> any:
171
+ assert type(ctx) == OptionHandlerCtxToSetValue
172
+ assert ctx.OptionName is not None
173
+ assert ctx.OptionValue is not None
174
+ RaiseError.MethodIsNotImplemented(__class__, "SetOptionValue")
175
+
176
+
177
+ # //////////////////////////////////////////////////////////////////////////////
178
+ # OptionHandlerCtxToGetValue
179
+
180
+
181
+ class OptionHandlerCtxToGetValue:
182
+ DataHandler: ConfigurationDataHandler
183
+ SourceData: typing.Union[None, FileData, OptionData]
184
+ OptionName: str
185
+
186
+ # --------------------------------------------------------------------
187
+ def __init__(
188
+ self,
189
+ dataHandler: ConfigurationDataHandler,
190
+ sourceData: typing.Union[None, FileData, OptionData],
191
+ optionName: str,
192
+ ):
193
+ assert isinstance(dataHandler, ConfigurationDataHandler)
194
+ assert (
195
+ sourceData is None
196
+ or type(sourceData) == FileData
197
+ or type(sourceData) == OptionData
198
+ )
199
+ assert type(optionName) == str
200
+
201
+ self.DataHandler = dataHandler
202
+ self.SourceData = sourceData
203
+ self.OptionName = optionName
204
+
205
+
206
+ # //////////////////////////////////////////////////////////////////////////////
207
+ # OptionHandlerToGetValue
208
+
209
+
210
+ class OptionHandlerToGetValue(OptionHandler):
211
+ def __init__(self):
212
+ super().__init__()
213
+
214
+ # interface ----------------------------------------------------------
215
+ def GetOptionValue(self, ctx: OptionHandlerCtxToGetValue) -> any:
216
+ assert type(ctx) == OptionHandlerCtxToGetValue
217
+ assert (
218
+ ctx.SourceData is None
219
+ or type(ctx.SourceData) == FileData
220
+ or type(ctx.SourceData) == OptionData
221
+ )
222
+ assert type(ctx.OptionName) == str
223
+ RaiseError.MethodIsNotImplemented(__class__, "GetOptionValue")
224
+
225
+
226
+ # //////////////////////////////////////////////////////////////////////////////
227
+ # OptionHandlerCtxToAddOption
228
+
229
+
230
+ class OptionHandlerCtxToAddOption:
231
+ DataHandler: ConfigurationDataHandler
232
+ Target: typing.Union[None, FileData, FileLineData]
233
+ OptionOffset: typing.Optional[int]
234
+ OptionName: str
235
+ OptionValue: any
236
+
237
+ # --------------------------------------------------------------------
238
+ def __init__(
239
+ self,
240
+ dataHandler: ConfigurationDataHandler,
241
+ target: typing.Union[None, FileData, FileLineData],
242
+ optionOffset: typing.Optional[int],
243
+ optionName: str,
244
+ optionValue: any,
245
+ ):
246
+ assert isinstance(dataHandler, ConfigurationDataHandler)
247
+ assert (
248
+ target is None or type(target) == FileData or type(target) == FileLineData
249
+ )
250
+ assert type(optionName) == str
251
+ assert optionValue is not None
252
+
253
+ self.DataHandler = dataHandler
254
+ self.Target = target
255
+ self.OptionOffset = optionOffset
256
+ self.OptionName = optionName
257
+ self.OptionValue = optionValue
258
+
259
+
260
+ # //////////////////////////////////////////////////////////////////////////////
261
+ # OptionHandlerToAddOption
262
+
263
+
264
+ class OptionHandlerToAddOption(OptionHandler):
265
+ def __init__(self):
266
+ super().__init__()
267
+
268
+ # interface ----------------------------------------------------------
269
+ def AddOption(self, ctx: OptionHandlerCtxToSetValue) -> any:
270
+ assert type(ctx) == OptionHandlerCtxToSetValue
271
+ RaiseError.MethodIsNotImplemented(__class__, "AddOption")
272
+
273
+
274
+ # //////////////////////////////////////////////////////////////////////////////
275
+ # OptionHandlerCtxToSetValueItem
276
+
277
+
278
+ class OptionHandlerCtxToSetValueItem:
279
+ DataHandler: ConfigurationDataHandler
280
+ TargetData: typing.Union[None, FileData, OptionData]
281
+ OptionName: str
282
+ OptionValueItem: any
283
+
284
+ # --------------------------------------------------------------------
285
+ def __init__(
286
+ self,
287
+ dataHandler: ConfigurationDataHandler,
288
+ targetData: typing.Union[None, FileData, OptionData],
289
+ optionName: str,
290
+ optionValueItem: any,
291
+ ):
292
+ assert isinstance(dataHandler, ConfigurationDataHandler)
293
+ assert (
294
+ targetData is None
295
+ or type(targetData) == FileData
296
+ or type(targetData) == OptionData
297
+ )
298
+ assert type(optionName) == str
299
+
300
+ self.DataHandler = dataHandler
301
+ self.TargetData = targetData
302
+ self.OptionName = optionName
303
+ self.OptionValueItem = optionValueItem
304
+
305
+
306
+ # //////////////////////////////////////////////////////////////////////////////
307
+ # OptionHandlerToSetValueItem
308
+
309
+
310
+ class OptionHandlerToSetValueItem(OptionHandler):
311
+ def __init__(self):
312
+ super().__init__()
313
+
314
+ # interface ----------------------------------------------------------
315
+ def SetOptionValueItem(self, ctx: OptionHandlerCtxToSetValueItem) -> any:
316
+ assert type(ctx) == OptionHandlerCtxToSetValueItem
317
+ assert (
318
+ ctx.TargetData is None
319
+ or type(ctx.TargetData) == FileData
320
+ or type(ctx.TargetData) == OptionData
321
+ )
322
+ assert type(ctx.OptionName) == str
323
+ assert ctx.OptionValueItem is not None
324
+ RaiseError.MethodIsNotImplemented(__class__, "SetOptionValueItem")
325
+
326
+
327
+ # //////////////////////////////////////////////////////////////////////////////
328
+ # OptionHandlerCtxToPrepareSetValue
329
+
330
+
331
+ class OptionHandlerCtxToPrepareSetValue:
332
+ DataHandler: ConfigurationDataHandler
333
+ OptionName: str
334
+ OptionValue: any
335
+
336
+ # --------------------------------------------------------------------
337
+ def __init__(
338
+ self,
339
+ dataHandler: ConfigurationDataHandler,
340
+ optionName: str,
341
+ optionValue: any,
342
+ ):
343
+ assert isinstance(dataHandler, ConfigurationDataHandler)
344
+ assert type(optionName) == str
345
+ assert optionValue is not None
346
+
347
+ self.DataHandler = dataHandler
348
+ self.OptionName = optionName
349
+ self.OptionValue = optionValue
350
+
351
+
352
+ # //////////////////////////////////////////////////////////////////////////////
353
+ # OptionHandlerToPrepareSetValue
354
+
355
+
356
+ class OptionHandlerToPrepareSetValue(OptionHandler):
357
+ def __init__(self):
358
+ super().__init__()
359
+
360
+ # interface ----------------------------------------------------------
361
+ def PrepareSetValue(self, ctx: OptionHandlerCtxToPrepareSetValue) -> str:
362
+ assert type(ctx) == OptionHandlerCtxToPrepareSetValue
363
+ RaiseError.MethodIsNotImplemented(__class__, "PrepareSetValue")
364
+
365
+
366
+ # //////////////////////////////////////////////////////////////////////////////
367
+ # OptionHandlerCtxToPrepareSetValueItem
368
+
369
+
370
+ class OptionHandlerCtxToPrepareSetValueItem:
371
+ DataHandler: ConfigurationDataHandler
372
+ OptionName: str
373
+ OptionValueItem: any
374
+
375
+ # --------------------------------------------------------------------
376
+ def __init__(
377
+ self,
378
+ dataHandler: ConfigurationDataHandler,
379
+ optionName: str,
380
+ optionValueItem: any,
381
+ ):
382
+ assert isinstance(dataHandler, ConfigurationDataHandler)
383
+ assert type(optionName) == str
384
+ assert optionValueItem is not None
385
+
386
+ self.DataHandler = dataHandler
387
+ self.OptionName = optionName
388
+ self.OptionValueItem = optionValueItem
389
+
390
+
391
+ # //////////////////////////////////////////////////////////////////////////////
392
+ # OptionHandlerToPrepareSetValueItem
393
+
394
+
395
+ class OptionHandlerToPrepareSetValueItem(OptionHandler):
396
+ def __init__(self):
397
+ super().__init__()
398
+
399
+ # interface ----------------------------------------------------------
400
+ def PrepareSetValueItem(self, ctx: OptionHandlerCtxToPrepareSetValueItem) -> str:
401
+ assert type(ctx) == OptionHandlerCtxToPrepareSetValueItem
402
+ RaiseError.MethodIsNotImplemented(__class__, "PrepareSetValueItem")
403
+
404
+
405
+ # //////////////////////////////////////////////////////////////////////////////
406
+ # OptionHandlerCtxToPrepareGetValue
407
+
408
+
409
+ class OptionHandlerCtxToPrepareGetValue:
410
+ DataHandler: ConfigurationDataHandler
411
+ OptionName: str
412
+ OptionValue: any
413
+
414
+ # --------------------------------------------------------------------
415
+ def __init__(
416
+ self,
417
+ dataHandler: ConfigurationDataHandler,
418
+ optionName: str,
419
+ optionValue: any,
420
+ ):
421
+ assert isinstance(dataHandler, ConfigurationDataHandler)
422
+ assert type(optionName) == str
423
+ assert optionValue is not None
424
+
425
+ self.DataHandler = dataHandler
426
+ self.OptionName = optionName
427
+ self.OptionValue = optionValue
428
+
429
+
430
+ # //////////////////////////////////////////////////////////////////////////////
431
+ # OptionHandlerToPrepareGetValue
432
+
433
+
434
+ class OptionHandlerToPrepareGetValue(OptionHandler):
435
+ def __init__(self):
436
+ super().__init__()
437
+
438
+ # interface ----------------------------------------------------------
439
+ def PrepareGetValue(self, ctx: OptionHandlerCtxToPrepareGetValue) -> str:
440
+ assert type(ctx) == OptionHandlerCtxToPrepareGetValue
441
+ RaiseError.MethodIsNotImplemented(__class__, "PrepareGetValue")
442
+
443
+
444
+ # //////////////////////////////////////////////////////////////////////////////
445
+ # OptionHandlerCtxToWrite
446
+
447
+
448
+ class OptionHandlerCtxToWrite:
449
+ DataHandler: ConfigurationDataHandler
450
+ OptionName: str
451
+ OptionValue: any
452
+
453
+ # --------------------------------------------------------------------
454
+ def __init__(
455
+ self,
456
+ dataHandler: ConfigurationDataHandler,
457
+ optionName: str,
458
+ optionValue: any,
459
+ ):
460
+ assert isinstance(dataHandler, ConfigurationDataHandler)
461
+ assert type(optionName) == str
462
+ assert optionValue is not None
463
+
464
+ self.DataHandler = dataHandler
465
+ self.OptionName = optionName
466
+ self.OptionValue = optionValue
467
+
468
+
469
+ # //////////////////////////////////////////////////////////////////////////////
470
+ # OptionHandlerToWrite
471
+
472
+
473
+ class OptionHandlerToWrite(OptionHandler):
474
+ def __init__(self):
475
+ super().__init__()
476
+
477
+ # interface ----------------------------------------------------------
478
+ def OptionValueToString(self, ctx: OptionHandlerCtxToWrite) -> str:
479
+ assert type(ctx) == OptionHandlerCtxToWrite
480
+ RaiseError.MethodIsNotImplemented(__class__, "OptionValueToString")
481
+
482
+
483
+ # //////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,95 @@
1
+ # //////////////////////////////////////////////////////////////////////////////
2
+ # Postgres Pro. PostgreSQL Configuration Python Library.
3
+
4
+ from .model import OptionData
5
+ from .bugcheck_error import BugCheckError
6
+
7
+ from ..os.abstract.configuration_os_ops import ConfigurationOsOps
8
+
9
+ import typing
10
+
11
+ # //////////////////////////////////////////////////////////////////////////////
12
+
13
+
14
+ class Helpers:
15
+ def ExtractOptionDataName(option: typing.Union[str, OptionData]) -> str:
16
+ assert type(option) == str or type(option) == OptionData
17
+
18
+ typeOption = type(option)
19
+
20
+ if typeOption == str:
21
+ return option
22
+
23
+ if typeOption == OptionData:
24
+ return option.m_Name
25
+
26
+ BugCheckError.UnkObjectDataType(typeOption)
27
+
28
+ # --------------------------------------------------------------------
29
+ def ExtractFirstOptionFromIndexItem(
30
+ optionName: str, indexItem: typing.Union[OptionData, typing.List[OptionData]]
31
+ ) -> OptionData:
32
+ assert type(optionName) == str
33
+
34
+ typeOfIndexItem = type(indexItem)
35
+
36
+ if typeOfIndexItem == OptionData:
37
+ assert indexItem.m_Name == optionName
38
+ return indexItem
39
+
40
+ if typeOfIndexItem == list:
41
+ assert len(indexItem) > 1
42
+ assert indexItem[0] is not None
43
+ assert type(indexItem[0]) == OptionData
44
+ assert indexItem[0].m_Name == optionName
45
+ return indexItem[0]
46
+
47
+ BugCheckError.UnkOptObjectDataType(optionName, typeOfIndexItem)
48
+
49
+ # --------------------------------------------------------------------
50
+ def DoesContainerContainsValue__NotNullAndExact(
51
+ container: typing.Iterable, value: any
52
+ ) -> bool:
53
+ assert container is not None
54
+ assert isinstance(container, typing.Iterable)
55
+ assert value is not None
56
+
57
+ for x in container:
58
+ assert x is not None
59
+ assert type(x) == type(value)
60
+
61
+ if x == value:
62
+ return True
63
+
64
+ return False
65
+
66
+ # --------------------------------------------------------------------
67
+ def NormalizeFilePath(
68
+ cfgOsOps: ConfigurationOsOps,
69
+ baseFolder: str,
70
+ filePath: str
71
+ ) -> str:
72
+ assert cfgOsOps is not None
73
+ assert isinstance(cfgOsOps, ConfigurationOsOps)
74
+ assert type(baseFolder) == str
75
+ assert type(filePath) == str
76
+ assert filePath != ""
77
+
78
+ newFilePath = None
79
+
80
+ if cfgOsOps.Path_IsAbs(filePath):
81
+ newFilePath = cfgOsOps.Path_NormPath(filePath)
82
+ else:
83
+ newFilePath = cfgOsOps.Path_Join(baseFolder, filePath)
84
+ newFilePath = cfgOsOps.Path_NormPath(newFilePath)
85
+
86
+ assert type(newFilePath) == str
87
+ assert newFilePath != ""
88
+
89
+ newFilePath = cfgOsOps.Path_AbsPath(newFilePath)
90
+ newFilePath = cfgOsOps.Path_NormCase(newFilePath)
91
+
92
+ return newFilePath
93
+
94
+
95
+ # //////////////////////////////////////////////////////////////////////////////