Path¶
Option_merge uses this Path object to encapsulate the idea of a path and the converters that are available to use.
We are able to use this to store a reference to the root of the configuration as well as whether the converters should be ignored or not.
It’s purpose is to behave like a string regardless of whether it is a string or a list of strings.
Instantiation¶
-
classmethod
Path.
convert
(path, configuration=None, converters=None, ignore_converters=None, joined=None)¶ Get us a Path object from this path
If path is already a Path instance, it is returned as is.
Otherwise, a joined version of the string is created and used, along with the other kwargs to this function, to produce a new Path instance
Instance Methods¶
-
class
option_merge.path.
Path
(path, configuration=None, converters=None, ignore_converters=False, joined=None, joined_function=None)¶ Encapsulate a path; a root configuration; a list of converters; and whether the converters should be used or not
A path may be just a string or a list of strings.
-
__add__
(other)¶ Create a copy of this path joined with other
-
__eq__
(other)¶ Compare the joined version of this path and the joined version of the other path
-
__getitem__
(key)¶ If the path is a string, treat it as a list of that one string, otherwise, treat path as it is and get the index of the path as specified by key
-
__hash__
()¶ The hash of the joined version of this path
-
__iter__
()¶ Iterate through the parts of our path
-
__len__
()¶ The length of our path
- If we have no path, then 0
- if path is a string, then 1
- if path is an array, then the length of the array
-
__ne__
(other)¶ Negation of whether other is equal to this path
-
__nonzero__
()¶ Whether we have any path or not
-
__str__
()¶ alias for self.joined
-
__unicode__
()¶ alias for self.joined
-
clone
()¶ Return a clone of this path with all the same values
-
converted
()¶ Determine if this path has been converted
-
converted_val
()¶ Return the converted value for this path
-
do_conversion
(value)¶ Do the conversion on some path if any conversion exists
Return (converted, did_conversion)
Where
did_conversion
is a boolean indicating whether a conversion took place.
-
do_conversion
(value) Do the conversion on some path if any conversion exists
Return (converted, did_conversion)
Where
did_conversion
is a boolean indicating whether a conversion took place.
-
endswith
(suffix)¶ Does the path end with this string?
-
find_converter
()¶ Find appropriate converter for this path
-
first_part_is
(key)¶ Return whether the first part of this path is this string
-
ignoring_converters
(ignore_converters=True)¶ Return a clone of this path with ignore_converters set to True
-
joined
()¶ Return the dot_join of of the path
-
prefixed
(prefix)¶ Return a clone with this prefix to the path
-
startswith
(base)¶ Does the path start with this string?
-
waiting
()¶ Return whether we’re waiting for this value
-
without
(base)¶ Return a clone of this path without the base
-