Return a string label for a MonomerPattern.
556131
def _monomer_pattern_label(mp):
    """"""
    site_strs = []
    for site, cond in mp.site_conditions.items():
        if isinstance(cond, tuple) or isinstance(cond, list):
            assert len(cond) == 2
            if cond[1] == WILD:
                site_str = '%s_%s' % (site, cond[0])
            else:
                site_str = '%s_%s%s' % (site, cond[0], cond[1])
        elif isinstance(cond, numbers.Real):
            continue
        else:
            site_str = '%s_%s' % (site, cond)
        site_strs.append(site_str)
    return '%s_%s' % (mp.monomer.name, '_'.join(site_strs))
788152
def _get_label(placeholder, label_mapping, label_i):
    
    if placeholder in label_mapping:
        return label_mapping[placeholder], label_mapping, label_i

    new_target = Label("{}{}".format(placeholder.prefix, label_i))
    label_i += 1
    label_mapping[placeholder] = new_target
    return new_target, label_mapping, label_i
591508
def label( self, node ):
        """"""
        result = []
        if node.get('type'):
            result.append( node['type'] )
        if node.get('name' ):
            result.append( node['name'] )
        elif node.get('value') is not None:
            result.append( unicode(node['value'])[:32])
        if 'module' in node and not node['module'] in result:
            result.append( ' in %s'%( node['module'] ))
        if node.get( 'size' ):
            result.append( '%s'%( mb( node['size'] )))
        if node.get( 'totsize' ):
            result.append( '(%s)'%( mb( node['totsize'] )))
        parent_count = len( node.get('parents',()))
        if parent_count > 1:
            result.append( '/%s refs'%( parent_count ))
        return " ".join(result)
246171
def normalize(self, decl_string, arg_separator=None):
        """"""
        if not self.has_pattern(decl_string):
            return decl_string
        name, args = self.split(decl_string)
        for i, arg in enumerate(args):
            args[i] = self.normalize(arg)
        return self.join(name, args, arg_separator)
1191376
def _get_regex_pattern(label):
    
    parts = _split_by_punctuation.split(label)

    for index, part in enumerate(parts):
        if index % 2 == 0:
            # Word
            if not parts[index].isdigit() and len(parts[index]) > 1:
                parts[index] = _convert_word(parts[index])
        else:
            # Punctuation
            if not parts[index + 1]:
                # The separator is not followed by another word. Treat
                # it as a symbol.
                parts[index] = _convert_punctuation(
                    parts[index],
                    current_app.config["CLASSIFIER_SYMBOLS"]
                )
            else:
                parts[index] = _convert_punctuation(
                    parts[index],
                    current_app.config["CLASSIFIER_SEPARATORS"]
                )

    return "".join(parts)
1277282
def repr_part(self):
        """"""
        optargs = [('weighting', self.const, 1.0),
                   ('exponent', self.exponent, 2.0)]
        return signature_string([], optargs, mod=':.4')
1305847
def get_labels(labels):
    """"""
    label_u = unique_labels(labels)
    label_u_line = [i + "_line" for i in label_u]
    return label_u, label_u_line
1293862
def label(self, value):
        
        return self._labels.get(value) or text.pretty(self(value))
401010
def get_label(key):
    
    if key in rel:
        if mpl.rcParams['text.usetex']:
            return rel[key]['label_latex']
        else:
            return rel[key]['label_mpl']
    else:
        return key
1291947
def _getOidLabel(self, nodeName, oidToLabelIdx, labelToOidIdx):
        """"""
        if not nodeName:
            return nodeName, nodeName, ()

        if nodeName in labelToOidIdx:
            return labelToOidIdx[nodeName], nodeName, ()

        if nodeName in oidToLabelIdx:
            return nodeName, oidToLabelIdx[nodeName], ()

        if len(nodeName) < 2:
            return nodeName, nodeName, ()

        oid, label, suffix = self._getOidLabel(
            nodeName[:-1], oidToLabelIdx, labelToOidIdx)

        suffix = suffix + nodeName[-1:]

        resLabel = label + tuple([str(x) for x in suffix])
        if resLabel in labelToOidIdx:
            return labelToOidIdx[resLabel], resLabel, ()

        resOid = oid + suffix
        if resOid in oidToLabelIdx:
            return resOid, oidToLabelIdx[resOid], ()

        return oid, label, suffix
426245
function getLabel(opts) {

  var className = mixin({
    'control-label': true
  }, opts.className);

  if (opts.align) {
    className['text-' + opts.align] = true;
  }

  return {
    tag: 'label',
    attrs: {
      htmlFor: opts.htmlFor,
      id: opts.id,
      className: className
    },
    children: opts.label
  };
}
526388
def label(self):
        
        if len(self.name) > 14 and '.' in self.name:
            return '\\.\\n'.join(self.name.split('.'))  # pragma: nocover
        return self.name
220511
def as_colr(
            self, label_args=None, type_args=None, type_val_args=None,
            value_args=None, spec_args=None):
        
        label_args = label_args or {'fore': 'red'}
        type_args = type_args or {'fore': 'yellow'}
        type_val_args = type_val_args or {'fore': 'grey'}
        value_args = value_args or {'fore': 'blue', 'style': 'bright'}
        spec_args = spec_args or {'fore': 'blue'}
        spec_repr = repr(self.spec)
        spec_quote = spec_repr[0]
        val_repr = repr(self.value)
        val_quote = val_repr[0]
        return Colr(self.default_format.format(
            label=Colr(':\n    ').join(
                Colr('Bad format spec. color name/value', **label_args),
                ',\n    '.join(
                    '{lbl:<5} ({val})'.format(
                        lbl=Colr(l, **type_args),
                        val=Colr(v, **type_val_args),
                    )
                    for l, v in self.accepted_values
                )
            ),
            spec=Colr('=').join(
                Colr(v, **spec_args)
                for v in spec_repr[1:-1].split('=')
            ).join((spec_quote, spec_quote)),
            value=Colr(
                val_repr[1:-1],
                **value_args
            ).join((val_quote, val_quote)),
        ))
1228573
def _get_theme_label(catalog, theme):
    """"""
    try:
        label = catalog.get_theme(identifier=theme)['label']
    except BaseException:
        try:
            label = catalog.get_theme(label=theme)['label']
        except BaseException:
            raise ce.ThemeNonExistentError(theme)

    label = re.sub(r'[^\wá-úÁ-ÚñÑ .-]+', '',
                   label, flags=re.UNICODE)
    return label
28562
def get_monomer_pattern(model, agent, extra_fields=None):
    """"""
    try:
        monomer = model.monomers[_n(agent.name)]
    except KeyError as e:
        logger.warning('Monomer with name %s not found in model' %
                       _n(agent.name))
        return None
    # Get the agent site pattern
    pattern = get_site_pattern(agent)
    if extra_fields is not None:
        for k, v in extra_fields.items():
            # This is an important assumption, it only sets the given pattern
            # on the monomer if that site/key is not already specified at the
            # Agent level. For instance, if the Agent is specified to have
            # 'activity', that site will not be updated here.
            if k not in pattern:
                pattern[k] = v
    # If a model is given, return the Monomer with the generated pattern,
    # otherwise just return the pattern
    try:
        monomer_pattern = monomer(**pattern)
    except Exception as e:
        logger.info("Invalid site pattern %s for monomer %s" %
                      (pattern, monomer))
        return None
    return monomer_pattern
927814
def label(self) -> str:
        """"""
        label = self.expression.replace("_", "\\;")
        if self.units_kind:
            symbol = wt_units.get_symbol(self.units)
            for v in self.variables:
                vl = "%s_{%s}" % (symbol, v.label)
                vl = vl.replace("_{}", "")  # label can be empty, no empty subscripts
                label = label.replace(v.natural_name, vl)
            units_dictionary = getattr(wt_units, self.units_kind)
            label += r"\,"
            label += r"\left("
            label += units_dictionary[self.units][2]
            label += r"\right)"
        label = r"$\mathsf{%s}$" % label
        return label
528767
def label_from_instance(self, obj):
        
        label = smart_text(obj)
        prefix = self.level_indicator * getattr(obj, obj._mptt_meta.level_attr)
        if prefix:
            return '%s %s' % (prefix, label)
        return label