當前位置: 首頁>>代碼示例>>Python>>正文


Python iconscollection.IconsCollection類代碼示例

本文整理匯總了Python中outwiker.core.iconscollection.IconsCollection的典型用法代碼示例。如果您正苦於以下問題:Python IconsCollection類的具體用法?Python IconsCollection怎麽用?Python IconsCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IconsCollection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testAddIcons_19_resize

    def testAddIcons_19_resize(self):
        files = ['16x16.png',
                 '16x15.png',
                 '16x17.png',
                 '15x16.png',
                 '17x16.png',
                 '17x17.png',
                 '15x15.png',
                 '8x8.png',
                 '8x16.png',
                 '16x8.png',
                 'first.png',
                 'first_vertical.png']

        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addIcons(None, fullPaths)

        icons = sorted(collection.getIcons(None))
        self.assertEqual(len(icons), 12)

        icons = {fname: os.path.join(self.tempDir1, fname) for fname in files}

        for fname in files:
            self.assertEqual(getImageSize(icons[fname]), (16, 16))
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:27,代碼來源:test_iconscollection.py

示例2: testAddCover_01_group

    def testAddCover_01_group(self):
        files = []
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        groupname = 'Новая группа'

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)
        collection.addGroup(groupname)
        collection.addIcons(groupname, fullPaths)

        coverpath = os.path.join(self.imagesDir, 'icon.png')

        newCoverPath = os.path.join(self.tempDir1,
                                    groupname,
                                    IconsCollection.COVER_FILE_NAME)

        collection.setCover(groupname, coverpath)
        self.assertTrue(os.path.exists(newCoverPath))
        self.assertEqual(os.path.abspath(newCoverPath),
                         os.path.abspath(collection.getCover(groupname)))

        collection.setCover(groupname, coverpath)
        self.assertTrue(os.path.exists(os.path.join(
            self.tempDir1,
            groupname,
            IconsCollection.COVER_FILE_NAME))
        )
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:28,代碼來源:test_iconscollection.py

示例3: _getGroupsInfo

    def _getGroupsInfo(self):
        result = []

        for n, path in enumerate(getIconsDirList()):
            # First None is root directory
            collection = IconsCollection(path)
            for groupname in [None] + sorted(collection.getGroups(), key=self._localize):
                # Get group name
                if groupname is None:
                    title = _(u'Not in groups')
                else:
                    title = self._localize(groupname)

                iconslist = collection.getIcons(groupname)
                cover = collection.getCover(groupname)
                if cover is None:
                    cover = self._default_group_cover

                group_type = (IconsGroupInfo.TYPE_BUILTIN if n == 0
                              else IconsGroupInfo.TYPE_CUSTOM)

                result.append(IconsGroupInfo(iconslist,
                                             title,
                                             cover,
                                             group_type=group_type,
                                             sort_key=os.path.basename))

        self._addRecentIconsGroup(result)
        eventParam = IconsGroupsListInitParams(result)
        self._application.onIconsGroupsListInit(self._page, eventParam)

        return eventParam.groupsList
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:32,代碼來源:iconspanel.py

示例4: testGroups_02

    def testGroups_02(self):
        collection = IconsCollection('../test/icons/Только группы')

        self.assertEqual(len(collection.getIcons(None)), 0)
        self.assertEqual(collection.getGroups(), ['Группа 3', 'Группа 4'])
        self.assertEqual(len(collection.getIcons('Группа 3')), 3)
        self.assertEqual(len(collection.getIcons('Группа 4')), 4)
        self.assertIsNone(collection.getCover(None))
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:8,代碼來源:test_iconscollection.py

示例5: testAddCover_04_root_invalid

    def testAddCover_04_root_invalid (self):
        os.mkdir (self.tempDir1)
        collection = IconsCollection (self.tempDir1)

        coverpath = os.path.join (self.imagesDir, u'invalid.png')

        collection.setCover (u'', coverpath)
        self.assertFalse (os.path.exists (os.path.join (self.tempDir1, IconsCollection.COVER_FILE_NAME)))
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:8,代碼來源:iconscollection.py

示例6: testEmpty_02

    def testEmpty_02(self):
        collection = IconsCollection('../test/icons/Без иконок')

        self.assertEqual(collection.getIcons(None), [])
        self.assertEqual(collection.getGroups(), [])
        self.assertRaises(KeyError, collection.getIcons, 'Группа')
        self.assertRaises(KeyError, collection.getCover, 'Группа')
        self.assertIsNone(collection.getCover(''))
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:8,代碼來源:test_iconscollection.py

示例7: testAddIcons_03_empty

    def testAddIcons_03_empty(self):
        files = []
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        collection.addIcons('', fullPaths)
        self.assertEqual(collection.getIcons(None), [])
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:9,代碼來源:test_iconscollection.py

示例8: testAddIcons_06

    def testAddIcons_06(self):
        files = ['new.png']
        fullPaths = [os.path.join(self.imagesDir, fname) for fname in files]

        os.mkdir(self.tempDir1)
        collection = IconsCollection(self.tempDir1)

        collection.addIcons(None, fullPaths)

        icons = collection.getIcons(None)
        self.assertIn('new.png', icons[0])
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:11,代碼來源:test_iconscollection.py

示例9: testAddCover_05_root

    def testAddCover_05_root (self):
        os.mkdir (self.tempDir1)
        collection = IconsCollection (self.tempDir1)

        coverpath = os.path.join (self.imagesDir, u'first.jpg')

        collection.setCover (None, coverpath)
        self.assertTrue (os.path.exists (os.path.join (self.tempDir1, IconsCollection.COVER_FILE_NAME)))

        self.assertEqual (self.__getMaxImageSize (os.path.join (
            self.tempDir1,
            IconsCollection.COVER_FILE_NAME)), 16)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:12,代碼來源:iconscollection.py

示例10: testRemoveGroup_01

    def testRemoveGroup_01(self):
        os.mkdir(self.tempDir1)

        collection = IconsCollection(self.tempDir1)
        collection.addGroup('Новая группа')
        collection.addGroup('Другая группа')

        collection.removeGroup('Новая группа')
        self.assertEqual(collection.getGroups(), ['Другая группа'])

        newcollection1 = IconsCollection(self.tempDir1)
        self.assertEqual(newcollection1.getGroups(), ['Другая группа'])
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:12,代碼來源:test_iconscollection.py

示例11: testAddIcons_07

    def testAddIcons_07 (self):
        files = [u'new.png', u'image_01.JPG']
        fullPaths = [os.path.join (self.imagesDir, fname) for fname in files]

        os.mkdir (self.tempDir1)
        collection = IconsCollection (self.tempDir1)

        collection.addIcons (None, fullPaths)

        icons = sorted (collection.getIcons (None))
        self.assertIn (u'image_01.png', icons[0])
        self.assertIn (u'new.png', icons[1])
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:12,代碼來源:iconscollection.py

示例12: testRenameGroup_04_invalid

    def testRenameGroup_04_invalid(self):
        os.mkdir(self.tempDir1)

        collection = IconsCollection(self.tempDir1)
        collection.addGroup('Новая группа')
        collection.addGroup('Абырвалг')

        self.assertRaises(
            DuplicateGroupError,
            collection.renameGroup,
            'Новая группа',
            'Абырвалг')
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:12,代碼來源:test_iconscollection.py

示例13: testRemoveGroup_03_invalid

    def testRemoveGroup_03_invalid(self):
        os.mkdir(self.tempDir1)

        collection = IconsCollection(self.tempDir1)
        collection.addGroup('Новая группа')

        self.assertRaises(
            KeyError,
            collection.removeGroup,
            'Абырвалг')

        self.assertRaises(
            KeyError,
            collection.removeGroup,
            '')
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:15,代碼來源:test_iconscollection.py

示例14: testAddGroup_03

    def testAddGroup_03 (self):
        os.mkdir (self.tempDir1)

        collection = IconsCollection (self.tempDir1)
        self.assertEqual (collection.getGroups(), [])

        collection.addGroup (u'Новая группа')
        collection.addGroup (u'Вторая группа')
        self.assertEqual (collection.getGroups(), [u'Вторая группа', u'Новая группа'])

        newcollection = IconsCollection (self.tempDir1)
        self.assertEqual (newcollection.getGroups(), [u'Вторая группа', u'Новая группа'])
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:12,代碼來源:iconscollection.py

示例15: testRenameGroup_01

    def testRenameGroup_01 (self):
        os.mkdir (self.tempDir1)

        collection = IconsCollection (self.tempDir1)
        collection.addGroup (u'Новая группа')
        self.assertEqual (collection.getGroups(), [u'Новая группа'])

        collection.renameGroup (u'Новая группа', u'Переименованная группа')
        self.assertEqual (collection.getGroups(), [u'Переименованная группа'])

        newcollection1 = IconsCollection (self.tempDir1)
        self.assertEqual (newcollection1.getGroups(), [u'Переименованная группа'])
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:12,代碼來源:iconscollection.py


注:本文中的outwiker.core.iconscollection.IconsCollection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。