Save metadata of last api call.
347290
def metadata_wrapper(fn):
        """"""
        @functools.wraps(fn)
        def wrapped_f(self, *args, **kwargs):
            self.last_metadata = {}
            self.last_metadata["url"] = self.configuration.host + args[0]
            self.last_metadata["method"] = args[1]
            self.last_metadata["timestamp"] = time.time()
            try:
                return fn(self, *args, **kwargs)
            except Exception as e:
                self.last_metadata["exception"] = e
                raise
        return wrapped_f
900163
def save_metadata(self):
        """"""
        metadata = self.field_mapping_widget.get_field_mapping()
        for key, value in list(metadata['fields'].items()):
            # Delete the key if it's set to None
            if key in self.metadata['inasafe_default_values']:
                self.metadata['inasafe_default_values'].pop(key)
            if value is None or value == []:
                if key in self.metadata['inasafe_fields']:
                    self.metadata['inasafe_fields'].pop(key)
            else:
                self.metadata['inasafe_fields'][key] = value

        for key, value in list(metadata['values'].items()):
            # Delete the key if it's set to None
            if key in self.metadata['inasafe_fields']:
                self.metadata['inasafe_fields'].pop(key)
            if value is None:
                if key in self.metadata['inasafe_default_values']:
                    self.metadata['inasafe_default_values'].pop(key)
            else:
                self.metadata['inasafe_default_values'][key] = value

        # Save metadata
        try:
            self.keyword_io.write_keywords(
                layer=self.layer, keywords=self.metadata)
        except InaSAFEError as e:
            error_message = get_error_message(e)
            # noinspection PyCallByClass,PyTypeChecker,PyArgumentList
            QMessageBox.warning(
                self, self.tr('InaSAFE'),
                ((self.tr(
                    'An error was encountered when saving the following '
                    'keywords:\n %s') % error_message.to_html())))

        # Update setting fir recent value
        if self.metadata.get('inasafe_default_values'):
            for key, value in \
                    list(self.metadata['inasafe_default_values'].items()):
                set_inasafe_default_value_qsetting(
                    self.setting, key, RECENT, value)
1039288
def lastLogged(self):
        """"""
        d = copy.deepcopy(self.__lastLogged)
        d.pop(-1, None)
        return d
859659
def objects_to_record(self):
        """"""

        o = self.get_object()

        o.about = self._bundle.metadata.about
        o.identity = self._dataset.identity.ident_dict
        o.names = self._dataset.identity.names_dict
        o.contacts = self._bundle.metadata.contacts

        self.set_object(o)
1161864
@Override
    public void endMetaData(MetaData metadata)
    {
        for (Listener listener : this.listeners) {
            listener.endMetaData(metadata);
        }
    }
481942
def write_artifacts_metadata(self):
        """"""
        if self.conf.artifacts_metadata_file:
            logger.info('Writing artifacts metadata to file "%s"',
                        self.conf.artifacts_metadata_file)
            with open(self.conf.artifacts_metadata_file, 'w') as fp:
                json.dump(self.artifacts_metadata, fp)
104121
protected function saveMetas()
    {
        $metas = '<?php return '.var_export($this->metas->getAll(), true).';';
        file_put_contents($this->getMetaFile(), $metas);
    }
289698
function(data, done) {
      if(!this._key) {
        done('no key found for metadata');
        return;
      }
      var key = data[this._key];
      var self = this;
      this._getCollection(function(err) {
        if(err) {
          done(err);
        }
        var kobj = {};
        kobj[self._key.getName()] = key;
        self._collection.find(kobj).toArray(function(err, docs) {
          if(docs.length > 0) {
            data._id = docs[0]._id;
          }
          self._collection.save(data, function(err, count) {
            self._db.close();
            done(err);
          });
        });
      });
    }
897206
def save_output_meta(self):
        
        options = self.options
        file_path = os.path.join(options.outputdir, 'output.meta.json')
        with open(file_path, 'w') as outfile:
            json.dump(self.OUTPUT_META_DICT, outfile)
43566
public function lastUpdatedDate() {
    $directory = $this->environment->getHooksDirectory();
    $hooks_file = "$directory/hooks_processed.php";
    if (file_exists($hooks_file)) {
      $timestamp = filemtime($hooks_file);
      return $timestamp;
    }
  }
605493
def load_metadata(stream):
    """"""
    try:
        metadata = json.load(
            stream, encoding='utf8', object_pairs_hook=OrderedDict)
    except json.JSONDecodeError as e:
        err = RuntimeError('Error parsing {}: {}'.format(stream.name, e))
        raise_from(err, e)
    else:
        # convert changelog keys back to ints for sorting
        for group in metadata:
            if group == '$version':
                continue
            apis = metadata[group]['apis']
            for api in apis.values():
                int_changelog = OrderedDict()
                for version, log in api.get('changelog', {}).items():
                    int_changelog[int(version)] = log
                api['changelog'] = int_changelog
    finally:
        stream.close()

    return metadata
824751
def save(cls, crawler, stage, level, run_id, error=None, message=None):
        """"""
        event = {
            'stage': stage.name,
            'level': level,
            'timestamp': pack_now(),
            'error': error,
            'message': message
        }
        data = dump_json(event)
        conn.lpush(make_key(crawler, "events"), data)
        conn.lpush(make_key(crawler, "events", level), data)
        conn.lpush(make_key(crawler, "events", stage), data)
        conn.lpush(make_key(crawler, "events", stage, level), data)
        conn.lpush(make_key(crawler, "events", run_id), data)
        conn.lpush(make_key(crawler, "events", run_id, level), data)
        return event
5890
def on_epoch_end(self, last_metrics, **kwargs):
        ""
        if not self.nums: return
        metrics = [self.metrics[name]/self.nums for name in self.names]
        return {'last_metrics': last_metrics+metrics}
223170
function(data, done) {
      if(!this._key) {
        done('no key found for metadata');
        return;
      }
      var key = data[this._key.getName()];
      var ix = -1;
      for(var i = 0; i < this._data.length; i++) {
        if(this._data[i][this._key.getName()] === key) {
          ix = i;
          break;
        }
      }
      if(ix === -1) {
        this._data.push(this._clone(data));
      } else {
        this._data[ix] = this._clone(data);
      }
      done(null);
    }
220793
def getLastModified(self):
        ""
        last_modified = self.headers.get('last-modified')
        if last_modified:
            last_modified = self.convertTimeString(last_modified)
        return last_modified
911869
def cache(self):
      """"""
      msg = 'Saving updates from more recent "%s" to "%s"'
      log.info(msg, self.filename, self.cachename)
      with open(self.cachename, 'wb') as output:
          cPickle.dump(self._dict, output, -1)
594374
def save(self):
        
        super(Samples, self).save()
        if self.metadata is not None:
            self.metadata.save()