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

Python pocommon.encodingToUse函数代码示例

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

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



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

示例1: __init__

    def __init__(self, source=None, encoding="UTF-8"):
        pocommon.pounit.__init__(self, source)
        self._encoding = encodingToUse(encoding)
        self._initallcomments(blankall=True)
        self._msgctxt = u""

        self.target = u""
开发者ID:cc-archive,项目名称:pootle,代码行数:7,代码来源:fpo.py


示例2: __init__

 def __init__(self, source=None, encoding="UTF-8"):
     self._encoding = encodingToUse(encoding)
     self.obsolete = False
     self._initallcomments(blankall=True)
     self.prev_msgctxt = []
     self.prev_msgid = []
     self.prev_msgid_plural = []
     self.msgctxt = []
     self.msgid = []
     self.msgid_pluralcomments = []
     self.msgid_plural = []
     self.msgstr = []
     pocommon.pounit.__init__(self, source)
开发者ID:cc-archive,项目名称:pootle,代码行数:13,代码来源:pypo.py


示例3: parse

    def parse(self, input, duplicatestyle="merge"):
        if hasattr(input, 'name'):
            self.filename = input.name
        elif not getattr(self, 'filename', ''):
            self.filename = ''

        if hasattr(input, "read"):
            posrc = input.read()
            input.close()
            input = posrc

        needtmpfile = not os.path.isfile(input)
        if needtmpfile:
            # This is not a file - we write the string to a temporary file
            fd, fname = tempfile.mkstemp(prefix='translate', suffix='.po')
            os.write(fd, input)
            input = fname
            os.close(fd)

        self._gpo_memory_file = gpo.po_file_read_v3(input, xerror_handler)
        if self._gpo_memory_file is None:
            logger.error("Error:")

        if needtmpfile:
            os.remove(input)

        self.units = []
        # Handle xerrors here
        self._header = gpo.po_file_domain_header(self._gpo_memory_file, None)
        if self._header:
            charset = gpo.po_header_field(self._header, "Content-Type")
            if charset:
                charset = re.search("charset=([^\\s]+)", charset).group(1)
            self._encoding = encodingToUse(charset)
        self._gpo_message_iterator = gpo.po_message_iterator(self._gpo_memory_file, None)
        newmessage = gpo.po_next_message(self._gpo_message_iterator)
        while newmessage:
            newunit = pounit(gpo_message=newmessage, encoding=self._encoding)
            self.addunit(newunit, new=False)
            newmessage = gpo.po_next_message(self._gpo_message_iterator)
        self._free_iterator()

        # duplicates are now removed by default unless duplicatestyle=allow
        if duplicatestyle != "allow":
            self.removeduplicates(duplicatestyle=duplicatestyle)
开发者ID:flyeven,项目名称:translate,代码行数:45,代码来源:cpo.py


示例4: changeencoding

    def changeencoding(self, newencoding):
        """Deprecated: changes the encoding on the file."""
        # This should not be here but in poheader. It also shouldn't mangle the
        # header itself, but use poheader methods. All users are removed, so
        # we can deprecate after one release.
        raise DeprecationWarning

        self._encoding = encodingToUse(newencoding)
        if not self.units:
            return
        header = self.header()
        if not header or header.isblank():
            return
        charsetline = None
        headerstr = header.target
        for line in headerstr.split("\n"):
            if not ":" in line:
                continue
            key, value = line.strip().split(":", 1)
            if key.strip() != "Content-Type":
                continue
            charsetline = line
        if charsetline is None:
            headerstr += "Content-Type: text/plain; charset=%s" % self._encoding
        else:
            charset = re.search("charset=([^ ]*)", charsetline)
            if charset is None:
                newcharsetline = charsetline
                if not newcharsetline.strip().endswith(";"):
                    newcharsetline += ";"
                newcharsetline += " charset=%s" % self._encoding
            else:
                charset = charset.group(1)
                newcharsetline = charsetline.replace(
                    "charset=%s" % charset, "charset=%s" % self._encoding, 1)
            headerstr = headerstr.replace(charsetline, newcharsetline, 1)
        header.target = headerstr
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:37,代码来源:fpo.py


示例5: _encodeifneccessary

 def _encodeifneccessary(self, output):
     """encodes unicode strings and returns other strings unchanged"""
     if isinstance(output, unicode):
         encoding = encodingToUse(getattr(self, "_encoding", "UTF-8"))
         return output.encode(encoding)
     return output
开发者ID:cc-archive,项目名称:pootle,代码行数:6,代码来源:pypo.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python properties._find_delimiter函数代码示例发布时间:2022-05-27
下一篇:
Python po.pounit函数代码示例发布时间: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