Package pology :: Module remove

Module remove

Remove special substrings from text.


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

License: GPLv3

Functions
 
remove_accel_text(text, msg, cat)
Remove accelerator marker from one of the text fields of the message [type F3A hook].
 
remove_accel_text_greedy(text, msg, cat)
Like remove_accel_text, except that if catalog reports None for accelerators, some frequent marker characters are removed [type F3A hook].
 
remove_accel_msg(msg, cat)
Remove accelerator marker from all applicable text fields in the message, as if remove_accel_text was applied to each [type F4A hook].
 
remove_accel_msg_greedy(msg, cat)
Like remove_accel_msg, except that if catalog reports None for accelerators, some frequent marker characters are removed [type F4A hook].
 
remove_markup_text(text, msg, cat)
Remove markup from one of the text fields of the message [type F3A hook].
 
remove_markup_msg(msg, cat)
Remove markup from all applicable text fields in the message, as if remove_markup_text was applied to each [type F4A hook].
 
remove_fmtdirs_text(text, msg, cat)
Remove format directives from one of the text fields of the message [type F3A hook].
(cat, msg, text) -> text
remove_fmtdirs_text_tick(tick)
Like remove_fmtdirs_text, except that each format directive is replaced by a non-whitespace "tick" instead of plainly removed [hook factory].
 
remove_fmtdirs_msg(msg, cat)
Remove format directives from all applicable text fields in the message, as if remove_fmtdirs_text was applied to each [type F4A hook].
(cat, msg, text) -> numerr
remove_fmtdirs_msg_tick(tick)
Remove format directives from all applicable text fields in the message, as if remove_fmtdirs_text_tick was applied to each [hook factory].
 
remove_literals_text(text, msg, cat)
Remove literal segments from one of the text fields of the message [type F3A hook].
(cat, msg, text) -> text
remove_literals_text_tick(tick)
Like remove_literals_text, except that each literal segment is replaced by a non-whitespace "tick" instead of plainly removed [hook factory].
 
remove_literals_msg(msg, cat)
Remove literal segments from all applicable text fields in the message, as if remove_literals_text was applied to each [type F4A hook].
(cat, msg, text) -> numerr
remove_literals_msg_tick(tick)
Remove literal segments from all applicable text fields in the message, as if remove_literals_text_tick was applied to each [hook factory].
 
remove_marlits_text(text, msg, cat)
Remove literals by markup from one of the text fields of the message [type F3A hook].
 
remove_marlits_msg(msg, cat)
Remove literal segments by markup from all applicable text fields in the message, as if remove_marlits_text was applied to each [type F4A hook].
 
remove_ignored_entities_msg(msg, cat)
Remove locally ignored entities from all applicable text fields in the message [type F4A hook].
 
rewrite_msgid(msg, cat)
Rewrite parts of msgid based on translator comments [type F4A hook].
 
rewrite_inverse(msg, cat)
Rewrite message by replacing all its elements with that of another message which has the same msgstr[0] [type F4A hook].
 
remove_paired_ents(msg, cat)
Remove all XML-like entities from original, and from translation all that are also found in original [type F4A hook].
(cat, msg, text) -> text
remove_paired_ents_tick(tick)
Like remove_paired_ents, except that each XML-like entity is replaced by a non-whitespace "tick" instead of plainly removed [hook factory].
Variables
  __package__ = 'pology'
Function Details

remove_accel_text(text, msg, cat)

 

Remove accelerator marker from one of the text fields of the message [type F3A hook].

Accelerator marker is determined from the catalog, by calling its accelerator() method. Use set_accelerator() to set possible accelerator markers after the catalog has been opened, in case it does not specify any on its own. If catalog reports None for accelerators, text is not touched.

Accelerator marker can also be specified for a particular message, by embedded accelerator-marker field in manual comments:

   # accelerator-marker: _

This overrides accelerator marker reported by the catalog.

Returns:
text

remove_accel_text_greedy(text, msg, cat)

 

Like remove_accel_text, except that if catalog reports None for accelerators, some frequent marker characters are removed [type F3A hook].

Returns:
text

remove_accel_msg(msg, cat)

 

Remove accelerator marker from all applicable text fields in the message, as if remove_accel_text was applied to each [type F4A hook].

Returns:
number of errors

remove_accel_msg_greedy(msg, cat)

 

Like remove_accel_msg, except that if catalog reports None for accelerators, some frequent marker characters are removed [type F4A hook].

Returns:
number of errors

remove_markup_text(text, msg, cat)

 

Remove markup from one of the text fields of the message [type F3A hook].

Expected markup types are determined from the catalog, by calling its markup() method. Use set_markup() to set expected markup types after the catalog has been opened, in case it does not specify any on its own. If catalog reports None for markup types, text is not touched.

Returns:
text

remove_markup_msg(msg, cat)

 

Remove markup from all applicable text fields in the message, as if remove_markup_text was applied to each [type F4A hook].

Returns:
number of errors

remove_fmtdirs_text(text, msg, cat)

 

Remove format directives from one of the text fields of the message [type F3A hook].

The type of format directives is determined from message format flags.

Returns:
text

remove_fmtdirs_text_tick(tick)

 

Like remove_fmtdirs_text, except that each format directive is replaced by a non-whitespace "tick" instead of plainly removed [hook factory].

Parameters:
  • tick (string) - the tick sequence
Returns: (cat, msg, text) -> text
type F3A hook

remove_fmtdirs_msg(msg, cat)

 

Remove format directives from all applicable text fields in the message, as if remove_fmtdirs_text was applied to each [type F4A hook].

Returns:
number of errors

remove_fmtdirs_msg_tick(tick)

 

Remove format directives from all applicable text fields in the message, as if remove_fmtdirs_text_tick was applied to each [hook factory].

Parameters:
  • tick (string) - the tick sequence
Returns: (cat, msg, text) -> numerr
type F4A hook

remove_literals_text(text, msg, cat)

 

Remove literal segments from one of the text fields of the message [type F3A hook].

Literal segments are URLs, email addresses, command line options, etc. anything symbolic that the machine, rather than human alone, should parse. Note format directives are excluded here, see remove_fmtdirs_text for removing them.

By default, literals are removed heuristically, but this can be influenced by embedded literal-segment fields in manual comments. For example:

   # literal-segment: foobar

states that all foobar segments are literals. The field value is actually a regular expression, and there may be several such fields:

   # literal-segment: \w+bar
   # literal-segment: foo[&=] ### a sub comment

To prevent any heuristic removal of literals, add a literal-segment field with empty value.

Returns:
text

remove_literals_text_tick(tick)

 

Like remove_literals_text, except that each literal segment is replaced by a non-whitespace "tick" instead of plainly removed [hook factory].

Parameters:
  • tick (string) - the tick sequence
Returns: (cat, msg, text) -> text
type F3A hook

remove_literals_msg(msg, cat)

 

Remove literal segments from all applicable text fields in the message, as if remove_literals_text was applied to each [type F4A hook].

Returns:
number of errors

remove_literals_msg_tick(tick)

 

Remove literal segments from all applicable text fields in the message, as if remove_literals_text_tick was applied to each [hook factory].

Parameters:
  • tick (string) - the tick sequence
Returns: (cat, msg, text) -> numerr
type F4A hook

remove_marlits_text(text, msg, cat)

 

Remove literals by markup from one of the text fields of the message [type F3A hook].

An "intersection" of remove_markup_text and remove_literals_text, where literals segments are determined by markup, and both the segment text and its markup is removed. See documentation of these hooks for notes on what is considered literal and how markup type is determined.

Returns:
text

remove_marlits_msg(msg, cat)

 

Remove literal segments by markup from all applicable text fields in the message, as if remove_marlits_text was applied to each [type F4A hook].

Returns:
number of errors

remove_ignored_entities_msg(msg, cat)

 

Remove locally ignored entities from all applicable text fields in the message [type F4A hook].

Entities are ignored by listing them in the embedded ignore-entities fields in manual comments. For example:

   # ignore-entity: foobar, froobaz

will remove entities &foobar; and &froobaz; from all text fields.

Returns:
number of errors

rewrite_msgid(msg, cat)

 

Rewrite parts of msgid based on translator comments [type F4A hook].

Translator comments may issue rewrite-msgid directives to modify parts of msgid (as well as msgid_plural) fields by applying a search regular expression and replace pattern. The search and replace pattern are wrapped and separated by any character consistently used, such as slashes. Examples:

   # rewrite-msgid: /foo/bar/
   # rewrite-msgid: /foo (\w+) fam/bar \1 bam/
   # rewrite-msgid: :foo/bar:foo/bam:

If a search pattern is not valid, a warning on message is issued.

Search pattern is case-sensitive.

Returns:
number of errors

rewrite_inverse(msg, cat)

 

Rewrite message by replacing all its elements with that of another message which has the same msgstr[0] [type F4A hook].

Translator comments may issue rewrite-inverse directives to replace all message parts with those from another message having the same msgstr[0] field. The argument to the directive is a regular expression search pattern on msgid and msgctxt (leading and trailing whitespace get stripped) which is used to select the particular message if more than one other messages have same msgstr[0]. Examples:

   # rewrite-inverse:
   # rewrite-inverse: Foo

If the pattern does not match or it matches more than one other message, current message is not touched; also if the pattern is left empty and there is more than one other message. Search pattern is applied to msgctxt and msgid in turn, and the message is matched if any matches. Search pattern is case-sensitive.

If more than one rewrite-inverse directive is seen, or the search pattern is not valid, a warning on message is issued and current message is not touched.

This hook is then executed again on the resulting message, in case the new translator comments contain another rewrite-inverse directive.

Returns:
number of errors

remove_paired_ents(msg, cat)

 

Remove all XML-like entities from original, and from translation all that are also found in original [type F4A hook].

To remove all entities from original, and all entitities from translation that also exist in original, may be useful prior to markup checks, when list of known entities is not available.

Returns:
number of errors

remove_paired_ents_tick(tick)

 

Like remove_paired_ents, except that each XML-like entity is replaced by a non-whitespace "tick" instead of plainly removed [hook factory].

Parameters:
  • tick (string) - the tick sequence
Returns: (cat, msg, text) -> text
type F3A hook