Commits

Ronny Pfannschmidt committed 07c3cca

rework most of the enum paches - new symbol type

Comments (0)

Files changed (9)

cleanup-validator-markup

+# HG changeset patch
+# Parent 24ccd4947bee2bb0bf9cbf74b2460b55a9bf6b1d
+diff --git a/pida-plugins/python_lint/python_lint.py b/pida-plugins/python_lint/python_lint.py
+--- a/pida-plugins/python_lint/python_lint.py
++++ b/pida-plugins/python_lint/python_lint.py
+@@ -63,7 +63,7 @@ class PythonError(ValidationError, Log):
+     """
+     Validator class for PyLint errrors
+     """
+-    def get_markup(self):
++    def markup_args(self):
+         if self.message_args:
+             try:
+                 if isinstance(self.message_args, (list, tuple)):
+@@ -78,38 +78,9 @@ class PythonError(ValidationError, Log):
+                 message_string = self.message
+         else:
+             message_string = self.message
+-        if self.type_ == 'error':
+-            typec = self.lookup_color('pida-val-error')
+-        elif self.type_ == 'error':
+-            typec = self.lookup_color('pida-val-info')
+-        elif self.type_ == 'warning':
+-            typec = self.lookup_color('pida-val-warning')
+-        else:
+-            typec = self.lookup_color('pida-val-def')
+-        if typec:
+-            typec = typec.to_string()
+-        else:
+-            linecolor = "black"
+-        linecolor = self.lookup_color('pida-lineno')
+-        if linecolor:
+-            linecolor = linecolor.to_string()
+-        else:
+-            linecolor = "black"
+-        markup = ("""<tt><span color="%(linecolor)s">%(lineno)s</span> </tt>"""
+-    """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
+-    """>:<span style="italic">%(subtype)s</span>  -  """
+-    """<span size="small" style="italic">%(msg_id)s</span>\n%(message)s""" % 
+-                      {'lineno':self.lineno,
+-                      'type': self.level.capitalize(),
+-                      'subtype': self.kind.capitalize(),
+-                      'message': message_string,
+-                      'linecolor': linecolor,
+-                      'typec': typec,
+-                      'msg_id': self.msg_id
+-                      })
+-        return markup
+-    markup = property(get_markup)
+-
++        mapping = ValidationError.markup_args(self)
++        mapping['message'] = message_string
++        return mapping
+ 
+ from logilab.common.ureports import TextWriter
+ from logilab.common.textutils import get_csv
+diff --git a/pida/utils/languages.py b/pida/utils/languages.py
+--- a/pida/utils/languages.py
++++ b/pida/utils/languages.py
+@@ -120,6 +120,15 @@ class ValidationError(InitObject):
+     filename = None
+     lineno = None
+ 
++    markup_string = (
++        '<tt><span color="{linecolor}">{lineno}</span> </tt>'
++        '<span foreground="{level_color}" style="italic" weight="bold">'
++        '{level}</span>:'
++        '<span style="italic">{kind}</span>\n'
++        '{message}'
++    )
++
++
+     def __str__(self):
+         return '%s:%s: %s' % (self.filename, self.lineno, self.message)
+ 
+@@ -132,7 +141,12 @@ class ValidationError(InitObject):
+         # FIXME
+         pass
+ 
+-    def get_markup(self):
++
++    @property
++    def markup(self):
++        return self.markup_string.format(**self.markup_args())
++
++    def markup_args(self):
+         mapping = {
+             'error': 'pida-val-error',
+             'info': 'pida-val-info',
+@@ -140,18 +154,14 @@ class ValidationError(InitObject):
+         }
+         typec = mapping.get(self.kind, 'pida-val-def')
+ 
+-        markup = ("""<tt><span color="%(linecolor)s">%(lineno)s</span> </tt>"""
+-    """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
+-    """>:<span style="italic">%(subtype)s</span>\n%(message)s""" % 
+-                      {'lineno':self.lineno, 
+-                      'type': self.level.capitalize(),
+-                      'subtype': self.kind.capitalize(),
+-                      'message':self.message,
++        return self.markup_string.format(**{
++                      'lineno': self.lineno,
++                      'level': self.level.capitalize(),
++                      'level_color': color_to_string(typec),
++                      'kind': self.kind.capitalize(),
++                      'message': self.message,
+                       'linecolor': color_to_string(self.lookup_color('pida-lineno')),
+-                      'typec': color_to_string(typec),
+                       })
+-        return markup
+-    markup = property(get_markup)
+ 
+ 
+ 

kill-completer-types-enum

 # User Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
 # Date 1280876358 -7200
 # Node ID dc2797856c153b649049583ebef79122fcfe43fd
-# Parent b51f85401eb94624b0ae37ec36c28097fdcbceb5
+# Parent aabde088e793c433aefdcd3576681d60c79b63cf
 imported patch kill-completer-types-enum
 
 diff --git a/pida-plugins/python/python.py b/pida-plugins/python/python.py
 --- a/pida-plugins/python/python.py
 +++ b/pida-plugins/python/python.py
-@@ -37,7 +37,7 @@ from pida.core.languages import (Languag
+@@ -37,7 +37,8 @@ from pida.core.languages import (Languag
      Completer, LanguageServiceFeaturesConfig, LanguageInfo, Definer, 
      Documentator, External)
  
 -from pida.utils.languages import (LANG_COMPLETER_TYPES,
 +from pida.utils.languages import (
++    COMPLETER,
      LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, LANG_OUTLINER_TYPES, 
      LANG_PRIO, Definition, Suggestion, Documentation, ValidationError)
  
-@@ -342,22 +342,15 @@ class PythonCompleter(Completer):
+@@ -342,22 +343,15 @@ class PythonCompleter(Completer):
                  r = Suggestion(c.name)
                  #'variable', 'class', 'function', 'imported' , 'paramter'
                  if keyword.iskeyword(c.name):
 -                    r.type_ = LANG_COMPLETER_TYPES.FUNCTION
 -                elif c.type == 'parameter':
 -                    r.type_ = LANG_COMPLETER_TYPES.PARAMETER
-+                    r.type_ = 'keyword'
++                    r.type_ = COMPLETER.KEYWORD
 +                elif c.type in ('variable','class', 'builtin',
 +                                'function', 'parameter',):
-+                    r.type_ = c.type_
++                    r.type_ = getattr(COMPLETER, c.type.upper())
                  elif c.type == None:
                      if c.kind == "parameter_keyword":
 -                        r.type_ = LANG_COMPLETER_TYPES.PARAMETER
-+                        r.type_ = 'parameter'
++                        r.type_ = COMPLETER.PARAMETER
                  else:
 -                    r.type_ = LANG_COMPLETER_TYPES.UNKNOWN
-+                    r.type_ = 'unknown'
++                    r.type_ = COMPLETER.UNKNOWN
                  yield r
  
  class PythonDefiner(Definer):
+diff --git a/pida-plugins/python_lint/python_lint.py b/pida-plugins/python_lint/python_lint.py
+--- a/pida-plugins/python_lint/python_lint.py
++++ b/pida-plugins/python_lint/python_lint.py
+@@ -21,7 +21,7 @@ from pida.core.options import OptionsCon
+ from pida.core.log import Log
+ 
+ from pida.core.languages import (LanguageService, Validator, External)
+-from pida.utils.languages import (LANG_COMPLETER_TYPES,
++from pida.utils.languages import (
+     LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, LANG_PRIO,
+    Definition, Suggestion, Documentation, ValidationError)
+ 
+diff --git a/pida/core/languages.py b/pida/core/languages.py
+--- a/pida/core/languages.py
++++ b/pida/core/languages.py
+@@ -15,7 +15,7 @@ from pida.core.document import Document
+ from pida.core.projects import Project
+ from pida.core.service import Service
+ from pida.core.features import FeaturesConfig
+-from pida.utils.languages import (LANG_COMPLETER_TYPES,
++from pida.utils.languages import (
+     LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, LANG_PRIO,
+     Suggestion, Definition, ValidationError, Documentation)
+ from pida.utils.path import get_relative_path
 diff --git a/pida/ui/completer.py b/pida/ui/completer.py
 --- a/pida/ui/completer.py
 +++ b/pida/ui/completer.py
  import gobject
  import os
 -from pida.utils.languages import LANG_COMPLETER_TYPES
-+from pida.utils.languages import completer_types
++from pida.utils.languages import COMPLETER
  
 +
 +#XXX: register as stock icons
                'taT', 'tUt', 'df', 'asdf', 'asdfa', 'sd', 'sdfsf', 'ssdfsdf', 'sd']:
 -        l.append(SuggestionsList.from_dbus((i, x)))
 -        i = i + 1%7
-+        l.append(SuggestionsList.from_dbus((completer_types[i], x)))
++        l.append(SuggestionsList.from_dbus((COMPLETER[i], x)))
 +        i = (i + 1)%7
  
      p.set_model(l)
 diff --git a/pida/utils/languages.py b/pida/utils/languages.py
 --- a/pida/utils/languages.py
 +++ b/pida/utils/languages.py
-@@ -11,6 +11,7 @@ from .addtypes import Enumeration
+@@ -8,9 +8,11 @@ List of general Language classes.
+ 
+ """
+ from .addtypes import Enumeration
++from .symbols import Symbols
  from .path import get_line_from_file
  from .descriptors import cached_property
  
  
  
  #!!!!!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-@@ -20,12 +21,26 @@ from .descriptors import cached_property
+@@ -20,12 +22,23 @@ from .descriptors import cached_property
  #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  
  
-+completer_types = [
++COMPLETER = Symbols('completer', [
 +    'unknown',
 +    'attribute',
 +    'class',
 +    'builtin',
 +    'keyword',
 +    'snippet',
-+]
-+completer_type_order = dict(zip(completer_types, range(len(completer_types))))
++])
  
 -# completer types
 -LANG_COMPLETER_TYPES = Enumeration('LANG_COMPLETER_TYPES',
 -    ('UNKNOWN', 'ATTRIBUTE', 'CLASS', 'METHOD', 'FUNCTION', 'MODULE', 
 -    'PROPERTY', 'EXTRAMETHOD', 'VARIABLE', 'IMPORT', 'PARAMETER', 'BUILTIN', 
 -    'KEYWORD', 'SNIPPET'))
-+LANG_COMPLETER_TYPES = Enumeration('LANG_COMPLETER_TYPES', map(str.upper, completer_types))
-+
  
  
  # main types
-@@ -237,7 +252,7 @@ class Suggestion(unicode):
+@@ -237,7 +250,7 @@ class Suggestion(unicode):
      """
      Suggestions are returned by an Completer class
      """
 -    type_ = LANG_TYPES.UNKNOWN
-+    type_ = 'unknown'
++    type_ = COMPLETER.UNKNOWN
      doc = None
      docpath = None
      signature = None

kill-most-language-enum-definitions

-# HG changeset patch
-# User Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
-# Date 1280876358 -7200
-# Node ID f9d89ccc19e59f68bf1962d9bc6a566eb4597e5a
-# Parent d2deb6f3af308ed68f2952d00e9a6c533cf5c978
-imported patch kill-most-language-enum-definitions
-
-diff --git a/pida/core/languages.py b/pida/core/languages.py
---- a/pida/core/languages.py
-+++ b/pida/core/languages.py
-@@ -16,7 +16,7 @@ from pida.core.projects import Project
- from pida.core.service import Service
- from pida.core.features import FeaturesConfig
- from pida.utils.languages import (
--    LANG_COMPLETER_TYPES, LANG_PRIO,
-+    LANG_PRIO,
-     Suggestion, Definition, ValidationError, Documentation)
- from pida.utils.path import get_relative_path
- # locale
-diff --git a/pida/utils/languages.py b/pida/utils/languages.py
---- a/pida/utils/languages.py
-+++ b/pida/utils/languages.py
-@@ -36,31 +36,30 @@ completer_types = [
-     'keyword',
-     'snippet',
- ]
--completer_type_order = dict(zip(completer_types, range(len(completer_types))))
--
--LANG_COMPLETER_TYPES = Enumeration('LANG_COMPLETER_TYPES', map(str.upper, completer_types))
- 
- 
- 
- # main types
--LANG_VALIDATOR_TYPES = Enumeration('LANG_TYPES',
--    ('UNKNOWN', 'INFO', 'WARNING', 'ERROR', 'FATAL'))
-+validator_types = ('unknown', 'info', 'warning', 'error', 'fatal')
- 
- # validation sub types
--LANG_VALIDATOR_SUBTYPES = Enumeration('LANG_VALIDATION_ERRORS',
--    ('UNKNOWN', 'SYNTAX', 'INDENTATION', 'UNDEFINED', 'REDEFINED', 'BADSTYLE',
--     'DUPLICATE', 'UNUSED', 'FIXME', 'PROTECTION', 'DANGEROUS'))
-+validator_subtypes = (
-+    'unknown', 'syntax', 'indentation', 'undefined', 'redefined', 'badstyle',
-+    'duplicate', 'unused', 'fixme', 'protection', 'dangerous',
-+)
- 
- # validation sub types
- 
--LANG_TYPES = Enumeration('LANG_TYPES',
-- ('', 'UNKNOWN', 
-- 'ATTRIBUTE', 'BUILTIN', 'CLASS', 'DEFINE', 'ENUMERATION',
-- 'ENUMERATION_NAME', 'FUNCTION', 'IMPORT', 'MEMBER', 'METHOD', 'PROPERTY',
-- 'PROTOTYPE', 'STRUCTURE', 'SUPERMETHOD', 'SUPERPROPERTY', 'TYPEDEF', 'UNION',
-- 'VARIABLE', 'NAMESPACE', 'ELEMENT', 'SECTION', 'CHAPTER', 'PARAGRAPH'))
-+types = (
-+    'unknown', 'attribute', 'builtin', 'class', 'define', 'enumeration',
-+    'enumeration_name', 'function', 'import', 'member', 'method', 'property',
-+    'prototype', 'structure', 'supermethod', 'superproperty', 'typedef',
-+    'union', 'variable',
-+    'namespace', 'element',
-+    'section', 'chapter', 'paragraph',
-+)
- 
--LANG_OUTLINER_TYPES = LANG_TYPES
-+outliner_types = types
- 
- LANG_PRIO = Enumeration('LANG_PRIORITIES',
- (
-@@ -74,29 +73,29 @@ LANG_PRIO = Enumeration('LANG_PRIORITIES
- 
- 
- LANG_IMAGE_MAP = {
--    LANG_TYPES.ATTRIBUTE: 'source-attribute',
--    LANG_TYPES.BUILTIN: 'source-attribute',
--    LANG_TYPES.CLASS: 'source-class',
--    LANG_TYPES.DEFINE: 'source-define',
--    LANG_TYPES.ENUMERATION: 'source-enum',
--    LANG_TYPES.ENUMERATION_NAME: 'source-enumarator',
--    LANG_TYPES.FUNCTION: 'source-function',
--    LANG_TYPES.IMPORT: 'source-import',
--    LANG_TYPES.MEMBER: 'source-member',
--    LANG_TYPES.METHOD: 'source-method',
--    LANG_TYPES.PROTOTYPE: 'source-interface',
--    LANG_TYPES.PROPERTY: 'source-property',
--    LANG_TYPES.METHOD: 'source-method',
--    LANG_TYPES.SUPERMETHOD: 'source-extramethod',
--    #FIXME: superproperty icon
--    LANG_TYPES.SUPERPROPERTY: 'source-property',
--    LANG_TYPES.TYPEDEF: 'source-typedef',
--    LANG_TYPES.UNION: 'source-union',
--    LANG_TYPES.VARIABLE: 'source-variable',
--    LANG_TYPES.SECTION: 'source-section',
--    LANG_TYPES.PARAGRAPH: 'source-paragraph',
--    LANG_TYPES.NAMESPACE: 'source-namespace',
--    LANG_TYPES.ELEMENT: 'source-element',
-+    'attribute': 'Source-attribute',
-+    'builtin': 'source-attribute',
-+    'class': 'source-class',
-+    'define': 'source-define',
-+    'enumeration': 'source-enum',
-+    'enumeration_name': 'source-enumarator',
-+    'function': 'source-function',
-+    'import': 'source-import',
-+    'member': 'source-member',
-+    'method': 'source-method',
-+    'prototype': 'source-interface',
-+    'property': 'source-property',
-+    'method': 'source-method',
-+    'supermethod': 'source-extramethod',
-+    #fixme: SUPERPROPERTY ICON
-+    'superproperty': 'source-property',
-+    'typedef': 'source-typedef',
-+    'union': 'source-union',
-+    'variable': 'source-variable',
-+    'section': 'source-section',
-+    'paragraph': 'source-paragraph',
-+    'namespace': 'source-namespace',
-+    'element': 'source-element',
- }
- 
- 
-@@ -148,10 +147,9 @@ class ValidationError(InitObject):
-     """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
-     """>:<span style="italic">%(subtype)s</span>\n%(message)s""" % 
-                       {'lineno':self.lineno, 
--                      'type':_(self.type_.capitalize()),
--                      'subtype':_(LANG_VALIDATOR_SUBTYPES.whatis(
--                                    self.subtype).capitalize()),
--                      'message':self.message,
-+                      'type': self.type_.capitalize(),
-+                      'subtype': self.subtype.capitalize(),
-+                      'message': self.message,
-                       'linecolor': color_to_string(self.lookup_color('pida-lineno')),
-                       'typec': color_to_string(typec),
-                       })
-@@ -177,7 +175,7 @@ class OutlineItem(InitObject):
-     """
-     Outlines are returned by an Outliner class
-     """
--    type = LANG_TYPES.UNKNOWN
-+    type = 'unknown'
-     name = ''
-     parent = None
-     id = None
-@@ -217,7 +215,7 @@ class OutlineItem(InitObject):
- 
- class Definition(InitObject):
-     """Returned by a Definer instance"""
--    type = LANG_TYPES.UNKNOWN
-+    type = 'unknown'
-     file_name = None
-     offset = None
-     length = None

kill-outliner-types-enum

 # User Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
 # Date 1280876358 -7200
 # Node ID d2deb6f3af308ed68f2952d00e9a6c533cf5c978
-# Parent 15126c8358813d60d0a73d3e5965774bf14a2de0
+# Parent 893c14aa765d20c78af4b2a47aef3bbf992b8f42
 imported patch kill-outliner-types-enum
 
 diff --git a/pida-plugins/ctags/ctags.py b/pida-plugins/ctags/ctags.py
 diff --git a/pida-plugins/python/python.py b/pida-plugins/python/python.py
 --- a/pida-plugins/python/python.py
 +++ b/pida-plugins/python/python.py
-@@ -38,7 +38,6 @@ from pida.core.languages import (Languag
-     Documentator, External)
+@@ -39,7 +39,6 @@ from pida.core.languages import (Languag
  
  from pida.utils.languages import (
+     COMPLETER, VALIDATOR_LEVEL, VALIDATOR_KIND,
 -    LANG_OUTLINER_TYPES, 
      LANG_PRIO, Definition, Suggestion, Documentation, ValidationError)
  
  # services
-@@ -131,14 +130,10 @@ class PythonOutliner(Outliner):
+@@ -132,14 +131,10 @@ class PythonOutliner(Outliner):
      description = _("A very deep and precises, but slow outliner")
  
  
  from pida.utils.languages import (
 -    LANG_PRIO, LANG_OUTLINER_TYPES,
 +    LANG_PRIO,
+     VALIDATOR_LEVEL, VALIDATOR_KIND,
      OutlineItem, ValidationError,
  )
- from pida.services.language import DOCTYPES
-@@ -247,8 +247,7 @@ class RSTOutliner(Outliner):
+@@ -248,8 +248,7 @@ class RSTOutliner(Outliner):
      name = "rst outliner"
      description = _("An outliner for ReStructuredText")
  
  
      def get_outline(self):
          self.doc_items = RSTTokenList()
-@@ -280,7 +279,7 @@ class RSTOutliner(Outliner):
+@@ -281,7 +280,7 @@ class RSTOutliner(Outliner):
                    isinstance(node, nodes.figure)):
                  new_item = True
                  name = node.attributes['uri']

kill-validator-types-subtypes-enums

 # User Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
 # Date 1280876358 -7200
 # Node ID 15126c8358813d60d0a73d3e5965774bf14a2de0
-# Parent dc2797856c153b649049583ebef79122fcfe43fd
+# Parent 203f60a88ffbbe3effabcc0350c40b0d638f97fc
 imported patch kill-validator-types-subtypes-enums
 
 diff --git a/pida-plugins/python/python.py b/pida-plugins/python/python.py
 --- a/pida-plugins/python/python.py
 +++ b/pida-plugins/python/python.py
-@@ -38,7 +38,7 @@ from pida.core.languages import (Languag
+@@ -38,8 +38,8 @@ from pida.core.languages import (Languag
      Documentator, External)
  
  from pida.utils.languages import (
+-    COMPLETER,
 -    LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, LANG_OUTLINER_TYPES, 
++    COMPLETER, VALIDATOR_LEVEL, VALIDATOR_KIND,
 +    LANG_OUTLINER_TYPES, 
      LANG_PRIO, Definition, Suggestion, Documentation, ValidationError)
  
  # services
-@@ -222,22 +222,22 @@ def _create_exception_validation(e):
+@@ -223,51 +223,13 @@ def _create_exception_validation(e):
      msg.lineno = lineno
      msg.message_args = (line,)
      msg.message = '<tt>%%s</tt>\n<tt>%s^</tt>' % (' ' * (offset - 2))
 +    msg.type_ = 'error'
      if isinstance(e, SyntaxError):
 -        msg.subtype = LANG_VALIDATOR_SUBTYPES.SYNTAX
-+        msg.subtype = 'syntax'
++        msg.kind = 'syntax'
      else:
 -        msg.subtype = LANG_VALIDATOR_SUBTYPES.INDENTATION
-+        msg.subtype = 'indentation'
++        msg.kind = 'indentation'
      return [msg]
  
- class PythonError(ValidationError):
-     def get_markup(self):
-         args = [('<b>%s</b>' % arg) for arg in self.message_args]
-         message_string = self.message % tuple(args)
+-class PythonError(ValidationError):
+-    def get_markup(self):
+-        args = [('<b>%s</b>' % arg) for arg in self.message_args]
+-        message_string = self.message % tuple(args)
 -        if self.type_ == LANG_VALIDATOR_TYPES.ERROR:
-+        if self.type_ == 'error':
-             typec = self.lookup_color('pida-val-error')
+-            typec = self.lookup_color('pida-val-error')
 -        elif self.type_ == LANG_VALIDATOR_TYPES.INFO:
-+        elif self.type_ == 'info':
-             typec = self.lookup_color('pida-val-info')
+-            typec = self.lookup_color('pida-val-info')
 -        elif self.type_ == LANG_VALIDATOR_TYPES.WARNING:
-+        elif self.type_ == 'warning':
-             typec = self.lookup_color('pida-val-warning')
-         else:
-             typec = self.lookup_color('pida-val-def')
-@@ -257,10 +257,9 @@ class PythonError(ValidationError):
-     """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
-     """>:<span style="italic">%(subtype)s</span>\n%(message)s""" % 
-                       {'lineno':self.lineno, 
+-            typec = self.lookup_color('pida-val-warning')
+-        else:
+-            typec = self.lookup_color('pida-val-def')
+-        
+-        if typec:
+-            typec = typec.to_string()
+-        else:
+-            typec = "black"
+-        
+-        linecolor = self.lookup_color('pida-lineno')
+-        if linecolor:
+-            linecolor = linecolor.to_string()
+-        else:
+-            linecolor = "black"
+-        
+-        markup = ("""<tt><span color="%(linecolor)s">%(lineno)s</span> </tt>"""
+-    """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
+-    """>:<span style="italic">%(subtype)s</span>\n%(message)s""" % 
+-                      {'lineno':self.lineno, 
 -                      'type':_(LANG_VALIDATOR_TYPES.whatis(self.type_).capitalize()),
 -                      'subtype':_(LANG_VALIDATOR_SUBTYPES.whatis(
 -                                    self.subtype).capitalize()),
 -                      'message':message_string,
-+                      'type': self.type_.capitalize(),
-+                      'subtype': self.subtype.capitalize(),
-+                      'message': message_string,
-                       'linecolor': linecolor,
-                       'typec': typec,
-                       })
-@@ -285,26 +284,27 @@ class PythonValidator(Validator):
+-                      'linecolor': linecolor,
+-                      'typec': typec,
+-                      })
+-        return markup
+-    markup = property(get_markup)
+-
+ class PythonValidator(Validator):
+ 
+     priority = LANG_PRIO.GOOD
+@@ -286,33 +248,34 @@ class PythonValidator(Validator):
              w = Checker(tree, filename)
              messages = w.messages
          for m in messages:
              if isinstance(m, pyflakes.messages.UnusedImport):
 -                type_ = LANG_VALIDATOR_TYPES.INFO
 -                subtype = LANG_VALIDATOR_SUBTYPES.UNUSED
-+                type_ = 'info'
-+                subtype = 'unused'
++                level = VALIDATOR_LEVEL.INFO
++                kind = VALIDATOR_KIND.UNUSED
              elif isinstance(m, pyflakes.messages.RedefinedWhileUnused):
 -                type_ = LANG_VALIDATOR_TYPES.WARNING
 -                subtype = LANG_VALIDATOR_SUBTYPES.REDEFINED
-+                type_ = 'warning'
-+                subtype = 'redefined'
++                level = VALIDATOR_LEVEL.WARNING
++                kind = VALIDATOR_KIND.REDEFINED
              elif isinstance(m, pyflakes.messages.ImportStarUsed):
 -                type_ = LANG_VALIDATOR_TYPES.WARNING
 -                subtype = LANG_VALIDATOR_SUBTYPES.BADSTYLE
-+                type_ = 'warning'
-+                subtype = 'badstyle'
++                level = VALIDATOR_LEVEL.WARNING
++                kind = VALIDATOR_KIND.BADSTYLe
              elif isinstance(m, pyflakes.messages.UndefinedName):
 -                type_ = LANG_VALIDATOR_TYPES.ERROR
 -                subtype = LANG_VALIDATOR_SUBTYPES.UNDEFINED
-+                type_ = 'error'
-+                subtype = 'undefined'
++                level = VALIDATOR_LEVEL.ERROR
++                kind = VALIDATOR_KIND.UNDEFINED
              elif isinstance(m, pyflakes.messages.DuplicateArgument):
 -                type_ = LANG_VALIDATOR_TYPES.ERROR
 -                subtype = LANG_VALIDATOR_SUBTYPES.DUPLICATE
-+                type_ = 'error'
-+                subtype = 'duplicate'
++                type_ = VALIDATOR_LEVEL.ERROR
++                kind = VALIDATOR_KIND.DUPLICATE
 +            else:
-+                type_ = 'unknown'
-+                subtype = 'unknown'
++                level = VALIDATOR_LEVEL.UNKNOWN
++                kind = VALIDATOR_KIND.UNKNOWN
  
-             ve = PythonError(
+-            ve = PythonError(
++            ve = ValidationError(
                  message=m.message,
+                 message_args=m.message_args,
+                 lineno=m.lineno,
+-                type_=type_,
+-                subtype=subtype,
++                level=level,
++                kind=kind,
+                 filename=filename
+                 )
+             yield ve
 diff --git a/pida-plugins/python_lint/python_lint.py b/pida-plugins/python_lint/python_lint.py
 --- a/pida-plugins/python_lint/python_lint.py
 +++ b/pida-plugins/python_lint/python_lint.py
-@@ -21,8 +21,7 @@ from pida.core.options import OptionsCon
- from pida.core.log import Log
+@@ -22,7 +22,6 @@ from pida.core.log import Log
  
  from pida.core.languages import (LanguageService, Validator, External)
--from pida.utils.languages import (LANG_COMPLETER_TYPES,
+ from pida.utils.languages import (
 -    LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, LANG_PRIO,
-+from pida.utils.languages import (LANG_PRIO,
     Definition, Suggestion, Documentation, ValidationError)
  
  # locale
-@@ -90,16 +89,15 @@ except ImportError:
+@@ -33,6 +32,7 @@ _ = locale.gettext
+ # log
+ import logging
+ log = logging.getLogger('python_lint')
++from pida.utils.languages import (LANG_PRIO,
+ 
+ try:
+     #import pylint
+@@ -90,16 +90,15 @@ except ImportError:
  #         pass
  
  SUBTYPE_MAPPING = {
  }
  
  
-@@ -122,11 +120,11 @@ class PythonError(ValidationError, Log):
+@@ -122,11 +121,11 @@ class PythonError(ValidationError, Log):
                  message_string = self.message
          else:
              message_string = self.message
              typec = self.lookup_color('pida-val-warning')
          else:
              typec = self.lookup_color('pida-val-def')
-@@ -144,10 +142,9 @@ class PythonError(ValidationError, Log):
+@@ -144,10 +143,9 @@ class PythonError(ValidationError, Log):
      """>:<span style="italic">%(subtype)s</span>  -  """
      """<span size="small" style="italic">%(msg_id)s</span>\n%(message)s""" % 
                        {'lineno':self.lineno,
 -                      'subtype':_(LANG_VALIDATOR_SUBTYPES.whatis(
 -                                    self.subtype).capitalize()),
 -                      'message':message_string,
-+                      'type': self.type_.capitalize(),
-+                      'subtype': self.subtype.capitalize(),
++                      'type': self.level.capitalize(),
++                      'subtype': self.kind.capitalize(),
 +                      'message': message_string,
                        'linecolor': linecolor,
                        'typec': typec,
                        'msg_id': self.msg_id
-@@ -225,26 +222,26 @@ class PidaLinter(PyLinter, Log):
+@@ -225,26 +223,26 @@ class PidaLinter(PyLinter, Log):
              return        
          # update stats
          if msg_id[0] == 'I':
  
          #msg_cat = MSG_TYPES[msg_id[0]]
          #self.stats[msg_cat] += 1
+@@ -269,8 +267,8 @@ class PidaLinter(PyLinter, Log):
+             path = node.root().file
+         # add the message
+         cmsg = PythonError( message = msg,
+-                            type_ = ty,
+-                            subtype = sty,
++                            level = ty,
++                            kind = sty,
+                             filename = path,
+                             message_args = args or (),
+                             lineno = line or 1,
 diff --git a/pida-plugins/rst/rst.py b/pida-plugins/rst/rst.py
 --- a/pida-plugins/rst/rst.py
 +++ b/pida-plugins/rst/rst.py
-@@ -12,9 +12,10 @@ from collections import defaultdict
+@@ -12,9 +12,11 @@ from collections import defaultdict
  
  # PIDA imports
  from pida.core.languages import LanguageService, Outliner, Validator
 -    LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, ValidationError)
 +from pida.utils.languages import (
 +    LANG_PRIO, LANG_OUTLINER_TYPES,
++    VALIDATOR_LEVEL, VALIDATOR_KIND,
 +    OutlineItem, ValidationError,
 +)
  from pida.services.language import DOCTYPES
  
  # docutils imports
-@@ -312,7 +313,7 @@ class RSTValidator(Validator):
+@@ -312,20 +314,20 @@ class RSTValidator(Validator):
      name = "rst validator"
      description = _("A validator for ReStructuredText")
  
 -    subtype = LANG_VALIDATOR_SUBTYPES.SYNTAX
-+    subtype = 'syntax'
++    kind = VALIDATOR_KIND.SYNTAX
  
      def get_validations(self):
          self.rstplugin = RSTPlugin(self.svc)
-@@ -335,9 +336,7 @@ class RSTValidator(Validator):
+         self.doctree = self.rstplugin.parse_rst(self.document)
+         if self.doctree:
+             for msg in self.doctree.parse_messages :
+-                message, type_, filename, lineno = self._parse_error(msg)
++                message, level, filename, lineno = self._parse_error(msg)
+                 # TODO need to filter out duplicates with no lineno set
+                 # not sure why this happens...
+                 if lineno:
+                     yield ValidationError (message=message,
+-                                           type_=type_,
+-                                           subtype=self.subtype,
++                                           level=level,
++                                           kind=self.kind,
+                                            filename=filename,
+                                            lineno=lineno)
+ 
+@@ -335,9 +337,7 @@ class RSTValidator(Validator):
          message = textwrap.fill(msg.children[0].children[0].data, width)
          # docutils defines the following error levels:
          #     "info/1", '"warning"/"2" (default), "error"/"3", "severe"/"4"
 -        type_ = (LANG_VALIDATOR_TYPES.INFO, LANG_VALIDATOR_TYPES.WARNING,
 -                 LANG_VALIDATOR_TYPES.ERROR, LANG_VALIDATOR_TYPES.FATAL
 -                )[msg['level'] - 1]
-+        type_ = ('info', 'warning', 'error', 'fatal')[msg['level'] - 1]
++        type_ = VALIDATOR_LEVEL[msg['level']]
          filename = msg.source
          lineno = msg.line
          return (message, type_, filename, lineno)
 diff --git a/pida/core/languages.py b/pida/core/languages.py
 --- a/pida/core/languages.py
 +++ b/pida/core/languages.py
-@@ -15,8 +15,8 @@ from pida.core.document import Document
- from pida.core.projects import Project
+@@ -16,7 +16,7 @@ from pida.core.projects import Project
  from pida.core.service import Service
  from pida.core.features import FeaturesConfig
--from pida.utils.languages import (LANG_COMPLETER_TYPES,
+ from pida.utils.languages import (
 -    LANG_VALIDATOR_TYPES, LANG_VALIDATOR_SUBTYPES, LANG_PRIO,
-+from pida.utils.languages import (
-+    LANG_COMPLETER_TYPES, LANG_PRIO,
++    COMPLETER, LANG_PRIO,
      Suggestion, Definition, ValidationError, Documentation)
  from pida.utils.path import get_relative_path
  # locale
 diff --git a/pida/utils/languages.py b/pida/utils/languages.py
 --- a/pida/utils/languages.py
 +++ b/pida/utils/languages.py
-@@ -117,8 +117,8 @@ class ValidationError(InitObject):
+@@ -41,14 +41,13 @@ COMPLETER = Symbols('completer', [
+ 
+ 
+ 
+-# main types
+-LANG_VALIDATOR_TYPES = Enumeration('LANG_TYPES',
+-    ('UNKNOWN', 'INFO', 'WARNING', 'ERROR', 'FATAL'))
++VALIDATOR_KIND = Symbols('validation errors',
++    ('unknown', 'syntax', 'indentation', 'undefined', 'redefined', 'badstyle',
++     'duplicate', 'unused', 'fixme', 'protection', 'dangerous'))
+ 
+-# validation sub types
+-LANG_VALIDATOR_SUBTYPES = Enumeration('LANG_VALIDATION_ERRORS',
+-    ('UNKNOWN', 'SYNTAX', 'INDENTATION', 'UNDEFINED', 'REDEFINED', 'BADSTYLE',
+-     'DUPLICATE', 'UNUSED', 'FIXME', 'PROTECTION', 'DANGEROUS'))
++VALIDATOR_LEVEL = Symbols('validation level',
++    ('unknown', 'info', 'warning', 'error', 'fatal'))
++
+ 
+ # validation sub types
+ 
+@@ -116,8 +115,8 @@ class ValidationError(InitObject):
      """Message a Validator should return"""
      message = ''
      message_args = None
 -    type_ = LANG_VALIDATOR_TYPES.UNKNOWN
 -    subtype = LANG_VALIDATOR_SUBTYPES.UNKNOWN
-+    type_ = 'unknown'
-+    subtype = 'unknown'
++    level = VALIDATOR_LEVEL.UNKNOWN
++    kind = VALIDATOR_KIND.UNKNOWN
      filename = None
      lineno = None
  
-@@ -135,11 +135,11 @@ class ValidationError(InitObject):
+@@ -134,41 +133,25 @@ class ValidationError(InitObject):
          pass
  
      def get_markup(self):
 -        if self.type_ == LANG_VALIDATOR_TYPES.ERROR:
-+        if self.type_ == 'error':
-             typec = self.lookup_color('pida-val-error')
+-            typec = self.lookup_color('pida-val-error')
 -        elif self.type_ == LANG_VALIDATOR_TYPES.INFO:
-+        elif self.type_ == 'info':
-             typec = self.lookup_color('pida-val-info')
+-            typec = self.lookup_color('pida-val-info')
 -        elif self.type_ == LANG_VALIDATOR_TYPES.WARNING:
-+        elif self.type_ == 'warning':
-             typec = self.lookup_color('pida-val-warning')
-         else:
-             typec = self.lookup_color('pida-val-def')
-@@ -148,7 +148,7 @@ class ValidationError(InitObject):
+-            typec = self.lookup_color('pida-val-warning')
+-        else:
+-            typec = self.lookup_color('pida-val-def')
+-        
++        mapping = {
++            'error': 'pida-val-error',
++            'info': 'pida-val-info',
++            'warning': 'pida-val-warning',
++        }
++        typec = mapping.get(self.kind, 'pida-val-def')
++
+         markup = ("""<tt><span color="%(linecolor)s">%(lineno)s</span> </tt>"""
      """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
      """>:<span style="italic">%(subtype)s</span>\n%(message)s""" % 
                        {'lineno':self.lineno, 
 -                      'type':_(LANG_VALIDATOR_TYPES.whatis(self.type_).capitalize()),
-+                      'type':_(self.type_.capitalize()),
-                       'subtype':_(LANG_VALIDATOR_SUBTYPES.whatis(
-                                     self.subtype).capitalize()),
+-                      'subtype':_(LANG_VALIDATOR_SUBTYPES.whatis(
+-                                    self.subtype).capitalize()),
++                      'type': self.level.capitalize(),
++                      'subtype': self.kind.capitalize(),
                        'message':self.message,
+                       'linecolor': color_to_string(self.lookup_color('pida-lineno')),
+                       'typec': color_to_string(typec),
+                       })
+         return markup
+     markup = property(get_markup)
+-#     def get_markup(self):
+-#         #args = [('<b>%s</b>' % arg) for arg in msg.message_args]
+-#         #message_string = self.message % tuple(args)
+-#         #msg.name = msg.__class__.__name__
+-#         markup = ('<tt>%s </tt><i>%s:%s</i>\n%s' % 
+-#                       (self.lineno, 
+-#                       LANG_VALIDATOR_TYPES.whatis(self.type_).capitalize(),
+-#                       LANG_VALIDATOR_SUBTYPES.whatis(self.subtype).capitalize(),
+-#                       self.message))
+-#         return markup
+-#     
+-#     markup = property(get_markup)
+-
+ 
+ 
+ 

pylint-kill-skeleton

+# HG changeset patch
+# Parent d7d48be4e1ca1ccec946c992a43a0c6cbe14eae4
+diff --git a/pida-plugins/python_lint/python_lint.py b/pida-plugins/python_lint/python_lint.py
+--- a/pida-plugins/python_lint/python_lint.py
++++ b/pida-plugins/python_lint/python_lint.py
+@@ -45,49 +45,6 @@ except ImportError:
+     pylint = None
+     BaseReporter = object
+ 
+-# class SkeletonEventsConfig(EventsConfig):
+-#
+-#     def subscribe_all_foreign(self):
+-#         self.subscribe_foreign('buffer', 'document-changed',
+-#                     self.on_document_changed)
+-#
+-#     def on_document_changed(self, document):
+-#         pass
+-#
+-#
+-# class SkeletonFeaturesConfig(FeaturesConfig):
+-#
+-#     def subscribe_all_foreign(self):
+-#         pass
+-#
+-#
+-# class SkeletonOptionsConfig(OptionsConfig):
+-#
+-#     def create_options(self):
+-#         self.create_option(
+-#             'Skeleton_for_executing',
+-#             _('Skeleton Executable for executing'),
+-#             str,
+-#             'Skeleton',
+-#             _('The Skeleton executable when executing a module'),
+-#         )
+-#
+-#
+-# class SkeletonActionsConfig(ActionsConfig):
+-#
+-#     def create_actions(self):
+-#         self.create_action(
+-#             'execute_Skeleton',
+-#             TYPE_NORMAL,
+-#             _('Execute Skeleton Module'),
+-#             _('Execute the current Skeleton module in a shell'),
+-#             gtk.STOCK_EXECUTE,
+-#             self.on_Skeleton_execute,
+-#         )
+-#
+-#     def on_Skeleton_execute(self, action):
+-#         #self.svc.execute_current_document()
+-#         pass
+ 
+ SUBTYPE_MAPPING = {
+     'W0511': 'fixme',
+symbols-util
 kill-completer-types-enum
 kill-validator-types-subtypes-enums
 kill-outliner-types-enum
-kill-most-language-enum-definitions
-validator-markup-format-cleanup
+pylint-kill-skeleton
+cleanup-validator-markup
 core-pdbus-pyxml-introspect #+dbus
 pida-remote-cleanup
 non-optional-core-pdbus #+dbus #-stable
+# HG changeset patch
+# Parent b51f85401eb94624b0ae37ec36c28097fdcbceb5
+create pida.utils.symbol as collection of ordered string constants/enums
+
+diff --git a/pida/utils/symbols.py b/pida/utils/symbols.py
+new file mode 100644
+--- /dev/null
++++ b/pida/utils/symbols.py
+@@ -0,0 +1,31 @@
++
++
++class Symbols(object):
++
++    def __init__(self, name, items):
++        self.items = {}
++        self.name = name
++        for index, value in enumerate(items):
++            if not value.islower():
++                raise ValueError('%s is not lower')
++            self.items[index] = value
++            self.items[value] = index
++            setattr(self, value.upper(), value)
++
++    def key(self, item):
++        """
++        :param str item: one of the symbols
++
++        key function for sorting a list of symbols
++        everything str thats not in this symbol bag gets sorted last
++        """
++        return self.items.get(item.lower(), len(self.items))
++
++    def __contains__(self, key):
++        return key.lower() in self.items
++
++    def __getitem__(self, item):
++        return self.items[item]
++
++    def __iter__(self):
++        raise TypeError("a bag of symbols is not iterable")
+diff --git a/tests/utils/test_symbols.py b/tests/utils/test_symbols.py
+new file mode 100644
+--- /dev/null
++++ b/tests/utils/test_symbols.py
+@@ -0,0 +1,35 @@
++from pida.utils.symbols import Symbols
++from py.test import raises
++
++
++def pytest_funcarg__table(request):
++    return Symbols('test', 'ab')
++
++
++def test_attrs(table):
++    assert table.A == 'a'
++    assert table.B == 'b'
++
++def test_content(table):
++    assert table['a'] == 0
++    assert table['b'] == 1
++    assert table[0] == 'a'
++    assert table[1] == 'b'
++
++def test_needs_lower():
++    raises(ValueError, Symbols, 'name', ['Foo'])
++
++def test_contains(table):
++    assert 'a' in table
++    assert 'A' in table
++
++def test_order():
++    t = Symbols('test', 'ba')
++    l = ['c', 'a', 'b']
++    l.sort(key=t.key)
++    #XXX: None sorts before anything else
++    assert l == ['b', 'a', 'c']
++
++def test_not_iterable(table):
++    with raises(TypeError):
++        list(table)

validator-markup-format-cleanup

-# HG changeset patch
-# User Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
-# Date 1280876358 -7200
-# Node ID 5d747f356bfc547439b23bd62b5b2f225851cf50
-# Parent 985a4f0089877903d25796735027805edb55b6bb
-imported patch validator-markip-format-cleanup
-
-diff --git a/pida-plugins/python/python.py b/pida-plugins/python/python.py
---- a/pida-plugins/python/python.py
-+++ b/pida-plugins/python/python.py
-@@ -225,41 +225,12 @@ def _create_exception_validation(e):
-     return [msg]
- 
- class PythonError(ValidationError):
--    def get_markup(self):
-+    def get_format_args(self):
-         args = [('<b>%s</b>' % arg) for arg in self.message_args]
--        message_string = self.message % tuple(args)
--        if self.type_ == 'error':
--            typec = self.lookup_color('pida-val-error')
--        elif self.type_ == 'info':
--            typec = self.lookup_color('pida-val-info')
--        elif self.type_ == 'warning':
--            typec = self.lookup_color('pida-val-warning')
--        else:
--            typec = self.lookup_color('pida-val-def')
--        
--        if typec:
--            typec = typec.to_string()
--        else:
--            typec = "black"
--        
--        linecolor = self.lookup_color('pida-lineno')
--        if linecolor:
--            linecolor = linecolor.to_string()
--        else:
--            linecolor = "black"
--        
--        markup = ("""<tt><span color="%(linecolor)s">%(lineno)s</span> </tt>"""
--    """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
--    """>:<span style="italic">%(subtype)s</span>\n%(message)s""" % 
--                      {'lineno':self.lineno, 
--                      'type': self.type_.capitalize(),
--                      'subtype': self.subtype.capitalize(),
--                      'message': message_string,
--                      'linecolor': linecolor,
--                      'typec': typec,
--                      })
--        return markup
--    markup = property(get_markup)
-+        data = ValidationError.get_format_args(self)
-+        data['message'] = self.message % tuple(args)
-+        return data
-+
- 
- class PythonValidator(Validator):
- 
-diff --git a/pida-plugins/python_lint/python_lint.py b/pida-plugins/python_lint/python_lint.py
---- a/pida-plugins/python_lint/python_lint.py
-+++ b/pida-plugins/python_lint/python_lint.py
-@@ -44,50 +44,6 @@ except ImportError:
-     pylint = None
-     BaseReporter = object
- 
--# class SkeletonEventsConfig(EventsConfig):
--#
--#     def subscribe_all_foreign(self):
--#         self.subscribe_foreign('buffer', 'document-changed',
--#                     self.on_document_changed)
--#
--#     def on_document_changed(self, document):
--#         pass
--#
--#
--# class SkeletonFeaturesConfig(FeaturesConfig):
--#
--#     def subscribe_all_foreign(self):
--#         pass
--#
--#
--# class SkeletonOptionsConfig(OptionsConfig):
--#
--#     def create_options(self):
--#         self.create_option(
--#             'Skeleton_for_executing',
--#             _('Skeleton Executable for executing'),
--#             str,
--#             'Skeleton',
--#             _('The Skeleton executable when executing a module'),
--#         )
--#
--#
--# class SkeletonActionsConfig(ActionsConfig):
--#
--#     def create_actions(self):
--#         self.create_action(
--#             'execute_Skeleton',
--#             TYPE_NORMAL,
--#             _('Execute Skeleton Module'),
--#             _('Execute the current Skeleton module in a shell'),
--#             gtk.STOCK_EXECUTE,
--#             self.on_Skeleton_execute,
--#         )
--#
--#     def on_Skeleton_execute(self, action):
--#         #self.svc.execute_current_document()
--#         pass
--
- SUBTYPE_MAPPING = {
-     'W0511': 'fixme',
-     'W0622': 'redefined',
-@@ -105,53 +61,35 @@ class PythonError(ValidationError, Log):
-     """
-     Validator class for PyLint errrors
-     """
--    def get_markup(self):
-+    
-+    markup_format = (
-+        '<tt><span color="{line_color}">{lineno}</span> </tt>'
-+        '<span foreground="{type_color}" style="italic" weight="bold">{type}'
-+        '</span>::<span style="italic">%(subtype)s</span> '
-+        '<span size="small" style="italic">{msg_id}</span>\n'
-+        '{message}'
-+    )
-+    def get_format_args(self):
-         if self.message_args:
-             try:
-                 if isinstance(self.message_args, (list, tuple)):
-                     args = [('<b>%s</b>' % arg) for arg in self.message_args]
--                    message_string = self.message % tuple(args)
-+                    message = self.message % tuple(args)
-                 else:
-                     args = '<b>%s</b>' % self.message_args
--                    message_string = self.message % args
-+                    message = self.message % args
-             except TypeError, e:
-                 self.log.warning("Can't convert arguments %s : %s" %(
-                                     self.message, self.message_args))
--                message_string = self.message
-+                message = self.message
-         else:
--            message_string = self.message
--        if self.type_ == 'error':
--            typec = self.lookup_color('pida-val-error')
--        elif self.type_ == 'error':
--            typec = self.lookup_color('pida-val-info')
--        elif self.type_ == 'warning':
--            typec = self.lookup_color('pida-val-warning')
--        else:
--            typec = self.lookup_color('pida-val-def')
--        if typec:
--            typec = typec.to_string()
--        else:
--            linecolor = "black"
--        linecolor = self.lookup_color('pida-lineno')
--        if linecolor:
--            linecolor = linecolor.to_string()
--        else:
--            linecolor = "black"
--        markup = ("""<tt><span color="%(linecolor)s">%(lineno)s</span> </tt>"""
--    """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
--    """>:<span style="italic">%(subtype)s</span>  -  """
--    """<span size="small" style="italic">%(msg_id)s</span>\n%(message)s""" % 
--                      {'lineno':self.lineno,
--                      'type': self.type_.capitalize(),
--                      'subtype': self.subtype.capitalize(),
--                      'message': message_string,
--                      'linecolor': linecolor,
--                      'typec': typec,
--                      'msg_id': self.msg_id
--                      })
--        return markup
--    markup = property(get_markup)
-+            message = self.message
- 
-+        base = ValidationError.get_format_args(self)
-+        base.update({
-+            'msg_id': self.msg_id,
-+            'message': message_string,
-+        })
- 
- from logilab.common.ureports import TextWriter
- from logilab.common.textutils import get_csv
-diff --git a/pida/utils/languages.py b/pida/utils/languages.py
---- a/pida/utils/languages.py
-+++ b/pida/utils/languages.py
-@@ -122,52 +122,41 @@ class ValidationError(InitObject):
-     filename = None
-     lineno = None
- 
-+
-+    markup_format =(
-+        '<tt><span color="{line_color}">{lineno}</span> </tt>'
-+        '<span foreground="{type_color}" style="italic" weight="bold">{type}'
-+        '</span>::<span style="italic">%(subtype)s</span>\n'
-+        '{message}'
-+    )
-     def __str__(self):
-         return '%s:%s: %s' % (self.filename, self.lineno, self.message)
- 
-     def lookup_color(self, color):
-         return "#000000"
- 
--    @staticmethod
--    def from_exception(exc):
--        """Returns a new Message from a python exception"""
--        # FIXME
--        pass
-+    def _type_color(self):
-+        mapping = {
-+            'error': 'pida-val-error',
-+            'info': 'pida-val-info',
-+            'warning': 'pida-val-warning',
-+        }
-+        lookup = mapping.get(self._type, 'pida-val-def')
-+        return self.lookup_color(lookup)
- 
--    def get_markup(self):
--        if self.type_ == 'error':
--            typec = self.lookup_color('pida-val-error')
--        elif self.type_ == 'info':
--            typec = self.lookup_color('pida-val-info')
--        elif self.type_ == 'warning':
--            typec = self.lookup_color('pida-val-warning')
--        else:
--            typec = self.lookup_color('pida-val-def')
--        
--        markup = ("""<tt><span color="%(linecolor)s">%(lineno)s</span> </tt>"""
--    """<span foreground="%(typec)s" style="italic" weight="bold">%(type)s</span"""
--    """>:<span style="italic">%(subtype)s</span>\n%(message)s""" % 
--                      {'lineno':self.lineno, 
--                      'type': self.type_.capitalize(),
--                      'subtype': self.subtype.capitalize(),
--                      'message': self.message,
--                      'linecolor': color_to_string(self.lookup_color('pida-lineno')),
--                      'typec': color_to_string(typec),
--                      })
--        return markup
--    markup = property(get_markup)
--#     def get_markup(self):
--#         #args = [('<b>%s</b>' % arg) for arg in msg.message_args]
--#         #message_string = self.message % tuple(args)
--#         #msg.name = msg.__class__.__name__
--#         markup = ('<tt>%s </tt><i>%s:%s</i>\n%s' % 
--#                       (self.lineno, 
--#                       LANG_VALIDATOR_TYPES.whatis(self.type_).capitalize(),
--#                       LANG_VALIDATOR_SUBTYPES.whatis(self.subtype).capitalize(),
--#                       self.message))
--#         return markup
--#     
--#     markup = property(get_markup)
-+    @property
-+    def markup(self):
-+        return self.markup_format.format(**self.get_format_args())
-+
-+    def get_format_args(self):
-+        return dict(
-+            lineno=self.lineno,
-+            type=self.type_.capitalize(),
-+            subtype=self.subtype.capitalize(),
-+            message=self.message,
-+            line_color=color_to_string(self.lookup_color('pida-lineno')),
-+            type_color=color_to_string(self._type_color()),
-+            )
- 
- 
-