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


Python FormatterError.ninjsFormatterError方法代码示例

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


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

示例1: format

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

            ninjs = {
                '_id': article['_id'],
                'version': str(article['_current_version']),
                'type': self._get_type(article)
            }
            try:
                ninjs['byline'] = self._get_byline(article)
            except:
                pass
            for copy_property in self.direct_copy_properties:
                if copy_property in article:
                    ninjs[copy_property] = article[copy_property]

            if 'description' in article:
                ninjs['description_text'] = article['description']

            if article['type'] == 'composite':
                ninjs['associations'] = self._get_associations(article)

            return [(pub_seq_num, json.dumps(ninjs, default=json_serialize_datetime_objectId))]
        except Exception as ex:
            raise FormatterError.ninjsFormatterError(ex, subscriber)
开发者ID:oxcarh,项目名称:superdesk,代码行数:28,代码来源:ninjs_formatter.py

示例2: format

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

            ninjs = {
                '_id': article['_id'],
                'version': str(article['_current_version']),
                'type': self._get_type(article)
            }
            try:
                ninjs['byline'] = self._get_byline(article)
            except:
                pass

            located = article.get('dateline', {}).get('located', {}).get('city')
            if located:
                ninjs['located'] = article.get('dateline', {}).get('located', {}).get('city', '')

            for copy_property in self.direct_copy_properties:
                if copy_property in article:
                    ninjs[copy_property] = article[copy_property]

            if 'description' in article:
                ninjs['description_text'] = article['description']

            if article[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE:
                ninjs['associations'] = self._get_associations(article)

            if article.get(EMBARGO):
                ninjs['embargoed'] = article.get(EMBARGO).isoformat()

            return [(pub_seq_num, json.dumps(ninjs, default=json_serialize_datetime_objectId))]
        except Exception as ex:
            raise FormatterError.ninjsFormatterError(ex, subscriber)
开发者ID:chalkjockey,项目名称:superdesk,代码行数:36,代码来源:ninjs_formatter.py

示例3: format

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

            ninjs = {
                '_id': article['_id'],
                'version': str(article.get(config.VERSION, 1)),
                'type': self._get_type(article)
            }

            try:
                ninjs['byline'] = self._get_byline(article)
            except:
                pass

            located = article.get('dateline', {}).get('located', {})
            if located:
                ninjs['located'] = located.get('city', '')

            for copy_property in self.direct_copy_properties:
                if article.get(copy_property) is not None:
                    ninjs[copy_property] = article[copy_property]

            if article.get('body_html'):
                ninjs['body_html'] = self.append_body_footer(article)

            if article.get('description'):
                ninjs['description_html'] = self.append_body_footer(article)

            if article[ITEM_TYPE] == CONTENT_TYPE.COMPOSITE:
                ninjs['associations'] = self._get_associations(article)
            elif article.get('associations', {}):
                ninjs['associations'] = self._format_related(article, subscriber)

            if article.get(EMBARGO):
                ninjs['embargoed'] = article.get(EMBARGO).isoformat()

            if article.get('priority'):
                ninjs['priority'] = article['priority']
            else:
                ninjs['priority'] = 5

            if article.get('subject'):
                ninjs['subject'] = self._get_subject(article)

            if article.get('anpa_category'):
                ninjs['service'] = self._get_service(article)

            if article.get('renditions'):
                ninjs['renditions'] = self._get_renditions(article)

            if article.get('abstract'):
                ninjs['description_text'] = article.get('abstract')
            elif article.get('description_text'):
                ninjs['description_text'] = article.get('description_text')

            return [(pub_seq_num, json.dumps(ninjs, default=json_serialize_datetime_objectId))]
        except Exception as ex:
            raise FormatterError.ninjsFormatterError(ex, subscriber)
开发者ID:ahilles107,项目名称:superdesk-core,代码行数:61,代码来源:ninjs_formatter.py

示例4: format

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

            ninjs = self._transform_to_ninjs(article, subscriber)
            return [(pub_seq_num, json.dumps(ninjs, default=json_serialize_datetime_objectId))]
        except Exception as ex:
            raise FormatterError.ninjsFormatterError(ex, subscriber)
开发者ID:hlmnrmr,项目名称:superdesk-core,代码行数:10,代码来源:ninjs_formatter.py

示例5: format

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

            ninjs = self._transform_to_ninjs(article, subscriber)

            # if the article has an abstract then the description text has been over written by the abstract
            if article.get('abstract'):
                # if it is a picture then put it back
                if article.get('type') == 'picture':
                    ninjs['description_text'] = article.get('description_text', '')

            media = article.get('associations', {}).get('featuremedia')
            ninjs_media = article.get('associations', {}).get('featuremedia')
            if media and media.get('type') == 'picture':
                ninjs_media['description_text'] = media.get('description_text')

            return [(pub_seq_num, json.dumps(ninjs, default=json_serialize_datetime_objectId))]
        except Exception as ex:
            raise FormatterError.ninjsFormatterError(ex, subscriber)
开发者ID:mdhaman,项目名称:superdesk-aap,代码行数:22,代码来源:aap_ninjs_formatter.py

示例6: format

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

            ninjs = {}
            ninjs['_id'] = article['_id']
            ninjs['version'] = str(article['version'])
            ninjs['type'] = self._get_type(article)
            try:
                ninjs['byline'] = self._get_byline(article)
            except:
                pass
            for copy_property in self.direct_copy_properties:
                if copy_property in article:
                    ninjs[copy_property] = article[copy_property]
            if article['type'] == 'composite':
                article['associations'] = self._get_associations(article)

            return pub_seq_num, json.dumps(ninjs, default=json_util.default)
        except Exception as ex:
            raise FormatterError.ninjsFormatterError(ex, destination)
开发者ID:Flowdeeps,项目名称:superdesk-1,代码行数:23,代码来源:ninjs_formatter.py


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