File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed
Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -120,33 +120,30 @@ def listTemplates(dir):
120120 ret [ti ['name' ]] = ti
121121 return ret
122122
123- def loadTemplateInfo (dir ):
123+ def loadTemplateInfo (path ):
124124 ''' Attempt to load a Roundup template from the indicated directory.
125125
126126 Return None if there's no template, otherwise a template info
127127 dictionary.
128128 '''
129- ti = os .path .join (dir , 'TEMPLATE-INFO.txt' )
130- if not os .path .exists (ti ):
129+ tif = os .path .join (path , 'TEMPLATE-INFO.txt' )
130+ if not os .path .exists (tif ):
131131 return None
132132
133- if os .path .exists (os .path .join (dir , 'config.py' )):
133+ if os .path .exists (os .path .join (path , 'config.py' )):
134134 print _ ("WARNING: directory '%s'\n "
135135 "\t contains old-style template - ignored"
136- ) % os .path .abspath (dir )
136+ ) % os .path .abspath (path )
137137 return None
138138
139139 # load up the template's information
140- f = open (ti )
141- try :
142- m = rfc822 .Message (open (ti ))
140+ with open (tif ) as f :
141+ m = rfc822 .Message (f )
143142 ti = {}
144143 ti ['name' ] = m ['name' ]
145144 ti ['description' ] = m ['description' ]
146145 ti ['intended-for' ] = m ['intended-for' ]
147- ti ['path' ] = dir
148- finally :
149- f .close ()
146+ ti ['path' ] = path
150147 return ti
151148
152149def writeHeader (name , value ):
You can’t perform that action at this time.
0 commit comments