Show More
@@ -10,10 +10,11 import error, util | |||||
10 | import os, errno |
|
10 | import os, errno | |
11 |
|
11 | |||
12 | class config(object): |
|
12 | class config(object): | |
13 | def __init__(self, data=None): |
|
13 | def __init__(self, data=None, includepaths=[]): | |
14 | self._data = {} |
|
14 | self._data = {} | |
15 | self._source = {} |
|
15 | self._source = {} | |
16 | self._unset = [] |
|
16 | self._unset = [] | |
|
17 | self._includepaths = includepaths | |||
17 | if data: |
|
18 | if data: | |
18 | for k in data._data: |
|
19 | for k in data._data: | |
19 | self._data[k] = data[k].copy() |
|
20 | self._data[k] = data[k].copy() | |
@@ -110,13 +111,17 class config(object): | |||||
110 | item = None |
|
111 | item = None | |
111 | cont = False |
|
112 | cont = False | |
112 | m = includere.match(l) |
|
113 | m = includere.match(l) | |
113 | if m: |
|
114 | ||
114 | inc = util.expandpath(m.group(1)) |
|
115 | if m and include: | |
115 |
|
|
116 | expanded = util.expandpath(m.group(1)) | |
116 | inc = os.path.normpath(os.path.join(base, inc)) |
|
117 | includepaths = [os.path.dirname(src)] + self._includepaths | |
117 | if include: |
|
118 | ||
|
119 | for base in includepaths: | |||
|
120 | inc = os.path.normpath(os.path.join(base, expanded)) | |||
|
121 | ||||
118 | try: |
|
122 | try: | |
119 | include(inc, remap=remap, sections=sections) |
|
123 | include(inc, remap=remap, sections=sections) | |
|
124 | break | |||
120 | except IOError, inst: |
|
125 | except IOError, inst: | |
121 | if inst.errno != errno.ENOENT: |
|
126 | if inst.errno != errno.ENOENT: | |
122 | raise error.ParseError(_("cannot include %s (%s)") |
|
127 | raise error.ParseError(_("cannot include %s (%s)") |
General Comments 0
You need to be logged in to leave comments.
Login now