testgres.postgres-configuration 0.2.3__py3-none-any.whl → 0.3.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.
@@ -21,7 +21,7 @@ class PostgresConfigurationObject:
21
21
  RaiseError.MethodIsNotImplemented(__class__, "get_Configuration")
22
22
 
23
23
  # --------------------------------------------------------------------
24
- def get_Parent(self) -> PostgresConfigurationObject:
24
+ def get_Parent(self) -> typing.Optional[PostgresConfigurationObject]:
25
25
  RaiseError.MethodIsNotImplemented(__class__, "get_Parent")
26
26
 
27
27
 
@@ -49,7 +49,7 @@ class PostgresConfigurationSetOptionValueResult:
49
49
 
50
50
  # interface -----------------------------------------------------------
51
51
  @property
52
- def Option(self) -> PostgresConfigurationOption:
52
+ def Option(self) -> typing.Optional[PostgresConfigurationOption]:
53
53
  RaiseError.GetPropertyIsNotImplemented(__class__, "Option")
54
54
 
55
55
  # ---------------------------------------------------------------------
@@ -80,7 +80,7 @@ class PostgresConfigurationComment(PostgresConfigurationElement):
80
80
  RaiseError.MethodIsNotImplemented(__class__, "get_Text")
81
81
 
82
82
  # --------------------------------------------------------------------
83
- def Delete(self, withLineIfLast: bool):
83
+ def Delete(self, withLineIfLast: bool) -> None:
84
84
  assert type(withLineIfLast) is bool
85
85
  RaiseError.MethodIsNotImplemented(__class__, "Delete")
86
86
 
@@ -144,7 +144,7 @@ class PostgresConfigurationOptions(typing.Iterable[PostgresConfigurationOption])
144
144
  RaiseError.MethodIsNotImplemented(__class__, "__len__")
145
145
 
146
146
  # --------------------------------------------------------------------
147
- def __iter__(self) -> PostgresConfigurationFileLinesIterator:
147
+ def __iter__(self) -> PostgresConfigurationOptionsIterator:
148
148
  RaiseError.MethodIsNotImplemented(__class__, "__iter__")
149
149
 
150
150
 
@@ -161,7 +161,7 @@ class PostgresConfigurationInclude(PostgresConfigurationElement):
161
161
  RaiseError.MethodIsNotImplemented(__class__, "get_File")
162
162
 
163
163
  # --------------------------------------------------------------------
164
- def Delete(self, withLine: bool):
164
+ def Delete(self, withLine: bool) -> None:
165
165
  assert type(withLine) is bool
166
166
  RaiseError.MethodIsNotImplemented(__class__, "Delete")
167
167
 
@@ -9,7 +9,9 @@ import typing
9
9
 
10
10
  class BugCheckError:
11
11
  @staticmethod
12
- def UnkObjectDataType(objectType: type):
12
+ def UnkObjectDataType(
13
+ objectType: type,
14
+ ) -> typing.NoReturn:
13
15
  assert objectType is not None
14
16
  assert type(objectType) is type
15
17
 
@@ -18,7 +20,10 @@ class BugCheckError:
18
20
 
19
21
  # --------------------------------------------------------------------
20
22
  @staticmethod
21
- def MultipleDefOfOptionIsFound(optName: str, count: int):
23
+ def MultipleDefOfOptionIsFound(
24
+ optName: str,
25
+ count: int,
26
+ ) -> typing.NoReturn:
22
27
  assert type(optName) is str
23
28
  assert type(count) is int
24
29
 
@@ -31,7 +36,10 @@ class BugCheckError:
31
36
 
32
37
  # --------------------------------------------------------------------
33
38
  @staticmethod
34
- def UnkOptObjectDataType(optName: str, optDataType: type):
39
+ def UnkOptObjectDataType(
40
+ optName: str,
41
+ optDataType: type,
42
+ ) -> typing.NoReturn:
35
43
  assert type(optName) is str
36
44
  assert type(optDataType) is type
37
45
 
@@ -44,7 +52,10 @@ class BugCheckError:
44
52
 
45
53
  # --------------------------------------------------------------------
46
54
  @staticmethod
47
- def MultipleDefOfFileIsFound(fileName: str, count: int):
55
+ def MultipleDefOfFileIsFound(
56
+ fileName: str,
57
+ count: int,
58
+ ) -> typing.NoReturn:
48
59
  assert type(fileName) is str
49
60
  assert type(count) is int
50
61
 
@@ -57,7 +68,10 @@ class BugCheckError:
57
68
 
58
69
  # --------------------------------------------------------------------
59
70
  @staticmethod
60
- def UnkFileObjectDataType(fileName: str, fileDataType: type):
71
+ def UnkFileObjectDataType(
72
+ fileName: str,
73
+ fileDataType: type,
74
+ ) -> typing.NoReturn:
61
75
  assert type(fileName) is str
62
76
  assert type(fileDataType) is type
63
77
 
@@ -68,7 +82,10 @@ class BugCheckError:
68
82
 
69
83
  # --------------------------------------------------------------------
70
84
  @staticmethod
71
- def UnkFileDataStatus(filePath: str, fileStatus: typing.Any):
85
+ def UnkFileDataStatus(
86
+ filePath: str,
87
+ fileStatus: typing.Any,
88
+ ) -> typing.NoReturn:
72
89
  assert type(filePath) is str
73
90
  assert fileStatus is not None
74
91
 
@@ -79,7 +96,10 @@ class BugCheckError:
79
96
 
80
97
  # --------------------------------------------------------------------
81
98
  @staticmethod
82
- def FileIsNotFoundInIndex(fileKey: str, filePath: str):
99
+ def FileIsNotFoundInIndex(
100
+ fileKey: str,
101
+ filePath: str,
102
+ ) -> typing.NoReturn:
83
103
  assert type(fileKey) is str
84
104
  assert type(filePath) is str
85
105
 
@@ -90,7 +110,9 @@ class BugCheckError:
90
110
 
91
111
  # --------------------------------------------------------------------
92
112
  @staticmethod
93
- def OptionIsNotFoundInIndex(optName: str):
113
+ def OptionIsNotFoundInIndex(
114
+ optName: str,
115
+ ) -> typing.NoReturn:
94
116
  assert type(optName) is str
95
117
 
96
118
  errMsg = "[BUG CHECK] Option [{0}] is not found in index.".format(optName)
@@ -98,7 +120,9 @@ class BugCheckError:
98
120
 
99
121
  # --------------------------------------------------------------------
100
122
  @staticmethod
101
- def OptionIsNotFoundInFileLine(optName: str):
123
+ def OptionIsNotFoundInFileLine(
124
+ optName: str,
125
+ ) -> typing.NoReturn:
102
126
  assert type(optName) is str
103
127
 
104
128
  errMsg = "[BUG CHECK] Option [{0}] is not found in file line.".format(optName)
@@ -106,25 +130,27 @@ class BugCheckError:
106
130
 
107
131
  # --------------------------------------------------------------------
108
132
  @staticmethod
109
- def CommentIsNotFoundInFileLine():
133
+ def CommentIsNotFoundInFileLine() -> typing.NoReturn:
110
134
  errMsg = "[BUG CHECK] Comment is not found in file line."
111
135
  raise Exception(errMsg)
112
136
 
113
137
  # --------------------------------------------------------------------
114
138
  @staticmethod
115
- def IncludeIsNotFoundInFileLine():
139
+ def IncludeIsNotFoundInFileLine() -> typing.NoReturn:
116
140
  errMsg = "[BUG CHECK] Include is not found in file line."
117
141
  raise Exception(errMsg)
118
142
 
119
143
  # --------------------------------------------------------------------
120
144
  @staticmethod
121
- def FileLineIsNotFoundInFile():
145
+ def FileLineIsNotFoundInFile() -> typing.NoReturn:
122
146
  errMsg = "[BUG CHECK] FileLine is not found in file."
123
147
  raise Exception(errMsg)
124
148
 
125
149
  # --------------------------------------------------------------------
126
150
  @staticmethod
127
- def OptionHandlerToPrepareSetValueIsNotDefined(name: str):
151
+ def OptionHandlerToPrepareSetValueIsNotDefined(
152
+ name: str,
153
+ ) -> typing.NoReturn:
128
154
  assert type(name) is str
129
155
 
130
156
  errMsg = "[BUG CHECK] OptionHandlerToPrepareSetValue for [{0}] is not defined.".format(
@@ -134,7 +160,9 @@ class BugCheckError:
134
160
 
135
161
  # --------------------------------------------------------------------
136
162
  @staticmethod
137
- def OptionHandlerToPrepareGetValueIsNotDefined(name: str):
163
+ def OptionHandlerToPrepareGetValueIsNotDefined(
164
+ name: str,
165
+ ) -> typing.NoReturn:
138
166
  assert type(name) is str
139
167
 
140
168
  errMsg = "[BUG CHECK] OptionHandlerToPrepareGetValue for [{0}] is not defined.".format(
@@ -144,7 +172,9 @@ class BugCheckError:
144
172
 
145
173
  # --------------------------------------------------------------------
146
174
  @staticmethod
147
- def OptionHandlerToPrepareSetValueItemIsNotDefined(name: str):
175
+ def OptionHandlerToPrepareSetValueItemIsNotDefined(
176
+ name: str,
177
+ ) -> typing.NoReturn:
148
178
  assert type(name) is str
149
179
 
150
180
  errMsg = "[BUG CHECK] OptionHandlerToPrepareSetValueItem for [{0}] is not defined.".format(
@@ -154,7 +184,9 @@ class BugCheckError:
154
184
 
155
185
  # --------------------------------------------------------------------
156
186
  @staticmethod
157
- def OptionHandlerToSetValueIsNotDefined(name: str):
187
+ def OptionHandlerToSetValueIsNotDefined(
188
+ name: str,
189
+ ) -> typing.NoReturn:
158
190
  assert type(name) is str
159
191
 
160
192
  errMsg = "[BUG CHECK] OptionHandlerToSetValue for [{0}] is not defined.".format(
@@ -164,7 +196,9 @@ class BugCheckError:
164
196
 
165
197
  # --------------------------------------------------------------------
166
198
  @staticmethod
167
- def OptionHandlerToGetValueIsNotDefined(name: str):
199
+ def OptionHandlerToGetValueIsNotDefined(
200
+ name: str,
201
+ ) -> typing.NoReturn:
168
202
  assert type(name) is str
169
203
 
170
204
  errMsg = "[BUG CHECK] OptionHandlerToGetValue for [{0}] is not defined.".format(
@@ -174,7 +208,9 @@ class BugCheckError:
174
208
 
175
209
  # --------------------------------------------------------------------
176
210
  @staticmethod
177
- def OptionHandlerToAddOptionIsNotDefined(name: str):
211
+ def OptionHandlerToAddOptionIsNotDefined(
212
+ name: str,
213
+ ) -> typing.NoReturn:
178
214
  assert type(name) is str
179
215
 
180
216
  errMsg = (
@@ -186,7 +222,9 @@ class BugCheckError:
186
222
 
187
223
  # --------------------------------------------------------------------
188
224
  @staticmethod
189
- def OptionHandlerToSetValueItemIsNotDefined(name: str):
225
+ def OptionHandlerToSetValueItemIsNotDefined(
226
+ name: str,
227
+ ) -> typing.NoReturn:
190
228
  assert type(name) is str
191
229
 
192
230
  errMsg = (
@@ -198,7 +236,9 @@ class BugCheckError:
198
236
 
199
237
  # --------------------------------------------------------------------
200
238
  @staticmethod
201
- def OptionHandlerToWriteIsNotDefined(name: str):
239
+ def OptionHandlerToWriteIsNotDefined(
240
+ name: str,
241
+ ) -> typing.NoReturn:
202
242
  assert type(name) is str
203
243
 
204
244
  errMsg = "[BUG CHECK] OptionHandlerToWrite for [{0}] is not defined.".format(
@@ -208,7 +248,11 @@ class BugCheckError:
208
248
 
209
249
  # --------------------------------------------------------------------
210
250
  @staticmethod
211
- def UnexpectedSituation(bugcheckSrc: str, bugcheckPoint: str, explain: str):
251
+ def UnexpectedSituation(
252
+ bugcheckSrc: str,
253
+ bugcheckPoint: str,
254
+ explain: str,
255
+ ) -> typing.NoReturn:
212
256
  assert type(bugcheckSrc) is str
213
257
  assert type(bugcheckPoint) is str
214
258
  assert explain is None or type(explain) is str
@@ -227,7 +271,10 @@ class BugCheckError:
227
271
 
228
272
  # --------------------------------------------------------------------
229
273
  @staticmethod
230
- def UnknownOptionValueType(optionName: str, typeOfOptionValue: type):
274
+ def UnknownOptionValueType(
275
+ optionName: str,
276
+ typeOfOptionValue: type,
277
+ ) -> typing.NoReturn:
231
278
  assert type(optionName) is str
232
279
  assert optionName != ""
233
280
  assert type(typeOfOptionValue) is type
@@ -266,8 +266,8 @@ class OptionHandlerToAddOption(OptionHandler):
266
266
  super().__init__()
267
267
 
268
268
  # interface ----------------------------------------------------------
269
- def AddOption(self, ctx: OptionHandlerCtxToSetValue) -> typing.Any:
270
- assert type(ctx) is OptionHandlerCtxToSetValue
269
+ def AddOption(self, ctx: OptionHandlerCtxToAddOption) -> typing.Any:
270
+ assert type(ctx) is OptionHandlerCtxToAddOption
271
271
  RaiseError.MethodIsNotImplemented(__class__, "AddOption")
272
272
 
273
273
 
@@ -12,41 +12,40 @@ import typing
12
12
 
13
13
 
14
14
  class Helpers:
15
+ @staticmethod
15
16
  def ExtractOptionDataName(option: typing.Union[str, OptionData]) -> str:
16
17
  assert type(option) is str or type(option) is OptionData
17
18
 
18
- typeOption = type(option)
19
-
20
- if typeOption is str:
19
+ if type(option) is str:
21
20
  return option
22
21
 
23
- if typeOption is OptionData:
22
+ if type(option) is OptionData:
24
23
  return option.m_Name
25
24
 
26
- BugCheckError.UnkObjectDataType(typeOption)
25
+ BugCheckError.UnkObjectDataType(type(option))
27
26
 
28
27
  # --------------------------------------------------------------------
28
+ @staticmethod
29
29
  def ExtractFirstOptionFromIndexItem(
30
30
  optionName: str, indexItem: typing.Union[OptionData, typing.List[OptionData]]
31
31
  ) -> OptionData:
32
32
  assert type(optionName) is str
33
33
 
34
- typeOfIndexItem = type(indexItem)
35
-
36
- if typeOfIndexItem is OptionData:
34
+ if type(indexItem) is OptionData:
37
35
  assert indexItem.m_Name == optionName
38
36
  return indexItem
39
37
 
40
- if typeOfIndexItem is list:
38
+ if type(indexItem) is list:
41
39
  assert len(indexItem) > 1
42
40
  assert indexItem[0] is not None
43
41
  assert type(indexItem[0]) is OptionData
44
42
  assert indexItem[0].m_Name == optionName
45
43
  return indexItem[0]
46
44
 
47
- BugCheckError.UnkOptObjectDataType(optionName, typeOfIndexItem)
45
+ BugCheckError.UnkOptObjectDataType(optionName, type(indexItem))
48
46
 
49
47
  # --------------------------------------------------------------------
48
+ @staticmethod
50
49
  def DoesContainerContainsValue__NotNullAndExact(
51
50
  container: typing.Iterable, value: typing.Any
52
51
  ) -> bool:
@@ -64,6 +63,7 @@ class Helpers:
64
63
  return False
65
64
 
66
65
  # --------------------------------------------------------------------
66
+ @staticmethod
67
67
  def NormalizeFilePath(
68
68
  cfgOsOps: ConfigurationOsOps, baseFolder: str, filePath: str
69
69
  ) -> str:
@@ -195,8 +195,8 @@ class FileLineData(ObjectData):
195
195
 
196
196
 
197
197
  class FileStatus(enum.Enum):
198
- IS_NEW: int = 0
199
- EXISTS: int = 1
198
+ IS_NEW = 0
199
+ EXISTS = 1
200
200
 
201
201
 
202
202
  # //////////////////////////////////////////////////////////////////////////////
@@ -204,6 +204,8 @@ class FileStatus(enum.Enum):
204
204
 
205
205
 
206
206
  class FileData(ObjectData):
207
+ T_OPTIONS_BY_NAME = typing.Dict[str, OptionData]
208
+
207
209
  m_Parent: ConfigurationData
208
210
 
209
211
  m_Status: FileStatus
@@ -212,7 +214,7 @@ class FileData(ObjectData):
212
214
  m_Path: str
213
215
  m_Lines: typing.List[FileLineData]
214
216
 
215
- m_OptionsByName: typing.Dict[str, OptionData]
217
+ m_OptionsByName: T_OPTIONS_BY_NAME
216
218
 
217
219
  # --------------------------------------------------------------------
218
220
  def __init__(self, parent: ConfigurationData, path: str):
@@ -256,15 +258,33 @@ class FileData(ObjectData):
256
258
 
257
259
 
258
260
  class ConfigurationData(ObjectData):
261
+ T_OPTION_OR_OPTIONS = typing.Union[
262
+ OptionData,
263
+ typing.List[OptionData],
264
+ ]
265
+
266
+ T_ALL_OPTIONS_BY_NAME = typing.Dict[
267
+ str,
268
+ T_OPTION_OR_OPTIONS,
269
+ ]
270
+
271
+ T_FILE_OR_FILES = typing.Union[
272
+ FileData,
273
+ typing.List[FileData],
274
+ ]
275
+
276
+ T_ALL_FILES_BY_NAME = typing.Dict[
277
+ str,
278
+ T_FILE_OR_FILES,
279
+ ]
280
+
259
281
  m_DataDir: str
260
282
  m_OsOps: ConfigurationOsOps
261
283
 
262
284
  m_Files: typing.List[FileData]
263
285
 
264
- m_AllOptionsByName: typing.Dict[
265
- str, typing.Union[OptionData, typing.List[OptionData]]
266
- ]
267
- m_AllFilesByName: typing.Dict[str, typing.Union[FileData, typing.List[FileData]]]
286
+ m_AllOptionsByName: T_ALL_OPTIONS_BY_NAME
287
+ m_AllFilesByName: T_ALL_FILES_BY_NAME
268
288
 
269
289
  # --------------------------------------------------------------------
270
290
  def __init__(self, data_dir: str, osOps: ConfigurationOsOps):