本文整理汇总了Python中superdesk.errors.FormatterError.nitfFormatterError方法的典型用法代码示例。如果您正苦于以下问题:Python FormatterError.nitfFormatterError方法的具体用法?Python FormatterError.nitfFormatterError怎么用?Python FormatterError.nitfFormatterError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类superdesk.errors.FormatterError
的用法示例。
在下文中一共展示了FormatterError.nitfFormatterError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: format
# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import nitfFormatterError [as 别名]
def format(self, article, subscriber, codes=None):
try:
pub_seq_num = superdesk.get_resource_service('subscribers').generate_sequence_number(subscriber)
nitf = self.get_nitf(article, subscriber, pub_seq_num)
return [(pub_seq_num, self.XML_ROOT + etree.tostring(nitf).decode('utf-8'))]
except Exception as ex:
raise FormatterError.nitfFormatterError(ex, subscriber)
示例2: format
# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import nitfFormatterError [as 别名]
def format(self, article, destination, selector_codes=None):
try:
pub_seq_num = superdesk.get_resource_service('output_channels').generate_sequence_number(destination)
nitf = self.get_nitf(article, destination, pub_seq_num)
return pub_seq_num, self.XML_ROOT + etree.tostring(nitf).decode('utf-8')
except Exception as ex:
raise FormatterError.nitfFormatterError(ex, destination)
示例3: format
# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import nitfFormatterError [as 别名]
def format(self, article, subscriber, codes=None):
try:
pub_seq_num = superdesk.get_resource_service('subscribers').generate_sequence_number(subscriber)
nitf = self.get_nitf(article, subscriber, pub_seq_num)
return [{'published_seq_num': pub_seq_num,
'formatted_item': etree.tostring(nitf, encoding='ascii').decode('ascii'),
'item_encoding': 'ascii'}]
except Exception as ex:
raise FormatterError.nitfFormatterError(ex, subscriber)
示例4: format
# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import nitfFormatterError [as 别名]
def format(self, article, subscriber, codes=None):
try:
pub_seq_num = superdesk.get_resource_service('subscribers').generate_sequence_number(subscriber)
nitf = self.get_nitf(article, subscriber, pub_seq_num)
strip_elements(nitf, 'body.end')
nitf_string = etree.tostring(nitf, encoding='utf-8').decode()
headers = ['<?xml version=\"1.0\" encoding=\"UTF-8\"?>',
'<!-- <!DOCTYPE nitf SYSTEM \"./nitf-3-3.dtd\"> -->']
return [{
'published_seq_num': pub_seq_num,
'formatted_item': '{}\r\n{}'.format("\r\n".join(headers), nitf_string).
replace(' \n', self.line_ender)}]
except Exception as ex:
raise FormatterError.nitfFormatterError(ex, subscriber)
示例5: format
# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import nitfFormatterError [as 别名]
def format(self, article, destination):
try:
nitf = etree.Element("nitf")
head = SubElement(nitf, "head")
body = SubElement(nitf, "body")
body_head = SubElement(body, "body.head")
body_content = SubElement(body, "body.content")
body_content.text = article['body_html']
body_end = SubElement(body, "body.end")
etree.Element('doc-id', attrib={'id-string': article['guid']})
self.__format_head(article, head)
self.__format_body_head(article, body_head)
self.__format_body_end(article, body_end)
return self.XML_ROOT + str(etree.tostring(nitf))
except Exception as ex:
raise FormatterError.nitfFormatterError(ex, destination)
示例6: format
# 需要导入模块: from superdesk.errors import FormatterError [as 别名]
# 或者: from superdesk.errors.FormatterError import nitfFormatterError [as 别名]
def format(self, article, destination, selector_codes=None):
try:
pub_seq_num = superdesk.get_resource_service('output_channels').generate_sequence_number(destination)
nitf = etree.Element("nitf")
head = SubElement(nitf, "head")
body = SubElement(nitf, "body")
body_head = SubElement(body, "body.head")
body_content = SubElement(body, "body.content")
body_content.text = article['body_html']
body_end = SubElement(body, "body.end")
etree.Element('doc-id', attrib={'id-string': article['guid']})
self.__append_meta(article, head, destination, pub_seq_num)
self.__format_head(article, head)
self.__format_body_head(article, body_head)
self.__format_body_end(article, body_end)
return pub_seq_num, self.XML_ROOT + str(etree.tostring(nitf))
except Exception as ex:
raise FormatterError.nitfFormatterError(ex, destination)