drepr.models.parsers.v1.path_parser#

Classes

PathParserV1()

A path can either be a JSONPath or our list path

class PathParserV1[source]#

Bases: PathParser

A path can either be a JSONPath or our list path

  1. If the path is a JSONPath, then it is a string startswith $. We only support the following type of step: range, index, list of index, and wildcard. However, wildcard is only used for selecting all values of an object

  2. If the path is a normal string

REG_SRANGE = re.compile('^(\\d+)?\\.\\.(-?\\d+)?(?::(\\d+))?$')#
REG_SINDEX = re.compile('^(?:\\$\\{([^}]+)})|(\\d+)|(.*)$')#
REG_SRANGE_EXPR = re.compile('^(?:(\\d+)|(?:\\$\\{([^}]+)}))?\\.\\.(?:(-\\d+)|(?:\\$\\{([^}]+)}))?(?::(\\d+)|(?:\\$\\{([^}]+)}))?$')#
REG_JPATH_BRACKET = re.compile("(?:\\[(-?\\d+)?\\:(?:(-?\\d+)(?:\\:(-?\\d+))?)?\\])|(?:\\[(-?\\d+)\\])|(?:\\['([^']+)'\\])")#
REG_JPATH_DOT = re.compile('\\.((?:(?!\\.|\\[).)+)')#
parse(_resource: Resource, path: Union[str, list], parse_trace: str) Path[source]#
Parameters:
Return type:

Path

parse_jsonpath(jpath: str, parse_trace: str) Path[source]#
Parameters:
  • jpath (str) –

  • parse_trace (str) –

Return type:

Path

parse_custom_path(path: List[str], parse_trace: str) Path[source]#
Parameters:
Return type:

Path

get_resource(resources: List[Resource], resource_id: str, trace: str) Resource#
Parameters:
Return type:

Resource