~ubuntu-branches/ubuntu/trusty/pylint/trusty

« back to all changes in this revision

Viewing changes to pyreverse/diadefslib.py

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2009-03-27 09:45:39 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090327094539-xe2s86jkbvdv3xhb
Tags: 0.18.0-1
* New upstream release
* debian/copyright
  - added packaging copyright for the work I do
  - clearly separated copyright and license notices, indenting by 4 spaces
  - link to GPL-2 file, not to the generic GPL
* debian/control
  - updated Homepage field
  - bump versions for python-logilab-common and python-logilab-astng depends
  - bump Standard-Versions to 3.8.1 (no changes needed)
* debian/{control, rules}
  - switch from python-central to python-support
* debian/rules
  - 'build' is a dir, we need to clean with 'rm'

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
            title =  '%s.%s' % (node.root().name, title)
41
41
        return title
42
42
 
 
43
    def _set_option(self, option):
 
44
        """activate some options if not explicitely desactivated"""
 
45
        # if we have a class diagram, we want more information by default;
 
46
        # so if the option is None, we return True
 
47
        if option is None:
 
48
            if self.config.classes:
 
49
                return True
 
50
            else:
 
51
                return False
 
52
        return option
 
53
 
43
54
    def _set_default_options(self):
44
55
        """set different default options with _default dictionary"""
45
 
        mod = {None:False, True:True, False:False}
46
 
        if self.config.classes: # defaults for class diagram
47
 
            mod[None] = True
48
 
        self.module_names = mod[self.config.module_names]
49
 
        all_ancestors = mod[self.config.all_ancestors]
50
 
        all_associated = mod[self.config.all_associated]
 
56
        self.module_names = self._set_option(self.config.module_names)
 
57
        all_ancestors = self._set_option(self.config.all_ancestors)
 
58
        all_associated = self._set_option(self.config.all_associated)
51
59
        anc_level, ass_level = (0, 0)
52
60
        if  all_ancestors:
53
61
            anc_level = -1
63
71
        """help function for search levels"""
64
72
        return self.anc_level, self.ass_level
65
73
 
66
 
    def not_show_builtin(self, node):
 
74
    def show_node(self, node):
67
75
        """true if builtins and not show_builtins"""
68
 
        builtin = (node.name in ('object', 'type') or 
69
 
                    node.root().name == '__builtin__')
70
 
        return builtin and not (self.config.show_builtin)
 
76
        if self.config.show_builtin:
 
77
            return True
 
78
        return node.root().name != '__builtin__'
71
79
 
72
80
    def add_class(self, node):
73
81
        """visit one class and add it to diagram"""
79
87
        if level == 0:
80
88
            return
81
89
        for ancestor in node.ancestors(recurs=False):
82
 
            if self.not_show_builtin(ancestor):
 
90
            if not self.show_node(ancestor):
83
91
                continue
84
92
            yield ancestor
85
93
 
91
99
            for ass_node in ass_nodes:
92
100
                if isinstance(ass_node, astng.Instance):
93
101
                    ass_node = ass_node._proxied
94
 
                if not isinstance(ass_node, astng.Class) \
95
 
                       or self.not_show_builtin(ass_node):
 
102
                if not (isinstance(ass_node, astng.Class) 
 
103
                        and self.show_node(ass_node)):
96
104
                    continue
97
105
                yield ass_node
98
106
 
99
107
    def extract_classes(self, klass_node, anc_level, ass_level):
100
 
        """extract recursively classes related to klass_node
101
 
        """
102
 
        if self.classdiagram.has_node(klass_node):
 
108
        """extract recursively classes related to klass_node"""
 
109
        if self.classdiagram.has_node(klass_node) or not self.show_node(klass_node):
103
110
            return
104
111
        self.add_class(klass_node)
105
112