Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit487f273

Browse files
author
d.kovalenko
committed
Merge branch 'D20250413_001--bool_options'
2 parentsf2538f5 +7824f79 commit487f273

12 files changed

+996
-2
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# //////////////////////////////////////////////////////////////////////////////
2+
# Postgres Pro. PostgreSQL Configuration Python Library.
3+
4+
from __future__importannotations
5+
6+
from ....handlersimportOptionHandlerToPrepareGetValue
7+
from ....handlersimportOptionHandlerCtxToPrepareGetValue
8+
from ....handlersimportConfigurationDataHandler
9+
10+
# //////////////////////////////////////////////////////////////////////////////
11+
# OptionHandlerToPrepareGetValue__Std__Bool
12+
13+
14+
classOptionHandlerToPrepareGetValue__Std__Bool(OptionHandlerToPrepareGetValue):
15+
def__init__(self):
16+
super().__init__()
17+
18+
# interface ----------------------------------------------------------
19+
defPrepareGetValue(self,ctx:OptionHandlerCtxToPrepareGetValue)->any:
20+
asserttype(ctx)==OptionHandlerCtxToPrepareGetValue
21+
assertisinstance(ctx.DataHandler,ConfigurationDataHandler)
22+
asserttype(ctx.OptionName)==str
23+
assertctx.OptionValueisnotNone
24+
25+
# [2025-04-13] Research
26+
asserttype(ctx.OptionValue)==bool
27+
28+
returnbool(ctx.OptionValue)
29+
30+
31+
# //////////////////////////////////////////////////////////////////////////////

‎src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__generic.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def PrepareGetValue(self, ctx: OptionHandlerCtxToPrepareGetValue) -> any:
3030
pass# OK
3131
eliftypeOfOptionValue==str:
3232
pass# OK
33+
eliftypeOfOptionValue==bool:
34+
pass# OK
3335
else:
3436
BugCheckError.UnknownOptionValueType(ctx.OptionName,typeOfOptionValue)
3537

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# //////////////////////////////////////////////////////////////////////////////
2+
# Postgres Pro. PostgreSQL Configuration Python Library.
3+
4+
from __future__importannotations
5+
6+
from ....raise_errorimportRaiseError
7+
8+
from ....handlersimportOptionHandlerToPrepareSetValue
9+
from ....handlersimportOptionHandlerCtxToPrepareSetValue
10+
from ....handlersimportConfigurationDataHandler
11+
12+
# //////////////////////////////////////////////////////////////////////////////
13+
# OptionHandlerToPrepareSetValue__Std__Bool
14+
15+
16+
classOptionHandlerToPrepareSetValue__Std__Bool(OptionHandlerToPrepareSetValue):
17+
def__init__(self):
18+
super().__init__()
19+
20+
# check
21+
assertnotany(set(__class__.sm_Str_True).intersection(__class__.sm_Str_False))
22+
23+
# prefixes are checked
24+
assertnotany(
25+
[
26+
x1
27+
forx1in__class__.sm_Str_True
28+
ifany([x2forx2in__class__.sm_Str_Falseifx2.startswith(x1)])
29+
]
30+
)
31+
assertnotany(
32+
[
33+
x1
34+
forx1in__class__.sm_Str_False
35+
ifany([x2forx2in__class__.sm_Str_Trueifx2.startswith(x1)])
36+
]
37+
)
38+
39+
# interface ----------------------------------------------------------
40+
defPrepareSetValue(self,ctx:OptionHandlerCtxToPrepareSetValue)->any:
41+
asserttype(ctx)==OptionHandlerCtxToPrepareSetValue
42+
assertisinstance(ctx.DataHandler,ConfigurationDataHandler)
43+
asserttype(ctx.OptionName)==str
44+
assertctx.OptionValueisnotNone
45+
46+
optionValue=ctx.OptionValue
47+
optionValueType=type(optionValue)
48+
49+
ifoptionValueType==bool:
50+
returnoptionValue
51+
52+
ifoptionValueType==int:
53+
asserttype(optionValue)==int
54+
55+
ifoptionValue==0:
56+
returnFalse
57+
58+
ifoptionValue==1:
59+
returnTrue
60+
61+
RaiseError.CantConvertOptionValue(ctx.OptionName,optionValueType,bool)
62+
63+
ifoptionValueType==str:
64+
asserttype(optionValue)==str
65+
66+
iflen(optionValue)<__class__.C_MIN_STR_VALUE_LENGTH:
67+
pass
68+
eliflen(optionValue)>__class__.C_MAX_STR_VALUE_LENGTH:
69+
pass
70+
else:
71+
optionValue_lower=optionValue.lower()
72+
73+
ifoptionValue_lowerin__class__.sm_Str_False:
74+
returnFalse
75+
76+
ifoptionValue_lowerin__class__.sm_Str_True:
77+
returnTrue
78+
79+
RaiseError.CantConvertOptionValue(ctx.OptionName,optionValueType,bool)
80+
81+
RaiseError.BadOptionValueType(ctx.OptionName,optionValueType,bool)
82+
83+
# Private data -------------------------------------------------------
84+
C_MIN_STR_VALUE_LENGTH=1
85+
C_MAX_STR_VALUE_LENGTH=5
86+
87+
sm_Str_False:list[str]= [
88+
"of",
89+
"off",
90+
"f",
91+
"fa",
92+
"fal",
93+
"fals",
94+
"false",
95+
"n",
96+
"no",
97+
"0",
98+
]
99+
100+
sm_Str_True:list[str]= [
101+
"on",
102+
"t",
103+
"tr",
104+
"tru",
105+
"true",
106+
"y",
107+
"ye",
108+
"yes",
109+
"1",
110+
]
111+
112+
113+
# //////////////////////////////////////////////////////////////////////////////

‎src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__generic.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def PrepareSetValue(self, ctx: OptionHandlerCtxToPrepareSetValue) -> any:
3030
pass# OK
3131
eliftypeOfOptionValue==str:
3232
pass# OK
33+
eliftypeOfOptionValue==bool:
34+
pass# OK
3335
else:
3436
BugCheckError.UnknownOptionValueType(ctx.OptionName,typeOfOptionValue)
3537

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# //////////////////////////////////////////////////////////////////////////////
2+
# Postgres Pro. PostgreSQL Configuration Python Library.
3+
4+
from __future__importannotations
5+
6+
from ....handlersimportOptionHandlerToWrite
7+
from ....handlersimportOptionHandlerCtxToWrite
8+
9+
from ....raise_errorimportRaiseError
10+
11+
# //////////////////////////////////////////////////////////////////////////////
12+
# OptionHandlerToWrite__Std__Bool
13+
14+
15+
classOptionHandlerToWrite__Std__Bool(OptionHandlerToWrite):
16+
def__init__(self):
17+
super().__init__()
18+
19+
# interface ----------------------------------------------------------
20+
defOptionValueToString(self,ctx:OptionHandlerCtxToWrite)->str:
21+
asserttype(ctx)==OptionHandlerCtxToWrite
22+
asserttype(ctx.OptionName)==str
23+
assertctx.OptionValueisnotNone
24+
25+
typeOfValue=type(ctx.OptionValue)
26+
27+
iftypeOfValue==bool:
28+
typedValue=bool(ctx.OptionValue)
29+
else:
30+
RaiseError.BadOptionValueItemType(ctx.OptionName,typeOfValue,bool)
31+
32+
asserttype(typedValue)==bool
33+
34+
iftypedValue:
35+
result="on"
36+
else:
37+
result="off"
38+
39+
returnresult
40+
41+
42+
# //////////////////////////////////////////////////////////////////////////////

‎src/core/option/handlers/write/option_handler_to_write__std__generic.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from .option_handler_to_write__std__intimportOptionHandlerToWrite__Std__Int
77
from .option_handler_to_write__std__strimportOptionHandlerToWrite__Std__Str
8+
from .option_handler_to_write__std__boolimportOptionHandlerToWrite__Std__Bool
89

910
from ....handlersimportOptionHandlerToWrite
1011
from ....handlersimportOptionHandlerCtxToWrite
@@ -20,6 +21,8 @@ class OptionHandlerToWrite__Std__Generic(OptionHandlerToWrite):
2021
sm_Handler_For_Int=OptionHandlerToWrite__Std__Int()
2122

2223
sm_Handler_For_Str=OptionHandlerToWrite__Std__Str()
24+
25+
sm_Handler_For_Bool=OptionHandlerToWrite__Std__Bool()
2326
# fmt on
2427

2528
# --------------------------------------------------------------------
@@ -39,6 +42,9 @@ def OptionValueToString(self, ctx: OptionHandlerCtxToWrite) -> str:
3942
iftypeOfOptionValue==str:
4043
return__class__.sm_Handler_For_Str.OptionValueToString(ctx)
4144

45+
iftypeOfOptionValue==bool:
46+
return__class__.sm_Handler_For_Bool.OptionValueToString(ctx)
47+
4248
BugCheckError.UnknownOptionValueType(ctx.OptionName,typeOfOptionValue)
4349

4450

‎src/implementation/v00/configuration_std.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
from ...core.option.handlers.prepare_set_value.option_handler_to_prepare_set_value__std__str \
2525
importOptionHandlerToPrepareSetValue__Std__Str
2626

27+
from ...core.option.handlers.prepare_set_value.option_handler_to_prepare_set_value__std__bool \
28+
importOptionHandlerToPrepareSetValue__Std__Bool
29+
2730
from ...core.option.handlers.prepare_set_value.option_handler_to_prepare_set_value__std__unique_str_list \
2831
importOptionHandlerToPrepareSetValue__Std__UniqueStrList
2932

@@ -41,6 +44,9 @@
4144
from ...core.option.handlers.prepare_get_value.option_handler_to_prepare_get_value__std__str \
4245
importOptionHandlerToPrepareGetValue__Std__Str
4346

47+
from ...core.option.handlers.prepare_get_value.option_handler_to_prepare_get_value__std__bool \
48+
importOptionHandlerToPrepareGetValue__Std__Bool
49+
4450
# -------------
4551
from ...core.option.handlers.prepare_get_value.option_handler_to_prepare_get_value__std__unique_str_list \
4652
importOptionHandlerToPrepareGetValue__Std__UniqueStrList
@@ -74,6 +80,9 @@
7480
from ...core.option.handlers.write.option_handler_to_write__std__str \
7581
importOptionHandlerToWrite__Std__Str
7682

83+
from ...core.option.handlers.write.option_handler_to_write__std__bool \
84+
importOptionHandlerToWrite__Std__Bool
85+
7786
from ...core.option.handlers.write.option_handler_to_write__std__unique_str_list \
7887
importOptionHandlerToWrite__Std__UniqueStrList
7988
# fmt: on
@@ -99,6 +108,9 @@ class PostgresConfiguration_Std(PostgresConfiguration_Base):
99108
sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Str= \
100109
OptionHandlerToPrepareSetValue__Std__Str()
101110

111+
sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Bool= \
112+
OptionHandlerToPrepareSetValue__Std__Bool()
113+
102114
sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__UniqueStrList= \
103115
OptionHandlerToPrepareSetValue__Std__UniqueStrList()
104116

@@ -116,6 +128,9 @@ class PostgresConfiguration_Std(PostgresConfiguration_Base):
116128
sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Str= \
117129
OptionHandlerToPrepareGetValue__Std__Str()
118130

131+
sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Bool= \
132+
OptionHandlerToPrepareGetValue__Std__Bool()
133+
119134
sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__UniqueStrList= \
120135
OptionHandlerToPrepareGetValue__Std__UniqueStrList()
121136

@@ -148,6 +163,9 @@ class PostgresConfiguration_Std(PostgresConfiguration_Base):
148163
sm_SingleInstance__OptionHandlerToWrite__Std__Str= \
149164
OptionHandlerToWrite__Std__Str()
150165

166+
sm_SingleInstance__OptionHandlerToWrite__Std__Bool= \
167+
OptionHandlerToWrite__Std__Bool()
168+
151169
sm_SingleInstance__OptionHandlerToWrite__Std__UniqueStrList= \
152170
OptionHandlerToWrite__Std__UniqueStrList()
153171
# fmt: on
@@ -245,6 +263,18 @@ def __init__(
245263
sm_SingleInstance__OptionHandlerToWrite__Std__Str,
246264
)
247265

266+
sm_OptionHandlers__Std__Bool= \
267+
tagOptionHandlers(
268+
sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__Bool,
269+
sm_SingleInstance__OptionHandlerToPrepareGetValue__Std__Bool,
270+
None,
271+
sm_SingleInstance__OptionHandlerToSetValue__Std__Simple,
272+
sm_SingleInstance__OptionHandlerToGetValue__Std__Simple,
273+
sm_SingleInstance__OptionHandlerToAddOption__Std,
274+
None,
275+
sm_SingleInstance__OptionHandlerToWrite__Std__Bool,
276+
)
277+
248278
sm_OptionHandlers__Std__UniqueStrList= \
249279
tagOptionHandlers(
250280
sm_SingleInstance__OptionHandlerToPrepareSetValue__Std__UniqueStrList,
@@ -265,6 +295,7 @@ def __init__(
265295
"port":sm_OptionHandlers__Std__Int,
266296
"listen_addresses":sm_OptionHandlers__Std__Str,
267297
"shared_preload_libraries":sm_OptionHandlers__Std__UniqueStrList,
298+
"restart_after_crash":sm_OptionHandlers__Std__Bool,
268299

269300
# PROXIMA --------------------------------------------------------
270301
"proxima.port":sm_OptionHandlers__Std__Int,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp