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


Python FormatterError.newml12FormatterError方法代码示例

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


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

示例1: format

# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import newml12FormatterError [as 别名]
    def format(self, article, subscriber):
        """
        Create article in NewsML1.2 format
        :param dict article:
        :param dict subscriber:
        :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)

            newsml = etree.Element("NewsML")
            SubElement(newsml, "Catalog", {'Href': 'http://www.iptc.org/std/catalog/catalog.IptcMasterCatalog.xml'})
            news_envelope = SubElement(newsml, "NewsEnvelope")
            news_item = SubElement(newsml, "NewsItem")

            self._format_news_envelope(article, news_envelope, pub_seq_num)
            self._format_identification(article, news_item)
            self._format_news_management(article, news_item)
            self._format_news_component(article, news_item)

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

示例2: format

# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import newml12FormatterError [as 别名]
    def format(self, article, subscriber, codes=None):
        """
        Create article in NewsML1.2 format

        :param dict article:
        :param dict subscriber:
        :param list 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:
            formatted_article = deepcopy(article)
            pub_seq_num = superdesk.get_resource_service('subscribers').generate_sequence_number(subscriber)
            self.now = utcnow()
            self.string_now = self.now.strftime('%Y%m%dT%H%M%S+0000')

            newsml = etree.Element("NewsML", {'Version': '1.2'})
            SubElement(newsml, "Catalog", {
                'Href': 'http://about.reuters.com/newsml/vocabulary/catalog-reuters-3rdParty-master_catalog.xml'})
            news_envelope = SubElement(newsml, "NewsEnvelope")
            news_item = SubElement(newsml, "NewsItem")

            self._format_news_envelope(formatted_article, news_envelope, pub_seq_num)
            self._format_identification(formatted_article, news_item)
            self._format_news_management(formatted_article, news_item)
            self._format_news_component(formatted_article, news_item)

            return [(pub_seq_num, self.XML_ROOT + etree.tostring(newsml).decode('utf-8'))]
        except Exception as ex:
            raise FormatterError.newml12FormatterError(ex, subscriber)
开发者ID:mdhaman,项目名称:superdesk-aap,代码行数:33,代码来源:reuters_newsml_1_2_formatter.py

示例3: format

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

            newsml = etree.Element("NewsML")
            SubElement(newsml, "Catalog", {'Href': 'http://www.aap.com.au/xml-res/aap-master-catalog.xml'})
            news_envelope = SubElement(newsml, "NewsEnvelope")
            news_item = SubElement(newsml, "NewsItem")

            self._format_news_envelope(article, news_envelope, pub_seq_num)
            self._format_identification(article, news_item)
            self._format_news_management(article, news_item)
            self._format_news_component(article, news_item)

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

示例4: format

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

            pub_seq_num = superdesk.get_resource_service("output_channels").generate_sequence_number(destination)

            newsml = etree.Element("NewsML")
            SubElement(newsml, "Catalog", {"Href": "http://www.aap.com.au/xml-res/aap-master-catalog.xml"})
            news_envelope = SubElement(newsml, "NewsEnvelope")
            news_item = SubElement(newsml, "NewsItem")

            self._format_news_envelope(article, news_envelope, pub_seq_num)
            self._format_identification(article, news_item)
            self._format_news_management(article, news_item)
            self._format_news_component(article, news_item)

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


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