Commits

Ronny Pfannschmidt committed 872cfbc

finish language-iconname-cachedproperty patch

Comments (0)

Files changed (2)

language-iconname-cachedproperty

-# HG changeset patch
-# User Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
-# Date 1280876358 -7200
-# Node ID 15835db48c6f7b84314741dfca4d7a3f4a060bf1
-# Parent 5d747f356bfc547439b23bd62b5b2f225851cf50
-imported patch language-iconname-cachedproperty
-
-diff --git a/pida/utils/languages.py b/pida/utils/languages.py
---- a/pida/utils/languages.py
-+++ b/pida/utils/languages.py
-@@ -9,6 +9,7 @@ List of general Language classes.
- """
- from .addtypes import Enumeration
- from .path import get_line_from_file
-+from .descriptors import cached_property
- 
- import itertools
- 
-@@ -178,12 +179,9 @@ class OutlineItem(InitObject):
-     def get_markup(self):
-         return '<b>%s</b>' % self.name
- 
--    def _get_icon_name(self):
--        return getattr(self, '_icon_name_set', 
--                                    LANG_IMAGE_MAP.get(self.type, ''))
--    def _set_icon_name(self, value):
--        self._icon_name_set = value
--    icon_name = property(_get_icon_name, _set_icon_name)
-+    @cached_property
-+    def icon_name(self):
-+        return LANG_IMAGE_MAP.get(self.type, '')
- 
-     #XXX: these 2 hacks need tests!!!
-     @property
-@@ -221,13 +219,9 @@ class Definition(InitObject):
-             where = " line %s " % self.line
-         return '<Definition %s%s>' % (self.file_name, where)
- 
--    def _get_icon_name(self):
--        return getattr(self, '_icon_name_set', 
--                                    LANG_IMAGE_MAP.get(self.type, ''))
--    def _set_icon_name(self, value):
--        self._icon_name_set = value
--
--    icon_name = property(_get_icon_name, _set_icon_name)
-+    @cached_property
-+    def icon_name(self):
-+        return LANG_IMAGE_MAP.get(self.type, '')
- 
-     def _get_signature(self):
-         if self.line is None and self.offset is None:
 kill-outliner-types-enum
 kill-most-language-enum-definitions
 validator-markip-format-cleanup
-language-iconname-cachedproperty
 core-pdbus-pyxml-introspect #+dbus
 pida-remote-cleanup
 non-optional-core-pdbus #+dbus #-stable