Table of Contents

Module: projtls projtls.py

Some basic tools for the collect package

This module contains a single "constant" value that is used for all angle handling in the program: projtls.degrees. This is the conversion factor to convert from degrees to radians and back. Please note that ALL angles in the program are supposed to be stored in radians, with exception of those in the configuration files, and thus those in the "misc.config" module.

Examples:

import projtls
theta=60*projtls.degrees
print "Theta= %.4f degrees"%theta/projtls.degrees

To remember the convention, "*projtls.degrees" can be pronounced as "to degrees", and "/projtls.degrees" as "in degrees".

Functions   
MappedOrString
ReScanText
fileage
filesize
filetime
freespace
moveoutofway
myopen
pcbyteorder
stringtofloats
timestamp
timestamps
wordsfromfile
youngest
  MappedOrString 
MappedOrString ( f,  size )

Return a memory mapped R/O part of a file, or if that doesn't work the same data as a string.

  ReScanText 
ReScanText (
        intext,
        what,
        into=None,
        allowunknown=0,
        )

Scan some textlines for some regular expressions, storing some variables in an object

once a line has matched, no more regular expressions are tested.

  • parameters:

    intext

    list of text-lines of input, each to be scanned (if a single string is given, it is split into lines first)

    what

    data structure describing what to search

  • optional parameters:

    into

    any object to store the attributes that were found. If it is not specified, an empty Record() is created.

    allowunknown

    if set to 1, will just complain a bit if a line is not understood. If set to 2, will not even complain. If set to 0, will raise an exception.

  • return value: into

side effect: into is changed.

The "what" structure is composed of:

what = tuple of trials

trial = tuple of ("re" regular expression object, tuple of groups)

group = tuple of (group number, type, attribute name)

type = "f" (float) | "l" (logical [Yes/No]) | "i" (integer) | "s" (string) | "a" (angle in degrees) | "t" (list of strings)

Exceptions   
ScanTextError( "Not understood", line )
  fileage 
fileage ( filename )

Get the relative file "age" (tests reverse from the "file time")

  filesize 
filesize ( filename )

Returns file size in bytes. To get real size of compressed file, use the routine with the same name from the interface.compress module

  filetime 
filetime ( filename )

Get the time the file was made

  freespace 
freespace ( path )

freespace(path) -> integer Return the number of bytes available to the user on the file system pointed to by path.

  moveoutofway 
moveoutofway ( filename,  dirok=0 )

Rename the given file to a safe backup name.

For the destination name, use the "emacs" .~#~ extension.

  • parameters:

    filename: the file to be renamed. If it does not exist, nothing will happen.

    dirok: normally only plain files will be renamed away, but if this option is set to 1, directories will be considered as well.

  myopen 
myopen ( filename,  mode )

Open a file. Based on the filename extension, open it through different compression/decompression program pipes.

parameters: filename : name of file to open. mode : r or w for read-only or write-only open.

Exceptions   
IOError( "unknown filemode?" )
  pcbyteorder 
pcbyteorder ()

Determine the byte order of the machine, to know e.g. whether KappaCCD images should be byte-swapped before presentation (this is needed when this routine returns 0)

  stringtofloats 
stringtofloats ( s )

Reads space-separated floating point values from a string. Returns as many floats as there are. Return value is a tuple of the values

  timestamp 
timestamp ()

Return a string in the form of 'Sep14 12:15:46.985: ' representing the current time. This is meant for logging (network) events.

  timestamps 
timestamps ()

Return a string in the form of Sep14 12:15:46 representing the current time. This is meant for less accurate logging.

  wordsfromfile 
wordsfromfile ( filename )

Read all non-comment lines from the given file.

Return value: list of words

  youngest 
youngest (
        pattern=None,
        files=None,
        exclude=(),
        )

Return the youngest file from a set.

Can be called with:

string in pattern

return the youngest file that matches the pattern

list or tuple of strings in pattern

return the youngest file that matches any of the patterns

no arguments

return the youngest file in the current directory

a string in pattern and a list of filenames in files

return the youngest file from the list of files that matches the pattern

a list of filenames in files

return the youngest file from the list

There is a function of the same name in the misc.compress module that will also find any compressed files.

Classes   
Cache

General Data cache

CalledElement

Help to delay list evaluation to the latest possible moment.

LongTaskTracer

Allow a Tkinter GUI to interrupt a long-lasting computation.

Record

Empty class for misc use

ScanTextError

Exception raised when ReScanText encounters a parsing problem.

timer

Poor man's profiler


Table of Contents

This document was automatically generated on Tue Nov 25 12:18:58 2008 by HappyDoc version WORKING