Package Yab :: Module Util
[show private | hide private]
[frames | no frames]

Module Yab.Util

This file holds misc Yab utilities.

Global variables:

   run_quietly - When set, output from message and progress_message is stifled.

Classes
File This class is used to store information about a file or directory on the file system.

Function Summary
  bat_minishell(cmds, env)
Execute the commands as in make.
  chdir(dir)
  clear_cache()
Clear the cache loaded by load_cache.
  cmd_minishell(cmds, env)
Execute the commands as in make.
  fileset(includes, excludes, base_dir, contains, inc_dirs, file_objects)
Implement Ant's notion of a "FileSet.":http://jakarta.apache.org/ant/manual/CoreTypes/fileset.html The function will return a list of files that match the "includes" patterns and **do not** match the "excludes" patterns.
  get_caller_global(name)
Return the value of 'name' in a callers global namespace.
  get_file_info(path)
Create a File from the given pathname.
  get_globals_containing(name)
Return the global namespace of the caller that has a value for 'name' in its global namepace.
  get_resulting_env(command)
Return the shell environment after a given command is run.
  get_test_result(toolset, test_name)
Get the test result for a given toolset and test_name.
  get_token()
  is_abs_path(x)
Is the pathname an absolute path.
  isFile(x)
  load_cache(path)
Load persistent information from the given path (usually .yabcache).
  message(string)
Print a message to the console, add a newline, and flush.
  minishell(cmds, env)
  normalize(path)
  parse_file(file, dir)
Return a single File object that represents the given file.
  parse_files(files, dir)
Returns a list of 'File'es for one of the ways to specify a set of files.
  progress_message(string)
Print string + "..." to the console to represent the start of an operation.
  save_cache(path)
Save the cache to the given path.
  set_test_result(toolset, test_name, value)
Set the test result for a given toolset and test_name.
  sh_minishell(cmds, env)
Execute the commands as in make.
  singleline(string)
Trim the whitespace between tokens (including newlines).
  unsafe_get_file_info(normpath)
Create a File from the given pathname.
  whereis(file)
Search the system's path for the given executable name.

Variable Summary
int cache_version = 10                                                                    
NoneType cmd_interp = None                                                                  
SRE_Pattern env_var_re = ^([^=]+)=(.*)$
dict file_info_map = {}
NoneType minishell_impl = None                                                                  
int run_quietly = 0                                                                     
dict test_results = {}
SRE_Pattern triml = ^\s+
int unique_token_counter = 1                                                                     
dict whereis_map = {('D:\\Program Files\\Microsoft Visual Stu...
SRE_Pattern whitespace_re = \s{2,}

Function Details

bat_minishell(cmds, env=None)

Execute the commands as in make. One command per line, a leading '-' means ignore the result code. If a command, not prefixed by '-', returns a non-zero result, stop processing and return a non-zero result.

Variable substitution should have already been done.

If 'env' is set, use that dictionary as the command environment.

clear_cache()

Clear the cache loaded by load_cache.

cmd_minishell(cmds, env=None)

Execute the commands as in make. One command per line, a leading '-' means ignore the result code. If a command, not prefixed by '-', returns a non-zero result, stop processing and return a non-zero result.

Variable substitution should have already been done.

If 'env' is set, use that dictionary as the command environment.

fileset(includes=['**/*'], excludes=[], base_dir='.', contains=None, inc_dirs=None, file_objects=None)

Implement Ant's notion of a "FileSet.":http://jakarta.apache.org/ant/manual/CoreTypes/fileset.html The function will return a list of files that match the "includes" patterns and **do not** match the "excludes" patterns.

get_caller_global(name)

Return the value of 'name' in a callers global namespace. Look up the call stack until it is found. raise ValueError if the name is not found.

get_file_info(path)

Create a File from the given pathname. Path MUST be absoulute filename.

get_globals_containing(name)

Return the global namespace of the caller that has a value for 'name' in its global namepace.

get_resulting_env(command)

Return the shell environment after a given command is run.

get_test_result(toolset, test_name)

Get the test result for a given toolset and test_name. If the test was never run, raise KeyError.

is_abs_path(x)

Is the pathname an absolute path. Workaround for a bug in the python runtime library.

load_cache(path)

Load persistent information from the given path (usually .yabcache). The cache contains information that is time consuming to calculate and that can be preserved from run to run. In includes:

1 File objects

2 test results

3 whereis information

message(string)

Print a message to the console, add a newline, and flush.

parse_file(file, dir=None)

Return a single File object that represents the given file. 'File' may be:

1 a File object, which is just returned

2 a string, that is interpreted relative to the passed in 'dir' parameter.

If no 'dir' is specified, the default is where the calling script is located (**not** the current directory).

If dir *is* specified, it is relative to the current directory (be careful when using this)

parse_files(files, dir=None)

Returns a list of 'File'es for one of the ways to specify a set of files. These are:

1 a string that is split to get a list of paths

2 a list of strings (usefull if you need to specify filenames with whitespace in them.

3 a File object

4 a Target object (files are the target's target_paths)

These names are interpreted relative to the directory passed in as the 'dir' parameter. If no 'dir' is specified, the default is where the calling script is located (**not** the current directory).

progress_message(string)

Print string + "..." to the console to represent the start of an operation. You should call message() after the operation completes to print the result.

save_cache(path)

Save the cache to the given path.

set_test_result(toolset, test_name, value)

Set the test result for a given toolset and test_name. These results are stored in the cache.

sh_minishell(cmds, env=None)

Execute the commands as in make. One command per line, a leading '-' means ignore the result code. If a command, not prefixed by '-', returns a non-zero result, stop processing and return a non-zero result.

Variable substitution should have already been done.

If 'env' is set, use that dictionary as the command environment.

singleline(string)

Trim the whitespace between tokens (including newlines).

unsafe_get_file_info(normpath)

Create a File from the given pathname. The pathname must be absoulite and have been returned from Util.normalize.

whereis(file)

Search the system's path for the given executable name. On win32 systems, check for <file>.exe and <file>.bat. On unix, check for an executable file (that is not a directory) Cached for speed.

Variable Details

cache_version

Type:
int
Value:
10                                                                    

cmd_interp

Type:
NoneType
Value:
None                                                                  

env_var_re

Type:
SRE_Pattern
Value:
^([^=]+)=(.*)$                                                         

file_info_map

Type:
dict
Value:
{}                                                                     

minishell_impl

Type:
NoneType
Value:
None                                                                  

run_quietly

Type:
int
Value:
0                                                                     

test_results

Type:
dict
Value:
{}                                                                     

triml

Type:
SRE_Pattern
Value:
^\s+                                                                   

unique_token_counter

Type:
int
Value:
1                                                                     

whereis_map

Type:
dict
Value:
{('D:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\IDE;\
D:\\Program Files\\Microsoft Visual Studio .NET 2003\\VC7\\BIN;D:\\Pro\
gram Files\\Microsoft Visual Studio .NET 2003\\Common7\\Tools;D:\\Prog\
ram Files\\Microsoft Visual Studio .NET 2003\\Common7\\Tools\\bin\\pre\
release;D:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\
\Tools\\bin;D:\\Program Files\\Microsoft Visual Studio .NET 2003\\SDK\\
\v1.1\\bin;C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322;C:\\texmf\\
\miktex\\bin\\;c:\\utils;d:\\utils;d:\\python;d:\\cygwin\\bin;C:\\WIND\
...                                                                    

whitespace_re

Type:
SRE_Pattern
Value:
\s{2,}                                                                 

Generated by Epydoc 2.0 on Fri Aug 15 16:30:51 2003 http://epydoc.sf.net