• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python s3codec.S3Codec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中s3codec.S3Codec的典型用法代码示例。如果您正苦于以下问题:Python S3Codec类的具体用法?Python S3Codec怎么用?Python S3Codec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: __init__

    def __init__(self):
        """
            Constructor

            @param manager: the S3ResourceController

            @todo 2.3: error message completion
        """

        T = current.T

        self.ERROR = Storage(
            REPORTLAB_ERROR = T("%(module)s not installed") % dict(module="ReportLab"),
            NO_RECORDS = T("No records in this resource"),
            XLWT_ERROR = T("%(module)s not installed") % dict(module="xlwt"),
        )

        self.xls = S3Codec.get_codec("xls").encode
        self.pdf = S3Codec.get_codec("pdf").encode
开发者ID:AnithaT,项目名称:eden,代码行数:19,代码来源:s3export.py


示例2: __init__

    def __init__(self, manager):
        """
            Constructor

            @param manager: the S3ResourceController

            @todo 2.3: error message completion
        """

        self.manager = manager
        T = current.T
        self.s3 = self.manager.s3

        self.ERROR = Storage(
            REPORTLAB_ERROR = T("ReportLab not installed"),
            GERALDO_ERROR = T("Geraldo not installed"),
            NO_RECORDS = T("No records in this resource"),
            XLWT_ERROR = T("Xlwt not installed"),
        )

        self.xls = S3Codec.get_codec("xls").encode
开发者ID:flavour,项目名称:lacity,代码行数:21,代码来源:s3export.py


示例3: xls

    def xls(self, *args, **kwargs):

        codec = S3Codec.get_codec("xls").encode
        return codec(*args, **kwargs)
开发者ID:AyudaEcuador,项目名称:eden,代码行数:4,代码来源:s3export.py


示例4: svg

    def svg(self, *args, **kwargs):

        codec = S3Codec.get_codec("svg").encode
        return codec(*args, **kwargs)
开发者ID:AyudaEcuador,项目名称:eden,代码行数:4,代码来源:s3export.py


示例5: shp

    def shp(self, *args, **kwargs):

        codec = S3Codec.get_codec("shp").encode
        return codec(*args, **kwargs)
开发者ID:AyudaEcuador,项目名称:eden,代码行数:4,代码来源:s3export.py


示例6: pdf

    def pdf(self, *args, **kwargs):

        codec = S3Codec.get_codec("pdf").encode
        return codec(*args, **kwargs)
开发者ID:AyudaEcuador,项目名称:eden,代码行数:4,代码来源:s3export.py


示例7: pdfcard

    def pdfcard(self, *args, **kwargs):

        codec = S3Codec.get_codec("card")
        return codec.encode(*args, **kwargs)
开发者ID:ramdesh,项目名称:eden,代码行数:4,代码来源:s3export.py


示例8: export_xls


#.........这里部分代码省略.........
        # Intepret the hierarchy_export setting for the resource
        setting = resource.get_config("hierarchy_export", {})
        field = setting.get("field")
        if not field:
            field = "name" if "name" in resource.fields else resource._id.name
        prefix = setting.get("prefix", "Sub")
        root = setting.get("root")
        if not root:
            root = "".join(s.capitalize() for s in resource.name.split("_"))
        branch = setting.get("branch")
        if not branch:
            branch = "%s%s" % (prefix, root)

        rfield = resource.resolve_selector(field)

        # Get the list fields
        list_fields = resource.list_fields("export_fields", id_column=False)
        rfields = resource.resolve_selectors(list_fields, extra_fields=False)[0]

        # Selectors = the fields to extract
        selectors = [h.pkey.name, rfield.selector]

        # Columns = the keys for the XLS Codec to access the rows
        # Types = the data types of the columns (in same order!)
        columns = []
        types = []

        # Generate the headers and type list for XLS Codec
        headers = {}
        for rf in rfields:
            selectors.append(rf.selector)
            if rf.colname == rfield.colname:
                continue
            columns.append(rf.colname)
            headers[rf.colname] = rf.label
            if rf.ftype == "virtual":
                types.append("string")
            else:
                types.append(rf.ftype)

        # Get the root nodes
        if self.record_id:
            if r.component and h.pkey.name != resource._id.name:
                query = resource.table._id == self.record_id
                row = current.db(query).select(h.pkey, limitby=(0, 1)).first()
                if not row:
                    r.error(404, current.ERROR.BAD_RECORD)
                roots = set([row[h.pkey]])
            else:
                roots = set([self.record_id])
        else:
            roots = h.roots

        # Find all child nodes
        all_nodes = h.findall(roots, inclusive=True)

        # ...and extract their data from a clone of the resource
        from s3query import FS

        query = FS(h.pkey.name).belongs(all_nodes)
        clone = current.s3db.resource(resource, filter=query)
        data = clone.select(selectors, represent=True, raw_data=True)

        # Convert into dict {hierarchy key: row}
        hkey = str(h.pkey)
        data_dict = dict((row._row[hkey], row) for row in data.rows)

        # Add hierarchy headers and types
        depth = max(h.depth(node_id) for node_id in roots)
        htypes = []
        hcolumns = []
        colprefix = "HIERARCHY"
        htype = "string" if rfield.ftype == "virtual" else rfield.ftype
        for level in xrange(depth + 1):
            col = "%s.%s" % (colprefix, level)
            if level == 0:
                headers[col] = root
            elif level == 1:
                headers[col] = branch
            else:
                headers[col] = "%s%s" % ("".join([prefix] * (level - 1)), branch)
            hcolumns.append(col)
            htypes.append(htype)

        # Generate the output for XLS Codec
        output = [headers, htypes + types]
        for node_id in roots:
            rows = h.export_node(
                node_id, prefix=colprefix, depth=depth, hcol=rfield.colname, columns=columns, data=data_dict
            )
            output.extend(rows)

        # Encode in XLS format
        from s3codec import S3Codec

        codec = S3Codec.get_codec("xls")
        result = codec.encode(output, title=resource.name, list_fields=hcolumns + columns)

        # Reponse headers and file name are set in codec
        return result
开发者ID:ahaym,项目名称:eden,代码行数:101,代码来源:s3hierarchy.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python s3crud.S3CRUD类代码示例发布时间:2022-05-27
下一篇:
Python s3utils.soundex函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap