Package pyplusplus :: Package messages

# Source Code for Package pyplusplus.messages

     1  # Copyright 2004-2008 Roman Yakovenko.
     2  # Distributed under the Boost Software License, Version 1.0. (See
     3  # accompanying file LICENSE_1_0.txt or copy at
     4  # http://www.boost.org/LICENSE_1_0.txt)
     5
     6  """This package defines all user messages( warnings + errors ), which will be
     7  reported to user.
     8  """
     9  from warnings_ import *
    10
    11  #implementation using regular expression is deprecated, I will leave it here for
    12  #some time to be sure that the new one does not cause any problems.
    13  #import re
    14  #__RE_GET_WARNING_ID = re.compile( r'warning\s(?P<id>W(\d){4})' )
    15  #match_obj = __RE_GET_WARNING_ID.search(msg)
    16  # if not match_obj:
    17  #     return None
    18  # else:
    19  #     return match_obj.group( 'id' )
    20
    21 -def find_out_message_id( msg ):
    22      return msg.identifier
    23
    24  DISABLE_MESSAGES = [
    25      W1000, W1001, W1002, W1011, W1012, W1013, W1015, W1019, W1030, W1034, W1039
    26  ]
    27  #Messages kept by DISABLE_MESSAGES list will not be reported
    28
    29 -def disable( *args ):
    30      DISABLE_MESSAGES.extend( args )
    31
    32 -def filter_disabled_msgs( msgs, disable_messages=None ):
    33      report = []
    34
    35      skip_them = DISABLE_MESSAGES[:]
    36      if disable_messages:
    37          skip_them.extend( disable_messages )
    38
    39      skip_them = filter( None, map( find_out_message_id, skip_them ) )
    40
    41      for msg in msgs:
    42          msg_id = find_out_message_id( msg )
    43          if msg_id and msg_id not in skip_them:
    44              report.append( msg )
    45
    46      return report
    47