5858from ...core .bugcheck_error import BugCheckError
5959# fmt: on
6060
61+ from ...os .abstract .configuration_os_ops import ConfigurationOsOps
62+
6163import typing
6264import os
6365import io
@@ -470,7 +472,7 @@ def AddInclude(
470472 # Add/Get file
471473 # Add include element
472474
473- baseFolder = os . path . dirname (self .m_FileLineData .m_Parent .m_Path )
475+ baseFolder = cfg . m_Data . OsOps . Path_DirName (self .m_FileLineData .m_Parent .m_Path )
474476 assert type (baseFolder ) == str
475477
476478 fileData = PgCfgModel__DataControllerUtils .Cfg__GetOrCreateFile__USER (
@@ -828,7 +830,7 @@ def AddInclude(self, path: str) -> PostgresConfigurationInclude_Base:
828830 # Add empty line
829831 # Add include element
830832
831- baseFolder = os . path . dirname (self .m_FileData .m_Path )
833+ baseFolder = self . m_Cfg . m_Data . OsOps . Path_DirName (self .m_FileData .m_Path )
832834 assert type (baseFolder ) == str
833835
834836 fileData = PgCfgModel__DataControllerUtils .Cfg__GetOrCreateFile__USER (
@@ -1264,7 +1266,7 @@ def GetFileByName(self, file_name: str) -> PostgresConfigurationFile_Base:
12641266 assert type (self .m_Cfg .m_Data ) == PgCfgModel__ConfigurationData
12651267 assert type (self .m_Cfg .m_Data .m_AllFilesByName ) == dict
12661268
1267- file_name2 = os . path . normcase (file_name )
1269+ file_name2 = self . m_Cfg . m_Data . OsOps . Path_NormCase (file_name )
12681270
12691271 if not (file_name2 in self .m_Cfg .m_Data .m_AllFilesByName .keys ()):
12701272 RaiseError .UnknownFileName (file_name )
@@ -1276,7 +1278,7 @@ def GetFileByName(self, file_name: str) -> PostgresConfigurationFile_Base:
12761278 typeOfIndexData = type (indexData )
12771279
12781280 if typeOfIndexData == PgCfgModel__FileData :
1279- assert os . path . basename (indexData .m_Path ) == file_name2
1281+ assert self . m_Cfg . m_Data . OsOps . Path_BaseName (indexData .m_Path ) == file_name2
12801282 file = PostgresConfigurationFactory_Base .GetObject (self .m_Cfg , indexData )
12811283 assert file is not None
12821284 assert isinstance (file , PostgresConfigurationFile_Base )
@@ -1395,11 +1397,14 @@ class PostgresConfiguration_Base(PostgresConfiguration, PgCfgModel__DataHandler)
13951397 m_AllOptions : PostgresConfiguration_Base__AllOptions
13961398
13971399 # --------------------------------------------------------------------
1398- def __init__ (self , data_dir : str ):
1400+ def __init__ (self , data_dir : str , osOps : ConfigurationOsOps ):
1401+ assert type (data_dir ) == str # noqa: E721
1402+ assert isinstance (osOps , ConfigurationOsOps )
1403+
13991404 super (PostgresConfiguration , self ).__init__ ()
14001405 super (PgCfgModel__DataHandler , self ).__init__ ()
14011406
1402- self .m_Data = PgCfgModel__ConfigurationData (data_dir )
1407+ self .m_Data = PgCfgModel__ConfigurationData (data_dir , osOps )
14031408 self .m_AllFiles = None
14041409 self .m_AllOptions = None
14051410
@@ -1415,7 +1420,9 @@ def get_Parent(self) -> PostgresConfigurationObject:
14151420 def AddTopLevelFile (self , path : str ) -> PostgresConfigurationTopLevelFile_Base :
14161421 assert type (path ) == str
14171422 assert path != ""
1418- assert os .path .basename (path ) != ""
1423+ assert type (self .m_Data ) == PgCfgModel__ConfigurationData # noqa: E721
1424+ assert isinstance (self .m_Data .OsOps , ConfigurationOsOps )
1425+ assert self .m_Data .OsOps .Path_BaseName (path ) != ""
14191426
14201427 fileData = PgCfgModel__DataControllerUtils .Cfg__CreateAndAddTopLevelFile__USER (
14211428 self .m_Data , path
@@ -2066,12 +2073,14 @@ def Helper__GetFileForSimpleOption(
20662073 def Helper__FindFile (self , file_name : str ) -> PgCfgModel__FileData :
20672074 assert type (file_name ) == str
20682075 assert file_name != ""
2069- assert os .path .basename (file_name ) == file_name
2076+ assert type (self .m_Data ) == PgCfgModel__ConfigurationData # noqa: E721
2077+ assert isinstance (self .m_Data .OsOps , ConfigurationOsOps )
2078+ assert self .m_Data .OsOps .Path_BaseName (file_name ) == file_name
20702079
20712080 assert type (self .m_Data ) == PgCfgModel__ConfigurationData
20722081 assert type (self .m_Data .m_AllFilesByName ) == dict
20732082
2074- file_name_n = os . path . normcase (file_name )
2083+ file_name_n = self . m_Data . OsOps . Path_NormCase (file_name )
20752084
20762085 if not (file_name_n in self .m_Data .m_AllFilesByName .keys ()):
20772086 return None
@@ -3150,6 +3159,8 @@ class PostgresConfigurationReader_Base:
31503159 def LoadConfigurationFile (
31513160 cfg : PostgresConfiguration_Base , filePath : str
31523161 ) -> PostgresConfigurationTopLevelFile_Base :
3162+ assert cfg is not None
3163+
31533164 assert isinstance (cfg , PostgresConfiguration_Base )
31543165 assert type (filePath ) == str
31553166 assert filePath != ""
@@ -3184,7 +3195,7 @@ def LoadConfigurationFile(
31843195 BugCheckError .UnkFileObjectDataType (fileName , typeOfIndexData )
31853196
31863197 # ----------------------------------------------------------------
3187- filePath_n = Helpers .NormalizeFilePath (cfg .m_Data .m_DataDir , filePath )
3198+ filePath_n = Helpers .NormalizeFilePath (cfg .m_Data .OsOps , cfg . m_Data . m_DataDir , filePath )
31883199 assert type (filePath_n ) == str
31893200
31903201 if filePath_n in existFileDatas :
@@ -3959,7 +3970,7 @@ def Helper__DoWork__Stage04__OpenNewFilesToWrite(
39593970
39603971 fileCtx .File .close () # raise
39613972
3962- os . remove (filePath ) # raise
3973+ ctx . Cfg . m_Data . OsOps . Remove (filePath ) # raise
39633974 continue
39643975
39653976 raise
0 commit comments