Marks the instance as ACTIVE and current active instance (if exists) as ARCHIVE
488550
protected function make_active() {
        global $DB;
        if ($this->data->status == self::INSTANCE_STATUS_ACTIVE) {
            // already active
            return;
        }
        if (empty($this->data->itemid)) {
            throw new coding_exception('You cannot mark active the grading instance without itemid');
        }
        $currentid = $this->get_controller()->get_current_instance($this->data->raterid, $this->data->itemid, true);
        if ($currentid && $currentid != $this->get_id()) {
            $DB->update_record('grading_instances', array('id' => $currentid, 'status' => self::INSTANCE_STATUS_ARCHIVE));
        }
        $DB->update_record('grading_instances', array('id' => $this->get_id(), 'status' => self::INSTANCE_STATUS_ACTIVE));
        $this->data->status = self::INSTANCE_STATUS_ACTIVE;
    }
84290
def mark_as_inactive(self, kid):
        
        k = self.get_key_with_kid(kid)
        k.inactive_since = time.time()
6356
def is_active(self, key, *instances, **kwargs):
        
        default = kwargs.pop('default', False)

        # Check all parents for a disabled state
        parts = key.split(':')
        if len(parts) > 1:
            child_kwargs = kwargs.copy()
            child_kwargs['default'] = None
            result = self.is_active(':'.join(parts[:-1]), *instances, **child_kwargs)

            if result is False:
                return result
            elif result is True:
                default = result

        try:
            switch = self[key]
        except KeyError:
            # switch is not defined, defer to parent
            return default

        if switch.status == GLOBAL:
            return True
        elif switch.status == DISABLED:
            return False
        elif switch.status == INHERIT:
            return default

        conditions = switch.value
        # If no conditions are set, we inherit from parents
        if not conditions:
            return default

        if instances:
            # HACK: support request.user by swapping in User instance
            instances = list(instances)
            for v in instances:
                if isinstance(v, HttpRequest) and hasattr(v, 'user'):
                    instances.append(v.user)

        # check each switch to see if it can execute
        return_value = False

        for switch in self._registry.itervalues():
            result = switch.has_active_condition(conditions, instances)
            if result is False:
                return False
            elif result is True:
                return_value = True

        # there were no matching conditions, so it must not be enabled
        return return_value
1282638
def file_archive(class_obj: type) -> type:
    
    assert isinstance(class_obj, type), "class_obj is not a Class"
    global _file_archive_resource_type
    _file_archive_resource_type = class_obj
    return class_obj
1236194
def archive(cls):
    """"""
    req = datastore.BeginTransactionRequest()
    resp = datastore.begin_transaction(req)
    tx = resp.transaction
    req = datastore.RunQueryRequest()
    req.read_options.transaction = tx
    q = req.query
    set_kind(q, kind='Todo')
    add_projection(q, '__key__')
    set_composite_filter(q.filter,
                         datastore.CompositeFilter.AND,
                         set_property_filter(
                             datastore.Filter(),
                             'done', datastore.PropertyFilter.EQUAL, True),
                         set_property_filter(
                             datastore.Filter(),
                             '__key__', datastore.PropertyFilter.HAS_ANCESTOR,
                             default_todo_list.key))
    resp = datastore.run_query(req)
    req = datastore.CommitRequest()
    req.transaction = tx
    for result in resp.batch.entity_results:
      req.mutations.add().delete.CopyFrom(result.entity.key)
    resp = datastore.commit(req)
    return ''
312486
def has_active_condition(self, condition, instances):
        
        return_value = None
        for instance in instances + [None]:
            if not self.can_execute(instance):
                continue
            result = self.is_active(instance, condition)
            if result is False:
                return False
            elif result is True:
                return_value = True
        return return_value
99124
def is_archive(self):
        '''
            
        '''
        try:
            if zipfile.is_zipfile(self.attachment.path) or tarfile.is_tarfile(self.attachment.path):
                return True
        except Exception:
            pass
        return False
1170409
public static function current_archived_stage()
    {
        $parts = explode('.', Versioned::get_reading_mode());
        if (sizeof($parts) === 3 && $parts[0] == 'Archive') {
            return $parts[2];
        }
        return static::DRAFT;
    }
514653
def open(self):
        '''
        
        '''
        if self.__arch is not None:
            raise salt.exceptions.SaltException('Archive already opened.')
        self.__arch = tarfile.TarFile.bz2open(self.archive_path, 'w')
1111628
def last_archive(self):
        '''
        
        '''
        archives = {}
        for archive in self.archives():
            archives[int(archive.split('.')[0].split('-')[-1])] = archive

        return archives and archives[max(archives)] or None
1245938
def is_active(self, name):
        
        if name in self._plugins.keys():
            return self._plugins["name"].active
        return None
1215486
def create_archive(
            self,
            archive_name,
            authority_name,
            archive_path,
            versioned,
            raise_on_err=True,
            metadata=None,
            user_config=None,
            tags=None,
            helper=False):
        '''
        

        '''

        archive_metadata = self._create_archive_metadata(
            archive_name=archive_name,
            authority_name=authority_name,
            archive_path=archive_path,
            versioned=versioned,
            raise_on_err=raise_on_err,
            metadata=metadata,
            user_config=user_config,
            tags=tags,
            helper=helper)

        if raise_on_err:
            self._create_archive(
                archive_name,
                archive_metadata)
        else:
            self._create_if_not_exists(
                archive_name,
                archive_metadata)

        return self.get_archive(archive_name)
993006
def _save_archive(self):
        
        import json
        from utility import json_serial
        with open(self.archpath, 'w') as f:
            json.dump(self.archive, f, default=json_serial)
895244
def create(
        ctx,
        archive_name,
        authority_name,
        versioned=True,
        tag=None,
        helper=False):
    '''
    
    '''

    tags = list(tag)

    _generate_api(ctx)
    args, kwargs = _parse_args_and_kwargs(ctx.args)
    assert len(args) == 0, 'Unrecognized arguments: "{}"'.format(args)

    var = ctx.obj.api.create(
        archive_name,
        authority_name=authority_name,
        versioned=versioned,
        metadata=kwargs,
        tags=tags,
        helper=helper)

    verstring = 'versioned archive' if versioned else 'archive'
    click.echo('created {} {}'.format(verstring, var))
1057628
def archive(self):
        

        self._client._put(
            "{0}/archived".format(
                self.__class__.base_url(
                    self.sys['space'].id,
                    self.sys['id'],
                    environment_id=self._environment_id
                ),
            ),
            {},
            headers=self._update_headers()
        )

        return self.reload()
660305
def _record_last_active(self, host):
        
        if host in self.hosts:  # this check is for when user passes a host at request time
            # Keep this thread safe: set hosts atomically and update it before the timestamp
            self.hosts = [host] + [h for h in self.hosts if h != host]
            self._last_time_recorded_active = time.time()
93483
def _get_archive_listing(self, archive_name):
        '''
        
        '''

        res = self.collection.find_one({'_id': archive_name})

        if res is None:
            raise KeyError

        return res