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

Sphinx documentation for the Msg class.

parent 75fdf47c
harvest_tools.msg.Msg
=====================
.. currentmodule:: harvest_tools.msg
.. autoclass:: Msg
.. rubric:: Methods
.. autosummary::
:toctree: msg/
~Msg.idle
~Msg.load
~Msg.modify
~Msg.reject
harvest_tools.msg.Msg.idle
==========================
.. currentmodule:: harvest_tools.msg
.. automethod:: Msg.idle
\ No newline at end of file
harvest_tools.msg.Msg.load
==========================
.. currentmodule:: harvest_tools.msg
.. automethod:: Msg.load
\ No newline at end of file
harvest_tools.msg.Msg.modify
============================
.. currentmodule:: harvest_tools.msg
.. automethod:: Msg.modify
\ No newline at end of file
harvest_tools.msg.Msg.reject
============================
.. currentmodule:: harvest_tools.msg
.. automethod:: Msg.reject
\ No newline at end of file
......@@ -36,6 +36,14 @@ Helper functions
format_author_fr
learn_my_authors
Logger
^^^^^^
.. currentmodule:: harvest_tools.msg
.. autosummary::
:toctree: generated/
Msg
Classes
^^^^^^^
......
......@@ -10,48 +10,31 @@ from invenio_tools import OAI_URL
class Msg(Storage):
"""Message and action taken for a publication.
- The publication is found by an harvester tool, in a store.
- The action refers to the database.
Fours action are defined:
- C{idle}
- C{load}
- C{modify}
- C{reject}
The class contains the attributes:
- C{action}: action taken
- C{collection}: the harvester collection
- C{harvester}: the harvester encoded as a JSON string
- C{record_id}; the store identifier of the record
- C{title}: title of the publication
- C{txt}: text of the message
- C{url}: url of the record
- C{year}: year of the publication
"""Action taken for a publication and its associated explanation.
"""
Note:
Actions are defined with respect to the database:
* *idle* do nothing.
* *load* the record is insert in the database.
* *modify* an existing record is modified.
* *reject* the record is rejected.
Args:
collection (unicode): the harvester collection used to
search the record.
harvester (gluon.dal.Row): the database harvester used to scan the
store.
record_id (int): the record identifier in the store.
title (unicode): the title of the publication.
"""
def __init__(self,
collection=None,
harvester=None,
record_id=None,
title=None):
"""
@type collection: str
@param collection: the collection containing the record
@type harvester: gluon.dal.Row or gluon.storage.Storage
@param harvester: the current harvester used to retrieve the record.
@type record_id: int
@param record_id: the store identifier of the record
@type title: str
@param title: the title associated to the record
"""
self.action = None
self.collection = collection
......@@ -67,64 +50,52 @@ class Msg(Storage):
self.year = None
def idle(self, txt, year=None, translate=True):
"""Set the action as idle and the message as C{txt}.
"""Set the action as *idle* and the explanation as ``txt``.
@type txt: unicode
@param txt: message
@type year: unicode
@param year: year of the publication
@type translate: boolean
@param translate: translate the txt according to the current language
Args:
txt (unicode): message associated to the action.
year (unicode): year of the publication
translate (bool): translate the message according to the
current language.
"""
self.action = 'idle'
self._set(txt, year, translate)
def load(self, txt, year=None, translate=True):
"""Set the action as C{load} and the message as C{txt}.
@type txt: unicode
@param txt: message
@type year: unicode
@param year: year of the publication
"""Set the action as *load* and the explanation as ``txt``.
@type translate: boolean
@param translate: translate the txt according to the current language
Args:
txt (unicode): message associated to the action.
year (unicode): year of the publication
translate (bool): translate the message according to the
current language.
"""
self.action = 'load'
self._set(txt, year, translate)
def modify(self, txt, year=None, translate=True):
"""Set the action as C{modify} and the message as C{txt}.
"""Set the action as *modify* and the explanation as ``txt``.
@type txt: unicode
@param txt: message
@type year: unicode
@param year: year of the publication
@type translate: boolean
@param translate: translate the txt according to the current language
Args:
txt (unicode): message associated to the action.
year (unicode): year of the publication
translate (bool): translate the message according to the
current language.
"""
self.action = 'modify'
self._set(txt, year, translate)
def reject(self, txt, year=None, translate=True):
"""Set the action as C{reject} set the message as C{txt}.
@type txt: unicode
@param txt: message
@type year: unicode
@param year: year of the publication
"""Set the action as *reject* set the explanation as ``txt``.
@type translate: boolean
@param translate: translate the txt according to the current language
Args:
txt (unicode): message associated to the action.
year (unicode): year of the publication
translate (bool): translate the message according to the
current language.
"""
self.action = 'reject'
......
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