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


Python Study.update_tags方法代码示例

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


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

示例1: study_tags_patch_request

# 需要导入模块: from qiita_db.study import Study [as 别名]
# 或者: from qiita_db.study.Study import update_tags [as 别名]
def study_tags_patch_request(user_id, study_id,
                             req_op, req_path, req_value=None, req_from=None):
    """Modifies an attribute of the artifact

    Parameters
    ----------
    user_id : int
        The id of the user performing the patch operation
    study_id : int
        The id of the study on which we will be performing the patch operation
    req_op : str
        The operation to perform on the study
    req_path : str
        The attribute to patch
    req_value : str, optional
        The value that needs to be modified
    req_from : str, optional
        The original path of the element

    Returns
    -------
    dict of {str, str}
        A dictionary with the following keys:
        - status: str, whether if the request is successful or not
        - message: str, if the request is unsuccessful, a human readable error
    """
    if req_op == 'replace':
        req_path = [v for v in req_path.split('/') if v]
        if len(req_path) != 1:
            return {'status': 'error',
                    'message': 'Incorrect path parameter'}

        attribute = req_path[0]

        # Check if the user actually has access to the study
        access_error = check_access(study_id, user_id)
        if access_error:
            return access_error
        study = Study(study_id)

        if attribute == 'tags':
            message = study.update_tags(User(user_id), req_value)
            return {'status': 'success',
                    'message': message}
        else:
            # We don't understand the attribute so return an error
            return {'status': 'error',
                    'message': 'Attribute "%s" not found. '
                               'Please, check the path parameter' % attribute}
    else:
        return {'status': 'error',
                'message': 'Operation "%s" not supported. '
                           'Current supported operations: replace' % req_op}
开发者ID:josenavas,项目名称:QiiTa,代码行数:55,代码来源:studies.py


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