gnulib-tool-py
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnulib-tool-py] Getting cached values of variables


From: Dmitriy Selyutin
Subject: [gnulib-tool-py] Getting cached values of variables
Date: Thu, 17 May 2012 18:44:18 +0400

Hi everyone!

I've broken my head totally, trying to find the same fast way to get cached values from gnulib-cache.m4 file, but there are two problems:
1. Python re module doesn't have cycles like sed. We can use default Python's cycles, but since we are working with Unicode (unicode/str types), it probably will take much time to complete such a task. As you know Unicode wastes more memory than usual bytes. That can make a headache because we use 'string' type everywhere.
2. The another disadvantage that we have to separate one big regex into several parts of code. I prefer to use big regex, because that means that we do not need to feed text to parsers a lot of times, but can do all we need instantly.
3. If we use sed, it works with C speed, so it will be very fast comparing to Python.

What can we do? I suggest to create new subdirectory 'shell' inside pygnulib. This subdirectory contains some scripts which shall be executed using shell.
The first script will be called 'gnulibcache.sh'. It takes the path to the gnulib-cache.m4 file from Python as argument, feeds all the text to sed and...
1) ...stores variables as files in temporary directory (which is the second argument). Then the control returns to Python, we open files, get data and stores it as Python variables;
2) ...exports variables using `export` command. Then we can get this variables using os.environ dictionary.

I think the first way is better, it seems that bash uses `export`, csh uses `setenv`, so we have some troubles with portability. That is a really bad way.

I think that it is not very good idea to keep some actions inside shell, but we already keep some actions which can not be done with Python (e.g. when we get version from git). So I think now is a case when we have to use shell (look at two reasons which I've explained before). I could do it inside module, but I think it will be better to separate this shell actions from Python's code.

What do you think?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]