[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnulib-tool-py] format of a module description
From: |
Bruno Haible |
Subject: |
[gnulib-tool-py] format of a module description |
Date: |
Mon, 02 Jul 2012 04:29:08 +0200 |
User-agent: |
KMail/4.7.4 (Linux/3.1.10-1.9-desktop; KDE/4.7.4; x86_64; ; ) |
Hi Dmitriy,
How to dissect a module description into sections? As stated [1], it is
important that the new and the old gnulib-tool do this with the same
results. It would not be good if a "Makefile.am" section, to take an
example, gets ignored because of a detail in syntax.
I see that in GLModule.__init__ you use file.read(). Good. This produces
the file's contents as a string in memory. But then you use a simple
substring search [2] in method _find_splitter_. This is not good.
If a configure.ac section happens to contain
# Transform the foobar.
sed -e 's:Makefile.am:Makefile.am.in:' < foo > foo.out
you should *not* interpret this occurrence of Makefile.am: as the
beginning of a section - because it is not at the beginning of a line.
Also, the code
if result.startswith('\t') or result.startswith(' '):
result = result[1:]
appears to be eating whitespace after the keyword. But why only 1 whitespace?
In sed_extract_prog any number of whitespace after the keyword is eaten,
and after this whitespace we expect a newline. The keyword that introduces
a new section is only to be recognized if it occurs at the beginning of a
line and if after it, in the same line, there is only whitespace.
(Rationale: Otherwise, the risk of recognizing a keyword in places where
it was not intended would be too large.)
Also, the sections are in arbitrary order. While usually, the 'Files:'
section comes before the 'Depends-on:' section, they may also be reversed!
You cannot assume a particular order.
Bruno
[1] http://lists.gnu.org/archive/html/gnulib-tool-py/2012-06/msg00038.html
[2] http://docs.python.org/py3k/reference/expressions.html#in
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnulib-tool-py] format of a module description,
Bruno Haible <=