[pygccxml-commit] SF.net SVN: pygccxml: [295] pygccxml_dev/pygccxml/utils
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-07-11 09:06:13
|
Revision: 295 Author: roman_yakovenko Date: 2006-07-11 02:05:55 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=295&view=rev Log Message: ----------- improving py++ messages usability Modified Paths: -------------- pygccxml_dev/pygccxml/utils/__init__.py pyplusplus_dev/pyplusplus/_logging_/__init__.py pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py pyplusplus_dev/pyplusplus/module_builder/__init__.py pyplusplus_dev/pyplusplus/module_creator/types_database.py Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2006-07-11 08:45:33 UTC (rev 294) +++ pygccxml_dev/pygccxml/utils/__init__.py 2006-07-11 09:05:55 UTC (rev 295) @@ -11,7 +11,7 @@ def _create_logger_( name ): logger = logging.getLogger(name) __handler = logging.StreamHandler(sys.stdout) - __handler.setFormatter( logging.Formatter( '%(levelname)s %(message)s' ) ) + __handler.setFormatter( logging.Formatter( os.linesep + '%(levelname)s %(message)s' ) ) logger.addHandler(__handler) logger.setLevel(logging.INFO) return logger Modified: pyplusplus_dev/pyplusplus/_logging_/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/_logging_/__init__.py 2006-07-11 08:45:33 UTC (rev 294) +++ pyplusplus_dev/pyplusplus/_logging_/__init__.py 2006-07-11 09:05:55 UTC (rev 295) @@ -8,14 +8,15 @@ This package contains logging configuration for pyplusplus. Default log level is DEBUG. Default log messages destination is sys.stdout. """ - + +import os import sys import logging def _create_logger_( name ): logger = logging.getLogger(name) __handler = logging.StreamHandler(sys.stdout) - __handler.setFormatter( logging.Formatter( '%(levelname)s %(message)s' ) ) + __handler.setFormatter( logging.Formatter( os.linesep + '%(levelname)s %(message)s' ) ) logger.addHandler(__handler) logger.setLevel(logging.INFO) return logger Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-07-11 08:45:33 UTC (rev 294) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-07-11 09:05:55 UTC (rev 295) @@ -197,8 +197,9 @@ if isinstance( oper, declarations.member_operator_t ) and oper.symbol in ( '()', '[]' ): return '' if not operators_helper.is_supported( oper ): - #see http://www.boost.org/libs/python/doc/v2/operators.html#introduction - return 'operator %s is not supported. Please take a look on http://www.boost.org/libs/python/doc/v2/operators.html#introduction.' + msg = [ '"operator%s" is not supported. ' % oper.symbol ] + msg.append( 'See Boost.Python documentation: http://www.boost.org/libs/python/doc/v2/operators.html#introduction.' ) + return os.linesep.join( msg ) return '' exportable = staticmethod( exportable ) Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-07-11 08:45:33 UTC (rev 294) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-07-11 09:05:55 UTC (rev 295) @@ -2,7 +2,8 @@ # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) - + +import os import sys import algorithm from pyplusplus import _logging_ @@ -10,13 +11,6 @@ -__REPOTED_REPLACES = [] -def report_msg_once( msg ): - global __REPOTED_REPLACES - if msg not in __REPOTED_REPLACES: - print 'pyplusplus: ', msg - __REPOTED_REPLACES.append( msg ) - class ERROR_BEHAVIOR: PRINT = 'print' RAISE = 'raise' @@ -29,7 +23,11 @@ information about how the binding is to be created. Instances of this class are never created by the user, instead they are returned by the API. - """ + """ + + DO_NOT_REPORT_MSGS = [ "pyplusplus does not exports compiler generated constructors" ] + ALREADY_REPORTED_MSGS = set() + def __init__(self): object.__init__(self) self._alias = None @@ -67,8 +65,21 @@ def rename( self, new_name ): self.alias = new_name + + def __report_warning( self, reason ): + if reason in decl_wrapper_t.DO_NOT_REPORT_MSGS: + return + if reason in decl_wrapper_t.ALREADY_REPORTED_MSGS: + return + decl_wrapper_t.ALREADY_REPORTED_MSGS.add( reason ) + msg = [ 'Declaration "%s" could not be exported.' % declarations.full_name( self ) ] + reason = reason.replace( os.linesep, os.linesep + '\t' ) + msg.append( '\tReason: %s' % reason ) + self.logger.warn( os.linesep.join( msg ) ) - def _get_ignore( self ): + def _get_ignore( self ): + if False == self._ignore and not self.exportable: + self.__report_warning( self.why_not_exportable() ) return self._ignore or not self.exportable def _set_ignore( self, value ): Modified: pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2006-07-11 08:45:33 UTC (rev 294) +++ pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2006-07-11 09:05:55 UTC (rev 295) @@ -48,9 +48,9 @@ type_ = declarations.remove_const( type_ ) if declarations.is_pointer( type_ ): if self.type_qualifiers.has_static: - return "pyplusplus, right now, can not expose static pointer member variables. This could be changed in future." + return "pyplusplus can not expose static pointer member variables. This could be changed in future." if declarations.is_fundamental( type_.base ): - return "pyplusplus, right now, can not expose pointer to fundamental member variables. This could be changed in future." + return "pyplusplus can not expose pointer to fundamental member variables. This could be changed in future." units = declarations.decompose_type( type_ ) ptr2functions = filter( lambda unit: isinstance( unit, declarations.calldef_type_t ) @@ -62,6 +62,6 @@ if declarations.class_traits.is_my_case( type_ ): cls = declarations.class_traits.get_declaration( type_ ) if not cls.name: - return "pyplusplus, right now, can not expose variables of with unnamed type." + return "pyplusplus can not expose variables of with unnamed type." return '' \ No newline at end of file Modified: pyplusplus_dev/pyplusplus/module_builder/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/module_builder/__init__.py 2006-07-11 08:45:33 UTC (rev 294) +++ pyplusplus_dev/pyplusplus/module_builder/__init__.py 2006-07-11 09:05:55 UTC (rev 295) @@ -52,5 +52,6 @@ def set_logger_level( level ): for l in __pygccxml_utils.loggers.all: - l.setLevel( level ) - __pyplusplus_logging.logger.setLevel( level ) \ No newline at end of file + l.setLevel( level ) + for l in __pyplusplus_logging.loggers.all: + l.setLevel( level ) Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-07-11 08:45:33 UTC (rev 294) +++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-07-11 09:05:55 UTC (rev 295) @@ -73,7 +73,7 @@ try: check_extraction = container_cls.indexing_suite.element_type except RuntimeError, error: - msg = 'WARNING: pyplusplus found "%s" instantiation declaration, ' % container_cls.name + msg = 'pyplusplus found "%s" instantiation declaration, ' % container_cls.name msg = msg + 'but can not find out value type!' msg = msg + os.linesep + 'This class will not be exported!' _logging_.loggers.declarations.warn( msg ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |