Commit d9f5c7de authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Sphinx documentation for the modules check_tools.

parent 9616f34f
callbacks
---------
A collections of functions used in the database callback: ``_before_delete``,
``before_insert`` and ``_before_update``. They protect the database against
forbidden actions.
.. currentmodule:: callbacks
.. autosummary::
:toctree: generated/
~callbacks.INHIBIT_CASCADE_DELETE
~callbacks.INHIBIT_DUPLICATE_PUBLICATION
~callbacks.INHIBIT_HARVESTER_ON_CATEGORY
~callbacks.INHIBIT_PUBLICATION_DELETE_ON_OK
~callbacks.INHIBIT_PUBLICATION_UPDATE_ON_OK
check_tools.check_publication
=============================
.. currentmodule:: check_tools
.. autofunction:: check_publication
\ No newline at end of file
check_tools.duplicate_article
=============================
.. currentmodule:: check_tools
.. autofunction:: duplicate_article
\ No newline at end of file
check_tools.duplicate_conference
================================
.. currentmodule:: check_tools
.. autofunction:: duplicate_conference
\ No newline at end of file
check_tools.duplicate_origin
============================
.. currentmodule:: check_tools
.. autofunction:: duplicate_origin
\ No newline at end of file
check_tools.duplicate_report
============================
.. currentmodule:: check_tools
.. autofunction:: duplicate_report
\ No newline at end of file
check_tools.extend_ids
======================
.. currentmodule:: check_tools
.. autofunction:: extend_ids
\ No newline at end of file
......@@ -11,7 +11,7 @@ API Documentation
invenio
harvester
callbacks
tools
Indices and tables
==================
......
tools
-----
callbacks
^^^^^^^^^
A collections of functions used in the database callback: ``_before_delete``,
``before_insert`` and ``_before_update``. They protect the database against
forbidden actions.
.. currentmodule:: callbacks
.. autosummary::
:toctree: generated/
~INHIBIT_CASCADE_DELETE
~INHIBIT_DUPLICATE_PUBLICATION
~INHIBIT_HARVESTER_ON_CATEGORY
~INHIBIT_PUBLICATION_DELETE_ON_OK
~INHIBIT_PUBLICATION_UPDATE_ON_OK
check_tools
^^^^^^^^^^^
A collection of functions to check the the consistency of the
publication table and to validate that publication fields match expectation
rules.
.. currentmodule:: check_tools
.. autosummary::
:toctree: generated/
~check_publication
~extend_ids
~duplicate_article
~duplicate_conference
~duplicate_origin
~duplicate_report
\ No newline at end of file
# -*- coding: utf-8 -*-
"""a collection of tools to check rows.
@author: R. Le Gac
"""
import re
import regex
......@@ -23,14 +21,14 @@ REG_HTML = re.compile('&[a-z]+;')
def check_publication(row):
"""Check the publication fields.
@type row: gluon.dal.Row
@param row: record defining a publication. Its contains the publications
table as well as its reference tables.
Args:
row (gluon.dal.Row): record defining a publication.
Its contains the publications table as well as its foreign tables.
@rtype: tuple
@return:
- the first element contains the list of message
- the second one contains the list of duplicate ids.
Returns:
tuple:
* the first element contains the list of message
* the second one contains the list of duplicate *ids*.
"""
T, li, idset = current.T, [], set()
......@@ -183,19 +181,15 @@ def check_publication(row):
def extend_ids(db, query, ids):
"""helper functions
@type db: gluon.dal.DAL
@param db:
"""Extend list of publication *ids* with those found by the *query*.
@type query: gluon.dal.query
@param query:
Note:
The *id* are unique in the list.
@type ids: list of string
@param ids: the current list of ids
@note: the current list of publication ids will be extend by those
corresponding to the C{query}. The id are unique in the list.
Args:
db (gluon.dal.DAL): database connection.
query (gluon.dal.query): database query
ids (list of string): the current list of *ids*
"""
set_records = db(query)
......@@ -208,18 +202,20 @@ def extend_ids(db, query, ids):
def duplicate_article(publication):
"""Look for duplicate article.
The comparison is performed on article published by the given team
using the following criteria:
- title, publishers, volume and pages
- publisher, volume and pages
- publisher and title
* title, publishers, volume and pages
* publisher, volume and pages
* publisher and title
@type publication: dict or gluon.storage.Storage
@param publication: contains the publication fields and theirs values
Args:
publication (dict or gluon.storage.Storage): contains the
publication fields and theirs values.
@rtype: list
@return: list of ids corresponding to duplicate entries
Returns:
list: list of *ids* corresponding to duplicate entries.
"""
ids = []
......@@ -260,18 +256,20 @@ def duplicate_article(publication):
def duplicate_conference(publication):
"""Look for duplicate talk / proceeding.
The comparison is performed on conference talk/proceeding published
by the given team using the following criteria:
- title, conference title, conference date and conference town
- title, conference date and conference town
- title, conference title and conference town
* title, conference title, conference date and conference town
* title, conference date and conference town
* title, conference title and conference town
@type publication: dict or gluon.storage.Storage
@param publication: contains the publication fields and theirs values
Args:
publication (dict or gluon.storage.Storage): contains the publication
fields and theirs values.
@rtype: list
@return: list of ids corresponding to duplicate entries
Returns:
list: list of *ids* corresponding to duplicate entries.
"""
ids = []
......@@ -318,11 +316,12 @@ def duplicate_conference(publication):
def duplicate_origin(publication):
"""Look for publications with the same value in the origin field.
@type publication: dict or gluon.storage.Storage
@param publication: contains the publication fields and theirs values
Args:
publication (dict or gluon.storage.Storage): contains the publication
fields and theirs values.
@rtype: list
@return: list of ids corresponding to duplicate entries
Returns:
list: list of *ids* corresponding to duplicate entries.
"""
ids = []
......@@ -348,16 +347,16 @@ def duplicate_origin(publication):
def duplicate_report(publication):
"""Look for duplicate report.
The comparison is performed on report published by the given team
using the following criteria:
- title
The comparison is performed on report published by the given team
using the *title*.
@type publication: dict or gluon.storage.Storage
@param publication: contains the publication fields and theirs values
Args:
publication (dict or gluon.storage.Storage): contains the publication
fields and theirs values.
@rtype: list
@return: list of ids corresponding to duplicate entries
Returns:
list: list of *ids* corresponding to duplicate entries.
"""
ids = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment