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


Python GangaList.remove方法代码示例

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


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

示例1: TestGangaList

# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import remove [as 别名]

#.........这里部分代码省略.........
    def testAppend(self):

        t = addProxy(TFile(name='foo'))

        self.plain1.append(t)
        assert self.plain1[-1] == t
        assert self.plain1.pop() == t

        self.proxied1.append(t)
        assert self.proxied1[-1] == t
        assert self.proxied1[-1] is t, 'Identity Test'
        assert isProxy(self.proxied1[-1]), 'Make sure we get back a proxy'
        assert self.proxied1.pop() == t

    def testExtend(self):

        t1 = [self._makeRandomTFile() for _ in xrange(10)]

        self.plain1.extend(t1)
        self.proxied1.extend(t1)

        assert self.plain1 == self.proxied1, 'Lists should be the same'

        t2 = self.proxied1[4:7]
        assert isProxy(t2)
        from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList as glist
        assert isType(t2, glist)
        self.plain1.extend(t2)
        self.proxied1.extend(t2)
        assert self.plain1 == self.proxied1, 'Lists should be the same'

    def testIndex(self):

        t = addProxy(TFile(name='foo'))
        self.proxied1.insert(8, t)
        assert self.proxied1[8] == t
        assert self.proxied1.index(t) == 8

    def testInsert(self):

        t = addProxy(TFile(name='foo'))
        self.proxied1.insert(8, t)
        assert self.proxied1[8] == t

    def testPop(self):

        list_len = len(self.proxied1)

        t = self.proxied1[-1]
        r = self.proxied1.pop()
        assert t == r
        assert t is r
        assert len(self.proxied1) == list_len - 1
        assert t not in self.proxied1
        assert t._impl not in self.proxied1._impl

        t = self.proxied1[6]
        r = self.proxied1.pop(6)
        assert t == r
        assert t is r
        assert len(self.proxied1) == list_len - 2
        assert t not in self.proxied1
        assert t._impl not in self.proxied1._impl

    def testRemove(self):

        t = addProxy(TFile(name='bar'))
        self.proxied1.insert(7, t)
        list_len = len(self.proxied1)

        self.proxied1.remove(t)

        assert len(self.proxied1) == list_len - 1
        assert t not in self.proxied1
        assert t._impl not in self.proxied1._impl

    def testIter(self):

        from TFile import TFile as tF

        count = 0
        for f in self.proxied1:
            count += 1
            assert isProxy(f)
            assert isType(f, tF)

        assert count == len(self.proxied1), 'Must visit every member'

    def testCmp(self):

        assert cmp(self.proxied1, self.proxied2) == cmp(
            self.plain1, self.plain2)

    def testHash(self):

        try:
            hash(int(self.proxied1))
            assert False, 'Lists are not hashable'
        except TypeError:
            pass
开发者ID:chrisburr,项目名称:ganga,代码行数:104,代码来源:TestGangaList.py

示例2: LHCbDataset

# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import remove [as 别名]

#.........这里部分代码省略.........
                logger.warning(msg)
                logger.warning("Error: %s" % str(err))
                retry_files.append(f)

        for f in retry_files:
            try:
                result = f.replicate( destSE=destSE )
            except Exception as err:
                msg = '2nd replication attempt failed for file %s. (will not retry)' % f.lfn
                logger.warning(msg)
                logger.warning(str(err))

    def extend(self, files, unique=False):
        '''Extend the dataset. If unique, then only add files which are not
        already in the dataset.'''
        from Ganga.GPIDev.Base import ReadOnlyObjectError

        if self._parent is not None and self._parent._readonly():
            raise ReadOnlyObjectError('object Job#%s  is read-only and attribute "%s/inputdata" cannot be modified now' % (self._parent.id, getName(self)))

        _external_files = []

        if type(files) is str or isType(files, IGangaFile):
            _external_files = [files]
        elif type(files) in [list, tuple]:
            _external_files = files
        elif isType(files, LHCbDataset):
            _external_files = files.files
        else:
            if not hasattr(files, "__getitem__") or not hasattr(files, '__iter__'):
                _external_files = [files]

        # just in case they extend w/ self
        _to_remove = []
        for this_file in _external_files:
            if hasattr(this_file, 'subfiles'):
                if len(this_file.subfiles) > 0:
                    _external_files = makeGangaListByRef(this_file.subfiles)
                    _to_remove.append(this_file)
            if type(this_file) is str:
                _external_files.append(string_datafile_shortcut_lhcb(this_file, None))
                _to_remove.append(this_file)

        for _this_file in _to_remove:
            _external_files.pop(_external_files.index(_this_file))

        for this_f in _external_files:
            _file = getDataFile(this_f)
            if _file is None:
                _file = this_f
            myName = _file.namePattern
            from GangaDirac.Lib.Files.DiracFile import DiracFile
            if isType(_file, DiracFile):
                myName = _file.lfn
            if unique and myName in self.getFileNames():
                continue
            self.files.append(stripProxy(_file))

    def removeFile(self, input_file):
        try:
            self.files.remove(input_file)
        except:
            raise GangaException('Dataset has no file named %s' % input_file.namePattern)

    def getLFNs(self):
        'Returns a list of all LFNs (by name) stored in the dataset.'
开发者ID:ganga-devs,项目名称:ganga,代码行数:70,代码来源:LHCbDataset.py

示例3: TestGangaList

# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import remove [as 别名]

#.........这里部分代码省略.........
        tmp = self.proxied1[2:9]
        self.assertIsNot(self.proxied1[2:9], tmp)

    def testAppend(self):

        t = TFile(name='foo')

        self.plain1.append(t)
        self.assertEqual(self.plain1[-1], t)
        self.assertEqual(self.plain1.pop(), t)

        self.proxied1.append(t)
        self.assertEqual(self.proxied1[-1], t)
        self.assertIs(self.proxied1[-1], t, 'Identity Test')
        self.assertTrue(isProxy(self.proxied1[-1]), 'Make sure we get back a proxy')
        self.assertEqual(self.proxied1.pop(), t)

    def testExtend(self):

        t1 = [self._makeRandomTFile() for _ in xrange(10)]

        self.plain1.extend(t1)
        self.proxied1.extend(t1)

        self.assertEqual(self.plain1, self.proxied1, 'Lists should be the same')

        t2 = self.proxied1[4:7]
        self.assertTrue(isProxy(t2))
        from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList as glist
        self.assertTrue(isType(t2, glist))
        self.plain1.extend(t2)
        self.proxied1.extend(t2)
        self.assertEqual(self.plain1, self.proxied1, 'Lists should be the same')

    def testIndex(self):

        t = TFile(name='foo')
        self.proxied1.insert(8, t)
        self.assertEqual(self.proxied1[8], t)
        self.assertEqual(self.proxied1.index(t), 8)

    def testInsert(self):

        t = TFile(name='foo')
        self.proxied1.insert(8, t)
        self.assertEqual(self.proxied1[8], t)

    def testPop(self):

        list_len = len(self.proxied1)

        t = self.proxied1[-1]
        r = self.proxied1.pop()
        self.assertEqual(t, r)
        self.assertIs(t, r)
        self.assertEqual(len(self.proxied1), list_len - 1)
        self.assertNotIn(t, self.proxied1)
        self.assertNotIn(t._impl, self.proxied1._impl)

        t = self.proxied1[6]
        r = self.proxied1.pop(6)
        self.assertEqual(t, r)
        self.assertIs(t, r)
        self.assertEqual(len(self.proxied1), list_len - 2)
        self.assertNotIn(t, self.proxied1)
        self.assertNotIn(t._impl, self.proxied1._impl)

    def testRemove(self):

        t = TFile(name='bar')
        self.proxied1.insert(7, t)
        list_len = len(self.proxied1)

        self.proxied1.remove(t)

        self.assertEqual(len(self.proxied1), list_len - 1)
        self.assertNotIn(t, self.proxied1)
        self.assertNotIn(t._impl, self.proxied1._impl)

    def testIter(self):

        count = 0
        for f in self.proxied1:
            count += 1
            self.assertTrue(isProxy(f))
            self.assertTrue(isType(f, TFile))

        self.assertEqual(count, len(self.proxied1), 'Must visit every member')

    def testCmp(self):

        self.assertEqual(cmp(self.proxied1, self.proxied2), cmp(self.plain1, self.plain2))

    def testHash(self):

        try:
            hash(int(self.proxied1))
            assert False, 'Lists are not hashable'
        except TypeError:
            pass
开发者ID:Erni1619,项目名称:ganga,代码行数:104,代码来源:TestGangaList.py


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