Robot Framework
robot.utils.robotpath Namespace Reference

Functions

def _common_path (p1, p2)
 Returns the longest path common to p1 and p2. More...
 
def _find_absolute_path (path)
 
def _find_relative_path (path, basedir)
 
def _get_link_path (target, base)
 
def _is_valid_file (path)
 
def abspath (path, case_normalize=False)
 Replacement for os.path.abspath with some enhancements and bug fixes. More...
 
def find_file (path, basedir='.', file_type=None)
 
def get_link_path (target, base)
 Returns a relative path to target from base. More...
 
def normpath (path, case_normalize=False)
 Replacement for os.path.normpath with some enhancements. More...
 

Variables

bool CASE_INSENSITIVE_FILESYSTEM = True
 

Function Documentation

◆ _common_path()

def robot.utils.robotpath._common_path (   p1,
  p2 
)
private

Returns the longest path common to p1 and p2.

Rationale: as os.path.commonprefix is character based, it doesn't consider
path separators as such, so it may return invalid paths:
commonprefix(('/foo/bar/', '/foo/baz.txt')) -> '/foo/ba' (instead of /foo)

Definition at line 115 of file robotpath.py.

◆ _find_absolute_path()

def robot.utils.robotpath._find_absolute_path (   path)
private

Definition at line 147 of file robotpath.py.

◆ _find_relative_path()

def robot.utils.robotpath._find_relative_path (   path,
  basedir 
)
private

Definition at line 153 of file robotpath.py.

◆ _get_link_path()

def robot.utils.robotpath._get_link_path (   target,
  base 
)
private

Definition at line 86 of file robotpath.py.

◆ _is_valid_file()

def robot.utils.robotpath._is_valid_file (   path)
private

Definition at line 165 of file robotpath.py.

◆ abspath()

def robot.utils.robotpath.abspath (   path,
  case_normalize = False 
)

Replacement for os.path.abspath with some enhancements and bug fixes.

1. Non-Unicode paths are converted to Unicode using file system encoding.
2. Optionally lower-case paths on case-insensitive file systems.
   That includes Windows and also OSX in default configuration.
3. Turn ``c:`` into ``c:\\`` on Windows instead of ``c:\\current\\path``.

Definition at line 65 of file robotpath.py.

◆ find_file()

def robot.utils.robotpath.find_file (   path,
  basedir = '.',
  file_type = None 
)

Definition at line 132 of file robotpath.py.

◆ get_link_path()

def robot.utils.robotpath.get_link_path (   target,
  base 
)

Returns a relative path to target from base.

If ``base`` is an existing file, then its parent directory is considered to
be the base. Otherwise ``base`` is assumed to be a directory.

The returned path is URL encoded. On Windows returns an absolute path with
``file:`` prefix if the target is on a different drive.

Definition at line 78 of file robotpath.py.

◆ normpath()

def robot.utils.robotpath.normpath (   path,
  case_normalize = False 
)

Replacement for os.path.normpath with some enhancements.

1. Convert non-Unicode paths to Unicode using the file system encoding.
2. NFC normalize Unicode paths (affects mainly OSX).
3. Optionally lower-case paths on case-insensitive file systems.
   That includes Windows and also OSX in default configuration.
4. Turn ``c:`` into ``c:\\`` on Windows instead of keeping it as ``c:``.

Definition at line 46 of file robotpath.py.

Variable Documentation

◆ CASE_INSENSITIVE_FILESYSTEM

bool robot.utils.robotpath.CASE_INSENSITIVE_FILESYSTEM = True

Definition at line 30 of file robotpath.py.