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


Python FormatterError.newmsmlG2FormatterError方法代码示例

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


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

示例1: format

# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import newmsmlG2FormatterError [as 别名]
    def format(self, article, subscriber, codes=None):
        """
        Create article in NewsML G2 format
        :param dict article:
        :param dict subscriber:
        :param list codes: selector codes
        :return [(int, str)]: return a List of tuples. A tuple consist of
            publish sequence number and formatted article string.
        :raises FormatterError: if the formatter fails to format an article
        """
        try:
            pub_seq_num = superdesk.get_resource_service('subscribers').generate_sequence_number(subscriber)
            is_package = self._is_package(article)
            self._message_attrib.update(self._debug_message_extra)
            news_message = etree.Element('newsMessage', attrib=self._message_attrib)
            self._format_header(article, news_message, pub_seq_num)
            item_set = self._format_item(news_message)
            if is_package:
                item = self._format_item_set(article, item_set, 'packageItem')
                self._format_groupset(article, item)
            elif article[ITEM_TYPE] in {CONTENT_TYPE.PICTURE, CONTENT_TYPE.AUDIO, CONTENT_TYPE.VIDEO}:
                item = self._format_item_set(article, item_set, 'newsItem')
                self._format_contentset(article, item)
            else:
                nitfFormater = NITFFormatter()
                nitf = nitfFormater.get_nitf(article, subscriber, pub_seq_num)
                newsItem = self._format_item_set(article, item_set, 'newsItem')
                self._format_content(article, newsItem, nitf)

            return [(pub_seq_num, self.XML_ROOT + etree.tostring(news_message).decode('utf-8'))]
        except Exception as ex:
            raise FormatterError.newmsmlG2FormatterError(ex, subscriber)
开发者ID:liveblog,项目名称:superdesk-core,代码行数:34,代码来源:newsml_g2_formatter.py

示例2: format

# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import newmsmlG2FormatterError [as 别名]
    def format(self, article, destination, selector_codes=None):
        try:
            pub_seq_num = superdesk.get_resource_service('output_channels').generate_sequence_number(destination)

            nitfFormater = NITFFormatter()
            nitf = nitfFormater.get_nitf(article, destination, pub_seq_num)

            self._message_attrib.update(self._debug_message_extra)
            newsMessage = etree.Element('newsMessage', attrib=self._message_attrib)
            self._format_header(article, newsMessage, pub_seq_num)
            itemSet = self._format_item(newsMessage)
            if article['type'] == 'text' or article['type'] == 'preformatted':
                self._format_newsitem(article, itemSet, nitf)

            return pub_seq_num, self.XML_ROOT + etree.tostring(newsMessage).decode('utf-8')
        except Exception as ex:
            raise FormatterError.newmsmlG2FormatterError(ex, destination)
开发者ID:Flowdeeps,项目名称:superdesk-1,代码行数:19,代码来源:newsml_g2_formatter.py

示例3: format

# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import newmsmlG2FormatterError [as 别名]
    def format(self, article, subscriber):
        try:
            pub_seq_num = superdesk.get_resource_service('subscribers').generate_sequence_number(subscriber)
            is_package = self._is_package(article)
            self._message_attrib.update(self._debug_message_extra)
            newsMessage = etree.Element('newsMessage', attrib=self._message_attrib)
            self._format_header(article, newsMessage, pub_seq_num)
            itemSet = self._format_item(newsMessage)
            if is_package:
                item = self._format_item_set(article, itemSet, 'packageItem')
                self._format_groupset(article, item)
            elif article[ITEM_TYPE] == CONTENT_TYPE.PICTURE:
                item = self._format_item_set(article, itemSet, 'newsItem')
                self._format_contentset(article, item)
            else:
                nitfFormater = NITFFormatter()
                nitf = nitfFormater.get_nitf(article, subscriber, pub_seq_num)
                newsItem = self._format_item_set(article, itemSet, 'newsItem')
                self._format_content(article, newsItem, nitf)

            return [(pub_seq_num, self.XML_ROOT + etree.tostring(newsMessage).decode('utf-8'))]
        except Exception as ex:
            raise FormatterError.newmsmlG2FormatterError(ex, subscriber)
开发者ID:chalkjockey,项目名称:superdesk,代码行数:25,代码来源:newsml_g2_formatter.py


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