Converts the name instance to a pyqode.core.share.Definition
339882
def to_definition(self):
        
        icon = {
            Name.Type.Root: icons.ICON_MIMETYPE,
            Name.Type.Division: icons.ICON_DIVISION,
            Name.Type.Section: icons.ICON_SECTION,
            Name.Type.Variable: icons.ICON_VAR,
            Name.Type.Paragraph: icons.ICON_FUNC
        }[self.node_type]
        d = Definition(self.name, self.line, self.column, icon, self.description)
        for ch in self.children:
            d.add_child(ch.to_definition())
        return d
148207
def define(collection_name, element_name = nil)
      element_name ||= singular(collection_name, element_name)
      create_collection_class(collection_name.to_s.capitalize)
      create_element_class(collection_name.to_s.capitalize, element_name.capitalize)

      # def subnets
      #   @subnets ||= Foggy::Networking::Subnets.new("subnet")
      # end
      klass = self.const_get(collection_name.capitalize)
      define_method("#{collection_name}") do
        unless instance_variable_defined?("@#{collection_name}")
          instance_variable_set("@#{collection_name}", klass.new(element_name))
        end
        return instance_variable_get("@#{collection_name}")
      end
    end
651728
def from_name(cls, name):
        
        disks = cls.list({'name': name})
        if len(disks) == 1:
            return disks[0]['id']
        elif not disks:
            return

        raise DuplicateResults('disk name %s is ambiguous.' % 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
1154737
def from_name(cls, name):
        """"""
        result = cls.list()
        dc_names = {}
        for dc in result:
            dc_names[dc['name']] = dc['id']

        return dc_names.get(name)
140008
def serialize_instance(instance):
    
    model_name = force_text(instance._meta)
    return '{}:{}'.format(model_name, instance.pk)
882531
def setName(self, name):
        
        self._name = name
        
        tree = self.treeWidget()
        if tree:
            col = tree.column('Name')
            if col != -1:
                self.setData(col, Qt.EditRole, wrapVariant(name))
686772
def generate_filename(self, instance, filename):
        
        from unidecode import unidecode

        return super().generate_filename(instance, unidecode(force_text(filename)))
155774
def share_with_names(self):
        """"""
        for container in self.share_with:
            if isinstance(container, six.string_types):
                yield container
            else:
                yield container.container_name
613712
def instance_get(attribute)
      getter = :"#{self.name}_#{attribute}"
      self.instance.send(getter) if instance.respond_to?(getter)
    end
546747
def with_name(self, name):
        """"""
        if not self.name:
            raise ValueError("%r has an empty name" % (self,))
        drv, root, parts = self._flavour.parse_parts((name,))
        if (not name or name[-1] in [self._flavour.sep, self._flavour.altsep]
                or drv or root or len(parts) != 1):
            raise ValueError("Invalid name %r" % (name))
        return self._from_parsed_parts(self._drv, self._root,
                                       self._parts[:-1] + [name])
413916
def instantiate_by_name(self, object_name):
        
        if object_name not in self.instances:
            instance = self.instantiate_from_data(self.environment[object_name])

            self.instances[object_name] = instance
            return instance
        else:
            return self.instances[object_name]
1236189
def compact_qname(ns_stack, name)
      return name if name.is_a?(String)

      local_part, prefix, uri = name
      raise "invalid name: #{name}" if !prefix && uri
      if prefix
        if prefix!="xmlns"
          ns = find_namespace_uri(ns_stack, prefix, uri)
          raise "namespace prefix not bound to a namespace: '#{prefix}'" if ! ns
        end
        [prefix, local_part].map{|s| s.to_s unless s.to_s.empty?}.compact.join(':')
      else
        local_part
      end
    end
396633
def namebase(self):
        
        base, ext = self.module.splitext(self.name)
        return base
779338
QName constructQName(XMLLibImpl lib, Context cx, Object namespace, Object name) {
        String nameString = null;
        if (name instanceof QName) {
            if (namespace == Undefined.instance) {
                return (QName)name;
            } else {
                nameString = ((QName)name).localName();
            }
        }
        if (name == Undefined.instance) {
            nameString = "";
        } else {
            nameString = ScriptRuntime.toString(name);
        }

        if (namespace == Undefined.instance) {
            if ("*".equals(nameString)) {
                namespace = null;
            } else {
                namespace = lib.getDefaultNamespace(cx);
            }
        }
        Namespace namespaceNamespace = null;
        if (namespace == null) {
            //    leave as null
        } else if (namespace instanceof Namespace) {
            namespaceNamespace = (Namespace)namespace;
        } else {
            namespaceNamespace = lib.newNamespace(ScriptRuntime.toString(namespace));
        }
        String q_localName = nameString;
        String q_uri;
        String q_prefix;
        if (namespace == null) {
            q_uri = null;
            q_prefix = null;    //    corresponds to undefined; see QName class
        } else {
            q_uri = namespaceNamespace.uri();
            q_prefix = namespaceNamespace.prefix();
        }
        return newQName(lib, q_uri, q_localName, q_prefix);
    }
778572
def name(self):
        
        name = self._element.name_val
        if name is None:
            return None
        return BabelFish.internal2ui(name)
195854
def rename(self, name):
        
        return self.client.api.rename(self.id, name)