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


Python HobPage._string_to_size方法代码示例

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


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

示例1: sort_column

# 需要导入模块: from bb.ui.crumbs.hobpages import HobPage [as 别名]
# 或者: from bb.ui.crumbs.hobpages.HobPage import _string_to_size [as 别名]
    def sort_column(self, model, row1, row2, col):
        value1 = model.get_value(row1, col)
        value2 = model.get_value(row2, col)
        if col==PackageListModel.COL_SIZE:
            value1 = HobPage._string_to_size(value1)
            value2 = HobPage._string_to_size(value2)

        cmp_res = cmp(value1, value2)
        if cmp_res!=0:
            if col==PackageListModel.COL_INC:
                return -cmp_res
            else:
                return cmp_res
        else:
            name1 = model.get_value(row1, PackageListModel.COL_NAME)
            name2 = model.get_value(row2, PackageListModel.COL_NAME)
            return cmp(name1,name2)
开发者ID:117111302,项目名称:poky,代码行数:19,代码来源:hoblistmodel.py

示例2: populate

# 需要导入模块: from bb.ui.crumbs.hobpages import HobPage [as 别名]
# 或者: from bb.ui.crumbs.hobpages.HobPage import _string_to_size [as 别名]
    def populate(self, pkginfolist):
        self.clear()
        self.pkgs_size = 0
        self.pn_path = {}
        self.pkg_path = {}
        self.rprov_pkg = {}

        def getpkgvalue(pkgdict, key, pkgname, defaultval = None):
            value = pkgdict.get('%s_%s' % (key, pkgname), None)
            if not value:
                value = pkgdict.get(key, defaultval)
            return value

        for pkginfo in pkginfolist:
            pn = pkginfo['PN']
            pv = pkginfo['PV']
            pr = pkginfo['PR']
            if pn in self.pn_path.keys():
                pniter = self.get_iter(self.pn_path[pn])
            else:
                pniter = self.append(None)
                self.set(pniter, self.COL_NAME, pn + '-' + pv + '-' + pr,
                                 self.COL_INC, False)
                self.pn_path[pn] = self.get_path(pniter)

            # PKG is always present
            pkg = pkginfo['PKG']
            pkgv = getpkgvalue(pkginfo, 'PKGV', pkg)
            pkgr = getpkgvalue(pkginfo, 'PKGR', pkg)
            # PKGSIZE is artificial, will always be overridden with the package name if present
            pkgsize = pkginfo.get('PKGSIZE_%s' % pkg, "0")
            # PKG_%s is the renamed version
            pkg_rename = pkginfo.get('PKG_%s' % pkg, "")
            # The rest may be overridden or not
            section = getpkgvalue(pkginfo, 'SECTION', pkg, "")
            summary = getpkgvalue(pkginfo, 'SUMMARY', pkg, "")
            rdep = getpkgvalue(pkginfo, 'RDEPENDS', pkg, "")
            rrec = getpkgvalue(pkginfo, 'RRECOMMENDS', pkg, "")
            rprov = getpkgvalue(pkginfo, 'RPROVIDES', pkg, "")
            for i in rprov.split():
                self.rprov_pkg[i] = pkg

            allow_empty = getpkgvalue(pkginfo, 'ALLOW_EMPTY', pkg, "")

            if pkgsize == "0" and not allow_empty:
                continue

            # pkgsize is in KB
            size = HobPage._size_to_string(HobPage._string_to_size(pkgsize + ' KB'))

            it = self.append(pniter)
            self.pkg_path[pkg] = self.get_path(it)
            self.set(it, self.COL_NAME, pkg, self.COL_VER, pkgv,
                     self.COL_REV, pkgr, self.COL_RNM, pkg_rename,
                     self.COL_SEC, section, self.COL_SUM, summary,
                     self.COL_RDEP, rdep + ' ' + rrec,
                     self.COL_RPROV, rprov, self.COL_SIZE, size,
                     self.COL_BINB, "", self.COL_INC, False, self.COL_FONT, '10')
开发者ID:TizenTeam,项目名称:poky,代码行数:60,代码来源:hoblistmodel.py

示例3: populate

# 需要导入模块: from bb.ui.crumbs.hobpages import HobPage [as 别名]
# 或者: from bb.ui.crumbs.hobpages.HobPage import _string_to_size [as 别名]
    def populate(self, pkginfolist):
        # First clear the model, in case repopulating
        self.clear()

        def getpkgvalue(pkgdict, key, pkgname, defaultval = None):
            value = pkgdict.get('%s_%s' % (key, pkgname), None)
            if not value:
                value = pkgdict.get(key, defaultval)
            return value

        for pkginfo in pkginfolist:
            pn = pkginfo['PN']
            pv = pkginfo['PV']
            pr = pkginfo['PR']
            pkg = pkginfo['PKG']
            pkgv = getpkgvalue(pkginfo, 'PKGV', pkg)
            pkgr = getpkgvalue(pkginfo, 'PKGR', pkg)
            # PKGSIZE is artificial, will always be overridden with the package name if present
            pkgsize = pkginfo.get('PKGSIZE_%s' % pkg, "0")
            # PKG_%s is the renamed version
            pkg_rename = pkginfo.get('PKG_%s' % pkg, "")
            # The rest may be overridden or not
            section = getpkgvalue(pkginfo, 'SECTION', pkg, "")
            summary = getpkgvalue(pkginfo, 'SUMMARY', pkg, "")
            rdep = getpkgvalue(pkginfo, 'RDEPENDS', pkg, "")
            rrec = getpkgvalue(pkginfo, 'RRECOMMENDS', pkg, "")
            rprov = getpkgvalue(pkginfo, 'RPROVIDES', pkg, "")
            files_list = getpkgvalue(pkginfo, 'FILES_INFO', pkg, "")
            for i in rprov.split():
                self.rprov_pkg[i] = pkg

            recipe = pn + '-' + pv + '-' + pr

            allow_empty = getpkgvalue(pkginfo, 'ALLOW_EMPTY', pkg, "")

            if pkgsize == "0" and not allow_empty:
                continue

            # pkgsize is in KB
            size = HobPage._size_to_string(HobPage._string_to_size(pkgsize + ' KB'))

            self.set(self.append(), self.COL_NAME, pkg, self.COL_VER, pkgv,
                     self.COL_REV, pkgr, self.COL_RNM, pkg_rename,
                     self.COL_SEC, section, self.COL_SUM, summary,
                     self.COL_RDEP, rdep + ' ' + rrec,
                     self.COL_RPROV, rprov, self.COL_SIZE, size,
                     self.COL_RCP, recipe, self.COL_BINB, "",
                     self.COL_INC, False, self.COL_FONT, '10', self.COL_FLIST, files_list)

        self.pn_path = {}
        it = self.get_iter_first()
        while it:
            pn = self.get_value(it, self.COL_NAME)
            path = self.get_path(it)
            self.pn_path[pn] = path
            it = self.iter_next(it)
开发者ID:aniltolinux,项目名称:poky,代码行数:58,代码来源:hoblistmodel.py

示例4: populate

# 需要导入模块: from bb.ui.crumbs.hobpages import HobPage [as 别名]
# 或者: from bb.ui.crumbs.hobpages.HobPage import _string_to_size [as 别名]
    def populate(self, pkginfolist):
        self.clear()
        self.pkgs_size = 0
        self.pn_path = {}
        self.pkg_path = {}
        self.rprov_pkg = {}

        for pkginfo in pkginfolist:
            pn = pkginfo['PN']
            pv = pkginfo['PV']
            pr = pkginfo['PR']
            if pn in self.pn_path.keys():
                pniter = self.get_iter(self.pn_path[pn])
            else:
                pniter = self.append(None)
                self.set(pniter, self.COL_NAME, pn + '-' + pv + '-' + pr,
                                 self.COL_INC, False)
                self.pn_path[pn] = self.get_path(pniter)

            pkg = pkginfo['PKG']
            pkgv = pkginfo['PKGV']
            pkgr = pkginfo['PKGR']
            pkgsize = pkginfo['PKGSIZE_%s' % pkg] if 'PKGSIZE_%s' % pkg in pkginfo.keys() else "0"
            pkg_rename = pkginfo['PKG_%s' % pkg] if 'PKG_%s' % pkg in pkginfo.keys() else ""
            section = pkginfo['SECTION_%s' % pkg] if 'SECTION_%s' % pkg in pkginfo.keys() else ""
            summary = pkginfo['SUMMARY_%s' % pkg] if 'SUMMARY_%s' % pkg in pkginfo.keys() else ""
            rdep = pkginfo['RDEPENDS_%s' % pkg] if 'RDEPENDS_%s' % pkg in pkginfo.keys() else ""
            rrec = pkginfo['RRECOMMENDS_%s' % pkg] if 'RRECOMMENDS_%s' % pkg in pkginfo.keys() else ""
            rprov = pkginfo['RPROVIDES_%s' % pkg] if 'RPROVIDES_%s' % pkg in pkginfo.keys() else ""
            for i in rprov.split():
                self.rprov_pkg[i] = pkg

            if 'ALLOW_EMPTY_%s' % pkg in pkginfo.keys():
                allow_empty = pkginfo['ALLOW_EMPTY_%s' % pkg]
            elif 'ALLOW_EMPTY' in pkginfo.keys():
                allow_empty = pkginfo['ALLOW_EMPTY']
            else:
                allow_empty = ""

            if pkgsize == "0" and not allow_empty:
                continue

            # pkgsize is in KB
            size = HobPage._size_to_string(HobPage._string_to_size(pkgsize + ' KB'))

            it = self.append(pniter)
            self.pkg_path[pkg] = self.get_path(it)
            self.set(it, self.COL_NAME, pkg, self.COL_VER, pkgv,
                     self.COL_REV, pkgr, self.COL_RNM, pkg_rename,
                     self.COL_SEC, section, self.COL_SUM, summary,
                     self.COL_RDEP, rdep + ' ' + rrec,
                     self.COL_RPROV, rprov, self.COL_SIZE, size,
                     self.COL_BINB, "", self.COL_INC, False, self.COL_FONT, '10')
开发者ID:dlespiau,项目名称:poky,代码行数:55,代码来源:hoblistmodel.py

示例5: get_packages_size

# 需要导入模块: from bb.ui.crumbs.hobpages import HobPage [as 别名]
# 或者: from bb.ui.crumbs.hobpages.HobPage import _string_to_size [as 别名]
    def get_packages_size(self):
        packages_size = 0
        it = self.get_iter_first()
        while it:
            if self.get_value(it, self.COL_INC):
                str_size = self.get_value(it, self.COL_SIZE)
                if not str_size:
                    continue

                packages_size += HobPage._string_to_size(str_size)

            it = self.iter_next(it)
        return packages_size
开发者ID:aniltolinux,项目名称:poky,代码行数:15,代码来源:hoblistmodel.py


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