heimpt.merge

This program is a utility file to merge a JATS/BITS XML section into a BIS-XML files

The current functions are limited to JATS and BITS XML Scheme of the Library of Congress. However the methods defined in this program can be used to modify any element tree.

Usage:

merge.py <input_file> <path> <scheme> [options]

merge.py -h –help

Options:

-o –out-file=<output_file_name_without_escapes> -d –debug Enable debug output -m –metadata=<file__name_schema.xml> -n –set-numbering-tags=<elemennt types as comma seperated lists>

References

Module Contents

heimpt.merge.__author__ = Dulip Withanage[source]
heimpt.merge.PYTHON_IMPORT_FAILED_LXML_MODULE = Failed to import python lxml module[source]
class heimpt.merge.Merge[source]

Bases: debug.Debuggable

Standalone Processing object which merges current JATS/BITS XML file in to the Body of a BITS-XML document.

static read_command_line()[source]

Reads and generates a docopt dictionary from the command line parameters.

docoptdictionary

A dictionary, where keys are names of command-line elements such as and values are theparsed values of those elements.

create_output_bits(self)[source]

Create bits output file, generates a new file, if no file is found. Otherwise the current file is appended to the book body as a book-part.

create_book_part_bits, create_book_bits, do_file_io

create_output_jats(self)[source]

Create jats output file, generates a new file,

create_book_part_bits, create_book_bits, do_file_io

process(self, tr)[source]

Process BITS-XML file and do all transformations into the elementtree

trelementtree

element tree as input

trelementtree

transformed element tree

globals.set_numbering_tags(), set_book_part_attributes()

set_book_part_attributes(self, tr)[source]

Add specific attributes to book-part

trelementtree

element tree as input

trelementtree

transformed element tree

create_metadata_path(self, metadata)[source]

creates the correct folder path for the metadata file. Metadata files should be in a folder : metadata

metadatastr

Suffix of the metadata files

pthstr

Correct path of the metadata file in the folder structure

We assume that metadata files are stored in a sub-folder named metadata

get_module_name(self)[source]

Reads the name of the module for debugging and logging

name string

Name of the Module

create_book_bits(self)[source]

creates a full BITS XML book and optionally adds metadata

bookelementtree

Elementtree which complies to BITS XML Scheme.

create_metadata_path, create_book_part_bits

create_journal_jats(self)[source]

creates a full JATS XML book and optionally adds metadata

bookelementtree

Elementtree which complies to BITS XML Scheme.

create_metadata_path, create_book_part_bits

create_book_part_bits(self)[source]

Reads a JATS XMl File and creates a book-part element tree according to BITS-XML.

bpelementtree

Book part elementTree

get_xml_parts(self)[source]

Returns the front-matter , body and back-matter of a JATS XML file in the above order

felementtree

Front-matter of JATS elementTree

bdelementtree

Body of JATS elementTree

bkelementtree

Back-matter of JATS elementTree

do_file_io(self, s, mode, pth)[source]

Executes read or write operations on a path

s: str

Content to be written or None for read

mode: str

w for write , r for r

pthstr

Path to the file to be read or written

IOError

I/O operation fails

run(self)[source]

Runs the configuration on the processing object. Process JATS-XML file and merges it into the full BITS-XML file

create_output_bits

function create_output_jats not yet used

heimpt.merge.main()[source]

Initializes a processing object from a xml file and and runs it.

run