@@ -116,8 +116,9 @@ def makeDirectories(self):
116116 self .msg (f"\t { path } already exists." )
117117 else :
118118 os .makedirs (path )
119- open (os .path .join (path , '__init__.py' ), 'w' ,
120- encoding = 'ascii' ).write ('#\n ' )
119+ with open (os .path .join (path , '__init__.py' ), 'w' ,
120+ encoding = 'ascii' ) as initFile :
121+ initFile .write ('#\n ' )
121122 self .msg (f"\t { path } created." )
122123
123124 def copyConfigFiles (self ):
@@ -193,14 +194,16 @@ def makeDefaultContext(self):
193194 self .msg (f"\t { filename } already exists." )
194195 else :
195196 self .msg (f"\t { filename } " )
196- open (filename , "w" , encoding = 'ascii' ).write (source )
197+ with open (filename , "w" , encoding = 'ascii' ) as sourceFile :
198+ sourceFile .write (source )
197199 self .msg ("Updating config for default context..." )
198200 filename = os .path .join (self ._workDir , 'Configs' , 'Application.config' )
199201 self .msg (f"\t { filename } " )
200- content = open (filename , encoding = 'utf-8' ).readlines ()
202+ with open (filename , encoding = 'utf-8' ) as configFile :
203+ configLines = configFile .readlines ()
201204 foundContext = 0
202205 with open (filename , 'w' , encoding = 'utf-8' ) as output :
203- for line in content :
206+ for line in configLines :
204207 contextName = self ._contextName
205208 if line .startswith (
206209 f"Contexts[{ contextName !r} ] = { configDir !r} \n " ):
0 commit comments