コード例 #1
0
ファイル: session.py プロジェクト: jgcumming/gnmi-py
    def _parse_path(self, path):
        if not path:
            path = Path_.from_string(path)
        elif isinstance(path, Path_):
            path = path
        elif isinstance(path, str):
            path = Path_.from_string(path)
        elif isinstance(path, (list, tuple)):
            path = Path_.from_string("/".join(path))
        else:
            raise ValueError("Failed to parse path: %s" % str(path))

        return path.raw
コード例 #2
0
ファイル: session.py プロジェクト: jgcumming/gnmi-py
    def _build_update(self, update):
        if isinstance(update, (Update_, Path_)):
            update = update
        if isinstance(update, str):
            update = Path_.from_string(update)
        elif isinstance(update, (list, tuple)):
            update = Update_.from_keyval(update)

        return update.raw
コード例 #3
0
def test_gnmi_path():
    paths = [
        "/system/nsftuff", "origin:/some/other/path",
        "/path/with/some[key=val-ue]/more[key=ssss]"
    ]
    for path in paths:
        pobj = Path_.from_string(path)
        pstr = pobj.to_string()

        [(e.name, e.key) for e in pobj.elem]

        assert path == pstr
コード例 #4
0
ファイル: test_messages.py プロジェクト: jgcumming/gnmi-py
def test_gnmi_path():
    paths = [
        "/system/nsftuff",
        "origin:/some/other/path",
        "/path/with/some[key=val-ue][df=sdf]/more[key=ssss]"
    ]
    for path in paths:
        pobj = Path_.from_string(path)
        pstr = pobj.to_string()

        print([(e.name, e.key) for e in pobj.elements])
        print(pstr)
        print(str(path))
        print(pobj.raw)
コード例 #5
0
    def _parse_path(
            self, path: Optional[Union[Path_, pb.Path, str, list,
                                       tuple]]) -> pb.Path:

        if path is None:
            path = ""
        elif isinstance(path, (list, tuple)):
            path = "/".join(list(path))

        if isinstance(path, str):
            return Path_.from_string(path).raw
        elif isinstance(path, Path_):
            return path.raw
        elif isinstance(path, pb.Path):
            return path
        else:
            raise ValueError("Failed to parse path: %s" % str(path))
コード例 #6
0
ファイル: test_gnmi.py プロジェクト: jgcumming/gnmi-py
def paths():
    return [Path_.from_string(p) for p in GNMI_PATHS.split(";")]