def __safe_path__(path, separator):
if issubclass(path.__class__, (MutableSequence)):<EOL><INDENT>return path<EOL><DEDENT>path = path.lstrip(separator).split(separator)<EOL>validated = []<EOL>for elem in path:<EOL><INDENT>key = elem[<NUM_LIT:0>]<EOL>strkey = str(key)<EOL>if (separator and (separator in strkey)):<EOL><INDENT>raise dpath.exceptions.InvalidKeyName("<STR_LIT>"<EOL>"<STR_LIT>".format(strkey,<EOL>separator.join(validated),<EOL>separator))<EOL><DEDENT>validated.append(strkey)<EOL><DEDENT>return path<EOL>
Given a path and separator, return a list of path components. If path
is already a list, return it.

Note that a string path with the separator at index[0] will have the
separator stripped off. If you pass a list path, the separator is
ignored, and is assumed to be part of each key glob. It will not be
stripped.