Transforms an USR into a valid python name.
333641
def make_python_name(self, name):
        """"""
        # FIXME see cindex.SpellingCache
        for k, v in [('<', '_'), ('>', '_'), ('::', '__'), (',', ''), (' ', ''),
                     ("$", "DOLLAR"), (".", "DOT"), ("@", "_"), (":", "_"),
                     ('-', '_')]:
            if k in name:  # template
                name = name.replace(k, v)
            # FIXME: test case ? I want this func to be neutral on C valid
            # names.
            if name.startswith("__"):
                return "_X" + name
        if len(name) == 0:
            pass
        elif name[0] in "01234567879":
            return "_" + name
        return name
1320340
def string_to_basename(s):
    '''
    
    '''
    s = s.strip().lower()
    s = re.sub(r'[^\w\s-]', '', s)
    return re.sub(r'[\s-]+', '-', s)
594822
def _unmangle_attribute_name(name):
    """"""

    # Python keywords cannot be used as variable names, an underscore should
    # be appended at the end of each of them when defining attribute names.
    name = _PYTHON_KEYWORD_MAP.get(name, name)

    # Attribute names are mangled with double underscore, as colon cannot
    # be used as a variable character symbol in Python. Single underscore is
    # used for substituting dash.
    name = name.replace('__', ':').replace('_', '-')

    return name
474260
def normalize(name):
    """"""

    # Name should not contain some specials chars (issue #1068)
    ret = name.replace(':', '')
    ret = ret.replace('%', '')
    ret = ret.replace(' ', '_')

    return ret
1225586
def nonver_name(self):
        """"""
        nv = self.as_version(None)
        if not nv:
            import re
            nv = re.sub(r'-[^-]+$', '', self.name)

        return nv
146251
def shorten_go_name_all(self, name):
        """"""
        name = self.replace_greek(name)
        name = name.replace("MHC class I", "MHC-I")
        return name
1270644
def untranslateName(s):
    """"""

    s = s.replace('DOT', '.')
    s = s.replace('DOLLAR', '$')
    # delete 'PY' at start of name components
    if s[:2] == 'PY': s = s[2:]
    s = s.replace('.PY', '.')
    return s
1075021
def _clean_name(self, prefix, obj):
        """"""
        return '{}{}_{}'.format(prefix, self._uid(), ''.join(c for c in obj.name if c.isalnum()))
1137339
def to_python(self, value):
        """"""
        if value is None or value == '':
            return value
        if isinstance(value, base.Version):
            return value
        if self.coerce:
            return base.Version.coerce(value, partial=self.partial)
        else:
            return base.Version(value, partial=self.partial)
621517
def convert_name(s):
    
    m = re.compile(r"^(.*)\.(.*)\((.*)\)(.*)  ::  (.*)$")
    res = m.search(s)
    if res:
        clname, methodname, all_args, ret, perm = res.groups()
        args = " ".join(map(name_to_androguard, all_args.split(",")))

        clname = name_to_androguard(clname)
        ret = name_to_androguard(ret)

        # perm is actually a comma separated list of permissions
        return "{}-{}-({}){}".format(clname, methodname, args, ret), perm.split(", ")
    else:
        raise ValueError("what?")
1216480
def to_str(self, s):
        '''
        
        '''
        if s.__class__ != str:
            if not IS_PY3K:
                s = s.encode('utf-8')
            else:
                raise AssertionError('Expected to have str on Python 3. Found: %s (%s)' % (s, s.__class__))
        return s
79650
def unit_key_from_name(name):
  """"""
  result = name

  for old, new in six.iteritems(UNIT_KEY_REPLACEMENTS):
    result = result.replace(old, new)

  # Collapse redundant underscores and convert to uppercase.
  result = re.sub(r'_+', '_', result.upper())

  return result
1171775
def _make_repr(attrs, ns):
    
    attr_names = tuple(a.name for a in attrs if a.repr)

    def __repr__(self):
        """
        Automatically created by attrs.
        """
        try:
            working_set = _already_repring.working_set
        except AttributeError:
            working_set = set()
            _already_repring.working_set = working_set

        if id(self) in working_set:
            return "..."
        real_cls = self.__class__
        if ns is None:
            qualname = getattr(real_cls, "__qualname__", None)
            if qualname is not None:
                class_name = qualname.rsplit(">.", 1)[-1]
            else:
                class_name = real_cls.__name__
        else:
            class_name = ns + "." + real_cls.__name__

        # Since 'self' remains on the stack (i.e.: strongly referenced) for the
        # duration of this call, it's safe to depend on id(...) stability, and
        # not need to track the instance and therefore worry about properties
        # like weakref- or hash-ability.
        working_set.add(id(self))
        try:
            result = [class_name, "("]
            first = True
            for name in attr_names:
                if first:
                    first = False
                else:
                    result.append(", ")
                result.extend((name, "=", repr(getattr(self, name, NOTHING))))
            return "".join(result) + ")"
        finally:
            working_set.remove(id(self))

    return __repr__
1030072
def register_proper_name(self, name):
        """"""
        with self.proper_names_db_path.open("a") as f:
            f.write(u"{0}\n".format(name))
686830
def instant_name_to_class_name(name):
    
    name2 = ''.join([e.title() for e in name.split('_')])
    return '_'.join([e[0].upper() + e[1:] for e in name2.split('.')])
270
def to_local_name(acs, attr):
    
    for aconv in acs:
        lattr = aconv.from_format(attr)
        if lattr:
            return lattr

    return attr.friendly_name
900972
def to_gremlin(self):
        """"""
        self.validate()
        mark_name, _ = self.location.get_location_name()
        return u'as({})'.format(safe_quoted_string(mark_name))