Package pyraf :: Module irafutils
[hide private]
[frames] | no frames]

Module irafutils

source code

module irafutils.py -- general utility functions

printCols       Print elements of list in cols columns
stripQuotes     Strip single or double quotes off string and remove embedded
                quote pairs
removeEscapes   Remove escaped quotes & newlines from strings
translateName   Convert CL parameter or variable name to Python-acceptable name
untranslateName Undo Python conversion of CL parameter or variable name
tkread          Read n bytes from file while running Tk mainloop
tkreadline     Read a line from file while running Tk mainloop

$Id: irafutils.py 678 2005-07-01 21:19:43Z perry $

R. White, 1999 Jul 16

Classes [hide private]
  _TkRead
Run Tk mainloop while waiting for a pending read operation
Functions [hide private]
 
printCols(strlist, cols=5, width=80)
Print elements of list in cols columns
source code
 
stripQuotes(value)
Strip single or double quotes off string; remove embedded quote pairs
source code
 
removeEscapes(value, quoted=0)
Remove escapes from in front of quotes (which IRAF seems to just stick in for fun sometimes.) Remove \-newline too.
source code
 
translateName(s, dot=0)
Convert CL parameter or variable name to Python-acceptable name
source code
 
untranslateName(s)
Undo Python conversion of CL parameter or variable name
source code
 
tkread(file, n=0)
Read n bytes from file (or socket) while running Tk mainloop.
source code
 
tkreadline(file=None)
Read a line from file while running Tk mainloop.
source code
Variables [hide private]
  _re_doubleq2 = re.compile('""')
  _re_singleq2 = re.compile("''")

Imports: os, sys, string, struct, re, keyword, types, select, Tkinter


Function Details [hide private]

removeEscapes(value, quoted=0)

source code 

Remove escapes from in front of quotes (which IRAF seems to just stick in for fun sometimes.) Remove \-newline too. If quoted is true, removes all blanks following \-newline (which is a nasty thing IRAF does for continuations inside quoted strings.) XXX Should we remove \ too?

translateName(s, dot=0)

source code 

Convert CL parameter or variable name to Python-acceptable name

Translate embedded dollar signs to 'DOLLAR' Add 'PY' prefix to components that are Python reserved words Add 'PY' prefix to components start with a number If dot != 0, also replaces '.' with 'DOT'

tkread(file, n=0)

source code 

Read n bytes from file (or socket) while running Tk mainloop.

If n=0 then this runs the mainloop until some input is ready on the file. (See tkreadline for an application of this.) The file must have a fileno method.

tkreadline(file=None)

source code 

Read a line from file while running Tk mainloop.

If the file is not line-buffered then the Tk mainloop will stop running after one character is typed. The function will still work but Tk widgets will stop updating. This should work OK for stdin and other line-buffered filehandles. If file is omitted, reads from sys.stdin.

The file must have a readline method. If it does not have a fileno method (which can happen e.g. for the status line input on the graphics window) then the readline method is simply called directly.