Custom initial method:
            * ensure node exists and store it in an instance attribute
            * change queryset to return only devices of current node
514927
def initial(self, request, *args, **kwargs):
        
        super(NodeDeviceList, self).initial(request, *args, **kwargs)

        # ensure node exists
        try:
            self.node = Node.objects.published()\
                        .accessible_to(request.user)\
                        .get(slug=self.kwargs.get('slug', None))
        except Node.DoesNotExist:
            raise Http404(_('Node not found.'))

        # check permissions on node (for device creation)
        self.check_object_permissions(request, self.node)

        # return only devices of current node
        self.queryset = Device.objects.filter(node_id=self.node.id)\
                        .accessible_to(self.request.user)\
                        .select_related('node')
140842
def _device_node(self, device):
        """"""
        label = device.ui_label
        dev_label = device.ui_device_label
        # determine available methods
        methods = [Action(method, device,
                          self._labels[method].format(label, dev_label),
                          partial(self._actions[method], device))
                   for method in self._get_device_methods(device)]
        # find the root device:
        root = device.parent_object_path
        # in this first step leave branches empty
        return device.object_path, Device(root, [], device, dev_label, methods)
608640
def process_node(e):
    
    node = {'id': e['id'],
            'lat': e['lat'],
            'lon': e['lon']}

    if 'tags' in e:
        if e['tags'] is not np.nan:
            for t, v in list(e['tags'].items()):
                if t in config.settings.keep_osm_tags:
                    node[t] = v

    return node
677484
def wait_for_exists(self, timeout=0, *args, **selectors):
        
        return self.device(**selectors).wait.exists(timeout=timeout)
979988
def show_instance(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )

    items = query(action='ve', command=name)

    ret = {}
    for item in items:
        if 'text' in item.__dict__:
            ret[item.tag] = item.text
        else:
            ret[item.tag] = item.attrib

        if item._children:
            ret[item.tag] = {}
            children = item._children
            for child in children:
                ret[item.tag][child.tag] = child.attrib

    __utils__['cloud.cache_node'](ret, __active_provider_name__, __opts__)
    return ret
241302
def get_prefetch_queryset(self, instances, queryset=None):
        
        if queryset is None:
            queryset = self.get_queryset()
        queryset._add_hints(instance=instances[0])

        # CleanerVersion change 1: force the querytime to be the same as the
        # prefetched-for instance.
        # This is necessary to have reliable results and avoid extra queries
        # for cache misses when accessing the child objects from their
        # parents (e.g. choice.poll).
        instance_querytime = instances[0]._querytime
        if instance_querytime.active:
            if queryset.querytime.active and \
                            queryset.querytime.time != instance_querytime.time:
                raise ValueError(
                    "A Prefetch queryset that specifies an as_of time must "
                    "match the as_of of the base queryset.")
            else:
                queryset.querytime = instance_querytime

        # CleanerVersion change 2: make rel_obj_attr return a tuple with
        # the object's identity.
        # rel_obj_attr = self.field.get_foreign_related_value
        def versioned_fk_rel_obj_attr(versioned_rel_obj):
            return versioned_rel_obj.identity,

        rel_obj_attr = versioned_fk_rel_obj_attr
        instance_attr = self.field.get_local_related_value
        instances_dict = {instance_attr(inst): inst for inst in instances}
        # CleanerVersion change 3: fake the related field so that it provides
        # a name of 'identity'.
        # related_field = self.field.foreign_related_fields[0]
        related_field = namedtuple('VersionedRelatedFieldTuple', 'name')(
            'identity')

        # FIXME: This will need to be revisited when we introduce support for
        # composite fields. In the meantime we take this practical approach to
        # solve a regression on 1.6 when the reverse manager in hidden
        # (related_name ends with a '+'). Refs #21410.
        # The check for len(...) == 1 is a special case that allows the query
        # to be join-less and smaller. Refs #21760.
        if self.field.remote_field.is_hidden() or len(
                self.field.foreign_related_fields) == 1:
            query = {'%s__in' % related_field.name: set(
                instance_attr(inst)[0] for inst in instances)}
        else:
            query = {'%s__in' % self.field.related_query_name(): instances}
        queryset = queryset.filter(**query)

        # Since we're going to assign directly in the cache,
        # we must manage the reverse relation cache manually.
        if not self.field.remote_field.multiple:
            rel_obj_cache_name = self.field.remote_field.get_cache_name()
            for rel_obj in queryset:
                instance = instances_dict[rel_obj_attr(rel_obj)]
                setattr(rel_obj, rel_obj_cache_name, instance)

        if VERSION[:1] < (2,):
            return (queryset, rel_obj_attr, instance_attr, True,
                    self.field.get_cache_name())
        else:
            return (queryset, rel_obj_attr, instance_attr, True,
                    self.field.get_cache_name(), False)
313123
def has_custom_queryset(manager):
    ""
    old_diff = getattr(manager, 'get_query_set', None) != getattr(Manager, 'get_query_set', None)
    new_diff = getattr(manager, 'get_queryset', None) != getattr(Manager, 'get_queryset', None)
    return old_diff or new_diff
1013162
def show_instance(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )

    conn = get_conn()
    node = conn.show_instance(name).__dict__
    __utils__['cloud.cache_node'](node, __active_provider_name__, __opts__)
    return node
1056072
function fromQueryNode(query) {
  var node = query.attrs.node.split('#')[0];
  var caps = new Caps(node);
  var identities = query.getChildren('identity');
  var features = query.getChildren('feature');

  identities.forEach(function(id) {
    caps.addIdentity(id.attrs.category, id.attrs.type, id.attrs.name, id.attrs.lang);
  });
  features.forEach(function(feature) {
    caps.addFeature(feature.attrs.var);
  });

  return caps;
}
535468
static DeviceInfo initialize(Context context) {
        if (thisInstance_ == null) {
            thisInstance_ = new DeviceInfo(context);
        }
        return thisInstance_;
    }
591223
def __initialize_node(self, attributes_flags=int(Qt.ItemIsSelectable | Qt.ItemIsEnabled)):
        

        self["traced"] = umbra.ui.nodes.GraphModelAttribute(name="traced",
                                                            value=foundations.trace.is_traced(self.__module),
                                                            flags=attributes_flags)
        self.update_node_attributes()
410998
def __get_known_node_by_host(self, hostname):
        '''
        
        '''
        for n in self.nodes:
            if (n.name == hostname):
                return n
        return None
989252
def get_device_by_ain(self, ain):
        """"""
        devices = self.get_devices()
        for device in devices:
            if device.ain == ain:
                return device
468732
def init_process(self):
        

        for item in Device.objects.filter(protocol__daq_daemon=1, active=1, id__in=self.device_ids):
            try:
                tmp_device = item.get_device_instance()
                if tmp_device is not None:
                    self.devices[item.pk] = tmp_device
                    self.dt_set = min(self.dt_set, item.polling_interval)
                    self.dt_query_data = min(self.dt_query_data, item.polling_interval)
            except:
                var = traceback.format_exc()
                logger.error("exception while initialisation of DAQ Process for Device %d %s %s" % (
                    item.pk, linesep, var))

        return True
31902
def first_or_new(self, _attributes=None, **attributes):
        
        if _attributes is not None:
            attributes.update(_attributes)

        instance = self._query.where(attributes).first()

        if instance is None:
            instance = self._related.new_instance()
            self._set_foreign_attributes_for_create(instance)

        return instance
1337983
def first(self) -> "QuerySet":
        
        queryset = self._clone()
        queryset._limit = 1
        queryset._single = True
        return queryset
1269484
def update_or_create(self, attributes, values=None, joining=None, touch=True):
        
        if values is None:
            values = {}

        instance = self._query.where(attributes).first()

        if instance is None:
            return self.create(values, joining, touch)

        instance.fill(**values)

        instance.save({"touch": False})

        return instance