Skip to content

Commit c4e6273

Browse files
Support of python 3.7, 3.8 (#2)
* tests includes src as module * Using typing.List, typing.Dict and typing.Set [py3.7] * Python 3.7 does not support operator ":=" * travis: enable python 3.7 and 3.8 * fix: ConfigurationData is corrected (compilation error)
1 parent 88d9e9d commit c4e6273

File tree

48 files changed

+343
-282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+343
-282
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ notifications:
1919
on_failure: always
2020

2121
env:
22+
- TEST_PLATFORM=std3-all PYTHON_VERSION=3.7
23+
- TEST_PLATFORM=std3-all PYTHON_VERSION=3.8
2224
- TEST_PLATFORM=std3-all PYTHON_VERSION=3.9
2325
- TEST_PLATFORM=std3-all PYTHON_VERSION=3.10
2426
- TEST_PLATFORM=std3-all PYTHON_VERSION=3.11

src/core/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def ExtractOptionDataName(option: typing.Union[str, OptionData]) -> str:
2727

2828
# --------------------------------------------------------------------
2929
def ExtractFirstOptionFromIndexItem(
30-
optionName: str, indexItem: typing.Union[OptionData, list[OptionData]]
30+
optionName: str, indexItem: typing.Union[OptionData, typing.List[OptionData]]
3131
) -> OptionData:
3232
assert type(optionName) == str
3333

src/core/model.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(self, element: FileLineElementData):
155155

156156
# --------------------------------------------------------------------
157157
m_Parent: FileData
158-
m_Items: list[tagItem]
158+
m_Items: typing.List[tagItem]
159159

160160
# --------------------------------------------------------------------
161161
def __init__(self, parent: FileData):
@@ -164,7 +164,7 @@ def __init__(self, parent: FileData):
164164
super().__init__()
165165

166166
self.m_Parent = parent
167-
self.m_Items = list[__class__.tagItem]()
167+
self.m_Items = list()
168168

169169
# own interface ------------------------------------------------------
170170
def MarkAsDeletedFrom(self, fileData: FileData) -> None:
@@ -206,9 +206,9 @@ class FileData(ObjectData):
206206
m_LastModifiedTimestamp: typing.Optional[datetime.datetime]
207207

208208
m_Path: str
209-
m_Lines: list[FileLineData]
209+
m_Lines: typing.List[FileLineData]
210210

211-
m_OptionsByName: dict[str, OptionData]
211+
m_OptionsByName: typing.Dict[str, OptionData]
212212

213213
# --------------------------------------------------------------------
214214
def __init__(self, parent: ConfigurationData, path: str):
@@ -226,9 +226,10 @@ def __init__(self, parent: ConfigurationData, path: str):
226226
self.m_LastModifiedTimestamp = None
227227

228228
self.m_Path = path
229-
self.m_Lines = list[FileLineData]()
229+
self.m_Lines = list()
230230

231-
self.m_OptionsByName = dict[str, OptionData]()
231+
self.m_OptionsByName = dict()
232+
assert type(self.m_OptionsByName) == dict
232233

233234
assert type(self.m_Path) == str
234235
assert self.m_Path != ""
@@ -254,10 +255,10 @@ class ConfigurationData(ObjectData):
254255
m_DataDir: str
255256
m_OsOps: ConfigurationOsOps
256257

257-
m_Files: list[FileData]
258+
m_Files: typing.List[FileData]
258259

259-
m_AllOptionsByName: dict[str, typing.Union[OptionData, list[OptionData]]]
260-
m_AllFilesByName: dict[str, typing.Union[FileData, list[FileData]]]
260+
m_AllOptionsByName: typing.Dict[str, typing.Union[OptionData, typing.List[OptionData]]]
261+
m_AllFilesByName: typing.Dict[str, typing.Union[FileData, typing.List[FileData]]]
261262

262263
# --------------------------------------------------------------------
263264
def __init__(self, data_dir: str, osOps: ConfigurationOsOps):
@@ -269,11 +270,13 @@ def __init__(self, data_dir: str, osOps: ConfigurationOsOps):
269270
self.m_DataDir = data_dir
270271
self.m_OsOps = osOps
271272

272-
self.m_Files = list[FileData]()
273-
self.m_AllOptionsByName = dict[
274-
str, typing.Union[OptionData, list[OptionData]]
275-
]()
276-
self.m_AllFilesByName = dict[str, typing.Union[FileData, list[FileData]]]()
273+
self.m_Files = list()
274+
self.m_AllOptionsByName = dict()
275+
self.m_AllFilesByName = dict()
276+
277+
assert type(self.m_Files) == list
278+
assert type(self.m_AllOptionsByName) == dict
279+
assert type(self.m_AllFilesByName) == dict
277280

278281
# Own interface ------------------------------------------------------
279282
@property

src/core/option/handlers/prepare_get_value/option_handler_to_prepare_get_value__std__unique_str_list.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from ....handlers import OptionHandlerCtxToPrepareGetValue
88
from ....handlers import ConfigurationDataHandler
99

10+
import typing
11+
1012
# //////////////////////////////////////////////////////////////////////////////
1113
# OptionHandlerToPrepareGetValue__Std__UniqueStrList
1214

@@ -25,9 +27,8 @@ def PrepareGetValue(self, ctx: OptionHandlerCtxToPrepareGetValue) -> any:
2527
assert ctx.OptionValue is not None
2628
assert type(ctx.OptionValue) == list
2729

28-
result = list[str]()
29-
30-
index = set[str]()
30+
result: typing.List[str] = list()
31+
index: set[str] = set()
3132

3233
for x in ctx.OptionValue:
3334
assert x is not None

src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__bool.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from ....handlers import OptionHandlerCtxToPrepareSetValue
1010
from ....handlers import ConfigurationDataHandler
1111

12+
import typing
13+
1214
# //////////////////////////////////////////////////////////////////////////////
1315
# OptionHandlerToPrepareSetValue__Std__Bool
1416

@@ -84,7 +86,7 @@ def PrepareSetValue(self, ctx: OptionHandlerCtxToPrepareSetValue) -> any:
8486
C_MIN_STR_VALUE_LENGTH = 1
8587
C_MAX_STR_VALUE_LENGTH = 5
8688

87-
sm_Str_False: list[str] = [
89+
sm_Str_False: typing.List[str] = [
8890
"of",
8991
"off",
9092
"f",
@@ -97,7 +99,7 @@ def PrepareSetValue(self, ctx: OptionHandlerCtxToPrepareSetValue) -> any:
9799
"0",
98100
]
99101

100-
sm_Str_True: list[str] = [
102+
sm_Str_True: typing.List[str] = [
101103
"on",
102104
"t",
103105
"tr",

src/core/option/handlers/prepare_set_value/option_handler_to_prepare_set_value__std__unique_str_list.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
from ....read_utils import ReadUtils
1313

14+
import typing
15+
1416
# //////////////////////////////////////////////////////////////////////////////
1517
# OptionHandlerToPrepareSetValue__Std__UniqueStrList
1618

@@ -36,9 +38,8 @@ def PrepareSetValue(self, ctx: OptionHandlerCtxToPrepareSetValue) -> any:
3638
assert type(result) == list
3739
return result
3840
elif typeOfOptionValue == list:
39-
result = list[str]()
40-
41-
index = set[str]()
41+
result: typing.List[str] = list()
42+
index: typing.Set[str] = set()
4243

4344
for x in ctx.OptionValue:
4445
if x is None:

src/core/read_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def IsValidSeqCh2(ch: str) -> bool:
165165
return __class__.IsValidSeqCh1(ch)
166166

167167
# --------------------------------------------------------------------
168-
def Unpack_StrList2(source: str) -> list[str]:
168+
def Unpack_StrList2(source: str) -> typing.List[str]:
169169
assert source is not None
170170
assert type(source) == str
171171

@@ -184,8 +184,8 @@ class tagCtx:
184184
ctx.mode = C_MODE__NONE
185185
ctx.curValueItem = None
186186
ctx.dataLength = 0
187-
ctx.result = list[str]()
188-
ctx.index = set[str]()
187+
ctx.result = list()
188+
ctx.index = set()
189189

190190
i = 0
191191
length = len(source)

src/core/write_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# //////////////////////////////////////////////////////////////////////////////
22
# Postgres Pro. PostgreSQL Configuration Python Library.
33

4+
import typing
45

56
# //////////////////////////////////////////////////////////////////////////////
67
# class WriteUtils
@@ -14,7 +15,8 @@ def Pack_StrList2(strList: list) -> str:
1415
result = ""
1516
sep = ""
1617

17-
index = set[str]()
18+
index: typing.Set[str] = set()
19+
assert type(index) == set
1820

1921
for x in strList:
2022
assert x is not None

src/implementation/v00/configuration_base.py

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,7 +3005,8 @@ def Debug__CheckOurObjectData(self, data: PgCfgModel__ObjectData):
30053005
assert data is not None
30063006
assert isinstance(data, PgCfgModel__ObjectData)
30073007

3008-
stack = set[PgCfgModel__ObjectData]()
3008+
stack: typing.Set[PgCfgModel__ObjectData] = set()
3009+
assert type(stack) == set
30093010

30103011
ptr = data
30113012
while ptr is not self.m_Data:
@@ -3030,7 +3031,8 @@ def GetObject(
30303031
assert isinstance(objectData, PgCfgModel__ObjectData)
30313032

30323033
# Build stack
3033-
stack = list[PostgresConfigurationObject]()
3034+
stack: typing.List[PostgresConfigurationObject] = []
3035+
30343036

30353037
while True:
30363038
stack.append(objectData)
@@ -3165,7 +3167,7 @@ def LoadConfigurationFile(
31653167
assert type(filePath) == str
31663168
assert filePath != ""
31673169

3168-
existFileDatas = dict[str, PgCfgModel__FileData]()
3170+
existFileDatas: typing.Dict[str, PgCfgModel__FileData] = dict()
31693171

31703172
for fileName in cfg.m_Data.m_AllFilesByName.keys():
31713173
assert type(fileName) == str
@@ -3212,7 +3214,7 @@ def LoadConfigurationFile(
32123214
assert rootFile.m_FileData.m_LastModifiedTimestamp is None
32133215
assert len(rootFile.m_FileData.m_Lines) == 0
32143216

3215-
queuedFileDatas = set[PgCfgModel__FileData]()
3217+
queuedFileDatas: typing.Set[PgCfgModel__FileData] = set()
32163218

32173219
queuedFileDatas.add(rootFile.m_FileData)
32183220

@@ -3302,7 +3304,13 @@ def Helper__LoadFileContent(
33023304

33033305
lineReader = ReadUtils__LineReader()
33043306

3305-
while lineData := fileContent.ReadLine():
3307+
while True:
3308+
lineData = fileContent.ReadLine()
3309+
3310+
if not lineData:
3311+
# assert lineData is None
3312+
break
3313+
33063314
assert type(lineData) == str
33073315

33083316
lineReader.SetData(lineData)
@@ -3346,7 +3354,15 @@ def Helper__ProcessLineData(
33463354
sequenceOffset = lineReader.GetColOffset()
33473355
sequence = ch
33483356

3349-
while ch := lineReader.ReadSymbol():
3357+
while True:
3358+
ch = lineReader.ReadSymbol()
3359+
3360+
if not ch:
3361+
assert ch is None
3362+
break
3363+
3364+
assert type(ch) == str
3365+
33503366
if ReadUtils.IsValidSeqCh2(ch):
33513367
sequence += ch
33523368
continue
@@ -3387,8 +3403,15 @@ def Helper__ProcessLineData__Comment(
33873403
commentText = ""
33883404
commentOffset = lineReader.GetColOffset()
33893405

3390-
ch: str
3391-
while ch := lineReader.ReadSymbol():
3406+
while True:
3407+
ch = lineReader.ReadSymbol()
3408+
3409+
if not ch:
3410+
assert ch is None
3411+
break
3412+
3413+
assert type(ch) == str
3414+
33923415
if ReadUtils.IsEOL(ch):
33933416
break
33943417
commentText += ch
@@ -3699,9 +3722,15 @@ def Helper__ProcessLineData__Option__Generic(
36993722

37003723
optionValue = ""
37013724

3702-
ch: str
3725+
while True:
3726+
ch = lineReader.ReadSymbol()
3727+
3728+
if not ch:
3729+
assert ch is None
3730+
break
3731+
3732+
assert type(ch) == str
37033733

3704-
while ch := lineReader.ReadSymbol():
37053734
if ch == "#" or ReadUtils.IsEOL(ch):
37063735
lineReader.StepBack()
37073736
break
@@ -3757,9 +3786,13 @@ def __init__(self, cfg: PostgresConfiguration_Base):
37573786

37583787
self.Cfg = cfg
37593788

3760-
self.AllFiles = list[PostgresConfigurationWriterFileCtx_Base]()
3761-
self.NewFiles = list[PostgresConfigurationWriterFileCtx_Base]()
3762-
self.UpdFiles = list[PostgresConfigurationWriterFileCtx_Base]()
3789+
self.AllFiles = list()
3790+
self.NewFiles = list()
3791+
self.UpdFiles = list()
3792+
3793+
assert type(self.AllFiles) == list
3794+
assert type(self.NewFiles) == list
3795+
assert type(self.UpdFiles) == list
37633796

37643797
# --------------------------------------------------------------------
37653798
def Init(self):

tests/CfgFileReader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# /////////////////////////////////////////////////////////////////////////////
22
# Postgres Pro. PostgreSQL Configuration Python Library. Tests.
33

4-
from ..src.os.abstract.configuration_os_ops import ConfigurationFileReader
4+
from src.os.abstract.configuration_os_ops import ConfigurationFileReader
55

66
import io
77

0 commit comments

Comments
 (0)