def format_element(bfo, us="yes"):
    """
    Returns either a date in 961__x or the date of record creation. 

    @param bfo: BibFormatObject for current record
    @type nfo: object

    @return: string of formatted date, or None of no date is found.
    """
    date = bfo.field("961__x").strip()
    if not date:
        return bfe_creation_date.format_element(bfo)
    return date
def format_element(bfo, us="yes"):
    """
    Returns either a date in 961__x or the date of record creation. 

    @param bfo: BibFormatObject for current record
    @type nfo: object

    @return: string of formatted date, or None of no date is found.
    """
    date = bfo.field("961__x").strip()
    if not date:
        return bfe_creation_date.format_element(bfo)
    return date
Example #3
0
def get_latest_deposits():
	NUMBER_OF_RECORDS = 4;
	from invenio.search_engine import perform_request_search
	ids = perform_request_search(of="id", rg=NUMBER_OF_RECORDS, sf="005", so="a")
	limit_ids = ids[:NUMBER_OF_RECORDS]

	from invenio.bibformat_engine import BibFormatObject
	bfo_list = [BibFormatObject(id) for id in limit_ids]

	from invenio.bibformat_elements import bfe_authors
	from invenio.bibformat_elements import bfe_title
	from invenio.bibformat_elements import bfe_creation_date
	
	recs = [{
		"id": bfo.recID,
		"date": bfe_creation_date.format_element(bfo),
		"author": bfe_authors.format_element(bfo),
		"title": bfe_title.format_element(bfo),
		"description": bfo.field("520__a"), 
		"category": bfo.field("980__a"), 
	} for bfo in bfo_list]
	return recs