Package pology :: Module merge

Module merge

Merge PO files.


Author: Chusslove Illich (Часлав Илић) <caslav.ilic@gmx.net>

License: GPLv3

Functions
bool or Catalog or None
merge_pofile(catpath, tplpath, outpath=None, update=False, wrapping=None, fuzzymatch=True, cmppaths=None, quiet=False, fuzzex=False, minwnex=0, minasfz=0.0, refuzzy=False, getcat=False, monitored=True, ignpotdate=False, abort=False)
Merge a PO file with the PO template.
Variables
  __package__ = 'pology'
Function Details

merge_pofile(catpath, tplpath, outpath=None, update=False, wrapping=None, fuzzymatch=True, cmppaths=None, quiet=False, fuzzex=False, minwnex=0, minasfz=0.0, refuzzy=False, getcat=False, monitored=True, ignpotdate=False, abort=False)

 

Merge a PO file with the PO template.

This function is a frontend to msgmerge command, providing some additional features on demand.

This function is usually used in one of three ways:

  • create a new PO file: the path is given with outpath parameter
  • update the original PO file: update is set to True and outpath is not given
  • only get merged catalog object: getcat is set to True and neither outpath nor update are issued; no PO file gets created or modified (except for temporaries, which are cleaned up on return)
  • check whether merging is possible: neither of outpath, update, or getcat are issued; if True is returned, merging succedded.

The return value differs based on getcat. If getcat is False, the return value is True if merging succedded (msgmerge exited normally), and False if not. If getcat is True, a catalog object on the merged catalog is returned if the merging succedded, and None if not. However, if abort is set to True, if msgmerge fails the program aborts with an error message.

When catalog object is returned, its sync state is undefined. If it needs to be in sync before use, it should be synced manually.

Parameters:
  • catpath (string) - path to PO file to merge
  • tplpath (string) - path to PO template
  • outpath (string) - path to output PO file
  • update (bool) - whether to update the PO file in place
  • wrapping (sequence of strings) - the wrapping policy (see the parameter of the same name to catalog constructor)
  • fuzzymatch (bool) - whether to perform fuzzy matching
  • cmppaths (sequence of strings) - paths to compendium files to be used on merging
  • quiet (bool) - whether msgmerge should operate quietly
  • fuzzex (bool) - whether to fuzzy exact matches from compendia
  • minwnex (int) - minimal number of words in the original in exact match from compendia to not fuzzy the message (a very large number approximates fuzzex set to True).
  • refuzzy (bool) - whether to "rebase" fuzzy messages, i.e. remove prior to merging those fuzzy messages whose translated counterparts (determined by previous fields) still exist in the catalog. This puts possibly newer translation into such messages, or even leads to a better fuzzy match.
  • getcat (Catalog or None) - whether to return catalog object on merged file
  • monitored (bool) - if getcat is in effect, whether to open catalog in monitoring mode (like the parameter to catalog constructor)
  • ignpotdate (bool) - whether to ignore changed POT-Creation-Date if there were no other changes, resetting it to original value
  • abort (bool) - whether to abort execution if msgmerge fails
Returns: bool or Catalog or None
whether merging succedded, or catalog object