33 lines
739 B
Python
33 lines
739 B
Python
import typing
|
|
|
|
|
|
class Labels:
|
|
def __init__(self, map: typing.Mapping[str, str]):
|
|
self._map = map
|
|
self._key = '{{{0}}}'.format(','.join(
|
|
['{0}="{1}"'.format(
|
|
k, v.replace('\\', r'\\').replace('\n', r'\n').replace('"', r'\"'))
|
|
for k, v in sorted(map.items())]))
|
|
|
|
@property
|
|
def key(self) -> str:
|
|
return self._key
|
|
|
|
@property
|
|
def map(self) -> typing.Mapping[str, str]:
|
|
return self._map
|
|
|
|
|
|
class Path:
|
|
def __init__(self, name, labels={}):
|
|
self._name = name
|
|
self._labels = Labels(labels)
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
return self._name
|
|
|
|
@property
|
|
def labels(self) -> Labels:
|
|
return self._labels
|