BriefRec class

class almasru.briefrecord.BriefRec(rec: Element | SruRecord)

Class representing a brief record object

You can create a brief record object from a SruRecord object or from the XML data of a MARCXML record using an Etree Element object.

The namespaces are removed from the XML data.

Variables:
  • error – boolean, is True in case of error

  • error_messages – list of string with the error messages

  • data – json object with brief record information

  • src_data – XML data of the record

  • recordSruRecord object if available

BriefRecFactory class

class almasru.briefrecord.BriefRecFactory

Class to create a brief record from a MARCXML record

The class can parse several fields of the MARCXML record. It can also summarize the result in a json object.

static check_is_online(bib: etree.Element)

Check if the record is an online record.

Use field 008 and leader. Position 23 indicate if a record is online or not (values “o”,

“q”, “s”). For visual material and maps it’s 29 position.

Parameters:

bibetree.Element

Returns:

boolean indicating whether the record is online

static extract_year(str) int | None

Extract a substring of 4 digits

Parameters:

txt – string to parse to get year

Returns:

int value with the found year or None if no year available

static get_33x_summary(bib: etree.Element) str | None

Get a summary of the 336, 337 and 338 fields

Parameters:

bibetree.Element

Returns:

summary of the 336, 337 and 338 fields

static get_bib_info(bib: etree.Element)

Return a json object with the brief record information

Parameters:

bibetree.Element

Returns:

json object with brief record information

static get_corp_creators(bib: Element) List[str] | None

get_authors(bib: etree.Element) -> Option.al[List[str]] Get the list of authors from 110$a, 111$a, 710$a and 711$a

Parameters:

bibetree.Element

Returns:

list of authors and None if not found

static get_creators(bib: Element) List[str] | None

get_authors(bib: etree.Element) -> Option.al[List[str]] Get the list of authors from 100$a, 700$a

Parameters:

bibetree.Element

Returns:

list of authors and None if not found

static get_date_1(bib: etree.Element) int | None

Get the first date of publication from 008 field

Parameters:

bibetree.Element

Returns:

Year of publication or None if not found

static get_date_2(bib: etree.Element) int | None

Get the second date of publication from 008 field

Parameters:

bibetree.Element

Returns:

Year of end of publication or None if not found

static get_editions(bib: etree.Element) List[str] | None

Returns a list of editions (fields 250$a and 250$b)

Parameters:

bibetree.Element

Returns:

list of editions or None if not found

static get_extent(bib: etree.Element)

Return extent from field 300$a

Parameters:

bibetree.Element

Returns:

list of extent or None if not found

static get_format(bib: etree.Element) str | None

Get the format of the record from leader field position 6 and 7

Parameters:

bibetree.Element

Returns:

format of the record

static get_isbns(bib: etree.Element) List[str] | None

Get a set of ISBNs

Parameters:

bibetree.Element

Returns:

set of ISBNs

static get_issns(bib: etree.Element) List[str] | None

Get a set of issns

Parameters:

bibetree.Element

Returns:

set of ISSNs

static get_language(bib: etree.Element) str | None

Return language from field 008

Parameters:

bibetree.Element

Returns:

language or None if not found

static get_leader_pos67(bib: etree.Element) str | None

Get the leader position 6 and 7

Used to determine the format of the record

Parameters:

bibetree.Element

Returns:

leader position 6 and 7 or None if not found

static get_other_std_num(bib: etree.Element) List[str] | None

Get a list of standardized numbers like DOI

Parameters:

bibetree.Element

Returns:

set of standardized numbers

static get_parent(bib: etree.Element) List[str] | None

Return a dictionary with information found in field 773

Keys of the parent dictionary: - title: title of the parent - issn: content of $x - isbn: content of $z - number: content of $g no:<content> - year: content of $g yr:<content> or first 4 digits numbers in a $g - parts: longest list of numbers in a $g

Parameters:

bibetree.Element

Returns:

list of parent information or None if not found

static get_part_title(bib: etree.Element) str | None
Parameters:

bibetree.Element

Returns:

content of 245$p or None if not found

static get_publishers(bib: etree.Element) List[str] | None

Return publishers from field 264$b

Parameters:

bibetree.Element

Returns:

list of publishers or None if not found

static get_rec_id(bib: etree.Element) str | None
static get_rec_id(bib) str | None

Get the record ID

Parameters:

bibetree.Element

Returns:

record ID or None if not found

static get_series(bib: etree.Element) List[str] | None

Return series title from field 490$a

Parameters:

bibetree.Element

Returns:

list of titles of related series or None if not found

static get_subtitle(bib: etree.Element) str | None

Get normalized content of 245$b

Parameters:

bibetree.Element

Returns:

normalized content of field 245$b or None if not found

static get_sysnums(bib: etree.Element) List[str] | None

Get a set of system numbers

Parameters:

bibetree.Element

Returns:

set of system numbers

static get_title(bib: etree.Element) str | None

Get normalized content of 245$a

Parameters:

bibetree.Element

Returns:

normalized content of field 245$a

static normalize_extent(extent: str) List[int]

Normalize extent string into list of ints

Parameters:

extent – extent to normalize

Returns:

list of ints

static normalize_isbn(isbn: str) str | None

Suppress hyphen and textual information of the provided isbn

Parameters:

isbn – raw string containing isbn

Returns:

string containing normalized isbn

static normalize_issn(issn: str) str | None

Suppress hyphen and textual information of the provided issn

Parameters:

issn – raw string containing issn

Returns:

string containing normalized issn

static normalize_title(title: str) str

Normalize title string

Idea is to remove “<<” and “>>” of the title and remove all non-alphanumeric characters.

Parameters:

title – title to normalize

Returns:

string with normalized title