8 Locating and Examining Translated CL Scripts

When the source for a PyRAF task is an IRAF CL script, PyRAF converts that CL script into an equivalent Python script, and it is that Python script that is actually executed when the task is invoked. The translation from CL to Python is normally done just once, when the task is first referenced, for example by using lpar or by running the task. Clearly, then, the translated script must be saved. The translated script (the Python equivalent of the CL script) is saved in a cache directory, which by default is the pyraf/clcache subdirectory of the user's IRAF home directory.

The file names in the clcache directory look peculiar (e.g. uJJQIVVFrKg-9jq2znC4OA==). Each name is constructed from the hash() of the contents of the corresponding CL script file, so the clcache files are tied to the contents of the CL scripts rather than to their names. One advantage of this is that if there are two or more identical CL scripts, they will map to the same clcache filename; such duplication does occur within the IRAF system. Another advantage to this scheme is that a CL script can be moved from one package to another (e.g. installing a script after testing in a local directory) without requiring recompilation of the cached version. It also allows multiple versions of IRAF on the same file system.

The files in the clcache directory are in Python pickle format. The getCode() method of the task retrieves the Python version of the script from the clcache directory and returns it as a string. Using the jqz.cl example given above, the syntax would be x = iraf.jqz.getCode(). The cached version of the CL script will be regenerated automatically if the CL script is edited (and then used). However, sometimes it may be necessary to force regeneration of the Python version without touching the original CL script. For example, this would be necessary if PyRAF itself were modified in a way that affected the parameter handling mechanism. The reCompile() method recreates the Python equivalent of the CL script and saves the result in the clcache directory; for example, iraf.jqz.reCompile().

Questions or comments? Contact help@stsci.edu
Documented updated on