Back to index

salome-kernel  6.5.0
Functions | Variables
getAppliPath Namespace Reference

Functions

def relpath
def set_var

Variables

tuple applipath = relpath(os.path.realpath(os.path.dirname(__file__)),os.path.realpath(os.getenv('HOME')))

Function Documentation

def getAppliPath.relpath (   target,
  base 
)
Find relative path from base to target
    if target== "/local/chris/appli" and base== "/local/chris" the result is appli
    if target== /tmp/appli and base /local/chris the result is ../../tmp/appli

Definition at line 27 of file getAppliPath.py.

00027 
00028 def relpath(target, base):
00029     """ Find relative path from base to target
00030         if target== "/local/chris/appli" and base== "/local/chris" the result is appli
00031         if target== /tmp/appli and base /local/chris the result is ../../tmp/appli
00032     """
00033     target=target.split(os.path.sep)
00034     base=base.split(os.path.sep)
00035     for i in xrange(len(base)):
00036       if base[i] != target[i]:
00037         i=i-1
00038         #not in base
00039         break
00040     p=['..']*(len(base)-i-1)+target[i+1:]
00041     if p == []:
00042       return '.'
00043     return os.path.join( *p )

def getAppliPath.set_var (   VAR,
  strpath 
)
Set VAR environment variable 

Definition at line 44 of file getAppliPath.py.

00044 
00045 def set_var(VAR, strpath):
00046     """Set VAR environment variable """
00047     value = "%r" % strpath
00048     shell = os.getenv('SHELL')
00049     if shell and shell.endswith('csh'):
00050         return "setenv %s %s" % (VAR, value)
00051     else:
00052         return "export %s=%s" % (VAR, value)


Variable Documentation

tuple getAppliPath.applipath = relpath(os.path.realpath(os.path.dirname(__file__)),os.path.realpath(os.getenv('HOME')))

Definition at line 54 of file getAppliPath.py.