本文整理汇总了Python中jsonpointer.JsonPointer.resolve方法的典型用法代码示例。如果您正苦于以下问题:Python JsonPointer.resolve方法的具体用法?Python JsonPointer.resolve怎么用?Python JsonPointer.resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonpointer.JsonPointer
的用法示例。
在下文中一共展示了JsonPointer.resolve方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
# 需要导入模块: from jsonpointer import JsonPointer [as 别名]
# 或者: from jsonpointer.JsonPointer import resolve [as 别名]
def add(self, name, value, *ignored_args, **ignored_kwargs):
""" Adds a new JSON Pointer expression to the store.
"""
# Make sure it's valid, no exception in 'resolve' means the expression was valid.
pointer = JsonPointer(value)
pointer.resolve({}, None)
with self.update_lock:
self.data[name] = pointer
示例2: createOffsetMeta
# 需要导入模块: from jsonpointer import JsonPointer [as 别名]
# 或者: from jsonpointer.JsonPointer import resolve [as 别名]
def createOffsetMeta(offset, bookkeeping):
'''
sets up a location to track rule and step ids for a given scope offset
'''
pointer = JsonPointer(offset)
view = bookkeeping
for x in pointer.parts:
view = view.setdefault(x,{})
pointer.resolve(bookkeeping).setdefault('_meta',{'stages': [], 'steps': []})
示例3: addRule
# 需要导入模块: from jsonpointer import JsonPointer [as 别名]
# 或者: from jsonpointer.JsonPointer import resolve [as 别名]
def addRule(self, rule, offset='', identifier = None):
'''
add a DAG extension rule, possibly with a scope offset
'''
thisoffset = JsonPointer(offset)
if offset != '':
createIndexData(thisoffset.path, self.steps, self.values)
createOffsetMeta(thisoffset.path, self.bookkeeper)
offsetstage = OffsetStage(rule, self._makeoffset(offset), identifier = identifier)
self.rules += [offsetstage]
thisoffset.resolve(self.bookkeeper)['_meta']['stages'] += [offsetstage.identifier]
return offsetstage.identifier
示例4: resolve
# 需要导入模块: from jsonpointer import JsonPointer [as 别名]
# 或者: from jsonpointer.JsonPointer import resolve [as 别名]
def resolve(self, doc, default=jsonpointer._nothing):
if self.isHash:
if len(self.parts) == 1:
refdata = doc
else:
p = JsonPointer('/' + '/'.join(self.parts[:-1]))
refdata = p.resolve(doc)
if isinstance(refdata, list):
return int(self.parts[-1])
else:
return self.parts[-1]
else:
return super(RelJsonPointer, self).resolve(doc, default)
示例5: createIndexData
# 需要导入模块: from jsonpointer import JsonPointer [as 别名]
# 或者: from jsonpointer.JsonPointer import resolve [as 别名]
def createIndexData(offset, stepindex, valueindex):
pointer = JsonPointer(offset)
pointer.resolve(stepindex)['_offset'] = offset
pointer.set(valueindex, {})