All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PathStripper Namespace Reference

Functions

def StripPath
 
def CleanVariable
 
def _check_output_options_cb
 

Variables

tuple parser = OptionParser()
 
string action = "append"
 
string dest = "envlist"
 
string metavar = "PATHVAR"
 
string help = "add environment variable to be processed"
 
list choices = ['csh','sh','bat']
 
string type = "string"
 
 callback = _check_output_options_cb,
 

Function Documentation

def PathStripper._check_output_options_cb (   option,
  opt_str,
  value,
  parser 
)
private

Definition at line 34 of file PathStripper.py.

34 
35 def _check_output_options_cb(option, opt_str, value, parser):
36  if opt_str == "--mktemp" :
37  if parser.values.output != stdout :
38  raise OptionValueError("--mktemp cannot be used at the same time as --output")
39  else :
40  parser.values.mktemp = True
41  fd, outname = mkstemp()
42  parser.values.output = fdopen(fd, "w")
43  print outname
44  elif opt_str == "--output" or opt_str == "-o" :
45  if parser.values.mktemp:
46  raise OptionValueError("--mktemp cannot be used at the same time as --output")
47  else :
48  parser.values.output = open(value, "w")
49 
def _check_output_options_cb
Definition: PathStripper.py:34
def PathStripper.CleanVariable (   varname,
  shell,
  out 
)

Definition at line 23 of file PathStripper.py.

23 
24 def CleanVariable(varname, shell, out):
25  if environ.has_key(varname):
26  pth = StripPath(environ[varname])
27  if shell == "csh" or shell.find("csh") != -1 :
28  out.write("setenv %s %s\n" % (varname, pth))
29  elif shell == "sh" or shell.find("sh") != -1 :
30  out.write("export %s=%s\n" % (varname, pth))
31  elif shell == "bat" :
32  out.write("set %s=%s\n" % (varname, pth))
33 
def PathStripper.StripPath (   path)

Definition at line 10 of file PathStripper.py.

10 
11 def StripPath(path):
12  collected = []
13  for p in path.split(pathsep):
14  rp = realpath(p)
15  # We keep the entry if it is a directory not empty or a zipfile
16  try :
17  if exists(rp) and ((isdir(rp) and listdir(rp))
18  or is_zipfile(rp)) and p not in collected:
19  collected.append(p)
20  except OSError :
21  pass
22  return pathsep.join(collected)

Variable Documentation

string PathStripper.action = "append"

Definition at line 55 of file PathStripper.py.

PathStripper.callback = _check_output_options_cb,

Definition at line 69 of file PathStripper.py.

list PathStripper.choices = ['csh','sh','bat']

Definition at line 60 of file PathStripper.py.

string PathStripper.dest = "envlist"

Definition at line 56 of file PathStripper.py.

string PathStripper.help = "add environment variable to be processed"

Definition at line 58 of file PathStripper.py.

string PathStripper.metavar = "PATHVAR"

Definition at line 57 of file PathStripper.py.

tuple PathStripper.parser = OptionParser()

Definition at line 52 of file PathStripper.py.

string PathStripper.type = "string"

Definition at line 65 of file PathStripper.py.