mathmaker  0.6(alpha)
mamk_misc/doc/mathmaker4doxygen/maintenance/debug.py
00001 # -*- coding: utf-8 -*-
00002 
00003 # Mathmaker creates automatically maths exercises sheets
00004 # with their answers
00005 # Copyright 2006-2014 Nicolas Hainaux <nico_h@users.sourceforge.net>
00006 
00007 # This file is part of Mathmaker.
00008 
00009 # Mathmaker is free software; you can redistribute it and/or modify
00010 # it under the terms of the GNU General Public License as published by
00011 # the Free Software Foundation; either version 3 of the License, or
00012 # any later version.
00013 
00014 # Mathmaker is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 
00019 # You should have received a copy of the GNU General Public License
00020 # along with Mathmaker; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 import os
00024 import sys
00025 from lib.common import cfg
00026 
00027 sdt_err_output = sys.stderr.fileno()
00028 
00029 ENABLED_STRING = cfg.get_value_from_file("DEBUGGING MODE", "ENABLED")
00030 
00031 ENABLED = False
00032 
00033 if ENABLED_STRING == "True" or ENABLED_STRING == "true":
00034     ENABLED = True
00035 
00036 into_str_in_item = False
00037 into_str_in_product = True
00038 into_str_in_sum = False
00039 into_str_in_quotient = False
00040 requires_brackets_in_sum = False
00041 requires_inner_brackets_in_product = True
00042 expand_and_reduce_next_step_sum = False
00043 expand_and_reduce_next_step_product = False
00044 expand_in_special_identity = False
00045 reduce_in_sum = False
00046 init_in_exercise_expression_expansion = False
00047 init_in_question_expression_expansion = False
00048 init_in_polynomial = False
00049 solve_next_step = False
00050 calculate_next_step_fraction = False
00051 calculate_next_step_sum = False
00052 calculate_next_step_item = False
00053 replace_striked_out = False
00054 striking_out_in_simplification_line = False
00055 simplification_line_minus_signs = False
00056 simplified = False
00057 monomial_plus = False
00058 throw_away_the_neutrals = False
00059 product_is_reducible = True
00060 get_factors_list_product = True
00061 reduce__product = False
00062 evaluate_in_operation = False
00063 eq_in_item = True
00064 
00065 
00066 
00067 
00068 # --------------------------------------------------------------------------
00069 ##
00070 #   @brief Writes the given String on the std err if debug mode is activated
00071 #   Activating & de-activating the DEBUG mode is made setting the
00072 #   ENABLED value at the beginning of this file.
00073 #   @param provided_string The string to write on std err
00074 def write(provided_string, **options):
00075     if ENABLED:
00076         if len(options) == 0:
00077             os.write(sdt_err_output, bytes(provided_string, 'utf-8'))
00078 
00079         elif 'case' in options and options['case'] == True:
00080             os.write(sdt_err_output, bytes(provided_string, 'utf-8'))