コード例 #1
0
def test_ckanerror():
    try:
        raise exceptions.CKANError({
            'message': 'this is a test',
            '__type': 'A custom type'
        })
    except exceptions.CKANError as e:
        print e
        print e.__repr__
    raise exceptions.CKANError({
        'message': 'this is a test',
        '__type': 'A custom type'
    })
コード例 #2
0
ファイル: organization.py プロジェクト: xxxGARUxxx/libckan
def organization_list_for_user(client=client.Client(), permission=''):
    """
    Return the list of organizations that the user is a member of.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param permission: the permission the user has against the returned organizations
      (optional, default: ``edit_group``)
    :type permission: string

    :returns: the names of organizations the user is authorized to do specific permission
    :rtype: list of strings

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='organization_list_for_user', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #3
0
ファイル: related.py プロジェクト: xxxGARUxxx/libckan
def related_show(client=client.Client(), id=''):
    """
    Return a single related item.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the id of the related item to show
    :type id: string

    :rtype: dictionary

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='related_show', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #4
0
def tag_show(client=client.Client(), id=''):
    """
    Return the details of a tag and all its datasets.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the name or id of the tag
    :type id: string

    :returns: the details of the tag, including a list of all of the tag's
        datasets and their details
    :rtype: dictionary

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='tag_show', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #5
0
ファイル: group.py プロジェクト: xxxGARUxxx/libckan
def group_list_authz(client=client.Client(), available_only=''):
    """
    Return the list of groups that the user is authorized to edit.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param available_only: remove the existing groups in the package
      (optional, default: ``False``)
    :type available_only: boolean

    :returns: the names of groups that the user is authorized to edit
    :rtype: list of strings

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='group_list_authz', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #6
0
def organization_activity_list_html(client=client.Client(), id=''):
    """
    Return a organization's activity stream as HTML.

    The activity stream is rendered as a snippet of HTML meant to be included
    in an HTML page, i.e. it doesn't have any HTML header or footer.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the id or name of the organization
    :type id: string

    :rtype: string

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='organization_activity_list_html', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #7
0
ファイル: user.py プロジェクト: xxxGARUxxx/libckan
def user_list(client=client.Client(), q='', order_by=''):
    """
    Return a list of the site's user accounts.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param q: restrict the users returned to those whose names contain a string
      (optional)
    :type q: string
    :param order_by: which field to sort the list by (optional, default:
      ``'name'``)
    :type order_by: string

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='user_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #8
0
def dashboard_new_activities_count(client=client.Client()):
    """
    Return the number of new activities in the user's dashboard.

    Return the number of new activities in the authorized user's dashboard
    activity stream.

    Activities from the user herself are not counted by this function even
    though they appear in the dashboard (users don't want to be notified about
    things they did themselves).

    :rtype: int

   

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
     

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='dashboard_new_activities_count', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #9
0
ファイル: package.py プロジェクト: xxxGARUxxx/libckan
def group_package_show(client=client.Client(), id='', limit=''):
    """
    Return the datasets (packages) of a group.


    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the id or name of the group
    :type id: string
    :param limit: the maximum number of datasets to return (optional)
    :type limit: int

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='group_package_show', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #10
0
ファイル: user.py プロジェクト: xxxGARUxxx/libckan
def user_autocomplete(client=client.Client(), q='', limit=''):
    """
    Return a list of user names that contain a string.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param q: the string to search for
    :type q: string
    :param limit: the maximum number of user names to return (optional,
        default: 20)
    :type limit: int

    :rtype: a list of user dictionaries each with keys ``'name'``,
        ``'fullname'``, and ``'id'``

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='user_autocomplete', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #11
0
def revision_list(client=client.Client()):
    """
    Return a list of the IDs of the site's revisions.

    :rtype: list of strings

   

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
     

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='revision_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #12
0
ファイル: user.py プロジェクト: xxxGARUxxx/libckan
def user_show(client=client.Client(), id='', user_obj=''):
    """
    Return a user account.

    Either the ``id`` or the ``user_obj`` parameter must be given.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the id or name of the user (optional)
    :type id: string
    :param user_obj: the user dictionary of the user (optional)
    :type user_obj: user dictionary

    :rtype: dictionary

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='user_show', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #13
0
ファイル: package.py プロジェクト: xxxGARUxxx/libckan
def package_autocomplete(client=client.Client(), q=''):
    """
    Return a list of datasets (packages) that match a string.

    Datasets with names or titles that contain the query string will be
    returned.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param q: the string to search for
    :type q: string

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='package_autocomplete', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #14
0
ファイル: package.py プロジェクト: xxxGARUxxx/libckan
def package_relationships_list(client=client.Client(), id='', id2='', rel=''):
    """
    Return a dataset (package)'s relationships.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the id or name of the package
    :type id: string
    :param id2:
    :type id2:
    :param rel:
    :type rel:

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='package_relationships_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #15
0
def roles_show(client=client.Client(), domain_object='', user=''):
    """
    Return the roles of all users and authorization groups for an object.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param domain_object: a package or group name or id
        to filter the results by
    :type domain_object: string
    :param user: a user name or id
    :type user: string

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='roles_show', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #16
0
def tag_search(client=client.Client(),
               query='',
               vocabulary_id='',
               fields='',
               limit='',
               offset=''):
    """
    Return a list of tags whose names contain a given string.

    By default only free tags (tags that don't belong to any vocabulary) are
    searched. If the ``vocabulary_id`` argument is given then only tags
    belonging to that vocabulary will be searched instead.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param query: the string(s) to search for
    :type query: string or list of strings
    :param vocabulary_id: the id or name of the tag vocabulary to search in
      (optional)
    :type vocabulary_id: string
    :param fields: deprecated
    :type fields: dictionary
    :param limit: the maximum number of tags to return
    :type limit: int
    :param offset: when ``limit`` is given, the offset to start returning tags
        from
    :type offset: int

    :returns: A dictionary with the following keys:

      ``'count'``
        The number of tags in the result.

      ``'results'``
        The list of tags whose names contain the given string, a list of
        dictionaries.

    :rtype: dictionary

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='tag_search', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #17
0
ファイル: test_resource.py プロジェクト: xxxGARUxxx/libckan
def test_resource_show():
    results = get.resource_search(client=client.Client(), query='name:csv')
    assert results['success'] is True
    if results['result']['count'] > 0:
        res_orig = results['result']['results'][0]
        try:
            res_show = get.resource_show(client=client.Client(),
                                         id=res_orig['id'])
            assert results['success'] is True
            assert res_show['id'] == res_orig['id']
        except exceptions.CKANError, e:
            if str(e.type).lower().find('auth') >= 0:
                return
            else:
                raise exceptions.CKANError(e)
コード例 #18
0
ファイル: organization.py プロジェクト: xxxGARUxxx/libckan
def organization_list(client=client.Client(),
                      order_by='',
                      sort='',
                      organizations='',
                      all_fields=''):
    """
    Return a list of the names of the site's organizations.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param order_by: the field to sort the list by, must be ``'name'`` or
      ``'packages'`` (optional, default: ``'name'``) Deprecated use sort.
    :type order_by: string
    :param sort: sorting of the search results.  Optional.  Default:
        "name asc" string of field name and sort-order. The allowed fields are
        'name' and 'packages'
    :type sort: string
    :param organizations: a list of names of the groups to return, if given only
        groups whose names are in this list will be returned (optional)
    :type organizations: list of strings
    :param all_fields: return full group dictionaries instead of  just names
        (optional, default: ``False``)
    :type all_fields: boolean

    :rtype: list of strings

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='organization_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #19
0
ファイル: related.py プロジェクト: xxxGARUxxx/libckan
def related_list(client=client.Client(), id='', dataset='', type_filter='', sort='', featured=''):
    """
    Return a dataset's related items.

    Either the ``id`` or the ``dataset`` parameter must be given.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: id or name of the dataset (optional)
    :type id: string
    :param dataset: dataset dictionary of the dataset (optional)
    :type dataset: dictionary
    :param type_filter: the type of related item to show (optional,
      default: None, show all items)
    :type type_filter: string
    :param sort: the order to sort the related items in, possible values are
      'view_count_asc', 'view_count_desc', 'created_asc' or 'created_desc'
      (optional)
    :type sort: string
    :param featured: whether or not to restrict the results to only featured
      related items (optional, default: False)
    :type featured: bool

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='related_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #20
0
def tag_list(client=client.Client(), query='', vocabulary_id='',
             all_fields=''):
    """
    Return a list of the site's tags.

    By default only free tags (tags that don't belong to a vocabulary) are
    returned. If the ``vocabulary_id`` argument is given then only tags
    belonging to that vocabulary will be returned instead.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param query: a tag name query to search for, if given only tags whose
        names contain this string will be returned (optional)
    :type query: string
    :param vocabulary_id: the id or name of a vocabulary, if give only tags
        that belong to this vocabulary will be returned (optional)
    :type vocabulary_id: string
    :param all_fields: return full tag dictionaries instead of just names
        (optional, default: ``False``)
    :type all_fields: boolean

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='tag_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #21
0
def dashboard_activity_list(client=client.Client(), offset='', limit=''):
    """
    Return the authorized user's dashboard activity stream.

    Unlike the activity dictionaries returned by other ``*_activity_list``
    actions, these activity dictionaries have an extra boolean value with key
    ``is_new`` that tells you whether the activity happened since the user last
    viewed her dashboard (``'is_new': True``) or not (``'is_new': False``).

    The user's own activities are always marked ``'is_new': False``.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param offset: where to start getting activity items from
        (optional, default: 0)
    :type offset: int
    :param limit: the maximum number of activities to return
        (optional, default: 31, the default value is configurable via the
        ``ckan.activity_list_limit`` setting)

    :rtype: list of activity dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='dashboard_activity_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #22
0
def recently_changed_packages_activity_list_html(
        client=client.Client(), offset='', limit=''):
    """
    Return the activity stream of all recently changed packages as HTML.

    The activity stream includes all recently added or changed packages. It is
    rendered as a snippet of HTML meant to be included in an HTML page, i.e. it
    doesn't have any HTML header or footer.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param offset: where to start getting activity items from
        (optional, default: 0)
    :type offset: int
    :param limit: the maximum number of activities to return
        (optional, default: 31, the default value is configurable via the
        ckan.activity_list_limit setting)
    :type limit: int

    :rtype: string

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(
        action='recently_changed_packages_activity_list_html', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #23
0
def user_activity_list(client=client.Client(), id='', offset='', limit=''):
    """
    Return a user's public activity stream.

    You must be authorized to view the user's profile.


    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the id or name of the user
    :type id: string
    :param offset: where to start getting activity items from
        (optional, default: 0)
    :type offset: int
    :param limit: the maximum number of activities to return
        (optional, default: 31, the default value is configurable via the
        ckan.activity_list_limit setting)
    :type limit: int

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='user_activity_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #24
0
ファイル: status.py プロジェクト: xxxGARUxxx/libckan
def task_status_show(
        client=client.Client(), id='', entity_id='', task_type='', key=''):
    """
    Return a task status.

    Either the ``id`` parameter *or* the ``entity_id``, ``task_type`` *and*
    ``key`` parameters must be given.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the id of the task status (optional)
    :type id: string
    :param entity_id: the entity_id of the task status (optional)
    :type entity_id: string
    :param task_type: the task_type of the task status (optional)
    :type tast_type: string
    :param key: the key of the task status (optional)
    :type key: string

    :rtype: dictionary

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='task_status_show', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #25
0
ファイル: user.py プロジェクト: xxxGARUxxx/libckan
def member_list(client=client.Client(), id='', object_type='', capacity=''):
    """
    Return the members of a group.

    The user must have permission to 'get' the group.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param id: the id or name of the group
    :type id: string
    :param object_type: restrict the members returned to those of a given type,
      e.g. ``'user'`` or ``'package'`` (optional, default: ``None``)
    :type object_type: string
    :param capacity: restrict the members returned to those with a given
      capacity, e.g. ``'member'``, ``'editor'``, ``'admin'``, ``'public'``,
      ``'private'`` (optional, default: ``None``)
    :type capacity: string

    :rtype: list of (id, type, capacity) tuples

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='member_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #26
0
ファイル: term.py プロジェクト: xxxGARUxxx/libckan
def term_translation_show(client=client.Client(), terms='', lang_codes=''):
    """
    Return the translations for the given term(s) and language(s).

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param terms: the terms to search for translations of, e.g. ``'Russian'``,
        ``'romantic novel'``
    :type terms: list of strings
    :param lang_codes: the language codes of the languages to search for
        translations into, e.g. ``'en'``, ``'de'`` (optional, default is to
        search for translations into any language)
    :type lang_codes: list of language code strings

    :rtype: a list of term translation dictionaries each with keys ``'term'``
        (the term searched for, in the source language), ``'term_translation'``
        (the translation of the term into the target language) and
        ``'lang_code'`` (the language code of the target language)

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='term_translation_show', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #27
0
ファイル: package.py プロジェクト: xxxGARUxxx/libckan
def current_package_list_with_resources(
        client=client.Client(), limit='', page=''):
    """
    Return a list of the site's datasets (packages) and their resources.

    The list is sorted most-recently-modified first.

    

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    :param limit: if given, the list of datasets will be broken into pages of
        at most ``limit`` datasets per page and only one page will be returned
        at a time (optional)
    :type limit: int
    :param page: when ``limit`` is given, which page to return
    :type page: int

    :rtype: list of dictionaries

    

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='current_package_list_with_resources',
                          data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #28
0
ファイル: status.py プロジェクト: xxxGARUxxx/libckan
def status_show(client=client.Client()):
    """
    Return a dictionary with information about the site's configuration

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    .

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='status_show', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #29
0
def member_roles_list(client=client.Client()):
    """
    <TODO: DESCRIPTION>

    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client
    <TODO: PARAMETERS>

    :returns: the dictionary returned by the CKAN API, 
        with the keys "help","result", and "success". 
        "results" is a list of packages (dict).
    :return: dict

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='member_roles_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp
コード例 #30
0
ファイル: package.py プロジェクト: xxxGARUxxx/libckan
def package_list(client=client.Client()):
    """
    Return a list of the names of the site's datasets (packages).

    :rtype: list of strings


    :param client: the CKAN Client. 
        Default: an instance of libckan.model.client.Client
    :type client: libckan.model.client.Client

    :returns: A list of names of the packages.
    :return: [str]

    Raises: :class:`libckan.model.exceptions.CKANError`: 
        An error occurred accessing CKAN API
    """
    args = client.sanitize_params(locals())

    resp = client.request(action='package_list', data=args)
    if not resp['success']:
        raise exceptions.CKANError(resp.error)
    return resp