a problem with writing a generator

Alf P. Steinbach alfps at start.no
Thu Jan 14 09:30:35 EST 2010


* Paweł Banyś:
> Hello,
> 
> Please forgive me if I repeat the subject anyhow. I am trying to write a
> simple program in Python which scans a config file in search for
> "include" lines. If those lines are found, the files included there are
> followed and scanned and if any further "include" lines are found, the
> whole procedure repeats itself. The program ends when the whole tree
> structure of those "includes" is generated.
> 
> I seem to have some blackout in my mind because I cannot understand how
> to use a generator functionality to complete the task. If anybody has
> already done such thing I would be very grateful for any guidance.

Assuming that include directives are like

   #include "blahblah"

and further that config files do not contain stuff that's not valid as C 
preprocessor tokens, may I suggest to check whether your C or C++ compiler 
offers an option to show the include file hierarchy.

For example, with gcc or g++ use option '-H' (it has other options for 
generating makefiles!), or with Microsoft's Visual C++, '-showIncludes'. You'll 
also have to ask the compiler to only preprocess.

Disclaimer: I haven't used *nix, if that's your environment, since mid 1990's...



Cheers & hth.,

- Alf



More information about the Python-list mailing list