当前位置: 首页>>代码示例>>Python>>正文


Python OrderedSet.add方法代码示例

本文整理汇总了Python中django.utils.datastructures.OrderedSet.add方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedSet.add方法的具体用法?Python OrderedSet.add怎么用?Python OrderedSet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.datastructures.OrderedSet的用法示例。


在下文中一共展示了OrderedSet.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: navigation_event_ids_by_user

# 需要导入模块: from django.utils.datastructures import OrderedSet [as 别名]
# 或者: from django.utils.datastructures.OrderedSet import add [as 别名]
def navigation_event_ids_by_user(user, start_date=None, end_date=None):
    database = NavigationEventAudit.get_db()

    def _date_key(date):
        return [date.year, date.month, date.day]

    startkey = [user]
    if start_date:
        startkey.extend(_date_key(start_date))

    endkey = [user]
    if end_date:
        end = end_date + timedelta(days=1)
        endkey.extend(_date_key(end))
    else:
        endkey.append({})

    ids = OrderedSet()
    results = database.view(
        'auditcare/urlpath_by_user_date',
        startkey=startkey,
        endkey=endkey,
        reduce=False,
        include_docs=False,
    )
    for row in results:
        ids.add(row['id'])
    return ids
开发者ID:dimagi,项目名称:commcare-hq,代码行数:30,代码来源:export.py

示例2: test_len

# 需要导入模块: from django.utils.datastructures import OrderedSet [as 别名]
# 或者: from django.utils.datastructures.OrderedSet import add [as 别名]
 def test_len(self):
     s = OrderedSet()
     self.assertEqual(len(s), 0)
     s.add(1)
     s.add(2)
     s.add(2)
     self.assertEqual(len(s), 2)
开发者ID:velis74,项目名称:django,代码行数:9,代码来源:test_datastructures.py

示例3: merge

# 需要导入模块: from django.utils.datastructures import OrderedSet [as 别名]
# 或者: from django.utils.datastructures.OrderedSet import add [as 别名]
    def merge(*lists):
        """
        Merge lists while trying to keep the relative order of the elements.
        Warn if the lists have the same elements in a different relative order.

        For static assets it can be important to have them included in the DOM
        in a certain order. In JavaScript you may not be able to reference a
        global or in CSS you might want to override a style.
        """
        dependency_graph = defaultdict(set)
        all_items = OrderedSet()
        for list_ in filter(None, lists):
            head = list_[0]
            # The first items depend on nothing but have to be part of the
            # dependency graph to be included in the result.
            dependency_graph.setdefault(head, set())
            for item in list_:
                all_items.add(item)
                # No self dependencies
                if head != item:
                    dependency_graph[item].add(head)
                head = item
        try:
            return stable_topological_sort(all_items, dependency_graph)
        except CyclicDependencyError:
            warnings.warn(
                'Detected duplicate Media files in an opposite order: {}'.format(
                    ', '.join(repr(l) for l in lists)
                ), MediaOrderConflictWarning,
            )
            return list(all_items)
开发者ID:MattBlack85,项目名称:django,代码行数:33,代码来源:widgets.py

示例4: get_parent_list

# 需要导入模块: from django.utils.datastructures import OrderedSet [as 别名]
# 或者: from django.utils.datastructures.OrderedSet import add [as 别名]
 def get_parent_list(self):
     """
     Return all the ancestors of this model as a list ordered by MRO.
     Useful for determining if something is an ancestor, regardless of lineage.
     """
     result = OrderedSet(self.parents)
     for parent in self.parents:
         for ancestor in parent._meta.get_parent_list():
             result.add(ancestor)
     return list(result)
开发者ID:agmond,项目名称:django,代码行数:12,代码来源:options.py

示例5: test_bool

# 需要导入模块: from django.utils.datastructures import OrderedSet [as 别名]
# 或者: from django.utils.datastructures.OrderedSet import add [as 别名]
 def test_bool(self):
     # Refs #23664
     s = OrderedSet()
     self.assertFalse(s)
     s.add(1)
     self.assertTrue(s)
开发者ID:carlio,项目名称:django,代码行数:8,代码来源:test_datastructures.py


注:本文中的django.utils.datastructures.OrderedSet.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。