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


Python PersistentMapping.itervalues方法代码示例

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


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

示例1: PatchedDirectory

# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import itervalues [as 别名]
class PatchedDirectory (FileMeta):

    ftype = fs.DIRECTORY

    EXISTING = 0
    ADDED    = 1
    REMOVED  = 2
    
    def __init__(self, name, parent, uid, gid, mode, mtime_ns):
        FileMeta.__init__(self, name, parent, uid, gid, mode, mtime_ns)
        
        self.adds         = PersistentMapping()
        self.removes      = PersistentMapping()
        self.meta_changes = PersistentMapping() # name => ((to_uid, to_gid, to_mode), (from_uid, from_gid, from_mode))

        self.subdirs      = PersistentMapping()

        self.state        = PatchedDirectory.EXISTING

    def pdbg(self, indent = ''):
        s = { 0 : 'EXISTING', 1 : 'ADDED', 2 : 'REMOVED' }
        
        print indent, 'Dir %s %s' % (s[self.state], self.dbg_meta())
        
        if self.adds:
            print indent, ' ** Adds **'
            for v in self.adds.itervalues():
                v.pdbg( indent + '   ' )
        if self.removes:
            print indent, ' ** Removes **'
            for v in self.removes.itervalues():
                v.pdbg( indent + '   ' )

        if self.meta_changes:
            print indent, ' ** Meta Mods **'
            for k, v in self.removes.iteritems():
                print indent + '   ', k, v

        for s in self.subdirs.itervalues():
            s.pdbg( indent + '   ' )
开发者ID:cocagne,项目名称:scratch,代码行数:42,代码来源:types.py

示例2: Directory

# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import itervalues [as 别名]
class Directory (FileMeta):

    ftype = fs.DIRECTORY
    
    def __init__(self, name, parent, uid, gid, mode, mtime_ns):
        FileMeta.__init__(self, name, parent, uid, gid, mode, mtime_ns)
        
        self.content = PersistentMapping()


    def get_content_set(self):
        return set( (v.name, v.ftype) for v in self.content.itervalues() )

    def get_meta_set(self, filenames):
        s = set()
        for fn in filenames:
            v = self.content[ fn ]
            s.add( (v.name, v.uid, v.gid, v.mode) )
        return s
开发者ID:cocagne,项目名称:scratch,代码行数:21,代码来源:types.py

示例3: checkBasicOps

# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import itervalues [as 别名]
    def checkBasicOps(self):
        from persistent.mapping import PersistentMapping
        m = PersistentMapping({'x': 1}, a=2, b=3)
        m['name'] = 'bob'
        self.assertEqual(m['name'], "bob")
        self.assertEqual(m.get('name', 42), "bob")
        self.assert_('name' in m)

        try:
            m['fred']
        except KeyError:
            pass
        else:
            self.fail("expected KeyError")
        self.assert_('fred' not in m)
        self.assertEqual(m.get('fred'), None)
        self.assertEqual(m.get('fred', 42), 42)

        keys = m.keys()
        keys.sort()
        self.assertEqual(keys, ['a', 'b', 'name', 'x'])

        values = m.values()
        values.sort()
        self.assertEqual(values, [1, 2, 3, 'bob'])

        items = m.items()
        items.sort()
        self.assertEqual(items,
                         [('a', 2), ('b', 3), ('name', 'bob'), ('x', 1)])

        keys = list(m.iterkeys())
        keys.sort()
        self.assertEqual(keys, ['a', 'b', 'name', 'x'])

        values = list(m.itervalues())
        values.sort()
        self.assertEqual(values, [1, 2, 3, 'bob'])

        items = list(m.iteritems())
        items.sort()
        self.assertEqual(items,
                         [('a', 2), ('b', 3), ('name', 'bob'), ('x', 1)])
开发者ID:Andyvs,项目名称:TrackMonthlyExpenses,代码行数:45,代码来源:testPersistentMapping.py

示例4: checkBasicOps

# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import itervalues [as 别名]
    def checkBasicOps(self):
        from persistent.mapping import PersistentMapping

        m = PersistentMapping({"x": 1}, a=2, b=3)
        m["name"] = "bob"
        self.assertEqual(m["name"], "bob")
        self.assertEqual(m.get("name", 42), "bob")
        self.assert_("name" in m)

        try:
            m["fred"]
        except KeyError:
            pass
        else:
            self.fail("expected KeyError")
        self.assert_("fred" not in m)
        self.assertEqual(m.get("fred"), None)
        self.assertEqual(m.get("fred", 42), 42)

        keys = m.keys()
        keys.sort()
        self.assertEqual(keys, ["a", "b", "name", "x"])

        values = m.values()
        values.sort()
        self.assertEqual(values, [1, 2, 3, "bob"])

        items = m.items()
        items.sort()
        self.assertEqual(items, [("a", 2), ("b", 3), ("name", "bob"), ("x", 1)])

        keys = list(m.iterkeys())
        keys.sort()
        self.assertEqual(keys, ["a", "b", "name", "x"])

        values = list(m.itervalues())
        values.sort()
        self.assertEqual(values, [1, 2, 3, "bob"])

        items = list(m.iteritems())
        items.sort()
        self.assertEqual(items, [("a", 2), ("b", 3), ("name", "bob"), ("x", 1)])
开发者ID:grodniewicz,项目名称:oship,代码行数:44,代码来源:testPersistentMapping.py

示例5: Book

# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import itervalues [as 别名]
class Book( Persistent ):
    ''' This is a user book to include user's orders, one per user '''
    def __init__(self, user=None):
        self.user = user
        self.orders = PersistentList()
        self.positions = PersistentMapping()

    def addOrder(self, order):
        if order.instrument in self.positions:
            self.positions[order.instrument].append(order)
        else:
            self.positions[order.instrument] = PersistentList(order)

    def cost(self):
        cost=0.0
        for orders in self.positions.itervalues():
            cost += sum([o.cost() for o in orders])
        return

    def marketValue(self):
        mktval = 0.0
        for inst, orders in self.positions.iteritems():
            mktval += inst.marketPrice * sum([o.amountMatched for o in orders])
        return mktval
开发者ID:charlesbo,项目名称:cintra,代码行数:26,代码来源:books.py

示例6: Room

# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import itervalues [as 别名]

#.........这里部分代码省略.........
        roomsBTree = Room.getRoot()
        location = kwargs.get( 'location' )

        if kwargs.get( 'allFast' ) == True:
            return [ room for room in roomsBTree.values() if room.isActive and (not location or room.locationName == location) ]

        if kwargs.get( 'reallyAllFast' ) == True:
            return [ room for room in roomsBTree.values() if (not location or room.locationName == location) ]

        if len( kwargs ) == 0:
            ret_lst = []
            for room in roomsBTree.values():
                ret_lst.append( room )

        roomID = kwargs.get( 'roomID' )
        roomName = kwargs.get( 'roomName' )
        roomEx = kwargs.get( 'roomExample' )
        resvEx = kwargs.get( 'resvExample' )
        freeText = kwargs.get( 'freeText' )
        available = kwargs.get( 'available' )
        countOnly = kwargs.get( 'countOnly' )
        minCapacity = kwargs.get( 'minCapacity' )
        location = kwargs.get( 'location' )
        ownedBy = kwargs.get( 'ownedBy' )
        customAtts = kwargs.get( 'customAtts' )
#        responsibleID = kwargs.get( 'responsibleID' )
        pendingBlockings = kwargs.get( 'pendingBlockings' )

        ret_lst = []
        counter = 0
        if roomID != None:
            return roomsBTree.get( roomID )
        if roomName != None:
            for room in roomsBTree.itervalues():
                if room.name == roomName:
                    if location == None or room.locationName == location:
                        return room
            return None

        for room in roomsBTree.itervalues():
            # Apply all conditions =========
            if location != None:
                if room.locationName != location:
                    continue
            if roomEx != None:
                if not qbeMatch( roomEx, room, Room.__attrSpecialEqual, minCapacity = minCapacity ):
                    continue
                if not room.__hasEquipment( roomEx.getEquipment() ):
                    continue
            if freeText != None:
                if not room.__hasFreeText( freeText.split() ):
                    continue
            if resvEx != None:
                resvEx.room = room
                aval = room.isAvailable( resvEx )
                if aval != available:
                    continue
                blockState = resvEx.getBlockingConflictState(ContextManager.get('currentUser'))
                if blockState == 'active':
                    continue
                elif blockState == 'pending' and pendingBlockings:
                    continue
            if ownedBy != None:
                if not room.isOwnedBy( ownedBy ):
                    continue
            if customAtts is not None:
开发者ID:aninhalacerda,项目名称:indico,代码行数:70,代码来源:room.py

示例7: Room

# 需要导入模块: from persistent.mapping import PersistentMapping [as 别名]
# 或者: from persistent.mapping.PersistentMapping import itervalues [as 别名]

#.........这里部分代码省略.........

        roomsBTree = Room.getRoot()
        location = kwargs.get( 'location' )

        if kwargs.get( 'allFast' ) == True:
            return [ room for room in roomsBTree.values() if room.isActive and (not location or room.locationName == location) ]

        if kwargs.get( 'reallyAllFast' ) == True:
            return [ room for room in roomsBTree.values() if (not location or room.locationName == location) ]
        
        if len( kwargs ) == 0:
            ret_lst = []
            for room in roomsBTree.values():
                ret_lst.append( room )

        roomID = kwargs.get( 'roomID' )
        roomName = kwargs.get( 'roomName' )
        roomEx = kwargs.get( 'roomExample' )
        resvEx = kwargs.get( 'resvExample' )
        freeText = kwargs.get( 'freeText' )
        available = kwargs.get( 'available' )
        countOnly = kwargs.get( 'countOnly' )
        minCapacity = kwargs.get( 'minCapacity' )
        location = kwargs.get( 'location' )
        ownedBy = kwargs.get( 'ownedBy' )
        customAtts = kwargs.get( 'customAtts' )
#        responsibleID = kwargs.get( 'responsibleID' )
        
        ret_lst = []
        counter = 0
        if roomID != None:
            return roomsBTree.get( roomID )
        if roomName != None:
            for room in roomsBTree.itervalues():
                if room.name == roomName:
                    if location == None or room.locationName == location:
                        return room
            return None
        
        for room in roomsBTree.itervalues():
            # Apply all conditions =========
            if location != None:
                if room.locationName != location:
                    continue            
            if roomEx != None:
                if not qbeMatch( roomEx, room, Room.__attrSpecialEqual, minCapacity = minCapacity ):
                    continue
                if not room.__hasEquipment( roomEx.getEquipment() ):
                    continue
            if freeText != None:
                if not room.__hasFreeText( freeText.split() ):
                    continue
            if resvEx != None:
                resvEx.room = room
                aval = room.isAvailable( resvEx )
                if aval != available:
                    continue
            if ownedBy != None:
                if not room.isOwnedBy( ownedBy ):
                    continue
            if customAtts is not None:
                if not hasattr(room, "customAtts"):
                    continue
                discard = False
                for condition in customAtts:
                    attName = condition["name"]
开发者ID:davidmorrison,项目名称:indico,代码行数:70,代码来源:room.py


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