本文整理汇总了Python中future.utils.itervalues方法的典型用法代码示例。如果您正苦于以下问题:Python utils.itervalues方法的具体用法?Python utils.itervalues怎么用?Python utils.itervalues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类future.utils
的用法示例。
在下文中一共展示了utils.itervalues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def __init__(self, path_response, list_id=None):
# common.debug('VideoList data: {}', path_response)
self.perpetual_range_selector = path_response.get('_perpetual_range_selector')
self.data = path_response
has_data = bool(path_response.get('lists'))
self.videos = OrderedDict()
self.artitem = None
self.contained_titles = None
self.videoids = None
if has_data:
# Generate one videoid, or from the first id of the list or with specified one
self.videoid = common.VideoId(
videoid=(list_id
if list_id
else next(iter(self.data['lists']))))
self.videos = OrderedDict(resolve_refs(self.data['lists'][self.videoid.value], self.data))
if self.videos:
# self.artitem = next(itervalues(self.videos))
self.artitem = listvalues(self.videos)[0]
self.contained_titles = _get_titles(self.videos)
try:
self.videoids = _get_videoids(self.videos)
except KeyError:
self.videoids = None
示例2: __iter__
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def __iter__(self):
for value in itervalues(self._backing):
yield value
示例3: added
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def added(self):
return itervalues(self._added)
示例4: removed
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def removed(self):
return itervalues(self._removed)
示例5: get_available_audio_languages
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def get_available_audio_languages():
"""Get the list of available audio languages of videos"""
call_args = {
'paths': [['spokenAudioLanguages', {'from': 0, 'to': 25}, ['id', 'name']]]
}
response = common.make_call('path_request', call_args)
lang_list = {}
for lang_dict in itervalues(response.get('spokenAudioLanguages', {})):
lang_list[lang_dict['id']] = lang_dict['name']
return lang_list
示例6: get_available_subtitles_languages
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def get_available_subtitles_languages():
"""Get the list of available subtitles languages of videos"""
call_args = {
'paths': [['subtitleLanguages', {'from': 0, 'to': 25}, ['id', 'name']]]
}
response = common.make_call('path_request', call_args)
lang_list = {}
for lang_dict in itervalues(response.get('subtitleLanguages', {})):
lang_list[lang_dict['id']] = lang_dict['name']
return lang_list
示例7: _get_titles
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def _get_titles(videos):
"""Return a list of videos' titles"""
return [_get_title(video)
for video in itervalues(videos)
if _get_title(video)]
示例8: _get_videoids
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def _get_videoids(videos):
"""Return a list of VideoId s for the videos"""
return [common.VideoId.from_videolist_item(video)
for video in itervalues(videos)]
示例9: _parse_tags
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def _parse_tags(item):
"""Parse the tags"""
return {'tag': [tagdef['name']
for tagdef
in itervalues(item.get('tags', {}))
if isinstance(tagdef.get('name', {}), unicode)]}
示例10: clear
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def clear(self):
'od.clear() -> None. Remove all items from od.'
try:
for node in itervalues(self.__map):
del node[:]
root = self.__root
root[:] = [root, root, None]
self.__map.clear()
except AttributeError:
pass
dict.clear(self)
示例11: itervalues
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def itervalues(self):
'od.itervalues -> an iterator over the values in od'
for k in self:
yield self[k]
示例12: categorize_columns
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def categorize_columns(self):
self.partition_cols = []
self.clustering_cols = []
self.regular_cols = []
self.static_cols = []
for i in itervalues(self.columns):
if i.cql_type == "partition_key":
self.partition_cols.append(i)
next
if i.cql_type == "clustering_key":
self.clustering_cols.append(i)
next
if i.cql_type == "regular":
self.regular_cols.append(i)
next
if i.cql_type == "static":
self.static_cols.append(i)
next
self.partition_cols = self.sort_columns(self.partition_cols)
self.clustering_cols = self.sort_columns(self.clustering_cols, reverse=True)
cluster_str = self.regular_cols
for i in self.clustering_cols:
cluster_str = [i, cluster_str]
#partition_cols = paste([i.name for i in partition_cols])
return self.partition_cols,[cluster_str, self.static_cols]
#TODO utilize TableMeta.describe to implement the same thing for keyspaces
示例13: extract_utterance_entities
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def extract_utterance_entities(dataset):
entities_values = {ent_name: set() for ent_name in dataset[ENTITIES]}
for intent in itervalues(dataset[INTENTS]):
for utterance in intent[UTTERANCES]:
for chunk in utterance[DATA]:
if ENTITY in chunk:
entities_values[chunk[ENTITY]].add(chunk[TEXT].strip())
return {k: list(v) for k, v in iteritems(entities_values)}
示例14: get_intents
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def get_intents(self, text):
"""Performs intent classification on the provided *text* and returns
the list of intents ordered by decreasing probability
The length of the returned list is exactly the number of intents in the
dataset + 1 for the None intent
.. note::
The probabilities returned along with each intent are not
guaranteed to sum to 1.0. They should be considered as scores
between 0 and 1.
"""
results = None
for parser in self.intent_parsers:
parser_results = parser.get_intents(text)
if results is None:
results = {res[RES_INTENT_NAME]: res for res in parser_results}
continue
for res in parser_results:
intent = res[RES_INTENT_NAME]
proba = max(res[RES_PROBA], results[intent][RES_PROBA])
results[intent][RES_PROBA] = proba
return sorted(itervalues(results), key=lambda res: -res[RES_PROBA])
示例15: remove_builtin_slots
# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import itervalues [as 别名]
def remove_builtin_slots(dataset):
filtered_dataset = deepcopy(dataset)
for intent_data in itervalues(filtered_dataset[INTENTS]):
for utterance in intent_data[UTTERANCES]:
utterance[DATA] = [
chunk for chunk in utterance[DATA]
if ENTITY not in chunk or not is_builtin_entity(chunk[ENTITY])]
return filtered_dataset