本文整理匯總了Python中pip._vendor.ordereddict.OrderedDict方法的典型用法代碼示例。如果您正苦於以下問題:Python ordereddict.OrderedDict方法的具體用法?Python ordereddict.OrderedDict怎麽用?Python ordereddict.OrderedDict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pip._vendor.ordereddict
的用法示例。
在下文中一共展示了ordereddict.OrderedDict方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: normalizeToken
# 需要導入模塊: from pip._vendor import ordereddict [as 別名]
# 或者: from pip._vendor.ordereddict import OrderedDict [as 別名]
def normalizeToken(self, token):
""" HTML5 specific normalizations to the token stream """
if token["type"] == tokenTypes["StartTag"]:
raw = token["data"]
token["data"] = OrderedDict(raw)
if len(raw) > len(token["data"]):
# we had some duplicated attribute, fix so first wins
token["data"].update(raw[::-1])
return token
示例2: adjust_attributes
# 需要導入模塊: from pip._vendor import ordereddict [as 別名]
# 或者: from pip._vendor.ordereddict import OrderedDict [as 別名]
def adjust_attributes(token, replacements):
if PY3 or _utils.PY27:
needs_adjustment = viewkeys(token['data']) & viewkeys(replacements)
else:
needs_adjustment = frozenset(token['data']) & frozenset(replacements)
if needs_adjustment:
token['data'] = OrderedDict((replacements.get(k, k), v)
for k, v in token['data'].items())