Save current position into file
495538
def _save_file_and_pos(self):
        
        if not self._pos_changed:
            return
        with open(self.pos_storage_filename, 'w+') as f:
            _pos = '%s:%s' % (self._log_file, self._log_pos)
            _logger.debug('Saving position %s to file %s'
                          % (_pos, self.pos_storage_filename))
            f.write(_pos)
            self._pos_changed = False
369595
def update_position(self):
        ''''''
        state = self.state
        pos = self.mouse_pos
        newtext = ''
        alt = 0
        if pos is not None:
            (lat,lon) = self.coordinates(pos.x, pos.y)
            newtext += 'Cursor: %f %f (%s)' % (lat, lon, mp_util.latlon_to_grid((lat, lon)))
            if state.elevation:
                alt = self.ElevationMap.GetElevation(lat, lon)
                if alt is not None:
                    newtext += ' %.1fm' % alt
        state.mt.set_download(state.download)
        pending = 0
        if state.download:
            pending = state.mt.tiles_pending()
        if pending:
            newtext += ' Map Downloading %u ' % pending
        if alt == -1:
            newtext += ' SRTM Downloading '
        newtext += '\n'
        if self.click_pos is not None:
            newtext += 'Click: %f %f (%s %s) (%s)' % (self.click_pos[0], self.click_pos[1],
                                                      mp_util.degrees_to_dms(self.click_pos[0]),
                                                      mp_util.degrees_to_dms(self.click_pos[1]),
                                                      mp_util.latlon_to_grid(self.click_pos))
        if self.last_click_pos is not None:
            distance = mp_util.gps_distance(self.last_click_pos[0], self.last_click_pos[1],
                                            self.click_pos[0], self.click_pos[1])
            bearing = mp_util.gps_bearing(self.last_click_pos[0], self.last_click_pos[1],
                                            self.click_pos[0], self.click_pos[1])
            newtext += '  Distance: %.1fm Bearing %.1f' % (distance, bearing)
        if newtext != state.oldtext:
            self.position.Clear()
            self.position.WriteText(newtext)
            state.oldtext = newtext
33700
def set_to_current(self, ):
        
        cur = self.get_current_file()
        if cur is not None:
            self.set_selection(cur)
        else:
            self.init_selection()
443295
def append_position(path, position, separator=''):
    
    filename, extension = os.path.splitext(path)
    return ''.join([filename, separator, str(position), extension])
400489
def copy_current_file_offset():
    """"""
    start, end = sark.get_selection()

    try:
        file_offset = sark.core.get_fileregion_offset(start)
        clipboard.copy("0x{:08X}".format(file_offset))

    except sark.exceptions.NoFileOffset:
        message("The current address cannot be mapped to a valid offset of the input file.")
1321569
function saveAsFile(editor, data, range) {
	return new Promise((resolve, reject) => {
		const fileName = atom.getCurrentWindow().showSaveDialog();
		if (!fileName) {
			return reject(new Error('User cancelled file dialog'));
		}

		fs.writeFile(fileName, Buffer.from(data, 'base64'), err => {
			if (err) {
				return reject(err);
			}

			const editorPath = editor.getPath();
			let displayPath = editorPath
				? path.relative(editorPath, fileName)
				: `file://${fileName}`;

			editor.transact(() => {
				// Convert Windows path separators to Unix
				editor.setTextInBufferRange(range, displayPath.replace(/\\+/g, '/'));
			});

			resolve(fileName);
		});
	});
}
439887
def save_as(self):
        """"""
        editorstack = self.get_current_editorstack()
        if editorstack.save_as():
            fname = editorstack.get_current_filename()
            self.__add_recent_file(fname)
193784
def move_to_limit(self, position):
        
        cmd = 'MOVE', [Float, Integer]
        self._write(cmd, position, 1)
888528
def _save(self, objects, old_pos, new_pos):
        """"""
        to_shift = objects.exclude(pk=self.pk) if self.pk else objects

        # If not set, insert at end.
        if self.sort_order is None:
            self._move_to_end(objects)

        # New insert.
        elif not self.pk and not old_pos:
            # Increment `sort_order` on objects with:
            #     sort_order > new_pos.
            to_shift = to_shift.filter(sort_order__gte=self.sort_order)
            self._update(to_shift)
            self.sort_order = new_pos

        # self.sort_order decreased.
        elif old_pos and new_pos < old_pos:
            self._move_to_end(objects)
            super(Orderable, self).save()
            # Increment `sort_order` on objects with:
            #     sort_order >= new_pos and sort_order < old_pos
            to_shift = to_shift.filter(sort_order__gte=new_pos, sort_order__lt=old_pos)
            self._update(to_shift)
            self.sort_order = new_pos

        # self.sort_order increased.
        elif old_pos and new_pos > old_pos:
            self._move_to_end(objects)
            super(Orderable, self).save()
            # Decrement sort_order on objects with:
            #     sort_order <= new_pos and sort_order > old_pos.
            to_shift = to_shift.filter(sort_order__lte=new_pos, sort_order__gt=old_pos)
            to_shift.update(sort_order=models.F('sort_order') - 1)
            self.sort_order = new_pos
866166
def set_position(self, position):
        """"""
        if position < 0:
            position += len(self.checkdefs)
        while position >= len(self.checkdefs):
            self.checkdefs.append(([], []))
        self.position = position
258285
def go_to_position(self, position):
        

        cursor = self.textCursor()
        cursor.setPosition(position)
        self.setTextCursor(cursor)
        return True
1049224
def save_object(fname, obj):
    """"""

    fd = gzip.open(fname, "wb")
    six.moves.cPickle.dump(obj, fd)
    fd.close()
915576
def location(self, x=None, y=None):
        ''' 
        '''
        stream = self._stream
        stream.write(self.save_pos)  # cursor position

        if x is not None and y is not None:
            stream.write(self.mv(y, x))
        elif x is not None:
            stream.write(self.mv_x(x))
        elif y is not None:
            stream.write(self.mv_y(y))

        stream.flush()
        try:
            yield self
        finally:
            stream.write(self.rest_pos)
            stream.flush()
1199390
private void moveTo(int position) {
    while (position >= currentPosition) {
      try {
        currentPosition = ignoreSpans.nextStartPosition();
        if (currentPosition != Spans.NO_MORE_POSITIONS
            && currentPosition >= minimumPosition) {
          if (!baseEndPositionList.containsKey(currentPosition)) {
            baseEndPositionList.put(currentPosition, new HashSet<Integer>());
            maxBaseEndPosition.put(currentPosition, currentPosition);
          } else {
            maxBaseEndPosition.put(currentPosition,
                Math.max(maxBaseEndPosition.get(currentPosition),
                    ignoreSpans.endPosition()));
          }
          if (!baseStartPositionList.containsKey(ignoreSpans.endPosition())) {
            baseStartPositionList.put(ignoreSpans.endPosition(),
                new HashSet<Integer>());
            minBaseStartPosition.put(ignoreSpans.endPosition(),
                ignoreSpans.endPosition());
          } else {
            minBaseStartPosition.put(ignoreSpans.endPosition(),
                Math.min(minBaseStartPosition.get(ignoreSpans.endPosition()),
                    currentPosition));
          }
          baseStartPositionList.get(ignoreSpans.endPosition())
              .add(currentPosition);
          baseEndPositionList.get(currentPosition)
              .add(ignoreSpans.endPosition());
        }
      } catch (IOException e) {
        log.debug(e);
        currentPosition = Spans.NO_MORE_POSITIONS;
        break;
      }
    }
  }
71660
def save_to_file(self, filename_prefix):
    """"""
    # Wrap in single quotes to make it easier to see the full subword when
    # it has spaces and make it easier to search with ctrl+f.
    filename = self._filename(filename_prefix)
    lines = ["'%s'" % s for s in self._subwords]
    self._write_lines_to_file(filename, lines)
721099
def save_point(self) -> str:
        
        if self._current_mount is left:
            msg = self.save_mount_offset()
            self._current_mount = right
        elif self._current_mount is types.Mount.LEFT:
            msg = self.save_mount_offset()
            self._current_mount = types.Mount.RIGHT
        else:
            pos = self._position()[:-1]
            self.actual_points[self._current_point] = pos
            log.debug("Saving {} for point {}".format(
                pos, self._current_point))
            msg = 'saved #{}: {}'.format(
                self._current_point, self.actual_points[self._current_point])
        return msg
337762
def save_positions(post_data, queryset=None):
    
    if not queryset:
        queryset = ObjectPosition.objects.all()
    for key in post_data:
        if key.startswith('position-'):
            try:
                obj_id = int(key.replace('position-', ''))
            except ValueError:
                continue
            queryset.filter(pk=obj_id).update(position=post_data[key])