diff options
author | Reinier Heeres <reinier@heeres.eu> | 2007-11-13 10:13:57 (GMT) |
---|---|---|
committer | Reinier Heeres <reinier@heeres.eu> | 2007-11-13 10:13:57 (GMT) |
commit | 3b0b9526b75d167981e4c2aeaa8b298de18c9583 (patch) | |
tree | 7fe78eaba745b0c6eb368b688c6d994fdcd1b656 /eqnparserhelp.py | |
parent | 297422fff90867e20be3cc7d1165c3e4e77ff584 (diff) |
Unicode parsing + bugfixes
Diffstat (limited to 'eqnparserhelp.py')
-rw-r--r-- | eqnparserhelp.py | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/eqnparserhelp.py b/eqnparserhelp.py index 34da3ae..2eb8d7c 100644 --- a/eqnparserhelp.py +++ b/eqnparserhelp.py @@ -19,33 +19,42 @@ # 2007-09-16: rwh, first version import types - from gettext import gettext as _ +import logging +_logger = logging.getLogger('EqnParser') + class Callable: def __init__(self, f): self.__call__ = f -# Just an example implementation; should be fixed for internationalization class EqnParserHelp(): + # Unfortunately gettext is not yet initialized at the time _() is called here. + # Still do it like this to make sure these strings show up in the POT-file DICT = { - "acos": "help_acos", - "asin": "help_asin", - "exp": "help_exp", - "functions": "help_functions", - "operators": "help_operators", - "plot": "help_plot", - "sqrt": "help_sqrt", - "test": "help_test", - "variables": "help_variables", + # These are the help topics and should explain how things work + "acos": _("help_acos"), + "asin": _("help_asin"), + "cos": _("help_cos"), + "exp": _("help_exp"), + "functions": _("help_functions"), + "operators": _("help_operators"), + "plot": _("help_plot"), + "sin": _("help_sin"), + "sqrt": _("help_sqrt"), + "test": _("help_test"), + "variables": _("help_variables"), } def __init__(self): - return + pass def help(about): - if type(about) != types.StringType or len(about) == 0: + _logger.debug('help about %r', about) + + t = type(about) + if (t != types.StringType and t != types.UnicodeType) or len(about) == 0: return _("help_usage") if about == "index": @@ -56,8 +65,8 @@ class EqnParserHelp(): ret = "" for (key, val) in EqnParserHelp.DICT.iteritems(): - if about.find(key) != -1: - ret += _(val) + if about == key: + ret += val if ret == "": ret += _("No help about '%s' available, use help(index) for the index") % (about) |