envprobe.vartypes.path.Path
- class Path(name, raw_value='')
A POSIX-compatible
PATH
environment variable.PATH
variables are commonly used as list of locations (directories, and, rarely, files) on the filesystem in an order of precedence for finding various system elements.PATH
variables in POSIX are separated by:
, except in rare circumstances.This class extends
envprobe.vartypes.colon_separated.ColonSeparatedArray
with automatically converting the given paths (when the array is constructed or modified) to absolute paths, by callingos.path.abspath()
on the value.Symbolic links are kept and variable sequences such as
~
remain unexpanded, however, relative references (a/../b
tob
) are removed and the current working directory (os.getcwd()
) is prepended.Create a
Path
from the given raw_value.Methods
__init__
(name[, raw_value])Create a
Path
from the given raw_value.apply_diff
(diff)Applies the given diff actions.
diff
(old, new)Generate an iterable difference "actions" between two variables.
insert_at
(idx, elem)Insert the element at a given index.
merge_diff
(diff_a, diff_b)Merges the two diffs into a diff that simulates applying diff_a first and then diff_b.
raw
()Convert the value to raw shell representation, i.e. a
str
separated byseparator
.remove_value
(elem)Removes all occurrences of elem from the array.
type_description
()A list of directories (and sometimes files) separated by :, and automatically expanded to absolute paths.
Attributes
extended_attributes
Returns the object managing the extended attributes (user-facing knowledge) about the variable.
name
The name of the variable.
separator
Get the separator the object was instantiated with.
value
Get the copy of the value of the variable, as a
list
.