Sometimes the EPA likes to nest their models and tables -- model within
        a model within a model -- so this internal method tries to clear all
        that up.
420337
def _inception_table_links(self, href_list):
        
        tables = set()
        for link in href_list:
            if not link.startswith('http://'):
                link = self.agency_url + link
            html = urlopen(link).read()
            doc = lh.fromstring(html)
            area = doc.cssselect('map area')
            if area:
                # Then this is a model containing models.
                tables.update((a.attrib['href'] for a in area))
            else:
                # The link is a table without additional models.
                tables.update(link)
        return tables
1341319
private function processPasteTopAfterModel(CollectionInterface $models, ModelIdInterface $parent = null)
    {
        if ($parent && $models->count()) {
            $manualSorting = ViewHelpers::getManualSortingProperty($this->getEnvironment());

            if ($manualSorting) {
                $this->pasteTop($models, $manualSorting, $parent);

                return;
            }

            $dataProvider = $this->getEnvironment()->getDataProvider();
            $dataProvider->saveEach($models);

            $this->triggerPostPasteModel($models);
            $this->clearModelCollection($models);
        }
    }
747406
public OrganizationModel attachOrganization(OrganizationModel organizationModel, ArchiveModel archiveModel)
    {
        for (OrganizationModel existingOrganizationModel : archiveModel.getOrganizationModels())
        {
            if (existingOrganizationModel.equals(organizationModel))
                return organizationModel;
        }
        organizationModel.addArchiveModel(archiveModel);
        return organizationModel;
    }
1355412
def _cleanup(self, ref):
        ''
        self.transitor_states[self._weakref_holder[ref]] -= 1
        del self._weakref_holder[ref]
892548
protected function deleteModels(): void
    {
        $model = app($this->modelClass);
        // determine if the model uses `SoftDeletes` trait
        $usesSoftDeletes = in_array(SoftDeletes::class, class_uses($model));

        foreach ($model->all() as $value) {
            try {
                if ($usesSoftDeletes) {
                    $value->forceDelete();
                } else {
                    $value->delete();
                }
            } catch (Exception $exception) {
                Log::warning(sprintf('Error during deleting models. Table: %s. Error: %s', $model->getTable(), $exception->getMessage()));
            }
        }
    }
1256111
function (model, options, callback) {
                var schema = model.schema,
                    subModels = [],
                    type,
                    subCollection,
                    subModel,
                    addSubModel = function (model) {
                        subModels.push(model);
                    };

                for (var reference in schema) {
                    if (schema.hasOwnProperty(reference)) {
                        type = schema[reference];
                        if (type.classof) {
                            // TODO: remove $nestedModels and use options to specify, which subModels should also be saved
                            // This depends on the changes of the model.
                            // If the submodels haven't changed, than there is no need to save sub models/collections.
                            if (type.classof(Model)) {
                                subModel = model.$[reference];
                                if (subModel && _.include(model.$nestedModels, reference)) {
                                    subModels.push(subModel);
                                }
                            } else if (type.classof(Collection)) {
                                subCollection = model.$[reference];
                                if (subCollection) {
                                    subCollection.each(addSubModel);
                                }
                            }
                        }

                    }
                }

                flow()
                    .parEach(subModels, function (model, cb) {
                        model.save(options, cb);
                    })
                    .exec(callback);
            }
941087
function(models, options) {
      models  || (models = []);
      options || (options = {});
      this.each(this._removeReference);
      this._reset();
      this.add(models, {silent: true});
      if (!options.silent) this.trigger('reset', this, options);
      return this;
    }
28964
def clear_model(model, dry_run=True, verbosity=1):
    '''
    '''
    N_existing = model.objects.count()
    if dry_run:
        print "DRY_RUN: NOT deleting %d records in %r." % (model.objects.all().count(), model)
    if N_existing:
        ans = 'y'
        if verbosity and not dry_run:
            ans = raw_input('Are you sure you want to delete all %d existing database records in %r? (y/n) ' % (N_existing, model))
        if ans.lower().startswith('y') and not dry_run:
            model.objects.all().delete()
        return N_existing - model.objects.count()
    return 0
622577
def adapt_step_table!(parsed_step_table, gathered_comments)
      # Saving off the original data
      parsed_step_table['cuke_modeler_parsing_data'] = Marshal::load(Marshal.dump(parsed_step_table['rows']))

      # Removing parsed data for child elements in order to avoid duplicating data
      parsed_step_table['cuke_modeler_parsing_data'].clear


      parsed_step_table['line'] = parsed_step_table['rows'].first['line']

      parsed_step_table['rows'].each do |row|
        adapt_table_row!(row, gathered_comments)
      end
    end
400090
def remove(self, models):
        
        models = self._check_model_types(models)
        for model in models:
            if model in self._selected:
                self._selected.remove(model)
1304342
def set_model(self, model):
        
        # do the set model in reverse!
        # set model might trigger an update for the lower levels
        # but the lower ones have a different model, so it will fail anyways
        # this way the initial state after set_model is correct.
        self.model = model
        self._levels[0].set_model(model)
147563
public function removeAll()
    {
        foreach ($this->_associated_objects as $parent_property => $object) {
            /**
             * @var Model
             */
            $object->setDirty($parent_property);
        }
        $this->exchangeArray([]);
    }
208117
def recover_model_from_data(model_class, original_data, modified_data, deleted_data):
    
    model = model_class()
    return set_model_internal_data(model, original_data, modified_data, deleted_data)
708326
function(callback) {
      stageModels(app, models, function(err) {
        models.pop(); // remove snapshot model
        models.pop(); // remove optimizedData model
        callback(err);
      });
    }
741859
def clear_subjects
      model_properties = properties

      (model_properties - model_properties.key | relationships).each do |subject|
        next unless subject.loaded?(self)
        remove_instance_variable(subject.instance_variable_name)
      end
    end
607682
function(models){
        var currentLen = this.length;

        // Cloning after converting to an Array because it should be dereferenced
        // in order to continue the while loop when erasing from this._models
        models = Array.from(models).slice();

        this.act(function(){
            var l = models.length,
                i = 0;

            while(l--){
                this._remove(models[i++]);
            }
        });

        // Signal change when the collection of models change
        if (!this.isActive() && this._changed) {
             this.signalChange();

             this.resetChange();
        }

        return this;
    }
788938
def nested_model(model, nested_fields):
    
    # type: (ModelBase, Any)->Optional[AppModel]
    if model is None:
        return None

    app_model = model.get_app_model()
    is_dict = isinstance(nested_fields, dict)

    for field in nested_fields:
        field = get_nested_field_name(field)

        nested_nested = nested_fields.get(
            field) if is_dict and nested_fields.get(field) else []
        value = getattr(model, field, None)

        # we can have also lists in field
        nm_fn = nested_models if isinstance(value, list) else nested_model

        setattr(app_model, field, nm_fn(value, nested_nested))

    return app_model