Ticket #4: yum-multiinclude.patch
| File yum-multiinclude.patch, 2.7 kB (added by arogge, 3 years ago) |
|---|
-
parser.py
old new 58 58 def __init__(self, configfile, vars=None): 59 59 # put the vars away in a helpful place 60 60 self._vars = vars 61 62 # used to track the current ini-section 63 self._section = None 61 64 62 65 # set some file-like object attributes for ConfigParser 63 66 # these just make confpp look more like a real file object. … … 129 132 # whooohoo a valid include line.. push it on the stack 130 133 fo = self._pushfile( url ) 131 134 else: 135 # check if the current line starts a new section 136 secmatch = re.match( r'\s*\[(?P<section>.*)\]', line ) 137 if secmatch: 138 self._section = secmatch.group('section') 132 139 # line didn't match include=, just return it as is 133 140 # for the ConfigParser 134 141 break … … 156 163 return url 157 164 else: 158 165 return urlparse.urljoin( self.geturl(), url ) 159 160 166 161 167 def _pushfile( self, url ): 162 168 """ 163 169 Opens the url specified, pushes it on the stack, and … … 169 175 # absolutize this url using the including files url 170 176 # as a base url. 171 177 absurl = self._absurl(url) 178 179 # get the current section to add it to the included 180 # url's name. 181 includetuple = (absurl, self._section) 172 182 # check if this has previously been included. 173 if self._ urlalreadyincluded(absurl):183 if self._isalreadyincluded(includetuple): 174 184 return None 175 185 try: 176 186 fo = urlgrabber.grabber.urlopen(absurl) … … 179 189 if fo is not None: 180 190 self.name = absurl 181 191 self._incstack.append( fo ) 182 self._alreadyincluded.append( absurl)192 self._alreadyincluded.append(includetuple) 183 193 else: 184 194 raise Errors.ConfigError, \ 185 195 'Error accessing file for config %s' % (absurl) … … 199 209 self.name = None 200 210 201 211 202 def _ urlalreadyincluded( self, url):212 def _isalreadyincluded( self, tuple ): 203 213 """ 204 Checks if the url has already been included at all.. this205 does not necessarily have to be recursive214 Checks if the tuple describes an include that was already done. 215 This does not necessarily have to be recursive 206 216 """ 207 for e urlin self._alreadyincluded:208 if e url == url: return 1217 for etuple in self._alreadyincluded: 218 if etuple == tuple: return 1 209 219 return 0 210 220 211 221

