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

Commit2ddecc4

Browse files
author
Dmitry Kovalenko
committed
Merge branch 'D20250817_001--cfg_os_ops' into 'master'
Usage of "os" is replaced with ConfigurationOsOpsSee merge request d.kovalenko/testgres.postgres_configuration!1
2 parents1a11fd0 +17a8446 commit2ddecc4

File tree

11 files changed

+422
-96
lines changed

11 files changed

+422
-96
lines changed

‎setup.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"testgres.postgres_configuration.core.option.handlers.set_value",
3636
"testgres.postgres_configuration.core.option.handlers.set_value_item",
3737
"testgres.postgres_configuration.core.option.handlers.write",
38+
"testgres.postgres_configuration.os",
39+
"testgres.postgres_configuration.os.abstract",
40+
"testgres.postgres_configuration.os.local",
3841
],
3942
package_dir={"testgres.postgres_configuration":"src"},
4043
description="PostgreSQL Configuration Python Library",

‎src/core/controller_utils.py‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
from .modelimportFileDataasPgCfgModel__FileData
1515
# fmt: on
1616

17+
from ..os.abstract.configuration_os_opsimportConfigurationOsOps
18+
1719
from .raise_errorimportRaiseError
1820
from .bugcheck_errorimportBugCheckError
1921
from .helpersimportHelpers
2022

21-
importos
2223
importtyping
2324

2425
# //////////////////////////////////////////////////////////////////////////////
@@ -350,12 +351,13 @@ def Cfg__CreateAndAddTopLevelFile__AUTO(
350351
asserttype(cfgData)==PgCfgModel__ConfigurationData
351352
asserttype(cfgData.m_Files)==list
352353
asserttype(cfgData.m_AllFilesByName)==dict
354+
assertisinstance(cfgData.OsOps,ConfigurationOsOps)
353355
asserttype(file_name)==str
354356
assertfile_name!=""
355-
assertos.path.basename(file_name)==file_name
357+
assertcfgData.OsOps.Path_BaseName(file_name)==file_name
356358

357-
newFilePath=os.path.join(cfgData.m_DataDir,file_name)
358-
newFilePath=os.path.normpath(newFilePath)
359+
newFilePath=cfgData.OsOps.Path_Join(cfgData.m_DataDir,file_name)
360+
newFilePath=cfgData.OsOps.Path_NormPath(newFilePath)
359361

360362
asserttype(newFilePath)==str
361363
assertnewFilePath!=""
@@ -370,9 +372,10 @@ def Cfg__CreateAndAddTopLevelFile__USER(
370372
asserttype(cfgData.m_Files)==list
371373
asserttype(cfgData.m_AllFilesByName)==dict
372374
asserttype(path)==str
375+
assertisinstance(cfgData.OsOps,ConfigurationOsOps)
373376
assertpath!=""
374377

375-
newFilePath=Helpers.NormalizeFilePath(cfgData.m_DataDir,path)
378+
newFilePath=Helpers.NormalizeFilePath(cfgData.OsOps,cfgData.m_DataDir,path)
376379

377380
asserttype(newFilePath)==str
378381
assertnewFilePath!=""
@@ -395,11 +398,12 @@ def Cfg__GetOrCreateFile__USER(
395398
asserttype(cfgData)==PgCfgModel__ConfigurationData
396399
asserttype(cfgData.m_Files)==list
397400
asserttype(cfgData.m_AllFilesByName)==dict
401+
assertisinstance(cfgData.OsOps,ConfigurationOsOps)
398402
asserttype(baseFolder)==str
399403
asserttype(path)==str
400404
assertpath!=""
401405

402-
newFilePath=Helpers.NormalizeFilePath(baseFolder,path)
406+
newFilePath=Helpers.NormalizeFilePath(cfgData.OsOps,baseFolder,path)
403407

404408
asserttype(newFilePath)==str
405409
assertnewFilePath!=""
@@ -492,13 +496,14 @@ def Helper__RegFileInCfgData(
492496
assertcfgDataisnotNone
493497
assertfileDataisnotNone
494498
asserttype(cfgData)==PgCfgModel__ConfigurationData
499+
assertisinstance(cfgData.OsOps,ConfigurationOsOps)
495500
asserttype(fileData)==PgCfgModel__FileData
496501
asserttype(fileData.m_Path)==str
497502
assertfileData.m_Path!=""
498503

499504
assertfileData.IsAlive()
500505

501-
fileName=os.path.basename(fileData.m_Path)
506+
fileName=cfgData.OsOps.Path_BaseName(fileData.m_Path)
502507
asserttype(fileName)==str
503508
assertfileName!=""
504509

@@ -513,12 +518,13 @@ def Helper__UnRegFileFromCfgData(
513518
assertcfgDataisnotNone
514519
assertfileDataisnotNone
515520
asserttype(cfgData)==PgCfgModel__ConfigurationData
521+
assertisinstance(cfgData.OsOps,ConfigurationOsOps)
516522
asserttype(fileData)==PgCfgModel__FileData
517523
assertfileData.m_Path!=""
518524

519525
assertfileData.IsAlive()
520526

521-
fileName=os.path.basename(fileData.m_Path)
527+
fileName=cfgData.OsOps.Path_BaseName(fileData.m_Path)
522528
asserttype(fileName)==str
523529
assertfileName!=""
524530

‎src/core/helpers.py‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
from .modelimportOptionData
55
from .bugcheck_errorimportBugCheckError
66

7+
from ..os.abstract.configuration_os_opsimportConfigurationOsOps
8+
79
importtyping
8-
importos
910

1011
# //////////////////////////////////////////////////////////////////////////////
1112

@@ -63,24 +64,30 @@ def DoesContainerContainsValue__NotNullAndExact(
6364
returnFalse
6465

6566
# --------------------------------------------------------------------
66-
defNormalizeFilePath(baseFolder:str,filePath:str)->str:
67+
defNormalizeFilePath(
68+
cfgOsOps:ConfigurationOsOps,
69+
baseFolder:str,
70+
filePath:str
71+
)->str:
72+
assertcfgOsOpsisnotNone
73+
assertisinstance(cfgOsOps,ConfigurationOsOps)
6774
asserttype(baseFolder)==str
6875
asserttype(filePath)==str
6976
assertfilePath!=""
7077

7178
newFilePath=None
7279

73-
ifos.path.isabs(filePath):
74-
newFilePath=os.path.normpath(filePath)
80+
ifcfgOsOps.Path_IsAbs(filePath):
81+
newFilePath=cfgOsOps.Path_NormPath(filePath)
7582
else:
76-
newFilePath=os.path.join(baseFolder,filePath)
77-
newFilePath=os.path.normpath(newFilePath)
83+
newFilePath=cfgOsOps.Path_Join(baseFolder,filePath)
84+
newFilePath=cfgOsOps.Path_NormPath(newFilePath)
7885

7986
asserttype(newFilePath)==str
8087
assertnewFilePath!=""
8188

82-
newFilePath=os.path.abspath(newFilePath)
83-
newFilePath=os.path.normcase(newFilePath)
89+
newFilePath=cfgOsOps.Path_AbsPath(newFilePath)
90+
newFilePath=cfgOsOps.Path_NormCase(newFilePath)
8491

8592
returnnewFilePath
8693

‎src/core/model.py‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
from .raise_errorimportRaiseError
77

8+
from ..os.abstract.configuration_os_opsimportConfigurationOsOps
9+
810
importtyping
9-
importos
1011
importenum
1112
importdatetime
1213

@@ -213,9 +214,9 @@ class FileData(ObjectData):
213214
def__init__(self,parent:ConfigurationData,path:str):
214215
asserttype(parent)==ConfigurationData
215216
asserttype(path)==str
216-
assertos.path.isabs(path)
217-
assertos.path.normpath(path)==path
218-
assertos.path.normcase(path)==path
217+
assertparent.OsOps.Path_IsAbs(path)
218+
assertparent.OsOps.Path_NormPath(path)==path
219+
assertparent.OsOps.Path_NormCase(path)==path
219220

220221
super().__init__()
221222

@@ -251,24 +252,35 @@ def IsAlive(self) -> bool:
251252

252253
classConfigurationData(ObjectData):
253254
m_DataDir:str
255+
m_OsOps:ConfigurationOsOps
256+
254257
m_Files:list[FileData]
255258

256259
m_AllOptionsByName:dict[str,typing.Union[OptionData,list[OptionData]]]
257260
m_AllFilesByName:dict[str,typing.Union[FileData,list[FileData]]]
258261

259262
# --------------------------------------------------------------------
260-
def__init__(self,data_dir:str):
263+
def__init__(self,data_dir:str,osOps:ConfigurationOsOps):
261264
asserttype(data_dir)==str
265+
assertisinstance(osOps,ConfigurationOsOps)
262266

263267
super().__init__()
264268

265269
self.m_DataDir=data_dir
270+
self.m_OsOps=osOps
271+
266272
self.m_Files=list[FileData]()
267273
self.m_AllOptionsByName=dict[
268274
str,typing.Union[OptionData,list[OptionData]]
269275
]()
270276
self.m_AllFilesByName=dict[str,typing.Union[FileData,list[FileData]]]()
271277

278+
# Own interface ------------------------------------------------------
279+
@property
280+
defOsOps(self)->ConfigurationOsOps:
281+
assertisinstance(self.m_OsOps,ConfigurationOsOps)
282+
returnself.m_OsOps
283+
272284
# Object interface ---------------------------------------------------
273285
defget_Parent(self)->FileData:
274286
returnNone

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp