Ejemplo n.º 1
0
    def sort_sub_modules(self):
        """ Sort submodules by name """
        sm = [ (m.name, m) for m in self.sub_modules ]
        alpha_sort(sm)
        sm = [ m[1] for m in sm ]

        self.sub_modules = sm
Ejemplo n.º 2
0
    def get_imported_objects(self):
        """
        return all objects in this module's namespace but which are not
        defined in this module

        result format: [ (local_name, obj), (local_name, obj), ... ]
        """
        result = [ (name, obj) for name, obj in self.get_objects()
                    if obj.parent_module is not self ]
        alpha_sort(result)
        return result
Ejemplo n.º 3
0
    def _divide_list(the_list):
        "split list into object types (attr_list, class_list, func_list, trait_list)"
        attr_children = [ ]
        class_children = [ ]
        func_children = [ ]
        traits_children = [ ]

        #print "Checking type of items:"
        # build up lists, adding names for easy alphabetization
        for child in the_list:
            #print "\t%s" % child.name
            if isinstance(child, Function):
                func_children.append((child.name, child))
            elif isinstance(child, Class):
                class_children.append((child.name, child))
            elif isinstance(child, Attribute):
                if child.is_trait():
                    traits_children.append((child.name, child))
                else:
                    attr_children.append((child.name, child))

        # sort by name
        alpha_sort(attr_children)
        alpha_sort(class_children)
        alpha_sort(func_children)
        alpha_sort(traits_children)

        # discard names
        attr_children = [ x[1] for x in attr_children ]
        class_children = [ x[1] for x in class_children ]
        func_children = [ x[1] for x in func_children ]
        traits_children = [ x[1] for x in traits_children ]

        return attr_children, class_children, func_children, traits_children
Ejemplo n.º 4
0
def _order_hierarchy(klass_list, klass_to_children):
    if klass_list == [ ]:
        return [ ]
    else:
        # order hierarchy for subclasses of each class
        result = [ (klass.name, klass.abs_name, klass,
                    _order_hierarchy(list(klass_to_children[klass]),
                                     klass_to_children))
                   for klass in klass_list ]

        # sort by name
        alpha_sort(result)
        result = [ r[2:] for r in result ]

        return result
Ejemplo n.º 5
0
    def get_objects(self):
        "index accessible in this namespace"
        result = self.id_map.items()
        alpha_sort(result)

        return result
Ejemplo n.º 6
0
    def get_objects(self):
        "index accessible in this namespace"
        result = self.id_map.items()
        alpha_sort(result)

        return result