Create chart that depicts the lifetime of the instance registered with
        `classname`. The output is written to `filename`.
518245
def create_lifetime_chart(self, classname, filename=''):
        
        try:
            from pylab import figure, title, xlabel, ylabel, plot, savefig
        except ImportError:
            return HtmlStats.nopylab_msg % (classname+" lifetime")

        cnt = []
        for tobj in self.index[classname]:
            cnt.append([tobj.birth, 1])
            if tobj.death:
                cnt.append([tobj.death, -1])
        cnt.sort()
        for i in range(1, len(cnt)):
            cnt[i][1] += cnt[i-1][1]
            #if cnt[i][0] == cnt[i-1][0]:
            #    del cnt[i-1]

        x = [t for [t,c] in cnt]
        y = [c for [t,c] in cnt]

        figure()
        xlabel("Execution time [s]")
        ylabel("Instance #")
        title("%s instances" % classname)
        plot(x, y, 'o')
        savefig(filename)

        return self.chart_tag % (os.path.basename(filename))
520221
def _get_class_path(self, klass_or_instance):
        
        if inspect.isclass(klass_or_instance):
            klass = '{}.{}'.format(klass_or_instance.__module__, klass_or_instance.__name__)
        elif not isinstance(klass_or_instance, str):
            klass = klass_or_instance.__class__
            klass = '{}.{}'.format(klass.__module__, klass.__name__)
        else:
            klass = klass_or_instance

        return klass
802365
def persistentRegisterInspector(fullName, fullClassName, pythonPath=''):
    
    registry = InspectorRegistry()
    registry.loadOrInitSettings()
    registry.registerInspector(fullName, fullClassName, pythonPath=pythonPath)
    registry.saveSettings()
866228
@Override
    public int classIndex() {
        int classIndex = instanceHeader.classIndex();
       // return  ? classIndex : 0;
        if(classIndex == Integer.MAX_VALUE)
        	if(this.instanceHeader.instanceInformation.range!=null)
        		classIndex=instanceHeader.instanceInformation.range.getStart();
        	else
        		classIndex=0;
        return classIndex;
    }
1221319
def instance(cls):
        

        if not hasattr(cls, "_instance") or cls._instance is None:
            cls._instance = cls()
        return cls._instance
449139
def singleton(cls):
    
    instances = {}
    def getinstance(**kwargs):
        """
        Creates a new RGeocoder instance if not created already
        """
        if cls not in instances:
            instances[cls] = cls(**kwargs)
        return instances[cls]
    return getinstance
363310
def _printInstances(self, hrlinetop=True):
        
        if not self.currentEntity:  # ==> ontology level
            return
        x = self.currentEntity['object']
        if self.currentEntity['type'] == 'class':
            if hrlinetop:
                self._print("----------------")
            self._print("INSTANCES: [%d]" % len(x.instances, "IMPORTANT"))
            for i in x.instances:
                self._print(i.qname)
            self._print("----------------")
        return
561979
def repr_def_class(self, class_data):
        
        classname = self.formatted_classname(class_data["classname"])
        if classname not in self.classes:
            self.lines.append("")
            self.lines.append("class %s(%s):" % (classname, self.basename))
            
            kwargs = list()
            setattr_arguments = list()
            for attr in self._classes[classname]:
                kwargs.append("%s=None" % attr)
                setattr_arguments.append(
                    self.Tab2 + "self.%s = %s" % (attr, attr))
            if len(kwargs):
                line = self.Tab + "def __init__(self, %s):" % ", ".join(kwargs)
            else:
                line = self.Tab + "def __init__(self):"
            self.lines.append(line)
            for setattr_argument in setattr_arguments:
                self.lines.append(setattr_argument)
            if len(setattr_arguments):
                self.lines.append("")
            self.classes.add(classname)
1197344
public String getInstanceNameFromDataservice(Class cls) {
		DataService dataService = (DataService) cls.getAnnotation(DataService.class);
		String clsName = dataService.name();
		if (clsName.isEmpty()) {
			clsName = cls.getSimpleName();
		}
		return getInstanceName(clsName);
	}
213775
def label_from_instance(self, obj):
        
        return '%s %s' % (self.level_indicator * getattr(obj, obj._mptt_meta.level_attr), obj)
1052661
def CreateInstance(self, *args, **kwargs):
        

        inst = args[0] if args else kwargs['NewInstance']
        try:
            self.instances[self.default_namespace].append(inst)
        except KeyError:
            self.instances[self.default_namespace] = [inst]
        return inst.path
1316967
def new(self, name, *args, **kwargs):
        '''
        '''
        if name in self._instance_map:
            raise ValueError('Instance {0} is already initialized'
                             .format(name))

        instance = self._class_map[name](*args, **kwargs)
        self._instance_map[name] = instance
        return instance
475817
def output(self, filename):
        
        info = 'Inheritance\n'

        if not self.contracts:
            return

        info += blue('Child_Contract -> ') + green('Immediate_Base_Contracts')
        info += green(' [Not_Immediate_Base_Contracts]')
        for child in self.contracts:
            info += blue(f'\n+ {child.name}')
            if child.inheritance:
                immediate = child.immediate_inheritance
                not_immediate = [i for i in child.inheritance if i not in immediate]
                info += ' -> ' + green(", ".join(map(str, immediate)))
                if not_immediate:
                    info += ", ["+ green(", ".join(map(str, not_immediate))) + "]"

        info += green('\n\nBase_Contract -> ') + blue('Immediate_Child_Contracts')
        info += blue(' [Not_Immediate_Child_Contracts]')
        for base in self.contracts:
            info += green(f'\n+ {base.name}')
            children = list(self._get_child_contracts(base))
            if children:
                immediate = [child for child in children if base in child.immediate_inheritance]
                not_immediate = [child for child in children if not child in immediate]
                info += ' -> ' + blue(", ".join(map(str, immediate)))
                if not_immediate:
                    info += ', [' + blue(", ".join(map(str, not_immediate))) + ']'
        self.info(info)
1135438
def stats(self):
        
        printDebug("Classes.....: %d" % len(self.classes))
        printDebug("Properties..: %d" % len(self.properties))
1357706
def show_instances(server, cim_class):
    
    if cim_class == 'CIM_RegisteredProfile':
        for inst in server.profiles:
            print(inst.tomof())
        return

    for ns in server.namespaces:
        try:
            insts = server.conn.EnumerateInstances(cim_class, namespace=ns)
            if len(insts):
                print('INSTANCES OF %s ns=%s' % (cim_class, ns))
                for inst in insts:
                    print(inst.tomof())
        except pywbem.Error as er:
            if er.status_code != pywbem.CIM_ERR_INVALID_CLASS:
                print('%s namespace %s Enumerate failed for conn=%s\n'
                      'exception=%s'
                      % (cim_class, ns, server, er))
1251562
def describe(cls) -> None:
        
        max_lengths = []
        for attr_name in cls.attr_names():
            attr_func = "%ss" % attr_name
            attr_list = list(map(str, getattr(cls, attr_func)())) + [attr_name]
            max_lengths.append(max(list(map(len, attr_list))))
        row_format = "{:>%d} | {:>%d} | {:>%d}" % tuple(max_lengths)
        headers = [attr_name.capitalize() for attr_name in cls.attr_names()]
        header_line = row_format.format(*headers)
        output = "Class: %s\n" % cls.__name__
        output += header_line + "\n"
        output += "-"*(len(header_line)) + "\n"
        for item in cls:
            format_list = [str(getattr(item, attr_name))
                           for attr_name in cls.attr_names()]
            output += row_format.format(*format_list) + "\n"
        print(output)
939553
def finalize(self, **kwargs):
        
        # Set the title
        self.set_title(
            'Class Balance for {:,} Instances'.format(self.support_.sum())
        )

        # Set the x ticks with the class names or labels if specified
        labels = self.labels if self.labels is not None else self.classes_
        xticks = np.arange(len(labels))
        if self._mode == COMPARE:
            xticks = xticks + (0.35/2)

        self.ax.set_xticks(xticks)
        self.ax.set_xticklabels(labels)

        # Compute the ceiling for the y limit
        cmax = self.support_.max()
        self.ax.set_ylim(0, cmax + cmax* 0.1)
        self.ax.set_ylabel("support")

        # Remove the vertical grid
        self.ax.grid(False, axis="x")

        # Add the legend if in compare mode:
        if self._mode == COMPARE:
            self.ax.legend(frameon=True)