Package pology :: Module comments

Module comments

Parsing and composing message comments.


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

License: GPLv3

Functions
list of strings
parse_list(comments, prefix, separator)
Extract elements of the list embedded in comments.
list of strings
manc_parse_list(msg, prefix, separator=' ')
Extract elements of the list embedded in manual comments.
list of strings
autoc_parse_list(msg, prefix, separator=' ')
Extract elements of the list embedded in auto comments.
list of strings
manc_parse_flag_list(msg, prefix)
Extract custom flags embedded in manual comments.
list of strings
autoc_parse_flag_list(msg, prefix)
Extract custom flags embedded in auto comments.
list of strings
parse_field_values(comments, field)
Extract values of a field embedded in comments.
list of strings
manc_parse_field_values(msg, field)
Extract values of a field embedded in manual comments.
list of strings
autoc_parse_field_values(msg, field)
Extract values of a field embedded in auto comments.
set of strings
parse_summit_branches(msg)
Summit: Extract branch IDs from comments.
Variables
  __package__ = None
Function Details

parse_list(comments, prefix, separator)

 

Extract elements of the list embedded in comments.

An embedded list is identified by a prefix substring in the comment, followed by list of elements separated by a certain character sequence. If several comments start by the same identifier substring, they are considered continuation of the same list (even if there are non-list comments in between).

Leading and trailing whitespace is stripped when matching for prefix substring, as well as from the parsed list elements.

Parameters:
  • comments (sequence of strings) - comments to parse
  • prefix (string) - list identifier substring
  • separator (string) - sequence separating list elements
Returns: list of strings
parsed elements

manc_parse_list(msg, prefix, separator=' ')

 

Extract elements of the list embedded in manual comments.

List elements are extracted by calling parse_list() on manual comments, passing along prefix and separtor as is.

Parameters:
  • msg (Message) - message to parse
  • prefix (string) - list identifier substring
  • separator (string) - sequence separating list elements
Returns: list of strings
parsed elements

See Also: parse_list

autoc_parse_list(msg, prefix, separator=' ')

 

Extract elements of the list embedded in auto comments.

Like manc_parse_list but works on auto comments.

Parameters:
  • msg (Message) - message to parse
  • prefix (string) - list identifier substring
  • separator (string) - sequence separating list elements
Returns: list of strings
parsed elements

manc_parse_flag_list(msg, prefix)

 

Extract custom flags embedded in manual comments.

An embedded list of flags is of the form:

   # <prefix>, flag1, flag2, ...

Custom flags are extracted by calling parse_list() with <prefix>, as prefix and , as element separator.

Some types of custom flags used elsewhere in Pology, by prefixes:

  • pipe flags, with pipe character (|) as prefix, used to influence behavior of sieves
Parameters:
  • msg (Message) - message to parse
  • prefix (string) - flag list identifier
Returns: list of strings
parsed flags

See Also: parse_list

autoc_parse_flag_list(msg, prefix)

 

Extract custom flags embedded in auto comments.

Like manc_parse_flag_list but works on auto comments.

Parameters:
  • msg (Message) - message to parse
  • prefix (string) - flag list identifier
Returns: list of strings
parsed flags

parse_field_values(comments, field)

 

Extract values of a field embedded in comments.

And embedded field is of the form:

   <field>: <value> ### sub-comment

There may be several fields of the same name, thus the values are returned in a list (empty if there were no appearances of the field). Values are stripped of leading and trailing whitespace.

Parameters:
  • comments (sequence of strings) - comments to parse
  • field (string) - field name
Returns: list of strings
parsed values

manc_parse_field_values(msg, field)

 

Extract values of a field embedded in manual comments.

Applies parse_field_values to manual comments of the message.

Parameters:
  • msg (Message) - message to parse
  • field (string) - field name
Returns: list of strings
parsed values

autoc_parse_field_values(msg, field)

 

Extract values of a field embedded in auto comments.

Like manc_parse_field_values but works on auto comments.

Parameters:
  • msg (Message) - message to parse
  • field (string) - field name
Returns: list of strings
parsed values

parse_summit_branches(msg)

 

Summit: Extract branch IDs from comments.

Branch IDs are embedded as an auto comment of this form:

   #. +> branch_id_1 branch_id_2 ...

Branch IDs should be unique.

Parameters:
  • msg (Message) - message to parse
Returns: set of strings
parsed branched IDs