summaryrefslogtreecommitdiff
path: root/redis/commands/json/path.py
blob: dff86482dfa819b87f95b304e6e942622a2727ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def str_path(p):
    """Return the string representation of a path if it is of class Path."""
    if isinstance(p, Path):
        return p.strPath
    else:
        return p


class Path(object):
    """This class represents a path in a JSON value."""

    strPath = ""

    @staticmethod
    def rootPath():
        """Return the root path's string representation."""
        return "."

    def __init__(self, path):
        """Make a new path based on the string representation in `path`."""
        self.strPath = path