Returns the closest format or closest parent format associated to given name.

        :param name: Format name.
        :type name: unicode
        :return: Format.
        :rtype: QTextCharFormat
186431
def get_format(self, name):
        

        formats = [format for format in self.list_formats(self.__root_node) if format in name]
        if not formats:
            return QTextCharFormat()

        name = max(formats)

        format = None
        current_node = self.__root_node
        for selector in name.split("."):
            nodes = [node for node in current_node.children if node.name == selector]
            format_node = nodes and nodes[0] or None
            if not format_node:
                break

            current_node = format_node

            if not format_node.format:
                continue

            format = format_node.format
        return format
282207
def _posix_split_name(self, name):
        
        prefix = name[:LENGTH_PREFIX + 1]
        while prefix and prefix[-1] != "/":
            prefix = prefix[:-1]

        name = name[len(prefix):]
        prefix = prefix[:-1]

        if not prefix or len(name) > LENGTH_NAME:
            raise ValueError("name is too long")
        return prefix, name
1358322
def canonicalize_name(name)
      if name == nil or name == SEP
        return name
      elsif name[0] == SEP[0]
        return name.split(/\/+/).join(SEP)
      else
        return SEP + name.split(/\/+/).join(SEP)
      end
    end
385041
def _qname(self, name):
        
        if isinstance(name, QName):
            return name
        if not isinstance(name, str):
            raise TypeError("{} must be str".format(name))
        if name == '':
            return name
        if name.startswith('{'):
            return name
        prefix, tag = name.split(':', maxsplit=1)
        uri = self.NS[prefix]
        return QName(uri, tag)
433543
def guessFormat(self, name):
        
        name = name.lower()
        generator = self.generator
        if re.findall(r'^is[_A-Z]', name): return lambda x:generator.boolean()
        if re.findall(r'(_a|A)t$', name): return lambda x:generator.dateTime()

        if name in ('first_name','firstname'): return lambda x: generator.firstName()
        if name in ('last_name','lastname'): return lambda x: generator.lastName()

        if name in ('username','login','nickname'): return lambda x:generator.userName()
        if name in ('email','email_address'): return lambda x:generator.email()
        if name in ('phone_number','phonenumber','phone'): return lambda x:generator.phoneNumber()
        if name == 'address' : return lambda x:generator.address()
        if name == 'city' : return lambda x: generator.city()
        if name == 'streetaddress' : return lambda x: generator.streetaddress()
        if name in ('postcode','zipcode'): return lambda x: generator.postcode()
        if name == 'state' : return lambda x: generator.state()
        if name == 'country' : return lambda x: generator.country()
        if name == 'title' : return lambda x: generator.sentence()
        if name in ('body','summary', 'description'): return lambda x: generator.text()
198810
def get_formatter(name):
    
    if name in ('self', 'instance', 'this'):
        return af_self
    elif name == 'class':
        return af_class
    elif name in ('named', 'param', 'parameter'):
        return af_named
    elif name in ('default', 'optional'):
        return af_default
#    elif name in ('anonymous', 'arbitrary', 'unnamed'):
#        return af_anonymous
    elif name in ('keyword', 'pair', 'pairs'):
        return af_keyword
    else:
        raise ValueError('unknown trace formatter %r' % name)
70588
def extract_middle(name)
      return unless name && name.size >= 1

      (name.size - 1).downto(0) do |n|
        next unless name[n]

        if name[n] =~ Nameable::Latin::Patterns::LAST_NAME_PRE_DANGLERS
          @last = "#{name[n].downcase.capitalize} #{@last}"
        elsif name[n] =~ Nameable::Latin::Patterns::O_LAST_NAME_PRE_CONCATS
          @last = "O'#{@last}"
        elsif name[n] =~ /\-/ && n > 0 && name[n - 1]
          @last = "#{name[n - 1].delete('-')}-#{@last}"
          name[n - 1] = nil
        else
          @middle = @middle ? "#{name[n]} #{@middle}" : name[n]
        end

        name.delete_at(n)
      end

      @middle.capitalize! if @middle && !(@middle =~ /[a-z]/ && @middle =~ /[A-Z]/)
      @middle = "#{@middle}." if @middle && @middle.size == 1
    end
656239
def _sort_text(definition):
    

    # If its 'hidden', put it next last
    prefix = 'z{}' if definition.name.startswith('_') else 'a{}'
    return prefix.format(definition.name)
1220399
def from_format(self, attr):
        
        if attr.name_format:
            if self.name_format == attr.name_format:
                try:
                    return self._fro[attr.name.lower()]
                except KeyError:
                    pass
        else:  # don't know the name format so try all I have
            try:
                return self._fro[attr.name.lower()]
            except KeyError:
                pass

        return ""
1156769
def qualified_name(self):
        

        parent = self.full_parent_name
        if parent:
            return parent + ' ' + self.name
        else:
            return self.name
669072
def from_local_name(acs, attr, name_format):
    
    for aconv in acs:
        #print(ac.format, name_format)
        if aconv.name_format == name_format:
            #print("Found a name_form converter")
            return aconv.to_format(attr)
    return attr
281926
def getbyname(self, name):
        
        if name not in self._schbyname:
            raise KeyError('name {0} not registered'.format(name))

        return self._schbyname[name]
1089577
public static String formatNameForClassLoading(String name) {
        if (name == null) {
            return "java.lang.Object;";
        }

        if (TypeUtil.isPrimitiveType(name)) {
            return name;
        }

        if (name.startsWith("[")) {
            return name.replace('/', '.');
        }

        if (name.startsWith("L")) {
            name = name.substring(1);
            if (name.endsWith(";")) {
                name = name.substring(0, name.length() - 1);
            }
            return name.replace('/', '.');
        }

        String prefix = "";
        if (name.endsWith("[]")) { // todo need process multi
            prefix = "[";
            name = name.substring(0, name.length() - 2);

            return prefix + TypeUtil.getDescriptionByName(name);
        }

        return name.replace('/', '.');
    }
213265
def GetPresetByName(self, name):
    
    name = name.lower()
    return self._definitions.get(name, None)
1077383
def proto_text(self):
        
        return self.proto_template.format(type=self.type, name=self.name)
133779
def _normalize_name(self, name: str) -> str:
        
        if self.mapping:
            name = self.mapping.get(name, name)
        return name.lower().replace('-', '_')
694718
def getMargin(self, name):
        
        for margin in self._margins:
            if margin.getName() == name:
                return margin
        return None