drepr.models.parsers.v2.path_parser#

Classes

PathParserV2()

Similar to path parser v1.

class PathParserV2[source]#

Bases: PathParser

Similar to path parser v1. However, we now allow special using indexing name per resource type

For spreadsheet, we allow column to be letter

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: Optional[Resource], path: Any, parse_trace: str) Path[source]#
Parameters:
Return type:

Path

letter2index(letter: str) int[source]#
Parameters:

letter (str) –

Return type:

int

isdigit(s: str) bool[source]#
Parameters:

s (str) –

Return type:

bool

parse_jsonpath(resource: Optional[Resource], jpath: str, parse_trace: str) Path[source]#
Parameters:
Return type:

Path

parse_custom_path(resource: Optional[Resource], 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