PathStripper Namespace Reference

Functions

def StripPath (path)
 
def CleanVariable (varname, shell, out)
 
def _check_output_options_cb (option, opt_str, value, parser)
 

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

Definition at line 23 of file PathStripper.py.

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

Definition at line 10 of file PathStripper.py.

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

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.