Save dev state to file

 === Return
 true:: Always return true
555135
def save_state
      # start will al state to be saved
      state_to_save = { 'startup_tags' => startup_tags,
                      'reboot' => reboot?,
                      'log_level' => log_level }

      # only save a log file one is defined
      if log_file
        state_to_save['log_file'] = log_file
      end

      # only save persist the fact we downloaded cookbooks if we are in dev mode
      if download_once?
        state_to_save['has_downloaded_cookbooks'] = has_downloaded_cookbooks?
      end

      RightScale::JsonUtilities::write_json(RightScale::CookState::STATE_FILE, state_to_save)
      true
    end
262989
def save(options = {})
      _run_save_callbacks do 
        raise GitModel::NullId unless self.id

        if new_record?
          raise GitModel::RecordExists if self.class.exists?(self.id)
        else
          raise GitModel::RecordDoesntExist unless self.class.exists?(self.id)
        end

        GitModel.logger.debug "Saving #{self.class.name} with id: #{id}"

        dir = File.join(self.class.db_subdir, self.id)

        transaction = options.delete(:transaction) || GitModel::Transaction.new(options) 
        result = transaction.execute do |t|
          # Write the attributes to the attributes file
          t.index.add(File.join(dir, 'attributes.json'), Yajl::Encoder.encode(attributes, nil, :pretty => true))

          # Write the blob files
          blobs.each do |name, data|
            t.index.add(File.join(dir, name), data)
          end
        end

        if result
          @path = dir
          @branch = transaction.branch
          @new_record = false
        end

        result
      end
    end
541365
def saveas name=nil, config={}
      unless name
        name = rb_gets "File to save as: "
        return if name.nil? || name == ""
      end
      overwrite_if_exists = config[:overwrite_if_exists] || false
      unless overwrite_if_exists
        exists = File.exists? name
        if exists # need to prompt
          return unless rb_confirm("Overwrite existing file? ")
        end
      end
      # if it has been set do not prompt. or ask only if value is :ask
      # But this should only be if there is someformatting provided, that is there 
      # is a @document
      l = @list
      # the check for document is to see if it is some old widget like textarea that is calling this.
      if @document
        if config.key? :save_with_formatting
          save_with_formatting = config[:save_with_formatting] 
        else
          save_with_formatting = rb_confirm("Save with formatting?")
        end
        if save_with_formatting
          l = @list
        else
          l = @document.native_text().map do |w| w.to_s ; end
        end
      end
      #l = getvalue
      File.open(name, "w"){ |f|
        l.each { |line| f.puts line }
        #l.each { |line| f.write line.gsub(/\r/,"\n") }
      }
      rb_puts "#{name} written."
    end
489737
public function save()
	{
		if (self::$file_added)
			file_put_contents($this->getFileListName(), '<?php return ' . var_export(self::$files[$this->prefix], true) . ';');

		self::$file_added = false;
	}
350228
function save() {

		if ($this->cacheConf['type'] == 'noop') {
			// do nothing
		}
		else { // non-noop

			$stateCopy = $this->state;
			$stateCopy['loaded'] = [];

			if ($this->cacheConf['type'] == 'file') {
				$username = \get_current_user();
				$cacheDir = realpath($this->syspath.'/'.\trim($this->cacheConf['path'], '\\/'));
				$cachePath = $cacheDir.'/freia.'.(\php_sapi_name() === 'cli' ? 'cli' : 'server').'.'.$username.'.symbols.json';
				if ($this->file_exists($cacheDir)) {
					try {
						$this->file_put_contents($cachePath, \json_encode($stateCopy, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
						if ( ! $this->chmod($cachePath, $this->filePermission())) {
							$this->error_log("Unable to set permissions on cache file: $cachePath");
						}
					}
					catch (\Exception $e) {
						$this->error_log('Failed to save state to cache file ['.$cachePath.'] Error: '.$e->getMessage());
					}
				}
				else {
					$this->error_log('Missing cache directory: '.$this->cacheConf['path']);
				}
			}
			else if ($this->cacheConf['type'] == 'memcached') {
				$mc = $this->memcachedInstance();
				$success = $mc->set('freia-symbols', $stateCopy, time() + 604800);
				if ( ! $success) {
					$this->error_log("Memcached failed to store key freia-symbols, code: ".$mc->getResultCode());
				}
			}
		}
	}
311399
def save(self, source: IO):
        
        write = source.write

        write(pack(
            '>IHH',
            ClassFile.MAGIC,
            self.version.minor,
            self.version.major
        ))

        self._constants.pack(source)

        write(self.access_flags.pack())
        write(pack(
            f'>HHH{len(self._interfaces)}H',
            self._this,
            self._super,
            len(self._interfaces),
            *self._interfaces
        ))

        self.fields.pack(source)
        self.methods.pack(source)
        self.attributes.pack(source)
196035
def save(self):
        
        self.projects.save()
        self.experiments.save()
        safe_dump(self.global_config, self._globals_file,
                  default_flow_style=False)
94451
def savestate(self, state):
        """"""
        oldstate = np.get_printoptions()
        np.set_printoptions(threshold=1e6)
        try:
            with open(os.path.join(self._directory, 'state.txt'), 'w') as f:
                print_(state, file=f)
        finally:
            np.set_printoptions(**oldstate)
302422
public function save()
    {
        // No payload to save.
        if (! $this->hasPayLoad()) {
            return false;
        }

        // Save the token.
        return (bool) file_put_contents($this->getFilePath(), collect($this->payLoad)->toJson(), LOCK_EX);
    }
1052369
def save(self):
        """"""
        self._connection.run(['change', '-i'], stdin=format(self), marshal_output=False)
        self._dirty = False
1087051
def save(opts={})
    options = { :validate => true }.merge(opts)
    return false if !(new_record? || changed?)
    if options[:validate]
      return false if !valid?
    end
    begin
      save!(options)
    rescue
      return false
    end
    true
  end
494465
public function save()
    {
        $this->load();
        // Do the work in case we have only changed hash
        if ($this->isChanged()) {
            @chmod($this->path, 0777);
            return file_put_contents($this->path, $this->fileType->render($this->config));
        } else {
            return true;
        }
    }
648076
def save(self, path, binary=False):
        
        if binary:
            ret = lib.EnvBsave(self._env, path.encode())
        else:
            ret = lib.EnvSave(self._env, path.encode())
        if ret == 0:
            raise CLIPSError(self._env)
494450
def _save_upload_state_to_file(self):
        
        if os.access(self.file_dir, os.W_OK | os.R_OK | os.X_OK):
            save_file = self.file + '.upload'
            data = {
                'upload_token': self.upload_token,
                'upload_server_ip': self.upload_server_ip
            }
            with open(save_file, 'w') as f:
                json.dump(data, f)
743617
public function save()
    {

        // Create config folder if it does not exist.
        $fs = new Filesystem();
        $dumper = new Dumper();

        if (!$fs->exists(getenv('HOME').'/.terra')) {
            try {
                $fs->mkdir(getenv('HOME').'/.terra/apps');
            } catch (IOExceptionInterface $e) {
                return false;
            }
        }

        try {
            $fs->dumpFile(getenv('HOME').'/.terra/terra', $dumper->dump($this->config, 10));

            return true;
        } catch (IOExceptionInterface $e) {
            return false;
        }
    }
221807
def save(path, params = {})
            options =
            {
                delinearize: true,
                recompile: true,
                decrypt: false
            }
            options.update(params)

            if self.frozen? # incompatible flags with frozen doc (signed)
                options[:recompile] =
                options[:rebuild_xrefs] =
                options[:noindent] =
                options[:obfuscate] = false
            end

            if path.respond_to?(:write)
                fd = path
            else
                path = File.expand_path(path)
                fd = File.open(path, 'w').binmode
                close = true
            end

            load_all_objects unless loaded?

            intents_as_pdfa1 if options[:intent] =~ /pdf[\/-]?A1?/i
            self.delinearize! if options[:delinearize] and self.linearized?
            compile(options) if options[:recompile]

            fd.write output(options)
            fd.close if close

            self
        end
404550
def save_to_file(self, path, human=True):
        
        write_file(path, self.dump(human))
        slog.info("Save %a done.", path)