(self, ast)
| 191 | return {} |
| 192 | |
| 193 | def g_include(self, ast): |
| 194 | filepath = self._unquote_tag(ast[0]) |
| 195 | |
| 196 | options = self._options |
| 197 | |
| 198 | if os.path.isabs(filepath): |
| 199 | configpath = [os.path.dirname(filepath)] |
| 200 | filename = os.path.basename(filepath) |
| 201 | |
| 202 | else: |
| 203 | configpath = options.get('configpath', []) |
| 204 | |
| 205 | if 'configroot' in options and options.get('includerelative'): |
| 206 | configpath.insert(0, options['configroot']) |
| 207 | |
| 208 | if 'programpath' in options: |
| 209 | configpath.append(options['programpath']) |
| 210 | else: |
| 211 | configpath.append('.') |
| 212 | |
| 213 | if self._reader.isdir(filepath): |
| 214 | configpath.insert(0, filepath) |
| 215 | filename = '.' |
| 216 | else: |
| 217 | filename = filepath |
| 218 | |
| 219 | for configdir in configpath: |
| 220 | |
| 221 | filepath = os.path.join(configdir, filename) |
| 222 | |
| 223 | if self._reader.isdir(filepath): |
| 224 | if options.get('includedirectories'): |
| 225 | contents = {} |
| 226 | |
| 227 | for include_file in sorted(self._reader.listdir(filepath)): |
| 228 | items = self.load(os.path.join( |
| 229 | filepath, include_file), initialize=False) |
| 230 | self._merge_contents(contents, items) |
| 231 | |
| 232 | return contents |
| 233 | |
| 234 | elif options.get('includeglob'): |
| 235 | contents = {} |
| 236 | |
| 237 | for include_file in sorted(glob.glob(filepath)): |
| 238 | items = self.load(include_file, initialize=False) |
| 239 | self._merge_contents(contents, items) |
| 240 | |
| 241 | return contents |
| 242 | |
| 243 | elif self._reader.exists(filepath): |
| 244 | return self.load(filepath, initialize=False) |
| 245 | |
| 246 | else: |
| 247 | raise error.ConfigFileReadError( |
| 248 | 'Config file "%s" not found in search path %s' |
| 249 | % (filename, ':'.join(configpath))) |
| 250 |
no test coverage detected