Show More
@@ -6,18 +6,21 b'' | |||||
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
9 | import util |
|
9 | import util, re | |
|
10 | ||||
|
11 | _commentre = None | |||
10 |
|
12 | |||
11 | def _parselines(fp): |
|
13 | def _parselines(fp): | |
12 | for line in fp: |
|
14 | for line in fp: | |
13 |
if n |
|
15 | if "#" in line: | |
14 | line += '\n' |
|
16 | global _commentre | |
15 | escape = False |
|
17 | if not _commentre: | |
16 | for i in xrange(len(line)): |
|
18 | _commentre = re.compile(r'((^|[^\\])(\\\\)*)#.*') | |
17 | if escape: escape = False |
|
19 | # remove comments prefixed by an even number of escapes | |
18 | elif line[i] == '\\': escape = True |
|
20 | line = _commentre.sub(r'\1', line) | |
19 | elif line[i] == '#': break |
|
21 | # fixup properly escaped comments that survived the above | |
20 |
line = line |
|
22 | line = line.replace("\\#", "#") | |
|
23 | line = line.rstrip() | |||
21 | if line: |
|
24 | if line: | |
22 | yield line |
|
25 | yield line | |
23 |
|
26 |
General Comments 0
You need to be logged in to leave comments.
Login now